Revert to rev 36a5e2fa01c9
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 28 Aug 2010 01:11:22 -0500
changeset 54050 e5d7f621d213c292d7a244434b66cea52b7bc520
parent 54049 ea67e8bf995c989b1ed9e25b153640720dbe06a3
child 54052 a9c735c870b8db3c03f9908462f10e070d17b9db
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Revert to rev 36a5e2fa01c9
browser/base/content/browser.xul
browser/themes/gnomestripe/browser/browser.css
content/events/src/nsEventStateManager.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsDOMWindowUtils.h
dom/interfaces/base/nsIDOMWindowUtils.idl
editor/libeditor/html/crashtests/crashtests.list
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxXlibSurface.cpp
layout/base/nsDisplayList.cpp
layout/base/nsDisplayList.h
layout/base/nsDocumentViewer.cpp
layout/base/nsIDocumentViewer.h
layout/base/nsIDocumentViewerPrint.h
layout/base/nsLayoutDebugger.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresShell.cpp
layout/base/tests/chrome/Makefile.in
layout/base/tests/chrome/chrome_content_integration_window.xul
layout/base/tests/chrome/default_background_window.xul
layout/base/tests/chrome/test_chrome_content_integration.xul
layout/base/tests/chrome/test_default_background.xul
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsPageContentFrame.cpp
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
layout/printing/nsPrintObject.cpp
layout/printing/nsPrintObject.h
layout/reftests/svg/reftest.list
layout/style/test/Makefile.in
layout/style/test/hover_helper.html
layout/style/test/test_hover.html
layout/xul/base/src/nsBoxFrame.cpp
toolkit/content/tests/widgets/test_tree_view.xul
widget/src/cocoa/nsNativeThemeCocoa.mm
widget/src/windows/nsNativeThemeWin.cpp
widget/src/windows/nsWindow.cpp
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -1208,17 +1208,17 @@
                   flex="1" contenttooltip="aHTMLTooltip"
                   tabcontainer="tabbrowser-tabs"
                   contentcontextmenu="contentAreaContextMenu"
                   autocompletepopup="PopupAutoComplete"
                   onclick="return contentAreaClick(event, false);"/>
     </vbox>
   </hbox>
 
-  <vbox id="browser-bottombox" layer="true">
+  <vbox id="browser-bottombox">
     <statusbar class="chromeclass-status" id="status-bar"
 #ifdef WINCE
                hidden="true"
 #endif
                >
       <statusbarpanel id="statusbar-display" label="" flex="1"/>
       <statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel">
         <progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/>
--- a/browser/themes/gnomestripe/browser/browser.css
+++ b/browser/themes/gnomestripe/browser/browser.css
@@ -63,21 +63,16 @@
 }
 
 #navigator-toolbox[inFullscreen="true"],
 #navigator-toolbox[inFullscreen="true"] > #nav-bar {
   border-top: none;
   padding-top: 0;
 }
 
-#browser-bottombox:not([lwthemefooter="true"]) {
-  /* opaque for layers optimization */
-  -moz-appearance: window;
-}
-
 #urlbar:-moz-lwtheme:not([focused="true"]),
 .searchbar-textbox:-moz-lwtheme:not([focused="true"]),
 .tabbrowser-tab:-moz-lwtheme:not([selected="true"]) {
   opacity: .85;
 }
 
 .tabbrowser-tab:-moz-lwtheme {
   text-shadow: none;
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -3289,17 +3289,16 @@ nsEventStateManager::PostHandleEvent(nsP
     }
     break;
 #endif // ANDROID
 #endif // MOZ_IPC
   }
 
   //Reset target frame to null to avoid mistargeting after reentrant event
   mCurrentTarget = nsnull;
-  mCurrentTargetContent = nsnull;
 
   return ret;
 }
 
 #ifdef MOZ_IPC
 #ifdef ANDROID
 mozilla::dom::PBrowserParent*
 nsEventStateManager::GetCrossProcessTarget()
