| 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 11 matching lines...) Expand all Loading... |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/layout/compositing/GraphicsLayerTreeBuilder.h" | 28 #include "core/layout/compositing/GraphicsLayerTreeBuilder.h" |
| 29 | 29 |
| 30 #include "core/html/HTMLMediaElement.h" | 30 #include "core/html/HTMLMediaElement.h" |
| 31 #include "core/html/HTMLVideoElement.h" | 31 #include "core/html/HTMLVideoElement.h" |
| 32 #include "core/layout/Layer.h" |
| 33 #include "core/layout/LayerReflectionInfo.h" |
| 32 #include "core/layout/compositing/CompositedLayerMapping.h" | 34 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 33 #include "core/layout/compositing/RenderLayerCompositor.h" | 35 #include "core/layout/compositing/LayerCompositor.h" |
| 34 #include "core/rendering/RenderLayer.h" | |
| 35 #include "core/rendering/RenderLayerReflectionInfo.h" | |
| 36 #include "core/rendering/RenderPart.h" | 36 #include "core/rendering/RenderPart.h" |
| 37 #include "core/rendering/RenderView.h" | 37 #include "core/rendering/RenderView.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 GraphicsLayerTreeBuilder::GraphicsLayerTreeBuilder() | 41 GraphicsLayerTreeBuilder::GraphicsLayerTreeBuilder() |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 GraphicsLayerTreeBuilder::~GraphicsLayerTreeBuilder() | 45 GraphicsLayerTreeBuilder::~GraphicsLayerTreeBuilder() |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 static bool shouldAppendLayer(const RenderLayer& layer) | 49 static bool shouldAppendLayer(const Layer& layer) |
| 50 { | 50 { |
| 51 if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) | 51 if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) |
| 52 return true; | 52 return true; |
| 53 Node* node = layer.renderer()->node(); | 53 Node* node = layer.renderer()->node(); |
| 54 if (node && isHTMLVideoElement(*node)) { | 54 if (node && isHTMLVideoElement(*node)) { |
| 55 HTMLVideoElement* element = toHTMLVideoElement(node); | 55 HTMLVideoElement* element = toHTMLVideoElement(node); |
| 56 // For WebRTC, video frame contains all the data and no hardware surface
is used. | 56 // For WebRTC, video frame contains all the data and no hardware surface
is used. |
| 57 // We should always append the layer in this case. | 57 // We should always append the layer in this case. |
| 58 if (element->isFullscreen() && !HTMLMediaElement::isMediaStreamURL(eleme
nt->sourceURL().string())) | 58 if (element->isFullscreen() && !HTMLMediaElement::isMediaStreamURL(eleme
nt->sourceURL().string())) |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void GraphicsLayerTreeBuilder::rebuild(RenderLayer& layer, AncestorInfo info) | 64 void GraphicsLayerTreeBuilder::rebuild(Layer& layer, AncestorInfo info) |
| 65 { | 65 { |
| 66 // Make the layer compositing if necessary, and set up clipping and content
layers. | 66 // Make the layer compositing if necessary, and set up clipping and content
layers. |
| 67 // Note that we can only do work here that is independent of whether the des
cendant layers | 67 // Note that we can only do work here that is independent of whether the des
cendant layers |
| 68 // have been processed. computeCompositingRequirements() will already have d
one the paint invalidation if necessary. | 68 // have been processed. computeCompositingRequirements() will already have d
one the paint invalidation if necessary. |
| 69 | 69 |
| 70 layer.stackingNode()->updateLayerListsIfNeeded(); | 70 layer.stackingNode()->updateLayerListsIfNeeded(); |
| 71 | 71 |
| 72 const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); | 72 const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); |
| 73 CompositedLayerMapping* currentCompositedLayerMapping = layer.compositedLaye
rMapping(); | 73 CompositedLayerMapping* currentCompositedLayerMapping = layer.compositedLaye
rMapping(); |
| 74 | 74 |
| 75 // If this layer has a compositedLayerMapping, then that is where we place s
ubsequent children GraphicsLayers. | 75 // If this layer has a compositedLayerMapping, then that is where we place s
ubsequent children GraphicsLayers. |
| 76 // Otherwise children continue to append to the child list of the enclosing
layer. | 76 // Otherwise children continue to append to the child list of the enclosing
layer. |
| 77 GraphicsLayerVector layerChildren; | 77 GraphicsLayerVector layerChildren; |
| 78 AncestorInfo infoForChildren(info); | 78 AncestorInfo infoForChildren(info); |
| 79 if (hasCompositedLayerMapping) { | 79 if (hasCompositedLayerMapping) { |
| 80 infoForChildren.childLayersOfEnclosingCompositedLayer = &layerChildren; | 80 infoForChildren.childLayersOfEnclosingCompositedLayer = &layerChildren; |
| 81 infoForChildren.enclosingCompositedLayer = &layer; | 81 infoForChildren.enclosingCompositedLayer = &layer; |
| 82 } | 82 } |
| 83 | 83 |
| 84 #if ENABLE(ASSERT) | 84 #if ENABLE(ASSERT) |
| 85 LayerListMutationDetector mutationChecker(layer.stackingNode()); | 85 LayerListMutationDetector mutationChecker(layer.stackingNode()); |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 if (layer.stackingNode()->isStackingContext()) { | 88 if (layer.stackingNode()->isStackingContext()) { |
| 89 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), Negative
ZOrderChildren); | 89 LayerStackingNodeIterator iterator(*layer.stackingNode(), NegativeZOrder
Children); |
| 90 while (RenderLayerStackingNode* curNode = iterator.next()) | 90 while (LayerStackingNode* curNode = iterator.next()) |
| 91 rebuild(*curNode->layer(), infoForChildren); | 91 rebuild(*curNode->layer(), infoForChildren); |
| 92 | 92 |
| 93 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. | 93 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. |
| 94 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou
ndLayer()) | 94 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou
ndLayer()) |
| 95 infoForChildren.childLayersOfEnclosingCompositedLayer->append(curren
tCompositedLayerMapping->foregroundLayer()); | 95 infoForChildren.childLayersOfEnclosingCompositedLayer->append(curren
tCompositedLayerMapping->foregroundLayer()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowCh
ildren | PositiveZOrderChildren); | 98 LayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowChildren
| PositiveZOrderChildren); |
| 99 while (RenderLayerStackingNode* curNode = iterator.next()) | 99 while (LayerStackingNode* curNode = iterator.next()) |
| 100 rebuild(*curNode->layer(), infoForChildren); | 100 rebuild(*curNode->layer(), infoForChildren); |
| 101 | 101 |
| 102 if (hasCompositedLayerMapping) { | 102 if (hasCompositedLayerMapping) { |
| 103 bool parented = false; | 103 bool parented = false; |
| 104 if (layer.renderer()->isRenderPart()) | 104 if (layer.renderer()->isRenderPart()) |
| 105 parented = RenderLayerCompositor::parentFrameContentLayers(toRenderP
art(layer.renderer())); | 105 parented = LayerCompositor::parentFrameContentLayers(toRenderPart(la
yer.renderer())); |
| 106 | 106 |
| 107 if (!parented) | 107 if (!parented) |
| 108 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay
erChildren); | 108 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay
erChildren); |
| 109 | 109 |
| 110 // If the layer has a clipping layer the overflow controls layers will b
e siblings of the clipping layer. | 110 // If the layer has a clipping layer the overflow controls layers will b
e siblings of the clipping layer. |
| 111 // Otherwise, the overflow control layers are normal children. | 111 // Otherwise, the overflow control layers are normal children. |
| 112 // FIXME: Why isn't this handled in CLM updateInternalHierarchy? | 112 // FIXME: Why isn't this handled in CLM updateInternalHierarchy? |
| 113 if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompos
itedLayerMapping->hasScrollingLayer()) { | 113 if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompos
itedLayerMapping->hasScrollingLayer()) { |
| 114 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp
ing->layerForHorizontalScrollbar()) { | 114 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp
ing->layerForHorizontalScrollbar()) { |
| 115 overflowControlLayer->removeFromParent(); | 115 overflowControlLayer->removeFromParent(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 if (layer.scrollParent() | 134 if (layer.scrollParent() |
| 135 && layer.scrollParent()->hasCompositedLayerMapping() | 135 && layer.scrollParent()->hasCompositedLayerMapping() |
| 136 && layer.scrollParent()->compositedLayerMapping()->needsToReparentOverfl
owControls() | 136 && layer.scrollParent()->compositedLayerMapping()->needsToReparentOverfl
owControls() |
| 137 && layer.scrollParent()->scrollableArea()->topmostScrollChild() == &laye
r) | 137 && layer.scrollParent()->scrollableArea()->topmostScrollChild() == &laye
r) |
| 138 info.childLayersOfEnclosingCompositedLayer->append(layer.scrollParent()-
>compositedLayerMapping()->detachLayerForOverflowControls(*info.enclosingComposi
tedLayer)); | 138 info.childLayersOfEnclosingCompositedLayer->append(layer.scrollParent()-
>compositedLayerMapping()->detachLayerForOverflowControls(*info.enclosingComposi
tedLayer)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } | 141 } |
| OLD | NEW |