Changeset 172494 in webkit


Ignore:
Timestamp:
Aug 12, 2014 2:31:23 PM (10 years ago)
Author:
Antti Koivisto
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r172472 r172494  
     12014-08-12  Antti Koivisto  <antti@apple.com>
     2
     3        Don't recurse into non-rendered subtrees when computing style
     4        https://bugs.webkit.org/show_bug.cgi?id=135844
     5
     6        Reviewed by Andreas Kling.
     7       
     8        Rebase.
     9
     10        * http/tests/security/video-poster-cross-origin-crash-expected.txt:
     11        * platform/mac/fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt:
     12
    1132014-08-12  Fabien Vallée  <fvallee@connected-labs.com>
    214
  • trunk/LayoutTests/http/tests/security/video-poster-cross-origin-crash-expected.txt

    r123121 r172494  
    1 CONSOLE MESSAGE: Cross-origin image load denied by Cross-Origin Resource Sharing policy.
    21CONSOLE MESSAGE: Cross-origin image load denied by Cross-Origin Resource Sharing policy.
    32>>>
  • trunk/LayoutTests/platform/mac/fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt

    r164375 r172494  
    55    RenderBody {BODY} at (8,8) size 784x584
    66      RenderBlock {SUMMARY} at (0,0) size 784x184
    7         RenderInline {I} at (0,0) size 304x18
     7        RenderInline {I} at (0,0) size 604x18
    88          RenderRuby (inline) {RUBY} at (0,0) size 300x18
    99            RenderRubyRun (anonymous) at (0,171) size 0x0
     
    2121          RenderText {#text} at (300,157) size 4x18
    2222            text run at (300,157) width 4: " "
    23         RenderEmbeddedObject {OBJECT} at (304,21) size 300x150
     23          RenderEmbeddedObject {OBJECT} at (304,21) size 300x150
    2424        RenderText {#text} at (0,0) size 0x0
    2525      RenderBlock {DIV} at (0,184) size 784x18
     
    3030          text run at (138,0) width 455: ". This test must be run under Guard Malloc. It passes if it does not crash."
    3131selection 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
    32 selection end:   position 0 of child 3 {#text} of child 0 {SUMMARY} of body
     32selection end:   position 1 of child 2 {OBJECT} of child 1 {I} of child 0 {SUMMARY} of body
  • trunk/Source/WebCore/ChangeLog

    r172487 r172494  
     12014-08-12  Antti Koivisto  <antti@apple.com>
     2
     3        Don't recurse into non-rendered subtrees when computing style
     4        https://bugs.webkit.org/show_bug.cgi?id=135844
     5
     6        Reviewed by Andreas Kling.
     7
     8        * style/StyleResolveTree.cpp:
     9        (WebCore::Style::resetStyleForNonRenderedDescendants):
     10       
     11        Do a simple reset of the style dirty bits and any computed style in non-rendered subtrees.
     12
     13        (WebCore::Style::attachRenderTree):
     14        (WebCore::Style::resolveTree):
     15       
     16        Don't recurse into descendants if the element does not create a renderer.
     17        We didn't compute style anyway in such subtrees.
     18
    1192014-08-12  Antti Koivisto  <antti@apple.com>
    220
  • trunk/Source/WebCore/style/StyleResolveTree.cpp

    r172487 r172494  
    556556}
    557557
     558static void resetStyleForNonRenderedDescendants(Element& current)
     559{
     560    ASSERT(!current.renderStyle());
     561    auto descendants = descendantsOfType<Element>(current);
     562    auto it = descendants.begin();
     563    auto end = descendants.end();
     564    while (it != end) {
     565        auto& element = *it;
     566        ASSERT(!element.renderStyle());
     567        if (element.needsStyleRecalc()) {
     568            element.resetComputedStyle();
     569            element.clearNeedsStyleRecalc();
     570        }
     571        if (element.childNeedsStyleRecalc()) {
     572            element.clearChildNeedsStyleRecalc();
     573            it.traverseNext();
     574        } else
     575            it.traverseNextSkippingChildren();
     576    }
     577}
     578
    558579static bool needsPseudoElement(Element& current, PseudoId pseudoId)
    559580{
     
    583604    WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
    584605
     606    if (isInsertionPoint(current)) {
     607        attachDistributedChildren(toInsertionPoint(current), inheritedStyle, renderTreePosition);
     608        return;
     609    }
     610
    585611    if (current.hasCustomStyleResolveCallbacks())
    586612        current.willAttachRenderers();
     
    588614    createRendererIfNeeded(current, inheritedStyle, renderTreePosition, resolvedStyle);
    589615
    590     StyleResolverParentPusher parentPusher(&current);
    591 
    592     RenderTreePosition childRenderTreePosition(current.renderer());
    593     attachBeforeOrAfterPseudoElementIfNeeded(current, BEFORE, childRenderTreePosition);
    594 
    595     if (ShadowRoot* shadowRoot = current.shadowRoot()) {
    596         parentPusher.push();
    597         attachShadowRoot(*shadowRoot);
    598     } else if (current.firstChild())
    599         parentPusher.push();
    600 
    601     if (isInsertionPoint(current))
    602         attachDistributedChildren(toInsertionPoint(current), inheritedStyle, renderTreePosition);
    603     else
    604         attachChildren(current, current.renderStyle(), childRenderTreePosition);
     616    if (RenderStyle* style = current.renderStyle()) {
     617        StyleResolverParentPusher parentPusher(&current);
     618
     619        RenderTreePosition childRenderTreePosition(current.renderer());
     620        attachBeforeOrAfterPseudoElementIfNeeded(current, BEFORE, childRenderTreePosition);
     621
     622        if (ShadowRoot* shadowRoot = current.shadowRoot()) {
     623            parentPusher.push();
     624            attachShadowRoot(*shadowRoot);
     625        } else if (current.firstChild())
     626            parentPusher.push();
     627
     628        attachChildren(current, style, childRenderTreePosition);
     629
     630        if (AXObjectCache* cache = current.document().axObjectCache())
     631            cache->updateCacheAfterNodeIsAttached(&current);
     632
     633        attachBeforeOrAfterPseudoElementIfNeeded(current, AFTER, childRenderTreePosition);
     634
     635        current.updateFocusAppearanceAfterAttachIfNeeded();
     636    } else
     637        resetStyleForNonRenderedDescendants(current);
    605638
    606639    current.clearNeedsStyleRecalc();
    607640    current.clearChildNeedsStyleRecalc();
    608 
    609     if (AXObjectCache* cache = current.document().axObjectCache())
    610         cache->updateCacheAfterNodeIsAttached(&current);
    611 
    612     attachBeforeOrAfterPseudoElementIfNeeded(current, AFTER, childRenderTreePosition);
    613 
    614     current.updateFocusAppearanceAfterAttachIfNeeded();
    615641
    616642    if (current.hasCustomStyleResolveCallbacks())
     
    885911        change = resolveLocal(current, inheritedStyle, renderTreePosition, change);
    886912
    887     if (change != Detach) {
     913    RenderStyle* style = current.renderStyle();
     914
     915    if (change != Detach && style) {
    888916        StyleResolverParentPusher parentPusher(&current);
    889917
     
    918946            if (change >= Inherit || childElement->childNeedsStyleRecalc() || childElement->needsStyleRecalc()) {
    919947                parentPusher.push();
    920                 resolveTree(*childElement, current.renderStyle(), childRenderTreePosition, change);
     948                resolveTree(*childElement, style, childRenderTreePosition, change);
    921949            }
    922950            forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;
     
    926954        updateBeforeOrAfterPseudoElement(current, change, AFTER, childRenderTreePosition);
    927955    }
     956    if (change != Detach && !style)
     957        resetStyleForNonRenderedDescendants(current);
    928958
    929959    current.clearNeedsStyleRecalc();
Note: See TracChangeset for help on using the changeset viewer.