jaegermonkey. what. a=arewefastyet
authorRobert Sayre <sayrer@gmail.com>
Sat, 11 Sep 2010 15:07:27 -0400
changeset 53643 f1bd314e64ac8ad717746fd72667300460b9cf38
parent 53642 09b657f24840aab9984395370900cfdcd6f33272 (current diff)
parent 52494 16eac4b8b8e05af3d7c5fe206676d9114e3b9c26 (diff)
child 53644 ac779114cfa60efff7753e389523b3de7a8a7525
push idunknown
push userunknown
push dateunknown
reviewersarewefastyet
milestone2.0b6pre
jaegermonkey. what. a=arewefastyet
build/automation.py.in
content/html/document/src/nsHTMLDocument.cpp
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -338,16 +338,17 @@ user_pref("dom.max_chrome_script_run_tim
 user_pref("dom.popup_maximum", -1);
 user_pref("signed.applets.codebase_principal_support", true);
 user_pref("security.warn_submit_insecure", false);
 user_pref("browser.shell.checkDefaultBrowser", false);
 user_pref("shell.checkDefaultClient", false);
 user_pref("browser.warnOnQuit", false);
 user_pref("accessibility.typeaheadfind.autostart", false);
 user_pref("javascript.options.showInConsole", true);
+user_pref("devtools.errorconsole.enabled", true);
 user_pref("layout.debug.enable_data_xbl", true);
 user_pref("browser.EULA.override", true);
 user_pref("javascript.options.tracejit.content", true);
 user_pref("javascript.options.methodjit.content", true);
 user_pref("gfx.color_management.force_srgb", true);
 user_pref("network.manage-offline-status", false);
 user_pref("test.mousescroll", true);
 user_pref("security.default_personal_cert", "Select Automatically"); // Need to client auth test be w/o any dialogs
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1845,16 +1845,17 @@ nsHTMLDocument::OpenCommon(const nsACStr
   if (!callerDoc) {
     // If we're called from C++ or in some other way without an originating
     // document we can't do a document.open w/o changing the principal of the
     // document to something like about:blank (as that's the only sane thing to
     // do when we don't know the origin of this call), and since we can't
     // change the principals of a document for security reasons we'll have to
     // refuse to go ahead with this call.
 
+    NS_WARNING("No caller doc for open call.");
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   // Grab a reference to the calling documents security info (if any)
   // and URIs as they may be lost in the call to Reset().
   nsCOMPtr<nsISupports> securityInfo = callerDoc->GetSecurityInfo();
   nsCOMPtr<nsIURI> uri = callerDoc->GetDocumentURI();
   nsCOMPtr<nsIURI> baseURI = callerDoc->GetBaseURI();
@@ -1864,16 +1865,17 @@ nsHTMLDocument::OpenCommon(const nsACStr
   // origin, not just that the caller can access the document. This is
   // needed to keep document principals from ever changing, which is
   // needed because of the way we use our XOW code, and is a sane
   // thing to do anyways.
 
   PRBool equals = PR_FALSE;
   if (NS_FAILED(callerPrincipal->Equals(NodePrincipal(), &equals)) ||
       !equals) {
+    NS_WARNING("Principals unequal for open call.");
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   // Stop current loads targeted at the window this document is in.
   if (mScriptGlobalObject) {
     nsCOMPtr<nsIContentViewer> cv;
     shell->GetContentViewer(getter_AddRefs(cv));
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -6479,19 +6479,17 @@ nsDocShell::CreateAboutBlankContentViewe
 
       // create a content viewer for us and the new document
       docFactory->CreateInstanceForDocument(NS_ISUPPORTS_CAST(nsIDocShell *, this),
                     blankDoc, "view", getter_AddRefs(viewer));
 
       // hook 'em up
       if (viewer) {
         viewer->SetContainer(static_cast<nsIContentViewerContainer *>(this));
-        nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(blankDoc));
         Embed(viewer, "", 0);
-        viewer->SetDOMDocument(domdoc);
 
         SetCurrentURI(blankDoc->GetDocumentURI(), nsnull, PR_TRUE);
         rv = mIsBeingDestroyed ? NS_ERROR_NOT_AVAILABLE : NS_OK;
       }
     }
   }
   mCreatingDocument = PR_FALSE;
 
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7927,19 +7927,17 @@ nsCSSFrameConstructor::ProcessRestyledFr
         didReflow = PR_TRUE;
       }
       if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView |
                   nsChangeHint_UpdateOpacityLayer | nsChangeHint_UpdateTransformLayer)) {
         ApplyRenderingChangeToTree(presContext, frame, hint);
         didInvalidate = PR_TRUE;
       }
       if (hint & nsChangeHint_UpdateCursor) {
-        nsIViewManager* viewMgr = mPresShell->GetViewManager();
-        if (viewMgr)
-          viewMgr->SynthesizeMouseMove(PR_FALSE);
+        mPresShell->SynthesizeMouseMove(PR_FALSE);
       }
     }
   }
 
   EndUpdate();
 
   if (didInvalidate && !didReflow) {
     // RepaintFrame changes can indicate changes in opacity etc which
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -209,16 +209,20 @@ public:
   void SetAccurateVisibleRegions() { mAccurateVisibleRegions = PR_TRUE; }
   PRBool GetAccurateVisibleRegions() { return mAccurateVisibleRegions; }
   /**
    * Allows callers to selectively override the regular paint suppression checks,
    * so that methods like GetFrameForPoint work when painting is suppressed.
    */
   void IgnorePaintSuppression() { mIgnoreSuppression = PR_TRUE; }
   /**
+   * @return Returns if this builder will ignore paint suppression.
+   */
+  PRBool IsIgnoringPaintSuppression() { return mIgnoreSuppression; }
+  /**
    * @return Returns if this builder had to ignore painting suppression on some
    * document when building the display list.
    */
   PRBool GetHadToIgnorePaintSuppression() { return mHadToIgnoreSuppression; }
   /**
    * Call this if we're doing normal painting to the window.
    */
   void SetPaintingToWindow(PRBool aToWindow) { mIsPaintingToWindow = aToWindow; }
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -134,18 +134,18 @@ typedef struct CapturingContentInfo {
   nsIContent* mContent;
 
   CapturingContentInfo() :
     mAllowed(PR_FALSE), mRetargetToElement(PR_FALSE), mPreventDrag(PR_FALSE),
     mContent(nsnull) { }
 } CapturingContentInfo;
 
 #define NS_IPRESSHELL_IID     \
-  { 0xe63a350c, 0x4e04, 0x4056, \
-    { 0x8d, 0xa0, 0x51, 0xcc, 0x55, 0x68, 0x68, 0x42 } }
+  { 0x28d10cd2, 0x90a9, 0x4416, \
+    { 0x8e, 0x88, 0x2a, 0xe3, 0x3d, 0xb1, 0x73, 0xd4 } }
 
 // Constants for ScrollContentIntoView() function
 #define NS_PRESSHELL_SCROLL_TOP      0
 #define NS_PRESSHELL_SCROLL_BOTTOM   100
 #define NS_PRESSHELL_SCROLL_LEFT     0
 #define NS_PRESSHELL_SCROLL_RIGHT    100
 #define NS_PRESSHELL_SCROLL_CENTER   50
 #define NS_PRESSHELL_SCROLL_ANYWHERE -1
@@ -1049,16 +1049,23 @@ public:
 
   /**
    * Get the layer manager for the widget of the root view, if it has
    * one.
    */
   virtual LayerManager* GetLayerManager() = 0;
 
   /**
+   * Dispatch a mouse move event based on the most recent mouse position if
+   * this PresShell is visible. This is used when the contents of the page
+   * moved (aFromScroll is false) or scrolled (aFromScroll is true).
+   */
+  virtual void SynthesizeMouseMove(PRBool aFromScroll) = 0;
+
+  /**
    * Refresh observer management.
    */
 protected:
   virtual PRBool AddRefreshObserverExternal(nsARefreshObserver* aObserver,
                                             mozFlushType aFlushType);
   PRBool AddRefreshObserverInternal(nsARefreshObserver* aObserver,
                                     mozFlushType aFlushType);
   virtual PRBool RemoveRefreshObserverExternal(nsARefreshObserver* aObserver,
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2387,16 +2387,43 @@ nsPresContext::CheckForInterrupt(nsIFram
 #ifdef NOISY_INTERRUPTIBLE_REFLOW
     printf("*** DETECTED pending interrupt (time=%lld)\n", PR_Now());
 #endif /* NOISY_INTERRUPTIBLE_REFLOW */
     mShell->FrameNeedsToContinueReflow(aFrame);
   }
   return mHasPendingInterrupt;
 }
 
+PRBool
+nsPresContext::IsRootContentDocument()
+{
+  // We are a root content document if: we are not chrome, we are a
+  // subdocument, and our parent is chrome.
+  if (IsChrome()) {
+    return PR_FALSE;
+  }
+  // We may not have a root frame, so use views.
+  nsIViewManager* vm = PresShell()->GetViewManager();
+  nsIView* view = nsnull;
+  if (NS_FAILED(vm->GetRootView(view)) || !view) {
+    return PR_FALSE;
+  }
+  view = view->GetParent(); // anonymous inner view
+  if (!view) {
+    return PR_FALSE;
+  }
+  view = view->GetParent(); // subdocumentframe's view
+  if (!view) {
+    return PR_FALSE;
+  }
+
+  nsIFrame* f = static_cast<nsIFrame*>(view->GetClientData());
+  return (f && f->PresContext()->IsChrome());
+}
+
 nsRootPresContext::nsRootPresContext(nsIDocument* aDocument,
                                      nsPresContextType aType)
   : nsPresContext(aDocument, aType),
     mUpdatePluginGeometryForFrame(nsnull),
     mNeedsToUpdatePluginGeometry(PR_FALSE)
 {
   mRegisteredPlugins.Init();
 }
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -978,16 +978,18 @@ public:
     PRUint32 result = 0;
 
     result += sizeof(nsPresContext);
     result += GetBidiMemoryUsed();
 
     return result;
   }
 
