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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutBlock.cpp
diff --git a/Source/core/layout/LayoutBlock.cpp b/Source/core/layout/LayoutBlock.cpp
index 993a929f237dd607a3cdcf5986ce81f0c5b2f8c4..c717f16cd731914f84449fa5e7454a712bf67b39 100644
--- a/Source/core/layout/LayoutBlock.cpp
+++ b/Source/core/layout/LayoutBlock.cpp
@@ -275,27 +275,19 @@ void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new
setReplaced(newStyle.isDisplayInlineType());
if (oldStyle && parent()) {
- bool oldStyleIsContainer = oldStyle->position() != StaticPosition || oldStyle->hasTransformRelatedProperty();
- bool newStyleIsContainer = newStyle.position() != StaticPosition || newStyle.hasTransformRelatedProperty();
+ bool oldHasTransformRelatedProperty = oldStyle->hasTransformRelatedProperty();
+ bool newHasTransformRelatedProperty = newStyle.hasTransformRelatedProperty();
+ bool oldStyleIsContainer = oldStyle->position() != StaticPosition || oldHasTransformRelatedProperty;
- if (oldStyleIsContainer && !newStyleIsContainer) {
+ if (oldStyleIsContainer && (newStyle.position() == StaticPosition || (oldHasTransformRelatedProperty && !newHasTransformRelatedProperty))) {
// Clear our positioned objects list. Our absolutely positioned descendants will be
// inserted into our containing block's positioned objects list during layout.
removePositionedObjects(0, NewContainingBlock);
- } else if (!oldStyleIsContainer && newStyleIsContainer) {
+ } else if (!oldStyleIsContainer && (newStyle.position() != StaticPosition || newHasTransformRelatedProperty)) {
// Remove our absolutely positioned descendants from their current containing block.
// They will be inserted into our positioned objects list during layout.
- LayoutObject* cb = parent();
- while (cb && (cb->style()->position() == StaticPosition || (cb->isInline() && !cb->isReplaced())) && !cb->isLayoutView()) {
- if (cb->style()->position() == RelativePosition && cb->isInline() && !cb->isReplaced()) {
- cb = cb->containingBlock();
- break;
- }
- cb = cb->parent();
- }
-
- if (cb->isLayoutBlock())
- toLayoutBlock(cb)->removePositionedObjects(this, NewContainingBlock);
+ if (LayoutBlock* cb = containingBlock())
+ cb->removePositionedObjects(this, NewContainingBlock);
}
}
@@ -326,6 +318,16 @@ void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS
const ComputedStyle& newStyle = styleRef();
+ if (oldStyle && parent()) {
+ if (oldStyle->position() != newStyle.position() && newStyle.position() != StaticPosition) {
+ // Remove our absolutely positioned descendants from their new containing block,
+ // in case containingBlock() changes by the change to the position property.
+ // See styleWillChange() for other cases.
+ if (LayoutBlock* cb = containingBlock())
+ cb->removePositionedObjects(this, NewContainingBlock);
+ }
+ }
+
if (TextAutosizer* textAutosizer = document().textAutosizer())
textAutosizer->record(this);
« 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