Title: [147240] trunk/Source/WebCore
Revision
147240
Author
d...@apple.com
Date
2013-03-29 12:31:45 -0700 (Fri, 29 Mar 2013)

Log Message

Snapshotted plugins must be able to restart on appropriate mouseup events
https://bugs.webkit.org/show_bug.cgi?id=113577

Reviewed by Tim Horton.

If the page content prevents the default behaviour of a mousedown event, then a snapshotted
plugin would never receive a click event, and thus be unable to restart. We have to also
look for a mouseup that happens with an associated mousedown, and trigger restart. This
won't call any page code - it's just behind the scenes.

* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): Initialize new member variable.
(WebCore::RenderSnapshottedPlugIn::handleEvent): Track the state of mousedown and up pairs, and restart
    if you see an appropriate mouseup.
* rendering/RenderSnapshottedPlugIn.h: New member variable to track mouse state.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147239 => 147240)


--- trunk/Source/WebCore/ChangeLog	2013-03-29 19:27:52 UTC (rev 147239)
+++ trunk/Source/WebCore/ChangeLog	2013-03-29 19:31:45 UTC (rev 147240)
@@ -1,3 +1,21 @@
+2013-03-29  Dean Jackson  <d...@apple.com>
+
+        Snapshotted plugins must be able to restart on appropriate mouseup events
+        https://bugs.webkit.org/show_bug.cgi?id=113577
+
+        Reviewed by Tim Horton.
+
+        If the page content prevents the default behaviour of a mousedown event, then a snapshotted
+        plugin would never receive a click event, and thus be unable to restart. We have to also
+        look for a mouseup that happens with an associated mousedown, and trigger restart. This
+        won't call any page code - it's just behind the scenes.
+
+        * rendering/RenderSnapshottedPlugIn.cpp:
+        (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): Initialize new member variable.
+        (WebCore::RenderSnapshottedPlugIn::handleEvent): Track the state of mousedown and up pairs, and restart
+            if you see an appropriate mouseup.
+        * rendering/RenderSnapshottedPlugIn.h: New member variable to track mouse state.
+
 2013-03-29  Simon Fraser  <simon.fra...@apple.com>
 
         removeViewportConstrainedLayer() should remove the layer from m_viewportConstrainedLayersNeedingUpdate too

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (147239 => 147240)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2013-03-29 19:27:52 UTC (rev 147239)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2013-03-29 19:31:45 UTC (rev 147240)
@@ -46,6 +46,7 @@
 RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element)
     : RenderEmbeddedObject(element)
     , m_snapshotResource(RenderImageResource::create())
+    , m_isPotentialMouseActivation(false)
 {
     m_snapshotResource->initialize(this);
 }
@@ -154,17 +155,27 @@
 
     MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
 
-    if (event->type() == eventNames().clickEvent) {
-        if (mouseEvent->button() != LeftButton)
-            return;
+    // If we're a snapshotted plugin, we want to make sure we activate on
+    // clicks even if the page is preventing our default behaviour. Otherwise
+    // we can never restart. One we do restart, then the page will happily
+    // block the new plugin in the normal renderer. All this means we have to
+    // be on the lookout for a mouseup event that comes after a mousedown
+    // event. The code below is not completely foolproof, but the worst that
+    // could happen is that a snapshotted plugin restarts.
 
+    if (event->type() == eventNames().mouseoutEvent)
+        m_isPotentialMouseActivation = false;
+
+    if (mouseEvent->button() != LeftButton)
+        return;
+
+    if (event->type() == eventNames().clickEvent || (m_isPotentialMouseActivation && event->type() == eventNames().mouseupEvent)) {
+        m_isPotentialMouseActivation = false;
         plugInImageElement()->setDisplayState(HTMLPlugInElement::RestartingWithPendingMouseClick);
         plugInImageElement()->userDidClickSnapshot(mouseEvent);
         event->setDefaultHandled();
     } else if (event->type() == eventNames().mousedownEvent) {
-        if (mouseEvent->button() != LeftButton)
-            return;
-
+        m_isPotentialMouseActivation = true;
         event->setDefaultHandled();
     }
 }

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h (147239 => 147240)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h	2013-03-29 19:27:52 UTC (rev 147239)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h	2013-03-29 19:31:45 UTC (rev 147240)
@@ -58,6 +58,7 @@
     virtual void layout() OVERRIDE;
 
     OwnPtr<RenderImageResource> m_snapshotResource;
+    bool m_isPotentialMouseActivation;
 };
 
 inline RenderSnapshottedPlugIn* toRenderSnapshottedPlugIn(RenderObject* object)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to