+  PRBool IsRootContentDocument();
+
 protected:
   friend class nsRunnableMethod<nsPresContext>;
   NS_HIDDEN_(void) ThemeChangedInternal();
   NS_HIDDEN_(void) SysColorChangedInternal();
 
   NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
 #ifdef MOZ_SMIL
   NS_HIDDEN_(void) SetSMILAnimations(nsIDocument *aDoc, PRUint16 aNewMode,
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -810,16 +810,18 @@ public:
   virtual already_AddRefed<gfxASurface> RenderSelection(nsISelection* aSelection,
                                                         nsIntPoint& aPoint,
                                                         nsIntRect* aScreenRect);
 
   virtual already_AddRefed<nsPIDOMWindow> GetRootWindow();
 
   virtual LayerManager* GetLayerManager();
 
+  virtual void SynthesizeMouseMove(PRBool aFromScroll);
+
   //nsIViewObserver interface
 
   NS_IMETHOD Paint(nsIView* aDisplayRoot,
                    nsIView* aViewToPaint,
                    nsIWidget* aWidget,
                    const nsRegion& aDirtyRegion,
                    const nsIntRegion& aIntDirtyRegion,
                    PRBool aPaintDefaultBackground,
@@ -829,17 +831,16 @@ public:
                          nsEventStatus*  aEventStatus);
   virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                                         nsEvent* aEvent,
                                                         nsEventStatus* aStatus);
   virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                                         nsIDOMEvent* aEvent,
                                                         nsEventStatus* aStatus);
   NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight);
