OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2014 Google Inc. All rights reserved. | 3 * Copyright (C) 2014 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "core/html/HTMLMediaElement.h" | 30 #include "core/html/HTMLMediaElement.h" |
31 #include "core/rendering/RenderLayer.h" | 31 #include "core/rendering/RenderLayer.h" |
32 #include "core/rendering/RenderLayerReflectionInfo.h" | 32 #include "core/rendering/RenderLayerReflectionInfo.h" |
33 #include "core/rendering/RenderPart.h" | 33 #include "core/rendering/RenderPart.h" |
34 #include "core/rendering/compositing/CompositedLayerMapping.h" | 34 #include "core/rendering/compositing/CompositedLayerMapping.h" |
35 #include "core/rendering/compositing/RenderLayerCompositor.h" | 35 #include "core/rendering/compositing/RenderLayerCompositor.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 static bool shouldAppendLayer(const RenderLayer& layer) | |
40 { | |
41 if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) | |
42 return true; | |
43 Node* node = layer.renderer()->node(); | |
44 if (node && isHTMLMediaElement(*node) && toHTMLMediaElement(node)->isFullscr
een()) | |
45 return false; | |
46 return true; | |
47 } | |
48 | |
49 GraphicsLayerUpdater::UpdateContext::UpdateContext(const UpdateContext& other, c
onst RenderLayer& layer) | 39 GraphicsLayerUpdater::UpdateContext::UpdateContext(const UpdateContext& other, c
onst RenderLayer& layer) |
50 : m_compositingStackingContext(other.m_compositingStackingContext) | 40 : m_compositingStackingContext(other.m_compositingStackingContext) |
51 , m_compositingAncestor(other.compositingContainer(layer)) | 41 , m_compositingAncestor(other.compositingContainer(layer)) |
52 { | 42 { |
53 CompositingState compositingState = layer.compositingState(); | 43 CompositingState compositingState = layer.compositingState(); |
54 if (compositingState != NotComposited && compositingState != PaintsIntoGroup
edBacking) { | 44 if (compositingState != NotComposited && compositingState != PaintsIntoGroup
edBacking) { |
55 m_compositingAncestor = &layer; | 45 m_compositingAncestor = &layer; |
56 if (layer.stackingNode()->isStackingContext()) | 46 if (layer.stackingNode()->isStackingContext()) |
57 m_compositingStackingContext = &layer; | 47 m_compositingStackingContext = &layer; |
58 } | 48 } |
59 } | 49 } |
60 | 50 |
61 const RenderLayer* GraphicsLayerUpdater::UpdateContext::compositingContainer(con
st RenderLayer& layer) const | 51 const RenderLayer* GraphicsLayerUpdater::UpdateContext::compositingContainer(con
st RenderLayer& layer) const |
62 { | 52 { |
63 return layer.stackingNode()->isNormalFlowOnly() ? m_compositingAncestor : m_
compositingStackingContext; | 53 return layer.stackingNode()->isNormalFlowOnly() ? m_compositingAncestor : m_
compositingStackingContext; |
64 } | 54 } |
65 | 55 |
66 GraphicsLayerUpdater::GraphicsLayerUpdater() | 56 GraphicsLayerUpdater::GraphicsLayerUpdater() |
67 : m_needsRebuildTree(false) | 57 : m_needsRebuildTree(false) |
68 { | 58 { |
69 } | 59 } |
70 | 60 |
71 GraphicsLayerUpdater::~GraphicsLayerUpdater() | 61 GraphicsLayerUpdater::~GraphicsLayerUpdater() |
72 { | 62 { |
73 } | 63 } |
74 | 64 |
75 void GraphicsLayerUpdater::rebuildTree(RenderLayer& layer, GraphicsLayerVector&
childLayersOfEnclosingLayer) | |
76 { | |
77 // Make the layer compositing if necessary, and set up clipping and content
layers. | |
78 // Note that we can only do work here that is independent of whether the des
cendant layers | |
79 // have been processed. computeCompositingRequirements() will already have d
one the repaint if necessary. | |
80 | |
81 layer.stackingNode()->updateLayerListsIfNeeded(); | |
82 | |
83 const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); | |
84 CompositedLayerMappingPtr currentCompositedLayerMapping = layer.compositedLa
yerMapping(); | |
85 | |
86 // If this layer has a compositedLayerMapping, then that is where we place s
ubsequent children GraphicsLayers. | |
87 // Otherwise children continue to append to the child list of the enclosing
layer. | |
88 GraphicsLayerVector layerChildren; | |
89 GraphicsLayerVector& childList = hasCompositedLayerMapping ? layerChildren :
childLayersOfEnclosingLayer; | |
90 | |
91 #if !ASSERT_DISABLED | |
92 LayerListMutationDetector mutationChecker(layer.stackingNode()); | |
93 #endif | |
94 | |
95 if (layer.stackingNode()->isStackingContext()) { | |
96 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), Negative
ZOrderChildren); | |
97 while (RenderLayerStackingNode* curNode = iterator.next()) | |
98 rebuildTree(*curNode->layer(), childList); | |
99 | |
100 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. | |
101 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou
ndLayer()) | |
102 childList.append(currentCompositedLayerMapping->foregroundLayer()); | |
103 } | |
104 | |
105 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowCh
ildren | PositiveZOrderChildren); | |
106 while (RenderLayerStackingNode* curNode = iterator.next()) | |
107 rebuildTree(*curNode->layer(), childList); | |
108 | |
109 if (hasCompositedLayerMapping) { | |
110 bool parented = false; | |
111 if (layer.renderer()->isRenderPart()) | |
112 parented = RenderLayerCompositor::parentFrameContentLayers(toRenderP
art(layer.renderer())); | |
113 | |
114 if (!parented) | |
115 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay
erChildren); | |
116 | |
117 // If the layer has a clipping layer the overflow controls layers will b
e siblings of the clipping layer. | |
118 // Otherwise, the overflow control layers are normal children. | |
119 if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompos
itedLayerMapping->hasScrollingLayer()) { | |
120 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp
ing->layerForHorizontalScrollbar()) { | |
121 overflowControlLayer->removeFromParent(); | |
122 currentCompositedLayerMapping->parentForSublayers()->addChild(ov
erflowControlLayer); | |
123 } | |
124 | |
125 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp
ing->layerForVerticalScrollbar()) { | |
126 overflowControlLayer->removeFromParent(); | |
127 currentCompositedLayerMapping->parentForSublayers()->addChild(ov
erflowControlLayer); | |
128 } | |
129 | |
130 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp
ing->layerForScrollCorner()) { | |
131 overflowControlLayer->removeFromParent(); | |
132 currentCompositedLayerMapping->parentForSublayers()->addChild(ov
erflowControlLayer); | |
133 } | |
134 } | |
135 | |
136 if (shouldAppendLayer(layer)) | |
137 childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->ch
ildForSuperlayers()); | |
138 } | |
139 } | |
140 | |
141 void GraphicsLayerUpdater::update(RenderLayer& layer, UpdateType updateType, con
st UpdateContext& context) | 65 void GraphicsLayerUpdater::update(RenderLayer& layer, UpdateType updateType, con
st UpdateContext& context) |
142 { | 66 { |
143 if (layer.hasCompositedLayerMapping()) { | 67 if (layer.hasCompositedLayerMapping()) { |
144 CompositedLayerMappingPtr mapping = layer.compositedLayerMapping(); | 68 CompositedLayerMappingPtr mapping = layer.compositedLayerMapping(); |
145 | 69 |
146 const RenderLayer* compositingContainer = context.compositingContainer(l
ayer); | 70 const RenderLayer* compositingContainer = context.compositingContainer(l
ayer); |
147 ASSERT(compositingContainer == layer.ancestorCompositingLayer()); | 71 ASSERT(compositingContainer == layer.ancestorCompositingLayer()); |
148 if (mapping->updateRequiresOwnBackingStoreForAncestorReasons(compositing
Container)) | 72 if (mapping->updateRequiresOwnBackingStoreForAncestorReasons(compositing
Container)) |
149 updateType = ForceUpdate; | 73 updateType = ForceUpdate; |
150 | 74 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (layer.hasCompositedLayerMapping()) | 108 if (layer.hasCompositedLayerMapping()) |
185 layer.compositedLayerMapping()->assertNeedsToUpdateGraphicsLayerBitsClea
red(); | 109 layer.compositedLayerMapping()->assertNeedsToUpdateGraphicsLayerBitsClea
red(); |
186 | 110 |
187 for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibl
ing()) | 111 for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibl
ing()) |
188 assertNeedsToUpdateGraphicsLayerBitsCleared(*child); | 112 assertNeedsToUpdateGraphicsLayerBitsCleared(*child); |
189 } | 113 } |
190 | 114 |
191 #endif | 115 #endif |
192 | 116 |
193 } // namespace WebCore | 117 } // namespace WebCore |
OLD | NEW |