Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlock.cpp

Issue 1415623002: Need to reposition an out-of-flow object *before* re-paginating it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/multicol/dynamic/bottom-aligned-abspos-change-column-height-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBlock.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index ad6462f99a8f74d4ddcbc7308b0dc5a2023280ba..dfe3167499f4eb0c9bd22e9339cc9621921d009b 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -1193,6 +1193,8 @@ void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou
if (!positionedDescendants)
return;
+ bool isPaginated = view()->layoutState()->isPaginated();
+
for (auto* positionedObject : *positionedDescendants) {
positionedObject->setMayNeedPaintInvalidation();
@@ -1213,6 +1215,20 @@ void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou
if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculation())
positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis);
+ LayoutUnit logicalTopEstimate;
+ bool needsBlockDirectionLocationSetBeforeLayout = isPaginated && !positionedObject->isUnsplittableForPagination();
+ if (needsBlockDirectionLocationSetBeforeLayout) {
+ // Out-of-flow objects are normally positioned after layout (while in-flow objects are
+ // positioned before layout). If the child object is paginated in the same context as
+ // we are, estimate its logical top now. We need to know this up-front, to correctly
+ // evaluate if we need to mark for relayout, and, if our estimate is correct, we'll
+ // even be able to insert correct pagination struts on the first attempt.
+ LogicalExtentComputedValues computedValues;
+ positionedObject->computeLogicalHeight(positionedObject->logicalHeight(), positionedObject->logicalTop(), computedValues);
+ logicalTopEstimate = computedValues.m_position;
+ positionedObject->setLogicalTop(logicalTopEstimate);
+ }
+
if (!positionedObject->needsLayout())
positionedObject->markForPaginationRelayoutIfNeeded(layoutScope);
@@ -1222,6 +1238,10 @@ void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou
positionedObject->setNeedsLayout(LayoutInvalidationReason::AncestorMoved, MarkOnlyThis);
positionedObject->layoutIfNeeded();
+
+ // Lay out again if our estimate was wrong.
+ if (needsBlockDirectionLocationSetBeforeLayout && logicalTopEstimate != logicalTopForChild(*positionedObject))
+ positionedObject->forceChildLayout();
}
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/multicol/dynamic/bottom-aligned-abspos-change-column-height-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698