Backout bug 630697 due to focus regressions (bug 631794).
authorJim Mathies <jmathies@mozilla.com>
Sat, 05 Feb 2011 17:13:20 -0600
changeset 61990 20608b6f871d19147bb1e9457e98d693f9956444
parent 61919 95fa72a8e8ab387ae57d177addfa9b93f1873170
child 61991 f0205c1265ea39a28b70f1a9af2934c45b5ac8e9
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
bugs630697, 631794
milestone2.0b12pre
Backout bug 630697 due to focus regressions (bug 631794).
dom/plugins/PluginInstanceChild.cpp
dom/plugins/PluginInstanceChild.h
dom/plugins/PluginModuleChild.cpp
dom/plugins/PluginModuleChild.h
--- a/dom/plugins/PluginInstanceChild.cpp
+++ b/dom/plugins/PluginInstanceChild.cpp
@@ -119,17 +119,16 @@ PluginInstanceChild::PluginInstanceChild
 #if defined(OS_WIN)
     , mPluginWindowHWND(0)
     , mPluginWndProc(0)
     , mPluginParentHWND(0)
     , mCachedWinlessPluginHWND(0)
     , mWinlessPopupSurrogateHWND(0)
     , mWinlessThrottleOldWndProc(0)
     , mWinlessHiddenMsgHWND(0)
-    , mMouseHook(NULL)
 #endif // OS_WIN
     , mAsyncCallMutex("PluginInstanceChild::mAsyncCallMutex")
 #if defined(OS_MACOSX)
 #if defined(__i386__)
     , mEventModel(NPEventModelCarbon)
 #endif
     , mShColorSpace(nsnull)
     , mShContext(nsnull)
@@ -1038,52 +1037,16 @@ PluginInstanceChild::RegisterWindowClass
     wcex.hbrBackground  = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
     wcex.lpszMenuName   = 0;
     wcex.lpszClassName  = kWindowClassName;
     wcex.hIconSm        = 0;
 
     return RegisterClassEx(&wcex) ? true : false;
 }
 
-static inline void
-HandleMouseCapture(HWND aWnd, UINT aMessage)
-{
-    // Make sure capture is released by the child on mouse events. Fixes a
-    // problem with flash full screen mode mouse input. Appears to be
-    // caused by a bug in flash, since we are not setting the capture
-    // on the window. (In non-oopp land, we would set and release via
-    // widget for other reasons.)
-    switch (aMessage) {
-        case WM_LBUTTONDOWN:
-        case WM_MBUTTONDOWN:
-        case WM_RBUTTONDOWN:
-            SetCapture(aWnd);
-            break;
-        case WM_LBUTTONUP:
-        case WM_MBUTTONUP:
-        case WM_RBUTTONUP:
-            ReleaseCapture();
-            break;
-    }
-}
-
-LRESULT CALLBACK MouseHookProc(int code,
-                               WPARAM wParam,
-                               LPARAM lParam)
-{
-  if (code == HC_ACTION) {
-      MOUSEHOOKSTRUCT* hookStruct =
-          reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam);
-      if (hookStruct)
-          HandleMouseCapture(hookStruct->hwnd, wParam);
-  }
-
-  return CallNextHookEx(NULL, code, wParam, lParam);
-}
-
 bool
 PluginInstanceChild::CreatePluginWindow()
 {
     // already initialized
     if (mPluginWindowHWND)
         return true;
         
     if (!RegisterWindowClass())
@@ -1100,21 +1063,16 @@ PluginInstanceChild::CreatePluginWindow(
         return false;
     if (!SetProp(mPluginWindowHWND, kPluginInstanceChildProperty, this))
         return false;
 
     // Apparently some plugins require an ASCII WndProc.
     SetWindowLongPtrA(mPluginWindowHWND, GWLP_WNDPROC,
                       reinterpret_cast<LONG_PTR>(DefWindowProcA));
 
-    // Mouse capture hook for flash full screen capture bug
-    if (GetQuirks() & PluginModuleChild::QUIRK_FLASH_HOOK_MOUSE_CAPTURE) {
-        mMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookProc, NULL,
-                                      GetCurrentThreadId());
-    }
     return true;
 }
 
 void
 PluginInstanceChild::DestroyPluginWindow()
 {
     if (mPluginWindowHWND) {
         // Unsubclass the window.
@@ -1126,21 +1084,16 @@ PluginInstanceChild::DestroyPluginWindow
             NS_ASSERTION(mPluginWndProc, "Should have old proc here!");
             SetWindowLongPtr(mPluginWindowHWND, GWLP_WNDPROC,
                              reinterpret_cast<LONG_PTR>(mPluginWndProc));
             mPluginWndProc = 0;
         }
         DestroyWindow(mPluginWindowHWND);
         mPluginWindowHWND = 0;
     }
