--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3363,46 +3363,20 @@ nsCSSFrameConstructor::ConstructDetailsF
nsFrameItems& aFrameItems)
{
if (!aStyleDisplay->IsScrollableOverflow()) {
return ConstructNonScrollableBlockWithConstructor(aState, aItem, aParentFrame,
aStyleDisplay, aFrameItems,
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, content, scrollFrame, scrollFrame,
- detailsStyle, &detailsFrame, scrollFrameItems,
- aStyleDisplay->IsAbsPosContainingBlock(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*
FindAncestorWithGeneratedContentPseudo(nsIFrame* aFrame)
{
for (nsIFrame* f = aFrame->GetParent(); f; f = f->GetParent()) {
NS_ASSERTION(f->IsGeneratedContentFrame(),
"should not have exited generated content");
@@ -4834,43 +4808,56 @@ nsCSSFrameConstructor::FindDisplayData(c
nsIFrame*
nsCSSFrameConstructor::ConstructScrollableBlock(nsFrameConstructorState& aState,
FrameConstructionItem& aItem,
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;
nsContainerFrame* newFrame = nullptr;
RefPtr<nsStyleContext> scrolledContentStyle
= BeginBuildingScrollFrame(aState, content, styleContext,
aState.GetGeometricParent(aDisplay, aParentFrame),
nsCSSAnonBoxes::scrolledContent,
false, newFrame);
// 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.
aState.AddChild(newFrame, aFrameItems, content, styleContext, aParentFrame);
nsFrameItems blockItem;
ConstructBlock(aState, content, newFrame, newFrame, scrolledContentStyle,
&scrolledFrame, blockItem,
aDisplay->IsAbsPosContainingBlock(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;
}
nsIFrame*
nsCSSFrameConstructor::ConstructNonScrollableBlock(nsFrameConstructorState& aState,
FrameConstructionItem& aItem,
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -1553,16 +1553,28 @@ private:
*/
nsIFrame* ConstructScrollableBlock(nsFrameConstructorState& aState,
FrameConstructionItem& aItem,
nsContainerFrame* aParentFrame,
const nsStyleDisplay* aDisplay,
nsFrameItems& aFrameItems);
/**
+ * Construct a scrollable block frame using the given block frame creation
+ * function.
+ */
+ nsIFrame* ConstructScrollableBlockWithConstructor(
+ nsFrameConstructorState& aState,
+ FrameConstructionItem& aItem,
+ nsContainerFrame* aParentFrame,
+ const nsStyleDisplay* aDisplay,
+ nsFrameItems& aFrameItems,
+ BlockFrameCreationFunc aConstructor);
+
+ /**
* Construct a non-scrollable block frame
*/
nsIFrame* ConstructNonScrollableBlock(nsFrameConstructorState& aState,
FrameConstructionItem& aItem,
nsContainerFrame* aParentFrame,
const nsStyleDisplay* aDisplay,
nsFrameItems& aFrameItems);