2011-01-19  Simon Fraser  <simon.fraser@apple.com>

        Reviewed by Sam Weinig.

        GraphicsLayers in subframes can get sync'd multiple times
        https://bugs.webkit.org/show_bug.cgi?id=52489

        Some cleanup that will work towards fixing this bug.

        Tested by existing iframe compositing tests.

        * WebCore.exp.in: syncCompositingStateRecursive()
        was renamed to syncCompositingStateIncludingSubframes().

        * page/FrameView.h:
        * page/FrameView.cpp:
        (WebCore::FrameView::syncCompositingStateForThisFrame): Some
        code cleanup: do all the word we need to do for this frame,
        including the needsLayout() check.
        (WebCore::FrameView::syncCompositingStateIncludingSubframes):
        This is no longer recursive; instead, it iterates over descendant
        frames via the frame tree, calling syncCompositingStateForThisFrame()
        on each Frame's view.

        * rendering/RenderLayerCompositor.h:
        (WebCore::RenderLayerCompositor::isFlushingLayers): Getter for the flag.
        * rendering/RenderLayerCompositor.cpp:
        (WebCore::RenderLayerCompositor::RenderLayerCompositor):
        (WebCore::RenderLayerCompositor::flushPendingLayerChanges): Maintain
        a flag to say if we're flushing, which allows us to assert on re-entrant flushes.
        (WebCore::RenderLayerCompositor::enclosingCompositorFlushingLayers):
        Add the ability to get the rootmost compositor that is in the middle
        of a flush.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76196 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderLayerCompositor.h b/Source/WebCore/rendering/RenderLayerCompositor.h
index fc36dca..32d64d3 100644
--- a/Source/WebCore/rendering/RenderLayerCompositor.h
+++ b/Source/WebCore/rendering/RenderLayerCompositor.h
@@ -88,6 +88,11 @@
     // at specific times.
     void scheduleLayerFlush();
     void flushPendingLayerChanges();
+    bool isFlushingLayers() const { return m_flushingLayers; }
+    
+    // flushPendingLayerChanges() flushes the entire GraphicsLayer tree, which can cross frame boundaries.
+    // This call returns the rootmost compositor that is being flushed (including self).
+    RenderLayerCompositor* enclosingCompositorFlushingLayers() const;
     
     // Rebuild the tree of compositing layers
     void updateCompositingLayers(CompositingUpdateType = CompositingUpdateAfterLayoutOrStyleChange, RenderLayer* updateRoot = 0);
@@ -266,6 +271,7 @@
 
     bool m_compositing;
     bool m_compositingLayersNeedRebuild;
+    bool m_flushingLayers;
 
     RootLayerAttachment m_rootLayerAttachment;