Title: [115201] trunk
Revision
115201
Author
[email protected]
Date
2012-04-25 07:04:52 -0700 (Wed, 25 Apr 2012)

Log Message

[SVG] Nothing should be stroked when the stroke-width is 0
https://bugs.webkit.org/show_bug.cgi?id=83568

Reviewed by Nikolas Zimmermann.

Source/WebCore:

The spec states that "A zero value causes no stroke to be painted".
We should avoid calling functions that could incorrectly paint something
in that case.

Test: svg/custom/path-zero-strokewidth.svg

* rendering/style/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::hasVisibleStroke):
* rendering/svg/RenderSVGEllipse.cpp:
(WebCore::RenderSVGEllipse::strokeShape): Check if the stroke should be visible before painting.
* rendering/svg/RenderSVGRect.cpp:
(WebCore::RenderSVGRect::strokeShape): Ditto.
* rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::strokeShape): Ditto.
(WebCore::RenderSVGShape::strokePath): Ditto.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paint): Dont call paintText for zero-width stroke.
(WebCore::SVGInlineTextBox::paintDecoration): Ditto.

LayoutTests:

* platform/chromium/test_expectations.txt: mark affected tests for rebaseline.
* platform/qt/Skipped: Unskip svg/custom/path-zero-strokewidth.svg

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (115200 => 115201)


--- trunk/LayoutTests/ChangeLog	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/LayoutTests/ChangeLog	2012-04-25 14:04:52 UTC (rev 115201)
@@ -1,3 +1,13 @@
+2012-04-25  Pierre Rossi  <[email protected]>
+
+        [SVG] Nothing should be stroked when the stroke-width is 0
+        https://bugs.webkit.org/show_bug.cgi?id=83568
+
+        Reviewed by Nikolas Zimmermann.
+
+        * platform/chromium/test_expectations.txt: mark affected tests for rebaseline.
+        * platform/qt/Skipped: Unskip svg/custom/path-zero-strokewidth.svg
+
 2012-04-25  Philippe Normand  <[email protected]>
 
         Unreviewed, GTK test_expectations update.

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (115200 => 115201)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-04-25 14:04:52 UTC (rev 115201)
@@ -3718,3 +3718,7 @@
 
 BUGWK84854 LINUX X86 : svg/batik/text/textOnPath.svg = IMAGE PASS
 BUGWK84854 LINUX X86 : svg/batik/text/verticalTextOnPath.svg = IMAGE PASS
+
+// Requires rebaseline after bug 83978
+BUGWK83568 : svg/custom/path-zero-strokewidth.svg = IMAGE
+BUGWK83568 : svg/custom/js-update-style.svg = IMAGE

Modified: trunk/LayoutTests/platform/qt/Skipped (115200 => 115201)


--- trunk/LayoutTests/platform/qt/Skipped	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-04-25 14:04:52 UTC (rev 115201)
@@ -2196,7 +2196,6 @@
 fast/writing-mode/vertical-baseline-alignment.html
 fast/writing-mode/vertical-font-fallback.html
 svg/css/shadow-changes.svg
-svg/custom/path-zero-strokewidth.svg
 svg/custom/use-invalid-pattern.svg
 svg/text/bidi-embedded-direction.svg
 svg/text/select-textLength-spacingAndGlyphs-squeeze-1.svg

Modified: trunk/Source/WebCore/ChangeLog (115200 => 115201)


--- trunk/Source/WebCore/ChangeLog	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/Source/WebCore/ChangeLog	2012-04-25 14:04:52 UTC (rev 115201)
@@ -1,3 +1,29 @@
+2012-04-25  Pierre Rossi  <[email protected]>
+
+        [SVG] Nothing should be stroked when the stroke-width is 0
+        https://bugs.webkit.org/show_bug.cgi?id=83568
+
+        Reviewed by Nikolas Zimmermann.
+
+        The spec states that "A zero value causes no stroke to be painted".
+        We should avoid calling functions that could incorrectly paint something
+        in that case.
+
+        Test: svg/custom/path-zero-strokewidth.svg
+
+        * rendering/style/SVGRenderStyle.h:
+        (WebCore::SVGRenderStyle::hasVisibleStroke):
+        * rendering/svg/RenderSVGEllipse.cpp:
+        (WebCore::RenderSVGEllipse::strokeShape): Check if the stroke should be visible before painting.
+        * rendering/svg/RenderSVGRect.cpp:
+        (WebCore::RenderSVGRect::strokeShape): Ditto.
+        * rendering/svg/RenderSVGShape.cpp:
+        (WebCore::RenderSVGShape::strokeShape): Ditto.
+        (WebCore::RenderSVGShape::strokePath): Ditto.
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paint): Dont call paintText for zero-width stroke.
+        (WebCore::SVGInlineTextBox::paintDecoration): Ditto.
+
 2012-04-25  Alexis Menard  <[email protected]>
 
         Unfortunately http://trac.webkit.org/changeset/115055 was landed using webkit-patch

Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyle.h (115200 => 115201)


