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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlock.cpp

Issue 2072473003: Change CSS containment should invalidate layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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: third_party/WebKit/Source/core/layout/LayoutBlock.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index 5d467351fbbe677e581143a030b555be27cce364..347a1eca79335624731eb8e5c127da8d4564f447 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -143,21 +143,26 @@ void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new
setIsAtomicInlineLevel(newStyle.isDisplayInlineType());
if (oldStyle && parent()) {
- bool oldHasTransformRelatedProperty = oldStyle->hasTransformRelatedProperty();
- bool newHasTransformRelatedProperty = newStyle.hasTransformRelatedProperty();
- bool oldStyleIsContainer = oldStyle->position() != StaticPosition || oldHasTransformRelatedProperty;
-
- if (oldStyleIsContainer && (newStyle.position() == StaticPosition || (oldHasTransformRelatedProperty && !newHasTransformRelatedProperty))) {
+ // Should keep in sync with LayoutObject::canContainFixedPositionObjects().
+ bool oldStyleContainsFixedPosition = oldStyle->hasTransformRelatedProperty() || oldStyle->containsPaint();
chrishtr 2016/06/16 04:31:06 Factor hasTransformRelatedProperty() || oldStyle->
trchen 2016/06/16 22:09:52 Done.
+ bool newStyleContainsFixedPosition = newStyle.hasTransformRelatedProperty() || newStyle.containsPaint();
+ // Should keep in sync with LayoutObject::canContainAbsolutePositionObjects().
+ bool oldStyleContainsAbsolutePosition = oldStyle->position() != StaticPosition || oldStyleContainsFixedPosition;
chrishtr 2016/06/16 04:31:06 Same here.
trchen 2016/06/16 22:09:52 Done.
+ bool newStyleContainsAbsolutePosition = newStyle.position() != StaticPosition || newStyleContainsFixedPosition;
+
+ if ((oldStyleContainsFixedPosition && !newStyleContainsFixedPosition)
+ || (oldStyleContainsAbsolutePosition && !newStyleContainsAbsolutePosition)) {
// Clear our positioned objects list. Our absolute and fixed positioned descendants will be
// inserted into our containing block's positioned objects list during layout.
removePositionedObjects(nullptr, NewContainingBlock);
- } else if (!oldStyleIsContainer && (newStyle.position() != StaticPosition || newHasTransformRelatedProperty)) {
+ }
+ if (!oldStyleContainsAbsolutePosition && newStyleContainsAbsolutePosition) {
// Remove our absolutely positioned descendants from their current containing block.
// They will be inserted into our positioned objects list during layout.
if (LayoutBlock* cb = containingBlockForAbsolutePosition())
cb->removePositionedObjects(this, NewContainingBlock);
}
- if (!oldHasTransformRelatedProperty && newHasTransformRelatedProperty) {
+ if (!oldStyleContainsFixedPosition && newStyleContainsFixedPosition) {
// Remove our fixed positioned descendants from their current containing block.
// They will be inserted into our positioned objects list during layout.
if (LayoutBlock* cb = containerForFixedPosition())
@@ -192,9 +197,11 @@ void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS
if (oldStyle && parent()) {
if (oldStyle->position() != newStyle.position() && newStyle.position() != StaticPosition) {
- // Remove our absolute and fixed positioned descendants from their new containing block,
- // in case containingBlock() changes by the change to the position property.
- // See styleWillChange() for other cases.
+ // In LayoutObject::styleWillChange() we already removed ourself from our old containg
chrishtr 2016/06/16 04:31:06 Typo: "containg"
trchen 2016/06/16 22:09:52 Done.
+ // block's positioned descendant list, and we will be inserted to the new containing
+ // block's list during layout. However the positioned descendant layout logic assumes
+ // layout objects to obey parent-child order in the list. Remove our descendants here
+ // so they will be re-inserted after us.
if (LayoutBlock* cb = containingBlock())
cb->removePositionedObjects(this, NewContainingBlock);
}

Powered by Google App Engine
This is Rietveld 408576698