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

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: WIP - fix on release, still hits CHECK in LayoutGeometryMap.cpp:156 Created 4 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/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (info.enclosingCompositedLayer) 108 if (info.enclosingCompositedLayer)
107 info.enclosingCompositedLayer->compositedLayerMapping()->setNeedsGra phicsLayerUpdate(GraphicsLayerUpdateSubtree); 109 info.enclosingCompositedLayer->compositedLayerMapping()->setNeedsGra phicsLayerUpdate(GraphicsLayerUpdateSubtree);
108 updateType = ForceUpdate; 110 updateType = ForceUpdate;
109 } 111 }
110 112
111 if (updateType == ForceUpdate) { 113 if (updateType == ForceUpdate) {
112 PaintLayer::AncestorDependentCompositingInputs properties; 114 PaintLayer::AncestorDependentCompositingInputs properties;
113 PaintLayer::RareAncestorDependentCompositingInputs rareProperties; 115 PaintLayer::RareAncestorDependentCompositingInputs rareProperties;
114 116
115 if (!layer->isRootLayer()) { 117 if (!layer->isRootLayer()) {
116 properties.clippedAbsoluteBoundingBox = enclosingIntRect(m_geometryM ap.absoluteRect(FloatRect(layer->boundingBoxForCompositingOverlapTest()))); 118 properties.clippedAbsoluteBoundingBox = enclosingIntRect(m_geometryM ap.absoluteRect(FloatRect(layer->boundingBoxForCompositingOverlapTest())));
flackr 2016/02/25 22:10:26 There seems to be a bit of a problem here. Seems w
chrishtr 2016/03/04 20:05:41 Are you blocked on this? Or did your proposed appr
117 // FIXME: Setting the absBounds to 1x1 instead of 0x0 makes very lit tle sense, 119 // FIXME: Setting the absBounds to 1x1 instead of 0x0 makes very lit tle sense,
118 // but removing this code will make JSGameBench sad. 120 // but removing this code will make JSGameBench sad.
119 // See https://codereview.chromium.org/13912020/ 121 // See https://codereview.chromium.org/13912020/
120 if (properties.clippedAbsoluteBoundingBox.isEmpty()) 122 if (properties.clippedAbsoluteBoundingBox.isEmpty())
121 properties.clippedAbsoluteBoundingBox.setSize(IntSize(1, 1)); 123 properties.clippedAbsoluteBoundingBox.setSize(IntSize(1, 1));
122 124
123 IntRect clipRect = pixelSnappedIntRect(layer->clipper().backgroundCl ipRect(ClipRectsContext(m_rootLayer, AbsoluteClipRects)).rect()); 125 IntRect clipRect = pixelSnappedIntRect(layer->clipper().backgroundCl ipRect(ClipRectsContext(m_rootLayer, AbsoluteClipRects)).rect());
124 properties.clippedAbsoluteBoundingBox.intersect(clipRect); 126 properties.clippedAbsoluteBoundingBox.intersect(clipRect);
125 127
126 const PaintLayer* parent = layer->parent(); 128 const PaintLayer* parent = layer->parent();
127 rareProperties.opacityAncestor = parent->isTransparent() ? parent : parent->opacityAncestor(); 129 rareProperties.opacityAncestor = parent->isTransparent() ? parent : parent->opacityAncestor();
128 rareProperties.transformAncestor = parent->hasTransformRelatedProper ty() ? parent : parent->transformAncestor(); 130 rareProperties.transformAncestor = parent->hasTransformRelatedProper ty() ? parent : parent->transformAncestor();
129 rareProperties.filterAncestor = parent->hasFilter() ? parent : paren t->filterAncestor(); 131 rareProperties.filterAncestor = parent->hasFilter() ? parent : paren t->filterAncestor();
130 bool layerIsFixedPosition = layer->layoutObject()->style()->position () == FixedPosition; 132 bool layerIsFixedPosition = layer->layoutObject()->style()->position () == FixedPosition;
131 rareProperties.nearestFixedPositionLayer = layerIsFixedPosition ? la yer : parent->nearestFixedPositionLayer(); 133 rareProperties.nearestFixedPositionLayer = layerIsFixedPosition ? la yer : parent->nearestFixedPositionLayer();
132 134
133 if (info.hasAncestorWithClipRelatedProperty) { 135 if (info.hasAncestorWithClipRelatedProperty) {
134 const PaintLayer* parentLayerOnClippingContainerChain = findPare ntLayerOnClippingContainerChain(layer); 136 const PaintLayer* parentLayerOnClippingContainerChain = findPare ntLayerOnClippingContainerChain(layer);
135 const bool parentHasClipRelatedProperty = parentLayerOnClippingC ontainerChain->layoutObject()->hasClipRelatedProperty(); 137 const bool parentHasClipRelatedProperty = parentLayerOnClippingC ontainerChain->layoutObject()->hasClipRelatedProperty();
136 properties.clippingContainer = parentHasClipRelatedProperty ? pa rentLayerOnClippingContainerChain->layoutObject() : parentLayerOnClippingContain erChain->clippingContainer(); 138 properties.clippingContainer = parentHasClipRelatedProperty ? pa rentLayerOnClippingContainerChain->layoutObject() : parentLayerOnClippingContain erChain->clippingContainer();
137 } 139 }
138 140
141 const LayoutObject* containingBlock = layer->layoutObject()->contain ingBlock();
142 const PaintLayer* parentLayerOnContainingBlockChain = findParentLaye rOnContainingBlockChain(containingBlock);
143
144 rareProperties.ancestorOverflowLayer = parentLayerOnContainingBlockC hain->ancestorOverflowLayer();
145 if (parentLayerOnContainingBlockChain->layoutObject()->hasOverflowCl ip())
146 rareProperties.ancestorOverflowLayer = parentLayerOnContainingBl ockChain;
147
139 if (info.lastScrollingAncestor) { 148 if (info.lastScrollingAncestor) {
140 const LayoutObject* containingBlock = layer->layoutObject()->con tainingBlock();
141 const PaintLayer* parentLayerOnContainingBlockChain = findParent LayerOnContainingBlockChain(containingBlock);
142 149
143 rareProperties.ancestorScrollingLayer = parentLayerOnContainingB lockChain->ancestorScrollingLayer(); 150 rareProperties.ancestorScrollingLayer = parentLayerOnContainingB lockChain->ancestorScrollingLayer();
144 if (parentLayerOnContainingBlockChain->scrollsOverflow()) 151 if (parentLayerOnContainingBlockChain->scrollsOverflow())
145 rareProperties.ancestorScrollingLayer = parentLayerOnContain ingBlockChain; 152 rareProperties.ancestorScrollingLayer = parentLayerOnContain ingBlockChain;
146 153
147 if (layer->layoutObject()->isOutOfFlowPositioned() && !layer->su btreeIsInvisible()) { 154 if (layer->layoutObject()->isOutOfFlowPositioned() && !layer->su btreeIsInvisible()) {
148 const PaintLayer* clippingLayer = properties.clippingContain er ? properties.clippingContainer->enclosingLayer() : layer->compositor()->rootL ayer(); 155 const PaintLayer* clippingLayer = properties.clippingContain er ? properties.clippingContainer->enclosingLayer() : layer->compositor()->rootL ayer();
149 if (hasClippedStackingAncestor(layer, clippingLayer)) 156 if (hasClippedStackingAncestor(layer, clippingLayer))
150 rareProperties.clipParent = clippingLayer; 157 rareProperties.clipParent = clippingLayer;
151 } 158 }
152 159
153 if (layer->stackingNode()->isTreatedAsOrStackingContext() 160 if (layer->stackingNode()->isTreatedAsOrStackingContext()
154 && rareProperties.ancestorScrollingLayer 161 && rareProperties.ancestorScrollingLayer
155 && !info.ancestorStackingContext->layoutObject()->isDescenda ntOf(rareProperties.ancestorScrollingLayer->layoutObject())) 162 && !info.ancestorStackingContext->layoutObject()->isDescenda ntOf(rareProperties.ancestorScrollingLayer->layoutObject()))
156 rareProperties.scrollParent = rareProperties.ancestorScrolli ngLayer; 163 rareProperties.scrollParent = rareProperties.ancestorScrolli ngLayer;
157 } 164 }
165
166 if (layer->layoutObject()->style()->position() == StickyPosition) {
167 if (info.lastOverflowLayer->isRootLayer())
168 layer->layoutObject()->view()->frameView()->addViewportConst rainedObject(layer->layoutObject());
169 else
170 layer->layoutObject()->view()->frameView()->removeViewportCo nstrainedObject(layer->layoutObject());
171 layer->layoutObject()->updateStickyPositionConstraints(info.last OverflowLayer);
172 }
173 } else {
174 rareProperties.ancestorOverflowLayer = info.lastOverflowLayer;
158 } 175 }
159 176
160 layer->updateAncestorDependentCompositingInputs(properties, rareProperti es, info.hasAncestorWithClipPath); 177 layer->updateAncestorDependentCompositingInputs(properties, rareProperti es, info.hasAncestorWithClipPath);
161 } 178 }
162 179
163 if (layer->stackingNode()->isStackingContext()) 180 if (layer->stackingNode()->isStackingContext())
164 info.ancestorStackingContext = layer; 181 info.ancestorStackingContext = layer;
165 182
183 if (layer->layoutObject()->hasOverflowClip())
184 info.lastOverflowLayer = layer;
185
166 if (layer->scrollsOverflow()) 186 if (layer->scrollsOverflow())
167 info.lastScrollingAncestor = layer; 187 info.lastScrollingAncestor = layer;
168 188
169 if (layer->layoutObject()->hasClipRelatedProperty()) 189 if (layer->layoutObject()->hasClipRelatedProperty())
170 info.hasAncestorWithClipRelatedProperty = true; 190 info.hasAncestorWithClipRelatedProperty = true;
171 191
172 if (layer->layoutObject()->hasClipPath()) 192 if (layer->layoutObject()->hasClipPath())
173 info.hasAncestorWithClipPath = true; 193 info.hasAncestorWithClipPath = true;
174 194
175 bool hasDescendantWithClipPath = false; 195 bool hasDescendantWithClipPath = false;
(...skipping 18 matching lines...) Expand all
194 ASSERT(!layer->childNeedsCompositingInputsUpdate()); 214 ASSERT(!layer->childNeedsCompositingInputsUpdate());
195 ASSERT(!layer->needsCompositingInputsUpdate()); 215 ASSERT(!layer->needsCompositingInputsUpdate());
196 216
197 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl ing()) 217 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl ing())
198 assertNeedsCompositingInputsUpdateBitsCleared(child); 218 assertNeedsCompositingInputsUpdateBitsCleared(child);
199 } 219 }
200 220
201 #endif 221 #endif
202 222
203 } // namespace blink 223 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698