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 "config.h" | 5 #include "config.h" |
6 #include "core/layout/compositing/CompositingInputsUpdater.h" | 6 #include "core/layout/compositing/CompositingInputsUpdater.h" |
7 | 7 |
8 #include "core/layout/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.h" |
9 #include "core/layout/compositing/CompositedLayerMapping.h" | 9 #include "core/layout/compositing/CompositedLayerMapping.h" |
10 #include "core/layout/compositing/PaintLayerCompositor.h" | 10 #include "core/layout/compositing/PaintLayerCompositor.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 static const PaintLayer* findParentLayerOnClippingContainerChain(const PaintLaye
r* layer) | 32 static const PaintLayer* findParentLayerOnClippingContainerChain(const PaintLaye
r* layer) |
33 { | 33 { |
34 LayoutObject* current = layer->layoutObject(); | 34 LayoutObject* current = layer->layoutObject(); |
35 while (current) { | 35 while (current) { |
36 if (current->style()->position() == FixedPosition) { | 36 if (current->style()->position() == FixedPosition) { |
37 for (current = current->parent(); current && !current->canContainFix
edPositionObjects(); current = current->parent()) { | 37 for (current = current->parent(); current && !current->canContainFix
edPositionObjects(); current = current->parent()) { |
38 // All types of clips apply to fixed-position descendants of oth
er fixed-position elements. | 38 // All types of clips apply to fixed-position descendants of oth
er fixed-position elements. |
39 // Note: it's unclear whether this is what the spec says. Firefo
x does not clip, but Chrome does. | 39 // Note: it's unclear whether this is what the spec says. Firefo
x does not clip, but Chrome does. |
40 if (current->style()->position() == FixedPosition && current->ha
sClipOrOverflowClip()) { | 40 if (current->style()->position() == FixedPosition && current->ha
sClipRelatedProperty()) { |
41 ASSERT(current->hasLayer()); | 41 ASSERT(current->hasLayer()); |
42 return static_cast<const LayoutBoxModelObject*>(current)->la
yer(); | 42 return static_cast<const LayoutBoxModelObject*>(current)->la
yer(); |
43 } | 43 } |
44 | 44 |
45 // CSS clip applies to fixed position elements even for ancestor
s that are not what the | 45 // CSS clip applies to fixed position elements even for ancestor
s that are not what the |
46 // fixed element is positioned with respect to. | 46 // fixed element is positioned with respect to. |
47 if (current->hasClip()) { | 47 if (current->hasClip()) { |
48 ASSERT(current->hasLayer()); | 48 ASSERT(current->hasLayer()); |
49 return static_cast<const LayoutBoxModelObject*>(current)->la
yer(); | 49 return static_cast<const LayoutBoxModelObject*>(current)->la
yer(); |
50 } | 50 } |
51 } | 51 } |
52 } else { | 52 } else { |
53 current = current->containingBlock(); | 53 current = current->containingBlock(); |
54 } | 54 } |
55 | 55 |
56 if (current->hasLayer()) | 56 if (current->hasLayer()) |
57 return static_cast<const LayoutBoxModelObject*>(current)->layer(); | 57 return static_cast<const LayoutBoxModelObject*>(current)->layer(); |
58 // Having clip or overflow clip forces the LayoutObject to become a laye
r. | 58 // Having clip or overflow clip forces the LayoutObject to become a laye
r. |
59 ASSERT(!current->hasClipOrOverflowClip()); | 59 ASSERT(!current->hasClipRelatedProperty()); |
60 } | 60 } |
61 ASSERT_NOT_REACHED(); | 61 ASSERT_NOT_REACHED(); |
62 return nullptr; | 62 return nullptr; |
63 } | 63 } |
64 | 64 |
65 static const PaintLayer* findParentLayerOnContainingBlockChain(const LayoutObjec
t* object) | 65 static const PaintLayer* findParentLayerOnContainingBlockChain(const LayoutObjec
t* object) |
66 { | 66 { |
67 for (const LayoutObject* current = object; current; current = current->conta
iningBlock()) { | 67 for (const LayoutObject* current = object; current; current = current->conta
iningBlock()) { |
68 if (current->hasLayer()) | 68 if (current->hasLayer()) |
69 return static_cast<const LayoutBoxModelObject*>(current)->layer(); | 69 return static_cast<const LayoutBoxModelObject*>(current)->layer(); |
70 } | 70 } |
71 ASSERT_NOT_REACHED(); | 71 ASSERT_NOT_REACHED(); |
72 return nullptr; | 72 return nullptr; |
73 } | 73 } |
74 | 74 |
75 static bool hasClippedStackingAncestor(const PaintLayer* layer, const PaintLayer
* clippingLayer) | 75 static bool hasClippedStackingAncestor(const PaintLayer* layer, const PaintLayer
* clippingLayer) |
76 { | 76 { |
77 if (layer == clippingLayer) | 77 if (layer == clippingLayer) |
78 return false; | 78 return false; |
79 bool foundInterveningClip = false; | 79 bool foundInterveningClip = false; |
80 const LayoutObject* clippingLayoutObject = clippingLayer->layoutObject(); | 80 const LayoutObject* clippingLayoutObject = clippingLayer->layoutObject(); |
81 for (const PaintLayer* current = layer->compositingContainer(); current; cur
rent = current->compositingContainer()) { | 81 for (const PaintLayer* current = layer->compositingContainer(); current; cur
rent = current->compositingContainer()) { |
82 if (current == clippingLayer) | 82 if (current == clippingLayer) |
83 return foundInterveningClip; | 83 return foundInterveningClip; |
84 | 84 |
85 if (current->layoutObject()->hasClipOrOverflowClip() && !clippingLayoutO
bject->isDescendantOf(current->layoutObject())) | 85 if (current->layoutObject()->hasClipRelatedProperty() && !clippingLayout
Object->isDescendantOf(current->layoutObject())) |
86 foundInterveningClip = true; | 86 foundInterveningClip = true; |
87 | 87 |
88 if (const LayoutObject* container = current->clippingContainer()) { | 88 if (const LayoutObject* container = current->clippingContainer()) { |
89 if (clippingLayoutObject != container && !clippingLayoutObject->isDe
scendantOf(container)) | 89 if (clippingLayoutObject != container && !clippingLayoutObject->isDe
scendantOf(container)) |
90 foundInterveningClip = true; | 90 foundInterveningClip = true; |
91 } | 91 } |
92 } | 92 } |
93 return false; | 93 return false; |
94 } | 94 } |
95 | 95 |
(...skipping 27 matching lines...) Expand all Loading... |
123 IntRect clipRect = pixelSnappedIntRect(layer->clipper().backgroundCl
ipRect(ClipRectsContext(m_rootLayer, AbsoluteClipRects)).rect()); | 123 IntRect clipRect = pixelSnappedIntRect(layer->clipper().backgroundCl
ipRect(ClipRectsContext(m_rootLayer, AbsoluteClipRects)).rect()); |
124 properties.clippedAbsoluteBoundingBox.intersect(clipRect); | 124 properties.clippedAbsoluteBoundingBox.intersect(clipRect); |
125 | 125 |
126 const PaintLayer* parent = layer->parent(); | 126 const PaintLayer* parent = layer->parent(); |
127 properties.opacityAncestor = parent->isTransparent() ? parent : pare
nt->opacityAncestor(); | 127 properties.opacityAncestor = parent->isTransparent() ? parent : pare
nt->opacityAncestor(); |
128 properties.transformAncestor = parent->hasTransformRelatedProperty()
? parent : parent->transformAncestor(); | 128 properties.transformAncestor = parent->hasTransformRelatedProperty()
? parent : parent->transformAncestor(); |
129 properties.filterAncestor = parent->hasFilter() ? parent : parent->f
ilterAncestor(); | 129 properties.filterAncestor = parent->hasFilter() ? parent : parent->f
ilterAncestor(); |
130 bool layerIsFixedPosition = layer->layoutObject()->style()->position
() == FixedPosition; | 130 bool layerIsFixedPosition = layer->layoutObject()->style()->position
() == FixedPosition; |
131 properties.nearestFixedPositionLayer = layerIsFixedPosition ? layer
: parent->nearestFixedPositionLayer(); | 131 properties.nearestFixedPositionLayer = layerIsFixedPosition ? layer
: parent->nearestFixedPositionLayer(); |
132 | 132 |
133 if (info.hasAncestorWithClipOrOverflowClip) { | 133 if (info.hasAncestorWithClipRelatedProperty) { |
134 const PaintLayer* parentLayerOnClippingContainerChain = findPare
ntLayerOnClippingContainerChain(layer); | 134 const PaintLayer* parentLayerOnClippingContainerChain = findPare
ntLayerOnClippingContainerChain(layer); |
135 const bool parentHasClipOrOverflowClip = parentLayerOnClippingCo
ntainerChain->layoutObject()->hasClipOrOverflowClip(); | 135 const bool parentHasClipRelatedProperty = parentLayerOnClippingC
ontainerChain->layoutObject()->hasClipRelatedProperty(); |
136 properties.clippingContainer = parentHasClipOrOverflowClip ? par
entLayerOnClippingContainerChain->layoutObject() : parentLayerOnClippingContaine
rChain->clippingContainer(); | 136 properties.clippingContainer = parentHasClipRelatedProperty ? pa
rentLayerOnClippingContainerChain->layoutObject() : parentLayerOnClippingContain
erChain->clippingContainer(); |
137 } | 137 } |
138 | 138 |
139 if (info.lastScrollingAncestor) { | 139 if (info.lastScrollingAncestor) { |
140 const LayoutObject* containingBlock = layer->layoutObject()->con
tainingBlock(); | 140 const LayoutObject* containingBlock = layer->layoutObject()->con
tainingBlock(); |
141 const PaintLayer* parentLayerOnContainingBlockChain = findParent
LayerOnContainingBlockChain(containingBlock); | 141 const PaintLayer* parentLayerOnContainingBlockChain = findParent
LayerOnContainingBlockChain(containingBlock); |
142 | 142 |
143 properties.ancestorScrollingLayer = parentLayerOnContainingBlock
Chain->ancestorScrollingLayer(); | 143 properties.ancestorScrollingLayer = parentLayerOnContainingBlock
Chain->ancestorScrollingLayer(); |
144 if (parentLayerOnContainingBlockChain->scrollsOverflow()) | 144 if (parentLayerOnContainingBlockChain->scrollsOverflow()) |
145 properties.ancestorScrollingLayer = parentLayerOnContainingB
lockChain; | 145 properties.ancestorScrollingLayer = parentLayerOnContainingB
lockChain; |
146 | 146 |
(...skipping 13 matching lines...) Expand all Loading... |
160 properties.hasAncestorWithClipPath = info.hasAncestorWithClipPath; | 160 properties.hasAncestorWithClipPath = info.hasAncestorWithClipPath; |
161 layer->updateAncestorDependentCompositingInputs(properties); | 161 layer->updateAncestorDependentCompositingInputs(properties); |
162 } | 162 } |
163 | 163 |
164 if (layer->stackingNode()->isStackingContext()) | 164 if (layer->stackingNode()->isStackingContext()) |
165 info.ancestorStackingContext = layer; | 165 info.ancestorStackingContext = layer; |
166 | 166 |
167 if (layer->scrollsOverflow()) | 167 if (layer->scrollsOverflow()) |
168 info.lastScrollingAncestor = layer; | 168 info.lastScrollingAncestor = layer; |
169 | 169 |
170 if (layer->layoutObject()->hasClipOrOverflowClip()) | 170 if (layer->layoutObject()->hasClipRelatedProperty()) |
171 info.hasAncestorWithClipOrOverflowClip = true; | 171 info.hasAncestorWithClipRelatedProperty = true; |
172 | 172 |
173 if (layer->layoutObject()->hasClipPath()) | 173 if (layer->layoutObject()->hasClipPath()) |
174 info.hasAncestorWithClipPath = true; | 174 info.hasAncestorWithClipPath = true; |
175 | 175 |
176 PaintLayer::DescendantDependentCompositingInputs descendantProperties; | 176 PaintLayer::DescendantDependentCompositingInputs descendantProperties; |
177 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl
ing()) { | 177 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl
ing()) { |
178 updateRecursive(child, updateType, info); | 178 updateRecursive(child, updateType, info); |
179 | 179 |
180 descendantProperties.hasDescendantWithClipPath |= child->hasDescendantWi
thClipPath() || child->layoutObject()->hasClipPath(); | 180 descendantProperties.hasDescendantWithClipPath |= child->hasDescendantWi
thClipPath() || child->layoutObject()->hasClipPath(); |
181 descendantProperties.hasNonIsolatedDescendantWithBlendMode |= (!child->s
tackingNode()->isStackingContext() && child->hasNonIsolatedDescendantWithBlendMo
de()) || child->layoutObject()->style()->hasBlendMode(); | 181 descendantProperties.hasNonIsolatedDescendantWithBlendMode |= (!child->s
tackingNode()->isStackingContext() && child->hasNonIsolatedDescendantWithBlendMo
de()) || child->layoutObject()->style()->hasBlendMode(); |
(...skipping 12 matching lines...) Expand all Loading... |
194 ASSERT(!layer->childNeedsCompositingInputsUpdate()); | 194 ASSERT(!layer->childNeedsCompositingInputsUpdate()); |
195 ASSERT(!layer->needsCompositingInputsUpdate()); | 195 ASSERT(!layer->needsCompositingInputsUpdate()); |
196 | 196 |
197 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl
ing()) | 197 for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibl
ing()) |
198 assertNeedsCompositingInputsUpdateBitsCleared(child); | 198 assertNeedsCompositingInputsUpdateBitsCleared(child); |
199 } | 199 } |
200 | 200 |
201 #endif | 201 #endif |
202 | 202 |
203 } // namespace blink | 203 } // namespace blink |
OLD | NEW |