From 96b57ed40507255611c8f0a27e2f960b0f4a33a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 23 Mar 2021 22:31:07 +0000 Subject: [PATCH] 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 --- layout/base/nsCSSFrameConstructor.cpp | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index ae8fbd125935..fd0aa7ce10f3 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2515,7 +2515,29 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock( // covers the entire canvas as specified by the CSS2 spec 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 = static_cast(GetRootFrame()); ComputedStyle* viewportPseudoStyle = viewportFrame->Style(); @@ -2552,27 +2574,6 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock( // will act as the scrolling mechanism for the viewport. // 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 // when we construct frames for the element whose overflow might be // propagated