Bug 1700472 - Minor cleanup in ConstructDocElementFrame. r=dholbert

No behavior change, just compute the different things we need upfront.
At first I was going to use this in the following patch but it ended up
not being needed.

Differential Revision: https://phabricator.services.mozilla.com/D109545
This commit is contained in:
Emilio Cobos Álvarez 2021-03-24 10:13:25 +00:00
Родитель d1c07416d3
Коммит 2656f9a4d1
1 изменённых файлов: 23 добавлений и 22 удалений

Просмотреть файл

@ -2515,7 +2515,29 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
// covers the entire canvas as specified by the CSS2 spec // covers the entire canvas as specified by the CSS2 spec
nsPresContext* presContext = mPresShell->GetPresContext(); nsPresContext* presContext = mPresShell->GetPresContext();
bool isPaginated = presContext->IsRootPaginatedDocument(); const bool isPaginated = presContext->IsRootPaginatedDocument();
const bool isHTML = aDocElement->IsHTMLElement();
const bool isXUL = !isHTML && aDocElement->IsXULElement();
const bool isScrollable = [&] {
if (isPaginated) {
return presContext->HasPaginatedScrolling();
}
// Never create scrollbars for XUL documents or top level XHTML documents
// that disable scrolling.
if (isXUL) {
return false;
}
if (aDocElement->OwnerDoc()->IsDocumentURISchemeChrome() &&
aDocElement->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::scrolling, nsGkAtoms::_false,
eCaseMatters)) {
return false;
}
return true;
}();
nsContainerFrame* viewportFrame = nsContainerFrame* viewportFrame =
static_cast<nsContainerFrame*>(GetRootFrame()); static_cast<nsContainerFrame*>(GetRootFrame());
ComputedStyle* viewportPseudoStyle = viewportFrame->Style(); ComputedStyle* viewportPseudoStyle = viewportFrame->Style();
@ -2552,27 +2574,6 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
// will act as the scrolling mechanism for the viewport. // will act as the scrolling mechanism for the viewport.
// XXX Do we even need a viewport when printing to a printer? // XXX Do we even need a viewport when printing to a printer?
bool isHTML = aDocElement->IsHTMLElement();
bool isXUL = false;
if (!isHTML) {
isXUL = aDocElement->IsXULElement();
}
// Never create scrollbars for XUL documents or top level XHTML documents that
// disable scrolling.
bool isScrollable = true;
if (isPaginated) {
isScrollable = presContext->HasPaginatedScrolling();
} else if (isXUL) {
isScrollable = false;
} else if (aDocElement->OwnerDoc()->IsDocumentURISchemeChrome() &&
aDocElement->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::scrolling, nsGkAtoms::_false,
eCaseMatters)) {
isScrollable = false;
}
// We no longer need to do overflow propagation here. It's taken care of // We no longer need to do overflow propagation here. It's taken care of
// when we construct frames for the element whose overflow might be // when we construct frames for the element whose overflow might be
// propagated // propagated