Source/core/frame/PinchViewport.cpp
// Modifies the top of the graphics layer tree to add layers needed to support
// the inner/outer viewport fixed-position model for pinch zoom. When finished,
// the tree will look like this (with * denoting added layers):
//
// *rootTransformLayer
//  +- *innerViewportContainerLayer (fixed pos container)
//      +- *pageScaleLayer
//  |       +- *innerViewportScrollLayer
//  |           +-- overflowControlsHostLayer (root layer)
//  |               +-- outerViewportContainerLayer (fixed pos container) [frame container layer in RenderLayerCompositor]
//  |               |   +-- outerViewportScrollLayer [frame scroll layer in RenderLayerCompositor]
//  |               |       +-- content layers ...
//  |               +-- horizontal ScrollbarLayer (non-overlay)
//  |               +-- verticalScrollbarLayer (non-overlay)
//  |               +-- scroll corner (non-overlay)
//  +- *horizontalScrollbarLayer (overlay)
//  +- *verticalScrollbarLayer (overlay)
//
Modifies the top of the graphics layer tree to add layers needed to support
the inner/outer viewport fixed-position model for pinch zoom. When finished,
the tree will look like this (with * denoting added layers).


Modifies the top of the graphics layer tree to add layers needed to support the inner / outer viewport fixed - position model for pinch zoom . When finished the tree will look like this ( with * denoting added layers ) .
void PinchViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, GraphicsLayerFactory* graphicsLayerFactory)
{
    TRACE_EVENT1("webkit", "PinchViewport::attachToLayerTree", "currentLayerTreeRoot", (bool)currentLayerTreeRoot);
    if (!currentLayerTreeRoot) {
        m_innerViewportScrollLayer->removeAllChildren();
        return;
    }
    if (currentLayerTreeRoot->parent() && currentLayerTreeRoot->parent() == m_innerViewportScrollLayer)
        return;
    if (!m_innerViewportScrollLayer) {
        ASSERT(!m_overlayScrollbarHorizontal
            && !m_overlayScrollbarVertical
            && !m_pageScaleLayer
            && !m_innerViewportContainerLayer);
        m_rootTransformLayer = GraphicsLayer::create(graphicsLayerFactory, this);
        m_innerViewportContainerLayer = GraphicsLayer::create(graphicsLayerFactory, this);
        m_pageScaleLayer = GraphicsLayer::create(graphicsLayerFactory, this);
        m_innerViewportScrollLayer = GraphicsLayer::create(graphicsLayerFactory, this);
        m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactory, this);
        m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory, this);
        WebCore::ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator();
        ASSERT(coordinator);
        coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportScrollLayer.get(), true);
        m_innerViewportContainerLayer->setMasksToBounds(m_frameHost.settings().mainFrameClipsContent());
        m_innerViewportContainerLayer->setSize(m_size);
        m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer(
            m_innerViewportContainerLayer->platformLayer());
        m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, true);
        m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get());
        m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get());
        m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get());
        m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get());
        m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get());
        coordinator->scrollableAreaScrollLayerDidChange(this);
        setupScrollbar(WebScrollbar::Horizontal);
        setupScrollbar(WebScrollbar::Vertical);
    }
    m_innerViewportScrollLayer->removeAllChildren();
    m_innerViewportScrollLayer->addChild(currentLayerTreeRoot);
}
void PinchViewport :: attachToLayerTree ( GraphicsLayer * currentLayerTreeRoot , GraphicsLayerFactory * graphicsLayerFactory ) { TRACE_EVENT1 ( " " , " " , " " , ( bool ) currentLayerTreeRoot ) ; if ( ! currentLayerTreeRoot ) { m_innerViewportScrollLayer -> removeAllChildren ( ) ; return ; } if ( currentLayerTreeRoot -> parent ( ) && currentLayerTreeRoot -> parent ( ) == m_innerViewportScrollLayer ) return ; if ( ! m_innerViewportScrollLayer ) { ASSERT ( ! m_overlayScrollbarHorizontal && ! m_overlayScrollbarVertical && ! m_pageScaleLayer && ! m_innerViewportContainerLayer ) ; m_rootTransformLayer = GraphicsLayer :: create ( graphicsLayerFactory , this ) ; m_innerViewportContainerLayer = GraphicsLayer :: create ( graphicsLayerFactory , this ) ; m_pageScaleLayer = GraphicsLayer :: create ( graphicsLayerFactory , this ) ; m_innerViewportScrollLayer = GraphicsLayer :: create ( graphicsLayerFactory , this ) ; m_overlayScrollbarHorizontal = GraphicsLayer :: create ( graphicsLayerFactory , this ) ; m_overlayScrollbarVertical = GraphicsLayer :: create ( graphicsLayerFactory , this ) ; WebCore :: ScrollingCoordinator * coordinator = m_frameHost . page ( ) . scrollingCoordinator ( ) ; ASSERT ( coordinator ) ; coordinator -> setLayerIsContainerForFixedPositionLayers ( m_innerViewportScrollLayer . get ( ) , true ) ; m_innerViewportContainerLayer -> setMasksToBounds ( m_frameHost . settings ( ) . mainFrameClipsContent ( ) ) ; m_innerViewportContainerLayer -> setSize ( m_size ) ; m_innerViewportScrollLayer -> platformLayer ( ) -> setScrollClipLayer ( m_innerViewportContainerLayer -> platformLayer ( ) ) ; m_innerViewportScrollLayer -> platformLayer ( ) -> setUserScrollable ( true , true ) ; m_rootTransformLayer -> addChild ( m_innerViewportContainerLayer . get ( ) ) ; m_innerViewportContainerLayer -> addChild ( m_pageScaleLayer . get ( ) ) ; m_pageScaleLayer -> addChild ( m_innerViewportScrollLayer . get ( ) ) ; m_innerViewportContainerLayer -> addChild ( m_overlayScrollbarHorizontal . get ( ) ) ; m_innerViewportContainerLayer -> addChild ( m_overlayScrollbarVertical . get ( ) ) ; coordinator -> scrollableAreaScrollLayerDidChange ( this ) ; setupScrollbar ( WebScrollbar :: Horizontal ) ; setupScrollbar ( WebScrollbar :: Vertical ) ; } m_innerViewportScrollLayer -> removeAllChildren ( ) ; m_innerViewportScrollLayer -> addChild ( currentLayerTreeRoot ) ; }
Modifies the top of the graphics layer tree to add layers needed to support
the inner/outer viewport fixed-position model for pinch zoom.
Modifies the top of the graphics layer tree to add layers needed to support the inner / outer viewport fixed - position model for pinch zoom .
// FIXME: The root transform layer should only be created on demand. // Set masks to bounds so the compositor doesn't clobber a manually // set inner viewport container layer size. // Ensure this class is set as the scroll layer's ScrollableArea. // Setup the inner viewport overlay scrollbars. // We only need to disable the existing (outer viewport) scrollbars // if the existing ones are already overlay. // FIXME: If we knew in advance before the overflowControlsHostLayer goes // away, we would re-enable the drawing of these scrollbars. // FIXME: This doesn't seem to work (at least on Android). Commenting out for now until // I figure out how to access RenderLayerCompositor from here. // if (GraphicsLayer* scrollbar = m_frameHost->compositor()->layerForHorizontalScrollbar()) //    scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollbars()); // if (GraphicsLayer* scrollbar = m_frameHost->compositor()->layerForVerticalScrollbar()) //    scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollbars());