⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277373 in webkit


Ignore:
Timestamp:
May 12, 2021, 10:13:20 AM (5 years ago)
Author:
rniwa@webkit.org
Message:

Source/WebCore:
REGRESSION: Release assert in SlotAssignment::assignedNodesForSlot via ComposedTreeIterator::traverseNextInShadowTree
in Element::insertedIntoAncestor
https://bugs.webkit.org/show_bug.cgi?id=225684

Reviewed by Darin Adler.

The release assertion failure was caused by RenderTreeUpdater::tearDownRenderers end up traversing the parts of the DOM
for which Element::insertedIntoAncestor had not been called yet. Since HTMLSlotElement::insertedIntoAncestor is where
SlotAssignment::Slot is updated for a newly inserted slot, SlotAssignment::Slot may not contain this slot element.

Fixed the bug by returning early in SlotAssignment::assignedNodesForSlot when this condition holds, which is when
the shadow root is connected to a document but HTMLSlotElement isn't since its connected flag has not been updated yet.

Test: fast/shadow-dom/insert-host-child-with-slot-renderer-teardown-crash.html

  • dom/SlotAssignment.cpp:

(WebCore::SlotAssignment::assignedNodesForSlot):

LayoutTests:
REGRESSION: Release assert in SlotAssignment::assignedNodesForSlot via ComposedTreeIterator::traverseNextInShadowTree in Element::insertedIntoAncestor
https://bugs.webkit.org/show_bug.cgi?id=225684

Reviewed by Darin Adler.

Added a regression test.

  • fast/shadow-dom/insert-host-child-with-slot-renderer-teardown-crash-expected.txt: Added.
  • fast/shadow-dom/insert-host-child-with-slot-renderer-teardown-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r277371 r277373  
     12021-05-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION: Release assert in SlotAssignment::assignedNodesForSlot via ComposedTreeIterator::traverseNextInShadowTree in Element::insertedIntoAncestor
     4        https://bugs.webkit.org/show_bug.cgi?id=225684
     5
     6        Reviewed by Darin Adler.
     7
     8        Added a regression test.
     9
     10        * fast/shadow-dom/insert-host-child-with-slot-renderer-teardown-crash-expected.txt: Added.
     11        * fast/shadow-dom/insert-host-child-with-slot-renderer-teardown-crash.html: Added.
     12
    1132021-05-12  Sergio Villar Senin  <svillar@igalia.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r277372 r277373  
     12021-05-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION: Release assert in SlotAssignment::assignedNodesForSlot via ComposedTreeIterator::traverseNextInShadowTree
     4        in Element::insertedIntoAncestor
     5        https://bugs.webkit.org/show_bug.cgi?id=225684
     6
     7        Reviewed by Darin Adler.
     8
     9        The release assertion failure was caused by RenderTreeUpdater::tearDownRenderers end up traversing the parts of the DOM
     10        for which Element::insertedIntoAncestor had not been called yet. Since HTMLSlotElement::insertedIntoAncestor is where
     11        SlotAssignment::Slot is updated for a newly inserted slot, SlotAssignment::Slot may not contain this slot element.
     12
     13        Fixed the bug by returning early in SlotAssignment::assignedNodesForSlot when this condition holds, which is when
     14        the shadow root is connected to a document but HTMLSlotElement isn't since its connected flag has not been updated yet.
     15
     16        Test: fast/shadow-dom/insert-host-child-with-slot-renderer-teardown-crash.html
     17
     18        * dom/SlotAssignment.cpp:
     19        (WebCore::SlotAssignment::assignedNodesForSlot):
     20
    1212021-05-12  Peng Liu  <peng.liu6@apple.com>
    222
  • trunk/Source/WebCore/dom/SlotAssignment.cpp

    r276010 r277373  
    333333    const AtomString& slotName = slotNameFromAttributeValue(slotElement.attributeWithoutSynchronization(nameAttr));
    334334    auto* slot = m_slots.get(slotName);
     335
     336    bool hasNotCalledInsertedIntoAncestorOnSlot = shadowRoot.isConnected() && !slotElement.isConnected();
     337    if (hasNotCalledInsertedIntoAncestorOnSlot)
     338        return nullptr;
    335339    RELEASE_ASSERT(slot);
    336340
Note: See TracChangeset for help on using the changeset viewer.