@@ -3608,18 +3607,16 @@ nsEventStateManager::DispatchMouseEvent(
   event.isShift = ((nsMouseEvent*)aEvent)->isShift;
   event.isControl = ((nsMouseEvent*)aEvent)->isControl;
   event.isAlt = ((nsMouseEvent*)aEvent)->isAlt;
   event.isMeta = ((nsMouseEvent*)aEvent)->isMeta;
   event.pluginEvent = ((nsMouseEvent*)aEvent)->pluginEvent;
   event.relatedTarget = aRelatedContent;
   event.inputSource = static_cast<nsMouseEvent*>(aEvent)->inputSource;
 
-  nsWeakFrame previousTarget = mCurrentTarget;
-
   mCurrentTargetContent = aTargetContent;
 
   nsIFrame* targetFrame = nsnull;
   if (aTargetContent) {
     nsESMEventCB callback(aTargetContent);
     nsEventDispatcher::Dispatch(aTargetContent, mPresContext, &event, nsnull,
                                 &status, &callback);
 
@@ -3627,17 +3624,16 @@ nsEventStateManager::DispatchMouseEvent(
     // it may not be the same object after event dispatching and handling.
     // So we need to refetch it.
     if (mPresContext) {
       targetFrame = mPresContext->GetPrimaryFrameFor(aTargetContent);
     }
   }
 
   mCurrentTargetContent = nsnull;
-  mCurrentTarget = previousTarget;
 
   return targetFrame;
 }
 
 void
 nsEventStateManager::NotifyMouseOut(nsGUIEvent* aEvent, nsIContent* aMovingInto)
 {
   if (!mLastMouseOverElement)
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -61,18 +61,16 @@
 
 #include "nsIViewManager.h"
 
 #include "nsIDOMHTMLCanvasElement.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 #include "nsLayoutUtils.h"
 #include "nsComputedDOMStyle.h"
-#include "nsIViewObserver.h"
-#include "nsIPresShell.h"
 
 #if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2)
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 #endif
 
 #include "jsobj.h"
 
@@ -223,43 +221,16 @@ NS_IMETHODIMP
 nsDOMWindowUtils::SendMouseEvent(const nsAString& aType,
                                  float aX,
                                  float aY,
                                  PRInt32 aButton,
                                  PRInt32 aClickCount,
                                  PRInt32 aModifiers,
                                  PRBool aIgnoreRootScrollFrame)
 {
-  return SendMouseEventCommon(aType, aX, aY, aButton, aClickCount, aModifiers,
-                              aIgnoreRootScrollFrame, PR_FALSE);
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::SendMouseEventToWindow(const nsAString& aType,
-                                         float aX,
-                                         float aY,
-                                         PRInt32 aButton,
-                                         PRInt32 aClickCount,
-                                         PRInt32 aModifiers,
-                                         PRBool aIgnoreRootScrollFrame)
-{
-  return SendMouseEventCommon(aType, aX, aY, aButton, aClickCount, aModifiers,
-                              aIgnoreRootScrollFrame, PR_TRUE);
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
-                                       float aX,
-                                       float aY,
-                                       PRInt32 aButton,
-                                       PRInt32 aClickCount,
-                                       PRInt32 aModifiers,
-                                       PRBool aIgnoreRootScrollFrame,
-                                       PRBool aToWindow)
-{
   if (!IsUniversalXPConnectCapable()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   // get the widget to send the event to
   nsPoint offset;
   nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
   if (!widget)
@@ -305,39 +276,18 @@ nsDOMWindowUtils::SendMouseEventCommon(c
   event.refPoint.x =
     NSAppUnitsToIntPixels(nsPresContext::CSSPixelsToAppUnits(aX) + offset.x,
                           appPerDev);
   event.refPoint.y =
     NSAppUnitsToIntPixels(nsPresContext::CSSPixelsToAppUnits(aY) + offset.y,
                           appPerDev);
   event.ignoreRootScrollFrame = aIgnoreRootScrollFrame;
 
-  nsresult rv;
   nsEventStatus status;
-  if (aToWindow) {
-    nsIPresShell* presShell = presContext->PresShell();
-    if (!presShell)
-      return NS_ERROR_FAILURE;
-    nsCOMPtr<nsIViewObserver> vo = do_QueryInterface(presShell);
-    if (!vo)
-      return NS_ERROR_FAILURE;
-    nsIViewManager* viewManager = presShell->GetViewManager();
-    if (!viewManager)
-      return NS_ERROR_FAILURE;
-    nsIView* view = nsnull;
-    rv = viewManager->GetRootView(view);
-    if (NS_FAILED(rv) || !view)
-      return NS_ERROR_FAILURE;
-
-    status = nsEventStatus_eIgnore;
-    rv = vo->HandleEvent(view, &event, &status);
-  } else {
-    rv = widget->DispatchEvent(&event, status);
-  }
-  return rv;
+  return widget->DispatchEvent(&event, status);
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SendMouseScrollEvent(const nsAString& aType,
                                        float aX,
                                        float aY,
                                        PRInt32 aButton,
                                        PRInt32 aScrollFlags,
--- a/dom/base/nsDOMWindowUtils.h
+++ b/dom/base/nsDOMWindowUtils.h
@@ -57,18 +57,9 @@ protected:
   // If aOffset is non-null, it gets filled in with the offset of the root
   // frame of our window to the nearest widget in the app units of our window.
   // Add this offset to any event offset we're given to make it relative to the
   // widget returned by GetWidget.
   nsIWidget* GetWidget(nsPoint* aOffset = nsnull);
   nsIWidget* GetWidgetForElement(nsIDOMElement* aElement);
 
   nsPresContext* GetPresContext();
-
-  NS_IMETHOD SendMouseEventCommon(const nsAString& aType,
-                                  float aX,
-                                  float aY,
-                                  PRInt32 aButton,
-                                  PRInt32 aClickCount,
-                                  PRInt32 aModifiers,
-                                  PRBool aIgnoreRootScrollFrame,
-                                  PRBool aToWindow);
 };
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -131,27 +131,16 @@ interface nsIDOMWindowUtils : nsISupport
   void sendMouseEvent(in AString aType,
                       in float aX,
                       in float aY,
                       in long aButton,
                       in long aClickCount,
                       in long aModifiers,
                       [optional] in boolean aIgnoreRootScrollFrame);
 
-  /** The same as sendMouseEvent but dispatches the event directly to the
-   *  window.
-   */
-  void sendMouseEventToWindow(in AString aType,
-                              in float aX,
-                              in float aY,
-                              in long aButton,
-                              in long aClickCount,
-                              in long aModifiers,
-                              [optional] in boolean aIgnoreRootScrollFrame);
-
   /** Synthesize a mouse scroll event for a window. The event types supported
    *  are: 
    *    DOMMouseScroll
    *    MozMousePixelScroll
    *
    * Events are sent in coordinates offset by aX and aY from the window.
    *
    * Cannot be accessed from unprivileged context (not content-accessible)
--- a/editor/libeditor/html/crashtests/crashtests.list
+++ b/editor/libeditor/html/crashtests/crashtests.list
@@ -3,17 +3,17 @@ load 382778-1.html
 load 407074-1.html
 load 407277-1.html
 load 418923-1.html
 load 420439.html
 load 428489-1.html
 load 431086-1.xhtml
 load 448329-1.html
 load 448329-2.html
-asserts(16-20) load 448329-3.html
+asserts(16) load 448329-3.html
 load 456727-1.html
 load 456727-2.html
 asserts(1) load 467647-1.html # bug 382210
 load 503709-1.xhtml
 load 513375-1.xhtml
 load 535632-1.xhtml
 load 574558-1.xhtml
 load 582138-1.xhtml
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -305,20 +305,16 @@ gfxASurface::Finish()
 {
     cairo_surface_finish(mSurface);
 }
 
 already_AddRefed<gfxASurface>
 gfxASurface::CreateSimilarSurface(gfxContentType aContent,
                                   const gfxIntSize& aSize)
 {
-    if (!mSurface || !mSurfaceValid) {
-      return nsnull;
-    }
-    
     cairo_surface_t *surface =
         cairo_surface_create_similar(mSurface, cairo_content_t(aContent),
                                      aSize.width, aSize.height);
     if (cairo_surface_status(surface)) {
         cairo_surface_destroy(surface);
         return nsnull;
     }
 
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -177,20 +177,16 @@ static PRBool GetForce24bppPref()
     prefs->GetBoolPref("mozilla.widget.force-24bpp", &val);
     return val;
 }
 
 already_AddRefed<gfxASurface>
 gfxXlibSurface::CreateSimilarSurface(gfxContentType aContent,
                                      const gfxIntSize& aSize)
 {
-    if (!mSurface || !mSurfaceValid) {
-      return nsnull;
-    }
-
     if (aContent == CONTENT_COLOR) {
         // cairo_surface_create_similar will use a matching visual if it can.
         // However, systems with 16-bit or indexed default visuals may benefit
         // from rendering with 24-bit formats.
         static PRBool force24bpp = GetForce24bppPref();
         if (force24bpp
             && cairo_xlib_surface_get_depth(CairoSurface()) != 24) {
             XRenderPictFormat* format =
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -282,34 +282,19 @@ nsDisplayList::GetBounds(nsDisplayListBu
   nsRect bounds;
   for (nsDisplayItem* i = GetBottom(); i != nsnull; i = i->GetAbove()) {
     bounds.UnionRect(bounds, i->GetBounds(aBuilder));
   }
   return bounds;
 }
 
 PRBool
-nsDisplayList::ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
-                                        nsRegion* aVisibleRegion) {
-  nsRegion r;
-  r.And(*aVisibleRegion, GetBounds(aBuilder));
-  return ComputeVisibilityForSublist(aBuilder, aVisibleRegion, r.GetBounds());
-}
-
-PRBool
-nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
-                                           nsRegion* aVisibleRegion,
-                                           const nsRect& aListVisibleBounds) {
-#ifdef DEBUG
-  nsRegion r;
-  r.And(*aVisibleRegion, GetBounds(aBuilder));
-  NS_ASSERTION(r.GetBounds() == aListVisibleBounds,
-               "bad aListVisibleBounds");
-#endif
-  mVisibleRect = aListVisibleBounds;
+nsDisplayList::ComputeVisibility(nsDisplayListBuilder* aBuilder,
+                                 nsRegion* aVisibleRegion) {
+  mVisibleRect = aVisibleRegion->GetBounds();
   PRBool anyVisible = PR_FALSE;
 
   nsAutoTArray<nsDisplayItem*, 512> elements;
   FlattenTo(&elements);
 
   for (PRInt32 i = elements.Length() - 1; i >= 0; --i) {
     nsDisplayItem* item = elements[i];
     nsDisplayItem* belowItem = i < 1 ? nsnull : elements[i - 1];
@@ -332,17 +317,17 @@ nsDisplayList::ComputeVisibilityForSubli
       if (item->IsOpaque(aBuilder) && f) {
         // Subtract opaque item from the visible region
         aBuilder->SubtractFromVisibleRegion(aVisibleRegion, nsRegion(bounds));
       }
     }
     AppendToBottom(item);
   }
 
-  mIsOpaque = !aVisibleRegion->Intersects(mVisibleRect);
+  mIsOpaque = aVisibleRegion->IsEmpty();
 #ifdef DEBUG
   mDidComputeVisibility = PR_TRUE;
 #endif
   return anyVisible;
 }
 
 void nsDisplayList::PaintRoot(nsDisplayListBuilder* aBuilder,
                               nsIRenderingContext* aCtx,
@@ -1065,23 +1050,24 @@ nsDisplayWrapList::HitTest(nsDisplayList
 nsRect
 nsDisplayWrapList::GetBounds(nsDisplayListBuilder* aBuilder) {
   return mList.GetBounds(aBuilder);
 }
 
 PRBool
 nsDisplayWrapList::ComputeVisibility(nsDisplayListBuilder* aBuilder,
                                      nsRegion* aVisibleRegion) {
-  return mList.ComputeVisibilityForSublist(aBuilder, aVisibleRegion,
-                                           mVisibleRect);
+  return mList.ComputeVisibility(aBuilder, aVisibleRegion);
 }
 
 PRBool
 nsDisplayWrapList::IsOpaque(nsDisplayListBuilder* aBuilder) {
-  return mList.IsOpaque();
+  // We could try to do something but let's conservatively just return PR_FALSE.
+  // We reimplement ComputeVisibility and that's what really matters
+  return PR_FALSE;
 }
 
 PRBool nsDisplayWrapList::IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) {
   // We could try to do something but let's conservatively just return PR_FALSE.
   return PR_FALSE;
 }
 
 PRBool nsDisplayWrapList::IsVaryingRelativeToMovingFrame(nsDisplayListBuilder* aBuilder,
@@ -1393,21 +1379,18 @@ void nsDisplayZoom::Paint(nsDisplayListB
 PRBool nsDisplayZoom::ComputeVisibility(nsDisplayListBuilder *aBuilder,
                                         nsRegion *aVisibleRegion)
 {
   // Convert the passed in visible region to our appunits.
   nsRegion visibleRegion =
     aVisibleRegion->ConvertAppUnitsRoundOut(mParentAPD, mAPD);
   nsRegion originalVisibleRegion = visibleRegion;
 
-  nsRect transformedVisibleRect =
-    mVisibleRect.ConvertAppUnitsRoundOut(mParentAPD, mAPD);
   PRBool retval =
-    mList.ComputeVisibilityForSublist(aBuilder, &visibleRegion,
-                                      transformedVisibleRect);
+    nsDisplayWrapList::ComputeVisibility(aBuilder, &visibleRegion);
 
   nsRegion removed;
   // removed = originalVisibleRegion - visibleRegion
   removed.Sub(originalVisibleRegion, visibleRegion);
   // Convert removed region to parent appunits.
   removed = removed.ConvertAppUnitsRoundIn(mAPD, mParentAPD);
   // aVisibleRegion = aVisibleRegion - removed (modulo any simplifications
   // SubtractFromVisibleRegion does)
@@ -1596,20 +1579,18 @@ nsDisplayTransform::GetLayerState(nsDisp
 PRBool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder,
                                              nsRegion *aVisibleRegion)
 {
   /* As we do this, we need to be sure to
    * untransform the visible rect, since we want everything that's painting to
    * think that it's painting in its original rectangular coordinate space. */
   nsRegion untransformedVisible =
     UntransformRect(mVisibleRect, mFrame, ToReferenceFrame());
-  // Call RecomputeVisiblity instead of ComputeVisibilty since
-  // nsDisplayItem::ComputeVisiblity should only be called from
-  // nsDisplayList::ComputeVisibility (which sets mVisibleRect on the item)
-  mStoredList.RecomputeVisibility(aBuilder, &untransformedVisible);
+
+  mStoredList.ComputeVisibility(aBuilder, &untransformedVisible);
   return PR_TRUE;
 }
 
 #ifdef DEBUG_HIT
 #include <time.h>
 #endif
 
 /* HitTest does some fun stuff with matrix transforms to obtain the answer. */
@@ -1857,19 +1838,17 @@ PRBool nsDisplaySVGEffects::ComputeVisib
   nsRect dirtyRect =
     nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(mEffectsFrame,
                                                            mVisibleRect - offset) +
     offset;
 
   // Our children may be made translucent or arbitrarily deformed so we should
   // not allow them to subtract area from aVisibleRegion.
   nsRegion childrenVisible(dirtyRect);
-  nsRect r;
-  r.IntersectRect(dirtyRect, mList.GetBounds(aBuilder));
-  mList.ComputeVisibilityForSublist(aBuilder, &childrenVisible, r);
+  nsDisplayWrapList::ComputeVisibility(aBuilder, &childrenVisible);
   return PR_TRUE;
 }
 
 PRBool nsDisplaySVGEffects::TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem)
 {
   if (aItem->GetType() != TYPE_SVG_EFFECTS)
     return PR_FALSE;
   // items for the same content element should be merged into a single
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -582,18 +582,16 @@ public:
    * nsDisplayList::ComputeVisibility automatically subtracts the bounds
    * of items that return true from IsOpaque(), and automatically
    * removes items whose bounds do not intersect the visible area,
    * so implementations of nsDisplayItem::ComputeVisibility do not
    * need to do these things.
    * nsDisplayList::ComputeVisibility will already have set mVisibleRect on
    * this item to the intersection of *aVisibleRegion (unioned with
    * *aVisibleRegionBeforeMove, if that's non-null) and this item's bounds.
-   * We rely on that, so this should only be called by
-   * nsDisplayList::ComputeVisibility or nsDisplayItem::RecomputeVisiblity.
    * 
    * @return PR_TRUE if the item is visible, PR_FALSE if no part of the item
    * is visible
    */
   virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
                                    nsRegion* aVisibleRegion)
   { return !mVisibleRect.IsEmpty(); }
 
@@ -839,44 +837,27 @@ public:
 
   /**
    * Compute visiblity for the items in the list.
    * We put this logic here so it can be shared by top-level
    * painting and also display items that maintain child lists.
    * This is also a good place to put ComputeVisibility-related logic
    * that must be applied to every display item. In particular, this
    * sets mVisibleRect on each display item.
-   * This sets mIsOpaque if the entire visible area of this list has
-   * been removed from aVisibleRegion when we return.
+   * This also sets mIsOpaque to whether aVisibleRegion is empty on return.
    * This does not remove any items from the list, so we can recompute
    * visiblity with different regions later (see
    * FrameLayerBuilder::DrawThebesLayer).
    * 
    * @param aVisibleRegion the area that is visible, relative to the
-   * reference frame; on return, this contains the area visible under the list.
-   * I.e., opaque contents of this list are subtracted from aVisibleRegion.
-   * @param aListVisibleBounds must be equal to the bounds of the intersection
-   * of aVisibleRegion and GetBounds() for this list.
+   * reference frame; on return, this contains the area visible under the list
    * @return true if any item in the list is visible
    */
-  PRBool ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
-                                     nsRegion* aVisibleRegion,
-                                     const nsRect& aListVisibleBounds);
-
-  /**
-   * As ComputeVisibility, but computes visibility for a sublist.
-   * aListVisibleBounds is a rectangle that's the bounds of the
-   * intersection of thisitem's GetBounds with aVisibleRegion.
-   *
-   * @param aVisibleRegion the area that is visible; on entry this must
-   * not extend outside the overflow area of the reference frame.
-   */
-  PRBool ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
-                                  nsRegion* aVisibleRegion);
-
+  PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
+                           nsRegion* aVisibleRegion);
   /**
    * Returns true if the visible region output from ComputeVisiblity was
    * empty, i.e. everything visible in this list is opaque.
    */
   PRBool IsOpaque() const {
     NS_ASSERTION(mDidComputeVisibility, "Need to have called ComputeVisibility");
     return mIsOpaque;
   }
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -321,23 +321,16 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIContentViewer interface...
   NS_DECL_NSICONTENTVIEWER
 
   // nsIDocumentViewer interface...
   NS_IMETHOD GetPresShell(nsIPresShell** aResult);
   NS_IMETHOD GetPresContext(nsPresContext** aResult);
-  /**
-   * Find the view to use as the container view for MakeWindow. Returns
-   * null if this will be the root of a view manager hierarchy. In that
-   * case, if mParentWidget is null then this document should not even
-   * be displayed.
-   */
-  virtual nsIView* FindContainerView();
 
   // nsIContentViewerEdit
   NS_DECL_NSICONTENTVIEWEREDIT
 
   // nsIContentViewerFile
   NS_DECL_NSICONTENTVIEWERFILE
 
   // nsIMarkupDocumentViewer
@@ -364,28 +357,37 @@ private:
    * mViewManager and mWindow.
    * @param aSize the initial size in appunits
    * @param aContainerView the container view to hook our root view up
    * to as a child, or null if this will be the root view manager
    */
   nsresult MakeWindow(const nsSize& aSize, nsIView* aContainerView);
 
   /**
+   * Find the view to use as the container view for MakeWindow. Returns
+   * null if this will be the root of a view manager hierarchy. In that
+   * case, if mParentWidget is null then this document should not even
+   * be displayed.
+   */
+  nsIView* FindContainerView();
+
+  /**
    * Create our device context
    */
   nsresult CreateDeviceContext(nsIView* aContainerView);
 
   /**
    * If aDoCreation is true, this creates the device context, creates a
    * prescontext if necessary, and calls MakeWindow.
    */
   nsresult InitInternal(nsIWidget* aParentWidget,
                         nsISupports *aState,
                         const nsIntRect& aBounds,
                         PRBool aDoCreation,
+                        PRBool aInPrintPreview,
                         PRBool aNeedMakeCX = PR_TRUE);
   /**
    * @param aDoInitialReflow set to true if you want to kick off the initial
    * reflow
    */
   nsresult InitPresentationStuff(PRBool aDoInitialReflow);
 
   nsresult GetPopupNode(nsIDOMNode** aNode);
@@ -684,17 +686,17 @@ DocumentViewerImpl::GetContainer(nsISupp
    container.swap(*aResult);
    return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentViewerImpl::Init(nsIWidget* aParentWidget,
                          const nsIntRect& aBounds)
 {
-  return InitInternal(aParentWidget, nsnull, aBounds, PR_TRUE);
+  return InitInternal(aParentWidget, nsnull, aBounds, PR_TRUE, PR_FALSE);
 }
 
 nsresult
 DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
 {
   if (GetIsPrintPreview())
     return NS_OK;
 
@@ -826,16 +828,17 @@ CreatePresContext(nsIDocument* aDocument
 // This method can be used to initial the "presentation"
 // The aDoCreation indicates whether it should create
 // all the new objects or just initialize the existing ones
 nsresult
 DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
                                  nsISupports *aState,
                                  const nsIntRect& aBounds,
                                  PRBool aDoCreation,
+                                 PRBool aInPrintPreview,
                                  PRBool aNeedMakeCX /*= PR_TRUE*/)
 {
   // We don't want any scripts to run here. That can cause flushing,
   // which can cause reentry into initialization of this document viewer,
   // which would be disastrous.
   nsAutoScriptBlocker blockScripts;
 
   mParentWidget = aParentWidget; // not ref counted
@@ -937,28 +940,30 @@ DocumentViewerImpl::InitInternal(nsIWidg
       nsCOMPtr<nsILinkHandler> linkHandler;
       requestor->GetInterface(NS_GET_IID(nsILinkHandler),
                               getter_AddRefs(linkHandler));
 
       mPresContext->SetContainer(requestor);
       mPresContext->SetLinkHandler(linkHandler);
     }
 
-    // Set script-context-owner in the document
-
-    nsCOMPtr<nsPIDOMWindow> window;
-    requestor->GetInterface(NS_GET_IID(nsPIDOMWindow),
-                            getter_AddRefs(window));
-
-    if (window) {
-      nsCOMPtr<nsIDocument> curDoc =
-        do_QueryInterface(window->GetExtantDocument());
-      if (!mIsPageMode || curDoc != mDocument) {
-        window->SetNewDocument(mDocument, aState);
-        nsJSContext::LoadStart();
+    if (!aInPrintPreview) {
+      // Set script-context-owner in the document
+
+      nsCOMPtr<nsPIDOMWindow> window;
+      requestor->GetInterface(NS_GET_IID(nsPIDOMWindow),
+                              getter_AddRefs(window));
+
+      if (window) {
+        nsCOMPtr<nsIDocument> curDoc =
+          do_QueryInterface(window->GetExtantDocument());
+        if (!mIsPageMode || curDoc != mDocument) {
+          window->SetNewDocument(mDocument, aState);
+          nsJSContext::LoadStart();
+        }
       }
     }
   }
 
   if (aDoCreation && mPresContext) {
     // The ViewManager and Root View was created above (in
     // MakeWindow())...
 
@@ -1350,17 +1355,17 @@ AttachContainerRecurse(nsIDocShell* aShe
 NS_IMETHODIMP
 DocumentViewerImpl::Open(nsISupports *aState, nsISHEntry *aSHEntry)
 {
   NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
 
   if (mDocument)
     mDocument->SetContainer(nsCOMPtr<nsISupports>(do_QueryReferent(mContainer)));
 
-  nsresult rv = InitInternal(mParentWidget, aState, mBounds, PR_FALSE);
+  nsresult rv = InitInternal(mParentWidget, aState, mBounds, PR_FALSE, PR_FALSE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mPresShell)
     mPresShell->SetForwardingContainer(nsnull);
 
   // Rehook the child presentations.  The child shells are still in
   // session history, so get them from there.
 
@@ -1874,16 +1879,23 @@ DocumentViewerImpl::SetBounds(const nsIn
   // This may slow down the performance of the new page load, but resize
   // during load is also probably a relatively unusual condition
   // relating to things being hidden while something is loaded.  It so
   // happens that Firefox does this a good bit with its infobar, and it
   // looks ugly if we don't do this.
   if (mPreviousViewer)
     mPreviousViewer->SetBounds(aBounds);
 
+#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
+  if (GetIsPrintPreview() && !mPrintEngine->GetIsCreatingPrintPreview()) {
+    mPrintEngine->GetPrintPreviewWindow()->Resize(aBounds.x, aBounds.y,
+                                                  aBounds.width, aBounds.height,
+                                                  PR_FALSE);
+  }
+#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentViewerImpl::Move(PRInt32 aX, PRInt32 aY)
 {
   NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
   mBounds.MoveTo(aX, aY);
@@ -3640,16 +3652,17 @@ DocumentViewerImpl::Print(nsIPrintSettin
   if (!mPrintEngine) {
     mPrintEngine = new nsPrintEngine();
     NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_OUT_OF_MEMORY);
 
     rv = mPrintEngine->Initialize(this, docShell, mDocument, 
                                   float(mDeviceContext->AppUnitsPerCSSInch()) /
                                   float(mDeviceContext->AppUnitsPerDevPixel()) /
                                   mPageZoom,
+                                  mParentWidget,
 #ifdef NS_DEBUG
                                   mDebugFile
 #else
                                   nsnull
 #endif
                                   );
     if (NS_FAILED(rv)) {
       mPrintEngine->Destroy();
@@ -3689,34 +3702,35 @@ DocumentViewerImpl::PrintPreview(nsIPrin
     nsPrintEngine::CloseProgressDialog(aWebProgressListener);
     nsPrintEngine::ShowPrintErrorDialog(NS_ERROR_GFX_PRINTER_NO_XUL, PR_FALSE);
     return NS_ERROR_FAILURE;
   }
 #endif
 
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
   NS_ASSERTION(docShell, "This has to be a docshell");
-  if (!docShell || !mDeviceContext) {
-    PR_PL(("Can't Print Preview without device context and docshell"));
+  if (!docShell ||! mDeviceContext || !mParentWidget) {
+    PR_PL(("Can't Print Preview without device context, docshell etc"));
     return NS_ERROR_FAILURE;
   }
 
   if (!mPrintEngine) {
     nsCOMPtr<nsIDOMDocument> domDoc;
     aChildDOMWin->GetDocument(getter_AddRefs(domDoc));
     nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
     NS_ENSURE_STATE(doc);
 
     mPrintEngine = new nsPrintEngine();
     NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_OUT_OF_MEMORY);
 
     rv = mPrintEngine->Initialize(this, docShell, doc,
                                   float(mDeviceContext->AppUnitsPerCSSInch()) /
                                   float(mDeviceContext->AppUnitsPerDevPixel()) /
                                   mPageZoom,
+                                  mParentWidget,
 #ifdef NS_DEBUG
                                   mDebugFile
 #else
                                   nsnull
 #endif
                                   );
     if (NS_FAILED(rv)) {
       mPrintEngine->Destroy();
@@ -4264,17 +4278,17 @@ NS_IMETHODIMP DocumentViewerImpl::SetPag
     mPresContext = CreatePresContext(mDocument,
         nsPresContext::eContext_PageLayout, FindContainerView());
     NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
     mPresContext->SetPaginatedScrolling(PR_TRUE);
     mPresContext->SetPrintSettings(aPrintSettings);
     nsresult rv = mPresContext->Init(mDeviceContext);
     NS_ENSURE_SUCCESS(rv, rv);
   }
-  InitInternal(mParentWidget, nsnull, mBounds, PR_TRUE, PR_FALSE);
+  InitInternal(mParentWidget, nsnull, mBounds, PR_TRUE, PR_FALSE, PR_FALSE);
 
   Show();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentViewerImpl::GetHistoryEntry(nsISHEntry **aHistoryEntry)
 {
@@ -4307,21 +4321,22 @@ DocumentViewerImpl::IsInitializedForPrin
 
 void
 DocumentViewerImpl::InitializeForPrintPreview()
 {
   mInitializedForPrintPreview = PR_TRUE;
 }
 
 void
-DocumentViewerImpl::SetPrintPreviewPresentation(nsIViewManager* aViewManager,
+DocumentViewerImpl::SetPrintPreviewPresentation(nsIWidget* aWidget,
+                                                nsIViewManager* aViewManager,
                                                 nsPresContext* aPresContext,
                                                 nsIPresShell* aPresShell)
 {
   if (mPresShell) {
     DestroyPresShell();
   }
 
-  mWindow = nsnull;
+  mWindow = aWidget;
   mViewManager = aViewManager;
   mPresContext = aPresContext;
   mPresShell = aPresShell;
 }
--- a/layout/base/nsIDocumentViewer.h
+++ b/layout/base/nsIDocumentViewer.h
@@ -41,33 +41,29 @@
 #define nsIDocumentViewer_h___
 
 #include "nsIContentViewer.h"
 
 class nsIDocument;
 class nsPresContext;
 class nsIPresShell;
 class nsIStyleSheet;
-class nsIView;
 
 #define NS_IDOCUMENT_VIEWER_IID \
-  { 0x79c0bdbf, 0xf508, 0x4970, \
-    { 0x94, 0x65, 0x03, 0x5e, 0xda, 0x2c, 0x02, 0x72 } }
-
+  { 0xf29e5537, 0x0763, 0x4977, \
+    { 0x83, 0xc2, 0x3c, 0x93, 0x6c, 0x66, 0xa9, 0xfc } }
 /**
  * A document viewer is a kind of content viewer that uses NGLayout
  * to manage the presentation of the content.
  */
 class nsIDocumentViewer : public nsIContentViewer
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_IID)
   
   NS_IMETHOD GetPresShell(nsIPresShell** aResult) = 0;
   
   NS_IMETHOD GetPresContext(nsPresContext** aResult) = 0;
-
-  virtual nsIView* FindContainerView() = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewer, NS_IDOCUMENT_VIEWER_IID)
 
 #endif /* nsIDocumentViewer_h___ */
--- a/layout/base/nsIDocumentViewerPrint.h
+++ b/layout/base/nsIDocumentViewerPrint.h
@@ -85,17 +85,18 @@ public:
   /**
    * Marks this viewer to be used for print preview.
    */
   virtual void InitializeForPrintPreview() = 0;
 
   /**
    * Replaces the current presentation with print preview presentation.
    */
-  virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager,
+  virtual void SetPrintPreviewPresentation(nsIWidget* aWidget,
+                                           nsIViewManager* aViewManager,
                                            nsPresContext* aPresContext,
                                            nsIPresShell* aPresShell) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint,
                               NS_IDOCUMENT_VIEWER_PRINT_IID)
 
 /* Use this macro when declaring classes that implement this interface. */
@@ -105,13 +106,14 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumen
   virtual void     SetIsPrintPreview(PRBool aIsPrintPreview); \
   virtual PRBool   GetIsPrintPreview(); \
   virtual nsresult CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet); \
   virtual void     IncrementDestroyRefCount(); \
   virtual void     ReturnToGalleyPresentation(); \
   virtual void     OnDonePrinting(); \
   virtual PRBool   IsInitializedForPrintPreview(); \
   virtual void     InitializeForPrintPreview(); \
-  virtual void     SetPrintPreviewPresentation(nsIViewManager* aViewManager, \
+  virtual void     SetPrintPreviewPresentation(nsIWidget* aWidget, \
+                                               nsIViewManager* aViewManager, \
                                                nsPresContext* aPresContext, \
                                                nsIPresShell* aPresShell);
 
 #endif /* nsIDocumentViewerPrint_h___ */
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -171,23 +171,23 @@ PrintDisplayListTo(nsDisplayListBuilder*
         rect = c->GetClipRect();
         break;
       }
       default:
         break;
     }
     nscolor color;
     nsRect vis = i->GetVisibleRect();
-    nsDisplayList* list = i->GetList();
     fprintf(aOutput, "%s %p(%s) (%d,%d,%d,%d)(%d,%d,%d,%d)%s%s\n",
             i->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
             rect.x, rect.y, rect.width, rect.height,
             vis.x, vis.y, vis.width, vis.height,
-            ((!list || list->DidComputeVisibility()) && i->IsOpaque(aBuilder)) ? " opaque" : "",
+            i->IsOpaque(aBuilder) ? " opaque" : "",
             i->IsUniform(aBuilder, &color) ? " uniform" : "");
+    nsDisplayList* list = i->GetList();
     if (list) {
       PrintDisplayListTo(aBuilder, *list, aIndent + 4, aOutput);
     }
     if (i->GetType() == nsDisplayItem::TYPE_TRANSFORM) {
       nsDisplayTransform* t = static_cast<nsDisplayTransform*>(i);
       PrintDisplayListTo(aBuilder, *(t->GetStoredList()->GetList()), aIndent + 4, aOutput);
     }
   }
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1372,17 +1372,17 @@ nsLayoutUtils::PaintFrame(nsIRenderingCo
 #ifdef DEBUG
   if (gDumpPaintList) {
     fprintf(stderr, "Painting --- before optimization (dirty %d,%d,%d,%d):\n",
             dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
     nsFrame::PrintDisplayList(&builder, list);
   }
 #endif
 
-  list.ComputeVisibilityForRoot(&builder, &visibleRegion);
+  list.ComputeVisibility(&builder, &visibleRegion);
 
 #ifdef DEBUG
   if (gDumpPaintList) {
     fprintf(stderr, "Painting --- after optimization:\n");
     nsFrame::PrintDisplayList(&builder, list);
   }
 #endif
 
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2531,17 +2531,17 @@ nsRootPresContext::GetPluginGeometryUpda
     if (gDumpPluginList) {
       fprintf(stderr, "Plugins --- before optimization (bounds %d,%d,%d,%d):\n",
           bounds.x, bounds.y, bounds.width, bounds.height);
       nsFrame::PrintDisplayList(&builder, list);
     }
 #endif
 
     nsRegion visibleRegion(bounds);
-    list.ComputeVisibilityForRoot(&builder, &visibleRegion);
+    list.ComputeVisibility(&builder, &visibleRegion);
 
 #ifdef DEBUG
     if (gDumpPluginList) {
       fprintf(stderr, "Plugins --- after optimization:\n");
       nsFrame::PrintDisplayList(&builder, list);
     }
 #endif
 
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5613,17 +5613,17 @@ PresShell::PaintRangePaintInfo(nsTArray<
     RangePaintInfo* rangeInfo = (*aItems)[i];
     // the display lists paint relative to the offset from the reference
     // frame, so translate the rendering context
     nsIRenderingContext::AutoPushTranslation
       translate(rc, rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y);
 
     aArea.MoveBy(-rangeInfo->mRootOffset.x, -rangeInfo->mRootOffset.y);
     nsRegion visible(aArea);
-    rangeInfo->mList.ComputeVisibilityForRoot(&rangeInfo->mBuilder, &visible);
+    rangeInfo->mList.ComputeVisibility(&rangeInfo->mBuilder, &visible);
     rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, rc, nsDisplayList::PAINT_DEFAULT);
     aArea.MoveBy(rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y);
   }
 
   // restore the old selection display state
   frameSelection->SetDisplaySelection(oldDisplaySelection);
 
   NS_ADDREF(surface);
@@ -5771,51 +5771,32 @@ nsresult PresShell::AddCanvasBackgroundC
       }
     }
   }
 
   return aList.AppendNewToBottom(
       new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor));
 }
 
-static PRBool IsTransparentContainerElement(nsPresContext* aPresContext)
-{
-  nsCOMPtr<nsISupports> container = aPresContext->GetContainerInternal();
-  nsCOMPtr<nsIDocShellTreeItem> docShellItem = do_QueryInterface(container);
-  nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(docShellItem));
-  if (!pwin)
-    return PR_FALSE;
-  nsCOMPtr<nsIContent> containerElement =
-    do_QueryInterface(pwin->GetFrameElementInternal());
-  return containerElement &&
-         containerElement->HasAttr(kNameSpaceID_None, nsGkAtoms::transparent);
-}
-
 void PresShell::UpdateCanvasBackground()
 {
   // If we have a frame tree and it has style information that
   // specifies the background color of the canvas, update our local
   // cache of that color.
-  nsIFrame* rootStyleFrame = FrameConstructor()->GetRootElementStyleFrame();
-  if (rootStyleFrame) {
+  nsIFrame* rootFrame = FrameConstructor()->GetRootElementStyleFrame();
+  if (rootFrame) {
     nsStyleContext* bgStyle =
-      nsCSSRendering::FindRootFrameBackground(rootStyleFrame);
+      nsCSSRendering::FindRootFrameBackground(rootFrame);
     // 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) &&
-        !IsTransparentContainerElement(mPresContext)) {
-      mCanvasBackgroundColor =
-        NS_ComposeColors(mPresContext->DefaultBackgroundColor(), mCanvasBackgroundColor);
-    }
+      nsCSSRendering::DetermineBackgroundColor(GetPresContext(), bgStyle,
+                                               rootFrame);
   }
 
   // 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
   // color we actually draw.
   if (!FrameConstructor()->GetRootElementFrame()) {
     mCanvasBackgroundColor = mPresContext->DefaultBackgroundColor();
   }
--- a/layout/base/tests/chrome/Makefile.in
+++ b/layout/base/tests/chrome/Makefile.in
@@ -48,18 +48,16 @@ include $(topsrcdir)/config/rules.mk
 	test_bug396367-2.html \
 	test_bug504311.xul \
 	test_bug514660.xul \
 	test_bug533845.xul \
 	test_bug551434.html \
 	bug551434_childframe.html \
 	test_chrome_content_integration.xul \
 	     chrome_content_integration_window.xul \
-	test_default_background.xul \
-	     default_background_window.xul \
 	test_printpreview.xul \
 	     printpreview_helper.xul \
 	test_printpreview_bug396024.xul \
 	     printpreview_bug396024_helper.xul \
 	test_printpreview_bug482976.xul \
 	     printpreview_bug482976_helper.xul \
     $(NULL)
 
--- a/layout/base/tests/chrome/chrome_content_integration_window.xul
+++ b/layout/base/tests/chrome/chrome_content_integration_window.xul
@@ -20,26 +20,30 @@
 
   <script type="application/javascript">
     <![CDATA[
     var imports = [ "SimpleTest", "is", "isnot", "ok" ];
     for each (var import in imports) {
       window[import] = window.opener.wrappedJSObject[import];
     }
     
+    var HTMLNS = "http://www.w3.org/1999/xhtml";
+
     function runTests() {
       var testCanvas = snapshotWindow(window);
 
       var refCanvas = snapshotWindow(window);
       var ctx = refCanvas.getContext('2d');
       ctx.fillStyle = "black";
       ctx.fillRect(0, 0, refCanvas.width, refCanvas.height);
 
       var comparison = compareSnapshots(testCanvas, refCanvas, true);
       ok(comparison[0], "Rendering OK, got " + comparison[1] + ", expected " + comparison[2]);
+      dump(comparison[1] + "\n");
+      dump(comparison[2] + "\n");
 
       var tester = window.SimpleTest;
       window.close();
       tester.finish();
     }
     ]]>
   </script>
 </window>
deleted file mode 100644
--- a/layout/base/tests/chrome/default_background_window.xul
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
-                 type="text/css"?>
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        onload="runTests()">
-  <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
-
-  <iframe type="content" id="f" src="about:blank" style="border:1px solid black;"/>
-
-  <script type="application/javascript">
-  <![CDATA[
-    SimpleTest.waitForExplicitFinish();
-
-    var imports = [ "SimpleTest", "is", "isnot", "ok" ];
-    for each (var import in imports) {
-      window[import] = window.opener.wrappedJSObject[import];
-    }
-    
-    function snapshot(win) {
-      var el = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
-      el.width = win.innerWidth;
-      el.height = win.innerHeight;
-
-      var ctx = el.getContext("2d");
-      ctx.drawWindow(win, 0, 0,
-                     win.innerWidth, win.innerHeight,
-                     "rgba(0,0,0,0)", 0);
-      return el;
-    }
-
-    var color = '#2468AC';
-    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-        .getService(Components.interfaces.nsIPrefBranch);
-    prefs.setCharPref('browser.display.background_color', color);
-
-    function runTests() {
-      var f = document.getElementById("f");
-
-      var testCanvas = snapshot(f.contentWindow);
-      prefs.clearUserPref('browser.display.background_color');
-
-      var refCanvas = snapshot(f.contentWindow);
-      var ctx = refCanvas.getContext('2d');
-      ctx.fillStyle = color;
-      ctx.fillRect(0, 0, refCanvas.width, refCanvas.height);
-
-      var comparison = compareSnapshots(testCanvas, refCanvas, true);
-      ok(comparison[0], "Rendering OK, got " + comparison[1] + ", expected " + comparison[2]);
-
-      var tester = window.SimpleTest;
-      window.close();
-      tester.finish();
-    }
-  ]]>
-  </script>
-</window>
--- a/layout/base/tests/chrome/test_chrome_content_integration.xul
+++ b/layout/base/tests/chrome/test_chrome_content_integration.xul
@@ -11,15 +11,13 @@
   <!-- test results are displayed in the html:body -->
   <body xmlns="http://www.w3.org/1999/xhtml">
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
     SimpleTest.waitForExplicitFinish();
-    // Run the test in a separate window so that the test runs as a chrome
-    // window
     window.open("chrome_content_integration_window.xul", "chrome_content_integration",
                 "chrome,width=200,height=300");
   ]]>
   </script>
 </window>
deleted file mode 100644
--- a/layout/base/tests/chrome/test_default_background.xul
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
-                 type="text/css"?>
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-
-  <!-- test results are displayed in the html:body -->
-  <body xmlns="http://www.w3.org/1999/xhtml">
-  </body>
-
-  <!-- test code goes here -->
-  <script type="application/javascript">
-  <![CDATA[
-    SimpleTest.waitForExplicitFinish();
-    // Run the test in a separate window so that the test runs as a chrome
-    // window
-    window.open("default_background_window.xul", "default_background",
-                "chrome,width=200,height=300");
-  ]]>
-  </script>
-</window>
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1563,17 +1563,17 @@ InvalidateFixedBackgroundFrames(nsIFrame
   nsDisplayList list;
   nsresult rv =
     aRootFrame->BuildDisplayListForStackingContext(&builder, aUpdateRect, &list);
   builder.LeavePresShell(aRootFrame, aUpdateRect);
   if (NS_FAILED(rv))
     return;
 
   nsRegion visibleRegion(aUpdateRect);
-  list.ComputeVisibilityForRoot(&builder, &visibleRegion);
+  list.ComputeVisibility(&builder, &visibleRegion);
 
   InvalidateFixedBackgroundFramesFromList(&builder, aMovingFrame, list);
   list.DeleteAll();
 }
 
 PRBool nsGfxScrollFrameInner::IsAlwaysActive() const
 {
   // The root scrollframe for a non-chrome document which is the direct
--- a/layout/generic/nsPageContentFrame.cpp
+++ b/layout/generic/nsPageContentFrame.cpp
@@ -144,18 +144,16 @@ nsPageContentFrame::Reflow(nsPresContext
   NS_ASSERTION(NS_FRAME_IS_COMPLETE(fixedStatus), "fixed frames can be truncated, but not incomplete");
 
   // Return our desired size
   aDesiredSize.width = aReflowState.availableWidth;
   if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
     aDesiredSize.height = aReflowState.availableHeight;
   }
 
-  FinishAndStoreOverflow(&aDesiredSize);
-
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
   return NS_OK;
 }
 
 nsIAtom*
 nsPageContentFrame::GetType() const
 {
   return nsGkAtoms::pageContentFrame; 
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -150,17 +150,16 @@ static const char kPrintingPromptService
 #include "nsGUIEvent.h"
 #include "nsHTMLReflowState.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsIDOMHTMLAreaElement.h"
 #include "nsIDOMHTMLLinkElement.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIContentViewerContainer.h"
 #include "nsIContentViewer.h"
-#include "nsIDocumentViewer.h"
 #include "nsIDocumentViewerPrint.h"
 
 #include "nsPIDOMWindow.h"
 #include "nsFocusManager.h"
 #include "nsRange.h"
 #include "nsCDefaultURIFixup.h"
 #include "nsIURIFixup.h"
 #include "mozilla/dom/Element.h"
@@ -261,16 +260,17 @@ nsPrintEngine::nsPrintEngine() :
   mIsDoingPrinting(PR_FALSE),
   mIsDoingPrintPreview(PR_FALSE),
   mProgressDialogIsShown(PR_FALSE),
   mContainer(nsnull),
   mScreenDPI(115.0f),
   mPrt(nsnull),
   mPagePrintTimer(nsnull),
   mPageSeqFrame(nsnull),
+  mParentWidget(nsnull),
   mPrtPreview(nsnull),
   mOldPrtPreview(nsnull),
   mDebugFile(nsnull)
 {
 }
 
 //-------------------------------------------------------
 nsPrintEngine::~nsPrintEngine()
@@ -315,26 +315,28 @@ void nsPrintEngine::DestroyPrintingData(
 //-- Section: Methods needed by the DocViewer
 //---------------------------------------------------------------------------------
 
 //--------------------------------------------------------
 nsresult nsPrintEngine::Initialize(nsIDocumentViewerPrint* aDocViewerPrint, 
                                    nsISupports*            aContainer,
                                    nsIDocument*            aDocument,
                                    float                   aScreenDPI,
+                                   nsIWidget*              aParentWidget,
                                    FILE*                   aDebugFile)
 {
   NS_ENSURE_ARG_POINTER(aDocViewerPrint);
   NS_ENSURE_ARG_POINTER(aContainer);
   NS_ENSURE_ARG_POINTER(aDocument);
 
   mDocViewerPrint = aDocViewerPrint;
   mContainer      = aContainer;      // weak reference
   mDocument       = aDocument;
   mScreenDPI      = aScreenDPI;
+  mParentWidget   = aParentWidget;    
 
   mDebugFile      = aDebugFile;      // ok to be NULL
 
   return NS_OK;
 }
 
 //-------------------------------------------------------
 PRBool
@@ -1877,47 +1879,35 @@ nsPrintEngine::ReflowDocList(nsPrintObje
 nsresult
 nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
 {
   NS_ASSERTION(aPO, "Pointer is null!");
   if (!aPO) return NS_ERROR_FAILURE;
 
   nsSize adjSize;
   PRBool documentIsTopLevel;
+  nsIFrame* frame = nsnull;
   if (!aPO->IsPrintable())
     return NS_OK;
 
-  PRBool canCreateScrollbars = PR_TRUE;
-  nsIView* parentView = nsnull;
-
   if (aPO->mParent && aPO->mParent->IsPrintable()) {
-    nsIFrame* frame = aPO->mContent->GetPrimaryFrame();
+    frame = aPO->mContent->GetPrimaryFrame();
     // Without a frame, this document can't be displayed; therefore, there is no
     // point to reflowing it
     if (!frame) {
       SetPrintPO(aPO, PR_FALSE);
       return NS_OK;
     }
 
     //XXX If printing supported printing document hierarchies with non-constant
     // zoom this would be wrong as we use the same mPrt->mPrintDC for all
     // subdocuments.
     adjSize = frame->GetContentRect().Size();
     documentIsTopLevel = PR_FALSE;
     // presshell exists because parent is printable
-
-    // the top nsPrintObject's widget will always have scrollbars
-    if (frame && frame->GetType() == nsGkAtoms::subDocumentFrame) {
-      nsIView* view = frame->GetView();
-      NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
-      view = view->GetFirstChild();
-      NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
-      parentView = view;
-      canCreateScrollbars = PR_FALSE;
-    }
   } else {
     nscoord pageWidth, pageHeight;
     mPrt->mPrintDC->GetDeviceSurfaceDimensions(pageWidth, pageHeight);
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
     // If we're in landscape mode on Linux, the device surface will have 
     // been rotated, so for the purposes of reflowing content, we'll 
     // treat device's height as our width and its width as our height, 
     PRInt32 orientation;
@@ -1926,27 +1916,41 @@ nsPrintEngine::ReflowPrintObject(nsPrint
       adjSize = nsSize(pageHeight, pageWidth);
     } else {
       adjSize = nsSize(pageWidth, pageHeight);
     }
 #else
     adjSize = nsSize(pageWidth, pageHeight);
 #endif // XP_UNIX && !XP_MACOSX
     documentIsTopLevel = PR_TRUE;
-
-    nsCOMPtr<nsIDocumentViewer> dv = do_QueryInterface(mDocViewerPrint);
-    if (dv) {
-      parentView = dv->FindContainerView();
-    }
+  }
+
+  // Here we decide whether we need scrollbars and
+  // what the parent will be of the widget
+  // How this logic presently works: Print Preview is always as-is (as far
+  // as I can tell; not sure how it would work in other cases); only the root 
+  // is not eIFrame or eFrame.  The child documents get a parent widget from
+  // logic in nsFrameFrame.  In any case, a child widget is created for the root
+  // view of the document.
+  PRBool canCreateScrollbars = PR_TRUE;
+  nsIView* parentView = nsnull;
+  // the top nsPrintObject's widget will always have scrollbars
+  if (frame && frame->GetType() == nsGkAtoms::subDocumentFrame) {
+    nsIView* view = frame->GetView();
+    NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
+    view = view->GetFirstChild();
+    NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
+    parentView = view;
+    canCreateScrollbars = PR_FALSE;
   }
 
   NS_ASSERTION(!aPO->mPresContext, "Recreating prescontext");
 
   // create the PresContext
-  aPO->mPresContext = new nsPresContext(aPO->mDocument,
+  aPO->mPresContext = new nsRootPresContext(aPO->mDocument,
     mIsCreatingPrintPreview ? nsPresContext::eContext_PrintPreview:
                               nsPresContext::eContext_Print);
   NS_ENSURE_TRUE(aPO->mPresContext, NS_ERROR_OUT_OF_MEMORY);
   aPO->mPresContext->SetPrintSettings(mPrt->mPrintSettings);
 
   // set the presentation context to the value in the print settings
   PRBool printBGColors;
   mPrt->mPrintSettings->GetPrintBGColors(&printBGColors);
@@ -1982,17 +1986,31 @@ nsPrintEngine::ReflowPrintObject(nsPrint
   PR_PL(("In DV::ReflowPrintObject PO: %p (%9s) Setting w,h to %d,%d\n", aPO,
          gFrameTypesStr[aPO->mFrameType], adjSize.width, adjSize.height));
 
   // Create a child window of the parent that is our "root view/window"
   nsRect tbounds = nsRect(nsPoint(0, 0), adjSize);
   nsIView* rootView = aPO->mViewManager->CreateView(tbounds, parentView);
   NS_ENSURE_TRUE(rootView, NS_ERROR_OUT_OF_MEMORY);
 
+  // Only create a widget for print preview; when printing, a widget is
+  // unnecessary and unexpected
+  // Also, no widget should be needed except for the top-level document
   if (mIsCreatingPrintPreview && documentIsTopLevel) {
+    nsIWidget* widget = nsnull;
+    if (!frame)
+      widget = mParentWidget;
+    rv = widget ? rootView->CreateWidgetForParent(widget, nsnull,
+                                                  PR_TRUE, PR_TRUE,
+                                                  eContentTypeContent)
+                : rootView->CreateWidget(nsnull,
+                                         PR_TRUE, PR_TRUE,
+                                         eContentTypeContent);
+    NS_ENSURE_SUCCESS(rv, rv);
+    aPO->mWindow = rootView->GetWidget();
     aPO->mPresContext->SetPaginatedScrolling(canCreateScrollbars);
   }
 
   // Setup hierarchical relationship in view manager
   aPO->mViewManager->SetRootView(rootView);
 
   // This docshell stuff is weird; will go away when we stop having multiple
   // presentations per document
@@ -2005,17 +2023,18 @@ nsPrintEngine::ReflowPrintObject(nsPrint
   aPO->mPresContext->SetIsRootPaginatedDocument(documentIsTopLevel);
   aPO->mPresContext->SetPageScale(aPO->mZoomRatio);
   // Calculate scale factor from printer to screen
   float printDPI = float(mPrt->mPrintDC->AppUnitsPerCSSInch()) /
                    float(mPrt->mPrintDC->AppUnitsPerDevPixel());
   aPO->mPresContext->SetPrintPreviewScale(mScreenDPI / printDPI);
 
   if (mIsCreatingPrintPreview && documentIsTopLevel) {
-    mDocViewerPrint->SetPrintPreviewPresentation(aPO->mViewManager,
+    mDocViewerPrint->SetPrintPreviewPresentation(aPO->mWindow,
+                                                 aPO->mViewManager,
                                                  aPO->mPresContext,
                                                  aPO->mPresShell);
   }
 
   rv = aPO->mPresShell->InitialReflow(adjSize.width, adjSize.height);
 
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ASSERTION(aPO->mPresShell, "Presshell should still be here");
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -100,16 +100,17 @@ public:
 
   void Destroy();
   void DestroyPrintingData();
 
   nsresult Initialize(nsIDocumentViewerPrint* aDocViewerPrint, 
                       nsISupports*            aContainer,
                       nsIDocument*            aDocument,
                       float                   aScreenDPI,
+                      nsIWidget*              aParentWidget,
                       FILE*                   aDebugFile);
 
   nsresult GetSeqFrameAndCountPages(nsIFrame*& aSeqFrame, PRInt32& aCount);
 
   //
   // The following three methods are used for printing...
   //
   nsresult DocumentReadyForPrinting();
@@ -189,16 +190,18 @@ public:
   static void ShowPrintErrorDialog(nsresult printerror,
                                    PRBool aIsPrinting = PR_TRUE);
 
   static PRBool HasFramesetChild(nsIContent* aContent);
 
   PRBool   CheckBeforeDestroy();
   nsresult Cancelled();
 
+  nsIWidget* GetPrintPreviewWindow() {return mPrtPreview->mPrintObject->mWindow;}
+
   nsIPresShell* GetPrintPreviewPresShell() {return mPrtPreview->mPrintObject->mPresShell;}
 
   float GetPrintPreviewScale() { return mPrtPreview->mPrintObject->
                                         mPresContext->GetPrintPreviewScale(); }
   
   static nsIPresShell* GetPresShellFor(nsIDocShell* aDocShell);
 
   // These calls also update the DocViewer
@@ -283,16 +286,17 @@ protected:
   nsISupports*            mContainer;      // [WEAK] it owns me!
   float                   mScreenDPI;
   
   nsPrintData*            mPrt;
   nsPagePrintTimer*       mPagePrintTimer;
   nsIPageSequenceFrame*   mPageSeqFrame;
 
   // Print Preview
+  nsCOMPtr<nsIWidget>     mParentWidget;        
   nsPrintData*            mPrtPreview;
   nsPrintData*            mOldPrtPreview;
 
   nsCOMPtr<nsIDocument>   mDocument;
 
   FILE* mDebugFile;
 
 private:
--- a/layout/printing/nsPrintObject.cpp
+++ b/layout/printing/nsPrintObject.cpp
@@ -117,16 +117,17 @@ nsPrintObject::Init(nsIDocShell* aDocShe
   return NS_OK;
 }
 
 //------------------------------------------------------------------
 // Resets PO by destroying the presentation
 void 
 nsPrintObject::DestroyPresentation()
 {
+  mWindow      = nsnull;
   mPresContext = nsnull;
   if (mPresShell) {
     mPresShell->EndObservingDocument();
     nsAutoScriptBlocker scriptBlocker;
     mPresShell->Destroy();
   }
   mPresShell   = nsnull;
   mViewManager = nsnull;
--- a/layout/printing/nsPrintObject.h
+++ b/layout/printing/nsPrintObject.h
@@ -40,16 +40,17 @@
 // Interfaces
 #include "nsCOMPtr.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsStyleSet.h"
 #include "nsIViewManager.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
+#include "nsIWidget.h"
 
 class nsPresContext;
 
 // nsPrintObject Document Type
 enum PrintObjectType  {eDoc = 0, eFrame = 1, eIFrame = 2, eFrameSet = 3};
 
 //---------------------------------------------------
 //-- nsPrintObject Class
@@ -70,16 +71,17 @@ public:
 
   // Data Members
   nsCOMPtr<nsIDocShell>    mDocShell;
   nsCOMPtr<nsIDocument>    mDocument;
 
   nsRefPtr<nsPresContext>  mPresContext;
   nsCOMPtr<nsIPresShell>   mPresShell;
   nsCOMPtr<nsIViewManager> mViewManager;
+  nsCOMPtr<nsIWidget>      mWindow;
 
   nsCOMPtr<nsIContent>     mContent;
   PrintObjectType  mFrameType;
   
   nsTArray<nsPrintObject*> mKids;
   nsPrintObject*   mParent;
   PRPackedBool     mHasBeenPrinted;
   PRPackedBool     mDontPrint;
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -105,18 +105,17 @@ fails == inline-in-xul-basic-01.xul pass
 == markers-and-group-opacity-01.svg markers-and-group-opacity-01-ref.svg
 == marker-attribute-01.svg pass.svg
 == marker-viewBox-01.svg marker-viewBox-01-ref.svg
 == mask-containing-masked-content-01.svg pass.svg
 # Bug 456323
 # == mask-transformed-01.svg mask-transformed-01-ref.svg
 == nested-viewBox-01.svg pass.svg
 == objectBoundingBox-and-clipPath.svg pass.svg
-# Bug 588684
-fails-if(gtk2Widget) == objectBoundingBox-and-fePointLight-01.svg objectBoundingBox-and-fePointLight-01-ref.svg
+== objectBoundingBox-and-fePointLight-01.svg objectBoundingBox-and-fePointLight-01-ref.svg
 == objectBoundingBox-and-mask.svg pass.svg
 == objectBoundingBox-and-pattern-01a.svg objectBoundingBox-and-pattern-01-ref.svg
 == objectBoundingBox-and-pattern-01b.svg objectBoundingBox-and-pattern-01-ref.svg
 == objectBoundingBox-and-pattern-01c.svg objectBoundingBox-and-pattern-01-ref.svg
 == opacity-and-gradient-01.svg pass.svg
 == opacity-and-gradient-02.svg opacity-and-gradient-02-ref.svg
 == opacity-and-pattern-01.svg pass.svg
 == outer-svg-border-and-padding-01.svg outer-svg-border-and-padding-01-ref.svg 
--- a/layout/style/test/Makefile.in
+++ b/layout/style/test/Makefile.in
@@ -141,17 +141,16 @@ GARBAGE += css_properties.js
 		test_css_cross_domain.html \
 		test_css_eof_handling.html \
 		test_descriptor_storage.html \
 		test_descriptor_syntax_errors.html \
 		test_dont_use_document_colors.html \
 		test_font_face_parser.html \
 		test_garbage_at_end_of_declarations.html \
 		test_hover.html \
-		hover_helper.html \
 		test_ident_escaping.html \
 		test_inherit_computation.html \
 		test_inherit_storage.html \
 		test_initial_computation.html \
 		test_initial_storage.html \
 		test_media_queries.html \
 		test_media_queries_dynamic.html \
 		test_media_queries_dynamic_xbl.html \
deleted file mode 100644
--- a/layout/style/test/hover_helper.html
+++ /dev/null
@@ -1,286 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for :hover</title>
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <style type="text/css">
-
-  div#one { height: 10px; width: 10px; }
-  div#one:hover { background: #00f; }
-  div#one > div { height: 5px; width: 20px; }
-  div#one > div:hover { background: #f00; }
-
-  div#twoparent { overflow: hidden; height: 20px; }
-  div#two { width: 10px; height: 10px; }
-  div#two:hover { margin-left: 5px; background: #0f0; }
-  div#two + iframe { width: 50px; height: 10px; }
-  div#two:hover + iframe { width: 100px; }
-
-  </style>
-</head>
-<!-- need a set timeout because we need things to start after painting suppression ends -->
-<body onload="setTimeout(step1, 0)">
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
-<div id="display" style="position: absolute; top: 0; left: 0; width: 300px; height: 300px">
-
-  <div id="one"><div></div></div>
-
-  <div id="twoparent">
-    <div id="two"></div>
-    <iframe id="twoi" src="about:blank"></iframe>
-    <div style="width: 5000px; height: 10px;"></div>
-  </div>
-
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-var imports = [ "SimpleTest", "is", "isnot", "ok" ];
-for each (var import in imports) {
-    window[import] = window.opener[import];
-}
-
-var div = document.getElementById("display");
-var divtwo = document.getElementById("two");
-var iframe = document.getElementById("twoi");
-var divtwoparent = document.getElementById("twoparent");
-
-iframe.contentDocument.open();
-iframe.contentDocument.write("<style type='text/css'>html, body { margin: 0; padding: 0; }<\/style><body>");
-iframe.contentDocument.close();
-
-var moveEvent = { type: "mousemove", clickCount: "0" };
-
-function setResize(str) {
-  iframe.contentDocument.body.setAttribute("onresize",
-                                            "document.body.setAttribute('onresize', 'void(0)');" + 
-                                            "setTimeout('" + str + "', 100)");
-}
-
-function step1() {
-    /** test basic hover **/
-    var divone = document.getElementById("one");
-    synthesizeMouse(divone, 5, 7, moveEvent, window);
-    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
-       ":hover applies");
-    is(getComputedStyle(divone.firstChild, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    synthesizeMouse(divone, 5, 2, moveEvent, window);
-    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
-       ":hover applies hierarchically");
-    is(getComputedStyle(divone.firstChild, "").backgroundColor, "rgb(255, 0, 0)",
-       ":hover applies");
-    synthesizeMouse(divone, 15, 7, moveEvent, window);
-    is(getComputedStyle(divone, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    is(getComputedStyle(divone.firstChild, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    synthesizeMouse(divone, 15, 2, moveEvent, window);
-    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
-       ":hover applies hierarchically");
-    is(getComputedStyle(divone.firstChild, "").backgroundColor, "rgb(255, 0, 0)",
-       ":hover applies");
-
-    /** Test for Bug 302561 **/
-    setResize("parent.step2()");
-    is(iframe.contentDocument.body.offsetWidth, 50,
-       ":hover does not apply (iframe body width)");
-    synthesizeMouse(divtwoparent, 7, 5, moveEvent, window);
-    is(iframe.contentDocument.body.offsetWidth, 100,
-       ":hover applies (iframe body width)");
-}
-
-var step2called = false;
-function step2() {
-    is(step2called, false, "step2 called only once");
-    step2called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
-       ":hover applies");
-    is(iframe.contentDocument.body.offsetWidth, 100,
-       ":hover applies (iframe body width)");
-    setResize("parent.step3()");
-    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
-    is(iframe.contentDocument.body.offsetWidth, 50,
-       ":hover does not apply (iframe body width)");
-}
-
-var step3called = false;
-function step3() {
-    is(step3called, false, "step3 called only once");
-    step3called = true;
-    if (getComputedStyle(iframe, "").width == "100px") {
-        // The two resize events may be coalesced into a single one.
-        step4();
-        return;
-    }
-    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    setResize("parent.step4()");
-    /* expect to get a second resize from the oscillation */
-}
-
-var step4called = false;
-function step4() {
-    is(step4called, false, "step4 called only once (more than two cycles of oscillation)");
-    if (step4called)
-        return;
-    step4called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
-       ":hover applies");
-    setTimeout(step5, 500); // time to detect oscillations if they exist
-}
-
-var step5called = false;
-function step5() {
-    is(step5called, false, "step5 called only once");
-    step5called = true;
-    setResize("parent.step6()");
-    synthesizeMouse(divtwoparent, 25, 5, moveEvent, window);
-}
-
-var step6called = false;
-function step6() {
-    is(step6called, false, "step6 called only once");
-    step6called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    setResize("parent.step7()");
-    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
-}
-
-var step7called = false;
-function step7() {
-    is(step7called, false, "step7 called only once");
-    step7called = true;
-    if (getComputedStyle(iframe, "").width == "50px") {
-        // The two resize events may be coalesced into a single one.
-        step8();
-        return;
-    }
-    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
-       ":hover applies");
-    setResize("parent.step8()");
-    /* expect to get a second resize from the oscillation */
-}
-
-var step8called = false;
-function step8() {
-    is(step8called, false, "step8 called only once (more than two cycles of oscillation)");
-    if (step8called)
-        return;
-    step8called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    setTimeout(step9, 500); // time to detect oscillations if they exist
-}
-
-/* test the same case with scrolltop */
-
-var step9called = false;
-function step9() {
-    is(step9called, false, "step9 called only once");
-    step9called = true;
-    iframe.contentDocument.body.removeAttribute("onresize");
-    /* move the mouse out of the way */
-    synthesizeMouse(divtwoparent, 200, 5, moveEvent, window);
-    divtwoparent.scrollLeft = 5;
-    setResize("parent.step10()");
-    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
-    /* mouse now over 7, 5 */
-}
-
-var step10called = false;
-function step10() {
-    is(step10called, false, "step10 called only once");
-    step10called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
-       ":hover applies");
-    setResize("parent.step11()");
-    divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
-}
-
-var step11called = false;
-function step11() {
-    is(step11called, false, "step11 called only once");
-    step11called = true;
-    if (getComputedStyle(iframe, "").width == "100px") {
-        // The two resize events may be coalesced into a single one.
-        step12();
-        return;
-    }
-    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    setResize("parent.step12()");
-    /* expect to get a second resize from the oscillation */
-}
-
-var step12called = false;
-function step12() {
-    is(step12called, false, "step12 called only once (more than two cycles of oscillation)");
-    if (step12called)
-        return;
-    step12called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
-       ":hover applies");
-    setTimeout(step13, 500); // time to detect oscillations if they exist
-}
-
-var step13called = false;
-function step13() {
-    is(step13called, false, "step13 called only once");
-    step13called = true;
-    setResize("parent.step14()");
-    divtwoparent.scrollLeft = 25; /* mouse now over 27,5 */
-}
-
-var step14called = false;
-function step14() {
-    is(step14called, false, "step14 called only once");
-    step14called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    setResize("parent.step15()");
-    divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
-}
-
-var step15called = false;
-function step15() {
-    is(step15called, false, "step15 called only once");
-    step15called = true;
-    if (getComputedStyle(iframe, "").width == "50px") {
-        // The two resize events may be coalesced into a single one.
-        step16();
-        return;
-    }
-    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
-       ":hover applies");
-    setResize("parent.step16()");
-    /* expect to get a second resize from the oscillation */
-}
-
-var step16called = false;
-function step16() {
-    is(step16called, false, "step16 called only once (more than two cycles of oscillation)");
-    if (step16called)
-        return;
-    step16called = true;
-    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
-       ":hover does not apply");
-    setTimeout(finish, 500); // time to detect oscillations if they exist
-}
-
-function finish() {
-    document.getElementById("display").style.display = "none";
-
-    var tester = window.SimpleTest;
-    window.close();
-    tester.finish();
-}
-
-</script>
-</pre>
-</body>
-</html>
--- a/layout/style/test/test_hover.html
+++ b/layout/style/test/test_hover.html
@@ -1,30 +1,279 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for :hover</title>
   <script type="application/javascript" src="/MochiKit/packed.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <style type="text/css">
+
+  div#one { height: 10px; width: 10px; }
+  div#one:hover { background: #00f; }
+  div#one > div { height: 5px; width: 20px; }
+  div#one > div:hover { background: #f00; }
+
+  div#twoparent { overflow: hidden; height: 20px; }
+  div#two { width: 10px; height: 10px; }
+  div#two:hover { margin-left: 5px; background: #0f0; }
+  div#two + iframe { width: 50px; height: 10px; }
+  div#two:hover + iframe { width: 100px; }
+
+  </style>
 </head>
-<body onload="startTest();">
+<!-- need a set timeout because we need things to start after painting suppression ends -->
+<body onload="setTimeout(step1, 0)">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
-<div id="display">
+<div id="display" style="position: absolute; top: 0; left: 0; width: 300px; height: 300px">
+
+  <div id="one"><div></div></div>
+
+  <div id="twoparent">
+    <div id="two"></div>
+    <iframe id="twoi" src="about:blank"></iframe>
+    <div style="width: 5000px; height: 10px;"></div>
+  </div>
 
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
+var div = document.getElementById("display");
+var divtwo = document.getElementById("two");
+var iframe = document.getElementById("twoi");
+var divtwoparent = document.getElementById("twoparent");
 
-function startTest() {
-  // Run the test in a separate window so that the parent document doesn't have
-  // anything that will cause reflows and dispatch synth mouse moves when we don't
-  // want them and disturb our test.
-  window.open("hover_helper.html", "hover_helper", "width=200,height=300");
+iframe.contentDocument.open();
+iframe.contentDocument.write("<style type='text/css'>html, body { margin: 0; padding: 0; }<\/style><body>");
+iframe.contentDocument.close();
+
+var moveEvent = { type: "mousemove", clickCount: "0" };
+
+function setResize(str) {
+  iframe.contentDocument.body.setAttribute("onresize",
+                                            "document.body.setAttribute('onresize', 'void(0)');" + 
+                                            "setTimeout('" + str + "', 100)");
+}
+
+function step1() {
+    /** test basic hover **/
+    var divone = document.getElementById("one");
+    synthesizeMouse(divone, 5, 7, moveEvent, window);
+    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
+       ":hover applies");
+    is(getComputedStyle(divone.firstChild, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    synthesizeMouse(divone, 5, 2, moveEvent, window);
+    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
+       ":hover applies hierarchically");
+    is(getComputedStyle(divone.firstChild, "").backgroundColor, "rgb(255, 0, 0)",
+       ":hover applies");
+    synthesizeMouse(divone, 15, 7, moveEvent, window);
+    is(getComputedStyle(divone, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    is(getComputedStyle(divone.firstChild, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    synthesizeMouse(divone, 15, 2, moveEvent, window);
+    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
+       ":hover applies hierarchically");
+    is(getComputedStyle(divone.firstChild, "").backgroundColor, "rgb(255, 0, 0)",
+       ":hover applies");
+
+    /** Test for Bug 302561 **/
+    setResize("parent.step2()");
+    is(iframe.contentDocument.body.offsetWidth, 50,
+       ":hover does not apply (iframe body width)");
+    synthesizeMouse(divtwoparent, 7, 5, moveEvent, window);
+    is(iframe.contentDocument.body.offsetWidth, 100,
+       ":hover applies (iframe body width)");
+}
+
+var step2called = false;
+function step2() {
+    is(step2called, false, "step2 called only once");
+    step2called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
+       ":hover applies");
+    is(iframe.contentDocument.body.offsetWidth, 100,
+       ":hover applies (iframe body width)");
+    setResize("parent.step3()");
+    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
+    is(iframe.contentDocument.body.offsetWidth, 50,
+       ":hover does not apply (iframe body width)");
+}
+
+var step3called = false;
+function step3() {
+    is(step3called, false, "step3 called only once");
+    step3called = true;
+    if (getComputedStyle(iframe, "").width == "100px") {
+        // The two resize events may be coalesced into a single one.
+        step4();
+        return;
+    }
+    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    setResize("parent.step4()");
+    /* expect to get a second resize from the oscillation */
+}
+
+var step4called = false;
+function step4() {
+    is(step4called, false, "step4 called only once (more than two cycles of oscillation)");
+    if (step4called)
+        return;
+    step4called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
+       ":hover applies");
+    setTimeout(step5, 500); // time to detect oscillations if they exist
+}
+
+var step5called = false;
+function step5() {
+    is(step5called, false, "step5 called only once");
+    step5called = true;
+    setResize("parent.step6()");
+    synthesizeMouse(divtwoparent, 25, 5, moveEvent, window);
+}
+
+var step6called = false;
+function step6() {
+    is(step6called, false, "step6 called only once");
+    step6called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    setResize("parent.step7()");
+    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
+}
+
+var step7called = false;
+function step7() {
+    is(step7called, false, "step7 called only once");
+    step7called = true;
+    if (getComputedStyle(iframe, "").width == "50px") {
+        // The two resize events may be coalesced into a single one.
+        step8();
+        return;
+    }
+    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
+       ":hover applies");
+    setResize("parent.step8()");
+    /* expect to get a second resize from the oscillation */
+}
+
+var step8called = false;
+function step8() {
+    is(step8called, false, "step8 called only once (more than two cycles of oscillation)");
+    if (step8called)
+        return;
+    step8called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    setTimeout(step9, 500); // time to detect oscillations if they exist
+}
+
+/* test the same case with scrolltop */
+
+var step9called = false;
+function step9() {
+    is(step9called, false, "step9 called only once");
+    step9called = true;
+    iframe.contentDocument.body.removeAttribute("onresize");
+    /* move the mouse out of the way */
+    synthesizeMouse(divtwoparent, 200, 5, moveEvent, window);
+    divtwoparent.scrollLeft = 5;
+    setResize("parent.step10()");
+    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
+    /* mouse now over 7, 5 */
+}
+
+var step10called = false;
+function step10() {
+    is(step10called, false, "step10 called only once");
+    step10called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
+       ":hover applies");
+    setResize("parent.step11()");
+    divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
+}
+
+var step11called = false;
+function step11() {
+    is(step11called, false, "step11 called only once");
+    step11called = true;
+    if (getComputedStyle(iframe, "").width == "100px") {
+        // The two resize events may be coalesced into a single one.
+        step12();
+        return;
+    }
+    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    setResize("parent.step12()");
+    /* expect to get a second resize from the oscillation */
+}
+
+var step12called = false;
+function step12() {
+    is(step12called, false, "step12 called only once (more than two cycles of oscillation)");
+    if (step12called)
+        return;
+    step12called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
+       ":hover applies");
+    setTimeout(step13, 500); // time to detect oscillations if they exist
+}
+
+var step13called = false;
+function step13() {
+    is(step13called, false, "step13 called only once");
+    step13called = true;
+    setResize("parent.step14()");
+    divtwoparent.scrollLeft = 25; /* mouse now over 27,5 */
+}
+
+var step14called = false;
+function step14() {
+    is(step14called, false, "step14 called only once");
+    step14called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    setResize("parent.step15()");
+    divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
+}
+
+var step15called = false;
+function step15() {
+    is(step15called, false, "step15 called only once");
+    step15called = true;
+    if (getComputedStyle(iframe, "").width == "50px") {
+        // The two resize events may be coalesced into a single one.
+        step16();
+        return;
+    }
+    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
+       ":hover applies");
+    setResize("parent.step16()");
+    /* expect to get a second resize from the oscillation */
+}
+
+var step16called = false;
+function step16() {
+    is(step16called, false, "step16 called only once (more than two cycles of oscillation)");
+    if (step16called)
+        return;
+    step16called = true;
+    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
+       ":hover does not apply");
+    setTimeout(finish, 500); // time to detect oscillations if they exist
+}
+
+function finish() {
+    document.getElementById("display").style.display = "none";
+    SimpleTest.finish();
 }
 
 </script>
 </pre>
 </body>
 </html>
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -1302,64 +1302,37 @@ PaintXULDebugBackground(nsIFrame* aFrame
 }
 #endif
 
 nsresult
 nsBoxFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                              const nsRect&           aDirtyRect,
                              const nsDisplayListSet& aLists)
 {
-  // forcelayer is only supported on XUL elements with box layout
-  PRBool forceLayer =
-    GetContent()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer) &&
-    GetContent()->IsXUL();
-
-  nsDisplayListCollection tempLists;
-  const nsDisplayListSet& destination = forceLayer ? tempLists : aLists;
-
-  nsresult rv = DisplayBorderBackgroundOutline(aBuilder, destination);
+  nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
   NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef DEBUG_LAYOUT
+  // REVIEW: From GetFrameForPoint
   if (mState & NS_STATE_CURRENTLY_IN_DEBUG) {
-    rv = destination.BorderBackground()->AppendNewToTop(new (aBuilder)
+    rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
         nsDisplayGeneric(aBuilder, this, PaintXULDebugBackground,
                          "XULDebugBackground"));
     NS_ENSURE_SUCCESS(rv, rv);
-    rv = destination.Outlines()->AppendNewToTop(new (aBuilder)
+    rv = aLists.Outlines()->AppendNewToTop(new (aBuilder)
         nsDisplayXULDebug(aBuilder, this));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 #endif
 
-  rv = BuildDisplayListForChildren(aBuilder, aDirtyRect, destination);
+  rv = BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // see if we have to draw a selection frame around this container
-  rv = DisplaySelectionOverlay(aBuilder, destination);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (forceLayer) {
-    // This is a bit of a hack. Collect up all descendant display items
-    // and merge them into a single Content() list. This can cause us
-    // to violate CSS stacking order, but forceLayer is a magic
-    // XUL-only extension anyway.
-    nsDisplayList masterList;
-    masterList.AppendToTop(tempLists.BorderBackground());
-    masterList.AppendToTop(tempLists.BlockBorderBackgrounds());
-    masterList.AppendToTop(tempLists.Floats());
-    masterList.AppendToTop(tempLists.Content());
-    masterList.AppendToTop(tempLists.PositionedDescendants());
-    masterList.AppendToTop(tempLists.Outlines());
-    // Wrap the list to make it its own layer
-    rv = aLists.Content()->AppendNewToTop(new (aBuilder)
-        nsDisplayOwnLayer(aBuilder, this, &masterList));
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-  return NS_OK;
+  return DisplaySelectionOverlay(aBuilder, aLists);
 }
 
 NS_IMETHODIMP
 nsBoxFrame::BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                         const nsRect&           aDirtyRect,
                                         const nsDisplayListSet& aLists)
 {
   nsIFrame* kid = mFrames.FirstChild();
--- a/toolkit/content/tests/widgets/test_tree_view.xul
+++ b/toolkit/content/tests/widgets/test_tree_view.xul
@@ -20,58 +20,52 @@ var treeData = [["Mary", "206 Garden Ave
                 ["Sarah", "702 Fern Avenue"],
                 ["John", "99 Westminster Avenue"]];
                 
 // This is our custom view, based on the treeview interface
 var view =
 {
   value: "",
   rowCount: 8,
-  getCellText: function(row, column) { return ((typeof treeData) != "undefined") ? treeData[row % 4][column.index] : ""; },
+  getCellText: function(row, column) { return treeData[row % 4][column.index]; },
   getCellValue: function(row, column) { return this.value; },
-  setCellText: function(row, column, val) { if ((typeof treeData) != "undefined") treeData[row % 4][column.index] = val; },
+  setCellText: function(row, column, val) { treeData[row % 4][column.index] = val; },
   setCellValue: function(row, column, val) { this.value = val; },
   setTree: function(tree) { this.tree = tree; },
   isContainer: function(row) { return false; },
   isContainerOpen: function(row) { return false; },
   isContainerEmpty: function(row) { return false; },
   isSeparator: function(row) { return false; },
   isSorted: function(row) { return false; },
   isSelectable: function(row, column) { return true; },
   isEditable: function(row, column) { return row != 2 || column.index != 1; },
-  getProgressMode: function(row, column) { return ((typeof Components) != "undefined") ? Components.interfaces.nsITreeView.PROGRESS_NORMAL : null; },
+  getProgressMode: function(row, column) { return Components.interfaces.nsITreeView.PROGRESS_NORMAL; },
   getParentIndex: function(row, column) { return -1; },
   getLevel: function(row) { return 0; },
   hasNextSibling: function(row, column) { return row != this.rowCount - 1; },
   getImageSrc: function(row, column) { return ""; },
   cycleHeader: function(column) { },
   getRowProperties: function(row, props) { },
   getCellProperties: function(row, column, props) { },
   getColumnProperties: function(column, props)
   {
-    if ((typeof netscape) == "undefined")
-      return;
-
     if (!column.index) {
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       var atomService = Components.classes["@mozilla.org/atom-service;1"].
                           getService(Components.interfaces.nsIAtomService);
       props.AppendElement(atomService.getAtom("one"));
       props.AppendElement(atomService.getAtom("two"));
     }
   }
 }
 
 function getCustomTreeViewCellInfo()
 {
   var obj = { rows: [] };
 
-  if ((typeof view) == "undefined" || (typeof treeData) == "undefined")
-    return;
-
   for (var row = 0; row < view.rowCount; row++) {
     var cellInfo = [ ];
     for (var column = 0; column < 1; column++) {
       cellInfo.push({ label: "" + treeData[row % 4][column],
                       value: "",
                       properties: "",
                       editable: row != 2 || column.index != 1,
                       selectable: true,
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -2526,17 +2526,15 @@ nsNativeThemeCocoa::GetWidgetTransparenc
 {
   switch (aWidgetType) {
   case NS_THEME_MENUPOPUP:
   case NS_THEME_TOOLTIP:
     return eTransparent;
 
   case NS_THEME_SCROLLBAR_SMALL:
   case NS_THEME_SCROLLBAR:
-  case NS_THEME_STATUSBAR:
-    // Knowing that scrollbars and statusbars are opaque improves
-    // performance, because we create layers for them.
+    // Scrollbars are drawn opaque. Knowing this improves performance.
     return eOpaque;
 
   default:
     return eUnknownTransparency;
   }
 }
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -2043,27 +2043,16 @@ PRBool
 nsNativeThemeWin::ThemeNeedsComboboxDropmarker()
 {
   return PR_TRUE;
 }
 
 nsITheme::Transparency
 nsNativeThemeWin::GetWidgetTransparency(nsIFrame* aFrame, PRUint8 aWidgetType)
 {
-  switch (aWidgetType) {
-  case NS_THEME_SCROLLBAR_SMALL:
-  case NS_THEME_SCROLLBAR:
-  case NS_THEME_STATUSBAR:
-    // Knowing that scrollbars and statusbars are opaque improves
-    // performance, because we create layers for them. This better be
-    // true across all Windows themes! If it's not true, we should
-    // paint an opaque background for them to make it true!
-    return eOpaque;
-  }
-
   HANDLE theme = GetTheme(aWidgetType);
   // For the classic theme we don't really have a way of knowing
   if (!theme)
     return eUnknownTransparency;
 
   PRInt32 part, state;
   nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
   // Fail conservatively
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -5216,20 +5216,22 @@ PRBool nsWindow::ProcessMessage(UINT msg
 
   case WM_GESTURE:
     result = OnGesture(wParam, lParam);
     break;
 
   case WM_GESTURENOTIFY:
     {
       if (mWindowType != eWindowType_invisible &&
-          mWindowType != eWindowType_plugin) {
-        // A GestureNotify event is dispatched to decide which single-finger panning
-        // direction should be active (including none) and if pan feedback should
-        // be displayed. Java and plugin windows can make their own calls.
+          mWindowType != eWindowType_plugin &&
+          mWindowType != eWindowType_toplevel) {
+        // eWindowType_toplevel is the top level main frame window. Gesture support
+        // there prevents the user from interacting with the title bar or nc
+        // areas using a single finger. Java and plugin windows can make their
+        // own calls.
         GESTURENOTIFYSTRUCT * gestureinfo = (GESTURENOTIFYSTRUCT*)lParam;
         nsPointWin touchPoint;
         touchPoint = gestureinfo->ptsLocation;
         touchPoint.ScreenToClient(mWnd);
         nsGestureNotifyEvent gestureNotifyEvent(PR_TRUE, NS_GESTURENOTIFY_EVENT_START, this);
         gestureNotifyEvent.refPoint = touchPoint;
         nsEventStatus status;
         DispatchEvent(&gestureNotifyEvent, status);