diff --git a/modules/plugin/base/src/nsPluginNativeWindowOS2.cpp b/modules/plugin/base/src/nsPluginNativeWindowOS2.cpp index 9f70587695ec..6c3a7c4101fc 100644 --- a/modules/plugin/base/src/nsPluginNativeWindowOS2.cpp +++ b/modules/plugin/base/src/nsPluginNativeWindowOS2.cpp @@ -308,14 +308,19 @@ static MRESULT EXPENTRY PluginWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM m // doesn't receive it, window activation/deactivation won't happen. WinDefWindowProc(hWnd, msg, mp1, mp2); - // If focus is being gained, and the plugin widget neither lost - // nor gained the focus, then a child just got it from some other - // window. Post a WM_FOCUSCHANGED msg that identifies the child - // as the window losing focus. After nsWindow::ActivatePlugin() - // activates the plugin, it will restore the focus to the child. + // If focus is being gained, and the plugin widget neither lost nor + // gained the focus, then a child just got it from some other window. + // If that other window was neither a child of the widget nor owned + // by a child of the widget (e.g. a popup menu), post a WM_FOCUSCHANGED + // msg that identifies the child as the window losing focus. After + // nsWindow:: ActivatePlugin() activates the plugin, it will restore + // the focus to the child. if (SHORT1FROMMP(mp2) && (HWND)mp1 != hWnd) { HWND hFocus = WinQueryFocus(HWND_DESKTOP); - if (hFocus != hWnd) { + if (hFocus != hWnd && + WinIsChild(hFocus, hWnd) && + !WinIsChild((HWND)mp1, hWnd) && + !WinIsChild(WinQueryWindow((HWND)mp1, QW_OWNER), hWnd)) { WinPostMsg(hWnd, WM_FOCUSCHANGED, (MPARAM)hFocus, mp2); } } diff --git a/widget/src/os2/nsWindow.cpp b/widget/src/os2/nsWindow.cpp index 6c67c11b9867..c46d52defa68 100644 --- a/widget/src/os2/nsWindow.cpp +++ b/widget/src/os2/nsWindow.cpp @@ -261,6 +261,13 @@ nsWindow::~nsWindow() Destroy(); } + // Once a plugin window has been destroyed, + // its parent, the clipping window, can be destroyed. + if (mClipWnd) { + WinDestroyWindow(mClipWnd); + mClipWnd = 0; + } + // If it exists, destroy our os2FrameWindow helper object. if (mFrame) { delete mFrame; @@ -812,11 +819,11 @@ void nsWindow::Scroll(const nsIntPoint& aDelta, // but not the part outside it [at least on Windows]. For // these widgets, we have to invalidate them to get both // parts updated after the scroll. - if (w->mBounds.Intersects(affectedRect)) { + if (w->mWnd && w->mBounds.Intersects(affectedRect)) { if (!ClipRegionContainedInRect(configuration.mClipRegion, - affectedRect - (w->mBounds.TopLeft() - + aDelta)) && mWnd) { - WinInvalidateRect(mWnd, 0, FALSE); + affectedRect - + (w->mBounds.TopLeft() + aDelta))) { + WinInvalidateRect(w->mWnd, 0, FALSE); } // Send a WM_VRNDISABLED to the plugin child of this widget.