--- trunk/Source/WebCore/rendering/style/SVGRenderStyle.h	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyle.h	2012-04-25 14:04:52 UTC (rev 115201)
@@ -362,6 +362,7 @@
     bool hasFilter() const { return !filterResource().isEmpty(); }
     bool hasMarkers() const { return !markerStartResource().isEmpty() || !markerMidResource().isEmpty() || !markerEndResource().isEmpty(); }
     bool hasStroke() const { return strokePaintType() != SVGPaint::SVG_PAINTTYPE_NONE; }
+    bool hasVisibleStroke() const { return hasStroke() && !strokeWidth().isZero(); }
     bool hasFill() const { return fillPaintType() != SVGPaint::SVG_PAINTTYPE_NONE; }
     bool isVerticalWritingMode() const { return writingMode() == WM_TBRL || writingMode() == WM_TB; }
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.cpp (115200 => 115201)


--- trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.cpp	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.cpp	2012-04-25 14:04:52 UTC (rev 115201)
@@ -120,6 +120,8 @@
 
 void RenderSVGEllipse::strokeShape(GraphicsContext* context) const
 {
+    if (!style()->svgStyle()->hasVisibleStroke())
+        return;
     if (isPaintingFallback()) {
         RenderSVGShape::strokeShape(context);
         return;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp (115200 => 115201)


--- trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp	2012-04-25 14:04:52 UTC (rev 115201)
@@ -127,6 +127,8 @@
 
 void RenderSVGRect::strokeShape(GraphicsContext* context) const
 {
+    if (!style()->svgStyle()->hasVisibleStroke())
+        return;
     if (!isPaintingFallback()) {
         context->strokeRect(m_boundingBox, strokeWidth());
         return;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp (115200 => 115201)


--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2012-04-25 14:04:52 UTC (rev 115201)
@@ -94,7 +94,8 @@
 
 void RenderSVGShape::strokeShape(GraphicsContext* context) const
 {
-    context->strokePath(path());
+    if (style()->svgStyle()->hasVisibleStroke())
+        context->strokePath(path());
 }
 
 bool RenderSVGShape::shapeDependentStrokeContains(const FloatPoint& point) const
@@ -265,6 +266,8 @@
                                 const Color& fallbackColor, bool nonScalingStroke, const AffineTransform& nonScalingStrokeTransform,
                                 int applyMode)
 {
+    if (!style->svgStyle()->hasVisibleStroke())
+        return;
     Path* usePath = path;
     if (nonScalingStroke) {
         usePath = nonScalingStrokePath(path, nonScalingStrokeTransform);

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (115200 => 115201)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2012-04-25 14:02:08 UTC (rev 115200)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2012-04-25 14:04:52 UTC (rev 115201)
@@ -274,7 +274,7 @@
     ASSERT(svgStyle);
 
     bool hasFill = svgStyle->hasFill();
-    bool hasStroke = svgStyle->hasStroke();
+    bool hasVisibleStroke = svgStyle->hasVisibleStroke();
 
     RenderStyle* selectionStyle = style;
     if (hasSelection) {
@@ -285,15 +285,15 @@
 
             if (!hasFill)
                 hasFill = svgSelectionStyle->hasFill();
-            if (!hasStroke)
-                hasStroke = svgSelectionStyle->hasStroke();
+            if (!hasVisibleStroke)
+                hasVisibleStroke = svgSelectionStyle->hasVisibleStroke();
         } else
             selectionStyle = style;
     }
 
     if (textRenderer->frame() && textRenderer->frame()->view() && textRenderer->frame()->view()->paintBehavior() & PaintBehaviorRenderingSVGMask) {
         hasFill = true;
-        hasStroke = false;
+        hasVisibleStroke = false;
     }
 
     AffineTransform fragmentTransform;
@@ -321,7 +321,7 @@
         }
 
         // Stroke text
-        if (hasStroke) {
+        if (hasVisibleStroke) {
             m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode;
             paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
         }
@@ -526,14 +526,14 @@
     ASSERT(svgDecorationStyle);
 
     bool hasDecorationFill = svgDecorationStyle->hasFill();
-    bool hasDecorationStroke = svgDecorationStyle->hasStroke();
+    bool hasVisibleDecorationStroke = svgDecorationStyle->hasVisibleStroke();
 
     if (hasDecorationFill) {
         m_paintingResourceMode = ApplyToFillMode;
         paintDecorationWithStyle(context, decoration, fragment, decorationRenderer);
     }
 
-    if (hasDecorationStroke) {
+    if (hasVisibleDecorationStroke) {
         m_paintingResourceMode = ApplyToStrokeMode;
         paintDecorationWithStyle(context, decoration, fragment, decorationRenderer);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to