Remove unnecessary sibling text renderers after attach
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Sep 2013 18:25:46 +0000 (18:25 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Sep 2013 18:25:46 +0000 (18:25 +0000)
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

68 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/flexbox/flex-flow-auto-margins-expected.txt
LayoutTests/css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt
LayoutTests/css3/flexbox/flex-flow-border-expected.txt
LayoutTests/css3/flexbox/flex-flow-margins-auto-size-expected.txt
LayoutTests/css3/flexbox/flex-flow-margins-expected.txt
LayoutTests/css3/flexbox/flex-flow-orientations-expected.txt
LayoutTests/css3/flexbox/flex-flow-overflow-expected.txt
LayoutTests/css3/flexbox/flex-flow-padding-expected.txt
LayoutTests/css3/flexbox/flexbox-ignore-firstLetter-expected.txt
LayoutTests/css3/flexbox/inline-flexbox-ignore-firstLine-expected.txt
LayoutTests/css3/flexbox/intrinsic-min-width-applies-with-fixed-width-expected.txt
LayoutTests/editing/selection/focus-crash-expected.txt
LayoutTests/editing/style/toggle-style-bold-italic-expected.txt
LayoutTests/editing/style/toggle-style-bold-italic-mixed-editability-expected.txt
LayoutTests/fast/block/float/intruding-float-not-removed-writing-mode-expected.txt
LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt
LayoutTests/fast/css/import-style-update-expected.txt
LayoutTests/fast/css/positioned-overflow-scroll-expected.txt
LayoutTests/fast/dom/HTMLLinkElement/resolve-url-on-insertion-expected.txt
LayoutTests/fast/dom/search-shadow-host-crash-expected.txt
LayoutTests/fast/dynamic/inline-to-block-crash-expected.txt
LayoutTests/fast/events/input-element-display-none-in-dragleave-crash-expected.txt
LayoutTests/fast/flexbox/intrinsic-min-width-applies-with-fixed-width-expected.txt
LayoutTests/fast/forms/select-listbox-focus-displaynone-expected.txt
LayoutTests/fast/frames/repaint-display-none-crash-expected.txt
LayoutTests/fast/inline/inline-with-empty-inline-children-expected.txt
LayoutTests/fast/inline/out-of-flow-objects-and-whitespace-after-empty-inline-expected.txt
LayoutTests/fast/repaint/text-in-relative-positioned-inline-expected.txt
LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-expected.txt
LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-vertical-lr-expected.txt
LayoutTests/fast/replaced/preferred-widths-expected.txt
LayoutTests/fast/spatial-navigation/snav-tiny-table-traversal-expected.txt
LayoutTests/fast/table/min-max-width-preferred-size-expected.txt
LayoutTests/fast/xsl/import-non-document-node-expected.txt
LayoutTests/fullscreen/full-screen-fixed-pos-parent-expected.txt
LayoutTests/http/tests/appcache/auth-expected.txt
LayoutTests/http/tests/cache/subresource-expiration-1-expected.txt
LayoutTests/http/tests/cache/subresource-expiration-2-expected.txt
LayoutTests/http/tests/xmlhttprequest/send-array-buffer-expected.txt
LayoutTests/http/tests/xmlhttprequest/send-data-view-expected.txt
LayoutTests/http/tests/xmlhttprequest/send-undefined-and-null-expected.txt
LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-plain-expected.txt
LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-styled-expected.txt
LayoutTests/platform/mac/editing/pasteboard/4989774-expected.txt
LayoutTests/platform/mac/editing/pasteboard/paste-match-style-001-expected.txt
LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.txt
LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.txt
LayoutTests/platform/mac/editing/selection/caret-ltr-expected.txt
LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.txt
LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.txt
LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.txt
LayoutTests/platform/mac/editing/selection/caret-rtl-expected.txt
LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.txt
LayoutTests/platform/mac/editing/selection/vertical-rl-ltr-extend-line-backward-wrap-expected.txt
LayoutTests/platform/mac/editing/selection/vertical-rl-ltr-extend-line-forward-wrap-expected.txt
LayoutTests/platform/mac/editing/style/style-boundary-005-expected.txt
LayoutTests/platform/mac/fast/AppleScript/001-expected.txt
LayoutTests/platform/mac/fast/forms/formmove3-expected.txt
LayoutTests/platform/mac/fast/forms/input-align-image-expected.txt
LayoutTests/platform/mac/fast/forms/preserveFormDuringResidualStyle-expected.txt
LayoutTests/platform/mac/fast/invalid/003-expected.txt
LayoutTests/platform/mac/fast/text/attributed-substring-from-range-002-expected.txt
LayoutTests/platform/mac/tables/mozilla/bugs/bug647-expected.txt
LayoutTests/userscripts/user-script-all-frames-expected.txt
LayoutTests/userscripts/user-script-top-frame-only-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/style/StyleResolveTree.cpp

index 11f05cc..ad77b72 100644 (file)
@@ -1,3 +1,86 @@
+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.
index 3aead6f..156bc4d 100644 (file)
@@ -142,4 +142,3 @@ Expected 90 for width, but got 60.
 <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>
-
index bd626aa..70155ba 100644 (file)
@@ -1,2 +1,2 @@
-To run this test manually, click the "Crash me" button. 
+To run this test manually, click the "Crash me" button.  
 SUCCEEDED
index e765982..26701d3 100644 (file)
@@ -68,4 +68,3 @@ execBoldCommand: <div id="test"> <div><b>Some text</b></div> <p><b>Some more tex
 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>
-
index dba58a5..717e1af 100644 (file)
@@ -66,4 +66,3 @@ execBoldCommand: <div id="test"><b> Editable </b><span contenteditable="false">N
 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>
-
index f112c32..a0547d0 100644 (file)
@@ -1,3 +1,2 @@
 Test that modifying @import stylesheet through DOM updates style properly. You should see PASS below:
 PASS
-
index 16adea1..a2d43f4 100644 (file)
@@ -3,5 +3,3 @@ This tests that links resouce URLs are resolved dynamically when inserted into t
 I should be blue...and I am!!!
 
 I should be red...and I am!!!
-
-
index d2bc04e..665cff7 100644 (file)
@@ -1,5 +1,3 @@
 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.
-
-
index 4d49176..b81ff9a 100644 (file)
@@ -1,9 +1,8 @@
 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
-
index c233f07..9603916 100644 (file)
@@ -4,5 +4,4 @@ layer at (0,0) size 800x600
   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]