-  NS_IMETHOD_(PRBool) IsVisible();
   NS_IMETHOD_(PRBool) ShouldIgnoreInvalidation();
   NS_IMETHOD_(void) WillPaint(PRBool aWillSendDidPaint);
   NS_IMETHOD_(void) DidPaint();
   NS_IMETHOD_(void) DispatchSynthMouseMove(nsGUIEvent *aEvent,
                                            PRBool aFlushOnHoverChange);
   NS_IMETHOD_(void) ClearMouseCapture(nsIView* aView);
 
   // caret handling
@@ -4553,18 +4554,18 @@ PresShell::UnsuppressAndInvalidate()
     }
   }
 
   // now that painting is unsuppressed, focus may be set on the document
   nsPIDOMWindow *win = mDocument->GetWindow();
   if (win)
     win->SetReadyForFocus();
 
-  if (!mHaveShutDown && mViewManager)
-    mViewManager->SynthesizeMouseMove(PR_FALSE);
+  if (!mHaveShutDown)
+    SynthesizeMouseMove(PR_FALSE);
 }
 
 void
 PresShell::UnsuppressPainting()
 {
   if (mPaintSuppressionTimer) {
     mPaintSuppressionTimer->Cancel();
     mPaintSuppressionTimer = nsnull;
@@ -5808,18 +5809,17 @@ void PresShell::UpdateCanvasBackground()
       nsCSSRendering::FindRootFrameBackground(rootStyleFrame);
     // XXX We should really be passing the canvasframe, not the root element
     // style frame but we don't have access to the canvasframe here. It isn't
     // a problem because only a few frames can return something other than true
     // and none of them would be a canvas frame or root element style frame.
     mCanvasBackgroundColor =
       nsCSSRendering::DetermineBackgroundColor(mPresContext, bgStyle,
                                                rootStyleFrame);
-    if (nsLayoutUtils::GetCrossDocParentFrame(FrameManager()->GetRootFrame()) &&
-        !nsContentUtils::IsChildOfSameType(mDocument) &&
+    if (GetPresContext()->IsRootContentDocument() &&
         !IsTransparentContainerElement(mPresContext)) {
       mCanvasBackgroundColor =
         NS_ComposeColors(mPresContext->DefaultBackgroundColor(), mCanvasBackgroundColor);
     }
   }
 
   // If the root element of the document (ie html) has style 'display: none'
   // then the document's background color does not get drawn; cache the
@@ -5858,16 +5858,23 @@ LayerManager* PresShell::GetLayerManager
   if (NS_SUCCEEDED(mViewManager->GetRootView(rootView)) && rootView) {
     if (nsIWidget* widget = rootView->GetWidget()) {
       return widget->GetLayerManager();
     }
   }
   return nsnull;
 }
 
+void PresShell::SynthesizeMouseMove(PRBool aFromScroll)
+{
+  if (mViewManager && !mPaintingSuppressed && mIsActive) {
+    mViewManager->SynthesizeMouseMove(aFromScroll);
+  }
+}
+
 static void DrawThebesLayer(ThebesLayer* aLayer,
                             gfxContext* aContext,
                             const nsIntRegion& aRegionToDraw,
                             const nsIntRegion& aRegionToInvalidate,
                             void* aCallbackData)
 {
   PaintParams* params = static_cast<PaintParams*>(aCallbackData);
   nsIFrame* frame = params->mFrame;
@@ -7178,39 +7185,27 @@ PresShell::GetCurrentItemAndPositionForE
 
 NS_IMETHODIMP
 PresShell::ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight)
 {
   return ResizeReflow(aWidth, aHeight);
 }
 
 NS_IMETHODIMP_(PRBool)
-PresShell::IsVisible()
-{
-  nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
-  nsCOMPtr<nsIBaseWindow> bw = do_QueryInterface(container);
-  if (!bw)
-    return PR_FALSE;
-  PRBool res = PR_TRUE;
-  bw->GetVisibility(&res);
-  return res;
-}
-
-NS_IMETHODIMP_(PRBool)
 PresShell::ShouldIgnoreInvalidation()
 {
   return mPaintingSuppressed || !mIsActive;
 }
 
 NS_IMETHODIMP_(void)
 PresShell::WillPaint(PRBool aWillSendDidPaint)
 {
-  // Don't bother doing anything if some viewmanager in our tree is
-  // painting while we still have painting suppressed.
-  if (mPaintingSuppressed) {
+  // Don't bother doing anything if some viewmanager in our tree is painting
+  // while we still have painting suppressed or we are not active.
+  if (mPaintingSuppressed || !mIsActive) {
     return;
   }
 
   if (!aWillSendDidPaint) {
     nsRootPresContext* rootPresContext = mPresContext->GetRootPresContext();
     if (!rootPresContext) {
       return;
     }
@@ -7369,25 +7364,25 @@ PresShell::Thaw()
     presContext->RefreshDriver()->Thaw();
   }
 
   mDocument->EnumerateFreezableElements(ThawElement, this);
 
   if (mDocument)
     mDocument->EnumerateSubDocuments(ThawSubDocument, nsnull);
 
-  UnsuppressPainting();
-
   // Get the activeness of our presshell, as this might have changed
   // while we were in the bfcache
   QueryIsActive();
 
   // We're now unfrozen
   mFrozen = PR_FALSE;
   UpdateImageLockingState();
+
+  UnsuppressPainting();
 }
 
 //--------------------------------------------------------
 // Start of protected and private methods on the PresShell
 //--------------------------------------------------------
 
 void
 PresShell::MaybeScheduleReflow()
@@ -7443,20 +7438,17 @@ PresShell::WillDoReflow()
 }
 
 void
 PresShell::DidDoReflow(PRBool aInterruptible)
 {
   mFrameConstructor->EndUpdate();
   
   HandlePostedReflowCallbacks(aInterruptible);
-  // Null-check mViewManager in case this happens during Destroy.  See
-  // bugs 244435 and 238546.
-  if (!mPaintingSuppressed && mViewManager)
-    mViewManager->SynthesizeMouseMove(PR_FALSE);
+  SynthesizeMouseMove(PR_FALSE);
   if (mCaret) {
     // Update the caret's position now to account for any changes created by
     // the reflow.
     mCaret->InvalidateOutsideCaret();
     mCaret->UpdateCaretPosition();
   }
 }
 
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1575,18 +1575,17 @@ InvalidateFixedBackgroundFrames(nsIFrame
 }
 
 PRBool nsGfxScrollFrameInner::IsAlwaysActive() const
 {
   // The root scrollframe for a non-chrome document which is the direct
   // child of a chrome document is always treated as "active".
   // XXX maybe we should extend this so that IFRAMEs which are fill the
   // entire viewport (like GMail!) are always active
-  return mIsRoot &&
-    !nsContentUtils::IsChildOfSameType(mOuter->GetContent()->GetCurrentDoc());
+  return mIsRoot && mOuter->PresContext()->IsRootContentDocument();
 }
 
 PRBool nsGfxScrollFrameInner::IsScrollingActive() const
 {
   return mScrollingActive || IsAlwaysActive();
 }
 
 void nsGfxScrollFrameInner::MarkActive()
@@ -1692,17 +1691,17 @@ nsGfxScrollFrameInner::ScrollToImpl(nsPo
   }
   
   // Update frame position for scrolling
   mScrolledFrame->SetPosition(mScrollPort.TopLeft() - pt);
 
   // We pass in the amount to move visually
   ScrollVisual(curPosDevPx - ptDevPx);
 
-  presContext->PresShell()->GetViewManager()->SynthesizeMouseMove(PR_TRUE);
+  presContext->PresShell()->SynthesizeMouseMove(PR_TRUE);
   UpdateScrollbarPosition();
   PostScrollEvent();
 
   // notify the listeners.
   for (PRUint32 i = 0; i < mListeners.Length(); i++) {
     mListeners[i]->ScrollPositionDidChange(pt.x, pt.y);
   }
 }
