| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 settings.layer_transforms_should_scale_layer_contents = true; | 46 settings.layer_transforms_should_scale_layer_contents = true; |
| 47 | 47 |
| 48 return settings; | 48 return settings; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool WebLayerTreeViewImplForTesting::hasLayer(const WebLayer& layer) { | 51 bool WebLayerTreeViewImplForTesting::hasLayer(const WebLayer& layer) { |
| 52 return layer.ccLayer()->GetLayerTreeHostForTesting() == m_layerTreeHost.get(); | 52 return layer.ccLayer()->GetLayerTreeHostForTesting() == m_layerTreeHost.get(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void WebLayerTreeViewImplForTesting::setRootLayer(const blink::WebLayer& root) { | 55 void WebLayerTreeViewImplForTesting::setRootLayer(const blink::WebLayer& root) { |
| 56 m_layerTreeHost->GetLayerTree()->SetRootLayer( | 56 m_layerTreeHost->SetRootLayer( |
| 57 static_cast<const cc_blink::WebLayerImpl*>(&root)->layer()); | 57 static_cast<const cc_blink::WebLayerImpl*>(&root)->layer()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void WebLayerTreeViewImplForTesting::clearRootLayer() { | 60 void WebLayerTreeViewImplForTesting::clearRootLayer() { |
| 61 m_layerTreeHost->GetLayerTree()->SetRootLayer(scoped_refptr<cc::Layer>()); | 61 m_layerTreeHost->SetRootLayer(scoped_refptr<cc::Layer>()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 cc::AnimationHost* WebLayerTreeViewImplForTesting::compositorAnimationHost() { | 64 cc::AnimationHost* WebLayerTreeViewImplForTesting::compositorAnimationHost() { |
| 65 return m_animationHost.get(); | 65 return m_animationHost.get(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void WebLayerTreeViewImplForTesting::setViewportSize( | 68 void WebLayerTreeViewImplForTesting::setViewportSize( |
| 69 const WebSize& unusedDeprecated, | 69 const WebSize& unusedDeprecated, |
| 70 const WebSize& deviceViewportSize) { | 70 const WebSize& deviceViewportSize) { |
| 71 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), | 71 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), |
| 72 std::max(0, deviceViewportSize.height)); | 72 std::max(0, deviceViewportSize.height)); |
| 73 m_layerTreeHost->GetLayerTree()->SetViewportSize(gfxSize); | 73 m_layerTreeHost->SetViewportSize(gfxSize); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void WebLayerTreeViewImplForTesting::setViewportSize( | 76 void WebLayerTreeViewImplForTesting::setViewportSize( |
| 77 const WebSize& deviceViewportSize) { | 77 const WebSize& deviceViewportSize) { |
| 78 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), | 78 gfx::Size gfxSize(std::max(0, deviceViewportSize.width), |
| 79 std::max(0, deviceViewportSize.height)); | 79 std::max(0, deviceViewportSize.height)); |
| 80 m_layerTreeHost->GetLayerTree()->SetViewportSize(gfxSize); | 80 m_layerTreeHost->SetViewportSize(gfxSize); |
| 81 } | 81 } |
| 82 | 82 |
| 83 WebSize WebLayerTreeViewImplForTesting::getViewportSize() const { | 83 WebSize WebLayerTreeViewImplForTesting::getViewportSize() const { |
| 84 return WebSize( | 84 return WebSize(m_layerTreeHost->device_viewport_size().width(), |
| 85 m_layerTreeHost->GetLayerTree()->device_viewport_size().width(), | 85 m_layerTreeHost->device_viewport_size().height()); |
| 86 m_layerTreeHost->GetLayerTree()->device_viewport_size().height()); | |
| 87 } | 86 } |
| 88 | 87 |
| 89 void WebLayerTreeViewImplForTesting::setDeviceScaleFactor( | 88 void WebLayerTreeViewImplForTesting::setDeviceScaleFactor( |
| 90 float deviceScaleFactor) { | 89 float deviceScaleFactor) { |
| 91 m_layerTreeHost->GetLayerTree()->SetDeviceScaleFactor(deviceScaleFactor); | 90 m_layerTreeHost->SetDeviceScaleFactor(deviceScaleFactor); |
| 92 } | 91 } |
| 93 | 92 |
| 94 void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) { | 93 void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) { |
| 95 m_layerTreeHost->GetLayerTree()->set_background_color(color); | 94 m_layerTreeHost->set_background_color(color); |
| 96 } | 95 } |
| 97 | 96 |
| 98 void WebLayerTreeViewImplForTesting::setHasTransparentBackground( | 97 void WebLayerTreeViewImplForTesting::setHasTransparentBackground( |
| 99 bool transparent) { | 98 bool transparent) { |
| 100 m_layerTreeHost->GetLayerTree()->set_has_transparent_background(transparent); | 99 m_layerTreeHost->set_has_transparent_background(transparent); |
| 101 } | 100 } |
| 102 | 101 |
| 103 void WebLayerTreeViewImplForTesting::setVisible(bool visible) { | 102 void WebLayerTreeViewImplForTesting::setVisible(bool visible) { |
| 104 m_layerTreeHost->SetVisible(visible); | 103 m_layerTreeHost->SetVisible(visible); |
| 105 } | 104 } |
| 106 | 105 |
| 107 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits( | 106 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits( |
| 108 float pageScaleFactor, | 107 float pageScaleFactor, |
| 109 float minimum, | 108 float minimum, |
| 110 float maximum) { | 109 float maximum) { |
| 111 m_layerTreeHost->GetLayerTree()->SetPageScaleFactorAndLimits( | 110 m_layerTreeHost->SetPageScaleFactorAndLimits(pageScaleFactor, minimum, |
| 112 pageScaleFactor, minimum, maximum); | 111 maximum); |
| 113 } | 112 } |
| 114 | 113 |
| 115 void WebLayerTreeViewImplForTesting::startPageScaleAnimation( | 114 void WebLayerTreeViewImplForTesting::startPageScaleAnimation( |
| 116 const blink::WebPoint& scroll, | 115 const blink::WebPoint& scroll, |
| 117 bool useAnchor, | 116 bool useAnchor, |
| 118 float newPageScale, | 117 float newPageScale, |
| 119 double durationSec) {} | 118 double durationSec) {} |
| 120 | 119 |
| 121 void WebLayerTreeViewImplForTesting::setNeedsBeginFrame() { | 120 void WebLayerTreeViewImplForTesting::setNeedsBeginFrame() { |
| 122 m_layerTreeHost->SetNeedsAnimate(); | 121 m_layerTreeHost->SetNeedsAnimate(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 147 | 146 |
| 148 void WebLayerTreeViewImplForTesting::DidFailToInitializeCompositorFrameSink() { | 147 void WebLayerTreeViewImplForTesting::DidFailToInitializeCompositorFrameSink() { |
| 149 ASSERT_NOT_REACHED(); | 148 ASSERT_NOT_REACHED(); |
| 150 } | 149 } |
| 151 | 150 |
| 152 void WebLayerTreeViewImplForTesting::registerViewportLayers( | 151 void WebLayerTreeViewImplForTesting::registerViewportLayers( |
| 153 const blink::WebLayer* overscrollElasticityLayer, | 152 const blink::WebLayer* overscrollElasticityLayer, |
| 154 const blink::WebLayer* pageScaleLayer, | 153 const blink::WebLayer* pageScaleLayer, |
| 155 const blink::WebLayer* innerViewportScrollLayer, | 154 const blink::WebLayer* innerViewportScrollLayer, |
| 156 const blink::WebLayer* outerViewportScrollLayer) { | 155 const blink::WebLayer* outerViewportScrollLayer) { |
| 157 m_layerTreeHost->GetLayerTree()->RegisterViewportLayers( | 156 m_layerTreeHost->RegisterViewportLayers( |
| 158 // The scroll elasticity layer will only exist when using pinch virtual | 157 // The scroll elasticity layer will only exist when using pinch virtual |
| 159 // viewports. | 158 // viewports. |
| 160 overscrollElasticityLayer | 159 overscrollElasticityLayer |
| 161 ? static_cast<const cc_blink::WebLayerImpl*>( | 160 ? static_cast<const cc_blink::WebLayerImpl*>( |
| 162 overscrollElasticityLayer) | 161 overscrollElasticityLayer) |
| 163 ->layer() | 162 ->layer() |
| 164 : nullptr, | 163 : nullptr, |
| 165 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(), | 164 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(), |
| 166 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer) | 165 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer) |
| 167 ->layer(), | 166 ->layer(), |
| 168 // The outer viewport layer will only exist when using pinch virtual | 167 // The outer viewport layer will only exist when using pinch virtual |
| 169 // viewports. | 168 // viewports. |
| 170 outerViewportScrollLayer | 169 outerViewportScrollLayer |
| 171 ? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLayer) | 170 ? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLayer) |
| 172 ->layer() | 171 ->layer() |
| 173 : nullptr); | 172 : nullptr); |
| 174 } | 173 } |
| 175 | 174 |
| 176 void WebLayerTreeViewImplForTesting::clearViewportLayers() { | 175 void WebLayerTreeViewImplForTesting::clearViewportLayers() { |
| 177 m_layerTreeHost->GetLayerTree()->RegisterViewportLayers( | 176 m_layerTreeHost->RegisterViewportLayers( |
| 178 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>(), | 177 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>(), |
| 179 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>()); | 178 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>()); |
| 180 } | 179 } |
| 181 | 180 |
| 182 void WebLayerTreeViewImplForTesting::registerSelection( | 181 void WebLayerTreeViewImplForTesting::registerSelection( |
| 183 const blink::WebSelection& selection) {} | 182 const blink::WebSelection& selection) {} |
| 184 | 183 |
| 185 void WebLayerTreeViewImplForTesting::clearSelection() {} | 184 void WebLayerTreeViewImplForTesting::clearSelection() {} |
| 186 | 185 |
| 187 void WebLayerTreeViewImplForTesting::setEventListenerProperties( | 186 void WebLayerTreeViewImplForTesting::setEventListenerProperties( |
| 188 blink::WebEventListenerClass eventClass, | 187 blink::WebEventListenerClass eventClass, |
| 189 blink::WebEventListenerProperties properties) { | 188 blink::WebEventListenerProperties properties) { |
| 190 // Equality of static_cast is checked in render_widget_compositor.cc. | 189 // Equality of static_cast is checked in render_widget_compositor.cc. |
| 191 m_layerTreeHost->GetLayerTree()->SetEventListenerProperties( | 190 m_layerTreeHost->SetEventListenerProperties( |
| 192 static_cast<cc::EventListenerClass>(eventClass), | 191 static_cast<cc::EventListenerClass>(eventClass), |
| 193 static_cast<cc::EventListenerProperties>(properties)); | 192 static_cast<cc::EventListenerProperties>(properties)); |
| 194 } | 193 } |
| 195 | 194 |
| 196 blink::WebEventListenerProperties | 195 blink::WebEventListenerProperties |
| 197 WebLayerTreeViewImplForTesting::eventListenerProperties( | 196 WebLayerTreeViewImplForTesting::eventListenerProperties( |
| 198 blink::WebEventListenerClass eventClass) const { | 197 blink::WebEventListenerClass eventClass) const { |
| 199 // Equality of static_cast is checked in render_widget_compositor.cc. | 198 // Equality of static_cast is checked in render_widget_compositor.cc. |
| 200 return static_cast<blink::WebEventListenerProperties>( | 199 return static_cast<blink::WebEventListenerProperties>( |
| 201 m_layerTreeHost->GetLayerTree()->event_listener_properties( | 200 m_layerTreeHost->event_listener_properties( |
| 202 static_cast<cc::EventListenerClass>(eventClass))); | 201 static_cast<cc::EventListenerClass>(eventClass))); |
| 203 } | 202 } |
| 204 | 203 |
| 205 void WebLayerTreeViewImplForTesting::setHaveScrollEventHandlers( | 204 void WebLayerTreeViewImplForTesting::setHaveScrollEventHandlers( |
| 206 bool haveEentHandlers) { | 205 bool haveEentHandlers) { |
| 207 m_layerTreeHost->GetLayerTree()->SetHaveScrollEventHandlers(haveEentHandlers); | 206 m_layerTreeHost->SetHaveScrollEventHandlers(haveEentHandlers); |
| 208 } | 207 } |
| 209 | 208 |
| 210 bool WebLayerTreeViewImplForTesting::haveScrollEventHandlers() const { | 209 bool WebLayerTreeViewImplForTesting::haveScrollEventHandlers() const { |
| 211 return m_layerTreeHost->GetLayerTree()->have_scroll_event_handlers(); | 210 return m_layerTreeHost->have_scroll_event_handlers(); |
| 212 } | 211 } |
| 213 | 212 |
| 214 } // namespace blink | 213 } // namespace blink |
| OLD | NEW |