index a3e185d..6ddff4a 100644 (file)
@@ -2,30 +2,29 @@ Test the effect of percentages widths on the preferred widths of replaced elemen
 
 
 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
index 70360c3..d62f466 100644 (file)
@@ -4,7 +4,7 @@ a       a       a
 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"
index 7ec3f83..9ce9b56 100644 (file)
@@ -1,5 +1,3 @@
 Test that appcache works with authentication. Should say SUCCESS:
 
 SUCCESS
-
-
index b1d8f83..13944ca 100644 (file)
@@ -9,4 +9,3 @@ Cache-control: max-age=10; (result=Cached expected=Cached) PASS
 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
-
index 789295e..3900289 100644 (file)
@@ -11,4 +11,3 @@ Expires: [now+10s]; Cache-control: max-age=0; (result=Uncached expected=Uncached
 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
-
index 9497ab2..cc001ff 100644 (file)
@@ -12,6 +12,4 @@ layer at (0,0) size 800x600
         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
index 7046b56..2806ec9 100644 (file)
@@ -44,5 +44,4 @@ layer at (0,0) size 800x600
             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
index e4dcf80..ba8425f 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x139
         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
index 30304c6..6cb1aba 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x139
         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
index 4f95f1e..40c81d3 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x139
         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
index 8af08ea..5b7e480 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x139
         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
index 23f8f0b..3b1d05a 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x140
         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
index 6855fcf..83e62a5 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x140
         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
index c27028a..0ab08c5 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x140
         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
index 7088f59..fee2153 100644 (file)
@@ -14,5 +14,4 @@ layer at (0,0) size 800x140
         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
index e1cf64b..35ad3cc 100644 (file)
@@ -12,7 +12,6 @@ layer at (0,0) size 800x199
             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
index 27e8c78..71cd375 100644 (file)
@@ -12,7 +12,6 @@ layer at (0,0) size 800x199
             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
index 315aa80..8ba5c8b 100644 (file)
@@ -65,5 +65,4 @@ layer at (0,0) size 800x600
           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
index 218a88b..f1e7753 100644 (file)
@@ -26,6 +26,5 @@ layer at (0,0) size 800x600
           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"
index 180085f..9297f19 100644 (file)
@@ -14,7 +14,6 @@ layer at (0,0) size 800x600
         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
index 8aba2b1..7e785e6 100644 (file)
@@ -23,7 +23,6 @@ layer at (0,0) size 800x600
           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"
index 5726e6e..30773ac 100644 (file)
@@ -49,7 +49,6 @@ layer at (0,0) size 800x600
         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 "
index bf8d0fc..c949541 100644 (file)
@@ -6,4 +6,3 @@ actual text: \n123456789
 from innerText (TextIterator): 123456789
 from attributedSubstringFromRange: 123456789
 SUCCESS: Strings matched, although there is room for improvement because they were both wrong.
-
index 18796fa..32ccf8f 100644 (file)
@@ -25,7 +25,6 @@ layer at (0,0) size 800x600
                               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"
index fd16428..091e199 100644 (file)
@@ -1,4 +1,4 @@
-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-->-->'
index f31fccb..b96b900 100644 (file)
@@ -1,4 +1,4 @@
-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-->-->'
index fd79ff0..8be888d 100644 (file)
@@ -1,3 +1,36 @@
+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
index 062cf3c..169e8cb 100644 (file)
@@ -280,25 +280,34 @@ static RenderObject* nextSiblingRenderer(const Text& textNode)
     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(&current); 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;
     }
 }
 
@@ -407,13 +416,14 @@ void updateTextRendererAfterContentChange(Text& textNode, unsigned offsetOfRepla
     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);
@@ -589,7 +599,7 @@ static Change resolveLocal(Element& current, Change inheritedChange)
         if (current.attached())
             detachRenderTree(current, ReattachDetach);
         attachRenderTree(current, newStyle.get());
-        createTextRenderersForSiblingsAfterAttachIfNeeded(current);
+        reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(current);
 
         return Detach;
     }
@@ -633,7 +643,7 @@ static void updateTextStyle(Text& text, RenderStyle* parentElementStyle, Style::
         renderer->setText(text.dataImpl());
     else {
         attachTextRenderer(text);
-        createTextRenderersForSiblingsAfterAttachIfNeeded(text);
+        reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(text);
     }
     text.clearNeedsStyleRecalc();
 }
@@ -817,7 +827,7 @@ void resolveTree(Document& document, Change change)
 void attachRenderTree(Element& element)
 {
     attachRenderTree(element, nullptr);
-    createTextRenderersForSiblingsAfterAttachIfNeeded(element);
+    reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(element);
 }
 
 void detachRenderTree(Element& element)