Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderLayerCompositor.cpp
index b86537e..137d720 100644 (file)
 #include "core/animation/DocumentAnimations.h"
 #include "core/dom/FullscreenElementStack.h"
 #include "core/dom/NodeList.h"
+#include "core/frame/DeprecatedScheduleStyleRecalcDuringCompositingUpdate.h"
+#include "core/frame/Frame.h"
+#include "core/frame/FrameView.h"
+#include "core/frame/Settings.h"
 #include "core/html/HTMLCanvasElement.h"
 #include "core/html/HTMLIFrameElement.h"
 #include "core/html/HTMLMediaElement.h"
 #include "core/html/canvas/CanvasRenderingContext.h"
 #include "core/inspector/InspectorInstrumentation.h"
 #include "core/page/Chrome.h"
-#include "core/frame/Frame.h"
-#include "core/frame/FrameView.h"
 #include "core/page/Page.h"
-#include "core/frame/Settings.h"
-#include "core/frame/animation/AnimationController.h"
 #include "core/page/scrolling/ScrollingConstraints.h"
 #include "core/page/scrolling/ScrollingCoordinator.h"
 #include "core/rendering/CompositedLayerMapping.h"
@@ -292,25 +292,11 @@ bool RenderLayerCompositor::canRender3DTransforms() const
 
 void RenderLayerCompositor::setCompositingLayersNeedRebuild(bool needRebuild)
 {
+    // FIXME: crbug,com/332248 ideally this could be merged with setNeedsCompositingUpdate().
     if (inCompositingMode())
         m_compositingLayersNeedRebuild = needRebuild;
-}
-
-void RenderLayerCompositor::didChangeVisibleRect()
-{
-    GraphicsLayer* rootLayer = rootGraphicsLayer();
-    if (!rootLayer)
-        return;
-
-    FrameView* frameView = m_renderView ? m_renderView->frameView() : 0;
-    if (!frameView)
-        return;
 
-    IntRect visibleRect = m_containerLayer ? IntRect(IntPoint(), frameView->contentsSize()) : frameView->visibleContentRect();
-    if (rootLayer->visibleRectChangeRequiresFlush(visibleRect)) {
-        if (Page* page = this->page())
-            page->chrome().client().scheduleCompositingLayerFlush();
-    }
+    m_renderView->frameView()->scheduleAnimation();
 }
 
 void RenderLayerCompositor::updateCompositingRequirementsState()
@@ -398,10 +384,7 @@ void RenderLayerCompositor::setNeedsCompositingUpdate(CompositingUpdateType upda
         break;
     }
 
-    // FIXME: some senior devs are suggesting that we need to always schedule a frame here.
-    // but we do seem to reach this point in code when frames are unnecessary and
-    // we need to resolve those instances before initiating a frame here, otherwise
-    // performance will regress by forcing unnecessary frames.
+    m_renderView->frameView()->scheduleAnimation();
 }
 
 void RenderLayerCompositor::updateCompositingLayers()
@@ -413,9 +396,13 @@ void RenderLayerCompositor::updateCompositingLayers()
     // necessary updates.
 
     // Avoid updating the layers with old values. Compositing layers will be updated after the layout is finished.
+    // FIXME: Can we assert that we never return here?
     if (m_renderView->needsLayout())
         return;
 
+    lifecycle().advanceTo(DocumentLifecycle::InCompositingUpdate);
+    DocumentLifecycle::Scope lifecycleScope(lifecycle(), DocumentLifecycle::CompositingClean);
+
     if (isMainFrame() && m_renderView->frameView())
         finishCompositingUpdateForFrameTree(&m_renderView->frameView()->frame());
 
@@ -425,8 +412,6 @@ void RenderLayerCompositor::updateCompositingLayers()
     if (!m_needsToRecomputeCompositingRequirements && !m_compositing)
         return;
 
-    AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame().animation());
-
     TemporaryChange<bool> postLayoutChange(m_inPostLayoutUpdate, true);
 
     bool needCompositingRequirementsUpdate = m_needsToRecomputeCompositingRequirements;
