| 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 |
| 71 | |
| 72 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); | 74 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); |
| 73 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); | 75 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); |
| 74 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get()); | 76 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get()); |
| 75 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()); | 77 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()); |
| 76 | 78 |
| 77 // Setup the inner viewport overlay scrollbars. | 79 // Setup the inner viewport overlay scrollbars. |
| 78 setupScrollbar(WebScrollbar::Horizontal); | 80 setupScrollbar(WebScrollbar::Horizontal); |
| 79 setupScrollbar(WebScrollbar::Vertical); | 81 setupScrollbar(WebScrollbar::Vertical); |
| 80 } | 82 } |
| 81 | 83 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); | 131 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); |
| 130 if (GraphicsLayer* scrollbar = m_owner->compositor()->layerForVerticalScroll
bar()) | 132 if (GraphicsLayer* scrollbar = m_owner->compositor()->layerForVerticalScroll
bar()) |
| 131 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); | 133 scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollb
ars()); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void PinchViewports::setupScrollbar(WebScrollbar::Orientation orientation) | 136 void PinchViewports::setupScrollbar(WebScrollbar::Orientation orientation) |
| 135 { | 137 { |
| 136 bool isHorizontal = orientation == WebScrollbar::Horizontal; | 138 bool isHorizontal = orientation == WebScrollbar::Horizontal; |
| 137 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? | 139 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? |
| 138 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); | 140 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); |
| 141 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? |
| 142 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; |
| 139 | 143 |
| 140 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); | 144 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); |
| 141 | 145 |
| 146 if (!webScrollbarLayer) { |
| 147 WebCore::ScrollingCoordinator* coordinator = m_owner->page()->scrollingC
oordinator(); |
| 148 ASSERT(coordinator); |
| 149 WebCore::ScrollbarOrientation webcoreOrientation = isHorizontal ? WebCor
e::HorizontalScrollbar : WebCore::VerticalScrollbar; |
| 150 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO
rientation, overlayScrollbarThickness, false); |
| 151 |
| 152 webScrollbarLayer->setScrollLayer(m_innerViewportScrollLayer->platformLa
yer()); |
| 153 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la
yer()); |
| 154 scrollbarGraphicsLayer->setDrawsContent(false); |
| 155 } |
| 156 |
| 142 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - overlayScrollbarThickness; | 157 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - overlayScrollbarThickness; |
| 143 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - overlayScrollbarThickness : 0; | 158 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - overlayScrollbarThickness : 0; |
| 144 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - o
verlayScrollbarThickness : overlayScrollbarThickness; | 159 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - o
verlayScrollbarThickness : overlayScrollbarThickness; |
| 145 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportConta
inerLayer->size().height() - overlayScrollbarThickness; | 160 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportConta
inerLayer->size().height() - overlayScrollbarThickness; |
| 146 | 161 |
| 147 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; | 162 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; |
| 148 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); | 163 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); |
| 149 } | 164 } |
| 150 | 165 |
| 151 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const | 166 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const |
| 152 { | 167 { |
| 153 if (!layerTreeView) | 168 ASSERT(layerTreeView); |
| 154 return; | |
| 155 | 169 |
| 156 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); | 170 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); |
| 171 GraphicsLayer* scrollLayer = compositor->scrollLayer(); |
| 172 |
| 157 ASSERT(compositor); | 173 ASSERT(compositor); |
| 158 layerTreeView->registerPinchViewportLayers( | 174 layerTreeView->registerViewportLayers( |
| 159 m_innerViewportContainerLayer->platformLayer(), | |
| 160 m_pageScaleLayer->platformLayer(), | 175 m_pageScaleLayer->platformLayer(), |
| 161 m_innerViewportScrollLayer->platformLayer(), | 176 m_innerViewportScrollLayer->platformLayer(), |
| 162 compositor->scrollLayer()->platformLayer(), | 177 scrollLayer->platformLayer()); |
| 163 m_overlayScrollbarHorizontal->platformLayer(), | |
| 164 m_overlayScrollbarVertical->platformLayer()); | |
| 165 } | 178 } |
| 166 | 179 |
| 167 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const | 180 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const |
| 168 { | 181 { |
| 169 if (!layerTreeView) | 182 ASSERT(layerTreeView); |
| 170 return; | |
| 171 | 183 |
| 172 layerTreeView->clearPinchViewportLayers(); | 184 layerTreeView->clearViewportLayers(); |
| 173 } | 185 } |
| 174 | 186 |
| 175 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double time) | 187 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double time) |
| 176 { | 188 { |
| 177 } | 189 } |
| 178 | 190 |
| 179 void PinchViewports::paintContents(const GraphicsLayer*, WebCore::GraphicsContex
t&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip) | 191 void PinchViewports::paintContents(const GraphicsLayer*, WebCore::GraphicsContex
t&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip) |
| 180 { | 192 { |
| 181 } | 193 } |
| 182 | 194 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 194 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { | 206 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { |
| 195 name = "Overlay Scrollbar Vertical Layer"; | 207 name = "Overlay Scrollbar Vertical Layer"; |
| 196 } else { | 208 } else { |
| 197 ASSERT_NOT_REACHED(); | 209 ASSERT_NOT_REACHED(); |
| 198 } | 210 } |
| 199 | 211 |
| 200 return name; | 212 return name; |
| 201 } | 213 } |
| 202 | 214 |
| 203 } // namespace WebKit | 215 } // namespace WebKit |
| OLD | NEW |