Bug 1064843 part 10 - Create and render backdrop frame for top layer frames. r=dbaron

This commit is contained in:
Xidorn Quan
2016-01-28 10:11:00 +11:00
parent fba483483d
commit 56b9331e0f
5 changed files with 73 additions and 1 deletions

View File

@@ -88,6 +88,7 @@
#include "nsSimplePageSequenceFrame.h"
#include "nsTableOuterFrame.h"
#include "nsIScrollableFrame.h"
#include "nsBackdropFrame.h"
#include "nsTransitionManager.h"
#ifdef MOZ_XUL
@@ -1214,6 +1215,15 @@ nsFrameConstructorState::AddChild(nsIFrame* aNewFrame,
placeholderFrame->AddStateBits(mAdditionalStateBits);
// Add the placeholder frame to the flow
aFrameItems.AddChild(placeholderFrame);
if (placeholderType == PLACEHOLDER_FOR_TOPLAYER) {
nsIFrame* backdropFrame = nsCSSFrameConstructor::
CreateBackdropFrameFor(mPresShell, aContent, aNewFrame,
outOfFlowFrameItems->containingBlock);
if (backdropFrame) {
frameItems->AddChild(backdropFrame);
}
}
}
#ifdef DEBUG
else {
@@ -2932,6 +2942,38 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
return placeholderFrame;
}
/* static */ nsIFrame*
nsCSSFrameConstructor::CreateBackdropFrameFor(nsIPresShell* aPresShell,
nsIContent* aContent,
nsIFrame* aFrame,
nsContainerFrame* aParentFrame)
{
MOZ_ASSERT(aFrame->StyleDisplay()->mTopLayer == NS_STYLE_TOP_LAYER_TOP);
nsContainerFrame* frame = do_QueryFrame(aFrame);
if (!frame) {
NS_WARNING("Cannot create backdrop frame for non-container frame");
return nullptr;
}
RefPtr<nsStyleContext> style = aPresShell->StyleSet()->
ResolvePseudoElementStyle(aContent->AsElement(),
nsCSSPseudoElements::ePseudo_backdrop,
/* aParentStyleContext */ nullptr,
/* aPseudoElement */ nullptr);
nsBackdropFrame* backdropFrame = new (aPresShell) nsBackdropFrame(style);
backdropFrame->Init(aContent, aParentFrame, nullptr);
nsIFrame* placeholder = CreatePlaceholderFrameFor(aPresShell, aContent,
backdropFrame,
frame->StyleContext(),
frame, nullptr,
PLACEHOLDER_FOR_TOPLAYER);
nsFrameList temp(placeholder, placeholder);
frame->SetInitialChildList(nsIFrame::kBackdropList, temp);
return backdropFrame;
}
// Clears any lazy bits set in the range [aStartContent, aEndContent). If
// aEndContent is null, that means to clear bits in all siblings starting with
// aStartContent. aStartContent must not be null unless aEndContent is also