Reuse ConstructScrollableBlock to build scrollable DetailsFrame.

Final part to resolve #1497.
This commit is contained in:
Pale Moon
2017-11-25 14:30:05 +01:00
committed by Roy Tam
parent 6cb76ffcc1
commit 2e9c10e234
2 changed files with 32 additions and 33 deletions
+20 -33
View File
@@ -3314,36 +3314,10 @@ nsCSSFrameConstructor::ConstructDetailsFrame(nsFrameConstructorState& aState,
NS_NewDetailsFrame);
}
nsIContent* const content = aItem.mContent;
nsStyleContext* const styleContext = aItem.mStyleContext;
nsContainerFrame* geometricParent =
aState.GetGeometricParent(aStyleDisplay, aParentFrame);
nsContainerFrame* detailsFrame = NS_NewDetailsFrame(mPresShell, styleContext);
// Build a scroll frame to wrap details frame if necessary.
nsContainerFrame* scrollFrame = nullptr;
RefPtr<nsStyleContext> detailsStyle =
BeginBuildingScrollFrame(aState, content, styleContext, geometricParent ,
nsCSSAnonBoxes::scrolledContent, false,
scrollFrame);
aState.AddChild(scrollFrame, aFrameItems, content, styleContext,
aParentFrame);
nsFrameItems scrollFrameItems;
ConstructBlock(aState, aStyleDisplay, content, scrollFrame, scrollFrame,
detailsStyle, &detailsFrame, scrollFrameItems,
aStyleDisplay->IsPositioned(scrollFrame) ?
scrollFrame : nullptr,
aItem.mPendingBinding);
MOZ_ASSERT(scrollFrameItems.OnlyChild() == detailsFrame);
FinishBuildingScrollFrame(scrollFrame, detailsFrame);
return scrollFrame;
return ConstructScrollableBlockWithConstructor(aState, aItem, aParentFrame,
aStyleDisplay, aFrameItems,
NS_NewDetailsFrame);
}
static nsIFrame*
@@ -4737,6 +4711,20 @@ nsCSSFrameConstructor::ConstructScrollableBlock(nsFrameConstructorState& aState,
nsContainerFrame* aParentFrame,
const nsStyleDisplay* aDisplay,
nsFrameItems& aFrameItems)
{
return ConstructScrollableBlockWithConstructor(aState, aItem, aParentFrame,
aDisplay, aFrameItems,
NS_NewBlockFormattingContext);
}
nsIFrame*
nsCSSFrameConstructor::ConstructScrollableBlockWithConstructor(
nsFrameConstructorState& aState,
FrameConstructionItem& aItem,
nsContainerFrame* aParentFrame,
const nsStyleDisplay* aDisplay,
nsFrameItems& aFrameItems,
BlockFrameCreationFunc aConstructor)
{
nsIContent* const content = aItem.mContent;
nsStyleContext* const styleContext = aItem.mStyleContext;
@@ -4750,8 +4738,7 @@ nsCSSFrameConstructor::ConstructScrollableBlock(nsFrameConstructorState& aState,
// Create our block frame
// pass a temporary stylecontext, the correct one will be set later
nsContainerFrame* scrolledFrame =
NS_NewBlockFormattingContext(mPresShell, styleContext);
nsContainerFrame* scrolledFrame = aConstructor(mPresShell, styleContext);
// Make sure to AddChild before we call ConstructBlock so that we
// end up before our descendants in fixed-pos lists as needed.
@@ -4764,8 +4751,8 @@ nsCSSFrameConstructor::ConstructScrollableBlock(nsFrameConstructorState& aState,
aDisplay->IsPositioned(newFrame) ? newFrame : nullptr,
aItem.mPendingBinding);
NS_ASSERTION(blockItem.FirstChild() == scrolledFrame,
"Scrollframe's frameItems should be exactly the scrolled frame");
MOZ_ASSERT(blockItem.OnlyChild() == scrolledFrame,
"Scrollframe's frameItems should be exactly the scrolled frame!");
FinishBuildingScrollFrame(newFrame, scrolledFrame);
return newFrame;