OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 setLocation(visibleRect().location()); | 188 setLocation(visibleRect().location()); |
189 | 189 |
190 // TODO: We should probably be calling scaleDidChange type functions here. | 190 // TODO: We should probably be calling scaleDidChange type functions here. |
191 // see Page::setPageScaleFactor. | 191 // see Page::setPageScaleFactor. |
192 } | 192 } |
193 | 193 |
194 // Modifies the top of the graphics layer tree to add layers needed to support | 194 // Modifies the top of the graphics layer tree to add layers needed to support |
195 // the inner/outer viewport fixed-position model for pinch zoom. When finished, | 195 // the inner/outer viewport fixed-position model for pinch zoom. When finished, |
196 // the tree will look like this (with * denoting added layers): | 196 // the tree will look like this (with * denoting added layers): |
197 // | 197 // |
198 // *innerViewportContainerLayer (fixed pos container) | 198 // *rootTransformLayer |
199 // +- *pageScaleLayer | 199 // +- *innerViewportContainerLayer (fixed pos container) |
200 // | +- *innerViewportScrollLayer | 200 // +- *pageScaleLayer |
201 // | +-- overflowControlsHostLayer (root layer) | 201 // | +- *innerViewportScrollLayer |
202 // | +-- rootTransformLayer (optional) | 202 // | +-- overflowControlsHostLayer (root layer) |
203 // | +-- outerViewportContainerLayer (fixed pos container) [frame
container layer in RenderLayerCompositor] | 203 // | +-- outerViewportContainerLayer (fixed pos container) [frame
container layer in RenderLayerCompositor] |
204 // | | +-- outerViewportScrollLayer [frame scroll layer in Rend
erLayerCompositor] | 204 // | | +-- outerViewportScrollLayer [frame scroll layer in Rend
erLayerCompositor] |
205 // | | +-- content layers ... | 205 // | | +-- content layers ... |
206 // | +-- horizontal ScrollbarLayer (non-overlay) | 206 // | +-- horizontal ScrollbarLayer (non-overlay) |
207 // | +-- verticalScrollbarLayer (non-overlay) | 207 // | +-- verticalScrollbarLayer (non-overlay) |
208 // | +-- scroll corner (non-overlay) | 208 // | +-- scroll corner (non-overlay) |
209 // +- *horizontalScrollbarLayer (overlay) | 209 // +- *horizontalScrollbarLayer (overlay) |
210 // +- *verticalScrollbarLayer (overlay) | 210 // +- *verticalScrollbarLayer (overlay) |
211 // | 211 // |
212 void PinchViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, Graph
icsLayerFactory* graphicsLayerFactory) | 212 void PinchViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, Graph
icsLayerFactory* graphicsLayerFactory) |
213 { | 213 { |
214 TRACE_EVENT1("webkit", "PinchViewport::attachToLayerTree", "currentLayerTree
Root", (bool)currentLayerTreeRoot); | 214 TRACE_EVENT1("webkit", "PinchViewport::attachToLayerTree", "currentLayerTree
Root", (bool)currentLayerTreeRoot); |
215 if (!currentLayerTreeRoot) { | 215 if (!currentLayerTreeRoot) { |
216 m_innerViewportScrollLayer->removeAllChildren(); | 216 m_innerViewportScrollLayer->removeAllChildren(); |
217 return; | 217 return; |
218 } | 218 } |
219 | 219 |
220 if (currentLayerTreeRoot->parent() && currentLayerTreeRoot->parent() == m_in
nerViewportScrollLayer) | 220 if (currentLayerTreeRoot->parent() && currentLayerTreeRoot->parent() == m_in
nerViewportScrollLayer) |
221 return; | 221 return; |
222 | 222 |
223 if (!m_innerViewportScrollLayer) { | 223 if (!m_innerViewportScrollLayer) { |
224 ASSERT(!m_overlayScrollbarHorizontal | 224 ASSERT(!m_overlayScrollbarHorizontal |
225 && !m_overlayScrollbarVertical | 225 && !m_overlayScrollbarVertical |
226 && !m_pageScaleLayer | 226 && !m_pageScaleLayer |
227 && !m_innerViewportContainerLayer); | 227 && !m_innerViewportContainerLayer); |
228 | 228 |
| 229 // FIXME: The root transform layer should only be created on demand. |
| 230 m_rootTransformLayer = GraphicsLayer::create(graphicsLayerFactory, this)
; |
229 m_innerViewportContainerLayer = GraphicsLayer::create(graphicsLayerFacto
ry, this); | 231 m_innerViewportContainerLayer = GraphicsLayer::create(graphicsLayerFacto
ry, this); |
230 m_pageScaleLayer = GraphicsLayer::create(graphicsLayerFactory, this); | 232 m_pageScaleLayer = GraphicsLayer::create(graphicsLayerFactory, this); |
231 m_innerViewportScrollLayer = GraphicsLayer::create(graphicsLayerFactory,
this); | 233 m_innerViewportScrollLayer = GraphicsLayer::create(graphicsLayerFactory,
this); |
232 m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactor
y, this); | 234 m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactor
y, this); |
233 m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory,
this); | 235 m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory,
this); |
234 | 236 |
235 WebCore::ScrollingCoordinator* coordinator = m_frameHost.page().scrollin
gCoordinator(); | 237 WebCore::ScrollingCoordinator* coordinator = m_frameHost.page().scrollin
gCoordinator(); |
236 ASSERT(coordinator); | 238 ASSERT(coordinator); |
237 coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportSc
rollLayer.get(), true); | 239 coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportSc
rollLayer.get(), true); |
238 | 240 |
239 // Set masks to bounds so the compositor doesn't clobber a manually | 241 // Set masks to bounds so the compositor doesn't clobber a manually |
240 // set inner viewport container layer size. | 242 // set inner viewport container layer size. |
241 m_innerViewportContainerLayer->setMasksToBounds(m_frameHost.settings().m
ainFrameClipsContent()); | 243 m_innerViewportContainerLayer->setMasksToBounds(m_frameHost.settings().m
ainFrameClipsContent()); |
242 m_innerViewportContainerLayer->setSize(m_size); | 244 m_innerViewportContainerLayer->setSize(m_size); |
243 | 245 |
244 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( | 246 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( |
245 m_innerViewportContainerLayer->platformLayer()); | 247 m_innerViewportContainerLayer->platformLayer()); |
246 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru
e); | 248 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru
e); |
247 | 249 |
| 250 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get()); |
248 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); | 251 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); |
249 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); | 252 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); |
250 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get
()); | 253 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get
()); |
251 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()
); | 254 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()
); |
252 | 255 |
253 // Ensure this class is set as the scroll layer's ScrollableArea. | 256 // Ensure this class is set as the scroll layer's ScrollableArea. |
254 coordinator->scrollableAreaScrollLayerDidChange(this); | 257 coordinator->scrollableAreaScrollLayerDidChange(this); |
255 | 258 |
256 // Setup the inner viewport overlay scrollbars. | 259 // Setup the inner viewport overlay scrollbars. |
257 setupScrollbar(WebScrollbar::Horizontal); | 260 setupScrollbar(WebScrollbar::Horizontal); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { | 443 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { |
441 name = "Overlay Scrollbar Vertical Layer"; | 444 name = "Overlay Scrollbar Vertical Layer"; |
442 } else { | 445 } else { |
443 ASSERT_NOT_REACHED(); | 446 ASSERT_NOT_REACHED(); |
444 } | 447 } |
445 | 448 |
446 return name; | 449 return name; |
447 } | 450 } |
448 | 451 |
449 } // namespace WebCore | 452 } // namespace WebCore |
OLD | NEW |