@@ -556,45 +541,46 @@ void RenderLayerCompositor::removeOutOfFlowPositionedLayer(RenderLayer* layer)
 bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* layer)
 {
     bool compositedLayerMappingChanged = false;
-    RenderLayer::ViewportConstrainedNotCompositedReason viewportConstrainedNotCompositedReason = RenderLayer::NoNotCompositedReason;
-    requiresCompositingForPosition(layer->renderer(), layer, &viewportConstrainedNotCompositedReason);
+    bool nonCompositedReasonChanged = updateLayerIfViewportConstrained(layer);
+    CompositingStateTransitionType compositedLayerUpdate = computeCompositedLayerUpdate(layer);
 
     // FIXME: It would be nice to directly use the layer's compositing reason,
     // but allocateOrClearCompositedLayerMapping also gets called without having updated compositing
     // requirements fully.
-    if (needsOwnBacking(layer)) {
+    switch (compositedLayerUpdate) {
+    case AllocateOwnCompositedLayerMapping:
+        ASSERT(!layer->hasCompositedLayerMapping());
         enableCompositingMode();
 
-        if (!layer->hasCompositedLayerMapping()) {
-            // If we need to repaint, do so before allocating the compositedLayerMapping
-            repaintOnCompositingChange(layer);
+        // If we need to repaint, do so before allocating the compositedLayerMapping
+        repaintOnCompositingChange(layer);
+        layer->ensureCompositedLayerMapping();
+        compositedLayerMappingChanged = true;
 
-            layer->ensureCompositedLayerMapping();
-            compositedLayerMappingChanged = true;
-
-            // At this time, the ScrollingCooridnator only supports the top-level frame.
-            if (layer->isRootLayer() && isMainFrame()) {
-                if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
-                    scrollingCoordinator->frameViewRootLayerDidChange(m_renderView->frameView());
-            }
-
-            // If this layer was previously squashed, we need to remove its reference to a groupedMapping right away, so
-            // that computing repaint rects will know the layer's correct compositingState.
-            // FIXME: do we need to also remove the layer from it's location in the squashing list of its groupedMapping?
-            // Need to create a test where a squashed layer pops into compositing. And also to cover all other
-            // sorts of compositingState transitions.
-            layer->setGroupedMapping(0);
-
-            // FIXME: it seems premature to compute this before all compositing state has been updated?
-            // This layer and all of its descendants have cached repaints rects that are relative to
-            // the repaint container, so change when compositing changes; we need to update them here.
-            if (layer->parent())
-                layer->repainter().computeRepaintRectsIncludingDescendants();
+        // At this time, the ScrollingCooridnator only supports the top-level frame.
+        if (layer->isRootLayer() && isMainFrame()) {
+            if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
+                scrollingCoordinator->frameViewRootLayerDidChange(m_renderView->frameView());
         }
 
-        if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForIntrinsicReasons())
-            compositedLayerMappingChanged = true;
-    } else {
+        // If this layer was previously squashed, we need to remove its reference to a groupedMapping right away, so
+        // that computing repaint rects will know the layer's correct compositingState.
+        // FIXME: do we need to also remove the layer from it's location in the squashing list of its groupedMapping?
+        // Need to create a test where a squashed layer pops into compositing. And also to cover all other
+        // sorts of compositingState transitions.
+        layer->setLostGroupedMapping(false);
+        layer->setGroupedMapping(0);
+
+        // FIXME: it seems premature to compute this before all compositing state has been updated?
+        // This layer and all of its descendants have cached repaints rects that are relative to
+        // the repaint container, so change when compositing changes; we need to update them here.
+        if (layer->parent())
+            layer->repainter().computeRepaintRectsIncludingDescendants();
+
+        break;
+    case RemoveOwnCompositedLayerMapping:
+    // PutInSquashingLayer means you might have to remove the composited layer mapping first.
+    case PutInSquashingLayer:
         if (layer->hasCompositedLayerMapping()) {
             // If we're removing the compositedLayerMapping from a reflection, clear the source GraphicsLayer's pointer to
             // its replica GraphicsLayer. In practice this should never happen because reflectee and reflection
@@ -619,8 +605,17 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
             // If we need to repaint, do so now that we've removed the compositedLayerMapping
             repaintOnCompositingChange(layer);
         }
+
+        break;
+    case RemoveFromSquashingLayer:
+    case NoCompositingStateChange:
+        // Do nothing.
+        break;
     }
 
+    if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForIntrinsicReasons())
+        compositedLayerMappingChanged = true;
+
     if (compositedLayerMappingChanged && layer->renderer()->isRenderPart()) {
         RenderLayerCompositor* innerCompositor = frameContentsCompositor(toRenderPart(layer->renderer()));
         if (innerCompositor && innerCompositor->inCompositingMode())
@@ -632,37 +627,143 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
 
     // If a fixed position layer gained/lost a compositedLayerMapping or the reason not compositing it changed,
     // the scrolling coordinator needs to recalculate whether it can do fast scrolling.
-    bool nonCompositedReasonChanged = false;
-    if (layer->renderer()->style()->position() == FixedPosition) {
-        if (layer->viewportConstrainedNotCompositedReason() != viewportConstrainedNotCompositedReason) {
-            layer->setViewportConstrainedNotCompositedReason(viewportConstrainedNotCompositedReason);
-            nonCompositedReasonChanged = true;
+    if (compositedLayerMappingChanged || nonCompositedReasonChanged) {
+        if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
+            scrollingCoordinator->frameViewFixedObjectsDidChange(m_renderView->frameView());
+    }
+
+    return compositedLayerMappingChanged || nonCompositedReasonChanged;
+}
+
+static IntPoint computeOffsetFromAbsolute(RenderLayer* layer)
+{
+    TransformState transformState(TransformState::ApplyTransformDirection, FloatPoint());
+    layer->renderer()->mapLocalToContainer(0, transformState, ApplyContainerFlip);
+    transformState.flatten();
+    return roundedIntPoint(transformState.lastPlanarPoint());
+}
+
+bool RenderLayerCompositor::updateSquashingAssignment(RenderLayer* layer, SquashingState& squashingState)
+{
+    CompositingStateTransitionType compositedLayerUpdate = computeCompositedLayerUpdate(layer);
+
+    // NOTE: In the future as we generalize this, the background of this layer may need to be assigned to a different backing than
+    // the squashed RenderLayer's own primary contents. This would happen when we have a composited negative z-index element that needs
+    // to paint on top of the background, but below the layer's main contents. For now, because we always composite layers
+    // when they have a composited negative z-index child, such layers will never need squashing so it is not yet an issue.
+    if (compositedLayerUpdate == PutInSquashingLayer) {
+        // A layer that is squashed with other layers cannot have its own CompositedLayerMapping.
+        ASSERT(!layer->hasCompositedLayerMapping());
+        ASSERT(squashingState.hasMostRecentMapping);
+
+        IntPoint offsetFromAbsoluteForSquashedLayer = computeOffsetFromAbsolute(layer);
+
+        IntSize offsetFromSquashingCLM(offsetFromAbsoluteForSquashedLayer.x() - squashingState.offsetFromAbsoluteForSquashingCLM.x(),
+            offsetFromAbsoluteForSquashedLayer.y() - squashingState.offsetFromAbsoluteForSquashingCLM.y());
+
+        bool changedSquashingLayer =
+            squashingState.mostRecentMapping->updateSquashingLayerAssignment(layer, offsetFromSquashingCLM, squashingState.nextSquashedLayerIndex);
+        squashingState.nextSquashedLayerIndex++;
+
+        if (!changedSquashingLayer)
+            return true;
+
+        layer->clipper().clearClipRectsIncludingDescendants();
+
+        // If we need to repaint, do so before allocating the layer to the squashing layer.
+        repaintOnCompositingChange(layer);
+
+        // FIXME: it seems premature to compute this before all compositing state has been updated?
+        // This layer and all of its descendants have cached repaints rects that are relative to
+        // the repaint container, so change when compositing changes; we need to update them here.
+
+        // FIXME: what's up with parent()?
+        if (layer->parent())
+            layer->repainter().computeRepaintRectsIncludingDescendants();
+
+        return true;
+    } else if (compositedLayerUpdate == RemoveFromSquashingLayer) {
+        layer->setGroupedMapping(0);
+
+        // This layer and all of its descendants have cached repaints rects that are relative to
+        // the repaint container, so change when compositing changes; we need to update them here.
+        layer->repainter().computeRepaintRectsIncludingDescendants();
+
+        // If we need to repaint, do so now that we've removed it from a squashed layer
+        repaintOnCompositingChange(layer);
+
+        layer->setLostGroupedMapping(false);
+        return true;
+    }
+    return false;
+}
+
+bool RenderLayerCompositor::updateLayerIfViewportConstrained(RenderLayer* layer)
+{
+    RenderLayer::ViewportConstrainedNotCompositedReason viewportConstrainedNotCompositedReason = RenderLayer::NoNotCompositedReason;
+    requiresCompositingForPosition(layer->renderer(), layer, &viewportConstrainedNotCompositedReason);
+
+    if (layer->viewportConstrainedNotCompositedReason() != viewportConstrainedNotCompositedReason) {
+        ASSERT(layer->renderer()->style()->position() == FixedPosition);
+
+        layer->setViewportConstrainedNotCompositedReason(viewportConstrainedNotCompositedReason);
+        return true;
+    }
+    return false;
+}
+
+RenderLayerCompositor::CompositingStateTransitionType RenderLayerCompositor::computeCompositedLayerUpdate(const RenderLayer* layer)
+{
+    CompositingStateTransitionType update = NoCompositingStateChange;
+    if (needsOwnBacking(layer)) {
+        if (!layer->hasCompositedLayerMapping()) {
+            update = AllocateOwnCompositedLayerMapping;
         }
-        if (compositedLayerMappingChanged || nonCompositedReasonChanged) {
-            if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
-                scrollingCoordinator->frameViewFixedObjectsDidChange(m_renderView->frameView());
+    } else {
+        if (layer->hasCompositedLayerMapping())
+            update = RemoveOwnCompositedLayerMapping;
+
+        if (layerSquashingEnabled()) {
+            if (requiresSquashing(layer->compositingReasons())) {
+                // We can't compute at this time whether the squashing layer update is a no-op,
+                // since that requires walking the render layer tree.
+                update = PutInSquashingLayer;
+            } else if (layer->groupedMapping() || layer->lostGroupedMapping()) {
+                update = RemoveFromSquashingLayer;
+            }
         }
     }
+    return update;
+}
 
-    return compositedLayerMappingChanged || nonCompositedReasonChanged;
+// These are temporary hacks to work around chicken-egg issues while we continue to refactor the compositing code.
+// See crbug.com/339892 for a list of tests that fail if this method is removed.
+void RenderLayerCompositor::applyUpdateLayerCompositingStateChickenEggHacks(RenderLayer* layer, CompositingStateTransitionType compositedLayerUpdate)
+{
+    if (compositedLayerUpdate != NoCompositingStateChange)
+        allocateOrClearCompositedLayerMapping(layer);
 }
 
-bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer)
+void RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer)
 {
     updateDirectCompositingReasons(layer);
-    bool layerChanged = allocateOrClearCompositedLayerMapping(layer);
+    CompositingStateTransitionType compositedLayerUpdate = computeCompositedLayerUpdate(layer);
 
-    if (layerSquashingEnabled()) {
-        // FIXME: this is not correct... info may be out of date and squashing returning true doesn't indicate that the layer changed
-        layerChanged = requiresSquashing(layer->compositingReasons());
+    if (compositedLayerUpdate != NoCompositingStateChange) {
+        setCompositingLayersNeedRebuild();
+        setNeedsToRecomputeCompositingRequirements();
     }
 
     // See if we need content or clipping layers. Methods called here should assume
     // that the compositing state of descendant layers has not been updated yet.
-    if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->updateGraphicsLayerConfiguration())
-        layerChanged = true;
+    if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->updateGraphicsLayerConfiguration()) {
+        setCompositingLayersNeedRebuild();
+    } else if (compositedLayerUpdate == NoCompositingStateChange) {
+        if (layer->compositingState() == PaintsIntoOwnBacking || layer->compositingState() == HasOwnBackingButPaintsIntoAncestor)
+            setCompositingLayersNeedRebuild();
+    }
 
-    return layerChanged;
+    applyUpdateLayerCompositingStateChickenEggHacks(layer, compositedLayerUpdate);
 }
 
 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer)
