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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 PinchViewports::PinchViewports(WebViewImpl* owner) | 58 PinchViewports::PinchViewports(WebViewImpl* owner) |
59 : m_owner(owner) | 59 : m_owner(owner) |
60 , m_innerViewportContainerLayer(GraphicsLayer::create(m_owner->graphicsLayer
Factory(), this)) | 60 , m_innerViewportContainerLayer(GraphicsLayer::create(m_owner->graphicsLayer
Factory(), this)) |
61 , m_pageScaleLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), th
is)) | 61 , m_pageScaleLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), th
is)) |
62 , m_innerViewportScrollLayer(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) | 62 , m_innerViewportScrollLayer(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) |
63 , m_overlayScrollbarHorizontal(GraphicsLayer::create(m_owner->graphicsLayerF
actory(), this)) | 63 , m_overlayScrollbarHorizontal(GraphicsLayer::create(m_owner->graphicsLayerF
actory(), this)) |
64 , m_overlayScrollbarVertical(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) | 64 , m_overlayScrollbarVertical(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) |
65 { | 65 { |
66 m_innerViewportContainerLayer->platformLayer()->setIsContainerForFixedPositi
onLayers(true); | 66 ASSERT(m_owner); |
| 67 WebCore::ScrollingCoordinator* coordinator = m_owner->page()->scrollingCoord
inator(); |
| 68 ASSERT(coordinator); |
| 69 coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportScroll
Layer.get(), true); |
| 70 |
67 // No need for the inner viewport to clip, since the compositing | 71 // No need for the inner viewport to clip, since the compositing |
68 // surface takes care of it -- and clipping here would interfere with | 72 // surface takes care of it -- and clipping here would interfere with |
69 // dynamically-sized viewports on Android. | 73 // dynamically-sized viewports on Android. |
70 m_innerViewportContainerLayer->setMasksToBounds(false); | 74 m_innerViewportContainerLayer->setMasksToBounds(false); |
71 | 75 |
| 76 // TODO(wjmaclean) Remove next line once https://codereview.chromium.org/239
83047 lands. |
72 m_innerViewportScrollLayer->platformLayer()->setScrollable(true); | 77 m_innerViewportScrollLayer->platformLayer()->setScrollable(true); |
| 78 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( |
| 79 m_innerViewportContainerLayer->platformLayer()); |
73 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, true); | 80 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, true); |
74 | 81 |
75 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); | 82 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); |
76 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); | 83 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); |
77 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get()); | 84 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get()); |
78 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()); | 85 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()); |
79 | 86 |
80 // Setup the inner viewport overlay scrollbars. | 87 // Setup the inner viewport overlay scrollbars. |
81 setupScrollbar(WebScrollbar::Horizontal); | 88 setupScrollbar(WebScrollbar::Horizontal); |
82 setupScrollbar(WebScrollbar::Vertical); | 89 setupScrollbar(WebScrollbar::Vertical); |
83 } | 90 } |
84 | 91 |
85 PinchViewports::~PinchViewports() { } | 92 PinchViewports::~PinchViewports() { } |
86 | 93 |
87 void PinchViewports::setViewportSize(const WebCore::IntSize& newSize) | 94 void PinchViewports::setViewportSize(const WebCore::IntSize& newSize) |
88 { | 95 { |
89 m_innerViewportContainerLayer->setSize(newSize); | 96 m_innerViewportContainerLayer->setSize(newSize); |
| 97 // The innerviewport scroll layer always has the same size as its clip layer
, but |
| 98 // the page scale layer lives between them, allowing for non-zero max scroll |
| 99 // offset when page scale > 1. |
| 100 m_innerViewportScrollLayer->setSize(newSize); |
90 | 101 |
91 // Need to re-compute sizes for the overlay scrollbars. | 102 // Need to re-compute sizes for the overlay scrollbars. |
92 setupScrollbar(WebScrollbar::Horizontal); | 103 setupScrollbar(WebScrollbar::Horizontal); |
93 setupScrollbar(WebScrollbar::Vertical); | 104 setupScrollbar(WebScrollbar::Vertical); |
94 } | 105 } |
95 | 106 |
96 // Modifies the top of the graphics layer tree to add layers needed to support | 107 // Modifies the top of the graphics layer tree to add layers needed to support |
97 // the inner/outer viewport fixed-position model for pinch zoom. When finished, | 108 // the inner/outer viewport fixed-position model for pinch zoom. When finished, |
98 // the tree will look like this (with * denoting added layers): | 109 // the tree will look like this (with * denoting added layers): |
99 // | 110 // |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; | 154 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; |
144 | 155 |
145 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); | 156 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); |
146 | 157 |
147 if (!webScrollbarLayer) { | 158 if (!webScrollbarLayer) { |
148 WebCore::ScrollingCoordinator* coordinator = m_owner->page()->scrollingC
oordinator(); | 159 WebCore::ScrollingCoordinator* coordinator = m_owner->page()->scrollingC
oordinator(); |
149 ASSERT(coordinator); | 160 ASSERT(coordinator); |
150 WebCore::ScrollbarOrientation webcoreOrientation = isHorizontal ? WebCor
e::HorizontalScrollbar : WebCore::VerticalScrollbar; | 161 WebCore::ScrollbarOrientation webcoreOrientation = isHorizontal ? WebCor
e::HorizontalScrollbar : WebCore::VerticalScrollbar; |
151 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO
rientation, overlayScrollbarThickness, false); | 162 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO
rientation, overlayScrollbarThickness, false); |
152 | 163 |
153 webScrollbarLayer->setScrollLayer(m_innerViewportScrollLayer->platformLa
yer()); | 164 webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformL
ayer()); |
154 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la
yer()); | 165 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la
yer()); |
155 scrollbarGraphicsLayer->setDrawsContent(false); | 166 scrollbarGraphicsLayer->setDrawsContent(false); |
156 } | 167 } |
157 | 168 |
158 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - overlayScrollbarThickness; | 169 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - overlayScrollbarThickness; |
159 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - overlayScrollbarThickness : 0; | 170 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - overlayScrollbarThickness : 0; |
160 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - o
verlayScrollbarThickness : overlayScrollbarThickness; | 171 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - o
verlayScrollbarThickness : overlayScrollbarThickness; |
161 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportConta
inerLayer->size().height() - overlayScrollbarThickness; | 172 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportConta
inerLayer->size().height() - overlayScrollbarThickness; |
162 | 173 |
| 174 // Use the GraphicsLayer to position the scrollbars. |
163 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; | 175 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; |
164 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); | 176 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); |
| 177 scrollbarGraphicsLayer->setContentsRect(WebCore::IntRect(0, 0, width, height
)); |
165 } | 178 } |
166 | 179 |
167 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const | 180 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const |
168 { | 181 { |
169 ASSERT(layerTreeView); | 182 ASSERT(layerTreeView); |
170 | 183 |
171 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); | 184 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); |
172 GraphicsLayer* scrollLayer = compositor->scrollLayer(); | 185 // Get the outer viewport scroll layer. |
| 186 WebLayer* scrollLayer = compositor->scrollLayer()->platformLayer(); |
| 187 |
| 188 m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer); |
| 189 m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer); |
173 | 190 |
174 ASSERT(compositor); | 191 ASSERT(compositor); |
175 layerTreeView->registerViewportLayers( | 192 layerTreeView->registerViewportLayers( |
176 m_pageScaleLayer->platformLayer(), | 193 m_pageScaleLayer->platformLayer(), |
177 m_innerViewportScrollLayer->platformLayer(), | 194 m_innerViewportScrollLayer->platformLayer(), |
178 scrollLayer->platformLayer()); | 195 scrollLayer); |
179 } | 196 } |
180 | 197 |
181 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const | 198 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const |
182 { | 199 { |
183 ASSERT(layerTreeView); | 200 ASSERT(layerTreeView); |
184 | 201 |
185 layerTreeView->clearViewportLayers(); | 202 layerTreeView->clearViewportLayers(); |
186 } | 203 } |
187 | 204 |
188 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double wallClo
ckTime, double monotonicTime) | 205 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double wallClo
ckTime, double monotonicTime) |
(...skipping 18 matching lines...) Expand all Loading... |
207 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { | 224 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { |
208 name = "Overlay Scrollbar Vertical Layer"; | 225 name = "Overlay Scrollbar Vertical Layer"; |
209 } else { | 226 } else { |
210 ASSERT_NOT_REACHED(); | 227 ASSERT_NOT_REACHED(); |
211 } | 228 } |
212 | 229 |
213 return name; | 230 return name; |
214 } | 231 } |
215 | 232 |
216 } // namespace blink | 233 } // namespace blink |
OLD | NEW |