https://bugs.webkit.org/show_bug.cgi?id=120953
Source/WebCore:
Reviewed by the Swedish Review Team: Anders Carlsson and Andreas Kling.
The current createTextRenderersForSiblingsAfterAttachIfNeeded code only adds text renderers, never removes them.
Style changes can go either way.
The patch causes no visible changes in rendered output. The whitespace nodes that it affects are leftovers that
have no rendering effect. However it does change results of many dumpAsText and render tree dump based layout
tests as unnecessary text nodes disappear.
The main goal is to make results of dynamic attach and parsing time attach produce more similar results. As
an added bonus we get slightly simpler rendering trees.
Rendering tree dumps show us still leaving behind empty anonymous blocks when removing whitespace text nodes.
Those should collapse away too.
* style/StyleResolveTree.cpp:
(WebCore::Style::reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded):
Allow the code both create and remove text renderers.
Tighten to bail out faster if case is not the exact one that matters.
Use NodeRenderingTraversal to mirror textRendererIsNeeded.
Renamed for clarity.
(WebCore::Style::updateTextRendererAfterContentChange):
(WebCore::Style::resolveLocal):
(WebCore::Style::updateTextStyle):
(WebCore::Style::attachRenderTree):
LayoutTests:
Reviewed by Anders Carlsson and Andreas Kling.
A bunch of spaces and empty lines disappear from dumpAsText test results.
Empty RenderTexts disapper from render tree dumps.
* css3/flexbox/flex-flow-auto-margins-expected.txt:
* css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt:
* css3/flexbox/flex-flow-border-expected.txt:
* css3/flexbox/flex-flow-margins-auto-size-expected.txt:
* css3/flexbox/flex-flow-margins-expected.txt:
* css3/flexbox/flex-flow-orientations-expected.txt:
* css3/flexbox/flex-flow-overflow-expected.txt:
* css3/flexbox/flex-flow-padding-expected.txt:
* css3/flexbox/flexbox-ignore-firstLetter-expected.txt:
* css3/flexbox/inline-flexbox-ignore-firstLine-expected.txt:
* css3/flexbox/intrinsic-min-width-applies-with-fixed-width-expected.txt:
* editing/selection/focus-crash-expected.txt:
A few frame based tests also gain an extra space from alrgorithm fixes in creation direction.
* editing/style/toggle-style-bold-italic-expected.txt:
* editing/style/toggle-style-bold-italic-mixed-editability-expected.txt:
* fast/block/float/intruding-float-not-removed-writing-mode-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt:
* fast/css/import-style-update-expected.txt:
* fast/css/positioned-overflow-scroll-expected.txt:
* fast/dom/HTMLLinkElement/resolve-url-on-insertion-expected.txt:
* fast/dom/search-shadow-host-crash-expected.txt:
* fast/dynamic/inline-to-block-crash-expected.txt:
* fast/events/input-element-display-none-in-dragleave-crash-expected.txt:
* fast/flexbox/intrinsic-min-width-applies-with-fixed-width-expected.txt:
* fast/forms/select-listbox-focus-displaynone-expected.txt:
* fast/frames/repaint-display-none-crash-expected.txt:
* fast/inline/inline-with-empty-inline-children-expected.txt:
* fast/inline/out-of-flow-objects-and-whitespace-after-empty-inline-expected.txt:
* fast/repaint/text-in-relative-positioned-inline-expected.txt:
* fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-expected.txt:
* fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-vertical-lr-expected.txt:
* fast/replaced/preferred-widths-expected.txt:
* fast/spatial-navigation/snav-tiny-table-traversal-expected.txt:
* fast/table/min-max-width-preferred-size-expected.txt:
* fast/xsl/import-non-document-node-expected.txt:
* fullscreen/full-screen-fixed-pos-parent-expected.txt:
* http/tests/appcache/auth-expected.txt:
* http/tests/cache/subresource-expiration-1-expected.txt:
* http/tests/cache/subresource-expiration-2-expected.txt:
* http/tests/xmlhttprequest/send-array-buffer-expected.txt:
* http/tests/xmlhttprequest/send-data-view-expected.txt:
* http/tests/xmlhttprequest/send-undefined-and-null-expected.txt:
* platform/mac/editing/input/firstrectforcharacterrange-plain-expected.txt:
* platform/mac/editing/input/firstrectforcharacterrange-styled-expected.txt:
* platform/mac/editing/pasteboard/4989774-expected.txt:
* platform/mac/editing/pasteboard/paste-match-style-001-expected.txt:
* platform/mac/editing/selection/caret-ltr-2-expected.txt:
* platform/mac/editing/selection/caret-ltr-2-left-expected.txt:
* platform/mac/editing/selection/caret-ltr-expected.txt:
* platform/mac/editing/selection/caret-ltr-right-expected.txt:
* platform/mac/editing/selection/caret-rtl-2-expected.txt:
* platform/mac/editing/selection/caret-rtl-2-left-expected.txt:
* platform/mac/editing/selection/caret-rtl-expected.txt:
* platform/mac/editing/selection/caret-rtl-right-expected.txt:
* platform/mac/editing/selection/vertical-rl-ltr-extend-line-backward-wrap-expected.txt:
* platform/mac/editing/selection/vertical-rl-ltr-extend-line-forward-wrap-expected.txt:
* platform/mac/editing/spelling/autocorrection-in-textarea-expected.txt:
* platform/mac/editing/style/style-boundary-005-expected.txt:
* platform/mac/fast/AppleScript/001-expected.txt:
* platform/mac/fast/AppleScript/date-expected.txt:
* platform/mac/fast/forms/formmove3-expected.txt:
* platform/mac/fast/forms/input-align-image-expected.txt:
* platform/mac/fast/forms/preserveFormDuringResidualStyle-expected.txt:
* platform/mac/fast/invalid/003-expected.txt:
* platform/mac/fast/text/attributed-substring-from-range-002-expected.txt:
* platform/mac/tables/mozilla/bugs/bug647-expected.txt:
* userscripts/user-script-all-frames-expected.txt:
* userscripts/user-script-top-frame-only-expected.txt:
Here too.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155253
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-09-07 Antti Koivisto <antti@apple.com>
+
+ Remove unnecessary sibling text renderers after attach
+ https://bugs.webkit.org/show_bug.cgi?id=120953
+
+ Reviewed by Anders Carlsson and Andreas Kling.
+
+ A bunch of spaces and empty lines disappear from dumpAsText test results.
+ Empty RenderTexts disapper from render tree dumps.
+
+ * css3/flexbox/flex-flow-auto-margins-expected.txt:
+ * css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt:
+ * css3/flexbox/flex-flow-border-expected.txt:
+ * css3/flexbox/flex-flow-margins-auto-size-expected.txt:
+ * css3/flexbox/flex-flow-margins-expected.txt:
+ * css3/flexbox/flex-flow-orientations-expected.txt:
+ * css3/flexbox/flex-flow-overflow-expected.txt:
+ * css3/flexbox/flex-flow-padding-expected.txt:
+ * css3/flexbox/flexbox-ignore-firstLetter-expected.txt:
+ * css3/flexbox/inline-flexbox-ignore-firstLine-expected.txt:
+ * css3/flexbox/intrinsic-min-width-applies-with-fixed-width-expected.txt:
+ * editing/selection/focus-crash-expected.txt:
+
+ A few frame based tests also gain an extra space from alrgorithm fixes in creation direction.
+
+ * editing/style/toggle-style-bold-italic-expected.txt:
+ * editing/style/toggle-style-bold-italic-mixed-editability-expected.txt:
+ * fast/block/float/intruding-float-not-removed-writing-mode-expected.txt:
+ * fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt:
+ * fast/css/import-style-update-expected.txt:
+ * fast/css/positioned-overflow-scroll-expected.txt:
+ * fast/dom/HTMLLinkElement/resolve-url-on-insertion-expected.txt:
+ * fast/dom/search-shadow-host-crash-expected.txt:
+ * fast/dynamic/inline-to-block-crash-expected.txt:
+ * fast/events/input-element-display-none-in-dragleave-crash-expected.txt:
+ * fast/flexbox/intrinsic-min-width-applies-with-fixed-width-expected.txt:
+ * fast/forms/select-listbox-focus-displaynone-expected.txt:
+ * fast/frames/repaint-display-none-crash-expected.txt:
+ * fast/inline/inline-with-empty-inline-children-expected.txt:
+ * fast/inline/out-of-flow-objects-and-whitespace-after-empty-inline-expected.txt:
+ * fast/repaint/text-in-relative-positioned-inline-expected.txt:
+ * fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-expected.txt:
+ * fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-vertical-lr-expected.txt:
+ * fast/replaced/preferred-widths-expected.txt:
+ * fast/spatial-navigation/snav-tiny-table-traversal-expected.txt:
+ * fast/table/min-max-width-preferred-size-expected.txt:
+ * fast/xsl/import-non-document-node-expected.txt:
+ * fullscreen/full-screen-fixed-pos-parent-expected.txt:
+ * http/tests/appcache/auth-expected.txt:
+ * http/tests/cache/subresource-expiration-1-expected.txt:
+ * http/tests/cache/subresource-expiration-2-expected.txt:
+ * http/tests/xmlhttprequest/send-array-buffer-expected.txt:
+ * http/tests/xmlhttprequest/send-data-view-expected.txt:
+ * http/tests/xmlhttprequest/send-undefined-and-null-expected.txt:
+ * platform/mac/editing/input/firstrectforcharacterrange-plain-expected.txt:
+ * platform/mac/editing/input/firstrectforcharacterrange-styled-expected.txt:
+ * platform/mac/editing/pasteboard/4989774-expected.txt:
+ * platform/mac/editing/pasteboard/paste-match-style-001-expected.txt:
+ * platform/mac/editing/selection/caret-ltr-2-expected.txt:
+ * platform/mac/editing/selection/caret-ltr-2-left-expected.txt:
+ * platform/mac/editing/selection/caret-ltr-expected.txt:
+ * platform/mac/editing/selection/caret-ltr-right-expected.txt:
+ * platform/mac/editing/selection/caret-rtl-2-expected.txt:
+ * platform/mac/editing/selection/caret-rtl-2-left-expected.txt:
+ * platform/mac/editing/selection/caret-rtl-expected.txt:
+ * platform/mac/editing/selection/caret-rtl-right-expected.txt:
+ * platform/mac/editing/selection/vertical-rl-ltr-extend-line-backward-wrap-expected.txt:
+ * platform/mac/editing/selection/vertical-rl-ltr-extend-line-forward-wrap-expected.txt:
+ * platform/mac/editing/spelling/autocorrection-in-textarea-expected.txt:
+ * platform/mac/editing/style/style-boundary-005-expected.txt:
+ * platform/mac/fast/AppleScript/001-expected.txt:
+ * platform/mac/fast/AppleScript/date-expected.txt:
+ * platform/mac/fast/forms/formmove3-expected.txt:
+ * platform/mac/fast/forms/input-align-image-expected.txt:
+ * platform/mac/fast/forms/preserveFormDuringResidualStyle-expected.txt:
+ * platform/mac/fast/invalid/003-expected.txt:
+ * platform/mac/fast/text/attributed-substring-from-range-002-expected.txt:
+ * platform/mac/tables/mozilla/bugs/bug647-expected.txt:
+ * userscripts/user-script-all-frames-expected.txt:
+ * userscripts/user-script-top-frame-only-expected.txt:
+
+ Here too.
+
2013-09-07 Mark Lam <mark.lam@apple.com>
Change fast/js/resources files to use pre and post js files in LayoutTests/resources.
PASS
vertical-rl rtl row-reverse logical
PASS
-
PASS
- PASS
- PASS
- PASS
-
+PASS
+PASS
+PASS
PASS
vertical-rl ltr column-reverse logical
PASS
-
<div class="container" data-expected-width="90" data-expected-height="90"><div class="flexbox vertical-rl ltr column-reverse" data-offset-x="40" data-offset-y="10">
<div style="-webkit-flex: 1 auto; width: 20px; height: 20px;" data-expected-width="20" data-expected-height="20" data-offset-x="48" data-offset-y="23"></div>
</div></div>
-
PASS
vertical-rl ltr row-reverse logical
PASS
-
PASS
vertical-rl ltr column-reverse
PASS
-
PASS
vertical-rl ltr column-reverse
PASS
-
PASS
vertical-rl ltr column-reverse logical
PASS
-
PASS
PASS
PASS
- PASS
-
+PASS
-To run this test manually, click the "Crash me" button.
+To run this test manually, click the "Crash me" button.
SUCCEEDED
execItalicCommand: <div id="test"> <div><b><i>Some text</i></b></div> <p><b><i>Some more text</i></b></p> </div>
execBoldCommand: <div id="test"> <div><i>Some text</i></div> <p><i>Some more text</i></p> </div>
execItalicCommand: <div id="test"> <div>Some text</div> <p>Some more text</p> </div>
-
execItalicCommand: <div id="test"><b><i> Editable </i></b><span contenteditable="false">Non-editable</span><b><i> Editable </i></b></div>
execBoldCommand: <div id="test"><i> Editable </i><span contenteditable="false">Non-editable</span><i> Editable </i></div>
execItalicCommand: <div id="test"> Editable <span contenteditable="false">Non-editable</span> Editable </div>
-
Test passes if it does not crash.
-
+
Test that modifying @import stylesheet through DOM updates style properly. You should see PASS below:
PASS
-
Test that scrollbar width is added to the intrinsic width of different display types.
PASS
-
I should be blue...and I am!!!
I should be red...and I am!!!
-
-
Click on the search box. This test passes if does not crash.
-
-
This test passes if there is no crash when dragging a file over and then away from the file input element below.
-
-
This is a test for https://bugs.webkit.org/show_bug.cgi?id=9862 REGRESSION: GMail: Crash in RenderView::repaintViewRectangle when spoofing as FF.
No crash means test PASS.
-
-
https://bugs.webkit.org/show_bug.cgi?id=95772: There should be six green bars below with a PASS in each.
PASS
+PASS
+PASS
PASS
+PASS
PASS
- PASS
- PASS
- PASS
-
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (100,0) size 684x100
- RenderText {#text} at (0,0) size 0x0
RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
PASS
-
+
PASS
-
+
FAIL:
Expected 130 for width, but got 30.
<div class="container" data-expected-width="130" data-expected-height="130">
<img class="min-content" src="resources/square-blue-100x100.png" style="width: 100%; border: 5px solid black; padding: 5px;" data-expected-width="120" data-expected-height="120">
</div>
-
+
FAIL:
Expected 130 for width, but got 30.
<div class="container" data-expected-width="130" data-expected-height="130">
<img class="max-content" src="resources/square-blue-100x100.png" style="width: 100%; border: 5px solid black; padding: 5px;" data-expected-width="120" data-expected-height="120">
</div>
-
-PASS
-
+
PASS
-
+
PASS
-
+
PASS
-
+
PASS
+PASS
a a a
a
a
- PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "4"
PASS gFocusedDocument.activeElement.getAttribute("id") is "7"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
Test importing an xsl:stylesheet node as stylesheet for XSLTProcessor.
SUCCESS
-
-
Test that appcache works with authentication. Should say SUCCESS:
SUCCESS
-
-
Cache-control: max-age=0; (result=Uncached expected=Uncached) PASS
Cache-control: max-age=1; [delay=1.5s] (result=Uncached expected=Uncached) PASS
Cache-control: max-age=10, no-cache; (result=Uncached expected=Uncached) PASS
-
Last-modified: [now-3600s]; [delay=1.5s] (result=Cached expected=Cached) PASS
Last-modified: [now-10s]; [delay=1.5s] (result=Uncached expected=Uncached) PASS
Last-modified: [now+10s]; (result=Uncached expected=Uncached) PASS
-
Tests sending an array buffer view.
0 1 2 48 49 50 128 129 130 253 254 255
-
Tests sending a data view.
0 1 2 48 49 50 128 129 130 253 254 255
-
Tests that sending undefined or null results in an empty request body.
PASS for undefined
PASS for null
-
0,0,0,0
0,0,0,0
0,0,0,0
-
-
0,0,0,0
0,0,0,0
0,0,0,0
-
-
text run at (629,103) width 153: "You should see several"
text run at (782,103) width 2: " "
text run at (0,121) width 307: "pictures above all in the same line/paragraph."
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (0,0) size 0x0
caret: position 164 of child 4 {#text} of body
RenderText {#text} at (2,2) size 25x28
text run at (2,2) width 25: "ab"
RenderBlock (anonymous) at (0,32) size 784x0
- RenderText {#text} at (0,0) size 0x0
caret: position 2 of child 0 {#text} of child 0 {B} of child 1 {DIV} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 0 {#text} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 7 of child 0 {#text} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 0 {#text} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 7 of child 0 {#text} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 7 of child 0 {#text} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 0 {#text} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 7 of child 0 {#text} of child 3 {DIV} of body
RenderText {#text} at (0,0) size 39x18
text run at (0,0) width 39: "PASS"
RenderBR {BR} at (39,0) size 0x18
- RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 0 {#text} of child 3 {DIV} of body
text run at (3,0) width 128: "\x{543E}\x{8F29}\x{306F}\x{732B}\x{3067}\x{3042}\x{308B}\x{3002}"
text run at (27,0) width 128: "\x{540D}\x{524D}\x{306F}\x{307E}\x{3060}\x{7121}\x{3044}\x{3002}"
RenderBlock (anonymous) at (0,170) size 784x0
- RenderText {#text} at (0,0) size 0x0
RenderBlock {PRE} at (0,183) size 784x0
selection start: position 5 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
selection end: position 13 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
text run at (3,0) width 128: "\x{543E}\x{8F29}\x{306F}\x{732B}\x{3067}\x{3042}\x{308B}\x{3002}"
text run at (27,0) width 128: "\x{540D}\x{524D}\x{306F}\x{307E}\x{3060}\x{7121}\x{3044}\x{3002}"
RenderBlock (anonymous) at (0,170) size 784x0
- RenderText {#text} at (0,0) size 0x0
RenderBlock {PRE} at (0,183) size 784x0
selection start: position 2 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
selection end: position 10 of child 0 {#text} of child 1 {P} of child 3 {DIV} of body
RenderText {#text} at (121,2) size 23x18
text run at (121,2) width 23: "one"
RenderBlock (anonymous) at (0,22) size 784x0
- RenderText {#text} at (0,0) size 0x0
caret: position 3 of child 2 {#text} of child 1 {DIV} of child 3 {DIV} of body
'msng' ('type')
(null)
"[object Object]" ('utxt')
-
-
RenderInline {A} at (0,0) size 0x0 [color=#0000EE]
RenderText {#text} at (0,0) size 0x0
RenderBlock (anonymous) at (0,28) size 784x18
- RenderText {#text} at (0,0) size 0x0
RenderText {#text} at (0,0) size 104x18
text run at (0,0) width 104: "Form did submit"
RenderBR {BR} at (0,36) size 0x18
RenderBR {BR} at (0,54) size 0x18
RenderImage {INPUT} at (767,72) size 17x19
- RenderText {#text} at (0,0) size 0x0
RenderBR {BR} at (0,72) size 0x18
RenderBR {BR} at (0,90) size 0x18
RenderBlock {DIV} at (0,142) size 784x0
RenderInline {FONT} at (0,0) size 0x0
RenderText {#text} at (0,0) size 0x0
RenderBlock (anonymous) at (0,25) size 784x0
- RenderText {#text} at (0,0) size 0x0
RenderBlock {DIV} at (0,25) size 784x36
RenderText {#text} at (0,0) size 775x36
text run at (0,0) width 775: "Success! This test succeeds if the input named mover is not detached from its form when it is moved around in the DOM to"
RenderText {#text} at (123,0) size 126x18
text run at (123,0) width 126: " I should not be red."
RenderBlock (anonymous) at (0,170) size 784x18
- RenderText {#text} at (0,0) size 0x0
RenderInline {B} at (0,0) size 131x18
RenderText {#text} at (0,0) size 36x18
text run at (0,0) width 36: "Bold "
from innerText (TextIterator): 123456789
from attributedSubstringFromRange: 123456789
SUCCESS: Strings matched, although there is room for improvement because they were both wrong.
-
text run at (33,0) width 24: "inside"
RenderText {#text} at (0,0) size 0x0
RenderBlock (anonymous) at (2,15) size 90x0
- RenderText {#text} at (0,0) size 0x0
RenderBlock (anonymous) at (0,23) size 100x18
RenderText {#text} at (10,0) size 80x18
text run at (10,0) width 80: "outside table"
-If any thingers appear on this page, the test has failed.
+If any thingers appear on this page, the test has failed.
--------
Frame: '<!--framePath //<!--frame0-->-->'
-Two thingers should appear on this page. Otherwise the test has failed.
+Two thingers should appear on this page. Otherwise the test has failed.
--------
Frame: '<!--framePath //<!--frame0-->-->'
+2013-09-07 Antti Koivisto <antti@apple.com>
+
+ Remove unnecessary sibling text renderers after attach
+ https://bugs.webkit.org/show_bug.cgi?id=120953
+
+ Reviewed by the Swedish Review Team: Anders Carlsson and Andreas Kling.
+
+ The current createTextRenderersForSiblingsAfterAttachIfNeeded code only adds text renderers, never removes them.
+ Style changes can go either way.
+
+ The patch causes no visible changes in rendered output. The whitespace nodes that it affects are leftovers that
+ have no rendering effect. However it does change results of many dumpAsText and render tree dump based layout
+ tests as unnecessary text nodes disappear.
+
+ The main goal is to make results of dynamic attach and parsing time attach produce more similar results. As
+ an added bonus we get slightly simpler rendering trees.
+
+ Rendering tree dumps show us still leaving behind empty anonymous blocks when removing whitespace text nodes.
+ Those should collapse away too.
+
+ * style/StyleResolveTree.cpp:
+ (WebCore::Style::reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded):
+
+ Allow the code both create and remove text renderers.
+ Tighten to bail out faster if case is not the exact one that matters.
+ Use NodeRenderingTraversal to mirror textRendererIsNeeded.
+ Renamed for clarity.
+
+ (WebCore::Style::updateTextRendererAfterContentChange):
+ (WebCore::Style::resolveLocal):
+ (WebCore::Style::updateTextStyle):
+ (WebCore::Style::attachRenderTree):
+
2013-09-07 Anders Carlsson <andersca@apple.com>
Get rid of FastAllocBase.h
return 0;
}
-static void createTextRenderersForSiblingsAfterAttachIfNeeded(Node& node)
+static void reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(Node& current)
{
- if (!node.renderer())
+ if (current.isInsertionPoint())
return;
- // If this node got a renderer it may be the previousRenderer() of sibling text nodes and thus affect the
- // result of Text::textRendererIsNeeded() for those nodes.
- for (Node* sibling = node.nextSibling(); sibling; sibling = sibling->nextSibling()) {
- if (sibling->renderer())
- break;
+ // This function finds sibling text renderers where the results of textRendererIsNeeded may have changed as a result of
+ // the current node gaining or losing the renderer. This can only affect white space text nodes.
+ for (Node* sibling = NodeRenderingTraversal::nextSibling(¤t); sibling; sibling = NodeRenderingTraversal::nextSibling(sibling)) {
+ // Siblings haven't been attached yet. They will be handled normally when they are.
if (!sibling->attached())
- break; // Assume this means none of the following siblings are attached.
+ return;
+ if (sibling->isElementNode()) {
+ // Text renderers beyond rendered elements can't be affected.
+ if (!sibling->renderer() || isRendererReparented(sibling->renderer()))
+ continue;
+ return;
+ }
if (!sibling->isTextNode())
continue;
- attachTextRenderer(*toText(sibling));
- // If we again decided not to create a renderer for next, we can bail out the loop,
- // because it won't affect the result of Text::textRendererIsNeeded() for the rest
- // of sibling nodes.
- if (!sibling->renderer())
- break;
+ Text& textSibling = *toText(sibling);
+ if (!textSibling.length() || !textSibling.containsOnlyWhitespace())
+ return;
+ Text& whitespaceTextSibling = textSibling;
+ bool hadRenderer = whitespaceTextSibling.renderer();
+ detachTextRenderer(whitespaceTextSibling);
+ attachTextRenderer(whitespaceTextSibling);
+ // No changes, futher renderers can't be affected.
+ if (hadRenderer == !!whitespaceTextSibling.renderer())
+ return;
}
}
RenderText* textRenderer = toRenderText(textNode.renderer());
if (!textRenderer) {
attachTextRenderer(textNode);
- createTextRenderersForSiblingsAfterAttachIfNeeded(textNode);
+ reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(textNode);
return;
}
RenderObject* parentRenderer = NodeRenderingTraversal::parent(&textNode)->renderer();
if (!textRendererIsNeeded(textNode, *parentRenderer, *textRenderer->style())) {
detachTextRenderer(textNode);
attachTextRenderer(textNode);
+ reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(textNode);
return;
}
textRenderer->setTextWithOffset(textNode.dataImpl(), offsetOfReplacedData, lengthOfReplacedData);
if (current.attached())
detachRenderTree(current, ReattachDetach);
attachRenderTree(current, newStyle.get());
- createTextRenderersForSiblingsAfterAttachIfNeeded(current);
+ reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(current);
return Detach;
}
renderer->setText(text.dataImpl());
else {
attachTextRenderer(text);
- createTextRenderersForSiblingsAfterAttachIfNeeded(text);
+ reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(text);
}
text.clearNeedsStyleRecalc();
}
void attachRenderTree(Element& element)
{
attachRenderTree(element, nullptr);
- createTextRenderersForSiblingsAfterAttachIfNeeded(element);
+ reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(element);
}
void detachRenderTree(Element& element)