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

Changeset 239402 in webkit


Ignore:
Timestamp:
Dec 19, 2018, 3:51:03 PM (8 years ago)
Author:
rniwa@webkit.org
Message:

SVGUseElement::findTarget should return nullptr when there is a cycle
​https://bugs.webkit.org/show_bug.cgi?id=192840

Reviewed by Tim Horton.

r233366 added an early return to updateShadowTree() when there is a cycle between an use element and its target.
Consolidate this cycle detection code with the one in SVGUseElement::findTarget which detected cycles when
the SVG use element itself had a corresponding element.

No new tests since there should be no behavioral change.

  • svg/SVGUseElement.cpp:

(WebCore::SVGUseElement::updateShadowTree):
(WebCore::SVGUseElement::findTarget const):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239398 r239402  
     12018-12-18  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        SVGUseElement::findTarget should return nullptr when there is a cycle
     4        https://bugs.webkit.org/show_bug.cgi?id=192840
     5
     6        Reviewed by Tim Horton.
     7
     8        r233366 added an early return to updateShadowTree() when there is a cycle between an use element and its target.
     9        Consolidate this cycle detection code with the one in SVGUseElement::findTarget which detected cycles when
     10        the SVG use element itself had a corresponding element.
     11
     12        No new tests since there should be no behavioral change.
     13
     14        * svg/SVGUseElement.cpp:
     15        (WebCore::SVGUseElement::updateShadowTree):
     16        (WebCore::SVGUseElement::findTarget const):
     17
    1182018-12-19  Myles C. Maxfield  <mmaxfield@apple.com>
    219
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r238524 r239402  
    245245    }
    246246
    247     if (isDescendantOf(target))
    248         return;
    249    
     247    RELEASE_ASSERT(!isDescendantOf(target));
    250248    {
    251249        auto& shadowRoot = ensureUserAgentShadowRoot();
    … …  
    424422        return nullptr;
    425423
    426     // Reject any target that has already been cloned to create one of the ancestors of this element,
    427     // already in the shadow tree. This is sufficient to prevent cycles.
    428424    if (correspondingElement) {
    429425        for (auto& ancestor : lineageOfType<SVGElement>(*this)) {
    … …  
    431427                return nullptr;
    432428        }
     429    } else {
     430        if (target.contains(this))
     431            return nullptr;
     432        // Target should only refer to a node in the same tree or a node in another document.
     433        ASSERT(!isDescendantOrShadowDescendantOf(&target));
    433434    }
    434435
Note: See TracChangeset for help on using the changeset viewer.