Bug 590294, part -1: Clip <browser> shadow layers properly. r=tn
authorChris Jones <jones.chris.g@gmail.com>
Fri, 03 Sep 2010 15:10:45 -0500
changeset 54074 b3039d94296ea086716f9ddb1442c3fcb7d86ba2
parent 54073 26d16ccfbdc0832b69003c3999e9a71b1b72fec3
child 54075 38d1ce121661ef142e3092d70b2cced75a6fab2c
push idunknown
push userunknown
push dateunknown
reviewerstn
bugs590294
milestone2.0b6pre
Bug 590294, part -1: Clip <browser> shadow layers properly. r=tn
layout/generic/nsSubDocumentFrame.cpp
layout/ipc/RenderFrameParent.cpp
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -166,17 +166,16 @@ nsSubDocumentFrame::Init(nsIContent*    
   // canvas) when it really needs to have this frame's view as its
   // parent. So, create this frame's view right away, whether we
   // really need it or not, and the inner view will get it as the
   // parent.
   if (!HasView()) {
     rv = nsHTMLContainerFrame::CreateViewForFrame(this, PR_TRUE);
     NS_ENSURE_SUCCESS(rv, rv);
   }
-  nsIView* view = GetView();
 
   // Set the primary frame now so that
   // DocumentViewerImpl::FindContainerView called by ShowViewer below
   // can find it if necessary.
   aContent->SetPrimaryFrame(this);
 
   nsContentUtils::AddScriptRunner(new AsyncFrameInit(this));
   return NS_OK;
@@ -257,31 +256,41 @@ nsSubDocumentFrame::BuildDisplayList(nsD
 
   if (aBuilder->IsForEventDelivery() &&
       GetStyleVisibility()->mPointerEvents == NS_STYLE_POINTER_EVENTS_NONE)
     return NS_OK;
 
   nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  if (!mInnerView)
+    return NS_OK;
+
 #ifdef MOZ_IPC
   nsFrameLoader* frameLoader = FrameLoader();
   if (frameLoader) {
     RenderFrameParent* rfp = frameLoader->GetCurrentRemoteFrame();
     if (rfp) {
       // We're the subdoc for <browser remote="true"> and it has
       // painted content.  Display its shadow layer tree.
-      return aLists.Content()
-        ->AppendNewToTop(new (aBuilder) nsDisplayRemote(aBuilder, this, rfp));
+      nsDisplayList shadowTree;
+      shadowTree.AppendToTop(
+        new (aBuilder) nsDisplayRemote(aBuilder, this, rfp));
+
+      // Clip the shadow layers to subdoc bounds
+      nsPoint offset = GetOffsetToCrossDoc(aBuilder->ReferenceFrame());
+      nsRect bounds = mInnerView->GetBounds() + offset;
+
+      return aLists.Content()->AppendNewToTop(
+        new (aBuilder) nsDisplayClip(aBuilder, this, this, &shadowTree,
+                                     bounds));
     }
   }
 #endif
 
-  if (!mInnerView)
-    return NS_OK;
   nsIView* subdocView = mInnerView->GetFirstChild();
   if (!subdocView)
     return NS_OK;
 
   nsCOMPtr<nsIPresShell> presShell;
 
   nsIFrame* subdocRootFrame =
     static_cast<nsIFrame*>(subdocView->GetClientData());
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -195,19 +195,18 @@ RenderFrameParent::BuildLayer(nsDisplayL
     }
     NS_ABORT_IF_FALSE(!mContainer->GetFirstChild(),
                       "container of shadow tree shouldn't have a 'root' here");
 
     mContainer->InsertAfter(shadowRoot, nsnull);
   }
 
   if (mContainer) {
-    mContainer->SetClipRect(shadowRoot->GetClipRect());
-    mContainer->SetVisibleRegion(shadowRoot->GetVisibleRegion());
     SetTransformFor(mContainer, aFrame, aBuilder);
+    mContainer->SetClipRect(nsnull);
   }
 
   AssertValidContainerOfShadowTree(mContainer, shadowRoot);
   return nsRefPtr<Layer>(mContainer).forget();
 }
 
 void
 RenderFrameParent::ActorDestroy(ActorDestroyReason why)