Title: [141054] trunk
Revision
141054
Author
[email protected]
Date
2013-01-28 22:22:28 -0800 (Mon, 28 Jan 2013)

Log Message

[Shadow] Gesture event is not fired in ShadowDOM
https://bugs.webkit.org/show_bug.cgi?id=107797

Reviewed by Dimitri Glazkov.

Source/WebCore:

Gesture event (e.g. touchstart) is not fired in ShadowDOM.

We have to run event retargetting algorithm to retarget touchTarget, however it is not implemented yet (Bug 107800).
Until it's implemented, we use the shadow ancestor node of touchTarget in Document treescope as touchTarget
for backward compatibility. If a touch event is fired in nested ShadowDOM, touchTarget will be always element in
document tree, so an event listener in ShadowDOM will get a wrong touchTarget. However we prioritized
the correctness of document tree.

Test: fast/dom/shadow/touch-event.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleTouchEvent): Allows us to take elements in ShadowDOM.

LayoutTests:

* fast/dom/shadow/touch-event-expected.txt: Added.
* fast/dom/shadow/touch-event.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141053 => 141054)


--- trunk/LayoutTests/ChangeLog	2013-01-29 06:19:10 UTC (rev 141053)
+++ trunk/LayoutTests/ChangeLog	2013-01-29 06:22:28 UTC (rev 141054)
@@ -1,3 +1,13 @@
+2013-01-28  Shinya Kawanaka  <[email protected]>
+
+        [Shadow] Gesture event is not fired in ShadowDOM
+        https://bugs.webkit.org/show_bug.cgi?id=107797
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/touch-event-expected.txt: Added.
+        * fast/dom/shadow/touch-event.html: Added.
+
 2013-01-28  Keishi Hattori  <[email protected]>
 
         [Chromium] Rebaselining integer-modulo after r141031.

Added: trunk/LayoutTests/fast/dom/shadow/touch-event-expected.txt (0 => 141054)


--- trunk/LayoutTests/fast/dom/shadow/touch-event-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/touch-event-expected.txt	2013-01-29 06:22:28 UTC (rev 141054)
@@ -0,0 +1,10 @@
+Touch event should be fired in Shadow DOM.
+
+Elements in ShadowDOM should not be revealed in touchTarget if it's examined in non shadow tree.
+
+PASS touchTargetForHost1 is host1
+PASS touchTargetForInput1 is input1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/touch-event.html (0 => 141054)


--- trunk/LayoutTests/fast/dom/shadow/touch-event.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/touch-event.html	2013-01-29 06:22:28 UTC (rev 141054)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html><body>
+<script src=""
+
+<p>Touch event should be fired in Shadow DOM.</p>
+<p>Elements in ShadowDOM should not be revealed in touchTarget if it's examined in non shadow tree.</p>
+
+<div id="container">
+    <input id="input1" type="text">
+    <div id="host1"></div>
+</div>
+<pre id="console"></pre>
+
+<script>
+var shadowRoot1 = host1.webkitCreateShadowRoot();
+shadowRoot1.innerHTML = 'foo <span id="host2">bar</span> baz';
+
+var host2 = shadowRoot1.getElementById('host2');
+var shadowRoot2 = host2.webkitCreateShadowRoot();
+shadowRoot2.innerHTML = '(foo <span id="target">bar</span> baz)';
+
+var target = shadowRoot2.getElementById('target');
+
+var touchTargetsForHost1;
+host1.addEventListener('touchstart', function(e) {
+    touchTargetForHost1 = e.touches[0].target;
+});
+
+var touchstartFiredInShadowDOM = false;
+target.addEventListener('touchstart', function(e) {
+    touchstartFiredInShadowDOM = true;
+});
+
+var touchTargetForInput1;
+input1.addEventListener('touchstart', function(e) {
+    touchTargetForInput1 = e.touches[1].target;
+});
+
+eventSender.clearTouchPoints();
+eventSender.addTouchPoint(target.offsetLeft + target.offsetWidth / 2, target.offsetTop + target.offsetHeight / 2);
+eventSender.addTouchPoint(input1.offsetLeft + input1.offsetWidth / 2, input1.offsetTop + input1.offsetHeight / 2);
+eventSender.touchStart();
+eventSender.touchEnd();
+
+shouldBe('touchTargetForHost1', 'host1');
+shouldBe('touchTargetForInput1', 'input1');
+
+container.remove();
+</script>
+
+<script src=""
+</body></html>

Modified: trunk/Source/WebCore/ChangeLog (141053 => 141054)


--- trunk/Source/WebCore/ChangeLog	2013-01-29 06:19:10 UTC (rev 141053)
+++ trunk/Source/WebCore/ChangeLog	2013-01-29 06:22:28 UTC (rev 141054)
@@ -1,3 +1,23 @@
+2013-01-28  Shinya Kawanaka  <[email protected]>
+
+        [Shadow] Gesture event is not fired in ShadowDOM
+        https://bugs.webkit.org/show_bug.cgi?id=107797
+
+        Reviewed by Dimitri Glazkov.
+
+        Gesture event (e.g. touchstart) is not fired in ShadowDOM.
+
+        We have to run event retargetting algorithm to retarget touchTarget, however it is not implemented yet (Bug 107800).
+        Until it's implemented, we use the shadow ancestor node of touchTarget in Document treescope as touchTarget
+        for backward compatibility. If a touch event is fired in nested ShadowDOM, touchTarget will be always element in
+        document tree, so an event listener in ShadowDOM will get a wrong touchTarget. However we prioritized
+        the correctness of document tree.
+
+        Test: fast/dom/shadow/touch-event.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleTouchEvent): Allows us to take elements in ShadowDOM.
+
 2013-01-28  Alexandre Elias  <[email protected]>
 
         Make page scale shrink FrameView in applyPageScaleInCompositor mode

Modified: trunk/Source/WebCore/page/EventHandler.cpp (141053 => 141054)


--- trunk/Source/WebCore/page/EventHandler.cpp	2013-01-29 06:19:10 UTC (rev 141053)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2013-01-29 06:22:28 UTC (rev 141054)
@@ -3857,7 +3857,7 @@
         if (pointState == PlatformTouchPoint::TouchPressed) {
             HitTestResult result;
             if (freshTouchEvents) {
-                result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false, false, DontHitTestScrollbars, hitType);
+                result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ true, false, DontHitTestScrollbars, hitType);
                 m_originatingTouchPointTargetKey = touchPointTargetKey;
             } else if (m_originatingTouchPointDocument.get() && m_originatingTouchPointDocument->frame()) {
                 LayoutPoint pagePointInOriginatingDocument = documentPointForWindowPoint(m_originatingTouchPointDocument->frame(), point.pos());
@@ -3891,7 +3891,7 @@
         } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
             // We only perform a hittest on release or cancel to unset :active or :hover state.
             if (touchPointTargetKey == m_originatingTouchPointTargetKey) {
-                hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false, false, DontHitTestScrollbars, hitType);
+                hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ true, false, DontHitTestScrollbars, hitType);
                 m_originatingTouchPointTargetKey = 0;
             } else if (m_originatingTouchPointDocument.get() && m_originatingTouchPointDocument->frame()) {
                 LayoutPoint pagePointInOriginatingDocument = documentPointForWindowPoint(m_originatingTouchPointDocument->frame(), point.pos());
@@ -3925,7 +3925,10 @@
         int adjustedPageX = lroundf(pagePoint.x() / scaleFactor);
         int adjustedPageY = lroundf(pagePoint.y() / scaleFactor);
 
-        RefPtr<Touch> touch = Touch::create(targetFrame, touchTarget.get(), point.id(),
+        // FIXME: Instead of taking shadow ancestor, event retargetting algorithm should run.
+        // https://bugs.webkit.org/show_bug.cgi?id=107800
+        EventTarget* adjustedTouchTarget = doc->ancestorInThisScope(touchTarget.get()->toNode());
+        RefPtr<Touch> touch = Touch::create(targetFrame, adjustedTouchTarget, point.id(),
                                             point.screenPos().x(), point.screenPos().y(),
                                             adjustedPageX, adjustedPageY,
                                             point.radiusX(), point.radiusY(), point.rotationAngle(), point.force());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to