@@ -728,7 +829,13 @@ void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer*
         return;
 
     removeViewportConstrainedLayer(child);
-    repaintInCompositedAncestor(child, child->compositedLayerMapping()->compositedBounds());
+
+    {
+        // FIXME: This is called from within RenderLayer::removeChild, which is called from RenderObject::RemoveChild.
+        // There's no guarantee that compositor state is up to date.
+        DisableCompositingQueryAsserts disabler;
+        repaintInCompositedAncestor(child, child->compositedLayerMapping()->compositedBounds());
+    }
 
     setCompositingParent(child, 0);
     setCompositingLayersNeedRebuild();
@@ -761,7 +868,7 @@ void RenderLayerCompositor::addToOverlapMap(OverlapMap& overlapMap, RenderLayer*
         boundsComputed = true;
     }
 
-    IntRect clipRect = pixelSnappedIntRect(layer->clipper().backgroundClipRect(ClipRectsContext(rootRenderLayer(), 0, AbsoluteClipRects)).rect()); // FIXME: Incorrect for CSS regions.
+    IntRect clipRect = pixelSnappedIntRect(layer->clipper().backgroundClipRect(ClipRectsContext(rootRenderLayer(), AbsoluteClipRects)).rect());
     clipRect.intersect(layerBounds);
     overlapMap.add(layer, clipRect);
 }
