From f4e4f7e7d2088d71c6b975622960b089e48cba76 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 30 Sep 2009 08:18:20 +1000 Subject: [PATCH] Bug 508908. Disable windowed plugins in popup windows, since they don't work. r=dbaron --HG-- extra : rebase_source : 1acfac3d3613d332586fade393f2911552bd03e0 --- layout/base/nsPresContext.cpp | 4 ++-- layout/generic/crashtests/508908-1.html | 24 +++++++++++++++++++++++ layout/generic/crashtests/crashtests.list | 1 + layout/generic/nsGfxScrollFrame.cpp | 12 ++++++++++-- layout/generic/nsObjectFrame.cpp | 9 ++++++++- layout/reftests/bugs/508908-1-ref.xul | 7 +++++++ layout/reftests/bugs/508908-1.xul | 15 ++++++++++++++ layout/reftests/bugs/reftest.list | 1 + 8 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 layout/generic/crashtests/508908-1.html create mode 100644 layout/reftests/bugs/508908-1-ref.xul create mode 100644 layout/reftests/bugs/508908-1.xul diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 0251227e7d10..6dd384cea3b5 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2357,8 +2357,8 @@ nsRootPresContext::UpdatePluginGeometry(nsIFrame* aChangedSubtree) GetPluginGeometryUpdates(aChangedSubtree, &configurations); if (configurations.IsEmpty()) return; - nsIWidget* widget = configurations[0].mChild->GetParent(); - NS_ASSERTION(widget, "Plugin must have a parent"); + nsIWidget* widget = FrameManager()->GetRootFrame()->GetWindow(); + NS_ASSERTION(widget, "Plugins must have a parent window"); widget->ConfigureChildren(configurations); DidApplyPluginGeometryUpdates(); } diff --git a/layout/generic/crashtests/508908-1.html b/layout/generic/crashtests/508908-1.html new file mode 100644 index 000000000000..e2dafdb8a15c --- /dev/null +++ b/layout/generic/crashtests/508908-1.html @@ -0,0 +1,24 @@ + + + + + + +
+ diff --git a/layout/generic/crashtests/crashtests.list b/layout/generic/crashtests/crashtests.list index 24e16f837164..1b7b7730a9fb 100644 --- a/layout/generic/crashtests/crashtests.list +++ b/layout/generic/crashtests/crashtests.list @@ -267,6 +267,7 @@ load 494332-1.html load 501535-1.html load 503961-1.xhtml load 503961-2.html +load 508908-1.html load 505912-1.html # load 508115-1.html load 511482.html diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index b5e0bf10fc3a..e9f13af95985 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -79,6 +79,7 @@ #endif #include "nsDisplayList.h" #include "nsBidiUtils.h" +#include "nsFrameManager.h" //---------------------------------------------------------------------- @@ -1815,8 +1816,15 @@ nsGfxScrollFrameInner::ViewPositionDidChange(nsIScrollableView* aScrollable, nsPoint childOffset = mScrolledFrame->GetView()->GetOffsetTo(mOuter->GetView()); mScrolledFrame->SetPosition(childOffset); - mOuter->PresContext()->RootPresContext()-> - GetPluginGeometryUpdates(mOuter, aConfigurations); + nsRootPresContext* rootPresContext = mOuter->PresContext()->RootPresContext(); + // Only update plugin geometry if we're scrolling in the root widget. + // In particular if we're scrolling inside a popup widget, we don't + // want to update plugins since they don't belong to this widget (we + // don't display windowed plugins in popups). + if (mOuter->GetWindow() == + rootPresContext->FrameManager()->GetRootFrame()->GetWindow()) { + rootPresContext->GetPluginGeometryUpdates(mOuter, aConfigurations); + } } /** diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index f53f6650165d..4c452a91939f 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -725,7 +725,14 @@ nsObjectFrame::CreateWidget(nscoord aWidth, rpc->RegisterPluginForGeometryUpdates(this); rpc->UpdatePluginGeometry(this); - mWidget->Show(PR_TRUE); + // If this frame has an ancestor with a widget which is not + // the root prescontext's widget, then this plugin should not be + // displayed, so don't show the widget. If we show the widget, the + // plugin may appear in the main window. In Web content this would + // only happen with a plugin in a XUL popup. + if (parentWidget == GetWindow()) { + mWidget->Show(PR_TRUE); + } } if (mWidget) { diff --git a/layout/reftests/bugs/508908-1-ref.xul b/layout/reftests/bugs/508908-1-ref.xul new file mode 100644 index 000000000000..148211860a79 --- /dev/null +++ b/layout/reftests/bugs/508908-1-ref.xul @@ -0,0 +1,7 @@ + + + + + + diff --git a/layout/reftests/bugs/508908-1.xul b/layout/reftests/bugs/508908-1.xul new file mode 100644 index 000000000000..9e3fa4581535 --- /dev/null +++ b/layout/reftests/bugs/508908-1.xul @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index d780200b967e..bf8b57526e60 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1313,6 +1313,7 @@ fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs == 507762-2.html 507762-2-ref.html == 507762-3.html 507762-1-ref.html == 507762-4.html 507762-2-ref.html +== 508908-1.xul 508908-1-ref.xul == 508919-1.xhtml 508919-1-ref.xhtml == 509155-1.xhtml 509155-1-ref.xhtml == 512410.html 512410-ref.html