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 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "PinchViewports.h" | 32 #include "PinchViewports.h" |
33 | 33 |
34 #include "WebSettingsImpl.h" | 34 #include "WebSettingsImpl.h" |
35 #include "WebViewImpl.h" | 35 #include "WebViewImpl.h" |
36 #include "core/page/Frame.h" | 36 #include "core/page/Frame.h" |
37 #include "core/page/FrameView.h" | 37 #include "core/page/FrameView.h" |
| 38 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 39 #include "core/platform/Scrollbar.h" |
38 #include "core/platform/graphics/FloatSize.h" | 40 #include "core/platform/graphics/FloatSize.h" |
39 #include "core/platform/graphics/GraphicsLayer.h" | 41 #include "core/platform/graphics/GraphicsLayer.h" |
40 #include "core/rendering/RenderLayerCompositor.h" | 42 #include "core/rendering/RenderLayerCompositor.h" |
41 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
42 #include "public/platform/WebCompositorSupport.h" | 44 #include "public/platform/WebCompositorSupport.h" |
| 45 #include "public/platform/WebLayer.h" |
43 #include "public/platform/WebLayerTreeView.h" | 46 #include "public/platform/WebLayerTreeView.h" |
44 #include "public/platform/WebScrollbarLayer.h" | 47 #include "public/platform/WebScrollbarLayer.h" |
45 | 48 |
46 using WebCore::GraphicsLayer; | 49 using WebCore::GraphicsLayer; |
47 | 50 |
48 namespace WebKit { | 51 namespace WebKit { |
49 | 52 |
50 PassOwnPtr<PinchViewports> PinchViewports::create(WebViewImpl* owner) | 53 PassOwnPtr<PinchViewports> PinchViewports::create(WebViewImpl* owner) |
51 { | 54 { |
52 return adoptPtr(new PinchViewports(owner)); | 55 return adoptPtr(new PinchViewports(owner)); |
53 } | 56 } |
54 | 57 |
55 PinchViewports::PinchViewports(WebViewImpl* owner) | 58 PinchViewports::PinchViewports(WebViewImpl* owner) |
56 : m_owner(owner) | 59 : m_owner(owner) |
57 , m_innerViewportContainerLayer(GraphicsLayer::create(m_owner->graphicsLayer
Factory(), this)) | 60 , m_innerViewportContainerLayer(GraphicsLayer::create(m_owner->graphicsLayer
Factory(), this)) |
58 , m_pageScaleLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), th
is)) | 61 , m_pageScaleLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), th
is)) |
59 , m_innerViewportScrollLayer(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) | 62 , m_innerViewportScrollLayer(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) |
60 , m_overlayScrollbarHorizontal(GraphicsLayer::create(m_owner->graphicsLayerF
actory(), this)) | 63 , m_overlayScrollbarHorizontal(GraphicsLayer::create(m_owner->graphicsLayerF
actory(), this)) |
61 , m_overlayScrollbarVertical(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) | 64 , m_overlayScrollbarVertical(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) |
62 { | 65 { |
63 m_innerViewportContainerLayer->platformLayer()->setIsContainerForFixedPositi
onLayers(true); | 66 m_innerViewportContainerLayer->platformLayer()->setIsContainerForFixedPositi
onLayers(true); |
64 // No need for the inner viewport to clip, since the compositing | 67 // No need for the inner viewport to clip, since the compositing |
65 // surface takes care of it -- and clipping here would interfere with | 68 // surface takes care of it -- and clipping here would interfere with |
66 // dynamically-sized viewports on Android. | 69 // dynamically-sized viewports on Android. |
67 m_innerViewportContainerLayer->setMasksToBounds(false); | 70 m_innerViewportContainerLayer->setMasksToBounds(false); |
68 | 71 |
69 m_innerViewportScrollLayer->platformLayer()->setScrollable(true); | 72 m_innerViewportScrollLayer->platformLayer()->setScrollable(true); |
70 | 73 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer(m_innerViewp
ortContainerLayer->platformLayer()); |
71 | 74 |
72 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); | 75 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); |
73 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); | 76 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); |
74 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get()); | 77 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get()); |
75 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()); | 78 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()); |
76 | 79 |
77 // Setup the inner viewport overlay scrollbars. | 80 // Setup the inner viewport overlay scrollbars. |
78 setupScrollbar(WebScrollbar::Horizontal); | 81 setupScrollbar(WebScrollbar::Horizontal); |
79 setupScrollbar(WebScrollbar::Vertical); | 82 setupScrollbar(WebScrollbar::Vertical); |
80 } | 83 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); | 132 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); |
130 if (GraphicsLayer* scrollbar = m_owner->compositor()->layerForVerticalScroll
bar()) | 133 if (GraphicsLayer* scrollbar = m_owner->compositor()->layerForVerticalScroll
bar()) |
131 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); | 134 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); |
132 } | 135 } |
133 | 136 |
134 void PinchViewports::setupScrollbar(WebScrollbar::Orientation orientation) | 137 void PinchViewports::setupScrollbar(WebScrollbar::Orientation orientation) |
135 { | 138 { |
136 bool isHorizontal = orientation == WebScrollbar::Horizontal; | 139 bool isHorizontal = orientation == WebScrollbar::Horizontal; |
137 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? | 140 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? |
138 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); | 141 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); |
| 142 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? |
| 143 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; |
139 | 144 |
140 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); | 145 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); |
141 | 146 |
| 147 if (!webScrollbarLayer) { |
| 148 WebCore::ScrollingCoordinator* coordinator = m_owner->page()->scrollingC
oordinator(); |
| 149 ASSERT(coordinator); |
| 150 WebCore::ScrollbarOrientation webcoreOrientation = isHorizontal ? WebCor
e::HorizontalScrollbar : WebCore::VerticalScrollbar; |
| 151 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO
rientation, overlayScrollbarThickness); |
| 152 |
| 153 webScrollbarLayer->setScrollLayer(m_innerViewportScrollLayer->platformLa
yer()); |
| 154 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la
yer()); |
| 155 scrollbarGraphicsLayer->setDrawsContent(false); |
| 156 } |
| 157 |
142 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - overlayScrollbarThickness; | 158 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - overlayScrollbarThickness; |
143 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - overlayScrollbarThickness : 0; | 159 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - overlayScrollbarThickness : 0; |
144 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - o
verlayScrollbarThickness : overlayScrollbarThickness; | 160 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - o
verlayScrollbarThickness : overlayScrollbarThickness; |
145 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportConta
inerLayer->size().height() - overlayScrollbarThickness; | 161 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportConta
inerLayer->size().height() - overlayScrollbarThickness; |
146 | 162 |
147 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; | 163 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; |
148 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); | 164 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); |
149 } | 165 } |
150 | 166 |
151 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const | 167 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const |
152 { | 168 { |
153 if (!layerTreeView) | 169 ASSERT(layerTreeView); |
154 return; | |
155 | 170 |
156 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); | 171 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); |
| 172 GraphicsLayer* scrollLayer = compositor->scrollLayer(); |
| 173 GraphicsLayer* clipLayer = compositor->rootGraphicsLayer(); |
| 174 scrollLayer->platformLayer()->setScrollClipLayer(clipLayer->platformLayer())
; |
| 175 |
157 ASSERT(compositor); | 176 ASSERT(compositor); |
158 layerTreeView->registerPinchViewportLayers( | 177 layerTreeView->registerViewportLayers( |
159 m_innerViewportContainerLayer->platformLayer(), | |
160 m_pageScaleLayer->platformLayer(), | 178 m_pageScaleLayer->platformLayer(), |
161 m_innerViewportScrollLayer->platformLayer(), | 179 m_innerViewportScrollLayer->platformLayer(), |
162 compositor->scrollLayer()->platformLayer(), | 180 scrollLayer->platformLayer()); |
163 m_overlayScrollbarHorizontal->platformLayer(), | |
164 m_overlayScrollbarVertical->platformLayer()); | |
165 } | 181 } |
166 | 182 |
167 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const | 183 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const |
168 { | 184 { |
169 if (!layerTreeView) | 185 ASSERT(layerTreeView); |
170 return; | |
171 | 186 |
172 layerTreeView->clearPinchViewportLayers(); | 187 layerTreeView->clearViewportLayers(); |
173 } | 188 } |
174 | 189 |
175 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double time) | 190 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double time) |
176 { | 191 { |
177 } | 192 } |
178 | 193 |
179 void PinchViewports::paintContents(const GraphicsLayer*, WebCore::GraphicsContex
t&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip) | 194 void PinchViewports::paintContents(const GraphicsLayer*, WebCore::GraphicsContex
t&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip) |
180 { | 195 { |
181 } | 196 } |
182 | 197 |
(...skipping 11 matching lines...) Expand all Loading... |
194 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { | 209 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { |
195 name = "Overlay Scrollbar Vertical Layer"; | 210 name = "Overlay Scrollbar Vertical Layer"; |
196 } else { | 211 } else { |
197 ASSERT_NOT_REACHED(); | 212 ASSERT_NOT_REACHED(); |
198 } | 213 } |
199 | 214 |
200 return name; | 215 return name; |
201 } | 216 } |
202 | 217 |
203 } // namespace WebKit | 218 } // namespace WebKit |
OLD | NEW |