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

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: Rebaseline one repaint order change for https://storage.googleapis.com/chromium-layout-test-archives/linux_blink_rel/66793/layout-test-results/results.html 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
Index: Source/core/layout/LayoutBlock.cpp
diff --git a/Source/core/layout/LayoutBlock.cpp b/Source/core/layout/LayoutBlock.cpp
index 993a929f237dd607a3cdcf5986ce81f0c5b2f8c4..6803b2c9fdf1fa37d76e445bbbbc928cbd36bb1e 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 || !newHasTransformRelatedProperty)) {
mstensho (USE GERRIT) 2015/06/16 14:22:37 Instead of !newHasTransformRelatedProperty: (oldH
kojii 2015/06/16 18:56:20 Done.
// 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);

Powered by Google App Engine
This is Rietveld 408576698