RESOLVED FIXED 239689
Setting white-space to non-default value dynamically on a blank (whitespace/new line) does not work correctly
https://bugs.webkit.org/show_bug.cgi?id=239689
Summary Setting white-space to non-default value dynamically on a blank (whitespace/n...
Chijin
Reported 2022-04-23 00:57:01 PDT
Created attachment 458204 [details] expected rendering result of chrome example url: https://codepen.io/chijinz/pen/eYyoLbz Steps to reproduce the problem: 1. use Safari to visit the example url 2. the green light is on the top of the page even though white-space has been set to "pre-line". This is inconsistent with the document (https://developer.mozilla.org/en-US/docs/Web/CSS/white-space). Other browsers (e.g. chrome) works fine with this issue.
Attachments
expected rendering result of chrome (189.66 KB, image/png)
2022-04-23 00:57 PDT, Chijin
no flags
Test reduction (210 bytes, text/html)
2022-04-24 20:01 PDT, zalan
no flags
Patch (3.36 KB, patch)
2024-03-17 13:55 PDT, zalan
no flags
Patch (3.75 KB, patch)
2024-03-17 20:28 PDT, zalan
no flags
Patch (4.69 KB, patch)
2024-03-18 05:32 PDT, zalan
no flags
[fast-cq]Patch (4.82 KB, patch)
2024-03-18 08:04 PDT, zalan
no flags
zalan
Comment 1 2022-04-24 20:01:17 PDT
Created attachment 458239 [details] Test reduction This bug only occurs when the pre-line is set dynamically on an "inline empty" content (no text or other inline level box).
zalan
Comment 2 2022-04-24 21:16:49 PDT
We don't create RenderText renderers for the whitespace/new line only content. It looks like in RenderTreeUpdater::updateRenderTree bool mayNeedUpdateWhitespaceOnlyRenderer = renderingParent().didCreateOrDestroyChildRenderer && text.data().isAllSpecialCharacters<isHTMLSpace>(); may need to be updated so that certain parent styles (e.g. white-space) are also taken into account when checking if the text node needs a renderer.
Radar WebKit Bug Importer
Comment 3 2022-04-30 00:57:14 PDT
Chijin
Comment 4 2022-05-02 19:50:46 PDT
Hi, anyone take care of this issue?
Ahmad Saleem
Comment 5 2022-12-31 04:16:50 PST
I am still able to reproduce this in Safari 16.2 & STP160, is this something progressed with IFC on trunk? @Alan?
zalan
Comment 6 2022-12-31 07:16:20 PST
(In reply to zalan from comment #2) > We don't create RenderText renderers for the whitespace/new line only > content. > > It looks like in RenderTreeUpdater::updateRenderTree > bool mayNeedUpdateWhitespaceOnlyRenderer = > renderingParent().didCreateOrDestroyChildRenderer && > text.data().isAllSpecialCharacters<isHTMLSpace>(); > may need to be updated so that certain parent styles (e.g. white-space) are > also taken into account when checking if the text node needs a renderer. Let's see what Antti thinks.
Chijin
Comment 7 2024-03-17 07:36:03 PDT
Hi zalan, one year has been passed, any update for this bug?
zalan
Comment 8 2024-03-17 13:55:51 PDT
zalan
Comment 9 2024-03-17 13:56:40 PDT
(In reply to Chijin from comment #7) > Hi zalan, one year has been passed, any update for this bug? This is not really my area, but let's see if I got this right.
zalan
Comment 10 2024-03-17 20:28:37 PDT
Chijin
Comment 11 2024-03-18 00:08:06 PDT
Thanks for the fixing!
zalan
Comment 12 2024-03-18 05:32:18 PDT
Antti Koivisto
Comment 13 2024-03-18 07:15:52 PDT
Comment on attachment 470415 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=470415&action=review > Source/WebCore/style/StyleTreeResolver.cpp:975 > + if (!node.renderer() && containsOnlyASCIIWhitespace && parent.style.preserveNewline()) > + return true; This could test !text->renderer() for consistency. This really needs to be done only when parent.style.preserveNewline() changes value. We could set a bit in the parent struct when that happens and test for that.
zalan
Comment 14 2024-03-18 08:04:41 PDT
Created attachment 470417 [details] [fast-cq]Patch
EWS
Comment 15 2024-03-18 09:45:36 PDT
Committed 276277@main (40f3c61c1d9d): <https://commits.webkit.org/276277@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 470417 [details].
zalan
Comment 16 2024-03-18 10:00:58 PDT
(In reply to Chijin from comment #11) > Thanks for the fixing! Thank you for filing it!
Note You need to log in before you can comment on or make changes to this bug.