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

Side by Side 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 unified diff | Download patch
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 LayoutBox::willBeDestroyed(); 136 LayoutBox::willBeDestroyed();
137 } 137 }
138 138
139 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style) 139 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style)
140 { 140 {
141 const ComputedStyle* oldStyle = style(); 141 const ComputedStyle* oldStyle = style();
142 142
143 setIsAtomicInlineLevel(newStyle.isDisplayInlineType()); 143 setIsAtomicInlineLevel(newStyle.isDisplayInlineType());
144 144
145 if (oldStyle && parent()) { 145 if (oldStyle && parent()) {
146 bool oldHasTransformRelatedProperty = oldStyle->hasTransformRelatedPrope rty(); 146 // Should keep in sync with LayoutObject::canContainFixedPositionObjects ().
147 bool newHasTransformRelatedProperty = newStyle.hasTransformRelatedProper ty(); 147 bool oldStyleContainsFixedPosition = oldStyle->hasTransformRelatedProper ty() || oldStyle->containsPaint();
chrishtr 2016/06/16 04:31:06 Factor hasTransformRelatedProperty() || oldStyle->
trchen 2016/06/16 22:09:52 Done.
148 bool oldStyleIsContainer = oldStyle->position() != StaticPosition || old HasTransformRelatedProperty; 148 bool newStyleContainsFixedPosition = newStyle.hasTransformRelatedPropert y() || newStyle.containsPaint();
149 // Should keep in sync with LayoutObject::canContainAbsolutePositionObje cts().
150 bool oldStyleContainsAbsolutePosition = oldStyle->position() != StaticPo sition || oldStyleContainsFixedPosition;
chrishtr 2016/06/16 04:31:06 Same here.
trchen 2016/06/16 22:09:52 Done.
151 bool newStyleContainsAbsolutePosition = newStyle.position() != StaticPos ition || newStyleContainsFixedPosition;
149 152
150 if (oldStyleIsContainer && (newStyle.position() == StaticPosition || (ol dHasTransformRelatedProperty && !newHasTransformRelatedProperty))) { 153 if ((oldStyleContainsFixedPosition && !newStyleContainsFixedPosition)
154 || (oldStyleContainsAbsolutePosition && !newStyleContainsAbsolutePos ition)) {
151 // Clear our positioned objects list. Our absolute and fixed positio ned descendants will be 155 // Clear our positioned objects list. Our absolute and fixed positio ned descendants will be
152 // inserted into our containing block's positioned objects list duri ng layout. 156 // inserted into our containing block's positioned objects list duri ng layout.
153 removePositionedObjects(nullptr, NewContainingBlock); 157 removePositionedObjects(nullptr, NewContainingBlock);
154 } else if (!oldStyleIsContainer && (newStyle.position() != StaticPositio n || newHasTransformRelatedProperty)) { 158 }
159 if (!oldStyleContainsAbsolutePosition && newStyleContainsAbsolutePositio n) {
155 // Remove our absolutely positioned descendants from their current c ontaining block. 160 // Remove our absolutely positioned descendants from their current c ontaining block.
156 // They will be inserted into our positioned objects list during lay out. 161 // They will be inserted into our positioned objects list during lay out.
157 if (LayoutBlock* cb = containingBlockForAbsolutePosition()) 162 if (LayoutBlock* cb = containingBlockForAbsolutePosition())
158 cb->removePositionedObjects(this, NewContainingBlock); 163 cb->removePositionedObjects(this, NewContainingBlock);
159 } 164 }
160 if (!oldHasTransformRelatedProperty && newHasTransformRelatedProperty) { 165 if (!oldStyleContainsFixedPosition && newStyleContainsFixedPosition) {
161 // Remove our fixed positioned descendants from their current contai ning block. 166 // Remove our fixed positioned descendants from their current contai ning block.
162 // They will be inserted into our positioned objects list during lay out. 167 // They will be inserted into our positioned objects list during lay out.
163 if (LayoutBlock* cb = containerForFixedPosition()) 168 if (LayoutBlock* cb = containerForFixedPosition())
164 cb->removePositionedObjects(this, NewContainingBlock); 169 cb->removePositionedObjects(this, NewContainingBlock);
165 } 170 }
166 } 171 }
167 172
168 LayoutBox::styleWillChange(diff, newStyle); 173 LayoutBox::styleWillChange(diff, newStyle);
169 } 174 }
170 175
(...skipping 14 matching lines...) Expand all
185 } 190 }
186 191
187 void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS tyle) 192 void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS tyle)
188 { 193 {
189 LayoutBox::styleDidChange(diff, oldStyle); 194 LayoutBox::styleDidChange(diff, oldStyle);
190 195
191 const ComputedStyle& newStyle = styleRef(); 196 const ComputedStyle& newStyle = styleRef();
192 197
193 if (oldStyle && parent()) { 198 if (oldStyle && parent()) {
194 if (oldStyle->position() != newStyle.position() && newStyle.position() ! = StaticPosition) { 199 if (oldStyle->position() != newStyle.position() && newStyle.position() ! = StaticPosition) {
195 // Remove our absolute and fixed positioned descendants from their n ew containing block, 200 // In LayoutObject::styleWillChange() we already removed ourself fro m our old containg
chrishtr 2016/06/16 04:31:06 Typo: "containg"
trchen 2016/06/16 22:09:52 Done.
196 // in case containingBlock() changes by the change to the position p roperty. 201 // block's positioned descendant list, and we will be inserted to th e new containing
197 // See styleWillChange() for other cases. 202 // block's list during layout. However the positioned descendant lay out logic assumes
203 // layout objects to obey parent-child order in the list. Remove our descendants here
204 // so they will be re-inserted after us.
198 if (LayoutBlock* cb = containingBlock()) 205 if (LayoutBlock* cb = containingBlock())
199 cb->removePositionedObjects(this, NewContainingBlock); 206 cb->removePositionedObjects(this, NewContainingBlock);
200 } 207 }
201 } 208 }
202 209
203 if (TextAutosizer* textAutosizer = document().textAutosizer()) 210 if (TextAutosizer* textAutosizer = document().textAutosizer())
204 textAutosizer->record(this); 211 textAutosizer->record(this);
205 212
206 propagateStyleToAnonymousChildren(); 213 propagateStyleToAnonymousChildren();
207 214
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) { 1848 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) {
1842 LayoutBox* currBox = *it; 1849 LayoutBox* currBox = *it;
1843 ASSERT(!currBox->needsLayout()); 1850 ASSERT(!currBox->needsLayout());
1844 } 1851 }
1845 } 1852 }
1846 } 1853 }
1847 1854
1848 #endif 1855 #endif
1849 1856
1850 } // namespace blink 1857 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698