Title: [172494] trunk
Revision
172494
Author
[email protected]
Date
2014-08-12 14:31:23 -0700 (Tue, 12 Aug 2014)

Log Message

Don't recurse into non-rendered subtrees when computing style
https://bugs.webkit.org/show_bug.cgi?id=135844

Reviewed by Andreas Kling.
Source/WebCore:


* style/StyleResolveTree.cpp:
(WebCore::Style::resetStyleForNonRenderedDescendants):
        
Do a simple reset of the style dirty bits and any computed style in non-rendered subtrees.

(WebCore::Style::attachRenderTree):
(WebCore::Style::resolveTree):
        
Don't recurse into descendants if the element does not create a renderer.
We didn't compute style anyway in such subtrees.

LayoutTests:

        
Rebase.

* http/tests/security/video-poster-cross-origin-crash-expected.txt:
* platform/mac/fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (172493 => 172494)


--- trunk/LayoutTests/ChangeLog	2014-08-12 20:58:07 UTC (rev 172493)
+++ trunk/LayoutTests/ChangeLog	2014-08-12 21:31:23 UTC (rev 172494)
@@ -1,3 +1,15 @@
+2014-08-12  Antti Koivisto  <[email protected]>
+
+        Don't recurse into non-rendered subtrees when computing style
+        https://bugs.webkit.org/show_bug.cgi?id=135844
+
+        Reviewed by Andreas Kling.
+        
+        Rebase.
+
+        * http/tests/security/video-poster-cross-origin-crash-expected.txt:
+        * platform/mac/fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt:
+
 2014-08-12  Fabien VallĂ©e  <[email protected]>
 
         [GStreamer] playback rate is rounded to integer

Modified: trunk/LayoutTests/http/tests/security/video-poster-cross-origin-crash-expected.txt (172493 => 172494)


--- trunk/LayoutTests/http/tests/security/video-poster-cross-origin-crash-expected.txt	2014-08-12 20:58:07 UTC (rev 172493)
+++ trunk/LayoutTests/http/tests/security/video-poster-cross-origin-crash-expected.txt	2014-08-12 21:31:23 UTC (rev 172494)
@@ -1,3 +1,2 @@
 CONSOLE MESSAGE: Cross-origin image load denied by Cross-Origin Resource Sharing policy.
-CONSOLE MESSAGE: Cross-origin image load denied by Cross-Origin Resource Sharing policy.
 >>>

Modified: trunk/LayoutTests/platform/mac/fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt (172493 => 172494)


--- trunk/LayoutTests/platform/mac/fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt	2014-08-12 20:58:07 UTC (rev 172493)
+++ trunk/LayoutTests/platform/mac/fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt	2014-08-12 21:31:23 UTC (rev 172494)
@@ -4,7 +4,7 @@
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
       RenderBlock {SUMMARY} at (0,0) size 784x184
-        RenderInline {I} at (0,0) size 304x18
+        RenderInline {I} at (0,0) size 604x18
           RenderRuby (inline) {RUBY} at (0,0) size 300x18
             RenderRubyRun (anonymous) at (0,171) size 0x0
               RenderRubyText {RT} at (0,0) size 0x0
