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/Layer.h" | 8 #include "core/layout/Layer.h" |
9 #include "core/layout/compositing/CompositedLayerMapping.h" | 9 #include "core/layout/compositing/CompositedLayerMapping.h" |
10 #include "core/layout/compositing/LayerCompositor.h" | 10 #include "core/layout/compositing/LayerCompositor.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 void CompositingInputsUpdater::update() | 26 void CompositingInputsUpdater::update() |
27 { | 27 { |
28 TRACE_EVENT0("blink", "CompositingInputsUpdater::update"); | 28 TRACE_EVENT0("blink", "CompositingInputsUpdater::update"); |
29 updateRecursive(m_rootLayer, DoNotForceUpdate, AncestorInfo()); | 29 updateRecursive(m_rootLayer, DoNotForceUpdate, AncestorInfo()); |
30 } | 30 } |
31 | 31 |
32 static const Layer* findParentLayerOnClippingContainerChain(const Layer* layer) | 32 static const Layer* findParentLayerOnClippingContainerChain(const Layer* layer) |
33 { | 33 { |
34 RenderObject* current = layer->renderer(); | 34 LayoutObject* current = layer->renderer(); |
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
sClipOrOverflowClip()) { |
41 ASSERT(current->hasLayer()); | 41 ASSERT(current->hasLayer()); |
42 return static_cast<const LayoutLayerModelObject*>(current)->
layer(); | 42 return static_cast<const LayoutLayerModelObject*>(current)->
layer(); |
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 LayoutLayerModelObject*>(current)->
layer(); | 49 return static_cast<const LayoutLayerModelObject*>(current)->
layer(); |
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 LayoutLayerModelObject*>(current)->layer(); | 57 return static_cast<const LayoutLayerModelObject*>(current)->layer(); |
58 // Having clip or overflow clip forces the RenderObject 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->hasClipOrOverflowClip()); |
60 } | 60 } |
61 ASSERT_NOT_REACHED(); | 61 ASSERT_NOT_REACHED(); |
62 return 0; | 62 return 0; |
63 } | 63 } |
64 | 64 |
65 static const Layer* findParentLayerOnContainingBlockChain(const RenderObject* ob
ject) | 65 static const Layer* findParentLayerOnContainingBlockChain(const LayoutObject* ob
ject) |
66 { | 66 { |
67 for (const RenderObject* 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 LayoutLayerModelObject*>(current)->layer(); | 69 return static_cast<const LayoutLayerModelObject*>(current)->layer(); |
70 } | 70 } |
71 ASSERT_NOT_REACHED(); | 71 ASSERT_NOT_REACHED(); |
72 return 0; | 72 return 0; |
73 } | 73 } |
74 | 74 |
75 static bool hasClippedStackingAncestor(const Layer* layer, const Layer* clipping
Layer) | 75 static bool hasClippedStackingAncestor(const Layer* layer, const Layer* clipping
Layer) |
76 { | 76 { |
77 if (layer == clippingLayer) | 77 if (layer == clippingLayer) |
78 return false; | 78 return false; |
79 const RenderObject* clippingRenderer = clippingLayer->renderer(); | 79 const LayoutObject* clippingRenderer = clippingLayer->renderer(); |
80 for (const Layer* current = layer->compositingContainer(); current && curren
t != clippingLayer; current = current->compositingContainer()) { | 80 for (const Layer* current = layer->compositingContainer(); current && curren
t != clippingLayer; current = current->compositingContainer()) { |
81 if (current->renderer()->hasClipOrOverflowClip() && !clippingRenderer->i
sDescendantOf(current->renderer())) | 81 if (current->renderer()->hasClipOrOverflowClip() && !clippingRenderer->i
sDescendantOf(current->renderer())) |
82 return true; | 82 return true; |
83 | 83 |
84 if (const RenderObject* container = current->clippingContainer()) { | 84 if (const LayoutObject* container = current->clippingContainer()) { |
85 if (clippingRenderer != container && !clippingRenderer->isDescendant
Of(container)) | 85 if (clippingRenderer != container && !clippingRenderer->isDescendant
Of(container)) |
86 return true; | 86 return true; |
87 } | 87 } |
88 } | 88 } |
89 return false; | 89 return false; |
90 } | 90 } |
91 | 91 |
92 void CompositingInputsUpdater::updateRecursive(Layer* layer, UpdateType updateTy
pe, AncestorInfo info) | 92 void CompositingInputsUpdater::updateRecursive(Layer* layer, UpdateType updateTy
pe, AncestorInfo info) |
93 { | 93 { |
94 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate
) | 94 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate
) |
(...skipping 29 matching lines...) Expand all Loading... |
124 properties.transformAncestor = parent->hasTransformRelatedProperty()
? parent : parent->transformAncestor(); | 124 properties.transformAncestor = parent->hasTransformRelatedProperty()
? parent : parent->transformAncestor(); |
125 properties.filterAncestor = parent->hasFilter() ? parent : parent->f
ilterAncestor(); | 125 properties.filterAncestor = parent->hasFilter() ? parent : parent->f
ilterAncestor(); |
126 | 126 |
127 if (info.hasAncestorWithClipOrOverflowClip) { | 127 if (info.hasAncestorWithClipOrOverflowClip) { |
128 const Layer* parentLayerOnClippingContainerChain = findParentLay
erOnClippingContainerChain(layer); | 128 const Layer* parentLayerOnClippingContainerChain = findParentLay
erOnClippingContainerChain(layer); |
129 const bool parentHasClipOrOverflowClip = parentLayerOnClippingCo
ntainerChain->renderer()->hasClipOrOverflowClip(); | 129 const bool parentHasClipOrOverflowClip = parentLayerOnClippingCo
ntainerChain->renderer()->hasClipOrOverflowClip(); |
130 properties.clippingContainer = parentHasClipOrOverflowClip ? par
entLayerOnClippingContainerChain->renderer() : parentLayerOnClippingContainerCha
in->clippingContainer(); | 130 properties.clippingContainer = parentHasClipOrOverflowClip ? par
entLayerOnClippingContainerChain->renderer() : parentLayerOnClippingContainerCha
in->clippingContainer(); |
131 } | 131 } |
132 | 132 |
133 if (info.lastScrollingAncestor) { | 133 if (info.lastScrollingAncestor) { |
134 const RenderObject* containingBlock = layer->renderer()->contain
ingBlock(); | 134 const LayoutObject* containingBlock = layer->renderer()->contain
ingBlock(); |
135 const Layer* parentLayerOnContainingBlockChain = findParentLayer
OnContainingBlockChain(containingBlock); | 135 const Layer* parentLayerOnContainingBlockChain = findParentLayer
OnContainingBlockChain(containingBlock); |
136 | 136 |
137 properties.ancestorScrollingLayer = parentLayerOnContainingBlock
Chain->ancestorScrollingLayer(); | 137 properties.ancestorScrollingLayer = parentLayerOnContainingBlock
Chain->ancestorScrollingLayer(); |
138 if (parentLayerOnContainingBlockChain->scrollsOverflow()) | 138 if (parentLayerOnContainingBlockChain->scrollsOverflow()) |
139 properties.ancestorScrollingLayer = parentLayerOnContainingB
lockChain; | 139 properties.ancestorScrollingLayer = parentLayerOnContainingB
lockChain; |
140 | 140 |
141 if (layer->renderer()->isOutOfFlowPositioned() && !layer->subtre
eIsInvisible()) { | 141 if (layer->renderer()->isOutOfFlowPositioned() && !layer->subtre
eIsInvisible()) { |
142 const Layer* clippingLayer = properties.clippingContainer ?
properties.clippingContainer->enclosingLayer() : layer->compositor()->rootLayer(
); | 142 const Layer* clippingLayer = properties.clippingContainer ?
properties.clippingContainer->enclosingLayer() : layer->compositor()->rootLayer(
); |
143 if (hasClippedStackingAncestor(layer, clippingLayer)) | 143 if (hasClippedStackingAncestor(layer, clippingLayer)) |
144 properties.clipParent = clippingLayer; | 144 properties.clipParent = clippingLayer; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 ASSERT(!layer->childNeedsCompositingInputsUpdate()); | 188 ASSERT(!layer->childNeedsCompositingInputsUpdate()); |
189 ASSERT(!layer->needsCompositingInputsUpdate()); | 189 ASSERT(!layer->needsCompositingInputsUpdate()); |
190 | 190 |
191 for (Layer* child = layer->firstChild(); child; child = child->nextSibling()
) | 191 for (Layer* child = layer->firstChild(); child; child = child->nextSibling()
) |
192 assertNeedsCompositingInputsUpdateBitsCleared(child); | 192 assertNeedsCompositingInputsUpdateBitsCleared(child); |
193 } | 193 } |
194 | 194 |
195 #endif | 195 #endif |
196 | 196 |
197 } // namespace blink | 197 } // namespace blink |
OLD | NEW |