Round-tripping stroke-width styles through getComputedStyle cause the text to gain...
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2017 00:41:14 +0000 (00:41 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2017 00:41:14 +0000 (00:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174701
Source/WebCore:

<rdar://problem/32903679>

Reviewed by Simon Fraser.

The initial value of stroke-color should be transparent, see https://www.w3.org/TR/fill-stroke-3/#stroke-color.
Also, there is no need to set the graphics context in text stroke mode, if the stroke color is not visible.

Test: fast/css/round-trip-stroke-width-using-computed-style.html

* rendering/TextPaintStyle.cpp:
(WebCore::updateGraphicsContext):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::initialStrokeWidth):
(WebCore::RenderStyle::initialStrokeColor):
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):

LayoutTests:

Reviewed by Simon Fraser.

* fast/css/round-trip-stroke-width-using-computed-style-expected.html: Added.
* fast/css/round-trip-stroke-width-using-computed-style.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219755 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/css/round-trip-stroke-width-using-computed-style-expected.html [new file with mode: 0644]
LayoutTests/fast/css/round-trip-stroke-width-using-computed-style.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/TextPaintStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp

index 830b09d..1be59fd 100644 (file)
@@ -1,3 +1,13 @@
+2017-07-21  Per Arne Vollan  <pvollan@apple.com>
+
+        Round-tripping stroke-width styles through getComputedStyle cause the text to gain a stroke.
+        https://bugs.webkit.org/show_bug.cgi?id=174701
+
+        Reviewed by Simon Fraser.
+
+        * fast/css/round-trip-stroke-width-using-computed-style-expected.html: Added.
+        * fast/css/round-trip-stroke-width-using-computed-style.html: Added.
+
 2017-07-21  Nan Wang  <n_wang@apple.com>
 
         AX: Expose form validation on iOS as hint
diff --git a/LayoutTests/fast/css/round-trip-stroke-width-using-computed-style-expected.html b/LayoutTests/fast/css/round-trip-stroke-width-using-computed-style-expected.html
new file mode 100644 (file)
index 0000000..c5fe33c
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML>
+
+<html>
+<body>
+<div>This text should not be stroked.</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/round-trip-stroke-width-using-computed-style.html b/LayoutTests/fast/css/round-trip-stroke-width-using-computed-style.html
new file mode 100644 (file)
index 0000000..a109ecf
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+
+<html>
+<body>
+<div id=t>This text should not be stroked.</div>
+<script>t.style=getComputedStyle(t).cssText</script>
+<body>
+</html>
index 506109d..11708e7 100644 (file)
@@ -1,3 +1,24 @@
+2017-07-21  Per Arne Vollan  <pvollan@apple.com>
+
+        Round-tripping stroke-width styles through getComputedStyle cause the text to gain a stroke.
+        https://bugs.webkit.org/show_bug.cgi?id=174701
+        <rdar://problem/32903679>
+
+        Reviewed by Simon Fraser.
+
+        The initial value of stroke-color should be transparent, see https://www.w3.org/TR/fill-stroke-3/#stroke-color.
+        Also, there is no need to set the graphics context in text stroke mode, if the stroke color is not visible.
+
+        Test: fast/css/round-trip-stroke-width-using-computed-style.html
+
+        * rendering/TextPaintStyle.cpp:
+        (WebCore::updateGraphicsContext):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::initialStrokeWidth):
+        (WebCore::RenderStyle::initialStrokeColor):
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+
 2017-07-21  Timothy Horton  <timothy_horton@apple.com>
 
         Remove an inaccurate comment from RenderTextLineBoxes
index 4f822ef..b0ab8f5 100644 (file)
@@ -187,7 +187,7 @@ void updateGraphicsContext(GraphicsContext& context, const TextPaintStyle& paint
     else
         newMode &= ~TextModeLetterpress;
 #endif
-    if (paintStyle.strokeWidth > 0)
+    if (paintStyle.strokeWidth > 0 && paintStyle.strokeColor.isVisible())
         newMode |= TextModeStroke;
     if (mode != newMode) {
         context.setTextDrawingMode(newMode);
index bf09400..5c15fb6 100644 (file)
@@ -1267,6 +1267,7 @@ public:
     const Length& strokeWidth() const { return m_rareInheritedData->strokeWidth; }
     void setStrokeWidth(Length&& w) { SET_VAR(m_rareInheritedData, strokeWidth, WTFMove(w)); }
     bool hasVisibleStroke() const { return svgStyle().hasStroke() && !strokeWidth().isZero(); }
+    static Length initialStrokeWidth() { return initialOneLength(); }
 
     float computedStrokeWidth(const IntSize& viewportSize) const;
     void setHasExplicitlySetStrokeWidth(bool v) { SET_VAR(m_rareInheritedData, hasSetStrokeWidth, static_cast<unsigned>(v)); }
@@ -1279,6 +1280,7 @@ public:
     const Color& visitedLinkStrokeColor() const { return m_rareInheritedData->visitedLinkStrokeColor; }
     void setHasExplicitlySetStrokeColor(bool v) { SET_VAR(m_rareInheritedData, hasSetStrokeColor, static_cast<unsigned>(v)); }
     bool hasExplicitlySetStrokeColor() const { return m_rareInheritedData->hasSetStrokeColor; };
+    static Color initialStrokeColor() { return Color(Color::transparent); }
     
     float strokeMiterLimit() const { return m_rareInheritedData->miterLimit; }
     void setStrokeMiterLimit(float f) { SET_VAR(m_rareInheritedData, miterLimit, f); }
index 14cd0fd..1231f3f 100644 (file)
@@ -130,7 +130,8 @@ StyleRareInheritedData::StyleRareInheritedData()
     , joinStyle(RenderStyle::initialJoinStyle())
     , hasSetStrokeWidth(false)
     , hasSetStrokeColor(false)
-    , strokeWidth(RenderStyle::initialOneLength())
+    , strokeWidth(RenderStyle::initialStrokeWidth())
+    , strokeColor(RenderStyle::initialStrokeColor())
     , miterLimit(RenderStyle::initialStrokeMiterLimit())
     , hyphenationLimitBefore(-1)
     , hyphenationLimitAfter(-1)