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

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

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Store ancestor overflow layer on PaintLayer to compute before other dependent compositing inputs. Created 4 years, 9 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/frame/FrameView.h"
7 #include "core/layout/LayoutBlock.h" 8 #include "core/layout/LayoutBlock.h"
9 #include "core/layout/LayoutView.h"
8 #include "core/layout/compositing/CompositedLayerMapping.h" 10 #include "core/layout/compositing/CompositedLayerMapping.h"
9 #include "core/layout/compositing/PaintLayerCompositor.h" 11 #include "core/layout/compositing/PaintLayerCompositor.h"
10 #include "core/paint/PaintLayer.h" 12 #include "core/paint/PaintLayer.h"
11 #include "platform/TraceEvent.h" 13 #include "platform/TraceEvent.h"
12 14
13 namespace blink { 15 namespace blink {
14 16
15 CompositingInputsUpdater::CompositingInputsUpdater(PaintLayer* rootLayer) 17 CompositingInputsUpdater::CompositingInputsUpdater(PaintLayer* rootLayer)
16 : m_geometryMap(UseTransforms) 18 : m_geometryMap(UseTransforms)
17 , m_rootLayer(rootLayer) 19 , m_rootLayer(rootLayer)
18 { 20 {
19 } 21 }
20 22
21 CompositingInputsUpdater::~CompositingInputsUpdater() 23 CompositingInputsUpdater::~CompositingInputsUpdater()
22 { 24 {
23 } 25 }
24 26
25 void CompositingInputsUpdater::update() 27 void CompositingInputsUpdater::update()
26 { 28 {
27 TRACE_EVENT0("blink", "CompositingInputsUpdater::update"); 29 TRACE_EVENT0("blink", "CompositingInputsUpdater::update");
28 updateRecursive(m_rootLayer, DoNotForceUpdate, AncestorInfo()); 30 updateRecursive(m_rootLayer, DoNotForceUpdate, AncestorInfo(m_rootLayer));
29 } 31 }
30 32
31 static const PaintLayer* findParentLayerOnClippingContainerChain(const PaintLaye r* layer) 33 static const PaintLayer* findParentLayerOnClippingContainerChain(const PaintLaye r* layer)
32 { 34 {
33 LayoutObject* current = layer->layoutObject(); 35 LayoutObject* current = layer->layoutObject();
34 while (current) { 36 while (current) {
35 if (current->style()->position() == FixedPosition) { 37 if (current->style()->position() == FixedPosition) {
36 for (current = current->parent(); current && !current->canContainFix edPositionObjects(); current = current->parent()) { 38 for (current = current->parent(); current && !current->canContainFix edPositionObjects(); current = current->parent()) {
37 // All types of clips apply to fixed-position descendants of oth er fixed-position elements. 39 // All types of clips apply to fixed-position descendants of oth er fixed-position elements.
38 // Note: it's unclear whether this is what the spec says. Firefo x does not clip, but Chrome does. 40 // Note: it's unclear whether this is what the spec says. Firefo x does not clip, but Chrome does.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 92 }
91 } 93 }
92 return false; 94 return false;
93 } 95 }
94 96
95 void CompositingInputsUpdater::updateRecursive(PaintLayer* layer, UpdateType upd ateType, AncestorInfo info) 97 void CompositingInputsUpdater::updateRecursive(PaintLayer* layer, UpdateType upd ateType, AncestorInfo info)
96 { 98 {
97 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate ) 99 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate )
98 return; 100 return;
99 101
102 const PaintLayer* previousOverflowLayer = layer->ancestorOverflowLayer();
103 layer->updateAncestorOverflowLayer(info.lastOverflowLayer);
104 if (layer->needsCompositingInputsUpdate() && layer->layoutObject()->style()- >position() == StickyPosition) {
105 if (info.lastOverflowLayer != previousOverflowLayer) {
106 // Remove sticky constraints from old ancestor scroller if there was a change.
107 if (previousOverflowLayer)
108 previousOverflowLayer->scrollableArea()->stickyConstraintsMap(). remove(layer);
109
110 if (info.lastOverflowLayer->isRootLayer())
111 layer->layoutObject()->view()->frameView()->addViewportConstrain edObject(layer->layoutObject());
112 else if (previousOverflowLayer && previousOverflowLayer->isRootLayer ())
113 layer->layoutObject()->view()->frameView()->removeViewportConstr ainedObject(layer->layoutObject());
114 }
115 layer->layoutObject()->updateStickyPositionConstraints(info.lastOverflow Layer);
116
117 // Layer position needs to be updated before mapping clippedAbsoluteBoun dingBox.
chrishtr 2016/03/09 16:53:08 Why is the layer position not already up-to-date a
flackr 2016/03/14 19:04:26 The overflow layer may have just changed - and the
chrishtr 2016/03/16 21:52:39 But layer positions should be set before the compo
flackr 2016/03/22 21:44:32 Yes, but without correct ancestor information. We
118 layer->updateLayerPosition();
119 }
120
100 m_geometryMap.pushMappingsToAncestor(layer, layer->parent()); 121 m_geometryMap.pushMappingsToAncestor(layer, layer->parent());
101 122
102 if (layer->hasCompositedLayerMapping()) 123 if (layer->hasCompositedLayerMapping())
103 info.enclosingCompositedLayer = layer; 124 info.enclosingCompositedLayer = layer;
104 125
105 if (layer->needsCompositingInputsUpdate()) { 126 if (layer->needsCompositingInputsUpdate()) {
106 if (info.enclosingCompositedLayer) 127 if (info.enclosingCompositedLayer)
107 info.enclosingCompositedLayer->compositedLayerMapping()->setNeedsGra phicsLayerUpdate(GraphicsLayerUpdateSubtree); 128 info.enclosingCompositedLayer->compositedLayerMapping()->setNeedsGra phicsLayerUpdate(GraphicsLayerUpdateSubtree);
108 updateType = ForceUpdate; 129 updateType = ForceUpdate;
109 } 130 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 rareProperties.scrollParent = rareProperties.ancestorScrolli ngLayer; 177 rareProperties.scrollParent = rareProperties.ancestorScrolli ngLayer;
157 } 178 }
158 } 179 }
159 180
160 layer->updateAncestorDependentCompositingInputs(properties, rareProperti es, info.hasAncestorWithClipPath); 181 layer->updateAncestorDependentCompositingInputs(properties, rareProperti es, info.hasAncestorWithClipPath);
161 } 182 }
162 183
163 if (layer->stackingNode()->isStackingContext()) 184 if (layer->stackingNode()->isStackingContext())
164 info.ancestorStackingContext = layer; 185 info.ancestorStackingContext = layer;
165 186
187 if (layer->layoutObject()->hasOverflowClip())
188 info.lastOverflowLayer = layer;
189
166 if (layer->scrollsOverflow()) 190 if (layer->scrollsOverflow())
167 info.lastScrollingAncestor = layer; 191 info.lastScrollingAncestor = layer;
168 192
169 if (layer->layoutObject()->hasClipRelatedProperty()) 193 if (layer->layoutObject()->hasClipRelatedProperty())
170 info.hasAncestorWithClipRelatedProperty = true; 194 info.hasAncestorWithClipRelatedProperty = true;
171 195
172 if (layer->layoutObject()->hasClipPath()) 196 if (layer->layoutObject()->hasClipPath())
173 info.hasAncestorWithClipPath = true; 197 info.hasAncestorWithClipPath = true;
174 198
175 bool hasDescendantWithClipPath = false; 199 bool hasDescendantWithClipPath = false;
(...skipping 18 matching lines...) Expand all
194 ASSERT(!layer->childNeedsCompositingInputsUpdate()); 218 ASSERT(!layer->childNeedsCompositingInputsUpdate());
195 ASSERT(!layer->needsCompositingInputsUpdate()); 219 ASSERT(!layer->needsCompositingInputsUpdate());
196 220
197 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl ing()) 221 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl ing())
198 assertNeedsCompositingInputsUpdateBitsCleared(child); 222 assertNeedsCompositingInputsUpdateBitsCleared(child);
199 } 223 }
200 224
201 #endif 225 #endif
202 226
203 } // namespace blink 227 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698