| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/rendering/compositing/CompositingPropertyUpdater.h" | |
| 7 | |
| 8 #include "core/rendering/RenderBlock.h" | |
| 9 #include "core/rendering/RenderLayer.h" | |
| 10 #include "core/rendering/compositing/CompositedLayerMapping.h" | |
| 11 | |
| 12 namespace WebCore { | |
| 13 | |
| 14 CompositingPropertyUpdater::CompositingPropertyUpdater(RenderLayer* rootRenderLa
yer) | |
| 15 : m_geometryMap(UseTransforms) | |
| 16 , m_rootRenderLayer(rootRenderLayer) | |
| 17 { | |
| 18 rootRenderLayer->updateDescendantDependentFlags(); | |
| 19 } | |
| 20 | |
| 21 CompositingPropertyUpdater::~CompositingPropertyUpdater() | |
| 22 { | |
| 23 } | |
| 24 | |
| 25 void CompositingPropertyUpdater::updateAncestorDependentProperties(RenderLayer*
layer, UpdateType updateType, AncestorInfo info) | |
| 26 { | |
| 27 if (!layer->childNeedsToUpdateAncestorDependantProperties() && updateType !=
ForceUpdate) | |
| 28 return; | |
| 29 | |
| 30 m_geometryMap.pushMappingsToAncestor(layer, layer->parent()); | |
| 31 | |
| 32 if (layer->hasCompositedLayerMapping()) | |
| 33 info.enclosingCompositedLayer = layer; | |
| 34 | |
| 35 if (layer->needsToUpdateAncestorDependentProperties()) { | |
| 36 if (info.enclosingCompositedLayer) | |
| 37 info.enclosingCompositedLayer->compositedLayerMapping()->setNeedsGra
phicsLayerUpdate(); | |
| 38 updateType = ForceUpdate; | |
| 39 } | |
| 40 | |
| 41 if (updateType == ForceUpdate) { | |
| 42 RenderLayer::AncestorDependentProperties properties; | |
| 43 | |
| 44 if (!layer->isRootLayer()) { | |
| 45 properties.clippedAbsoluteBoundingBox = enclosingIntRect(m_geometryM
ap.absoluteRect(layer->boundingBoxForCompositingOverlapTest())); | |
| 46 // FIXME: Setting the absBounds to 1x1 instead of 0x0 makes very lit
tle sense, | |
| 47 // but removing this code will make JSGameBench sad. | |
| 48 // See https://codereview.chromium.org/13912020/ | |
| 49 if (properties.clippedAbsoluteBoundingBox.isEmpty()) | |
| 50 properties.clippedAbsoluteBoundingBox.setSize(IntSize(1, 1)); | |
| 51 | |
| 52 IntRect clipRect = pixelSnappedIntRect(layer->clipper().backgroundCl
ipRect(ClipRectsContext(m_rootRenderLayer, AbsoluteClipRects)).rect()); | |
| 53 properties.clippedAbsoluteBoundingBox.intersect(clipRect); | |
| 54 | |
| 55 const RenderLayer* parent = layer->parent(); | |
| 56 properties.opacityAncestor = parent->isTransparent() ? parent : pare
nt->ancestorDependentProperties().opacityAncestor; | |
| 57 properties.transformAncestor = parent->hasTransform() ? parent : par
ent->ancestorDependentProperties().transformAncestor; | |
| 58 properties.filterAncestor = parent->hasFilter() ? parent : parent->a
ncestorDependentProperties().filterAncestor; | |
| 59 | |
| 60 if (layer->renderer()->isOutOfFlowPositioned() && info.ancestorScrol
lingLayer && !layer->subtreeIsInvisible()) { | |
| 61 const RenderObject* container = layer->renderer()->containingBlo
ck(); | |
| 62 const RenderObject* scroller = info.ancestorScrollingLayer->rend
erer(); | |
| 63 properties.isUnclippedDescendant = scroller != container && scro
ller->isDescendantOf(container); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 layer->updateAncestorDependentProperties(properties); | |
| 68 } | |
| 69 | |
| 70 if (layer->scrollsOverflow()) | |
| 71 info.ancestorScrollingLayer = layer; | |
| 72 | |
| 73 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib
ling()) | |
| 74 updateAncestorDependentProperties(child, updateType, info); | |
| 75 | |
| 76 m_geometryMap.popMappingsToAncestor(layer->parent()); | |
| 77 | |
| 78 layer->clearChildNeedsToUpdateAncestorDependantProperties(); | |
| 79 } | |
| 80 | |
| 81 #if !ASSERT_DISABLED | |
| 82 | |
| 83 void CompositingPropertyUpdater::assertNeedsToUpdateAncestorDependantPropertiesB
itsCleared(RenderLayer* layer) | |
| 84 { | |
| 85 ASSERT(!layer->childNeedsToUpdateAncestorDependantProperties()); | |
| 86 ASSERT(!layer->needsToUpdateAncestorDependentProperties()); | |
| 87 | |
| 88 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib
ling()) | |
| 89 assertNeedsToUpdateAncestorDependantPropertiesBitsCleared(child); | |
| 90 } | |
| 91 | |
| 92 #endif | |
| 93 | |
| 94 } // namespace WebCore | |
| OLD | NEW |