Add Event.deepPath() and Event.scoped
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Mar 2016 03:11:04 +0000 (03:11 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Mar 2016 03:11:04 +0000 (03:11 +0000)
commitaaacd157d67bb0737977bed311a38fd7da67f7aa
tree9781d4f6173a7272b04d561136659db697236a4d
parent8aa161dd0a60f779dd1dae4e136b6127d52ddf55
Add Event.deepPath() and Event.scoped
https://bugs.webkit.org/show_bug.cgi?id=153538
<rdar://problem/24363836>

Reviewed by Darin Adler.

Source/WebCore:

Added the support for deepPath(), scoped, and relatedTargetScoped on Event.prototype for shadow DOM:
http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event-interface
and updated the EventPath class to respect scoped and relatedTargetScoped flags as specified at:
http://w3c.github.io/webcomponents/spec/shadow/#get-the-parent

Tests: fast/shadow-dom/Extensions-to-Event-Interface.html
       fast/shadow-dom/trusted-event-scoped-flags.html

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorDefinition): Added the support for Conditional for InitializedByEventConstructor.
* bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.cpp:
* bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.h:
* bindings/scripts/test/JS/JSTestEventConstructor.cpp:
* bindings/scripts/test/ObjC/DOMTestEventConstructor.h:
* bindings/scripts/test/ObjC/DOMTestEventConstructor.mm:
* bindings/scripts/test/TestEventConstructor.idl: Added a test case for using InitializedByEventConstructor
with Conditional.
* dom/Event.cpp:
(WebCore::Event::Event): Initialize m_scoped and m_relatedTargetScoped from EventInit dictionary.
(WebCore::Event::scoped): Added. Implements http://w3c.github.io/webcomponents/spec/shadow/#scoped-flag
(WebCore::Event::deepPath): Added.
* dom/Event.h:
(WebCore::Event::relatedTargetScoped): Added. Overridden by FocusEvent and MouseEvent to implement
http://w3c.github.io/webcomponents/spec/shadow/#relatedtargetscoped-flag
(WebCore::Event::setEventPath): Added.
(WebCore::Event::clearEventPath): Added.
* dom/Event.idl: Added scoped, relatedTargetScoped, and deepPath() conditionally enabled for shadow DOM.
* dom/EventContext.h:
(WebCore::EventContext::currentTarget):
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent): Set the event path while the event is being dispatched.
* dom/EventPath.cpp:
(WebCore::shouldEventCrossShadowBoundary): Check event.scoped flag instead of hard-coding a list of events here
which has been moved to Event::scoped. See above.
(WebCore::EventPath::setRelatedTarget): Check m_event.relatedTargetScoped() instead of hard-coding a list of
events here. relatedTargetScoped is overridden by FocusEvent and MouseEvent.
(WebCore::EventPath::hasEventListeners): Fixed the misleading variable name.
(WebCore::isUnclosedNodeOf): Added. Implements http://w3c.github.io/webcomponents/spec/shadow/#dfn-unclosed-node
(WebCore::EventPath::computePathDisclosedToTarget): Added. Implements the algorithm to filter event targets:
http://w3c.github.io/webcomponents/spec/shadow/#widl-Event-deepPath-sequence-EventTarget
* dom/EventPath.h:
* dom/FocusEvent.cpp:
(WebCore::FocusEvent::relatedTargetScoped): Returns true when this is a trusted event per:
http://w3c.github.io/webcomponents/spec/shadow/#relatedtargetscoped-flag
* dom/FocusEvent.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::relatedTargetScoped): Ditto.
* dom/MouseEvent.h:

LayoutTests:

Added a W3C style testharness.js tests for Event.prototype.scoped, Event.prototype.scopedRelatedTarget,
Event.prototype.deepPath() and a test that uses eventSender to verify the values of the scoped and
scopedRelatedTarget flags on trusted events.

* fast/shadow-dom/Extensions-to-Event-Interface-expected.txt: Added.
* fast/shadow-dom/Extensions-to-Event-Interface.html: Added.
* fast/shadow-dom/event-with-related-target.html:
* fast/shadow-dom/resources: Added.
* fast/shadow-dom/resources/event-path-test-helpers.js: Added. Extracted from event-with-related-target.html.
* fast/shadow-dom/trusted-event-scoped-flags-expected.txt: Added.
* fast/shadow-dom/trusted-event-scoped-flags.html: Added.
* fast/xmlhttprequest/xmlhttprequest-get-expected.txt:
* http/tests/workers/worker-importScriptsOnError-expected.txt:
* inspector/model/remote-object-get-properties-expected.txt:
* platform/ios-simulator/fast/shadow-dom/trusted-event-scoped-flags-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@198056 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/event-with-related-target.html
LayoutTests/fast/shadow-dom/negative-tabindex-on-shadow-host-expected.txt
LayoutTests/fast/shadow-dom/negative-tabindex-on-shadow-host.html
LayoutTests/fast/shadow-dom/resources/event-path-test-helpers.js [new file with mode: 0644]
LayoutTests/fast/shadow-dom/trusted-event-scoped-flags-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/trusted-event-scoped-flags.html [new file with mode: 0644]
LayoutTests/fast/xmlhttprequest/xmlhttprequest-get-expected.txt
LayoutTests/http/tests/workers/worker-importScriptsOnError-expected.txt
LayoutTests/inspector/model/remote-object-get-properties-expected.txt
LayoutTests/platform/ios-simulator/fast/shadow-dom/trusted-event-scoped-flags-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.h
Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestEventConstructor.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestEventConstructor.mm
Source/WebCore/bindings/scripts/test/TestEventConstructor.idl
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/Event.idl
Source/WebCore/dom/EventContext.h
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/EventPath.cpp
Source/WebCore/dom/EventPath.h
Source/WebCore/dom/FocusEvent.cpp
Source/WebCore/dom/FocusEvent.h
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h