Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / compositing / CompositedLayerMapping.h
index 22a0d75..d6e83e1 100644 (file)
@@ -33,7 +33,7 @@
 #include "platform/graphics/GraphicsLayer.h"
 #include "platform/graphics/GraphicsLayerClient.h"
 
-namespace WebCore {
+namespace blink {
 
 class RenderLayerCompositor;
 
@@ -50,22 +50,7 @@ struct GraphicsLayerPaintInfo {
     IntSize offsetFromRenderer;
     bool offsetFromRendererSet;
 
-    LayoutSize subpixelAccumulation;
-
-    GraphicsLayerPaintingPhase paintingPhase;
-
-    bool isBackgroundLayer;
-
-    GraphicsLayerPaintInfo() : renderLayer(0), offsetFromRendererSet(false), isBackgroundLayer(false) { }
-
-    bool isEquivalentForSquashing(const GraphicsLayerPaintInfo& other)
-    {
-        // FIXME: offsetFromRenderer and compositedBounds should not be checked here, because
-        // they are not yet fixed at the time this function is used.
-        return renderLayer == other.renderLayer
-            && paintingPhase == other.paintingPhase
-            && isBackgroundLayer == other.isBackgroundLayer;
-    }
+    GraphicsLayerPaintInfo() : renderLayer(0), offsetFromRendererSet(false) { }
 };
 
 enum GraphicsLayerUpdateScope {
@@ -89,11 +74,8 @@ public:
 
     RenderLayer& owningLayer() const { return m_owningLayer; }
 
-    // Returns true if layer configuration changed.
-    bool updateGraphicsLayerConfiguration(GraphicsLayerUpdater::UpdateType);
-    // Update graphics layer position and bounds.
-
-    void updateGraphicsLayerGeometry(GraphicsLayerUpdater::UpdateType, const RenderLayer* compositingContainer, Vector<RenderLayer*>& layersNeedingPaintInvalidation);
+    bool updateGraphicsLayerConfiguration();
+    void updateGraphicsLayerGeometry(const RenderLayer* compositingContainer, const RenderLayer* compositingStackingContext, Vector<RenderLayer*>& layersNeedingPaintInvalidation);
 
     // Update whether layer needs blending.
     void updateContentsOpaque();
@@ -127,8 +109,6 @@ public:
 
     GraphicsLayer* parentForSublayers() const;
     GraphicsLayer* childForSuperlayers() const;
-    // localRootForOwningLayer does not include the m_squashingContainmentLayer, which is technically not associated with this CLM's owning layer.
-    GraphicsLayer* localRootForOwningLayer() const;
 
     GraphicsLayer* childTransformLayer() const { return m_childTransformLayer.get(); }
 
@@ -153,14 +133,14 @@ public:
     void setSquashingContentsNeedDisplay();
     void setContentsNeedDisplay();
     // r is in the coordinate space of the layer's render object
-    void setContentsNeedDisplayInRect(const IntRect&);
+    void setContentsNeedDisplayInRect(const LayoutRect&);
 
     // Notification from the renderer that its content changed.
     void contentChanged(ContentChangeType);
 
     LayoutRect compositedBounds() const { return m_compositedBounds; }
     IntRect pixelSnappedCompositedBounds() const;
-    void updateCompositedBounds(GraphicsLayerUpdater::UpdateType);
+    void updateCompositedBounds();
 
     void positionOverflowControlsLayers(const IntSize& offsetFromRoot);
     bool hasUnpositionedOverflowControlsLayers() const;
@@ -176,11 +156,9 @@ public:
     // GraphicsLayerClient interface
     virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTime) OVERRIDE;
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clip) OVERRIDE;
-    virtual bool isTrackingRepaints() const OVERRIDE;
-
-    PassOwnPtr<Vector<FloatRect> > collectTrackedRepaintRects() const;
+    virtual bool isTrackingPaintInvalidations() const OVERRIDE;
 
-#ifndef NDEBUG
+#if ENABLE(ASSERT)
     virtual void verifyNotPainting() OVERRIDE;
 #endif
 
@@ -190,18 +168,29 @@ public:
     GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
     GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
 
+    // Returns true if the overflow controls cannot be positioned within this
+    // CLM's internal hierarchy without incorrectly stacking under some
+    // scrolling content. If this returns true, these controls must be
+    // repositioned in the graphics layer tree to ensure that they stack above
+    // scrolling content.
+    bool needsToReparentOverflowControls() const;
+
+    // Removes the overflow controls host layer from its parent and positions it
+    // so that it can be inserted as a sibling to this CLM without changing
+    // position.
+    GraphicsLayer* detachLayerForOverflowControls(const RenderLayer& enclosingLayer);
+
     void updateFilters(const RenderStyle*);
-    bool canCompositeFilters() const { return m_canCompositeFilters; }
 
-    void setBlendMode(blink::WebBlendMode);
+    void setBlendMode(WebBlendMode);
 
+    bool needsGraphicsLayerUpdate() { return m_pendingUpdateScope > GraphicsLayerUpdateNone; }
     void setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateScope scope) { m_pendingUpdateScope = std::max(static_cast<GraphicsLayerUpdateScope>(m_pendingUpdateScope), scope); }
     void clearNeedsGraphicsLayerUpdate() { m_pendingUpdateScope = GraphicsLayerUpdateNone; }
 
-    bool shouldUpdateGraphicsLayer(GraphicsLayerUpdater::UpdateType updateType) const { return m_pendingUpdateScope > GraphicsLayerUpdateNone || updateType == GraphicsLayerUpdater::ForceUpdate; }
     GraphicsLayerUpdater::UpdateType updateTypeForChildren(GraphicsLayerUpdater::UpdateType) const;
 
-#if ASSERT_ENABLED
+#if ENABLE(ASSERT)
     void assertNeedsToUpdateGraphicsLayerBitsCleared() {  ASSERT(m_pendingUpdateScope == GraphicsLayerUpdateNone); }
 #endif
 
@@ -227,6 +216,7 @@ private:
     void updateSquashingLayerGeometry(const LayoutPoint& offsetFromCompositedAncestor, const IntPoint& graphicsLayerParentLocation, const RenderLayer& referenceLayer, Vector<GraphicsLayerPaintInfo>& layers, GraphicsLayer*, LayoutPoint* offsetFromTransformedAncestor, Vector<RenderLayer*>& layersNeedingPaintInvalidation);
     void updateMainGraphicsLayerGeometry(const IntRect& relativeCompositingBounds, const IntRect& localCompositingBounds, IntPoint& graphicsLayerParentLocation);
     void updateAncestorClippingLayerGeometry(const RenderLayer* compositingContainer, const IntPoint& snappedOffsetFromCompositedAncestor, IntPoint& graphicsLayerParentLocation);
+    void updateOverflowControlsHostLayerGeometry(const RenderLayer* compositingStackingContext);
     void updateChildContainmentLayerGeometry(const IntRect& clippingBox, const IntRect& localCompositingBounds);
     void updateChildTransformLayerGeometry();
     void updateMaskLayerGeometry();
@@ -250,7 +240,7 @@ private:
     void updatePaintingPhases();
     bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip);
     bool updateChildTransformLayer(bool needsChildTransformLayer);
-    bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer);
+    bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer, bool needsAncestorClip);
     bool updateForegroundLayer(bool needsForegroundLayer);
     bool updateBackgroundLayer(bool needsBackgroundLayer);
     bool updateMaskLayer(bool needsMaskLayer);
@@ -260,7 +250,7 @@ private:
     bool requiresScrollCornerLayer() const { return m_owningLayer.scrollableArea() && !m_owningLayer.scrollableArea()->scrollCornerAndResizerRect().isEmpty(); }
     bool updateScrollingLayers(bool scrollingLayers);
     void updateScrollParent(RenderLayer*);
-    void updateClipParent(RenderLayer*);
+    void updateClipParent();
     bool updateSquashingLayers(bool needsSquashingLayers);
     void updateDrawsContent();
     void updateChildrenTransform();
@@ -301,9 +291,7 @@ private:
 
     static bool hasVisibleNonCompositingDescendant(RenderLayer* parent);
 
-    void paintsIntoCompositedAncestorChanged();
-
-    void doPaintTask(GraphicsLayerPaintInfo&, GraphicsContext*, const IntRect& clip);
+    void doPaintTask(const GraphicsLayerPaintInfo&, const PaintLayerFlags&, GraphicsContext*, const IntRect& clip);
 
     // Computes the background clip rect for the given squashed layer, up to any containing layer that is squashed into the
     // same squashing layer and contains this squashed layer's clipping ancestor.
@@ -312,6 +300,10 @@ private:
     // FIXME: unify this code with the code that sets up m_ancestorClippingLayer. They are doing very similar things.
     static IntRect localClipRectForSquashedLayer(const RenderLayer& referenceLayer, const GraphicsLayerPaintInfo&,  const Vector<GraphicsLayerPaintInfo>& layers);
 
+    // Return true if |m_owningLayer|'s compositing ancestor is not a descendant (inclusive) of the
+    // clipping container for |m_owningLayer|.
+    bool owningLayerClippedByLayerNotAboveCompositedAncestor();
+
     RenderLayer& m_owningLayer;
 
     // The hierarchy of layers that is maintained by the CompositedLayerMapping looks like this:
@@ -319,8 +311,14 @@ private:
     //  + m_ancestorClippingLayer [OPTIONAL]
     //     + m_graphicsLayer
     //        + m_childContainmentLayer [OPTIONAL] <-OR-> m_scrollingLayer [OPTIONAL] <-OR-> m_childTransformLayer
-    //                                                     + m_scrollingContentsLayer [Present iff m_scrollingLayer is present]
-    //                                                        + m_scrollingBlockSelectionLayer [Present iff m_scrollingLayer is present]
+    //        |                                            + m_scrollingContentsLayer [Present iff m_scrollingLayer is present]
+    //        |                                               + m_scrollingBlockSelectionLayer [Present iff m_scrollingLayer is present]
+    //        |
+    //        + m_overflowControlsClippingLayer [OPTIONAL] // *The overflow controls may need to be repositioned in the
+    //          + m_overflowControlsHostLayer              //  graphics layer tree by the RLC to ensure that they stack
+    //            + m_layerForVerticalScrollbar            //  above scrolling content.
+    //            + m_layerForHorizontalScrollbar
+    //            + m_layerForScrollCorner
     //
     // We need an ancestor clipping layer if our clipping ancestor is not our ancestor in the
     // clipping tree. Here's what that might look like.
@@ -377,7 +375,7 @@ private:
     //         + root content layer
     //
     // With the hierarchy set up like this, the root content layer is able to scroll without affecting
-    // the background layer (or repainting).
+    // the background layer (or paint invalidation).
     OwnPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
     OwnPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
 
@@ -385,6 +383,18 @@ private:
     OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
     OwnPtr<GraphicsLayer> m_layerForScrollCorner;
 
+    // This layer exists to simplify the reparenting of overflow control that is occasionally required
+    // to ensure that scrollbars appear above scrolling content.
+    OwnPtr<GraphicsLayer> m_overflowControlsHostLayer;
+
+    // The reparented overflow controls sometimes need to be clipped by a non-ancestor. In just the same
+    // way we need an ancestor clipping layer to clip this CLM's internal hierarchy, we add another layer
+    // to clip the overflow controls. It would be possible to make m_overflowControlsHostLayer be
+    // responsible for applying this clip, but that could require repositioning all of the overflow
+    // controls since the this clip may apply an offset. By using a separate layer, the overflow controls
+    // can remain ignorant of the layers above them and still work correctly.
+    OwnPtr<GraphicsLayer> m_overflowControlsClippingLayer;
+
     // A squashing CLM has two possible squashing-related structures.
     //
     // If m_ancestorClippingLayer is present:
@@ -398,6 +408,9 @@ private:
     // m_squashingContainmentLayer
     //   + m_graphicsLayer
     //   + m_squashingLayer
+    //
+    // Stacking children of a squashed layer receive graphics layers that are parented to the compositd ancestor of the
+    // squashed layer (i.e. nearest enclosing composited layer that is not squashed).
     OwnPtr<GraphicsLayer> m_squashingContainmentLayer; // Only used if any squashed layers exist and m_squashingContainmentLayer is not present, to contain the squashed layers as siblings to the rest of the GraphicsLayer tree chunk.
     OwnPtr<GraphicsLayer> m_squashingLayer; // Only used if any squashed layers exist, this is the backing that squashed layers paint into.
     Vector<GraphicsLayerPaintInfo> m_squashedLayers;
@@ -409,11 +422,10 @@ private:
     unsigned m_isMainFrameRenderViewLayer : 1;
     unsigned m_requiresOwnBackingStoreForIntrinsicReasons : 1;
     unsigned m_requiresOwnBackingStoreForAncestorReasons : 1;
-    unsigned m_canCompositeFilters : 1;
     unsigned m_backgroundLayerPaintsFixedRootBackground : 1;
     unsigned m_scrollingContentsAreEmpty : 1;
 };
 
-} // namespace WebCore
+} // namespace blink
 
 #endif // CompositedLayerMapping_h