Bug 1792741 - Remove nsDocElementBoxFrame. r=TYLin

After bug 1665476, it's pretty much a regular XUL box with a couple
special-cases that we can use IsRootElementStyle for. Do that, and allow
using nsFlexContainerFrame when using flexbox emulation.

Differential Revision: https://phabricator.services.mozilla.com/D158288
This commit is contained in:
Emilio Cobos Álvarez
2022-10-01 00:28:13 +00:00
parent c903967783
commit c581af533f
10 changed files with 41 additions and 134 deletions

View File

@@ -209,9 +209,6 @@ static FrameCtorDebugFlags gFlags[] = {
//------------------------------------------------------------------
nsContainerFrame* NS_NewDocElementBoxFrame(PresShell* aPresShell,
ComputedStyle* aStyle);
nsIFrame* NS_NewLeafBoxFrame(PresShell* aPresShell, ComputedStyle* aStyle);
nsIFrame* NS_NewRangeFrame(PresShell* aPresShell, ComputedStyle* aStyle);
@@ -2420,14 +2417,7 @@ nsIFrame* nsCSSFrameConstructor::ConstructDocElementFrame(
nsFrameConstructorSaveState absoluteSaveState;
// Check whether we need to build a XUL box or SVG root frame
if (aDocElement->IsXULElement()) {
contentFrame = NS_NewDocElementBoxFrame(mPresShell, computedStyle);
InitAndRestoreFrame(state, aDocElement, mDocElementContainingBlock,
contentFrame);
frameList = {contentFrame, contentFrame};
processChildren = true;
} else if (aDocElement->IsSVGElement()) {
if (aDocElement->IsSVGElement()) {
if (!aDocElement->IsSVGElement(nsGkAtoms::svg)) {
return nullptr;
}
@@ -2447,11 +2437,17 @@ nsIFrame* nsCSSFrameConstructor::ConstructDocElementFrame(
} else if (display->mDisplay == StyleDisplay::Flex ||
display->mDisplay == StyleDisplay::WebkitBox ||
display->mDisplay == StyleDisplay::Grid ||
(display->mDisplay == StyleDisplay::MozBox &&
computedStyle->StyleVisibility()->EmulateMozBoxWithFlex())) {
auto func = display->mDisplay == StyleDisplay::Grid
? NS_NewGridContainerFrame
: NS_NewFlexContainerFrame;
display->mDisplay == StyleDisplay::MozBox) {
auto func = [&] {
if (display->mDisplay == StyleDisplay::Grid) {
return NS_NewGridContainerFrame;
}
if (display->mDisplay == StyleDisplay::MozBox &&
!computedStyle->StyleVisibility()->EmulateMozBoxWithFlex()) {
return NS_NewBoxFrame;
}
return NS_NewFlexContainerFrame;
}();
contentFrame = func(mPresShell, computedStyle);
InitAndRestoreFrame(
state, aDocElement,
@@ -2602,19 +2598,14 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
/*
how the root frame hierarchy should look
Galley presentation, non-XUL, with scrolling:
Galley presentation, with scrolling:
ViewportFrame [fixed-cb]
nsHTMLScrollFrame
nsHTMLScrollFrame (if needed)
nsCanvasFrame [abs-cb]
root element frame (nsBlockFrame, SVGOuterSVGFrame,
nsTableWrapperFrame, nsPlaceholderFrame)
Galley presentation, XUL
ViewportFrame [fixed-cb]
nsCanvasFrame [abs-cb]
root element frame (nsDocElementBoxFrame)
nsTableWrapperFrame, nsPlaceholderFrame,
nsBoxFrame)
Print presentation, non-XUL
@@ -4472,7 +4463,8 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay& aDisplay,
if (aMozBoxLayout == StyleMozBoxLayout::Legacy ||
aElement.IsXULElement(nsGkAtoms::scrollcorner)) {
static constexpr FrameConstructionData data =
SCROLLABLE_ABSPOS_CONTAINER_XUL_FCDATA(NS_NewBoxFrame);
SCROLLABLE_ABSPOS_CONTAINER_XUL_FCDATA(
ToCreationFunc(NS_NewBoxFrame));
return &data;
}
[[fallthrough]];