@@ -1073,14 +1180,6 @@ void RenderLayerCompositor::SquashingState::updateSquashingStateForNewMapping(Co
     offsetFromAbsoluteForSquashingCLM = newOffsetFromAbsoluteForSquashingCLM;
 }
 
-static IntPoint computeOffsetFromAbsolute(RenderLayer* layer)
-{
-    TransformState transformState(TransformState::ApplyTransformDirection, FloatPoint());
-    layer->renderer()->mapLocalToContainer(0, transformState, ApplyContainerFlip);
-    transformState.flatten();
-    return roundedIntPoint(transformState.lastPlanarPoint());
-}
-
 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* updateRoot, bool& layersChanged)
 {
     SquashingState squashingState;
@@ -1089,61 +1188,30 @@ void RenderLayerCompositor::assignLayersToBackings(RenderLayer* updateRoot, bool
         squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squashingState.nextSquashedLayerIndex);
 }
 
+void RenderLayerCompositor::assignLayersToBackingsForReflectionLayer(RenderLayer* reflectionLayer, bool& layersChanged)
+{
+    if (computeCompositedLayerUpdate(reflectionLayer) != NoCompositingStateChange) {
+        layersChanged = true;
+        allocateOrClearCompositedLayerMapping(reflectionLayer);
+    }
+    updateDirectCompositingReasons(reflectionLayer);
+    if (reflectionLayer->hasCompositedLayerMapping())
+        reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfiguration();
+}
+
 void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, SquashingState& squashingState, bool& layersChanged)
 {
     if (allocateOrClearCompositedLayerMapping(layer))
         layersChanged = true;
 
-    if (layer->reflectionInfo() && updateLayerCompositingState(layer->reflectionInfo()->reflectionLayer()))
-        layersChanged = true;
+    // FIXME: special-casing reflection layers here is not right.
+    if (layer->reflectionInfo())
+        assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflectionLayer(), layersChanged);
 
     // Add this layer to a squashing backing if needed.
     if (layerSquashingEnabled()) {
-        // NOTE: In the future as we generalize this, the background of this layer may need to be assigned to a different backing than
-        // the squashed RenderLayer's own primary contents. This would happen when we have a composited negative z-index element that needs
-        // to paint on top of the background, but below the layer's main contents. For now, because we always composite layers
-        // when they have a composited negative z-index child, such layers will never need squashing so it is not yet an issue.
-        if (requiresSquashing(layer->compositingReasons())) {
-            // A layer that is squashed with other layers cannot have its own CompositedLayerMapping.
-            ASSERT(!layer->hasCompositedLayerMapping());
-            ASSERT(squashingState.hasMostRecentMapping);
-
-            IntPoint offsetFromAbsoluteForSquashedLayer = computeOffsetFromAbsolute(layer);
-
-            IntSize offsetFromSquashingCLM(offsetFromAbsoluteForSquashedLayer.x() - squashingState.offsetFromAbsoluteForSquashingCLM.x(),
-                offsetFromAbsoluteForSquashedLayer.y() - squashingState.offsetFromAbsoluteForSquashingCLM.y());
-
-            squashingState.mostRecentMapping->addRenderLayerToSquashingGraphicsLayer(layer, offsetFromSquashingCLM, squashingState.nextSquashedLayerIndex);
-            squashingState.nextSquashedLayerIndex++;
-
-            // FIXME: this can be false sometimes depending on what happens in addRenderLayerToSquashingGraphicsLayer, which should return a bool.
+        if (updateSquashingAssignment(layer, squashingState))
             layersChanged = true;
-
-            // FIXME: this should be conditioned on whether this layer actually changed status
-            layer->clipper().clearClipRectsIncludingDescendants();
-        } else {
-            if (layer->compositingState() == PaintsIntoGroupedBacking) {
-                // This scenario is a layer transitioning from squashed to not-squashed.
-                ASSERT(layer->groupedMapping());
-                layer->setGroupedMapping(0);
-                layer->setShouldInvalidateNextBacking(true);
-            }
-        }
-    }
-
-    // At this point, the layer's compositingState() is correct and indicates where this layer would paint into. Issue
-    // an invalidation if we needed to.
-    if (layer->shouldInvalidateNextBacking()) {
-        // FIXME: these should invalidate only the rect that needs to be invalidated, i.e. the layer's rect in the squashingLayer's space.
-        if (layer->compositingState() == PaintsIntoGroupedBacking && squashingState.mostRecentMapping->squashingLayer()) {
-            squashingState.mostRecentMapping->squashingLayer()->setNeedsDisplay();
-        } else {
-            RenderLayer* enclosingLayer = layer->enclosingCompositingLayerForRepaint(ExcludeSelf);
-            if (enclosingLayer->hasCompositedLayerMapping())
-                enclosingLayer->compositedLayerMapping()->setContentsNeedDisplay();
-        }
-
-        layer->setShouldInvalidateNextBacking(false);
     }
 
     if (layer->stackingNode()->isStackingContainer()) {
@@ -1238,6 +1306,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
     // have been processed. computeCompositingRequirements() will already have done the repaint if necessary.
 
     layer->stackingNode()->updateLayerListsIfNeeded();
+    layer->update3dRenderingContext();
 
     // Used for gathering UMA data about the effect on memory usage of promoting all layers
     // that have a webkit-transition on opacity or transform and intersect the viewport.
@@ -1375,15 +1444,6 @@ void RenderLayerCompositor::frameViewDidScroll()
     blink::Platform::current()->histogramEnumeration("Renderer.AcceleratedFixedRootBackground",
         ScrolledMainFrameBucket,
         AcceleratedFixedRootBackgroundHistogramMax);
-
-    if (!m_renderView->rootBackgroundIsEntirelyFixed())
-        return;
-
-    blink::Platform::current()->histogramEnumeration("Renderer.AcceleratedFixedRootBackground",
-        !!fixedRootBackgroundLayer()
-            ? ScrolledMainFrameWithAcceleratedFixedRootBackground
-            : ScrolledMainFrameWithUnacceleratedFixedRootBackground,
-        AcceleratedFixedRootBackgroundHistogramMax);
 }
 
 void RenderLayerCompositor::frameViewDidLayout()