@@ -1749,17 +1748,17 @@ nsGfxScrollFrameInner::BuildDisplayList(
   // frame and we are a toplevel content document. In this situation, the
   // scrollbar(s) would normally be assigned their own layer anyway, since
   // they're not scrolled with the rest of the document. But when both
   // scrollbars are visible, the layer's visible rectangle would be the size
   // of the viewport, so most layer implementations would create a layer buffer
   // that's much larger than necessary. Creating independent layers for each
   // scrollbar works around the problem.
   PRBool createLayersForScrollbars = mIsRoot &&
-      !nsContentUtils::IsChildOfSameType(mOuter->GetContent()->GetCurrentDoc());
+    mOuter->PresContext()->IsRootContentDocument();
   for (nsIFrame* kid = mOuter->GetFirstChild(nsnull); kid; kid = kid->GetNextSibling()) {
     if (kid != mScrolledFrame) {
       if (kid == mScrollCornerBox && hasResizer) {
         // skip the resizer as this will be drawn later on top of the scrolled content
         continue;
       }
       rv = mOuter->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, scrollParts,
                                             nsIFrame::DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -258,35 +258,45 @@ nsSubDocumentFrame::BuildDisplayList(nsD
   NS_ENSURE_SUCCESS(rv, rv);
   
   if (!mInnerView)
     return NS_OK;
   nsIView* subdocView = mInnerView->GetFirstChild();
   if (!subdocView)
     return NS_OK;
 
-  nsCOMPtr<nsIPresShell> presShell;
+  nsCOMPtr<nsIPresShell> presShell = nsnull;
 
   nsIFrame* subdocRootFrame =
     static_cast<nsIFrame*>(subdocView->GetClientData());
 
   if (subdocRootFrame) {
     presShell = subdocRootFrame->PresContext()->PresShell();
-  } else {
+  }
+  // If painting is suppressed in the presshell, we try to look for a better
+  // presshell to use.
+  if (!presShell || (presShell->IsPaintingSuppressed() &&
+                     !aBuilder->IsIgnoringPaintSuppression())) {
     // During page transition mInnerView will sometimes have two children, the
     // first being the new page that may not have any frame, and the second
     // being the old page that will probably have a frame.
     nsIView* nextView = subdocView->GetNextSibling();
+    nsIFrame* frame = nsnull;
     if (nextView) {
-      subdocRootFrame = static_cast<nsIFrame*>(nextView->GetClientData());
+      frame = static_cast<nsIFrame*>(nextView->GetClientData());
     }
-    if (subdocRootFrame) {
-      subdocView = nextView;
-      presShell = subdocRootFrame->PresContext()->PresShell();
-    } else {
+    if (frame) {
+      nsIPresShell* ps = frame->PresContext()->PresShell();
+      if (!presShell || (ps && !ps->IsPaintingSuppressed())) {
+        subdocView = nextView;
+        subdocRootFrame = frame;
+        presShell = ps;
+      }
+    }
+    if (!presShell) {
       // If we don't have a frame we use this roundabout way to get the pres shell.
       if (!mFrameLoader)
         return NS_OK;
       nsCOMPtr<nsIDocShell> docShell;
       mFrameLoader->GetDocShell(getter_AddRefs(docShell));
       if (!docShell)
         return NS_OK;
       docShell->GetPresShell(getter_AddRefs(presShell));
@@ -360,17 +370,17 @@ nsSubDocumentFrame::BuildDisplayList(nsD
   }
 
   if (NS_SUCCEEDED(rv)) {
     if (subdocRootFrame && parentAPD != subdocAPD) {
       nsDisplayZoom* zoomItem =
         new (aBuilder) nsDisplayZoom(aBuilder, subdocRootFrame, &childItems,
                                      subdocAPD, parentAPD);
       childItems.AppendToTop(zoomItem);
-    } else if (!nsContentUtils::IsChildOfSameType(presShell->GetDocument())) {
+    } else if (presContext->IsRootContentDocument()) {
       // We always want top level content documents to be in their own layer.
       // If we need a zoom item then we are good because it creates a layer. If
       // not then create our own layer.
       nsDisplayOwnLayer* layerItem = new (aBuilder) nsDisplayOwnLayer(
         aBuilder, subdocRootFrame ? subdocRootFrame : this, &childItems);
       childItems.AppendToTop(layerItem);
     }
 
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -94,22 +94,27 @@
             .treeOwner
             .QueryInterface(Ci.nsIInterfaceRequestor)
             .getInterface(Ci.nsIXULWindow)
             .XULBrowserWindow = gXULBrowserWindow;
 
       var _delayedOnLoad = function() {
         gFindBar = document.getElementById("FindToolbar");
         gBrowser = document.getElementById("content");
-        gBrowser.addEventListener("pageshow", onPageShow, false);
+        gBrowser.addEventListener("pageshow", _delayedOnPageShow, false);
         gBrowser.loadURI("data:text/html,<h2 id='h2'>" + SEARCH_TEXT + "</h2><h2><a href='" + SAMPLE_URL + "'>Link Test</a></h2><input id='text' type='text' value='" + SAMPLE_TEXT + "'></input><input id='button' type='button'></input><img id='img' width='50' height='50'/>");
       }
       setTimeout(_delayedOnLoad, 1000);
     }
 
+    function _delayedOnPageShow() {
+      // setTimeout to the test runs after painting suppression ends
+      setTimeout(onPageShow, 0);
+    }
+
     function onPageShow() {
       testNormalFind();
       gFindBar.close();
       ok(gFindBar.hidden, "Failed to close findbar after testNormalFind");
       testAutoCaseSensitivityUI();
       testQuickFindText();
       gFindBar.close();
       ok(gFindBar.hidden, "Failed to close findbar after testQuickFindText");
--- a/view/public/nsIViewObserver.h
+++ b/view/public/nsIViewObserver.h
@@ -42,18 +42,18 @@
 #include "nsEvent.h"
 #include "nsColor.h"
 #include "nsRect.h"
 
 class nsIRenderingContext;
 class nsGUIEvent;
 
 #define NS_IVIEWOBSERVER_IID  \
-  { 0x6af699da, 0x8bfe, 0x43c9, \
-    { 0xae, 0xc1, 0x76, 0x1b, 0x03, 0x62, 0x8d, 0x64 } }
+  { 0x4d467c73, 0xb6a9, 0x462a, \
+    { 0x90, 0x25, 0x80, 0xd9, 0x42, 0xbc, 0xcc, 0xb5 } }
 
 class nsIViewObserver : public nsISupports
 {
 public:
   
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWOBSERVER_IID)
 
   /* called when the observer needs to paint. This paints the entire
@@ -103,22 +103,16 @@ public:
    * content within the view needs to be reflowed.
    * @param aWidth - new width of view
    * @param aHeight - new height of view
    * @return error status
    */
   NS_IMETHOD ResizeReflow(nsIView * aView, nscoord aWidth, nscoord aHeight) = 0;
 
   /**
-   * Hack to find out if the view observer is itself visible, in lieu
-   * of having the view trees linked.
-   */
-  NS_IMETHOD_(PRBool) IsVisible() = 0;
-
-  /**
    * Returns true if the view observer wants to drop all invalidation right now
    * because painting is suppressed. It will invalidate everything when it
    * unsuppresses.
    */
   NS_IMETHOD_(PRBool) ShouldIgnoreInvalidation() = 0;
 
   /**
    * Notify the observer that we're about to start painting.  This
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -95,28 +95,16 @@ public:
     if (mViewManager)
       mViewManager->ProcessInvalidateEvent();
     return NS_OK;
   }
 };
 
 //-------------- End Invalidate Event Definition ---------------------------
 
-static PRBool IsViewVisible(nsView *aView)
-{
-  if (!aView->IsEffectivelyVisible())
-    return PR_FALSE;
-
-  // Find out if the root view is visible by asking the view observer
-  // (this won't be needed anymore if we link view trees across chrome /
-  // content boundaries in DocumentViewerImpl::MakeWindow).
-  nsIViewObserver* vo = aView->GetViewManager()->GetViewObserver();
-  return vo && vo->IsVisible();
-}
-
 void
 nsViewManager::PostInvalidateEvent()
 {
   NS_ASSERTION(IsRootVM(), "Caller screwed up");
 
   if (!mInvalidateEvent.IsPending()) {
     nsRefPtr<nsViewManagerEvent> ev = new nsInvalidateEvent(this);
     if (NS_FAILED(NS_DispatchToCurrentThread(ev))) {
@@ -319,17 +307,17 @@ void nsViewManager::DoSetWindowDimension
     if (mObserver)
       mObserver->ResizeReflow(mRootView, aWidth, aHeight);
   }
 }
 
 NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
 {
   if (mRootView) {
-    if (IsViewVisible(mRootView)) {
+    if (mRootView->IsEffectivelyVisible()) {
       mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
       DoSetWindowDimensions(aWidth, aHeight);
     } else {
       mDelayedResize.SizeTo(aWidth, aHeight);
     }
   }
 
   return NS_OK;
@@ -616,17 +604,20 @@ nsViewManager::UpdateWidgetArea(nsView *
   if (aWidget->GetTransparencyMode() != eTransparencyTransparent) {
     for (nsIWidget* childWidget = aWidget->GetFirstChild();
          childWidget;
          childWidget = childWidget->GetNextSibling()) {
       nsView* view = nsView::GetViewFor(childWidget);
       NS_ASSERTION(view != aWidgetView, "will recur infinitely");
       PRBool visible;
       childWidget->IsVisible(visible);
-      if (view && visible && !IsWidgetDrawnByPlugin(childWidget, view)) {
+      nsWindowType type;
+      childWidget->GetWindowType(type);
+      if (view && visible && !IsWidgetDrawnByPlugin(childWidget, view) &&
+          type != eWindowType_popup) {
         // Don't mess with views that are in completely different view
         // manager trees
         nsViewManager* viewManager = view->GetViewManager();
         if (viewManager->RootViewManager() == RootViewManager()) {
           // get the damage region into view's coordinate system and appunits
           nsRegion damage =
             ConvertRegionBetweenViews(intersection, aWidgetView, view);
 
@@ -874,32 +865,32 @@ NS_IMETHODIMP nsViewManager::DispatchEve
           // If an ancestor widget was hidden and then shown, we could
           // have a delayed resize to handle.
           PRBool didResize = PR_FALSE;
           for (nsViewManager *vm = this; vm;
                vm = vm->mRootView->GetParent()
                       ? vm->mRootView->GetParent()->GetViewManager()
                       : nsnull) {
             if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
-                IsViewVisible(vm->mRootView)) {
+                vm->mRootView->IsEffectivelyVisible()) {
               vm->FlushDelayedResize(PR_TRUE);
 
               // Paint later.
               vm->UpdateView(vm->mRootView, NS_VMREFRESH_NO_SYNC);
               didResize = PR_TRUE;
 
               // not sure if it's valid for us to claim that we
               // ignored this, but we're going to do so anyway, since
               // we didn't actually paint anything
               *aStatus = nsEventStatus_eIgnore;
             }
           }
 
           if (!didResize) {
-            //NS_ASSERTION(IsViewVisible(view), "painting an invisible view");
+            //NS_ASSERTION(view->IsEffectivelyVisible(), "painting an invisible view");
 
             // Notify view observers that we're about to paint.
             // Make sure to not send WillPaint notifications while scrolling.
 
             nsCOMPtr<nsIWidget> widget;
             rootVM->GetRootWidget(getter_AddRefs(widget));
             PRBool transparentWindow = PR_FALSE;
             if (widget)
@@ -1666,21 +1657,23 @@ nsViewManager::CallWillPaintOnObservers(
 #ifdef DEBUG
   PRInt32 savedUpdateBatchCnt = mUpdateBatchCnt;
 #endif
   PRInt32 index;
   for (index = 0; index < mVMCount; index++) {
     nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
     if (vm->RootViewManager() == this) {
       // One of our kids.
-      nsCOMPtr<nsIViewObserver> obs = vm->GetViewObserver();
-      if (obs) {
-        obs->WillPaint(aWillSendDidPaint);
-        NS_ASSERTION(mUpdateBatchCnt == savedUpdateBatchCnt,
-                     "Observer did not end view batch?");
+      if (vm->mRootView && vm->mRootView->IsEffectivelyVisible()) {
+        nsCOMPtr<nsIViewObserver> obs = vm->GetViewObserver();
+        if (obs) {
+          obs->WillPaint(aWillSendDidPaint);
+          NS_ASSERTION(mUpdateBatchCnt == savedUpdateBatchCnt,
+                       "Observer did not end view batch?");
+        }
       }
     }
   }
 }
 
 void
 nsViewManager::CallDidPaintOnObservers()
 {