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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1186 }
1187 return false; 1187 return false;
1188 } 1188 }
1189 1189
1190 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info) 1190 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info)
1191 { 1191 {
1192 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects(); 1192 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects();
1193 if (!positionedDescendants) 1193 if (!positionedDescendants)
1194 return; 1194 return;
1195 1195
1196 bool isPaginated = view()->layoutState()->isPaginated();
1197
1196 for (auto* positionedObject : *positionedDescendants) { 1198 for (auto* positionedObject : *positionedDescendants) {
1197 positionedObject->setMayNeedPaintInvalidation(); 1199 positionedObject->setMayNeedPaintInvalidation();
1198 1200
1199 SubtreeLayoutScope layoutScope(*positionedObject); 1201 SubtreeLayoutScope layoutScope(*positionedObject);
1200 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So 1202 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So
1201 // if this is a fixed position element, mark it for layout if it has an abspos ancestor and needs to move with that ancestor, i.e. 1203 // if this is a fixed position element, mark it for layout if it has an abspos ancestor and needs to move with that ancestor, i.e.
1202 // it has static position. 1204 // it has static position.
1203 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope); 1205 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope);
1204 if (info == LayoutOnlyFixedPositionedObjects) { 1206 if (info == LayoutOnlyFixedPositionedObjects) {
1205 positionedObject->layoutIfNeeded(); 1207 positionedObject->layoutIfNeeded();
1206 continue; 1208 continue;
1207 } 1209 }
1208 1210
1209 if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject))) 1211 if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject)))
1210 layoutScope.setChildNeedsLayout(positionedObject); 1212 layoutScope.setChildNeedsLayout(positionedObject);
1211 1213
1212 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths. 1214 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
1213 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion()) 1215 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion())
1214 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis); 1216 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis);
1215 1217
1218 LayoutUnit logicalTopEstimate;
1219 bool needsBlockDirectionLocationSetBeforeLayout = isPaginated && !positi onedObject->isUnsplittableForPagination();
1220 if (needsBlockDirectionLocationSetBeforeLayout) {
1221 // Out-of-flow objects are normally positioned after layout (while i n-flow objects are
1222 // positioned before layout). If the child object is paginated in th e same context as
1223 // we are, estimate its logical top now. We need to know this up-fro nt, to correctly
1224 // evaluate if we need to mark for relayout, and, if our estimate is correct, we'll
1225 // even be able to insert correct pagination struts on the first att empt.
1226 LogicalExtentComputedValues computedValues;
1227 positionedObject->computeLogicalHeight(positionedObject->logicalHeig ht(), positionedObject->logicalTop(), computedValues);
1228 logicalTopEstimate = computedValues.m_position;
1229 positionedObject->setLogicalTop(logicalTopEstimate);
1230 }
1231
1216 if (!positionedObject->needsLayout()) 1232 if (!positionedObject->needsLayout())
1217 positionedObject->markForPaginationRelayoutIfNeeded(layoutScope); 1233 positionedObject->markForPaginationRelayoutIfNeeded(layoutScope);
1218 1234
1219 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need 1235 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need
1220 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756 1236 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756
1221 if (info == ForcedLayoutAfterContainingBlockMoved) 1237 if (info == ForcedLayoutAfterContainingBlockMoved)
1222 positionedObject->setNeedsLayout(LayoutInvalidationReason::AncestorM oved, MarkOnlyThis); 1238 positionedObject->setNeedsLayout(LayoutInvalidationReason::AncestorM oved, MarkOnlyThis);
1223 1239
1224 positionedObject->layoutIfNeeded(); 1240 positionedObject->layoutIfNeeded();
1241
1242 // Lay out again if our estimate was wrong.
1243 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopEstimate != logicalTopForChild(*positionedObject))
1244 positionedObject->forceChildLayout();
1225 } 1245 }
1226 } 1246 }
1227 1247
1228 void LayoutBlock::markPositionedObjectsForLayout() 1248 void LayoutBlock::markPositionedObjectsForLayout()
1229 { 1249 {
1230 if (TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects() ) { 1250 if (TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects() ) {
1231 for (auto* descendant : *positionedDescendants) 1251 for (auto* descendant : *positionedDescendants)
1232 descendant->setChildNeedsLayout(); 1252 descendant->setChildNeedsLayout();
1233 } 1253 }
1234 } 1254 }
(...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2876 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2857 { 2877 {
2858 showLayoutObject(); 2878 showLayoutObject();
2859 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2879 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2860 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2880 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2861 } 2881 }
2862 2882
2863 #endif 2883 #endif
2864 2884
2865 } // namespace blink 2885 } // namespace blink
OLDNEW
« 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