Commit 7b7e0956 authored by mstensho's avatar mstensho Committed by Commit bot

Disable layout optimization when column height may be non-uniform.

We have no way of telling what changes beyond the first column break, so if we
cannot guarantee that the column height *is* and *was* non-uniform, we need to
re-lay out children that may stretch into the unknown.

Review-Url: https://codereview.chromium.org/2562273003
Cr-Commit-Position: refs/heads/master@{#437928}
parent 12ed8948
<!DOCTYPE html>
<p>The word "HEST" should be seen below.</p>
<div style="position:relative; columns:2; column-gap:0; column-fill:auto; width:400px; height:40px; line-height:20px; orphans:1; widows:1;">
<div id="inner" style="columns:2; column-gap:0; column-fill:auto; height:80px;">
<div>
<br>
<br>
<br>
<br>
<br>
<span id="elm">HEST</span><br>
</div>
</div>
</div>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
test(() => {
var inner = document.getElementById("inner");
var elm = document.getElementById("elm");
assert_equals(elm.offsetLeft, 200);
document.body.offsetLeft;
inner.style.height = "72px";
assert_equals(elm.offsetLeft, 300);
}, "Change inner multicol height, which only affects the second row.");
</script>
......@@ -4720,6 +4720,7 @@ bool LayoutBox::childNeedsRelayoutForPagination(const LayoutBox& child) const {
// just marking and bailing here.
if (child.isFloating())
return true;
const LayoutFlowThread* flowThread = child.flowThreadContainingBlock();
LayoutUnit logicalTop = child.logicalTop();
// Figure out if we really need to force re-layout of the child. We only need
// to do this if there's a chance that we need to recalculate pagination
......@@ -4733,6 +4734,10 @@ bool LayoutBox::childNeedsRelayoutForPagination(const LayoutBox& child) const {
// location as before.
if (child.offsetToNextPage() != remainingSpace)
return true;
// If column height isn't guaranteed to be uniform, we have no way of
// telling what has happened after the first break.
if (flowThread && flowThread->mayHaveNonUniformPageLogicalHeight())
return true;
} else if (logicalHeight > remainingSpace) {
// Last time we laid out this child, we didn't need to break, but now we
// have to. So we need to relayout.
......@@ -4747,7 +4752,6 @@ bool LayoutBox::childNeedsRelayoutForPagination(const LayoutBox& child) const {
// It seems that we can skip layout of this child, but we need to ask the flow
// thread for permission first. We currently cannot skip over objects
// containing column spanners.
LayoutFlowThread* flowThread = child.flowThreadContainingBlock();
return flowThread && !flowThread->canSkipLayout(child);
}
......
......@@ -141,6 +141,7 @@ class CORE_EXPORT LayoutFlowThread : public LayoutBlockFlow {
LayoutUnit contentLogicalHeight) const;
virtual bool isPageLogicalHeightKnown() const { return true; }
virtual bool mayHaveNonUniformPageLogicalHeight() const = 0;
bool pageLogicalSizeChanged() const { return m_pageLogicalSizeChanged; }
// Return the visual bounding box based on the supplied flow-thread bounding
......
......@@ -365,6 +365,15 @@ bool LayoutMultiColumnFlowThread::isPageLogicalHeightKnown() const {
return false;
}
bool LayoutMultiColumnFlowThread::mayHaveNonUniformPageLogicalHeight() const {
const LayoutMultiColumnSet* columnSet = firstMultiColumnSet();
if (!columnSet)
return false;
if (columnSet->nextSiblingMultiColumnSet())
return true;
return enclosingFragmentationContext();
}
LayoutSize LayoutMultiColumnFlowThread::flowThreadTranslationAtOffset(
LayoutUnit offsetInFlowThread,
PageBoundaryRule rule,
......
......@@ -216,6 +216,7 @@ class CORE_EXPORT LayoutMultiColumnFlowThread : public LayoutFlowThread,
virtual bool needsNewWidth() const;
bool isPageLogicalHeightKnown() const final;
bool mayHaveNonUniformPageLogicalHeight() const final;
LayoutSize flowThreadTranslationAtOffset(LayoutUnit,
PageBoundaryRule,
......
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