-
-    if (mMouseHook) {
-        UnhookWindowsHookEx(mMouseHook);
-        mMouseHook = NULL;
-    }
 }
 
 void
 PluginInstanceChild::ReparentPluginWindow(HWND hWndParent)
 {
     if (hWndParent != mPluginParentHWND && IsWindow(hWndParent)) {
         // Fix the child window's style to be a child window.
         LONG_PTR style = GetWindowLongPtr(mPluginWindowHWND, GWL_STYLE);
@@ -1242,21 +1195,35 @@ PluginInstanceChild::PluginWindowProc(HW
       self->CallPluginFocusChange(false);
 
     if (message == WM_USER+1 &&
         (self->GetQuirks() & PluginModuleChild::QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)) {
         self->FlashThrottleMessage(hWnd, message, wParam, lParam, true);
         return 0;
     }
 
-    HandleMouseCapture(hWnd, message);
-    
     LRESULT res = CallWindowProc(self->mPluginWndProc, hWnd, message, wParam,
                                  lParam);
 
+    // Make sure capture is released by the child on mouse events. Fixes a
+    // problem with flash full screen mode mouse input. Appears to be
+    // caused by a bug in flash, since we are not setting the capture
+    // on the window. (In non-oopp land, we would set and release via
+    // widget for other reasons.)
+    switch (message) {
+      case WM_LBUTTONDOWN:
+      case WM_MBUTTONDOWN:
+      case WM_RBUTTONDOWN:
+      case WM_LBUTTONUP:
+      case WM_MBUTTONUP:
+      case WM_RBUTTONUP:
+      ReleaseCapture();
+      break;
+    }
+
     if (message == WM_CLOSE)
         self->DestroyPluginWindow();
 
     if (message == WM_NCDESTROY)
         RemoveProp(hWnd, kPluginInstanceChildProperty);
 
     return res;
 }
--- a/dom/plugins/PluginInstanceChild.h
+++ b/dom/plugins/PluginInstanceChild.h
@@ -341,17 +341,16 @@ private:
     WNDPROC mPluginWndProc;
     HWND mPluginParentHWND;
     int mNestedEventLevelDepth;
     HWND mCachedWinlessPluginHWND;
     HWND mWinlessPopupSurrogateHWND;
     nsIntPoint mPluginSize;
     WNDPROC mWinlessThrottleOldWndProc;
     HWND mWinlessHiddenMsgHWND;
-    HHOOK mMouseHook;
 #endif
 
     friend class ChildAsyncCall;
 
     Mutex mAsyncCallMutex;
     nsTArray<ChildAsyncCall*> mPendingAsyncCalls;
     nsTArray<nsAutoPtr<ChildTimer> > mTimers;
 
--- a/dom/plugins/PluginModuleChild.cpp
+++ b/dom/plugins/PluginModuleChild.cpp
@@ -1824,17 +1824,16 @@ PluginModuleChild::InitQuirksModes(const
     // application/x-shockwave-flash
     NS_NAMED_LITERAL_CSTRING(flash, "application/x-shockwave-flash");
     if (FindInReadable(flash, aMimeType)) {
         mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
         mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS; 
         mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
         mQuirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO;
         mQuirks |= QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS;
-        mQuirks |= QUIRK_FLASH_HOOK_MOUSE_CAPTURE;
     }
 #endif
 }
 
 bool
 PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
                                                     const nsCString& aMimeType,
                                                     const uint16_t& aMode,
--- a/dom/plugins/PluginModuleChild.h
+++ b/dom/plugins/PluginModuleChild.h
@@ -233,19 +233,16 @@ public:
         QUIRK_FLASH_EXPOSE_COORD_TRANSLATION            = 1 << 4,
         // Win32: Catch get window info calls on the browser and tweak the
         // results so mouse input works when flash is displaying it's settings
         // window.
         QUIRK_FLASH_HOOK_GETWINDOWINFO                  = 1 << 5,
         // Win: Flash trashes the alpha channel in our buffers when cleartype
         // is enabled. Mask this setting so they don't know it's enabled.
         QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS             = 1 << 6,
-        // Win: Addresses a flash bug with mouse capture and full screen
-        // windows.
-        QUIRK_FLASH_HOOK_MOUSE_CAPTURE                  = 1 << 7,
     };
 
     int GetQuirks() { return mQuirks; }
     void AddQuirk(PluginQuirks quirk) {
       if (mQuirks == QUIRKS_NOT_INITIALIZED)
         mQuirks = 0;
       mQuirks |= quirk;
     }