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

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: Add LayoutTest 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 old ancestor scroller was the root layer, we may not be
114 // viewport constrained anymore. This might be re-added below if the new
flackr 2017/02/22 14:45:42 I don't think the case in this comment can happen.
smcgruer 2017/02/22 15:26:32 Done.
115 // ancestor scroller is also the root layer.
116 if (previousOverflowLayer && previousOverflowLayer->isRootLayer()) {
117 layer->layoutObject()
118 ->view()
119 ->frameView()
120 ->removeViewportConstrainedObject(layer->layoutObject());
121 }
122 }
123
124 if (info.lastOverflowClipLayer->isRootLayer()) {
114 layer->layoutObject() 125 layer->layoutObject()
115 ->view() 126 ->view()
116 ->frameView() 127 ->frameView()
117 ->addViewportConstrainedObject(layer->layoutObject()); 128 ->addViewportConstrainedObject(layer->layoutObject());
118 else if (previousOverflowLayer && previousOverflowLayer->isRootLayer()) 129 }
119 layer->layoutObject()
120 ->view()
121 ->frameView()
122 ->removeViewportConstrainedObject(layer->layoutObject());
123 } 130 }
124 layer->layoutObject()->updateStickyPositionConstraints(); 131 layer->layoutObject()->updateStickyPositionConstraints();
125 132
126 // Sticky position constraints and ancestor overflow scroller affect 133 // Sticky position constraints and ancestor overflow scroller affect
127 // the sticky layer position, so we need to update it again here. 134 // 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 135 // TODO(flackr): This should be refactored in the future to be clearer
129 // (i.e. update layer position and ancestor inputs updates in the 136 // (i.e. update layer position and ancestor inputs updates in the
130 // same walk) 137 // same walk)
131 layer->updateLayerPosition(); 138 layer->updateLayerPosition();
132 } 139 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ASSERT(!layer->needsCompositingInputsUpdate()); 275 ASSERT(!layer->needsCompositingInputsUpdate());
269 276
270 for (PaintLayer* child = layer->firstChild(); child; 277 for (PaintLayer* child = layer->firstChild(); child;
271 child = child->nextSibling()) 278 child = child->nextSibling())
272 assertNeedsCompositingInputsUpdateBitsCleared(child); 279 assertNeedsCompositingInputsUpdateBitsCleared(child);
273 } 280 }
274 281
275 #endif 282 #endif
276 283
277 } // namespace blink 284 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698