| OLD | NEW | 
|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "webkit/renderer/compositor_bindings/web_layer_impl.h" | 5 #include "content/renderer/compositor_bindings/web_layer_impl.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/debug/trace_event_impl.h" | 8 #include "base/debug/trace_event_impl.h" | 
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" | 
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" | 
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" | 
| 12 #include "cc/animation/animation.h" | 12 #include "cc/animation/animation.h" | 
| 13 #include "cc/base/region.h" | 13 #include "cc/base/region.h" | 
| 14 #include "cc/base/switches.h" | 14 #include "cc/base/switches.h" | 
| 15 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" | 
| 16 #include "cc/layers/layer_position_constraint.h" | 16 #include "cc/layers/layer_position_constraint.h" | 
| 17 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" | 
|  | 18 #include "content/renderer/compositor_bindings/web_animation_impl.h" | 
|  | 19 #include "content/renderer/compositor_bindings/web_blend_mode.h" | 
|  | 20 #include "content/renderer/compositor_bindings/web_filter_operations_impl.h" | 
|  | 21 #include "content/renderer/compositor_bindings/web_to_cc_animation_delegate_adap
     ter.h" | 
| 18 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 22 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 
| 19 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 23 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 
| 20 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" | 24 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" | 
| 21 #include "third_party/WebKit/public/platform/WebLayerClient.h" | 25 #include "third_party/WebKit/public/platform/WebLayerClient.h" | 
| 22 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 26 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 
| 23 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 27 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 
| 24 #include "third_party/WebKit/public/platform/WebSize.h" | 28 #include "third_party/WebKit/public/platform/WebSize.h" | 
| 25 #include "third_party/skia/include/utils/SkMatrix44.h" | 29 #include "third_party/skia/include/utils/SkMatrix44.h" | 
| 26 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" |  | 
| 27 #include "webkit/renderer/compositor_bindings/web_blend_mode.h" |  | 
| 28 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" |  | 
| 29 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
     er.h" |  | 
