RESOLVED FIXED 174701
Round-tripping stroke-width styles through getComputedStyle cause the text to gain a stroke.
https://bugs.webkit.org/show_bug.cgi?id=174701
Summary Round-tripping stroke-width styles through getComputedStyle cause the text to...
Per Arne Vollan
Reported 2017-07-20 17:24:18 PDT
WebKit will currently render the text stroked in the following test case: <div id=t>This text should not be stroked.</div> <script>t.style=getComputedStyle(t).cssText</script>
Attachments
Patch (3.42 KB, patch)
2017-07-20 17:31 PDT, Per Arne Vollan
no flags
Archive of layout-test-results from ews101 for mac-elcapitan (1.12 MB, application/zip)
2017-07-20 18:08 PDT, Build Bot
no flags
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (1.26 MB, application/zip)
2017-07-20 18:19 PDT, Build Bot
no flags
Archive of layout-test-results from ews113 for mac-elcapitan (1.89 MB, application/zip)
2017-07-20 18:46 PDT, Build Bot
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (10.56 MB, application/zip)
2017-07-20 20:02 PDT, Build Bot
no flags
Patch (4.88 KB, patch)
2017-07-21 08:46 PDT, Per Arne Vollan
no flags
Patch (5.59 KB, patch)
2017-07-21 12:21 PDT, Per Arne Vollan
no flags
Per Arne Vollan
Comment 1 2017-07-20 17:25:02 PDT
Per Arne Vollan
Comment 2 2017-07-20 17:31:57 PDT
Build Bot
Comment 3 2017-07-20 18:08:25 PDT
Comment on attachment 316047 [details] Patch Attachment 316047 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/4158324 New failing tests: fast/css/getComputedStyle/computed-style-without-renderer.html fast/css/parsing-stroke-width.html fast/css/getComputedStyle/computed-style.html
Build Bot
Comment 4 2017-07-20 18:08:26 PDT
Created attachment 316052 [details] Archive of layout-test-results from ews101 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Darin Adler
Comment 5 2017-07-20 18:09:24 PDT
Comment on attachment 316047 [details] Patch The test looks good, but I am not sure the fix is correct. I’d like to see another test explicitly checking the value of computed style when stroke width was not set, and I’d like to compare with the CSS specification asks for and possibly also what other browsers do.
Build Bot
Comment 6 2017-07-20 18:19:23 PDT
Comment on attachment 316047 [details] Patch Attachment 316047 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/4158349 New failing tests: fast/css/getComputedStyle/computed-style-without-renderer.html fast/css/parsing-stroke-width.html fast/css/getComputedStyle/computed-style.html
Build Bot
Comment 7 2017-07-20 18:19:24 PDT
Created attachment 316054 [details] Archive of layout-test-results from ews104 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 8 2017-07-20 18:46:52 PDT
Comment on attachment 316047 [details] Patch Attachment 316047 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/4158371 New failing tests: fast/css/getComputedStyle/computed-style-without-renderer.html fast/css/parsing-stroke-width.html fast/css/getComputedStyle/computed-style.html
Build Bot
Comment 9 2017-07-20 18:46:53 PDT
Created attachment 316055 [details] Archive of layout-test-results from ews113 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Simon Fraser (smfr)
Comment 10 2017-07-20 19:32:50 PDT
Today I searched for initialStrokeWidth() and was unable to find it. Why does StyleRareInheritedData use: , strokeWidth(RenderStyle::initialOneLength()) which I can't easily search for? Question about the patch: why does the text get a black stroke, when the default stroke color is transparent?
Build Bot
Comment 11 2017-07-20 20:02:25 PDT
Comment on attachment 316047 [details] Patch Attachment 316047 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/4158685 New failing tests: fast/css/parsing-stroke-width.html
Build Bot
Comment 12 2017-07-20 20:02:26 PDT
Created attachment 316061 [details] Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.5
Per Arne Vollan
Comment 13 2017-07-20 20:30:43 PDT
(In reply to Simon Fraser (smfr) from comment #10) > Today I searched for initialStrokeWidth() and was unable to find it. Why > does StyleRareInheritedData use: > > , strokeWidth(RenderStyle::initialOneLength()) > > which I can't easily search for? > > Question about the patch: why does the text get a black stroke, when the > default stroke color is transparent? These are very good points. From what I can see, the default color does not seem to be transparent, but black (opaque), which is not correct. I will update the patch shortly. Thanks for reviewing, all!
Per Arne Vollan
Comment 14 2017-07-21 08:46:42 PDT
Per Arne Vollan
Comment 15 2017-07-21 09:23:20 PDT
(In reply to Darin Adler from comment #5) > Comment on attachment 316047 [details] > Patch > > The test looks good, but I am not sure the fix is correct. I’d like to see > another test explicitly checking the value of computed style when stroke > width was not set, and I’d like to compare with the CSS specification asks > for and possibly also what other browsers do. Yes, I agree the fix is not correct. After the suggestion from Simon, I have changed the patch to instead set the correct initial value of the stroke-color to transparent, see https://www.w3.org/TR/fill-stroke-3/#stroke-color. Thanks for reviewing!
mitz
Comment 16 2017-07-21 10:53:18 PDT
Comment on attachment 316090 [details] Patch This patch also changes behavior outside of getting computed style, right? Currently <div style="stroke-width: 1px">Text</div> renders with a stroke, but after the patch it won’t, unless a non-transparent stroke-color is also specified. Seems like this should be covered in a test as well.
Per Arne Vollan
Comment 17 2017-07-21 11:04:01 PDT
(In reply to mitz from comment #16) > Comment on attachment 316090 [details] > Patch > > This patch also changes behavior outside of getting computed style, right? > Currently <div style="stroke-width: 1px">Text</div> renders with a stroke, > but after the patch it won’t, unless a non-transparent stroke-color is also > specified. Seems like this should be covered in a test as well. Yes, this also changes the behavior outside of getting the computed style. I will add a new test. Thanks for reviewing!
Per Arne Vollan
Comment 18 2017-07-21 12:17:58 PDT
(In reply to mitz from comment #16) > Comment on attachment 316090 [details] > Patch > > This patch also changes behavior outside of getting computed style, right? > Currently <div style="stroke-width: 1px">Text</div> renders with a stroke, > but after the patch it won’t, unless a non-transparent stroke-color is also > specified. Seems like this should be covered in a test as well. Actually, no, it doesn't. When stroke-color is not explicitly specified, we fall back to the value of -webkit-text-stroke-color, which means the text in your example will be stroked.
Per Arne Vollan
Comment 19 2017-07-21 12:21:59 PDT
Darin Adler
Comment 20 2017-07-21 13:28:46 PDT
Comment on attachment 316109 [details] Patch Might be OK. Test seems just right. I am not as sure that the behavior change is OK. I don’t see the additional testing that Mitz asked for, covering various behavior changes outside editing.
Simon Fraser (smfr)
Comment 21 2017-07-21 13:52:23 PDT
(In reply to Per Arne Vollan from comment #18) > (In reply to mitz from comment #16) > > Comment on attachment 316090 [details] > > Patch > > > > This patch also changes behavior outside of getting computed style, right? > > Currently <div style="stroke-width: 1px">Text</div> renders with a stroke, > > but after the patch it won’t, unless a non-transparent stroke-color is also > > specified. Seems like this should be covered in a test as well. > > Actually, no, it doesn't. When stroke-color is not explicitly specified, we > fall back to the value of -webkit-text-stroke-color, which means the text in > your example will be stroked. If <div style="stroke-width: 1px">Text</div> now renders with a stroke, then we have problems. initialtextstrokecolor doesn't exist so I can't easily tell what the default value is.
Per Arne Vollan
Comment 22 2017-07-21 14:38:42 PDT
(In reply to Simon Fraser (smfr) from comment #21) > (In reply to Per Arne Vollan from comment #18) > > (In reply to mitz from comment #16) > > > Comment on attachment 316090 [details] > > > Patch > > > > > > This patch also changes behavior outside of getting computed style, right? > > > Currently <div style="stroke-width: 1px">Text</div> renders with a stroke, > > > but after the patch it won’t, unless a non-transparent stroke-color is also > > > specified. Seems like this should be covered in a test as well. > > > > Actually, no, it doesn't. When stroke-color is not explicitly specified, we > > fall back to the value of -webkit-text-stroke-color, which means the text in > > your example will be stroked. > > If <div style="stroke-width: 1px">Text</div> now renders with a stroke, then > we have problems. > > initialtextstrokecolor doesn't exist so I can't easily tell what the default > value is. The initial value of -webkit-text-stroke-color is an invalid color value. Since it is invalid, it will get the value of the css color property (in RenderStyle::visitedDependentColor), which is initially black. This explains the black stroke in the test case above. I don't think this patch has behavior changes outside of getting the computed style, since stroke-color falls back to -webkit-text-stroke-color if not explicitly specified, but I might be mistaken. Since the result of the test case '<div style="stroke-width: 1px">Text</div>' does not change with this patch, should we address the problem that it renders with a stroke in a separate bug?
Simon Fraser (smfr)
Comment 23 2017-07-21 14:57:17 PDT
(In reply to Per Arne Vollan from comment #22) > (In reply to Simon Fraser (smfr) from comment #21) > > (In reply to Per Arne Vollan from comment #18) > > > (In reply to mitz from comment #16) > > > > Comment on attachment 316090 [details] > > > > Patch > > > > > > > > This patch also changes behavior outside of getting computed style, right? > > > > Currently <div style="stroke-width: 1px">Text</div> renders with a stroke, > > > > but after the patch it won’t, unless a non-transparent stroke-color is also > > > > specified. Seems like this should be covered in a test as well. > > > > > > Actually, no, it doesn't. When stroke-color is not explicitly specified, we > > > fall back to the value of -webkit-text-stroke-color, which means the text in > > > your example will be stroked. > > > > If <div style="stroke-width: 1px">Text</div> now renders with a stroke, then > > we have problems. > > > > initialtextstrokecolor doesn't exist so I can't easily tell what the default > > value is. > > The initial value of -webkit-text-stroke-color is an invalid color value. > Since it is invalid, it will get the value of the css color property (in > RenderStyle::visitedDependentColor), which is initially black. This explains > the black stroke in the test case above. I think that's wrong, because https://www.w3.org/TR/fill-stroke-3/#propdef-stroke-color states that the initial value of stroke-color is transparent, not currentColor (c.f. border-color https://www.w3.org/TR/css3-background/#border-color). So this aliasing to -webkit-text-stroke-color which has unspecified behavior is causing problems.
Jon Lee
Comment 24 2017-07-21 15:04:05 PDT
(In reply to Simon Fraser (smfr) from comment #23) > So this aliasing to -webkit-text-stroke-color which has unspecified behavior > is causing problems. Seems like we could either 1) Keep the fallback, and change -webkit-text-stroke-color to default to transparent; or, 2) Not fall back to -webkit-text-stroke-color if stroke-color is specified.
Per Arne Vollan
Comment 25 2017-07-21 15:21:00 PDT
(In reply to Jon Lee from comment #24) > (In reply to Simon Fraser (smfr) from comment #23) > > So this aliasing to -webkit-text-stroke-color which has unspecified behavior > > is causing problems. > > Seems like we could either > > 1) Keep the fallback, and change -webkit-text-stroke-color to default to > transparent; or, > 2) Not fall back to -webkit-text-stroke-color if stroke-color is specified. Thanks for the input! I would prefer 2), since 1) might break sites using -webkit-text-stroke-width and -webkit-text-stroke-color. I assume these are used more frequently than stroke-width and stroke-color.
Per Arne Vollan
Comment 26 2017-07-21 16:06:54 PDT
(In reply to Per Arne Vollan from comment #25) > (In reply to Jon Lee from comment #24) > > (In reply to Simon Fraser (smfr) from comment #23) > > > So this aliasing to -webkit-text-stroke-color which has unspecified behavior > > > is causing problems. > > > > Seems like we could either > > > > 1) Keep the fallback, and change -webkit-text-stroke-color to default to > > transparent; or, > > 2) Not fall back to -webkit-text-stroke-color if stroke-color is specified. > > Thanks for the input! I would prefer 2), since 1) might break sites using > -webkit-text-stroke-width and -webkit-text-stroke-color. I assume these are > used more frequently than stroke-width and stroke-color. Although, I would like to fix this as a separate issue, and just focus on the round-trip issue in this bug. This is fixed by the current patch, without changes in behavior outside of getting the computed style, I believe.
Per Arne Vollan
Comment 27 2017-07-21 16:48:17 PDT
(In reply to Per Arne Vollan from comment #26) > (In reply to Per Arne Vollan from comment #25) > > (In reply to Jon Lee from comment #24) > > > (In reply to Simon Fraser (smfr) from comment #23) > > > > So this aliasing to -webkit-text-stroke-color which has unspecified behavior > > > > is causing problems. > > > > > > Seems like we could either > > > > > > 1) Keep the fallback, and change -webkit-text-stroke-color to default to > > > transparent; or, > > > 2) Not fall back to -webkit-text-stroke-color if stroke-color is specified. > > > > Thanks for the input! I would prefer 2), since 1) might break sites using > > -webkit-text-stroke-width and -webkit-text-stroke-color. I assume these are > > used more frequently than stroke-width and stroke-color. > > Although, I would like to fix this as a separate issue, and just focus on > the round-trip issue in this bug. This is fixed by the current patch, > without changes in behavior outside of getting the computed style, I believe. I have filed a new bug to address this issue: https://bugs.webkit.org/show_bug.cgi?id=174737
Per Arne Vollan
Comment 28 2017-07-21 17:11:33 PDT
Thanks for the input and review, all!
WebKit Commit Bot
Comment 29 2017-07-21 17:41:17 PDT
Comment on attachment 316109 [details] Patch Clearing flags on attachment: 316109 Committed r219755: <http://trac.webkit.org/changeset/219755>
WebKit Commit Bot
Comment 30 2017-07-21 17:41:19 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.