Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1638)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 784463002: Add initial CC support for scroll-blocks-on (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with trunk Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 mask_layer_id_(-1), 47 mask_layer_id_(-1),
48 replica_layer_id_(-1), 48 replica_layer_id_(-1),
49 layer_id_(id), 49 layer_id_(id),
50 layer_tree_impl_(tree_impl), 50 layer_tree_impl_(tree_impl),
51 scroll_offset_(scroll_offset), 51 scroll_offset_(scroll_offset),
52 scroll_offset_delegate_(nullptr), 52 scroll_offset_delegate_(nullptr),
53 scroll_clip_layer_(nullptr), 53 scroll_clip_layer_(nullptr),
54 should_scroll_on_main_thread_(false), 54 should_scroll_on_main_thread_(false),
55 have_wheel_event_handlers_(false), 55 have_wheel_event_handlers_(false),
56 have_scroll_event_handlers_(false), 56 have_scroll_event_handlers_(false),
57 scroll_blocks_on_(ScrollBlocksOnNone),
57 user_scrollable_horizontal_(true), 58 user_scrollable_horizontal_(true),
58 user_scrollable_vertical_(true), 59 user_scrollable_vertical_(true),
59 stacking_order_changed_(false), 60 stacking_order_changed_(false),
60 double_sided_(true), 61 double_sided_(true),
61 should_flatten_transform_(true), 62 should_flatten_transform_(true),
62 layer_property_changed_(false), 63 layer_property_changed_(false),
63 masks_to_bounds_(false), 64 masks_to_bounds_(false),
64 contents_opaque_(false), 65 contents_opaque_(false),
65 is_root_for_isolated_group_(false), 66 is_root_for_isolated_group_(false),
66 use_parent_backface_visibility_(false), 67 use_parent_backface_visibility_(false),
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 : user_scrollable_vertical_; 386 : user_scrollable_vertical_;
386 } 387 }
387 388
388 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { 389 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() {
389 DCHECK(layer_tree_impl()->IsActiveTree()); 390 DCHECK(layer_tree_impl()->IsActiveTree());
390 scroll_offset_->AbortCommit(); 391 scroll_offset_->AbortCommit();
391 } 392 }
392 393
393 InputHandler::ScrollStatus LayerImpl::TryScroll( 394 InputHandler::ScrollStatus LayerImpl::TryScroll(
394 const gfx::PointF& screen_space_point, 395 const gfx::PointF& screen_space_point,
395 InputHandler::ScrollInputType type) const { 396 InputHandler::ScrollInputType type,
397 ScrollBlocksOn effective_block_mode) const {
396 if (should_scroll_on_main_thread()) { 398 if (should_scroll_on_main_thread()) {
397 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); 399 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread");
398 return InputHandler::ScrollOnMainThread; 400 return InputHandler::ScrollOnMainThread;
399 } 401 }
400 402
401 if (!screen_space_transform().IsInvertible()) { 403 if (!screen_space_transform().IsInvertible()) {
402 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); 404 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform");
403 return InputHandler::ScrollIgnored; 405 return InputHandler::ScrollIgnored;
404 } 406 }
405 407
(...skipping 17 matching lines...) Expand all
423 1.f / contents_scale_y()); 425 1.f / contents_scale_y());
424 if (!clipped && 426 if (!clipped &&
425 non_fast_scrollable_region().Contains( 427 non_fast_scrollable_region().Contains(
426 gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { 428 gfx::ToRoundedPoint(hit_test_point_in_layer_space))) {
427 TRACE_EVENT0("cc", 429 TRACE_EVENT0("cc",
428 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); 430 "LayerImpl::tryScroll: Failed NonFastScrollableRegion");
429 return InputHandler::ScrollOnMainThread; 431 return InputHandler::ScrollOnMainThread;
430 } 432 }
431 } 433 }
432 434
433 if (type == InputHandler::Wheel && have_wheel_event_handlers()) { 435 if (have_scroll_event_handlers() &&
436 effective_block_mode & ScrollBlocksOnScrollEvent) {
437 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed ScrollEventHandlers");
438 return InputHandler::ScrollOnMainThread;
439 }
440
441 if (type == InputHandler::Wheel && have_wheel_event_handlers() &&
442 effective_block_mode & ScrollBlocksOnWheelEvent) {
434 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers"); 443 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers");
435 return InputHandler::ScrollOnMainThread; 444 return InputHandler::ScrollOnMainThread;
436 } 445 }
437 446
438 if (!scrollable()) { 447 if (!scrollable()) {
439 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); 448 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable");
440 return InputHandler::ScrollIgnored; 449 return InputHandler::ScrollIgnored;
441 } 450 }
442 451
443 gfx::ScrollOffset max_scroll_offset = MaxScrollOffset(); 452 gfx::ScrollOffset max_scroll_offset = MaxScrollOffset();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 draw_checkerboard_for_missing_tiles_); 489 draw_checkerboard_for_missing_tiles_);
481 layer->SetDrawsContent(DrawsContent()); 490 layer->SetDrawsContent(DrawsContent());
482 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 491 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
483 layer->SetHasRenderSurface(!!render_surface()); 492 layer->SetHasRenderSurface(!!render_surface());
484 layer->SetFilters(filters()); 493 layer->SetFilters(filters());
485 layer->SetBackgroundFilters(background_filters()); 494 layer->SetBackgroundFilters(background_filters());
486 layer->SetMasksToBounds(masks_to_bounds_); 495 layer->SetMasksToBounds(masks_to_bounds_);
487 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); 496 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
488 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); 497 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_);
489 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); 498 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_);
499 layer->SetScrollBlocksOn(scroll_blocks_on_);
490 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 500 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
491 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 501 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
492 layer->SetContentsOpaque(contents_opaque_); 502 layer->SetContentsOpaque(contents_opaque_);
493 layer->SetOpacity(opacity_); 503 layer->SetOpacity(opacity_);
494 layer->SetBlendMode(blend_mode_); 504 layer->SetBlendMode(blend_mode_);
495 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); 505 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_);
496 layer->SetPosition(position_); 506 layer->SetPosition(position_);
497 layer->SetIsContainerForFixedPositionLayers( 507 layer->SetIsContainerForFixedPositionLayers(
498 is_container_for_fixed_position_layers_); 508 is_container_for_fixed_position_layers_);
499 layer->SetPositionConstraint(position_constraint_); 509 layer->SetPositionConstraint(position_constraint_);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 652
643 if (have_wheel_event_handlers_) 653 if (have_wheel_event_handlers_)
644 result->SetBoolean("WheelHandler", have_wheel_event_handlers_); 654 result->SetBoolean("WheelHandler", have_wheel_event_handlers_);
645 if (have_scroll_event_handlers_) 655 if (have_scroll_event_handlers_)
646 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); 656 result->SetBoolean("ScrollHandler", have_scroll_event_handlers_);
647 if (!touch_event_handler_region_.IsEmpty()) { 657 if (!touch_event_handler_region_.IsEmpty()) {
648 scoped_ptr<base::Value> region = touch_event_handler_region_.AsValue(); 658 scoped_ptr<base::Value> region = touch_event_handler_region_.AsValue();
649 result->Set("TouchRegion", region.release()); 659 result->Set("TouchRegion", region.release());
650 } 660 }
651 661
662 if (scroll_blocks_on_) {
663 list = new base::ListValue;
664 if (scroll_blocks_on_ & ScrollBlocksOnStartTouch)
665 list->AppendString("StartTouch");
666 if (scroll_blocks_on_ & ScrollBlocksOnWheelEvent)
667 list->AppendString("WheelEvent");
668 if (scroll_blocks_on_ & ScrollBlocksOnScrollEvent)
669 list->AppendString("ScrollEvent");
670 result->Set("ScrollBlocksOn", list);
671 }
672
652 list = new base::ListValue; 673 list = new base::ListValue;
653 for (size_t i = 0; i < children_.size(); ++i) 674 for (size_t i = 0; i < children_.size(); ++i)
654 list->Append(children_[i]->LayerTreeAsJson()); 675 list->Append(children_[i]->LayerTreeAsJson());
655 result->Set("Children", list); 676 result->Set("Children", list);
656 677
657 return result; 678 return result;
658 } 679 }
659 680
660 void LayerImpl::SetStackingOrderChanged(bool stacking_order_changed) { 681 void LayerImpl::SetStackingOrderChanged(bool stacking_order_changed) {
661 if (stacking_order_changed) { 682 if (stacking_order_changed) {
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 Region scroll_region(scroll_rect); 1454 Region scroll_region(scroll_rect);
1434 state->BeginArray("scroll_event_handler_region"); 1455 state->BeginArray("scroll_event_handler_region");
1435 scroll_region.AsValueInto(state); 1456 scroll_region.AsValueInto(state);
1436 state->EndArray(); 1457 state->EndArray();
1437 } 1458 }
1438 if (!non_fast_scrollable_region_.IsEmpty()) { 1459 if (!non_fast_scrollable_region_.IsEmpty()) {
1439 state->BeginArray("non_fast_scrollable_region"); 1460 state->BeginArray("non_fast_scrollable_region");
1440 non_fast_scrollable_region_.AsValueInto(state); 1461 non_fast_scrollable_region_.AsValueInto(state);
1441 state->EndArray(); 1462 state->EndArray();
1442 } 1463 }
1464 if (scroll_blocks_on_) {
1465 state->SetInteger("scroll_blocks_on", scroll_blocks_on_);
1466 }
1443 1467
1444 state->BeginArray("children"); 1468 state->BeginArray("children");
1445 for (size_t i = 0; i < children_.size(); ++i) { 1469 for (size_t i = 0; i < children_.size(); ++i) {
1446 state->BeginDictionary(); 1470 state->BeginDictionary();
1447 children_[i]->AsValueInto(state); 1471 children_[i]->AsValueInto(state);
1448 state->EndDictionary(); 1472 state->EndDictionary();
1449 } 1473 }
1450 state->EndArray(); 1474 state->EndArray();
1451 if (mask_layer_) { 1475 if (mask_layer_) {
1452 state->BeginDictionary("mask_layer"); 1476 state->BeginDictionary("mask_layer");
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 SetNeedsPushProperties(); 1562 SetNeedsPushProperties();
1539 layer_tree_impl()->set_needs_update_draw_properties(); 1563 layer_tree_impl()->set_needs_update_draw_properties();
1540 if (should_have_render_surface) { 1564 if (should_have_render_surface) {
1541 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); 1565 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this));
1542 return; 1566 return;
1543 } 1567 }
1544 render_surface_.reset(); 1568 render_surface_.reset();
1545 } 1569 }
1546 1570
1547 } // namespace cc 1571 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698