| 30 | 30 | 
| 31 using cc::Animation; | 31 using cc::Animation; | 
| 32 using cc::Layer; | 32 using cc::Layer; | 
| 33 using blink::WebLayer; | 33 using blink::WebLayer; | 
| 34 using blink::WebFloatPoint; | 34 using blink::WebFloatPoint; | 
| 35 using blink::WebVector; | 35 using blink::WebVector; | 
| 36 using blink::WebRect; | 36 using blink::WebRect; | 
| 37 using blink::WebSize; | 37 using blink::WebSize; | 
| 38 using blink::WebColor; | 38 using blink::WebColor; | 
| 39 using blink::WebFilterOperations; | 39 using blink::WebFilterOperations; | 
| 40 | 40 | 
| 41 namespace webkit { | 41 namespace content { | 
| 42 namespace { | 42 namespace { | 
| 43 | 43 | 
| 44 bool g_impl_side_painting_enabled = false; | 44 bool g_impl_side_painting_enabled = false; | 
| 45 | 45 | 
| 46 }  // namespace | 46 }  // namespace | 
| 47 | 47 | 
| 48 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { | 48 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { | 
| 49   web_layer_client_ = NULL; | 49   web_layer_client_ = NULL; | 
| 50   layer_->SetLayerClient(this); | 50   layer_->SetLayerClient(this); | 
| 51 } | 51 } | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 64 // static | 64 // static | 
| 65 bool WebLayerImpl::UsingPictureLayer() { | 65 bool WebLayerImpl::UsingPictureLayer() { | 
| 66   return g_impl_side_painting_enabled; | 66   return g_impl_side_painting_enabled; | 
| 67 } | 67 } | 
| 68 | 68 | 
| 69 // static | 69 // static | 
| 70 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { | 70 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { | 
| 71   g_impl_side_painting_enabled = enabled; | 71   g_impl_side_painting_enabled = enabled; | 
| 72 } | 72 } | 
| 73 | 73 | 
| 74 int WebLayerImpl::id() const { return layer_->id(); } | 74 int WebLayerImpl::id() const { | 
|  | 75   return layer_->id(); | 
|  | 76 } | 
| 75 | 77 | 
| 76 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { | 78 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { | 
| 77   layer_->SetNeedsDisplayRect(rect); | 79   layer_->SetNeedsDisplayRect(rect); | 
| 78 } | 80 } | 
| 79 | 81 | 
| 80 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } | 82 void WebLayerImpl::invalidate() { | 
|  | 83   layer_->SetNeedsDisplay(); | 
|  | 84 } | 
| 81 | 85 | 
| 82 void WebLayerImpl::addChild(WebLayer* child) { | 86 void WebLayerImpl::addChild(WebLayer* child) { | 
| 83   layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); | 87   layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); | 
| 84 } | 88 } | 
| 85 | 89 | 
| 86 void WebLayerImpl::insertChild(WebLayer* child, size_t index) { | 90 void WebLayerImpl::insertChild(WebLayer* child, size_t index) { | 
| 87   layer_->InsertChild(static_cast<WebLayerImpl*>(child)->layer(), index); | 91   layer_->InsertChild(static_cast<WebLayerImpl*>(child)->layer(), index); | 
| 88 } | 92 } | 
| 89 | 93 | 
| 90 void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* new_layer) { | 94 void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* new_layer) { | 
| 91   layer_->ReplaceChild(static_cast<WebLayerImpl*>(reference)->layer(), | 95   layer_->ReplaceChild(static_cast<WebLayerImpl*>(reference)->layer(), | 
| 92                        static_cast<WebLayerImpl*>(new_layer)->layer()); | 96                        static_cast<WebLayerImpl*>(new_layer)->layer()); | 
| 93 } | 97 } | 
| 94 | 98 | 
| 95 void WebLayerImpl::removeFromParent() { layer_->RemoveFromParent(); } | 99 void WebLayerImpl::removeFromParent() { | 
|  | 100   layer_->RemoveFromParent(); | 
|  | 101 } | 
| 96 | 102 | 
| 97 void WebLayerImpl::removeAllChildren() { layer_->RemoveAllChildren(); } | 103 void WebLayerImpl::removeAllChildren() { | 
|  | 104   layer_->RemoveAllChildren(); | 
|  | 105 } | 
| 98 | 106 | 
| 99 void WebLayerImpl::setBounds(const WebSize& size) { layer_->SetBounds(size); } | 107 void WebLayerImpl::setBounds(const WebSize& size) { layer_->SetBounds(size); } | 
| 100 | 108 | 
| 101 WebSize WebLayerImpl::bounds() const { return layer_->bounds(); } | 109 WebSize WebLayerImpl::bounds() const { | 
|  | 110   return layer_->bounds(); | 
|  | 111 } | 
| 102 | 112 | 
| 103 void WebLayerImpl::setMasksToBounds(bool masks_to_bounds) { | 113 void WebLayerImpl::setMasksToBounds(bool masks_to_bounds) { | 
| 104   layer_->SetMasksToBounds(masks_to_bounds); | 114   layer_->SetMasksToBounds(masks_to_bounds); | 
| 105 } | 115 } | 
| 106 | 116 | 
| 107 bool WebLayerImpl::masksToBounds() const { return layer_->masks_to_bounds(); } | 117 bool WebLayerImpl::masksToBounds() const { | 
|  | 118   return layer_->masks_to_bounds(); | 
|  | 119 } | 
| 108 | 120 | 
| 109 void WebLayerImpl::setMaskLayer(WebLayer* maskLayer) { | 121 void WebLayerImpl::setMaskLayer(WebLayer* maskLayer) { | 
| 110   layer_->SetMaskLayer( | 122   layer_->SetMaskLayer( | 
| 111       maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->layer() : 0); | 123       maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->layer() : 0); | 
| 112 } | 124 } | 
| 113 | 125 | 
| 114 void WebLayerImpl::setReplicaLayer(WebLayer* replica_layer) { | 126 void WebLayerImpl::setReplicaLayer(WebLayer* replica_layer) { | 
| 115   layer_->SetReplicaLayer( | 127   layer_->SetReplicaLayer( | 
| 116       replica_layer ? static_cast<WebLayerImpl*>(replica_layer)->layer() : 0); | 128       replica_layer ? static_cast<WebLayerImpl*>(replica_layer)->layer() : 0); | 
| 117 } | 129 } | 
| 118 | 130 | 
| 119 void WebLayerImpl::setOpacity(float opacity) { layer_->SetOpacity(opacity); } | 131 void WebLayerImpl::setOpacity(float opacity) { | 
|  | 132   layer_->SetOpacity(opacity); | 
|  | 133 } | 
| 120 | 134 | 
| 121 float WebLayerImpl::opacity() const { return layer_->opacity(); } | 135 float WebLayerImpl::opacity() const { | 
|  | 136   return layer_->opacity(); | 
|  | 137 } | 
| 122 | 138 | 
| 123 void WebLayerImpl::setBlendMode(blink::WebBlendMode blend_mode) { | 139 void WebLayerImpl::setBlendMode(blink::WebBlendMode blend_mode) { | 
| 124   layer_->SetBlendMode(BlendModeToSkia(blend_mode)); | 140   layer_->SetBlendMode(BlendModeToSkia(blend_mode)); | 
| 125 } | 141 } | 
| 126 | 142 | 
| 127 blink::WebBlendMode WebLayerImpl::blendMode() const { | 143 blink::WebBlendMode WebLayerImpl::blendMode() const { | 
| 128   return BlendModeFromSkia(layer_->blend_mode()); | 144   return BlendModeFromSkia(layer_->blend_mode()); | 
| 129 } | 145 } | 
| 130 | 146 | 
| 131 void WebLayerImpl::setIsRootForIsolatedGroup(bool isolate) { | 147 void WebLayerImpl::setIsRootForIsolatedGroup(bool isolate) { | 
| 132   layer_->SetIsRootForIsolatedGroup(isolate); | 148   layer_->SetIsRootForIsolatedGroup(isolate); | 
| 133 } | 149 } | 
| 134 | 150 | 
| 135 bool WebLayerImpl::isRootForIsolatedGroup() { | 151 bool WebLayerImpl::isRootForIsolatedGroup() { | 
| 136   return layer_->is_root_for_isolated_group(); | 152   return layer_->is_root_for_isolated_group(); | 
| 137 } | 153 } | 
| 138 | 154 | 
| 139 void WebLayerImpl::setOpaque(bool opaque) { layer_->SetContentsOpaque(opaque); } | 155 void WebLayerImpl::setOpaque(bool opaque) { | 
|  | 156   layer_->SetContentsOpaque(opaque); | 
|  | 157 } | 
| 140 | 158 | 
| 141 bool WebLayerImpl::opaque() const { return layer_->contents_opaque(); } | 159 bool WebLayerImpl::opaque() const { | 
|  | 160   return layer_->contents_opaque(); | 
|  | 161 } | 
| 142 | 162 | 
| 143 void WebLayerImpl::setPosition(const WebFloatPoint& position) { | 163 void WebLayerImpl::setPosition(const WebFloatPoint& position) { | 
| 144   layer_->SetPosition(position); | 164   layer_->SetPosition(position); | 
| 145 } | 165 } | 
| 146 | 166 | 
| 147 WebFloatPoint WebLayerImpl::position() const { return layer_->position(); } | 167 WebFloatPoint WebLayerImpl::position() const { | 
|  | 168   return layer_->position(); | 
|  | 169 } | 
| 148 | 170 | 
| 149 void WebLayerImpl::setTransform(const SkMatrix44& matrix) { | 171 void WebLayerImpl::setTransform(const SkMatrix44& matrix) { | 
| 150   gfx::Transform transform; | 172   gfx::Transform transform; | 
| 151   transform.matrix() = matrix; | 173   transform.matrix() = matrix; | 
| 152   layer_->SetTransform(transform); | 174   layer_->SetTransform(transform); | 
| 153 } | 175 } | 
| 154 | 176 | 
| 155 void WebLayerImpl::setTransformOrigin(const blink::WebFloatPoint3D& point) { | 177 void WebLayerImpl::setTransformOrigin(const blink::WebFloatPoint3D& point) { | 
| 156   gfx::Point3F gfx_point = point; | 178   gfx::Point3F gfx_point = point; | 
| 157   layer_->SetTransformOrigin(gfx_point); | 179   layer_->SetTransformOrigin(gfx_point); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 174 }; | 196 }; | 
| 175 | 197 | 
| 176 SkMatrix44 WebLayerImpl::transform() const { | 198 SkMatrix44 WebLayerImpl::transform() const { | 
| 177   return layer_->transform().matrix(); | 199   return layer_->transform().matrix(); | 
| 178 } | 200 } | 
| 179 | 201 | 
| 180 void WebLayerImpl::setDrawsContent(bool draws_content) { | 202 void WebLayerImpl::setDrawsContent(bool draws_content) { | 
| 181   layer_->SetIsDrawable(draws_content); | 203   layer_->SetIsDrawable(draws_content); | 
| 182 } | 204 } | 
| 183 | 205 | 
| 184 bool WebLayerImpl::drawsContent() const { return layer_->DrawsContent(); } | 206 bool WebLayerImpl::drawsContent() const { | 
|  | 207   return layer_->DrawsContent(); | 
|  | 208 } | 
| 185 | 209 | 
| 186 void WebLayerImpl::setShouldFlattenTransform(bool flatten) { | 210 void WebLayerImpl::setShouldFlattenTransform(bool flatten) { | 
| 187   layer_->SetShouldFlattenTransform(flatten); | 211   layer_->SetShouldFlattenTransform(flatten); | 
| 188 } | 212 } | 
| 189 | 213 | 
| 190 void WebLayerImpl::setRenderingContext(int context) { | 214 void WebLayerImpl::setRenderingContext(int context) { | 
| 191   layer_->SetIs3dSorted(context != 0); | 215   layer_->SetIs3dSorted(context != 0); | 
| 192 } | 216 } | 
| 193 | 217 | 
| 194 void WebLayerImpl::setUseParentBackfaceVisibility( | 218 void WebLayerImpl::setUseParentBackfaceVisibility( | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 209       static_cast<const WebFilterOperationsImpl&>(filters); | 233       static_cast<const WebFilterOperationsImpl&>(filters); | 
| 210   layer_->SetFilters(filters_impl.AsFilterOperations()); | 234   layer_->SetFilters(filters_impl.AsFilterOperations()); | 
| 211 } | 235 } | 
| 212 | 236 | 
| 213 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 237 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 
| 214   const WebFilterOperationsImpl& filters_impl = | 238   const WebFilterOperationsImpl& filters_impl = | 
| 215       static_cast<const WebFilterOperationsImpl&>(filters); | 239       static_cast<const WebFilterOperationsImpl&>(filters); | 
| 216   layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | 240   layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | 
| 217 } | 241 } | 
| 218 | 242 | 
| 219 void WebLayerImpl::setAnimationDelegate( | 243 void WebLayerImpl::setAnimationDelegate(blink::WebAnimationDelegate* delegate) { | 
| 220       blink::WebAnimationDelegate* delegate) { |  | 
| 221   animation_delegate_adapter_.reset( | 244   animation_delegate_adapter_.reset( | 
| 222       new WebToCCAnimationDelegateAdapter(delegate)); | 245       new WebToCCAnimationDelegateAdapter(delegate)); | 
| 223   layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | 246   layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | 
| 224 } | 247 } | 
| 225 | 248 | 
| 226 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { | 249 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { | 
| 227   bool result = layer_->AddAnimation( | 250   bool result = layer_->AddAnimation( | 
| 228       static_cast<WebAnimationImpl*>(animation)->PassAnimation()); | 251       static_cast<WebAnimationImpl*>(animation)->PassAnimation()); | 
| 229   delete animation; | 252   delete animation; | 
| 230   return result; | 253   return result; | 
| 231 } | 254 } | 
| 232 | 255 | 
| 233 void WebLayerImpl::removeAnimation(int animation_id) { | 256 void WebLayerImpl::removeAnimation(int animation_id) { | 
| 234   layer_->RemoveAnimation(animation_id); | 257   layer_->RemoveAnimation(animation_id); | 
| 235 } | 258 } | 
| 236 | 259 | 
| 237 void WebLayerImpl::removeAnimation( | 260 void WebLayerImpl::removeAnimation( | 
| 238     int animation_id, | 261     int animation_id, | 
| 239     blink::WebAnimation::TargetProperty target_property) { | 262     blink::WebAnimation::TargetProperty target_property) { | 
| 240   layer_->layer_animation_controller()->RemoveAnimation( | 263   layer_->layer_animation_controller()->RemoveAnimation( | 
| 241       animation_id, | 264       animation_id, static_cast<Animation::TargetProperty>(target_property)); | 
| 242       static_cast<Animation::TargetProperty>(target_property)); |  | 
| 243 } | 265 } | 
| 244 | 266 | 
| 245 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { | 267 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { | 
| 246   layer_->PauseAnimation(animation_id, time_offset); | 268   layer_->PauseAnimation(animation_id, time_offset); | 
| 247 } | 269 } | 
| 248 | 270 | 
| 249 bool WebLayerImpl::hasActiveAnimation() { return layer_->HasActiveAnimation(); } | 271 bool WebLayerImpl::hasActiveAnimation() { | 
|  | 272   return layer_->HasActiveAnimation(); | 
|  | 273 } | 
| 250 | 274 | 
| 251 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { | 275 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { | 
| 252   layer_->SetForceRenderSurface(force_render_surface); | 276   layer_->SetForceRenderSurface(force_render_surface); | 
| 253 } | 277 } | 
| 254 | 278 | 
| 255 void WebLayerImpl::setScrollPosition(blink::WebPoint position) { | 279 void WebLayerImpl::setScrollPosition(blink::WebPoint position) { | 
| 256   layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin()); | 280   layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin()); | 
| 257 } | 281 } | 
| 258 | 282 | 
| 259 blink::WebPoint WebLayerImpl::scrollPosition() const { | 283 blink::WebPoint WebLayerImpl::scrollPosition() const { | 
| 260   return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset()); | 284   return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset()); | 
| 261 } | 285 } | 
| 262 | 286 | 
| 263 void WebLayerImpl::setScrollClipLayer(WebLayer* clip_layer) { | 287 void WebLayerImpl::setScrollClipLayer(WebLayer* clip_layer) { | 
| 264   if (!clip_layer) { | 288   if (!clip_layer) { | 
| 265     layer_->SetScrollClipLayerId(Layer::INVALID_ID); | 289     layer_->SetScrollClipLayerId(Layer::INVALID_ID); | 
| 266     return; | 290     return; | 
| 267   } | 291   } | 
| 268   layer_->SetScrollClipLayerId(clip_layer->id()); | 292   layer_->SetScrollClipLayerId(clip_layer->id()); | 
| 269 } | 293 } | 
| 270 | 294 | 
| 271 bool WebLayerImpl::scrollable() const { return layer_->scrollable(); } | 295 bool WebLayerImpl::scrollable() const { | 
|  | 296   return layer_->scrollable(); | 
|  | 297 } | 
| 272 | 298 | 
| 273 void WebLayerImpl::setUserScrollable(bool horizontal, bool vertical) { | 299 void WebLayerImpl::setUserScrollable(bool horizontal, bool vertical) { | 
| 274   layer_->SetUserScrollable(horizontal, vertical); | 300   layer_->SetUserScrollable(horizontal, vertical); | 
| 275 } | 301 } | 
| 276 | 302 | 
| 277 bool WebLayerImpl::userScrollableHorizontal() const { | 303 bool WebLayerImpl::userScrollableHorizontal() const { | 
| 278   return layer_->user_scrollable_horizontal(); | 304   return layer_->user_scrollable_horizontal(); | 
| 279 } | 305 } | 
| 280 | 306 | 
| 281 bool WebLayerImpl::userScrollableVertical() const { | 307 bool WebLayerImpl::userScrollableVertical() const { | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 385 | 411 | 
| 386 void WebLayerImpl::setPositionConstraint( | 412 void WebLayerImpl::setPositionConstraint( | 
| 387     const blink::WebLayerPositionConstraint& constraint) { | 413     const blink::WebLayerPositionConstraint& constraint) { | 
| 388   layer_->SetPositionConstraint(ToLayerPositionConstraint(constraint)); | 414   layer_->SetPositionConstraint(ToLayerPositionConstraint(constraint)); | 
| 389 } | 415 } | 
| 390 | 416 | 
| 391 blink::WebLayerPositionConstraint WebLayerImpl::positionConstraint() const { | 417 blink::WebLayerPositionConstraint WebLayerImpl::positionConstraint() const { | 
| 392   return ToWebLayerPositionConstraint(layer_->position_constraint()); | 418   return ToWebLayerPositionConstraint(layer_->position_constraint()); | 
| 393 } | 419 } | 
| 394 | 420 | 
| 395 void WebLayerImpl::setScrollClient( | 421 void WebLayerImpl::setScrollClient(blink::WebLayerScrollClient* scroll_client) { | 
| 396     blink::WebLayerScrollClient* scroll_client) { |  | 
| 397   if (scroll_client) { | 422   if (scroll_client) { | 
| 398     layer_->set_did_scroll_callback( | 423     layer_->set_did_scroll_callback( | 
| 399         base::Bind(&blink::WebLayerScrollClient::didScroll, | 424         base::Bind(&blink::WebLayerScrollClient::didScroll, | 
| 400                    base::Unretained(scroll_client))); | 425                    base::Unretained(scroll_client))); | 
| 401   } else { | 426   } else { | 
| 402     layer_->set_did_scroll_callback(base::Closure()); | 427     layer_->set_did_scroll_callback(base::Closure()); | 
| 403   } | 428   } | 
| 404 } | 429 } | 
| 405 | 430 | 
| 406 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } | 431 bool WebLayerImpl::isOrphan() const { | 
|  | 432   return !layer_->layer_tree_host(); | 
|  | 433 } | 
| 407 | 434 | 
| 408 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { | 435 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { | 
| 409   web_layer_client_ = client; | 436   web_layer_client_ = client; | 
| 410 } | 437 } | 
| 411 | 438 | 
| 412 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { | 439 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { | 
| 413  public: | 440  public: | 
| 414   // This object takes ownership of the debug_info object. | 441   // This object takes ownership of the debug_info object. | 
| 415   explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) : | 442   explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) | 
| 416     debug_info_(debug_info) {} | 443       : debug_info_(debug_info) {} | 
| 417   virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | 444   virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | 
| 418     DCHECK(thread_checker_.CalledOnValidThread()); | 445     DCHECK(thread_checker_.CalledOnValidThread()); | 
| 419     blink::WebString web_string; | 446     blink::WebString web_string; | 
| 420     debug_info_->appendAsTraceFormat(&web_string); | 447     debug_info_->appendAsTraceFormat(&web_string); | 
| 421     out->append(web_string.utf8()); | 448     out->append(web_string.utf8()); | 
| 422   } | 449   } | 
|  | 450 | 
| 423  private: | 451  private: | 
| 424   virtual ~TracedDebugInfo() {} | 452   virtual ~TracedDebugInfo() {} | 
| 425   scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; | 453   scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; | 
| 426   base::ThreadChecker thread_checker_; | 454   base::ThreadChecker thread_checker_; | 
| 427 }; | 455 }; | 
| 428 | 456 | 
| 429 scoped_refptr<base::debug::ConvertableToTraceFormat> | 457 scoped_refptr<base::debug::ConvertableToTraceFormat> | 
| 430     WebLayerImpl::TakeDebugInfo() { | 458 WebLayerImpl::TakeDebugInfo() { | 
| 431   if (!web_layer_client_) | 459   if (!web_layer_client_) | 
| 432     return NULL; | 460     return NULL; | 
| 433   blink::WebGraphicsLayerDebugInfo* debug_info = | 461   blink::WebGraphicsLayerDebugInfo* debug_info = | 
| 434       web_layer_client_->takeDebugInfoFor(this); | 462       web_layer_client_->takeDebugInfoFor(this); | 
| 435 | 463 | 
| 436   if (debug_info) | 464   if (debug_info) | 
| 437     return new TracedDebugInfo(debug_info); | 465     return new TracedDebugInfo(debug_info); | 
| 438   else | 466   else | 
| 439     return NULL; | 467     return NULL; | 
| 440 } | 468 } | 
| 441 | 469 | 
| 442 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { | 470 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { | 
| 443   cc::Layer* scroll_parent = NULL; | 471   cc::Layer* scroll_parent = NULL; | 
| 444   if (parent) | 472   if (parent) | 
| 445     scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 473     scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 
| 446   layer_->SetScrollParent(scroll_parent); | 474   layer_->SetScrollParent(scroll_parent); | 
| 447 } | 475 } | 
| 448 | 476 | 
| 449 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 477 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 
| 450   cc::Layer* clip_parent = NULL; | 478   cc::Layer* clip_parent = NULL; | 
| 451   if (parent) | 479   if (parent) | 
| 452     clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 480     clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 
| 453   layer_->SetClipParent(clip_parent); | 481   layer_->SetClipParent(clip_parent); | 
| 454 } | 482 } | 
| 455 | 483 | 
| 456 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 484 Layer* WebLayerImpl::layer() const { | 
|  | 485   return layer_.get(); | 
|  | 486 } | 
| 457 | 487 | 
| 458 }  // namespace webkit | 488 }  // namespace content | 
|  | 489 | 
| OLD | NEW | 
|---|