Bug 1346983 - Part2: Insert the new nsColumnSetWrapperFrame into the frame hierarchy and reflow children. r?dholbert
MozReview-Commit-ID: lWT4KrxwJo
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -12029,29 +12029,33 @@ nsCSSFrameConstructor::ConstructBlock(ns
blockFrame->GetType() == nsGkAtoms::detailsFrame),
"not a block frame nor a details frame?");
nsContainerFrame* parent = aParentFrame;
RefPtr<nsStyleContext> blockStyle = aStyleContext;
const nsStyleColumn* columns = aStyleContext->StyleColumn();
if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO
|| columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
+ nsContainerFrame* columnSetWrapper =
+ NS_NewColumnSetWrapperFrame(mPresShell, aStyleContext);
+ InitAndRestoreFrame(aState, aContent, aParentFrame, columnSetWrapper);
+
nsContainerFrame* columnSetFrame =
NS_NewColumnSetFrame(mPresShell, aStyleContext, nsFrameState(0));
-
- InitAndRestoreFrame(aState, aContent, aParentFrame, columnSetFrame);
+ InitAndRestoreFrame(aState, aContent, columnSetWrapper, columnSetFrame);
+ SetInitialSingleChild(columnSetWrapper, columnSetFrame);
+
blockStyle = mPresShell->StyleSet()->
ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::columnContent,
aStyleContext);
parent = columnSetFrame;
- *aNewFrame = columnSetFrame;
+ *aNewFrame = columnSetWrapper;
if (aPositionedFrameForAbsPosContainer == blockFrame) {
aPositionedFrameForAbsPosContainer = columnSetFrame;
}
-
SetInitialSingleChild(columnSetFrame, blockFrame);
}
blockFrame->SetStyleContextWithoutNotification(blockStyle);
InitAndRestoreFrame(aState, aContent, parent, blockFrame);
aState.AddChild(*aNewFrame, aFrameItems, aContent, aStyleContext,
aContentParentFrame ? aContentParentFrame :
--- a/layout/generic/nsColumnSetWrapperFrame.cpp
+++ b/layout/generic/nsColumnSetWrapperFrame.cpp
@@ -19,8 +19,86 @@ NS_NewColumnSetWrapperFrame(nsIPresShell
NS_IMPL_FRAMEARENA_HELPERS(nsColumnSetWrapperFrame)
nsColumnSetWrapperFrame::nsColumnSetWrapperFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
{
}
+// XXX decide what happens here when we have multiple nsColumnSetFrames and
+// spanning elements.
+nscoord
+nsColumnSetWrapperFrame::GetMinISize(nsRenderingContext* aRenderingContext)
+{
+ // What is the point of a wrapper without any children? If this is the case
+ // then the wrapper should not have been created.
+ // The call to SetInitialChildList() in nsCSSFrameConstructor should ensure
+ // that this has a child upon creation.
+ MOZ_ASSERT(mFrames.FirstChild() ,
+ "There cannot be an ColumnSetWrapper without any children!");
+ return mFrames.FirstChild()->GetMinISize(aRenderingContext);
+}
+
+// XXX decide what happens here when we have multiple nsColumnSetFrames and
+// spanning elements.
+nscoord
+nsColumnSetWrapperFrame::GetPrefISize(nsRenderingContext* aRenderingContext)
+{
+ // What is the point of a wrapper without any children? If this is the case
+ // then the wrapper should not have been created.
+ // The call to SetInitialChildList() in nsCSSFrameConstructor should ensure
+ // that this has a child upon creation.
+ MOZ_ASSERT(mFrames.FirstChild() ,
+ "There cannot be an ColumnSetWrapper without any children!");
+ return mFrames.FirstChild()->GetPrefISize(aRenderingContext);
+}
+
+void
+nsColumnSetWrapperFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
+ const nsRect& aDirtyRect,
+ const nsDisplayListSet& aLists)
+{
+ DisplayBorderBackgroundOutline(aBuilder, aLists);
+
+ // Our children won't have backgrounds so it doesn't matter where we put them.
+ for (nsIFrame* childFrame : mFrames) {
+ BuildDisplayListForChild(aBuilder, childFrame, aDirtyRect, aLists);
+ }
+}
+
+void
+nsColumnSetWrapperFrame::Reflow(nsPresContext* aPresContext,
+ ReflowOutput& aDesiredSize,
+ const ReflowInput& aReflowInput,
+ nsReflowStatus& aStatus)
+{
+ MarkInReflow();
+ DO_GLOBAL_REFLOW_COUNT("nsColumnSetWrapperFrame");
+ DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
+ MOZ_ASSERT(aStatus.IsEmpty(), "Expecting outparam to be initially empty");
+
+ WritingMode wm = GetWritingMode();
+ LogicalMargin borderPadding = aReflowInput.ComputedLogicalBorderPadding();
+ LogicalSize computedSize = aReflowInput.ComputedSize(wm);
+ LogicalSize availableSize = aReflowInput.AvailableSize(wm);
+ LogicalSize childCBSize(wm, availableSize.ISize(wm), computedSize.BSize(wm));
+ nsSize containerSize = aReflowInput.ComputedSizeAsContainerIfConstrained();
+
+ for (nsIFrame* childFrame : mFrames) {
+ nsReflowStatus childStatus;
+ LogicalPoint childOrigin(wm,
+ borderPadding.IStart(wm),
+ borderPadding.BStart(wm));
+ ReflowInput childReflowInput(aPresContext, aReflowInput, childFrame,
+ availableSize, &childCBSize);
+ ReflowOutput childDesiredSize(wm, aDesiredSize.mFlags);
+
+ ReflowChild(childFrame, aPresContext, childDesiredSize, childReflowInput,
+ wm, childOrigin, containerSize, 0, childStatus);
+
+ FinishReflowChild(childFrame, aPresContext, childDesiredSize,
+ &childReflowInput, wm, childOrigin, containerSize, 0);
+
+ aDesiredSize.SetSize(wm, childDesiredSize.Size(wm));
+ aStatus.MergeCompletionStatusFrom(childStatus);
+ }
+}
--- a/layout/generic/nsColumnSetWrapperFrame.h
+++ b/layout/generic/nsColumnSetWrapperFrame.h
@@ -22,26 +22,37 @@
class nsColumnSetWrapperFrame final : public nsContainerFrame
{
public:
NS_DECL_FRAMEARENA_HELPERS
friend nsContainerFrame* NS_NewColumnSetWrapperFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
+ void BuildDisplayList(nsDisplayListBuilder* aBuilder,
+ const nsRect& aDirtyRect,
+ const nsDisplayListSet& aLists) override;
+
nsIAtom* GetType() const override {
return nsGkAtoms::columnSetWrapperFrame;
}
#ifdef DEBUG_FRAME_DUMP
nsresult GetFrameName(nsAString& aResult) const override {
return MakeFrameName(NS_LITERAL_STRING("ColumnSetWrapper"), aResult);
}
#endif
+ nscoord GetMinISize(nsRenderingContext* aRenderingContext) override;
+ nscoord GetPrefISize(nsRenderingContext* aRenderingContext) override;
+
+ void Reflow(nsPresContext* aPresContext,
+ ReflowOutput& aDesiredSize,
+ const ReflowInput& aReflowInput,
+ nsReflowStatus& aStatus) override;
private:
explicit nsColumnSetWrapperFrame(nsStyleContext* aContext);
~nsColumnSetWrapperFrame() override
{
}
};