summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/rendering/svg
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/svg')
-rw-r--r--Source/WebCore/rendering/svg/RenderSVGResource.cpp39
-rw-r--r--Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp4
-rw-r--r--Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp6
-rw-r--r--Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp4
-rw-r--r--Source/WebCore/rendering/svg/SVGInlineTextBox.cpp51
-rw-r--r--Source/WebCore/rendering/svg/SVGInlineTextBox.h4
-rw-r--r--Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp9
-rw-r--r--Source/WebCore/rendering/svg/SVGResources.cpp11
-rw-r--r--Source/WebCore/rendering/svg/SVGTextMetrics.cpp6
9 files changed, 86 insertions, 48 deletions
diff --git a/Source/WebCore/rendering/svg/RenderSVGResource.cpp b/Source/WebCore/rendering/svg/RenderSVGResource.cpp
index c0b16c5..12ed53a 100644
--- a/Source/WebCore/rendering/svg/RenderSVGResource.cpp
+++ b/Source/WebCore/rendering/svg/RenderSVGResource.cpp
@@ -51,33 +51,36 @@ static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode m
return 0;
}
- SVGPaint* paint = mode == ApplyToFillMode ? svgStyle->fillPaint() : svgStyle->strokePaint();
- ASSERT(paint);
-
- SVGPaint::SVGPaintType paintType = paint->paintType();
+ bool applyToFill = mode == ApplyToFillMode;
+ SVGPaint::SVGPaintType paintType = applyToFill ? svgStyle->fillPaintType() : svgStyle->strokePaintType();
if (paintType == SVGPaint::SVG_PAINTTYPE_NONE)
return 0;
Color color;
- if (paintType == SVGPaint::SVG_PAINTTYPE_RGBCOLOR
- || paintType == SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR
- || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR
- || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR)
- color = paint->color();
- else if (paintType == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paintType == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR)
- color = style->visitedDependentColor(CSSPropertyColor);
+ switch (paintType) {
+ case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR:
+ case SVGPaint::SVG_PAINTTYPE_RGBCOLOR:
+ case SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
+ case SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR:
+ case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR:
+ case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
+ color = applyToFill ? svgStyle->fillPaintColor() : svgStyle->strokePaintColor();
+ default:
+ break;
+ }
if (style->insideLink() == InsideVisitedLink) {
RenderStyle* visitedStyle = style->getCachedPseudoStyle(VISITED_LINK);
ASSERT(visitedStyle);
- if (SVGPaint* visitedPaint = mode == ApplyToFillMode ? visitedStyle->svgStyle()->fillPaint() : visitedStyle->svgStyle()->strokePaint()) {
- // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visitedColor'.
- if (visitedPaint->paintType() < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaint->paintType() != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) {
- const Color& visitedColor = visitedPaint->color();
- if (visitedColor.isValid())
- color = Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), color.alpha());
- }
+ const SVGRenderStyle* svgVisitedStyle = visitedStyle->svgStyle();
+ SVGPaint::SVGPaintType visitedPaintType = applyToFill ? svgVisitedStyle->fillPaintType() : svgVisitedStyle->strokePaintType();
+
+ // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visitedColor'.
+ if (visitedPaintType < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaintType != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) {
+ const Color& visitedColor = applyToFill ? svgVisitedStyle->fillPaintColor() : svgVisitedStyle->strokePaintColor();
+ if (visitedColor.isValid())
+ color = Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), color.alpha());
}
}
diff --git a/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
index c57f8b0..245a859 100644
--- a/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
+++ b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
@@ -254,8 +254,8 @@ bool RenderSVGResourceClipper::drawContentIntoMaskImage(ClipperData* clipperData
RefPtr<RenderStyle> oldRenderStyle = renderer->style();
RefPtr<RenderStyle> newRenderStyle = RenderStyle::clone(oldRenderStyle.get());
SVGRenderStyle* svgStyle = newRenderStyle.get()->accessSVGStyle();
- svgStyle->setFillPaint(SVGPaint::defaultFill());
- svgStyle->setStrokePaint(SVGPaint::defaultStroke());
+ svgStyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri());
+ svgStyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri());
svgStyle->setFillRule(newClipRule);
newRenderStyle.get()->setOpacity(1.0f);
svgStyle->setFillOpacity(1.0f);
diff --git a/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
index 1b14ce4..b82be1b 100644
--- a/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
+++ b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
@@ -233,10 +233,8 @@ bool RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer,
// Apply viewBox/objectBoundingBox transformations.
if (!viewBoxCTM.isIdentity())
tileImageTransform = viewBoxCTM;
- else if (attributes.boundingBoxModeContent()) {
- tileImageTransform.translate(objectBoundingBox.x(), objectBoundingBox.y());
+ else if (attributes.boundingBoxModeContent())
tileImageTransform.scale(objectBoundingBox.width(), objectBoundingBox.height());
- }
return true;
}
@@ -276,6 +274,8 @@ PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(RenderObject*
tileImageContext->concatCTM(tileImageTransform);
AffineTransform contentTransformation;
+ if (attributes.boundingBoxModeContent())
+ contentTransformation = tileImageTransform;
// Draw the content into the ImageBuffer.
for (Node* node = attributes.patternContentElement()->firstChild(); node; node = node->nextSibling()) {
diff --git a/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp
index 99ea763..d429bdc 100644
--- a/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp
+++ b/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp
@@ -26,7 +26,11 @@
#include "RenderStyle.h"
#include "SVGRenderSupport.h"
+<<<<<<< HEAD
#if PLATFORM(SKIA) && !PLATFORM(ANDROID)
+=======
+#if USE(SKIA)
+>>>>>>> WebKit at r80534
#include "PlatformContextSkia.h"
#endif
diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
index 52976f2..05e1357 100644
--- a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
+++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
@@ -47,7 +47,7 @@ SVGInlineTextBox::SVGInlineTextBox(RenderObject* object)
{
}
-int SVGInlineTextBox::offsetForPosition(int, bool) const
+int SVGInlineTextBox::offsetForPosition(float, bool) const
{
// SVG doesn't use the standard offset <-> position selection system, as it's not suitable for SVGs complex needs.
// vertical text selection, inline boxes spanning multiple lines (contrary to HTML, etc.)
@@ -76,7 +76,7 @@ int SVGInlineTextBox::offsetForPositionInFragment(const SVGTextFragment& fragmen
return fragment.positionListOffset - start() + textRenderer->scaledFont().offsetForPosition(textRun, position * scalingFactor, includePartialGlyphs);
}
-int SVGInlineTextBox::positionForOffset(int) const
+float SVGInlineTextBox::positionForOffset(int) const
{
// SVG doesn't use the offset <-> position selection system.
ASSERT_NOT_REACHED();
@@ -415,9 +415,6 @@ TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
run.setReferencingRenderObject(text);
#endif
- // Disable any word/character rounding.
- run.disableRoundingHacks();
-
// We handle letter & word spacing ourselves.
run.disableSpacing();
return run;
@@ -519,6 +516,29 @@ void SVGInlineTextBox::paintDecoration(GraphicsContext* context, ETextDecoration
}
}
+static inline void normalizeTransform(AffineTransform& transform)
+{
+ // Obtain consistent numerical results for the AffineTransform on both 32/64bit platforms.
+ // Tested with SnowLeopard on Core Duo vs. Core 2 Duo.
+ static const float s_floatEpsilon = std::numeric_limits<float>::epsilon();
+
+ if (fabs(transform.a() - 1) <= s_floatEpsilon)
+ transform.setA(1);
+ else if (fabs(transform.a() + 1) <= s_floatEpsilon)
+ transform.setA(-1);
+
+ if (fabs(transform.d() - 1) <= s_floatEpsilon)
+ transform.setD(1);
+ else if (fabs(transform.d() + 1) <= s_floatEpsilon)
+ transform.setD(-1);
+
+ if (fabs(transform.e()) <= s_floatEpsilon)
+ transform.setE(0);
+
+ if (fabs(transform.f()) <= s_floatEpsilon)
+ transform.setF(0);
+}
+
void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, ETextDecoration decoration, const SVGTextFragment& fragment, RenderObject* decorationRenderer)
{
ASSERT(!m_paintingResource);
@@ -546,7 +566,12 @@ void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, ETextD
if (scalingFactor != 1) {
width *= scalingFactor;
decorationOrigin.scale(scalingFactor, scalingFactor);
- context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
+
+ AffineTransform newTransform = context->getCTM();
+ newTransform.scale(1 / scalingFactor);
+ normalizeTransform(newTransform);
+
+ context->setCTM(newTransform);
}
decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetForDecoration(decoration, scaledFontMetrics, thickness));
@@ -589,13 +614,21 @@ void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyl
if (shadow)
extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */);
- if (scalingFactor != 1)
- context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
+ AffineTransform originalTransform;
+ if (scalingFactor != 1) {
+ originalTransform = context->getCTM();
+
+ AffineTransform newTransform = originalTransform;
+ newTransform.scale(1 / scalingFactor);
+ normalizeTransform(newTransform);
+
+ context->setCTM(newTransform);
+ }
scaledFont.drawText(context, textRun, textOrigin + extraOffset, startPosition, endPosition);
if (scalingFactor != 1)
- context->scale(FloatSize(scalingFactor, scalingFactor));
+ context->setCTM(originalTransform);
restoreGraphicsContextAfterTextPainting(context, textRun);
diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.h b/Source/WebCore/rendering/svg/SVGInlineTextBox.h
index f2ca303..79c836f 100644
--- a/Source/WebCore/rendering/svg/SVGInlineTextBox.h
+++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.h
@@ -42,8 +42,8 @@ public:
virtual int selectionTop() { return m_y; }
virtual int selectionHeight() { return m_logicalHeight; }
- virtual int offsetForPosition(int x, bool includePartialGlyphs = true) const;
- virtual int positionForOffset(int offset) const;
+ virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const;
+ virtual float positionForOffset(int offset) const;
void paintSelectionBackground(PaintInfo&);
virtual void paint(PaintInfo&, int tx, int ty);
diff --git a/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
index 97e15af..0f94fdd 100644
--- a/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
+++ b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
@@ -222,7 +222,7 @@ static TextStream& operator<<(TextStream& ts, const SVGMarkerElement::SVGMarkerU
TextStream& operator<<(TextStream& ts, const Color& c)
{
- return ts << c.name();
+ return ts << c.nameForRenderTreeAsText();
}
// FIXME: Maybe this should be in KCanvasRenderingStyle.cpp
@@ -435,13 +435,16 @@ static void writeRenderSVGTextBox(TextStream& ts, const RenderBlock& text)
if (!box)
return;
- ts << " at (" << text.x() << "," << text.y() << ") size " << box->logicalWidth() << "x" << box->logicalHeight();
+ // FIXME: For now use an int for logicalWidth, although this makes it harder
+ // to detect any changes caused by the conversion to floating point. :(
+ int logicalWidth = ceilf(box->x() + box->logicalWidth()) - box->x();
+ ts << " at (" << text.x() << "," << text.y() << ") size " << logicalWidth << "x" << box->logicalHeight();
// FIXME: Remove this hack, once the new text layout engine is completly landed. We want to preserve the old layout test results for now.
ts << " contains 1 chunk(s)";
if (text.parent() && (text.parent()->style()->visitedDependentColor(CSSPropertyColor) != text.style()->visitedDependentColor(CSSPropertyColor)))
- writeNameValuePair(ts, "color", text.style()->visitedDependentColor(CSSPropertyColor).name());
+ writeNameValuePair(ts, "color", text.style()->visitedDependentColor(CSSPropertyColor).nameForRenderTreeAsText());
}
static inline void writeSVGInlineTextBox(TextStream& ts, SVGInlineTextBox* textBox, int indent)
diff --git a/Source/WebCore/rendering/svg/SVGResources.cpp b/Source/WebCore/rendering/svg/SVGResources.cpp
index 9a2c999..d3cd184 100644
--- a/Source/WebCore/rendering/svg/SVGResources.cpp
+++ b/Source/WebCore/rendering/svg/SVGResources.cpp
@@ -152,15 +152,12 @@ static inline String targetReferenceFromResource(SVGElement* element)
return SVGURIReference::getTarget(target);
}
-static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document* document, SVGPaint* paint, AtomicString& id, bool& hasPendingResource)
+static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document* document, const SVGPaint::SVGPaintType& paintType, const String& paintUri, AtomicString& id, bool& hasPendingResource)
{
- ASSERT(paint);
-
- SVGPaint::SVGPaintType paintType = paint->paintType();
if (paintType != SVGPaint::SVG_PAINTTYPE_URI && paintType != SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR)
return 0;
- id = SVGURIReference::getTarget(paint->uri());
+ id = SVGURIReference::getTarget(paintUri);
RenderSVGResourceContainer* container = getRenderSVGResourceContainerById(document, id);
if (!container) {
hasPendingResource = true;
@@ -259,7 +256,7 @@ bool SVGResources::buildCachedResources(const RenderObject* object, const SVGRen
if (style->hasFill()) {
bool hasPendingResource = false;
AtomicString id;
- if (setFill(paintingResourceFromSVGPaint(document, style->fillPaint(), id, hasPendingResource)))
+ if (setFill(paintingResourceFromSVGPaint(document, style->fillPaintType(), style->fillPaintUri(), id, hasPendingResource)))
foundResources = true;
else if (hasPendingResource)
registerPendingResource(extensions, id, element);
@@ -268,7 +265,7 @@ bool SVGResources::buildCachedResources(const RenderObject* object, const SVGRen
if (style->hasStroke()) {
bool hasPendingResource = false;
AtomicString id;
- if (setStroke(paintingResourceFromSVGPaint(document, style->strokePaint(), id, hasPendingResource)))
+ if (setStroke(paintingResourceFromSVGPaint(document, style->strokePaintType(), style->strokePaintUri(), id, hasPendingResource)))
foundResources = true;
else if (hasPendingResource)
registerPendingResource(extensions, id, element);
diff --git a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp b/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
index ca20d3d..d75bdb3 100644
--- a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
+++ b/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
@@ -47,8 +47,9 @@ SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun&
int length = 0;
// Calculate width/height using the scaled font, divide this result by the scalingFactor afterwards.
- m_width = scaledFont.floatWidth(run, extraCharsAvailable, length, m_glyph.name) / scalingFactor;
+ m_width = scaledFont.width(run, extraCharsAvailable, length, m_glyph.name) / scalingFactor;
m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor;
+
m_glyph.unicodeString = String(run.characters(), length);
m_glyph.isValid = true;
@@ -79,9 +80,6 @@ static TextRun constructTextRun(RenderSVGInlineText* text, const UChar* characte
run.setReferencingRenderObject(text);
#endif
- // Disable any word/character rounding.
- run.disableRoundingHacks();
-
// We handle letter & word spacing ourselves.
run.disableSpacing();
return run;