Commit 6f795cec authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Too early to detect viewport pagination at style recalc.

Style recalculation of HTML/BODY is what determines whether the
viewport will be paginated or not. If paged overflow happens to be
specified on BODY, we'll already have walked past HTML and therefore
won't have forced legacy layout on it.

Therefore perform this check during layout tree building. Detection of
printing, on the other hand, needs to remain in the style calculation
phase. A style recalc is forced on the root element before re-laying
out for printing, and forcing legacy layout on computed style is what
triggers a full subtree reattach, which is what we need. Checking for
printing during layout tree building may not be necessary, but I added
that as well, for good measure.

Also get rid of Document::Paginated(), since it was confusing, in that
it wouldn't return true if the viewport got paginated by paged
overflow.

This fixes one test.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I36337b5597478d1029b9529bf6e6a24e407086bb
Reviewed-on: https://chromium-review.googlesource.com/1092573Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565964}
parent 9f8ee958
......@@ -587,7 +587,6 @@ crbug.com/591099 fast/overflow/line-clamp.html [ Failure ]
crbug.com/591099 fast/overflow/overflow-update-transform.html [ Failure ]
crbug.com/591099 fast/overflow/recompute-overflow-of-layout-root-container.html [ Failure ]
crbug.com/591099 fast/pagination/modal-dialog.html [ Failure ]
crbug.com/824918 fast/pagination/paged-x-column-gap.html [ Failure ]
crbug.com/591099 fast/parser/001.html [ Failure ]
crbug.com/591099 fast/parser/entities-in-html.html [ Failure ]
crbug.com/591099 fast/parser/entities-in-xhtml.xhtml [ Failure ]
......
......@@ -693,7 +693,7 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
(style.IsOverflowPaged() &&
element != document.ViewportDefiningElement())) {
style.SetForceLegacyLayout(true);
} else if (document.Paginated()) {
} else if (document.Printing()) {
// This needs to be discovered on the root element.
DCHECK_EQ(element, document.documentElement());
style.SetForceLegacyLayout(true);
......
......@@ -709,8 +709,6 @@ class CORE_EXPORT Document : public ContainerNode,
}
void SetPrinting(PrintingState);
bool Paginated() const { return Printing(); }
enum CompatibilityMode { kQuirksMode, kLimitedQuirksMode, kNoQuirksMode };
void SetCompatibilityMode(CompatibilityMode);
......
......@@ -115,9 +115,19 @@ namespace blink {
namespace {
inline bool ShouldUseNewLayout(const ComputedStyle& style) {
return RuntimeEnabledFeatures::LayoutNGEnabled() &&
!style.ForceLegacyLayout();
inline bool ShouldUseNewLayout(const Element& element,
const ComputedStyle& style) {
if (!RuntimeEnabledFeatures::LayoutNGEnabled())
return false;
const Document& document = element.GetDocument();
bool requires_ng_block_fragmentation =
document.Printing() ||
(document.GetLayoutView() &&
document.GetLayoutView()->StyleRef().IsOverflowPaged());
if (requires_ng_block_fragmentation &&
!RuntimeEnabledFeatures::LayoutNGBlockFragmentationEnabled())
return false;
return !style.ForceLegacyLayout();
}
template <typename Predicate>
......@@ -244,11 +254,11 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kBlock:
case EDisplay::kFlowRoot:
case EDisplay::kInlineBlock:
if (ShouldUseNewLayout(style))
if (ShouldUseNewLayout(*element, style))
return new LayoutNGBlockFlow(element);
return new LayoutBlockFlow(element);
case EDisplay::kListItem:
if (ShouldUseNewLayout(style))
if (ShouldUseNewLayout(*element, style))
return new LayoutNGListItem(element);
return new LayoutListItem(element);
case EDisplay::kTable:
......@@ -264,11 +274,11 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kTableColumn:
return new LayoutTableCol(element);
case EDisplay::kTableCell:
if (ShouldUseNewLayout(style))
if (ShouldUseNewLayout(*element, style))
return new LayoutNGTableCell(element);
return new LayoutTableCell(element);
case EDisplay::kTableCaption:
if (ShouldUseNewLayout(style))
if (ShouldUseNewLayout(*element, style))
return new LayoutNGTableCaption(element);
return new LayoutTableCaption(element);
case EDisplay::kWebkitBox:
......@@ -277,7 +287,7 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kFlex:
case EDisplay::kInlineFlex:
if (RuntimeEnabledFeatures::LayoutNGFlexBoxEnabled() &&
ShouldUseNewLayout(style)) {
ShouldUseNewLayout(*element, style)) {
return new LayoutNGFlexibleBox(element);
}
return new LayoutFlexibleBox(element);
......
......@@ -295,7 +295,7 @@ void LayoutView::UpdateBlockLayout(bool relayout_children) {
}
void LayoutView::UpdateLayout() {
if (!GetDocument().Paginated())
if (!GetDocument().Printing())
SetPageLogicalHeight(LayoutUnit());
// TODO(wangxianzhu): Move this into ViewPaintInvalidator.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment