Changeset 247826 in webkit


Ignore:
Timestamp:
Jul 25, 2019 10:56:45 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION (r244995): Assertion failure when addEventListener to an SVGElement which has an. instance in shadow tree
https://bugs.webkit.org/show_bug.cgi?id=200083

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-07-25
Reviewed by Ryosuke Niwa.

Source/WebCore:

When adding an event listener to an SVGElement, the same event listener
has to be add to all the instances of SVGElement in the shadow tree. See
SVGElement::addEventListener().

In r244995, an assertion was added to ensure if the event listener is
attached to an event target, the new event target has be the same as the
attached one. This assertion isn't correct for the event targets which
were copied from the targetElement sub tree of an SVGUseElement to the
shadow tree.

Test: svg/custom/add-event-listener-shadow-tree-element.html

  • bindings/js/JSLazyEventListener.cpp:

(WebCore::isCloneInShadowTreeOfSVGUseElement):
(WebCore::JSLazyEventListener::checkValidityForEventTarget):

LayoutTests:

  • svg/custom/add-event-listener-shadow-tree-element-expected.txt: Added.
  • svg/custom/add-event-listener-shadow-tree-element.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247825 r247826  
     12019-07-25  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION (r244995): Assertion failure when addEventListener to an SVGElement which has an. instance in shadow tree
     4        https://bugs.webkit.org/show_bug.cgi?id=200083
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * svg/custom/add-event-listener-shadow-tree-element-expected.txt: Added.
     9        * svg/custom/add-event-listener-shadow-tree-element.html: Added.
     10
    1112019-07-25  Truitt Savell  <tsavell@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r247825 r247826  
     12019-07-25  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION (r244995): Assertion failure when addEventListener to an SVGElement which has an. instance in shadow tree
     4        https://bugs.webkit.org/show_bug.cgi?id=200083
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When adding an event listener to an SVGElement, the same event listener
     9        has to be add to all the instances of SVGElement in the shadow tree. See
     10        SVGElement::addEventListener().
     11
     12        In r244995, an assertion was added to ensure if the event listener is
     13        attached to an event target, the new event target has be the same as the
     14        attached one. This assertion isn't correct for the event targets which
     15        were copied from the targetElement sub tree of an SVGUseElement to the
     16        shadow tree.
     17
     18        Test: svg/custom/add-event-listener-shadow-tree-element.html
     19
     20        * bindings/js/JSLazyEventListener.cpp:
     21        (WebCore::isCloneInShadowTreeOfSVGUseElement):
     22        (WebCore::JSLazyEventListener::checkValidityForEventTarget):
     23
    1242019-07-25  Truitt Savell  <tsavell@apple.com>
    225
  • trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp

    r246490 r247826  
    2727#include "JSNode.h"
    2828#include "QualifiedName.h"
     29#include "SVGElement.h"
    2930#include "ScriptController.h"
    3031#include <JavaScriptCore/CatchScope.h>
     
    8182
    8283#if !ASSERT_DISABLED
     84static inline bool isCloneInShadowTreeOfSVGUseElement(Node& originalNode, EventTarget& eventTarget)
     85{
     86    if (!eventTarget.isNode())
     87        return false;
     88
     89    auto& node = downcast<Node>(eventTarget);
     90    if (!is<SVGElement>(node))
     91        return false;
     92
     93    auto& element = downcast<SVGElement>(node);
     94    if (!element.correspondingElement())
     95        return false;
     96
     97    ASSERT(element.isInShadowTree());
     98    return &originalNode == element.correspondingElement();
     99}
     100
    83101// This is to help find the underlying cause of <rdar://problem/24314027>.
    84102void JSLazyEventListener::checkValidityForEventTarget(EventTarget& eventTarget)
     
    86104    if (eventTarget.isNode()) {
    87105        ASSERT(m_originalNode);
    88         ASSERT(static_cast<EventTarget*>(m_originalNode.get()) == &eventTarget);
     106        ASSERT(static_cast<EventTarget*>(m_originalNode.get()) == &eventTarget || isCloneInShadowTreeOfSVGUseElement(*m_originalNode, eventTarget));
    89107    } else
    90108        ASSERT(!m_originalNode);
Note: See TracChangeset for help on using the changeset viewer.