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

Side by Side Diff: Source/core/layout/LayoutBlock.cpp

Issue 1217833007: Cannot rely on auto-positioned absolutely positioned descendants being marked for layout. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/block/positioning/abspos-auto-left-fixed-top-change-parent-margin-left-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 Length marginLeft = child.style()->marginStartUsing(style()); 1195 Length marginLeft = child.style()->marginStartUsing(style());
1196 Length marginRight = child.style()->marginEndUsing(style()); 1196 Length marginRight = child.style()->marginEndUsing(style());
1197 LayoutUnit margin = 0; 1197 LayoutUnit margin = 0;
1198 if (marginLeft.isFixed()) 1198 if (marginLeft.isFixed())
1199 margin += marginLeft.value(); 1199 margin += marginLeft.value();
1200 if (marginRight.isFixed()) 1200 if (marginRight.isFixed())
1201 margin += marginRight.value(); 1201 margin += marginRight.value();
1202 return margin; 1202 return margin;
1203 } 1203 }
1204 1204
1205 static bool needsLayoutDueToStaticPosition(LayoutObject* child) 1205 static bool needsLayoutDueToStaticPosition(LayoutBox* child)
1206 { 1206 {
1207 // When a non-positioned block element moves, it may have positioned childre n that are implicitly positioned relative to the 1207 // When a non-positioned block element moves, it may have positioned childre n that are
1208 // non-positioned block. In block flow we can detect these when we layout th e non-positioned block (by noticing the change 1208 // implicitly positioned relative to the non-positioned block.
1209 // in the immediate parent's logical top in |adjustPositionedBlock|). In lin e layout we always need to mark the positioned
1210 // child for layout if its statically positioned in the direction in which t he object lays out.
1211 // crbug.com/490322(rhogan): We probably need to move the block layout case in here too, as marking a positioned object for
1212 // layout while laying out an object's children invalidly assumes that our p ositionedObjects list is in DOM order and that
1213 // we could never mark a positioned object for layout *after* we've laid it out in layoutPositionedObjects.
1214 if (!child->parent()->childrenInline())
1215 return false;
1216 const ComputedStyle* style = child->style(); 1209 const ComputedStyle* style = child->style();
1217 bool isHorizontal = style->isHorizontalWritingMode(); 1210 bool isHorizontal = style->isHorizontalWritingMode();
1218 return style->hasStaticBlockPosition(isHorizontal) || (style->isOriginalDisp layInlineType() && style->hasStaticInlinePosition(isHorizontal)); 1211 if (style->hasStaticBlockPosition(isHorizontal)) {
1212 LayoutBox::LogicalExtentComputedValues computedValues;
1213 LayoutUnit currentLogicalTop = child->logicalTop();
1214 LayoutUnit currentLogicalHeight = child->logicalHeight();
1215 child->computeLogicalHeight(currentLogicalHeight, currentLogicalTop, com putedValues);
1216 if (computedValues.m_position != currentLogicalTop || computedValues.m_e xtent != currentLogicalHeight)
1217 return true;
1218 }
1219 if (style->hasStaticInlinePosition(isHorizontal)) {
1220 LayoutBox::LogicalExtentComputedValues computedValues;
1221 LayoutUnit currentLogicalLeft = child->logicalLeft();
1222 LayoutUnit currentLogicalWidth = child->logicalWidth();
1223 child->computeLogicalWidth(computedValues);
1224 if (computedValues.m_position != currentLogicalLeft || computedValues.m_ extent != currentLogicalWidth)
1225 return true;
1226 }
1227 return false;
1219 } 1228 }
1220 1229
1221 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info) 1230 void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou tBehavior info)
1222 { 1231 {
1223 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects(); 1232 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects();
1224 if (!positionedDescendants) 1233 if (!positionedDescendants)
1225 return; 1234 return;
1226 1235
1227 for (auto* positionedObject : *positionedDescendants) { 1236 for (auto* positionedObject : *positionedDescendants) {
1228 positionedObject->setMayNeedPaintInvalidation(); 1237 positionedObject->setMayNeedPaintInvalidation();
1229 1238
1230 SubtreeLayoutScope layoutScope(*positionedObject); 1239 SubtreeLayoutScope layoutScope(*positionedObject);
1231 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So 1240 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So
1232 // 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. 1241 // 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.
1233 // it has static position. 1242 // it has static position.
1234 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope); 1243 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope);
1235 if (info == LayoutOnlyFixedPositionedObjects) { 1244 if (info == LayoutOnlyFixedPositionedObjects) {
1236 positionedObject->layoutIfNeeded(); 1245 positionedObject->layoutIfNeeded();
1237 continue; 1246 continue;
1238 } 1247 }
1239 1248
1240 if (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject) ) 1249 if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject)))
1241 layoutScope.setChildNeedsLayout(positionedObject); 1250 layoutScope.setChildNeedsLayout(positionedObject);
1242 1251
1243 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths. 1252 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
1244 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion()) 1253 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion())
1245 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis); 1254 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis);
1246 1255
1247 if (!positionedObject->needsLayout()) 1256 if (!positionedObject->needsLayout())
1248 positionedObject->markForPaginationRelayoutIfNeeded(layoutScope); 1257 positionedObject->markForPaginationRelayoutIfNeeded(layoutScope);
1249 1258
1250 // If we are paginated or in a line grid, go ahead and compute a vertica l position for our object now. 1259 // If we are paginated or in a line grid, go ahead and compute a vertica l position for our object now.
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2930 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2922 { 2931 {
2923 showLayoutObject(); 2932 showLayoutObject();
2924 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2933 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2925 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2934 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2926 } 2935 }
2927 2936
2928 #endif 2937 #endif
2929 2938
2930 } // namespace blink 2939 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/block/positioning/abspos-auto-left-fixed-top-change-parent-margin-left-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698