@@ -20,7 +20,7 @@
                   RenderBlock {DIV} at (0,150) size 300x-8
           RenderText {#text} at (300,157) size 4x18
             text run at (300,157) width 4: " "
-        RenderEmbeddedObject {OBJECT} at (304,21) size 300x150
+          RenderEmbeddedObject {OBJECT} at (304,21) size 300x150
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {DIV} at (0,184) size 784x18
         RenderInline {A} at (0,0) size 138x18 [color=#0000EE]
@@ -29,4 +29,4 @@
         RenderText {#text} at (138,0) size 455x18
           text run at (138,0) width 455: ". This test must be run under Guard Malloc. It passes if it does not crash."
 selection start: position 0 of child 1 {OBJECT} of child 3 {H1} of child 0 {RUBY} of child 1 {I} of child 0 {SUMMARY} of body
-selection end:   position 0 of child 3 {#text} of child 0 {SUMMARY} of body
+selection end:   position 1 of child 2 {OBJECT} of child 1 {I} of child 0 {SUMMARY} of body

Modified: trunk/Source/WebCore/ChangeLog (172493 => 172494)


--- trunk/Source/WebCore/ChangeLog	2014-08-12 20:58:07 UTC (rev 172493)
+++ trunk/Source/WebCore/ChangeLog	2014-08-12 21:31:23 UTC (rev 172494)
@@ -1,5 +1,23 @@
 2014-08-12  Antti Koivisto  <[email protected]>
 
+        Don't recurse into non-rendered subtrees when computing style
+        https://bugs.webkit.org/show_bug.cgi?id=135844
+
+        Reviewed by Andreas Kling.
+
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::resetStyleForNonRenderedDescendants):
+        
+        Do a simple reset of the style dirty bits and any computed style in non-rendered subtrees.
+
+        (WebCore::Style::attachRenderTree):
+        (WebCore::Style::resolveTree):
+        
+        Don't recurse into descendants if the element does not create a renderer.
+        We didn't compute style anyway in such subtrees.
+
+2014-08-12  Antti Koivisto  <[email protected]>
+
         Remove isInCanvasSubtree bit
         https://bugs.webkit.org/show_bug.cgi?id=135837
 

Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (172493 => 172494)


--- trunk/Source/WebCore/style/StyleResolveTree.cpp	2014-08-12 20:58:07 UTC (rev 172493)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp	2014-08-12 21:31:23 UTC (rev 172494)
@@ -555,6 +555,27 @@
     current.clearAfterPseudoElement();
 }
 
+static void resetStyleForNonRenderedDescendants(Element& current)
+{
+    ASSERT(!current.renderStyle());
+    auto descendants = descendantsOfType<Element>(current);
+    auto it = descendants.begin();
+    auto end = descendants.end();
+    while (it != end) {
+        auto& element = *it;
+        ASSERT(!element.renderStyle());
+        if (element.needsStyleRecalc()) {
+            element.resetComputedStyle();
+            element.clearNeedsStyleRecalc();
+        }
+        if (element.childNeedsStyleRecalc()) {
+            element.clearChildNeedsStyleRecalc();
+            it.traverseNext();
+        } else
+            it.traverseNextSkippingChildren();
+    }
+}
+
 static bool needsPseudoElement(Element& current, PseudoId pseudoId)
 {
     if (!current.document().styleSheetCollection().usesBeforeAfterRules())
@@ -582,36 +603,41 @@
     PostResolutionCallbackDisabler callbackDisabler(current.document());
     WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
 
+    if (isInsertionPoint(current)) {
+        attachDistributedChildren(toInsertionPoint(current), inheritedStyle, renderTreePosition);
+        return;
+    }
+
     if (current.hasCustomStyleResolveCallbacks())
         current.willAttachRenderers();
 
     createRendererIfNeeded(current, inheritedStyle, renderTreePosition, resolvedStyle);
 
-    StyleResolverParentPusher parentPusher(&current);
+    if (RenderStyle* style = current.renderStyle()) {
+        StyleResolverParentPusher parentPusher(&current);
 
-    RenderTreePosition childRenderTreePosition(current.renderer());
-    attachBeforeOrAfterPseudoElementIfNeeded(current, BEFORE, childRenderTreePosition);
+        RenderTreePosition childRenderTreePosition(current.renderer());
+        attachBeforeOrAfterPseudoElementIfNeeded(current, BEFORE, childRenderTreePosition);
 
-    if (ShadowRoot* shadowRoot = current.shadowRoot()) {
-        parentPusher.push();
-        attachShadowRoot(*shadowRoot);
-    } else if (current.firstChild())
-        parentPusher.push();
+        if (ShadowRoot* shadowRoot = current.shadowRoot()) {
+            parentPusher.push();
+            attachShadowRoot(*shadowRoot);
+        } else if (current.firstChild())
+            parentPusher.push();
 
-    if (isInsertionPoint(current))
-        attachDistributedChildren(toInsertionPoint(current), inheritedStyle, renderTreePosition);
-    else
-        attachChildren(current, current.renderStyle(), childRenderTreePosition);
+        attachChildren(current, style, childRenderTreePosition);
 
-    current.clearNeedsStyleRecalc();
-    current.clearChildNeedsStyleRecalc();
+        if (AXObjectCache* cache = current.document().axObjectCache())
+            cache->updateCacheAfterNodeIsAttached(&current);
 
-    if (AXObjectCache* cache = current.document().axObjectCache())
-        cache->updateCacheAfterNodeIsAttached(&current);
+        attachBeforeOrAfterPseudoElementIfNeeded(current, AFTER, childRenderTreePosition);
 
-    attachBeforeOrAfterPseudoElementIfNeeded(current, AFTER, childRenderTreePosition);
+        current.updateFocusAppearanceAfterAttachIfNeeded();
+    } else
+        resetStyleForNonRenderedDescendants(current);
 
-    current.updateFocusAppearanceAfterAttachIfNeeded();
+    current.clearNeedsStyleRecalc();
+    current.clearChildNeedsStyleRecalc();
 
     if (current.hasCustomStyleResolveCallbacks())
         current.didAttachRenderers();
@@ -884,7 +910,9 @@
     if (inheritedStyle && (change >= Inherit || current.needsStyleRecalc()))
         change = resolveLocal(current, inheritedStyle, renderTreePosition, change);
 
-    if (change != Detach) {
+    RenderStyle* style = current.renderStyle();
+
+    if (change != Detach && style) {
         StyleResolverParentPusher parentPusher(&current);
 
         if (ShadowRoot* shadowRoot = current.shadowRoot()) {
@@ -917,7 +945,7 @@
                 childElement->setNeedsStyleRecalc();
             if (change >= Inherit || childElement->childNeedsStyleRecalc() || childElement->needsStyleRecalc()) {
                 parentPusher.push();
-                resolveTree(*childElement, current.renderStyle(), childRenderTreePosition, change);
+                resolveTree(*childElement, style, childRenderTreePosition, change);
             }
             forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;
             forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules);
@@ -925,6 +953,8 @@
 
         updateBeforeOrAfterPseudoElement(current, change, AFTER, childRenderTreePosition);
     }
+    if (change != Detach && !style)
+        resetStyleForNonRenderedDescendants(current);
 
     current.clearNeedsStyleRecalc();
     current.clearChildNeedsStyleRecalc();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to