| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sky/viewer/cc/web_layer_impl.h" | 5 #include "sky/viewer/cc/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" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 return layer_->should_scroll_on_main_thread(); | 329 return layer_->should_scroll_on_main_thread(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void WebLayerImpl::setNonFastScrollableRegion(const WebVector<WebRect>& rects) { | 332 void WebLayerImpl::setNonFastScrollableRegion(const WebVector<WebRect>& rects) { |
| 333 cc::Region region; | 333 cc::Region region; |
| 334 for (size_t i = 0; i < rects.size(); ++i) | 334 for (size_t i = 0; i < rects.size(); ++i) |
| 335 region.Union(rects[i]); | 335 region.Union(rects[i]); |
| 336 layer_->SetNonFastScrollableRegion(region); | 336 layer_->SetNonFastScrollableRegion(region); |
| 337 } | 337 } |
| 338 | 338 |
| 339 WebVector<WebRect> WebLayerImpl::nonFastScrollableRegion() const { | |
| 340 size_t num_rects = 0; | |
| 341 for (cc::Region::Iterator region_rects(layer_->non_fast_scrollable_region()); | |
| 342 region_rects.has_rect(); | |
| 343 region_rects.next()) | |
| 344 ++num_rects; | |
| 345 | |
| 346 WebVector<WebRect> result(num_rects); | |
| 347 size_t i = 0; | |
| 348 for (cc::Region::Iterator region_rects(layer_->non_fast_scrollable_region()); | |
| 349 region_rects.has_rect(); | |
| 350 region_rects.next()) { | |
| 351 result[i] = region_rects.rect(); | |
| 352 ++i; | |
| 353 } | |
| 354 return result; | |
| 355 } | |
| 356 | |
| 357 void WebLayerImpl::setTouchEventHandlerRegion(const WebVector<WebRect>& rects) { | |
| 358 cc::Region region; | |
| 359 for (size_t i = 0; i < rects.size(); ++i) | |
| 360 region.Union(rects[i]); | |
| 361 layer_->SetTouchEventHandlerRegion(region); | |
| 362 } | |
| 363 | |
| 364 WebVector<WebRect> WebLayerImpl::touchEventHandlerRegion() const { | |
| 365 size_t num_rects = 0; | |
| 366 for (cc::Region::Iterator region_rects(layer_->touch_event_handler_region()); | |
| 367 region_rects.has_rect(); | |
| 368 region_rects.next()) | |
| 369 ++num_rects; | |
| 370 | |
| 371 WebVector<WebRect> result(num_rects); | |
| 372 size_t i = 0; | |
| 373 for (cc::Region::Iterator region_rects(layer_->touch_event_handler_region()); | |
| 374 region_rects.has_rect(); | |
| 375 region_rects.next()) { | |
| 376 result[i] = region_rects.rect(); | |
| 377 ++i; | |
| 378 } | |
| 379 return result; | |
| 380 } | |
| 381 | |
| 382 void WebLayerImpl::setScrollClient(blink::WebLayerScrollClient* scroll_client) { | 339 void WebLayerImpl::setScrollClient(blink::WebLayerScrollClient* scroll_client) { |
| 383 if (scroll_client) { | 340 if (scroll_client) { |
| 384 layer_->set_did_scroll_callback( | 341 layer_->set_did_scroll_callback( |
| 385 base::Bind(&blink::WebLayerScrollClient::didScroll, | 342 base::Bind(&blink::WebLayerScrollClient::didScroll, |
| 386 base::Unretained(scroll_client))); | 343 base::Unretained(scroll_client))); |
| 387 } else { | 344 } else { |
| 388 layer_->set_did_scroll_callback(base::Closure()); | 345 layer_->set_did_scroll_callback(base::Closure()); |
| 389 } | 346 } |
| 390 } | 347 } |
| 391 | 348 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 if (parent) | 397 if (parent) |
| 441 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 398 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
| 442 layer_->SetClipParent(clip_parent); | 399 layer_->SetClipParent(clip_parent); |
| 443 } | 400 } |
| 444 | 401 |
| 445 Layer* WebLayerImpl::layer() const { | 402 Layer* WebLayerImpl::layer() const { |
| 446 return layer_.get(); | 403 return layer_.get(); |
| 447 } | 404 } |
| 448 | 405 |
| 449 } // namespace sky_viewer_cc | 406 } // namespace sky_viewer_cc |
| OLD | NEW |