void GraphicsLayerUpdater::updateRecursive(RenderLayer& layer, UpdateType updateType, const UpdateContext& context, Vector<RenderLayer*>& layersNeedingPaintInvalidation)
{
    if (layer.hasCompositedLayerMapping()) {
        CompositedLayerMapping* mapping = layer.compositedLayerMapping();

        if (updateType == ForceUpdate || mapping->needsGraphicsLayerUpdate()) {
            const RenderLayer* compositingContainer = context.compositingContainer(layer);
            ASSERT(compositingContainer == layer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf));

            if (mapping->updateGraphicsLayerConfiguration())
                m_needsRebuildTree = true;

            mapping->updateGraphicsLayerGeometry(compositingContainer, context.compositingStackingContext(), layersNeedingPaintInvalidation);

            if (mapping->hasUnpositionedOverflowControlsLayers())
                layer.scrollableArea()->positionOverflowControls(IntSize());

            updateType = mapping->updateTypeForChildren(updateType);
            mapping->clearNeedsGraphicsLayerUpdate();
        }
    }

    UpdateContext childContext(context, layer);
    for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibling())
        updateRecursive(*child, updateType, childContext, layersNeedingPaintInvalidation);
}
void GraphicsLayerUpdater::update(RenderLayer& layer, UpdateType updateType, const UpdateContext& context)
{
    if (layer.hasCompositedLayerMapping()) {
        CompositedLayerMappingPtr mapping = layer.compositedLayerMapping();

        const RenderLayer* compositingContainer = context.compositingContainer(layer);
        ASSERT(compositingContainer == layer.ancestorCompositingLayer());
        if (mapping->updateRequiresOwnBackingStoreForAncestorReasons(compositingContainer))
            updateType = ForceUpdate;

        // Note carefully: here we assume that the compositing state of all descendants have been updated already,
        // so it is legitimate to compute and cache the composited bounds for this layer.
        mapping->updateCompositedBounds(updateType);

        if (RenderLayerReflectionInfo* reflection = layer.reflectionInfo()) {
            if (reflection->reflectionLayer()->hasCompositedLayerMapping())
                reflection->reflectionLayer()->compositedLayerMapping()->updateCompositedBounds(ForceUpdate);
        }

        if (mapping->updateGraphicsLayerConfiguration(updateType))
            m_needsRebuildTree = true;

        mapping->updateGraphicsLayerGeometry(updateType, compositingContainer);

        updateType = mapping->updateTypeForChildren(updateType);
        mapping->clearNeedsGraphicsLayerUpdate();

        if (!layer.parent())
            layer.compositor()->updateRootLayerPosition();

        if (mapping->hasUnpositionedOverflowControlsLayers())
            layer.scrollableArea()->positionOverflowControls();
    }

    UpdateContext childContext(context, layer);
    for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibling())
        update(*child, updateType, childContext);
}