Bug 836786 - Allow mousemove events to propagate from windowless plugins. r=josh
authorJohn Schoenick <jschoenick@mozilla.com>
Thu, 24 Oct 2013 14:04:36 -0700
changeset 173206 e8036c3e0a7b242a3dbaa51d9308973635d83a2a
parent 173205 d45173c0e33894969475262b32a71359164d25f4
child 173207 25de9f31826128f85ebd541e25ecefef4f1a5e77
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjosh
bugs836786
milestone30.0a1
Bug 836786 - Allow mousemove events to propagate from windowless plugins. r=josh
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1677,34 +1677,37 @@ nsPluginInstanceOwner::ProcessMouseDown(
     if (nsEventStatus_eConsumeNoDefault == rv) {
       return aMouseEvent->PreventDefault(); // consume event
     }
   }
   
   return NS_OK;
 }
 
-nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
+nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent,
+                                                      bool aAllowPropagate)
 {
 #if !defined(XP_MACOSX)
   if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
     return aMouseEvent->PreventDefault(); // consume event
   // continue only for cases without child window
 #endif
   // don't send mouse events if we are hidden
   if (!mWidgetVisible)
     return NS_OK;
 
   WidgetMouseEvent* mouseEvent =
     aMouseEvent->GetInternalNSEvent()->AsMouseEvent();
   if (mouseEvent && mouseEvent->eventStructType == NS_MOUSE_EVENT) {
     nsEventStatus rv = ProcessEvent(*mouseEvent);
     if (nsEventStatus_eConsumeNoDefault == rv) {
       aMouseEvent->PreventDefault();
-      aMouseEvent->StopPropagation();
+      if (!aAllowPropagate) {
+        aMouseEvent->StopPropagation();
+      }
     }
     if (mouseEvent->message == NS_MOUSE_BUTTON_UP) {
       mLastMouseDownButtonType = -1;
     }
   }
   return NS_OK;
 }
 
@@ -1736,18 +1739,20 @@ nsPluginInstanceOwner::HandleEvent(nsIDO
     WidgetMouseEvent* mouseEvent = aEvent->GetInternalNSEvent()->AsMouseEvent();
     if (mouseEvent &&
         static_cast<int>(mouseEvent->button) != mLastMouseDownButtonType) {
       aEvent->PreventDefault();
       return NS_OK;
     }
     return DispatchMouseToPlugin(aEvent);
   }
-  if (eventType.EqualsLiteral("mousemove") ||
-      eventType.EqualsLiteral("click") ||
+  if (eventType.EqualsLiteral("mousemove")) {
+    return DispatchMouseToPlugin(aEvent, true);
+  }
+  if (eventType.EqualsLiteral("click") ||
       eventType.EqualsLiteral("dblclick") ||
       eventType.EqualsLiteral("mouseover") ||
       eventType.EqualsLiteral("mouseout")) {
     return DispatchMouseToPlugin(aEvent);
   }
   if (eventType.EqualsLiteral("keydown") ||
       eventType.EqualsLiteral("keyup")) {
     return DispatchKeyToPlugin(aEvent);
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -360,17 +360,18 @@ private:
   // returned true.
   bool mUseAsyncRendering;
 #endif
   
   // pointer to wrapper for nsIDOMContextMenuListener
   nsRefPtr<nsPluginDOMContextMenuListener> mCXMenuListener;
   
   nsresult DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent);
-  nsresult DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent);
+  nsresult DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent,
+                                 bool aAllowPropagate = false);
   nsresult DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent);
 
   int mLastMouseDownButtonType;
   
   nsresult EnsureCachedAttrParamArrays();
   
 #ifdef MOZ_X11
   class Renderer