@@ -1753,7 +1813,7 @@ bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const
     if (!computeClipRoot || computeClipRoot == layer)
         return false;
 
-    return layer->clipper().backgroundClipRect(ClipRectsContext(computeClipRoot, 0, TemporaryClipRects)).rect() != PaintInfo::infiniteRect(); // FIXME: Incorrect for CSS regions.
+    return layer->clipper().backgroundClipRect(ClipRectsContext(computeClipRoot, TemporaryClipRects)).rect() != PaintInfo::infiniteRect();
 }
 
 // Return true if the given layer is a stacking context and has compositing child
@@ -1880,9 +1940,6 @@ bool RenderLayerCompositor::requiresCompositingForAnimation(RenderObject* render
     if (!(m_compositingTriggers & ChromeClient::AnimationTrigger))
         return false;
 
-    if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled())
-        return renderer->animation().isRunningAcceleratableAnimationOnRenderer(renderer);
-
     return shouldCompositeForActiveAnimations(*renderer);
 }
 
@@ -2097,8 +2154,6 @@ bool RenderLayerCompositor::isRunningAcceleratedTransformAnimation(RenderObject*
 {
     if (!(m_compositingTriggers & ChromeClient::AnimationTrigger))
         return false;
-    if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled())
-        return renderer->animation().isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitTransform);
     return hasActiveAnimations(*renderer, CSSPropertyWebkitTransform);
 }
 
