OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 5 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
9 #include "cc/animation/animation_timeline.h" | 9 #include "cc/animation/animation_timeline.h" |
10 #include "cc/blink/web_layer_impl.h" | 10 #include "cc/blink/web_layer_impl.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return settings; | 60 return settings; |
61 } | 61 } |
62 | 62 |
63 bool WebLayerTreeViewImplForTesting::hasLayer(const WebLayer& layer) | 63 bool WebLayerTreeViewImplForTesting::hasLayer(const WebLayer& layer) |
64 { | 64 { |
65 return layer.ccLayer()->layer_tree_host() == m_layerTreeHost.get(); | 65 return layer.ccLayer()->layer_tree_host() == m_layerTreeHost.get(); |
66 } | 66 } |
67 | 67 |
68 void WebLayerTreeViewImplForTesting::setRootLayer(const blink::WebLayer& root) | 68 void WebLayerTreeViewImplForTesting::setRootLayer(const blink::WebLayer& root) |
69 { | 69 { |
70 m_layerTreeHost->SetRootLayer(static_cast<const cc_blink::WebLayerImpl*>(&ro
ot)->layer()); | 70 m_layerTreeHost->GetLayerTree()->SetRootLayer(static_cast<const cc_blink::We
bLayerImpl*>(&root)->layer()); |
71 } | 71 } |
72 | 72 |
73 void WebLayerTreeViewImplForTesting::clearRootLayer() | 73 void WebLayerTreeViewImplForTesting::clearRootLayer() |
74 { | 74 { |
75 m_layerTreeHost->SetRootLayer(scoped_refptr<cc::Layer>()); | 75 m_layerTreeHost->GetLayerTree()->SetRootLayer(scoped_refptr<cc::Layer>()); |
76 } | 76 } |
77 | 77 |
78 void WebLayerTreeViewImplForTesting::attachCompositorAnimationTimeline(cc::Anima
tionTimeline* compositorTimeline) | 78 void WebLayerTreeViewImplForTesting::attachCompositorAnimationTimeline(cc::Anima
tionTimeline* compositorTimeline) |
79 { | 79 { |
80 ASSERT(m_layerTreeHost->animation_host()); | 80 ASSERT(m_layerTreeHost->animation_host()); |
81 m_layerTreeHost->animation_host()->AddAnimationTimeline(compositorTimeline); | 81 m_layerTreeHost->animation_host()->AddAnimationTimeline(compositorTimeline); |
82 } | 82 } |
83 | 83 |
84 void WebLayerTreeViewImplForTesting::detachCompositorAnimationTimeline(cc::Anima
tionTimeline* compositorTimeline) | 84 void WebLayerTreeViewImplForTesting::detachCompositorAnimationTimeline(cc::Anima
tionTimeline* compositorTimeline) |
85 { | 85 { |
86 ASSERT(m_layerTreeHost->animation_host()); | 86 ASSERT(m_layerTreeHost->animation_host()); |
87 m_layerTreeHost->animation_host()->RemoveAnimationTimeline(compositorTimelin
e); | 87 m_layerTreeHost->animation_host()->RemoveAnimationTimeline(compositorTimelin
e); |
88 } | 88 } |
89 | 89 |
90 void WebLayerTreeViewImplForTesting::setViewportSize(const WebSize& unusedDeprec
ated, const WebSize& deviceViewportSize) | 90 void WebLayerTreeViewImplForTesting::setViewportSize(const WebSize& unusedDeprec
ated, const WebSize& deviceViewportSize) |
91 { | 91 { |
92 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), std::max(0, deviceV
iewportSize.height)); | 92 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), std::max(0, deviceV
iewportSize.height)); |
93 m_layerTreeHost->SetViewportSize(gfxSize); | 93 m_layerTreeHost->GetLayerTree()->SetViewportSize(gfxSize); |
94 } | 94 } |
95 | 95 |
96 void WebLayerTreeViewImplForTesting::setViewportSize(const WebSize& deviceViewpo
rtSize) | 96 void WebLayerTreeViewImplForTesting::setViewportSize(const WebSize& deviceViewpo
rtSize) |
97 { | 97 { |
98 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), std::max(0, deviceV
iewportSize.height)); | 98 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), std::max(0, deviceV
iewportSize.height)); |
99 m_layerTreeHost->SetViewportSize(gfxSize); | 99 m_layerTreeHost->GetLayerTree()->SetViewportSize(gfxSize); |
100 } | 100 } |
101 | 101 |
102 void WebLayerTreeViewImplForTesting::setDeviceScaleFactor(float deviceScaleFacto
r) | 102 void WebLayerTreeViewImplForTesting::setDeviceScaleFactor(float deviceScaleFacto
r) |
103 { | 103 { |
104 m_layerTreeHost->SetDeviceScaleFactor(deviceScaleFactor); | 104 m_layerTreeHost->GetLayerTree()->SetDeviceScaleFactor(deviceScaleFactor); |
105 } | 105 } |
106 | 106 |
107 void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) | 107 void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) |
108 { | 108 { |
109 m_layerTreeHost->set_background_color(color); | 109 m_layerTreeHost->GetLayerTree()->set_background_color(color); |
110 } | 110 } |
111 | 111 |
112 void WebLayerTreeViewImplForTesting::setHasTransparentBackground(bool transparen
t) | 112 void WebLayerTreeViewImplForTesting::setHasTransparentBackground(bool transparen
t) |
113 { | 113 { |
114 m_layerTreeHost->set_has_transparent_background(transparent); | 114 m_layerTreeHost->GetLayerTree()->set_has_transparent_background(transparent)
; |
115 } | 115 } |
116 | 116 |
117 void WebLayerTreeViewImplForTesting::setVisible(bool visible) | 117 void WebLayerTreeViewImplForTesting::setVisible(bool visible) |
118 { | 118 { |
119 m_layerTreeHost->SetVisible(visible); | 119 m_layerTreeHost->SetVisible(visible); |
120 } | 120 } |
121 | 121 |
122 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits( | 122 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits( |
123 float pageScaleFactor, | 123 float pageScaleFactor, |
124 float minimum, | 124 float minimum, |
125 float maximum) | 125 float maximum) |
126 { | 126 { |
127 m_layerTreeHost->SetPageScaleFactorAndLimits(pageScaleFactor, minimum, maxim
um); | 127 m_layerTreeHost->GetLayerTree()->SetPageScaleFactorAndLimits(pageScaleFactor
, minimum, maximum); |
128 } | 128 } |
129 | 129 |
130 void WebLayerTreeViewImplForTesting::startPageScaleAnimation( | 130 void WebLayerTreeViewImplForTesting::startPageScaleAnimation( |
131 const blink::WebPoint& scroll, | 131 const blink::WebPoint& scroll, |
132 bool useAnchor, | 132 bool useAnchor, |
133 float newPageScale, | 133 float newPageScale, |
134 double durationSec) {} | 134 double durationSec) {} |
135 | 135 |
136 void WebLayerTreeViewImplForTesting::setNeedsAnimate() | 136 void WebLayerTreeViewImplForTesting::setNeedsAnimate() |
137 { | 137 { |
(...skipping 29 matching lines...) Expand all Loading... |
167 { | 167 { |
168 ASSERT_NOT_REACHED(); | 168 ASSERT_NOT_REACHED(); |
169 } | 169 } |
170 | 170 |
171 void WebLayerTreeViewImplForTesting::registerViewportLayers( | 171 void WebLayerTreeViewImplForTesting::registerViewportLayers( |
172 const blink::WebLayer* overscrollElasticityLayer, | 172 const blink::WebLayer* overscrollElasticityLayer, |
173 const blink::WebLayer* pageScaleLayer, | 173 const blink::WebLayer* pageScaleLayer, |
174 const blink::WebLayer* innerViewportScrollLayer, | 174 const blink::WebLayer* innerViewportScrollLayer, |
175 const blink::WebLayer* outerViewportScrollLayer) | 175 const blink::WebLayer* outerViewportScrollLayer) |
176 { | 176 { |
177 m_layerTreeHost->RegisterViewportLayers( | 177 m_layerTreeHost->GetLayerTree()->RegisterViewportLayers( |
178 // The scroll elasticity layer will only exist when using pinch virtual | 178 // The scroll elasticity layer will only exist when using pinch virtual |
179 // viewports. | 179 // viewports. |
180 overscrollElasticityLayer | 180 overscrollElasticityLayer |
181 ? static_cast<const cc_blink::WebLayerImpl*>(overscrollElasticityLay
er)->layer() | 181 ? static_cast<const cc_blink::WebLayerImpl*>(overscrollElasticityLay
er)->layer() |
182 : nullptr, | 182 : nullptr, |
183 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(), | 183 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(), |
184 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer)->la
yer(), | 184 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer)->la
yer(), |
185 // The outer viewport layer will only exist when using pinch virtual | 185 // The outer viewport layer will only exist when using pinch virtual |
186 // viewports. | 186 // viewports. |
187 outerViewportScrollLayer | 187 outerViewportScrollLayer |
188 ? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLaye
r)->layer() | 188 ? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLaye
r)->layer() |
189 : nullptr); | 189 : nullptr); |
190 } | 190 } |
191 | 191 |
192 void WebLayerTreeViewImplForTesting::clearViewportLayers() | 192 void WebLayerTreeViewImplForTesting::clearViewportLayers() |
193 { | 193 { |
194 m_layerTreeHost->RegisterViewportLayers(scoped_refptr<cc::Layer>(), | 194 m_layerTreeHost->GetLayerTree()->RegisterViewportLayers(scoped_refptr<cc::La
yer>(), |
195 scoped_refptr<cc::Layer>(), | 195 scoped_refptr<cc::Layer>(), |
196 scoped_refptr<cc::Layer>(), | 196 scoped_refptr<cc::Layer>(), |
197 scoped_refptr<cc::Layer>()); | 197 scoped_refptr<cc::Layer>()); |
198 } | 198 } |
199 | 199 |
200 void WebLayerTreeViewImplForTesting::registerSelection(const blink::WebSelection
& selection) | 200 void WebLayerTreeViewImplForTesting::registerSelection(const blink::WebSelection
& selection) |
201 { | 201 { |
202 } | 202 } |
203 | 203 |
204 void WebLayerTreeViewImplForTesting::clearSelection() | 204 void WebLayerTreeViewImplForTesting::clearSelection() |
205 { | 205 { |
206 } | 206 } |
207 | 207 |
208 void WebLayerTreeViewImplForTesting::setEventListenerProperties( | 208 void WebLayerTreeViewImplForTesting::setEventListenerProperties( |
209 blink::WebEventListenerClass eventClass, | 209 blink::WebEventListenerClass eventClass, |
210 blink::WebEventListenerProperties properties) | 210 blink::WebEventListenerProperties properties) |
211 { | 211 { |
212 // Equality of static_cast is checked in render_widget_compositor.cc. | 212 // Equality of static_cast is checked in render_widget_compositor.cc. |
213 m_layerTreeHost->SetEventListenerProperties( | 213 m_layerTreeHost->GetLayerTree()->SetEventListenerProperties( |
214 static_cast<cc::EventListenerClass>(eventClass), | 214 static_cast<cc::EventListenerClass>(eventClass), |
215 static_cast<cc::EventListenerProperties>(properties)); | 215 static_cast<cc::EventListenerProperties>(properties)); |
216 } | 216 } |
217 | 217 |
218 blink::WebEventListenerProperties | 218 blink::WebEventListenerProperties |
219 WebLayerTreeViewImplForTesting::eventListenerProperties(blink::WebEventListenerC
lass eventClass) const | 219 WebLayerTreeViewImplForTesting::eventListenerProperties(blink::WebEventListenerC
lass eventClass) const |
220 { | 220 { |
221 // Equality of static_cast is checked in render_widget_compositor.cc. | 221 // Equality of static_cast is checked in render_widget_compositor.cc. |
222 return static_cast<blink::WebEventListenerProperties>( | 222 return static_cast<blink::WebEventListenerProperties>( |
223 m_layerTreeHost->event_listener_properties( | 223 m_layerTreeHost->GetLayerTree()->event_listener_properties( |
224 static_cast<cc::EventListenerClass>(eventClass))); | 224 static_cast<cc::EventListenerClass>(eventClass))); |
225 } | 225 } |
226 | 226 |
227 void WebLayerTreeViewImplForTesting::setHaveScrollEventHandlers(bool haveEentHan
dlers) | 227 void WebLayerTreeViewImplForTesting::setHaveScrollEventHandlers(bool haveEentHan
dlers) |
228 { | 228 { |
229 m_layerTreeHost->SetHaveScrollEventHandlers(haveEentHandlers); | 229 m_layerTreeHost->GetLayerTree()->SetHaveScrollEventHandlers(haveEentHandlers
); |
230 } | 230 } |
231 | 231 |
232 bool WebLayerTreeViewImplForTesting::haveScrollEventHandlers() const | 232 bool WebLayerTreeViewImplForTesting::haveScrollEventHandlers() const |
233 { | 233 { |
234 return m_layerTreeHost->have_scroll_event_handlers(); | 234 return m_layerTreeHost->GetLayerTree()->have_scroll_event_handlers(); |
235 } | 235 } |
236 | 236 |
237 } // namespace blink | 237 } // namespace blink |
OLD | NEW |