mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 509876 - Clean up SyncFrameViewGeometryDependentProperties. r=roc
--HG-- extra : rebase_source : fdf898d51147231f33df507d28d927924dc465b8
This commit is contained in:
parent
90370ecda5
commit
df51e1d007
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -471,38 +471,41 @@ IsMenuPopup(nsIFrame *aFrame)
|
||||
return (frameType == nsGkAtoms::menuPopupFrame);
|
||||
}
|
||||
|
||||
static PRBool
|
||||
IsTopLevelWidget(nsPresContext* aPresContext)
|
||||
static nsIWidget*
|
||||
GetPresContextContainerWidget(nsPresContext* aPresContext)
|
||||
{
|
||||
nsCOMPtr<nsISupports> container = aPresContext->Document()->GetContainer();
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
|
||||
if (!baseWindow)
|
||||
return PR_FALSE;
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIWidget> 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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user