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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositingInputsUpdater.cpp

Issue 2706673002: Mark elements as viewport constrained when they become sticky positioned (Closed)
Patch Set: Address reviewer comments Created 3 years, 10 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/compositing/CompositingInputsUpdater.h" 5 #include "core/layout/compositing/CompositingInputsUpdater.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/layout/LayoutBlock.h" 10 #include "core/layout/LayoutBlock.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void CompositingInputsUpdater::updateRecursive(PaintLayer* layer, 95 void CompositingInputsUpdater::updateRecursive(PaintLayer* layer,
96 UpdateType updateType, 96 UpdateType updateType,
97 AncestorInfo info) { 97 AncestorInfo info) {
98 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate) 98 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate)
99 return; 99 return;
100 100
101 const PaintLayer* previousOverflowLayer = layer->ancestorOverflowLayer(); 101 const PaintLayer* previousOverflowLayer = layer->ancestorOverflowLayer();
102 layer->updateAncestorOverflowLayer(info.lastOverflowClipLayer); 102 layer->updateAncestorOverflowLayer(info.lastOverflowClipLayer);
103 if (info.lastOverflowClipLayer && layer->needsCompositingInputsUpdate() && 103 if (info.lastOverflowClipLayer && layer->needsCompositingInputsUpdate() &&
104 layer->layoutObject()->style()->position() == EPosition::kSticky) { 104 layer->layoutObject()->style()->position() == EPosition::kSticky) {
105 if (info.lastOverflowClipLayer != previousOverflowLayer && 105 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
106 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 106 if (info.lastOverflowClipLayer != previousOverflowLayer) {
107 // Old ancestor scroller should no longer have these constraints. 107 // Old ancestor scroller should no longer have these constraints.
108 ASSERT(!previousOverflowLayer || 108 DCHECK(!previousOverflowLayer ||
109 !previousOverflowLayer->getScrollableArea() 109 !previousOverflowLayer->getScrollableArea()
110 ->stickyConstraintsMap() 110 ->stickyConstraintsMap()
111 .contains(layer)); 111 .contains(layer));
112 112
113 if (info.lastOverflowClipLayer->isRootLayer()) 113 // If our ancestor scroller has changed and the previous one was the
114 // root layer, we are no longer viewport constrained.
115 if (previousOverflowLayer && previousOverflowLayer->isRootLayer()) {
116 layer->layoutObject()
117 ->view()
118 ->frameView()
119 ->removeViewportConstrainedObject(layer->layoutObject());
120 }
121 }
122
123 if (info.lastOverflowClipLayer->isRootLayer()) {
114 layer->layoutObject() 124 layer->layoutObject()
115 ->view() 125 ->view()
116 ->frameView() 126 ->frameView()
117 ->addViewportConstrainedObject(layer->layoutObject()); 127 ->addViewportConstrainedObject(layer->layoutObject());
118 else if (previousOverflowLayer && previousOverflowLayer->isRootLayer()) 128 }
119 layer->layoutObject()
120 ->view()
121 ->frameView()
122 ->removeViewportConstrainedObject(layer->layoutObject());
123 } 129 }
124 layer->layoutObject()->updateStickyPositionConstraints(); 130 layer->layoutObject()->updateStickyPositionConstraints();
125 131
126 // Sticky position constraints and ancestor overflow scroller affect 132 // Sticky position constraints and ancestor overflow scroller affect
127 // the sticky layer position, so we need to update it again here. 133 // the sticky layer position, so we need to update it again here.
128 // TODO(flackr): This should be refactored in the future to be clearer 134 // TODO(flackr): This should be refactored in the future to be clearer
129 // (i.e. update layer position and ancestor inputs updates in the 135 // (i.e. update layer position and ancestor inputs updates in the
130 // same walk) 136 // same walk)
131 layer->updateLayerPosition(); 137 layer->updateLayerPosition();
132 } 138 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ASSERT(!layer->needsCompositingInputsUpdate()); 274 ASSERT(!layer->needsCompositingInputsUpdate());
269 275
270 for (PaintLayer* child = layer->firstChild(); child; 276 for (PaintLayer* child = layer->firstChild(); child;
271 child = child->nextSibling()) 277 child = child->nextSibling())
272 assertNeedsCompositingInputsUpdateBitsCleared(child); 278 assertNeedsCompositingInputsUpdateBitsCleared(child);
273 } 279 }
274 280
275 #endif 281 #endif
276 282
277 } // namespace blink 283 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698