From 7ee7b46bd336a47e0ea2a6413be43619a0de09b5 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 5 Sep 2012 09:23:45 -0700 Subject: [PATCH] Bug 783066: Paint the backgrounds of remote subdocuments like we paint those of same-process subdocuments. r=roc --- dom/ipc/TabChild.cpp | 17 +++++++++++++++++ dom/ipc/TabChild.h | 2 ++ layout/base/nsPresContext.cpp | 19 +++++++++++++++++++ layout/base/nsPresContext.h | 1 + layout/base/nsPresShell.cpp | 2 +- widget/xpwidgets/PuppetWidget.h | 11 +++++++++-- 6 files changed, 49 insertions(+), 3 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index c3b0f717988..10c6693de19 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -677,6 +677,23 @@ TabChild::~TabChild() } } +bool +TabChild::IsRootContentDocument() +{ + if (!mIsBrowserElement && mAppId == nsIScriptSecurityManager::NO_APP_ID) { + // We're the child side of a . This + // is always a root content document. + return true; + } + + // Otherwise, we're the child side of an or . Because of bug 761935, + // these can't be nested within another , so + // we assume that we can't be a root content document. When that + // bug is fixed, we need to revisit that assumption. + return false; +} + bool TabChild::RecvLoadURL(const nsCString& uri) { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 045d0eb2cfa..6d21cab0cde 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -164,6 +164,8 @@ public: uint32_t GetAppId() { return mAppId; } + bool IsRootContentDocument(); + NS_DECL_ISUPPORTS NS_DECL_NSIWEBBROWSERCHROME NS_DECL_NSIWEBBROWSERCHROME2 diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index a974fa2c6aa..769469e43f0 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -5,6 +5,8 @@ /* a presentation of a document, part 1 */ +#include "base/basictypes.h" + #include "nsCOMPtr.h" #include "nsPresContext.h" #include "nsIPresShell.h" @@ -63,6 +65,8 @@ #include "nsDOMMediaQueryList.h" #include "nsSMILAnimationController.h" #include "mozilla/css/ImageLoader.h" +#include "mozilla/dom/PBrowserChild.h" +#include "mozilla/dom/TabChild.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" @@ -2340,6 +2344,21 @@ nsPresContext::IsRootContentDocument() return (f && f->PresContext()->IsChrome()); } +bool +nsPresContext::IsCrossProcessRootContentDocument() +{ + if (!IsRootContentDocument()) { + return false; + } + + if (XRE_GetProcessType() == GeckoProcessType_Default) { + return true; + } + + TabChild* tabChild = GetTabChildFrom(mShell); + return (tabChild && tabChild->IsRootContentDocument()); +} + nsRootPresContext::nsRootPresContext(nsIDocument* aDocument, nsPresContextType aType) : nsPresContext(aDocument, aType), diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 5f0f5289a9c..4924f6530a9 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -897,6 +897,7 @@ public: } bool IsRootContentDocument(); + bool IsCrossProcessRootContentDocument(); protected: friend class nsRunnableMethod; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 9fbdb6a4e75..df445234ada 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4927,7 +4927,7 @@ void PresShell::UpdateCanvasBackground() rootStyleFrame, drawBackgroundImage, drawBackgroundColor); - if (GetPresContext()->IsRootContentDocument() && + if (GetPresContext()->IsCrossProcessRootContentDocument() && !IsTransparentContainerElement(mPresContext)) { mCanvasBackgroundColor = NS_ComposeColors(GetDefaultBackgroundColorToDraw(), mCanvasBackgroundColor); diff --git a/widget/xpwidgets/PuppetWidget.h b/widget/xpwidgets/PuppetWidget.h index aee7885f651..7a7e6077c2c 100644 --- a/widget/xpwidgets/PuppetWidget.h +++ b/widget/xpwidgets/PuppetWidget.h @@ -133,13 +133,20 @@ public: // nsBaseWidget methods we override // -//NS_IMETHOD CaptureMouse(bool aCapture); + // Documents loaded in child processes are always subdocuments of + // other docs in an ancestor process. To ensure that the + // backgrounds of those documents are painted like those of + // same-process subdocuments, we force the widget here to be + // transparent, which in turn will cause layout to use a transparent + // backstop background color. + virtual nsTransparencyMode GetTransparencyMode() MOZ_OVERRIDE + { return eTransparencyTransparent; } + virtual LayerManager* GetLayerManager(PLayersChild* aShadowManager = nullptr, LayersBackend aBackendHint = mozilla::layers::LAYERS_NONE, LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, bool* aAllowRetaining = nullptr); -// virtual nsDeviceContext* GetDeviceContext(); virtual gfxASurface* GetThebesSurface(); NS_IMETHOD ResetInputState();