Bug 783066: Paint the backgrounds of remote subdocuments like we paint those of same-process subdocuments. r=roc

This commit is contained in:
Chris Jones 2012-09-05 09:23:45 -07:00
parent 5acd657e06
commit 7ee7b46bd3
6 changed files with 49 additions and 3 deletions

View File

@ -677,6 +677,23 @@ TabChild::~TabChild()
}
}
bool
TabChild::IsRootContentDocument()
{
if (!mIsBrowserElement && mAppId == nsIScriptSecurityManager::NO_APP_ID) {
// We're the child side of a <xul:browser remote=true>. This
// is always a root content document.
return true;
}
// Otherwise, we're the child side of an <html:browser
// remote=true> or <html:app remote=true>. Because of bug 761935,
// these can't be nested within another <html:app remote=true>, 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)
{

View File

@ -164,6 +164,8 @@ public:
uint32_t GetAppId() { return mAppId; }
bool IsRootContentDocument();
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIWEBBROWSERCHROME2

View File

@ -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),

View File

@ -897,6 +897,7 @@ public:
}
bool IsRootContentDocument();
bool IsCrossProcessRootContentDocument();
protected:
friend class nsRunnableMethod<nsPresContext>;

View File

@ -4927,7 +4927,7 @@ void PresShell::UpdateCanvasBackground()
rootStyleFrame,
drawBackgroundImage,
drawBackgroundColor);
if (GetPresContext()->IsRootContentDocument() &&
if (GetPresContext()->IsCrossProcessRootContentDocument() &&
!IsTransparentContainerElement(mPresContext)) {
mCanvasBackgroundColor =
NS_ComposeColors(GetDefaultBackgroundColorToDraw(), mCanvasBackgroundColor);

View File

@ -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();