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

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

Issue 1181983002: Ensure that positioned objects' list is always in parent first order (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: mstensho's nits and change test to avoid timeouts Created 5 years, 6 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
« no previous file with comments | « LayoutTests/fast/dynamic/transform-removed-from-absolute-with-fixed-children-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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 LayoutBox::willBeDestroyed(); 268 LayoutBox::willBeDestroyed();
269 } 269 }
270 270
271 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style) 271 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style)
272 { 272 {
273 const ComputedStyle* oldStyle = style(); 273 const ComputedStyle* oldStyle = style();
274 274
275 setReplaced(newStyle.isDisplayInlineType()); 275 setReplaced(newStyle.isDisplayInlineType());
276 276
277 if (oldStyle && parent()) { 277 if (oldStyle && parent()) {
278 bool oldStyleIsContainer = oldStyle->position() != StaticPosition || old Style->hasTransformRelatedProperty(); 278 bool oldHasTransformRelatedProperty = oldStyle->hasTransformRelatedPrope rty();
279 bool newStyleIsContainer = newStyle.position() != StaticPosition || newS tyle.hasTransformRelatedProperty(); 279 bool newHasTransformRelatedProperty = newStyle.hasTransformRelatedProper ty();
280 bool oldStyleIsContainer = oldStyle->position() != StaticPosition || old HasTransformRelatedProperty;
280 281
281 if (oldStyleIsContainer && !newStyleIsContainer) { 282 if (oldStyleIsContainer && (newStyle.position() == StaticPosition || (ol dHasTransformRelatedProperty && !newHasTransformRelatedProperty))) {
282 // Clear our positioned objects list. Our absolutely positioned desc endants will be 283 // Clear our positioned objects list. Our absolutely positioned desc endants will be
283 // inserted into our containing block's positioned objects list duri ng layout. 284 // inserted into our containing block's positioned objects list duri ng layout.
284 removePositionedObjects(0, NewContainingBlock); 285 removePositionedObjects(0, NewContainingBlock);
285 } else if (!oldStyleIsContainer && newStyleIsContainer) { 286 } else if (!oldStyleIsContainer && (newStyle.position() != StaticPositio n || newHasTransformRelatedProperty)) {
286 // Remove our absolutely positioned descendants from their current c ontaining block. 287 // Remove our absolutely positioned descendants from their current c ontaining block.
287 // They will be inserted into our positioned objects list during lay out. 288 // They will be inserted into our positioned objects list during lay out.
288 LayoutObject* cb = parent(); 289 if (LayoutBlock* cb = containingBlock())
289 while (cb && (cb->style()->position() == StaticPosition || (cb->isIn line() && !cb->isReplaced())) && !cb->isLayoutView()) { 290 cb->removePositionedObjects(this, NewContainingBlock);
290 if (cb->style()->position() == RelativePosition && cb->isInline( ) && !cb->isReplaced()) {
291 cb = cb->containingBlock();
292 break;
293 }
294 cb = cb->parent();
295 }
296
297 if (cb->isLayoutBlock())
298 toLayoutBlock(cb)->removePositionedObjects(this, NewContainingBl ock);
299 } 291 }
300 } 292 }
301 293
302 LayoutBox::styleWillChange(diff, newStyle); 294 LayoutBox::styleWillChange(diff, newStyle);
303 } 295 }
304 296
305 static bool borderOrPaddingLogicalWidthChanged(const ComputedStyle& oldStyle, co nst ComputedStyle& newStyle) 297 static bool borderOrPaddingLogicalWidthChanged(const ComputedStyle& oldStyle, co nst ComputedStyle& newStyle)
306 { 298 {
307 if (newStyle.isHorizontalWritingMode()) { 299 if (newStyle.isHorizontalWritingMode()) {
308 return oldStyle.borderLeftWidth() != newStyle.borderLeftWidth() 300 return oldStyle.borderLeftWidth() != newStyle.borderLeftWidth()
(...skipping 10 matching lines...) Expand all
319 311
320 void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS tyle) 312 void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS tyle)
321 { 313 {
322 LayoutBox::styleDidChange(diff, oldStyle); 314 LayoutBox::styleDidChange(diff, oldStyle);
323 315
324 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isLayoutBlockFlow ()) 316 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isLayoutBlockFlow ())
325 toLayoutBlock(parent())->removeAnonymousWrappersIfRequired(); 317 toLayoutBlock(parent())->removeAnonymousWrappersIfRequired();
326 318
327 const ComputedStyle& newStyle = styleRef(); 319 const ComputedStyle& newStyle = styleRef();
328 320
321 if (oldStyle && parent()) {
322 if (oldStyle->position() != newStyle.position() && newStyle.position() ! = StaticPosition) {
323 // Remove our absolutely positioned descendants from their new conta ining block,
324 // in case containingBlock() changes by the change to the position p roperty.
325 // See styleWillChange() for other cases.
326 if (LayoutBlock* cb = containingBlock())
327 cb->removePositionedObjects(this, NewContainingBlock);
328 }
329 }
330
329 if (TextAutosizer* textAutosizer = document().textAutosizer()) 331 if (TextAutosizer* textAutosizer = document().textAutosizer())
330 textAutosizer->record(this); 332 textAutosizer->record(this);
331 333
332 propagateStyleToAnonymousChildren(true); 334 propagateStyleToAnonymousChildren(true);
333 335
334 // It's possible for our border/padding to change, but for the overall logic al width of the block to 336 // It's possible for our border/padding to change, but for the overall logic al width of the block to
335 // end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true. 337 // end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true.
336 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n eedsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle); 338 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n eedsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle);
337 339
338 // If the style has unloaded images, want to notify the ResourceLoadPriority Optimizer so that 340 // If the style has unloaded images, want to notify the ResourceLoadPriority Optimizer so that
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2917 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2916 { 2918 {
2917 showLayoutObject(); 2919 showLayoutObject();
2918 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2920 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2919 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2921 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2920 } 2922 }
2921 2923
2922 #endif 2924 #endif
2923 2925
2924 } // namespace blink 2926 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/dynamic/transform-removed-from-absolute-with-fixed-children-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698