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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 namespace WebKit { | 47 namespace WebKit { |
48 | 48 |
49 PassOwnPtr<PinchViewports> PinchViewports::create(WebViewImpl* owner) | 49 PassOwnPtr<PinchViewports> PinchViewports::create(WebViewImpl* owner) |
50 { | 50 { |
51 return adoptPtr(new PinchViewports(owner)); | 51 return adoptPtr(new PinchViewports(owner)); |
52 } | 52 } |
53 | 53 |
54 PinchViewports::PinchViewports(WebViewImpl* owner) | 54 PinchViewports::PinchViewports(WebViewImpl* owner) |
55 : m_owner(owner) | 55 : m_owner(owner) |
56 , m_innerViewportClipLayer(GraphicsLayer::create(m_owner->graphicsLayerFacto
ry(), this)) | 56 , m_innerViewportContainerLayer(GraphicsLayer::create(m_owner->graphicsLayer
Factory(), this)) |
57 , m_pageScaleLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), th
is)) | 57 , m_pageScaleLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), th
is)) |
58 , m_innerViewportScrollLayer(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) | 58 , m_innerViewportScrollLayer(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) |
59 , m_overlayScrollbarHorizontal(GraphicsLayer::create(m_owner->graphicsLayerF
actory(), this)) | 59 , m_overlayScrollbarHorizontal(GraphicsLayer::create(m_owner->graphicsLayerF
actory(), this)) |
60 , m_overlayScrollbarVertical(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) | 60 , m_overlayScrollbarVertical(GraphicsLayer::create(m_owner->graphicsLayerFac
tory(), this)) |
61 { | 61 { |
62 m_innerViewportClipLayer->setMasksToBounds(true); | 62 m_innerViewportContainerLayer->platformLayer()->setIsContainerForFixedPositi
onLayers(true); |
63 m_innerViewportClipLayer->platformLayer()->setIsContainerForFixedPositionLay
ers(true); | 63 // No need for the inner viewport to clip, since the compositing |
| 64 // surface takes care of it -- and clipping here would interfere with |
| 65 // dynamically-sized viewports on Android. |
| 66 m_innerViewportContainerLayer->setMasksToBounds(false); |
64 | 67 |
65 m_innerViewportScrollLayer->platformLayer()->setScrollable(true); | 68 m_innerViewportScrollLayer->platformLayer()->setScrollable(true); |
66 | 69 |
67 #ifndef NDEBUG | 70 #ifndef NDEBUG |
68 m_innerViewportClipLayer->setName("inner viewport clip layer"); | 71 m_innerViewportContainerLayer->setName("inner viewport container layer"); |
69 m_pageScaleLayer->setName("page scale layer"); | 72 m_pageScaleLayer->setName("page scale layer"); |
70 m_innerViewportScrollLayer->setName("inner viewport scroll layer"); | 73 m_innerViewportScrollLayer->setName("inner viewport scroll layer"); |
71 m_overlayScrollbarHorizontal->setName("overlay scrollbar horizontal"); | 74 m_overlayScrollbarHorizontal->setName("overlay scrollbar horizontal"); |
72 m_overlayScrollbarVertical->setName("overlay scrollbar vertical"); | 75 m_overlayScrollbarVertical->setName("overlay scrollbar vertical"); |
73 #endif | 76 #endif |
74 | 77 |
75 m_innerViewportClipLayer->addChild(m_pageScaleLayer.get()); | 78 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); |
76 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); | 79 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); |
77 m_innerViewportClipLayer->addChild(m_overlayScrollbarHorizontal.get()); | 80 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get()); |
78 m_innerViewportClipLayer->addChild(m_overlayScrollbarVertical.get()); | 81 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()); |
79 | 82 |
80 // Setup the inner viewport overlay scrollbars. | 83 // Setup the inner viewport overlay scrollbars. |
81 setupScrollbar(WebScrollbar::Horizontal); | 84 setupScrollbar(WebScrollbar::Horizontal); |
82 setupScrollbar(WebScrollbar::Vertical); | 85 setupScrollbar(WebScrollbar::Vertical); |
83 } | 86 } |
84 | 87 |
85 PinchViewports::~PinchViewports() { } | 88 PinchViewports::~PinchViewports() { } |
86 | 89 |
87 void PinchViewports::setViewportSize(const WebCore::IntSize& newSize) | 90 void PinchViewports::setViewportSize(const WebCore::IntSize& newSize) |
88 { | 91 { |
89 m_innerViewportClipLayer->setSize(newSize); | 92 m_innerViewportContainerLayer->setSize(newSize); |
90 | 93 |
91 // Need to re-compute sizes for the overlay scrollbars. | 94 // Need to re-compute sizes for the overlay scrollbars. |
92 setupScrollbar(WebScrollbar::Horizontal); | 95 setupScrollbar(WebScrollbar::Horizontal); |
93 setupScrollbar(WebScrollbar::Vertical); | 96 setupScrollbar(WebScrollbar::Vertical); |
94 } | 97 } |
95 | 98 |
96 // Modifies the top of the graphics layer tree to add layers needed to support | 99 // 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, | 100 // the inner/outer viewport fixed-position model for pinch zoom. When finished, |
98 // the tree will look like this (with * denoting added layers): | 101 // the tree will look like this (with * denoting added layers): |
99 // | 102 // |
100 // *innerViewportClipLayer (fixed pos container) | 103 // *innerViewportContainerLayer (fixed pos container) |
101 // +- *pageScaleLayer | 104 // +- *pageScaleLayer |
102 // | +- *innerViewportScrollLayer | 105 // | +- *innerViewportScrollLayer |
103 // | +-- overflowControlsHostLayer (root layer) | 106 // | +-- overflowControlsHostLayer (root layer) |
104 // | +-- outerViewportClipLayer (fixed pos container) [frame clip lay
er in RenderLayerCompositor] | 107 // | +-- outerViewportContainerLayer (fixed pos container) [frame con
tainer layer in RenderLayerCompositor] |
105 // | | +-- outerViewportScrollLayer [frame scroll layer in RenderLa
yerCompositor] | 108 // | | +-- outerViewportScrollLayer [frame scroll layer in RenderLa
yerCompositor] |
106 // | | +-- content layers ... | 109 // | | +-- content layers ... |
107 // | +-- horizontal ScrollbarLayer (non-overlay) | 110 // | +-- horizontal ScrollbarLayer (non-overlay) |
108 // | +-- verticalScrollbarLayer (non-overlay) | 111 // | +-- verticalScrollbarLayer (non-overlay) |
109 // | +-- scroll corner (non-overlay) | 112 // | +-- scroll corner (non-overlay) |
110 // +- *horizontalScrollbarLayer (overlay) | 113 // +- *horizontalScrollbarLayer (overlay) |
111 // +- *verticalScrollbarLayer (overlay) | 114 // +- *verticalScrollbarLayer (overlay) |
112 // | 115 // |
113 void PinchViewports::setOverflowControlsHostLayer(GraphicsLayer* layer) | 116 void PinchViewports::setOverflowControlsHostLayer(GraphicsLayer* layer) |
114 { | 117 { |
(...skipping 20 matching lines...) Expand all Loading... |
135 } | 138 } |
136 | 139 |
137 void PinchViewports::setupScrollbar(WebScrollbar::Orientation orientation) | 140 void PinchViewports::setupScrollbar(WebScrollbar::Orientation orientation) |
138 { | 141 { |
139 bool isHorizontal = orientation == WebScrollbar::Horizontal; | 142 bool isHorizontal = orientation == WebScrollbar::Horizontal; |
140 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? | 143 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? |
141 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); | 144 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); |
142 | 145 |
143 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); | 146 const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayS
crollbarThickness(); |
144 | 147 |
145 int xPosition = isHorizontal ? 0 : m_innerViewportClipLayer->size().width()
- overlayScrollbarThickness; | 148 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - overlayScrollbarThickness; |
146 int yPosition = isHorizontal ? m_innerViewportClipLayer->size().height() - o
verlayScrollbarThickness : 0; | 149 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - overlayScrollbarThickness : 0; |
147 int width = isHorizontal ? m_innerViewportClipLayer->size().width() - overla
yScrollbarThickness : overlayScrollbarThickness; | 150 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - o
verlayScrollbarThickness : overlayScrollbarThickness; |
148 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportClipL
ayer->size().height() - overlayScrollbarThickness; | 151 int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportConta
inerLayer->size().height() - overlayScrollbarThickness; |
149 | 152 |
150 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; | 153 scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition))
; |
151 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); | 154 scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height)); |
152 } | 155 } |
153 | 156 |
154 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const | 157 void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerT
reeView) const |
155 { | 158 { |
156 if (!layerTreeView) | 159 if (!layerTreeView) |
157 return; | 160 return; |
158 | 161 |
159 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); | 162 WebCore::RenderLayerCompositor* compositor = m_owner->compositor(); |
160 ASSERT(compositor); | 163 ASSERT(compositor); |
161 layerTreeView->registerPinchViewportLayers( | 164 layerTreeView->registerPinchViewportLayers( |
162 m_innerViewportClipLayer->platformLayer(), | 165 m_innerViewportContainerLayer->platformLayer(), |
163 m_pageScaleLayer->platformLayer(), | 166 m_pageScaleLayer->platformLayer(), |
164 m_innerViewportScrollLayer->platformLayer(), | 167 m_innerViewportScrollLayer->platformLayer(), |
165 compositor->scrollLayer()->platformLayer(), | 168 compositor->scrollLayer()->platformLayer(), |
166 m_overlayScrollbarHorizontal->platformLayer(), | 169 m_overlayScrollbarHorizontal->platformLayer(), |
167 m_overlayScrollbarVertical->platformLayer()); | 170 m_overlayScrollbarVertical->platformLayer()); |
168 } | 171 } |
169 | 172 |
170 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const | 173 void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeV
iew) const |
171 { | 174 { |
172 if (!layerTreeView) | 175 if (!layerTreeView) |
173 return; | 176 return; |
174 | 177 |
175 layerTreeView->clearPinchViewportLayers(); | 178 layerTreeView->clearPinchViewportLayers(); |
176 } | 179 } |
177 | 180 |
178 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double time) | 181 void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double time) |
179 { | 182 { |
180 } | 183 } |
181 | 184 |
182 void PinchViewports::paintContents(const GraphicsLayer*, WebCore::GraphicsContex
t&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip) | 185 void PinchViewports::paintContents(const GraphicsLayer*, WebCore::GraphicsContex
t&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip) |
183 { | 186 { |
184 } | 187 } |
185 | 188 |
186 } // namespace WebKit | 189 } // namespace WebKit |
OLD | NEW |