diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 696ee4fc71b4..aa5f1857916c 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2688,6 +2688,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIFrame** aNewFrame) nsContainerFrame::SyncFrameViewProperties(mPresShell->GetPresContext(), viewportFrame, viewportPseudoStyle, rootView); + nsContainerFrame::SyncWindowProperties(mPresShell->GetPresContext(), viewportFrame, + rootView); // The viewport is the containing block for 'fixed' elements mFixedContainingBlock = viewportFrame; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 097477ae882d..3f40e8a97bb9 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -7190,6 +7190,8 @@ PresShell::DoReflow(nsIFrame* target, PRBool aInterruptible) nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, target, target->GetView(), &desiredSize.mOverflowArea); + nsContainerFrame::SyncWindowProperties(mPresContext, target, + target->GetView()); target->DidReflow(mPresContext, nsnull, NS_FRAME_REFLOW_FINISHED); if (target == rootFrame && size.height == NS_UNCONSTRAINEDSIZE) { diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index f4f58f27cf87..e281b52bd31e 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -471,38 +471,41 @@ IsMenuPopup(nsIFrame *aFrame) return (frameType == nsGkAtoms::menuPopupFrame); } -static PRBool -IsTopLevelWidget(nsPresContext* aPresContext) +static nsIWidget* +GetPresContextContainerWidget(nsPresContext* aPresContext) { nsCOMPtr container = aPresContext->Document()->GetContainer(); nsCOMPtr baseWindow = do_QueryInterface(container); if (!baseWindow) - return PR_FALSE; + return nsnull; nsCOMPtr mainWidget; baseWindow->GetMainWidget(getter_AddRefs(mainWidget)); - if (!mainWidget) - return PR_FALSE; + return mainWidget; +} +static PRBool +IsTopLevelWidget(nsIWidget* aWidget) +{ nsWindowType windowType; - mainWidget->GetWindowType(windowType); + aWidget->GetWindowType(windowType); return windowType == eWindowType_toplevel || - windowType == eWindowType_dialog; + windowType == eWindowType_dialog || + windowType == eWindowType_sheet; // popups aren't toplevel so they're not handled here } -static void -SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext, - nsIFrame* aFrame, - nsStyleContext* aStyleContext, - nsIView* aView, - PRUint32 aFlags) +void +nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, + nsIFrame* aFrame, + nsIView* aView) { #ifdef MOZ_XUL - if (!nsCSSRendering::IsCanvasFrame(aFrame)) + if (!aView || !nsCSSRendering::IsCanvasFrame(aFrame) || !aView->HasWidget()) return; - if (!aView->HasWidget() || !IsTopLevelWidget(aPresContext)) + nsIWidget* windowWidget = GetPresContextContainerWidget(aPresContext); + if (!windowWidget || !IsTopLevelWidget(windowWidget)) return; nsIViewManager* vm = aView->GetViewManager(); @@ -532,21 +535,21 @@ SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext, return; } + nsIFrame *rootFrame = aPresContext->PresShell()->FrameConstructor()->GetRootElementStyleFrame(); + if (!rootFrame) + return; + + nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame); // The issue here is that the CSS 'background' propagates from the root // element's frame (rootFrame) to the real root frame (nsViewportFrame), // so we need to call GetFrameTransparency on that. But -moz-appearance // does not propagate so we need to check that directly on rootFrame. - nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame); - nsIFrame *rootFrame = aPresContext->PresShell()->FrameConstructor()->GetRootElementStyleFrame(); - if (rootFrame && - NS_THEME_WIN_GLASS == rootFrame->GetStyleDisplay()->mAppearance) { + if (NS_THEME_WIN_GLASS == rootFrame->GetStyleDisplay()->mAppearance) { mode = eTransparencyGlass; } - nsIWidget* widget = aView->GetWidget(); - widget->SetTransparencyMode(mode); - if (rootFrame) { - widget->SetWindowShadowStyle(rootFrame->GetStyleUIReset()->mWindowShadow); - } + nsIWidget* viewWidget = aView->GetWidget(); + viewWidget->SetTransparencyMode(mode); + windowWidget->SetWindowShadowStyle(rootFrame->GetStyleUIReset()->mWindowShadow); #endif } @@ -572,15 +575,6 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext, nsIViewManager* vm = aView->GetViewManager(); vm->ResizeView(aView, *aCombinedArea, PR_TRUE); - - // Even if the size hasn't changed, we need to sync up the - // geometry dependent properties, because overflow areas of - // children might have changed, and we can't - // detect whether it has or not. Likewise, whether the view size - // has changed or not, we may need to change the transparency - // state even if there is no clip. - nsStyleContext* savedStyleContext = aFrame->GetStyleContext(); - SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, savedStyleContext, aView, aFlags); } } @@ -664,8 +658,6 @@ nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext, } vm->SetViewZIndex(aView, autoZIndex, zIndex, isPositioned); - - SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags); } PRBool diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h index 5ade699c0da3..05f4a2372d81 100644 --- a/layout/generic/nsContainerFrame.h +++ b/layout/generic/nsContainerFrame.h @@ -126,11 +126,15 @@ public: nsIView* aView, const nsRect* aCombinedArea, PRUint32 aFlags = 0); - + + // Syncs properties to the top level view and window, like transparency and + // shadow. + static void SyncWindowProperties(nsPresContext* aPresContext, + nsIFrame* aFrame, + nsIView* aView); + // Sets the view's attributes from the frame style. - // - opacity // - visibility - // - content transparency // - clip // Call this when one of these styles changes or when the view has just // been created.