Title: [247826] trunk
- Revision
- 247826
- Author
- [email protected]
- Date
- 2019-07-25 10:56:45 -0700 (Thu, 25 Jul 2019)
Log 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 <[email protected]> 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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (247825 => 247826)
--- trunk/LayoutTests/ChangeLog 2019-07-25 17:55:30 UTC (rev 247825)
+++ trunk/LayoutTests/ChangeLog 2019-07-25 17:56:45 UTC (rev 247826)
@@ -1,3 +1,13 @@
+2019-07-25 Said Abou-Hallawa <[email protected]>
+
+ 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
+
+ Reviewed by Ryosuke Niwa.
+
+ * svg/custom/add-event-listener-shadow-tree-element-expected.txt: Added.
+ * svg/custom/add-event-listener-shadow-tree-element.html: Added.
+
2019-07-25 Truitt Savell <[email protected]>
Unreviewed, rolling out r247821.
Added: trunk/LayoutTests/svg/custom/add-event-listener-shadow-tree-element-expected.txt (0 => 247826)
--- trunk/LayoutTests/svg/custom/add-event-listener-shadow-tree-element-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/custom/add-event-listener-shadow-tree-element-expected.txt 2019-07-25 17:56:45 UTC (rev 247826)
@@ -0,0 +1,2 @@
+PASS if it doesn't assert in debug builds.
+
Added: trunk/LayoutTests/svg/custom/add-event-listener-shadow-tree-element.html (0 => 247826)
--- trunk/LayoutTests/svg/custom/add-event-listener-shadow-tree-element.html (rev 0)
+++ trunk/LayoutTests/svg/custom/add-event-listener-shadow-tree-element.html 2019-07-25 17:56:45 UTC (rev 247826)
@@ -0,0 +1,27 @@
+<html>
+<body _onload_=test()>
+ <svg>
+ <def>
+ <rect id="rect" width="100" height="100" fill="red"/>
+ </def>
+ <use id="use1" href=""
+ <use id="use2" href=""
+ <text y="120">PASS if it doesn't assert in debug builds.</text>
+ </svg>
+ <script>
+ function eventhandler() {
+ rect.setAttribute("fill", "green");
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }
+ function test() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+ use1.setAttribute("onfocusin", "eventhandler()");
+ use1.focus();
+ }
+ </script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (247825 => 247826)
--- trunk/Source/WebCore/ChangeLog 2019-07-25 17:55:30 UTC (rev 247825)
+++ trunk/Source/WebCore/ChangeLog 2019-07-25 17:56:45 UTC (rev 247826)
@@ -1,3 +1,26 @@
+2019-07-25 Said Abou-Hallawa <[email protected]>
+
+ 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
+
+ Reviewed by Ryosuke Niwa.
+
+ 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):
+
2019-07-25 Truitt Savell <[email protected]>
Unreviewed, rolling out r247821.
Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp (247825 => 247826)
--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2019-07-25 17:55:30 UTC (rev 247825)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2019-07-25 17:56:45 UTC (rev 247826)
@@ -26,6 +26,7 @@
#include "Frame.h"
#include "JSNode.h"
#include "QualifiedName.h"
+#include "SVGElement.h"
#include "ScriptController.h"
#include <_javascript_Core/CatchScope.h>
#include <_javascript_Core/FunctionConstructor.h>
@@ -80,12 +81,29 @@
}
#if !ASSERT_DISABLED
+static inline bool isCloneInShadowTreeOfSVGUseElement(Node& originalNode, EventTarget& eventTarget)
+{
+ if (!eventTarget.isNode())
+ return false;
+
+ auto& node = downcast<Node>(eventTarget);
+ if (!is<SVGElement>(node))
+ return false;
+
+ auto& element = downcast<SVGElement>(node);
+ if (!element.correspondingElement())
+ return false;
+
+ ASSERT(element.isInShadowTree());
+ return &originalNode == element.correspondingElement();
+}
+
// This is to help find the underlying cause of <rdar://problem/24314027>.
void JSLazyEventListener::checkValidityForEventTarget(EventTarget& eventTarget)
{
if (eventTarget.isNode()) {
ASSERT(m_originalNode);
- ASSERT(static_cast<EventTarget*>(m_originalNode.get()) == &eventTarget);
+ ASSERT(static_cast<EventTarget*>(m_originalNode.get()) == &eventTarget || isCloneInShadowTreeOfSVGUseElement(*m_originalNode, eventTarget));
} else
ASSERT(!m_originalNode);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes