Title: [136899] trunk
Revision
136899
Author
joc...@chromium.org
Date
2012-12-06 15:20:12 -0800 (Thu, 06 Dec 2012)

Log Message

[chromium] when forwarding events through the WebPluginContainer, create a UserGestureIndicator if processing a user gesture
https://bugs.webkit.org/show_bug.cgi?id=104306

Reviewed by Dimitri Glazkov.

Source/WebKit/chromium:

In http://trac.webkit.org/changeset/65964 a UserGestureIndicator was
introduced in chromium's WebKit layer intended to fix a problem with
plugins, however, it also affected regular event handling, so I removed
it in http://trac.webkit.org/changeset/128273. Turns out it still is a
problem for plugins. This change adds the UserGestureIndicator back,
however, only for the WebPluginContainer.

* public/WebInputEvent.h:
(WebInputEvent):
(WebKit::WebInputEvent::isUserGestureEventType):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::handleEvent):

Tools:

* DumpRenderTree/chromium/TestWebPlugin.cpp:
(TestWebPlugin::TestWebPlugin):
(TestWebPlugin::handleInputEvent): add support for printing the user gesture status
* DumpRenderTree/chromium/TestWebPlugin.h:
(TestWebPlugin):

LayoutTests:

* platform/chromium/plugins/user-gesture-expected.txt: Added.
* platform/chromium/plugins/user-gesture.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136898 => 136899)


--- trunk/LayoutTests/ChangeLog	2012-12-06 23:02:11 UTC (rev 136898)
+++ trunk/LayoutTests/ChangeLog	2012-12-06 23:20:12 UTC (rev 136899)
@@ -1,3 +1,13 @@
+2012-12-06  Jochen Eisinger  <joc...@chromium.org>
+
+        [chromium] when forwarding events through the WebPluginContainer, create a UserGestureIndicator if processing a user gesture
+        https://bugs.webkit.org/show_bug.cgi?id=104306
+
+        Reviewed by Dimitri Glazkov.
+
+        * platform/chromium/plugins/user-gesture-expected.txt: Added.
+        * platform/chromium/plugins/user-gesture.html: Added.
+
 2012-12-06  David Grogan  <dgro...@chromium.org>
 
         IndexedDB: Add webkitErrorMessage to IDBTransaction

Added: trunk/LayoutTests/platform/chromium/plugins/user-gesture-expected.txt (0 => 136899)


--- trunk/LayoutTests/platform/chromium/plugins/user-gesture-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/plugins/user-gesture-expected.txt	2012-12-06 23:20:12 UTC (rev 136899)
@@ -0,0 +1,14 @@
+Plugin received event: MouseEnter
+* not handling user gesture
+Plugin received event: MouseMove
+* not handling user gesture
+Plugin received event: MouseDown
+* handling user gesture
+Plugin received event: MouseUp
+* handling user gesture
+Plugin received event: MouseDown
+* not handling user gesture
+Plugin received event: MouseUp
+* not handling user gesture
+
+Test that the user gesture indicator is correctly set for events forwarded through the WebPluginContainer. The tests succeeds if the first mousedown/mouseup event pair is a user gesture, and the second is not.

Added: trunk/LayoutTests/platform/chromium/plugins/user-gesture.html (0 => 136899)


--- trunk/LayoutTests/platform/chromium/plugins/user-gesture.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/plugins/user-gesture.html	2012-12-06 23:20:12 UTC (rev 136899)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<body>
+<embed id="plugin" type="application/x-webkit-test-webplugin" accepts-touch="raw" print-user-gesture-status="true" width="100" height="100"></embed>
+<p>
+  Test that the user gesture indicator is correctly set for events forwarded
+  through the WebPluginContainer. The tests succeeds if the first
+  mousedown/mouseup event pair is a user gesture, and the second is not.
+</p>
+<script>
+    if (!window.testRunner || !window.eventSender) {
+        document.write("This test does not work in manual mode.");
+    } else {
+        testRunner.dumpAsText();
+
+        // Click on the plugin.
+        eventSender.mouseMoveTo(20, 20);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+
+        // Fake mouse events
+        var plugin = document.getElementById("plugin");
+        var evt = document.createEvent("MouseEvent");
+        evt.initMouseEvent("mousedown", true, true, window, 1, 20, 20, 20, 20, false, false, false, false, 0, null);
+        plugin.dispatchEvent(evt);
+
+        evt = document.createEvent("MouseEvent");
+        evt.initMouseEvent("mouseup", true, true, window, 1, 20, 20, 20, 20, false, false, false, false, 0, null);
+        plugin.dispatchEvent(evt);
+    }
+</script>
+</body>
+</html>

Modified: trunk/Source/WebKit/chromium/ChangeLog (136898 => 136899)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-12-06 23:02:11 UTC (rev 136898)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-12-06 23:20:12 UTC (rev 136899)
@@ -1,3 +1,23 @@
+2012-12-06  Jochen Eisinger  <joc...@chromium.org>
+
+        [chromium] when forwarding events through the WebPluginContainer, create a UserGestureIndicator if processing a user gesture
+        https://bugs.webkit.org/show_bug.cgi?id=104306
+
+        Reviewed by Dimitri Glazkov.
+
+        In http://trac.webkit.org/changeset/65964 a UserGestureIndicator was
+        introduced in chromium's WebKit layer intended to fix a problem with
+        plugins, however, it also affected regular event handling, so I removed
+        it in http://trac.webkit.org/changeset/128273. Turns out it still is a
+        problem for plugins. This change adds the UserGestureIndicator back,
+        however, only for the WebPluginContainer.
+
+        * public/WebInputEvent.h:
+        (WebInputEvent):
+        (WebKit::WebInputEvent::isUserGestureEventType):
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::handleEvent):
+
 2012-12-06  David Grogan  <dgro...@chromium.org>
 
         IndexedDB: Abort transactions because of leveldb errors part 4

Modified: trunk/Source/WebKit/chromium/public/WebInputEvent.h (136898 => 136899)


--- trunk/Source/WebKit/chromium/public/WebInputEvent.h	2012-12-06 23:02:11 UTC (rev 136898)
+++ trunk/Source/WebKit/chromium/public/WebInputEvent.h	2012-12-06 23:20:12 UTC (rev 136899)
@@ -203,6 +203,16 @@
             || type == TouchCancel;
     }
 
+    // Returns true if the WebInputEvent |type| should be handled as user gesture.
+    static bool isUserGestureEventType(int type)
+    {
+        return isKeyboardEventType(type)
+            || type == MouseDown
+            || type == MouseUp
+            || type == TouchStart
+            || type == TouchEnd;
+    }
+
     // Returns true if the WebInputEvent is a gesture event.
     static bool isGestureEventType(int type)
     {

Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp (136898 => 136899)


--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-12-06 23:02:11 UTC (rev 136898)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-12-06 23:20:12 UTC (rev 136899)
@@ -185,6 +185,9 @@
     if (!m_webPlugin->acceptsInputEvents())
         return;
 
+    const WebInputEvent* currentInputEvent = WebViewImpl::currentInputEvent();
+    UserGestureIndicator gestureIndicator(currentInputEvent && WebInputEvent::isUserGestureEventType(currentInputEvent->type) ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
+
     RefPtr<WebPluginContainerImpl> protector(this);
     // The events we pass are defined at:
     //    http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/structures5.html#1000000

Modified: trunk/Tools/ChangeLog (136898 => 136899)


--- trunk/Tools/ChangeLog	2012-12-06 23:02:11 UTC (rev 136898)
+++ trunk/Tools/ChangeLog	2012-12-06 23:20:12 UTC (rev 136899)
@@ -1,3 +1,16 @@
+2012-12-06  Jochen Eisinger  <joc...@chromium.org>
+
+        [chromium] when forwarding events through the WebPluginContainer, create a UserGestureIndicator if processing a user gesture
+        https://bugs.webkit.org/show_bug.cgi?id=104306
+
+        Reviewed by Dimitri Glazkov.
+
+        * DumpRenderTree/chromium/TestWebPlugin.cpp:
+        (TestWebPlugin::TestWebPlugin):
+        (TestWebPlugin::handleInputEvent): add support for printing the user gesture status
+        * DumpRenderTree/chromium/TestWebPlugin.h:
+        (TestWebPlugin):
+
 2012-12-06  Dirk Pranke  <dpra...@chromium.org>
 
         new-run-webkit-tests --lint-test-files seems to be broken

Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp (136898 => 136899)


--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp	2012-12-06 23:02:11 UTC (rev 136898)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp	2012-12-06 23:20:12 UTC (rev 136899)
@@ -137,6 +137,7 @@
     , m_context(0)
     , m_touchEventRequest(WebKit::WebPluginContainer::TouchEventRequestTypeNone)
     , m_printEventDetails(false)
+    , m_printUserGestureStatus(false)
     , m_canProcessDrag(false)
 {
     static const WebString kAttributePrimitive = WebString::fromUTF8("primitive");
@@ -146,6 +147,7 @@
     static const WebString kAttributeAcceptsTouch = WebString::fromUTF8("accepts-touch");
     static const WebString kAttributePrintEventDetails = WebString::fromUTF8("print-event-details");
     static const WebString kAttributeCanProcessDrag = WebString::fromUTF8("can-process-drag");
+    static const WebString kAttributePrintUserGestureStatus = WebString::fromUTF8("print-user-gesture-status");
 
     ASSERT(params.attributeNames.size() == params.attributeValues.size());
     size_t size = params.attributeNames.size();
@@ -167,6 +169,8 @@
             m_printEventDetails = parseBoolean(attributeValue);
         else if (attributeName == kAttributeCanProcessDrag)
             m_canProcessDrag = parseBoolean(attributeValue);
+        else if (attributeName == kAttributePrintUserGestureStatus)
+            m_printUserGestureStatus = parseBoolean(attributeValue);
     }
 }
 
@@ -486,6 +490,8 @@
     printf("Plugin received event: %s\n", eventName ? eventName : "unknown");
     if (m_printEventDetails)
         printEventDetails(event);
+    if (m_printUserGestureStatus)
+        printf("* %shandling user gesture\n", m_frame->isProcessingUserGesture() ? "" : "not ");
     return false;
 }
 

Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h (136898 => 136899)


--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h	2012-12-06 23:02:11 UTC (rev 136898)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h	2012-12-06 23:20:12 UTC (rev 136899)
@@ -134,6 +134,7 @@
 
     WebKit::WebPluginContainer::TouchEventRequestType m_touchEventRequest;
     bool m_printEventDetails;
+    bool m_printUserGestureStatus;
     bool m_canProcessDrag;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to