| OLD | NEW |
| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } else { |
| 166 rareProperties.ancestorOverflowLayer = info.lastOverflowLayer; |
| 158 } | 167 } |
| 159 | 168 |
| 169 // TODO: Clear sticky constraints from old scroll ancestor when scroll a
ncestor changes. |
| 160 layer->updateAncestorDependentCompositingInputs(properties, rareProperti
es, info.hasAncestorWithClipPath); | 170 layer->updateAncestorDependentCompositingInputs(properties, rareProperti
es, info.hasAncestorWithClipPath); |
| 171 if (layer->layoutObject()->style()->position() == StickyPosition) { |
| 172 if (info.lastOverflowLayer->isRootLayer()) |
| 173 layer->layoutObject()->view()->frameView()->addViewportConstrain
edObject(layer->layoutObject()); |
| 174 else |
| 175 layer->layoutObject()->view()->frameView()->removeViewportConstr
ainedObject(layer->layoutObject()); |
| 176 layer->layoutObject()->ensureStickyPositionConstraints(layer->layout
Object()->computeStickyConstrainingRect().size()); |
| 177 } |
| 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 Loading... |
| 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 |
| OLD | NEW |