Changeset 208378 in webkit


Ignore:
Timestamp:
Nov 3, 2016 11:21:06 PM (7 years ago)
Author:
Antti Koivisto
Message:

REGRESSION (r207717): DumpRenderTree crashed in com.apple.WebCore: WebCore::Style::Scope::flushPendingUpdate + 16
https://bugs.webkit.org/show_bug.cgi?id=164397
<rdar://problem/29100135>

Reviewed by Ryosuke Niwa.

The problem here was that we were leaving stale pointers to Document::m_inDocumentShadowRoots set when
using fast-path document teardown.

(Patch and stories mostly by rniwa).

  • dom/Document.cpp:

(WebCore::Document::~Document):
(WebCore::Document::didInsertInDocumentShadowRoot):
(WebCore::Document::didRemoveInDocumentShadowRoot):

Improve asserts.

  • dom/Element.cpp:

(WebCore::Element::removeShadowRoot):

Remove the superfluous call to notifyChildNodeRemoved in Element::removeShadowRoot to
avoid invoking notifyChildNodeRemoved during a document teardown, which is incorrect. It's sufficient that
~ShadowRoot calls ContainerNode::removeDetachedChildren(), and in turn removeDetachedChildrenInContainer()
since the latter function tears down nodes via the deletion queue during a document destruction and use
notifyChildNodeRemoved() on nodes that outlive the shadow root.

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::~ShadowRoot):

Take care to clean up inDocumentShadowRoots for fast-pathed destruction too.

(WebCore::ShadowRoot::insertedInto):
(WebCore::ShadowRoot::removedFrom):

Improve ShadowRoot's insertedInto and removedFrom so that they only try to add and remove itself from
m_inDocumentShadowRoots when the connected-ness changes.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r208371 r208378  
     12016-11-03  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (r207717): DumpRenderTree crashed in com.apple.WebCore: WebCore::Style::Scope::flushPendingUpdate + 16
     4        https://bugs.webkit.org/show_bug.cgi?id=164397
     5        <rdar://problem/29100135>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        The problem here was that we were leaving stale pointers to Document::m_inDocumentShadowRoots set when
     10        using fast-path document teardown.
     11
     12        (Patch and stories mostly by rniwa).
     13
     14        * dom/Document.cpp:
     15        (WebCore::Document::~Document):
     16        (WebCore::Document::didInsertInDocumentShadowRoot):
     17        (WebCore::Document::didRemoveInDocumentShadowRoot):
     18
     19            Improve asserts.
     20
     21        * dom/Element.cpp:
     22        (WebCore::Element::removeShadowRoot):
     23
     24            Remove the superfluous call to notifyChildNodeRemoved in Element::removeShadowRoot to
     25            avoid invoking notifyChildNodeRemoved during a document teardown, which is incorrect. It's sufficient that
     26            ~ShadowRoot calls ContainerNode::removeDetachedChildren(), and in turn removeDetachedChildrenInContainer()
     27            since the latter function tears down nodes via the deletion queue during a document destruction and use
     28            notifyChildNodeRemoved() on nodes that outlive the shadow root.
     29
     30        * dom/ShadowRoot.cpp:
     31        (WebCore::ShadowRoot::~ShadowRoot):
     32
     33            Take care to clean up inDocumentShadowRoots for fast-pathed destruction too.
     34
     35        (WebCore::ShadowRoot::insertedInto):
     36        (WebCore::ShadowRoot::removedFrom):
     37
     38            Improve ShadowRoot's insertedInto and removedFrom so that they only try to add and remove itself from
     39            m_inDocumentShadowRoots when the connected-ness changes.
     40
    1412016-11-03  Simon Fraser  <simon.fraser@apple.com>
    242
  • trunk/Source/WebCore/dom/Document.cpp

    r208371 r208378  
    592592    ASSERT(!m_parentTreeScope);
    593593    ASSERT(!m_disabledFieldsetElementsCount);
     594    ASSERT(m_inDocumentShadowRoots.isEmpty());
    594595
    595596#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
     
    69816982{
    69826983    ASSERT(shadowRoot.inDocument());
     6984    ASSERT(!m_inDocumentShadowRoots.contains(&shadowRoot));
    69836985    m_inDocumentShadowRoots.add(&shadowRoot);
    69846986}
  • trunk/Source/WebCore/dom/Element.cpp

    r208356 r208378  
    17851785    oldRoot->setHost(nullptr);
    17861786    oldRoot->setParentTreeScope(&document());
    1787 
    1788     notifyChildNodeRemoved(*this, *oldRoot);
    17891787}
    17901788
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r208356 r208378  
    7171ShadowRoot::~ShadowRoot()
    7272{
     73    if (inDocument())
     74        document().didRemoveInDocumentShadowRoot(*this);
     75
    7376    // We cannot let ContainerNode destructor call willBeDeletedFrom()
    7477    // for this ShadowRoot instance because TreeScope destructor
     
    8588Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode& insertionPoint)
    8689{
    87     auto result = DocumentFragment::insertedInto(insertionPoint);
    88     if (inDocument())
     90    bool wasInDocument = inDocument();
     91    DocumentFragment::insertedInto(insertionPoint);
     92    if (insertionPoint.inDocument() && !wasInDocument)
    8993        document().didInsertInDocumentShadowRoot(*this);
    90     return result;
     94    return InsertionDone;
    9195}
    9296
    9397void ShadowRoot::removedFrom(ContainerNode& insertionPoint)
    9498{
    95     if (inDocument())
     99    DocumentFragment::removedFrom(insertionPoint);
     100    if (insertionPoint.inDocument() && !inDocument())
    96101        document().didRemoveInDocumentShadowRoot(*this);
    97     DocumentFragment::removedFrom(insertionPoint);
    98102}
    99103
Note: See TracChangeset for help on using the changeset viewer.