@@ -2432,9 +2487,12 @@ void RenderLayerCompositor::attachRootLayer(RootLayerAttachment attachment)
             break;
         }
         case RootLayerAttachedViaEnclosingFrame: {
+            HTMLFrameOwnerElement* ownerElement = m_renderView->document().ownerElement();
+            ASSERT(ownerElement);
+            DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerElement->document().lifecycle());
             // The layer will get hooked up via CompositedLayerMapping::updateGraphicsLayerConfiguration()
             // for the frame's renderer in the parent document.
-            m_renderView->document().ownerElement()->scheduleLayerUpdate();
+            ownerElement->scheduleLayerUpdate();
             break;
         }
     }
@@ -2456,8 +2514,10 @@ void RenderLayerCompositor::detachRootLayer()
         else
             m_rootContentLayer->removeFromParent();
 
-        if (HTMLFrameOwnerElement* ownerElement = m_renderView->document().ownerElement())
+        if (HTMLFrameOwnerElement* ownerElement = m_renderView->document().ownerElement()) {
+            DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerElement->document().lifecycle());
             ownerElement->scheduleLayerUpdate();
+        }
         break;
     }
     case RootLayerAttachedViaChromeClient: {
@@ -2496,14 +2556,21 @@ void RenderLayerCompositor::notifyIFramesOfCompositingChange()
     Frame& frame = m_renderView->frameView()->frame();
 
     for (Frame* child = frame.tree().firstChild(); child; child = child->tree().traverseNext(&frame)) {
-        if (child->document() && child->document()->ownerElement())
-            child->document()->ownerElement()->scheduleLayerUpdate();
+        if (!child->document())
+            continue; // FIXME: Can this happen?
+        if (HTMLFrameOwnerElement* ownerElement = child->document()->ownerElement()) {
+            DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerElement->document().lifecycle());
+            ownerElement->scheduleLayerUpdate();
+        }
     }
 
     // Compositing also affects the answer to RenderIFrame::requiresAcceleratedCompositing(), so
     // we need to schedule a style recalc in our parent document.
-    if (HTMLFrameOwnerElement* ownerElement = m_renderView->document().ownerElement())
+    if (HTMLFrameOwnerElement* ownerElement = m_renderView->document().ownerElement()) {
+        ownerElement->document().renderView()->compositor()->setNeedsToRecomputeCompositingRequirements();
+        DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerElement->document().lifecycle());
         ownerElement->scheduleLayerUpdate();
+    }
 }
 
 bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const
@@ -2634,6 +2701,11 @@ Page* RenderLayerCompositor::page() const
     return m_renderView->frameView()->frame().page();
 }
 
+DocumentLifecycle& RenderLayerCompositor::lifecycle() const
+{
+    return m_renderView->document().lifecycle();
+}
+
 String RenderLayerCompositor::debugName(const GraphicsLayer* graphicsLayer)
 {
     String name;