diff options
34 files changed, 101 insertions, 105 deletions
diff --git a/cc/blink/web_layer_impl.cc b/cc/blink/web_layer_impl.cc index 67e4f19..d373f80 100644 --- a/cc/blink/web_layer_impl.cc +++ b/cc/blink/web_layer_impl.cc @@ -320,14 +320,6 @@ bool WebLayerImpl::userScrollableVertical() const { return layer_->user_scrollable_vertical(); } -void WebLayerImpl::setHaveScrollEventHandlers(bool have_scroll_event_handlers) { - layer_->SetHaveScrollEventHandlers(have_scroll_event_handlers); -} - -bool WebLayerImpl::haveScrollEventHandlers() const { - return layer_->have_scroll_event_handlers(); -} - void WebLayerImpl::addMainThreadScrollingReasons( uint32_t main_thread_scrolling_reasons) { DCHECK(main_thread_scrolling_reasons); diff --git a/cc/blink/web_layer_impl.h b/cc/blink/web_layer_impl.h index b1bebdb..3dbc41e 100644 --- a/cc/blink/web_layer_impl.h +++ b/cc/blink/web_layer_impl.h @@ -121,8 +121,6 @@ class WebLayerImpl : public blink::WebLayer { void setUserScrollable(bool horizontal, bool vertical) override; bool userScrollableHorizontal() const override; bool userScrollableVertical() const override; - void setHaveScrollEventHandlers(bool have_scroll_event_handlers) override; - bool haveScrollEventHandlers() const override; void addMainThreadScrollingReasons( uint32_t main_thread_scrolling_reasons) override; void clearMainThreadScrollingReasons() override; diff --git a/cc/debug/debug_rect_history.cc b/cc/debug/debug_rect_history.cc index 33896f8..59ca9de 100644 --- a/cc/debug/debug_rect_history.cc +++ b/cc/debug/debug_rect_history.cc @@ -197,7 +197,7 @@ void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) { } void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) { - if (!layer->have_scroll_event_handlers()) + if (!layer->layer_tree_impl()->have_scroll_event_handlers()) return; debug_rects_.push_back( diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 0dfa3db..24ae932 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -71,7 +71,6 @@ Layer::Layer(const LayerSettings& settings) main_thread_scrolling_reasons_( MainThreadScrollingReason::kNotScrollingOnMain), should_flatten_transform_from_property_tree_(false), - have_scroll_event_handlers_(false), user_scrollable_horizontal_(true), user_scrollable_vertical_(true), is_root_for_isolated_group_(false), @@ -970,14 +969,6 @@ void Layer::ClearMainThreadScrollingReasons() { SetNeedsCommit(); } -void Layer::SetHaveScrollEventHandlers(bool have_scroll_event_handlers) { - DCHECK(IsPropertyChangeAllowed()); - if (have_scroll_event_handlers_ == have_scroll_event_handlers) - return; - have_scroll_event_handlers_ = have_scroll_event_handlers; - SetNeedsCommit(); -} - void Layer::SetNonFastScrollableRegion(const Region& region) { DCHECK(IsPropertyChangeAllowed()); if (non_fast_scrollable_region_ == region) @@ -1213,7 +1204,6 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { layer->SetBackgroundFilters(background_filters()); layer->SetMasksToBounds(masks_to_bounds_); layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); - layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); layer->SetTouchEventHandlerRegion(touch_event_handler_region_); layer->SetContentsOpaque(contents_opaque_); @@ -1482,7 +1472,6 @@ void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) { base->set_masks_to_bounds(masks_to_bounds_); base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); - base->set_have_scroll_event_handlers(have_scroll_event_handlers_); RegionToProto(non_fast_scrollable_region_, base->mutable_non_fast_scrollable_region()); RegionToProto(touch_event_handler_region_, @@ -1567,7 +1556,6 @@ void Layer::FromLayerSpecificPropertiesProto( has_render_surface_ = base.has_render_surface(); masks_to_bounds_ = base.masks_to_bounds(); main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); - have_scroll_event_handlers_ = base.have_scroll_event_handlers(); non_fast_scrollable_region_ = RegionFromProto(base.non_fast_scrollable_region()); touch_event_handler_region_ = diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 2b4272b..82ba93b 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -284,11 +284,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, return !!main_thread_scrolling_reasons_; } - void SetHaveScrollEventHandlers(bool have_scroll_event_handlers); - bool have_scroll_event_handlers() const { - return have_scroll_event_handlers_; - } - void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region); const Region& non_fast_scrollable_region() const { return non_fast_scrollable_region_; @@ -720,7 +715,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, gfx::Vector2dF offset_to_transform_parent_; uint32_t main_thread_scrolling_reasons_; bool should_flatten_transform_from_property_tree_ : 1; - bool have_scroll_event_handlers_ : 1; bool user_scrollable_horizontal_ : 1; bool user_scrollable_vertical_ : 1; bool is_root_for_isolated_group_ : 1; diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 1b620ad..708c8d2 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -60,7 +60,6 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, scroll_clip_layer_id_(Layer::INVALID_ID), main_thread_scrolling_reasons_( MainThreadScrollingReason::kNotScrollingOnMain), - have_scroll_event_handlers_(false), user_scrollable_horizontal_(true), user_scrollable_vertical_(true), stacking_order_changed_(false), @@ -614,7 +613,6 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { layer->SetBackgroundFilters(background_filters()); layer->SetMasksToBounds(masks_to_bounds_); layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); - layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); layer->SetTouchEventHandlerRegion(touch_event_handler_region_); layer->SetContentsOpaque(contents_opaque_); @@ -763,8 +761,6 @@ base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { if (scrollable()) result->SetBoolean("Scrollable", true); - if (have_scroll_event_handlers_) - result->SetBoolean("ScrollHandler", have_scroll_event_handlers_); if (!touch_event_handler_region_.IsEmpty()) { scoped_ptr<base::Value> region = touch_event_handler_region_.AsValue(); result->Set("TouchRegion", region.release()); @@ -1726,13 +1722,6 @@ void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const { touch_event_handler_region_.AsValueInto(state); state->EndArray(); } - if (have_scroll_event_handlers_) { - gfx::Rect scroll_rect(bounds()); - Region scroll_region(scroll_rect); - state->BeginArray("scroll_event_handler_region"); - scroll_region.AsValueInto(state); - state->EndArray(); - } if (!non_fast_scrollable_region_.IsEmpty()) { state->BeginArray("non_fast_scrollable_region"); non_fast_scrollable_region_.AsValueInto(state); diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index fe3c1c7..162aca9 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -503,13 +503,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, return !!main_thread_scrolling_reasons_; } - void SetHaveScrollEventHandlers(bool have_scroll_event_handlers) { - have_scroll_event_handlers_ = have_scroll_event_handlers; - } - bool have_scroll_event_handlers() const { - return have_scroll_event_handlers_; - } - void SetNonFastScrollableRegion(const Region& region) { non_fast_scrollable_region_ = region; } @@ -761,7 +754,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, gfx::Vector2dF offset_to_transform_parent_; uint32_t main_thread_scrolling_reasons_; - bool have_scroll_event_handlers_ : 1; bool user_scrollable_horizontal_ : 1; bool user_scrollable_vertical_ : 1; diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc index 76e41ca..afc6c35 100644 --- a/cc/layers/layer_unittest.cc +++ b/cc/layers/layer_unittest.cc @@ -134,8 +134,6 @@ class LayerSerializationTest : public testing::Test { EXPECT_EQ(src->masks_to_bounds_, dest->masks_to_bounds_); EXPECT_EQ(src->main_thread_scrolling_reasons_, dest->main_thread_scrolling_reasons_); - EXPECT_EQ(src->have_scroll_event_handlers_, - dest->have_scroll_event_handlers_); EXPECT_EQ(src->non_fast_scrollable_region_, dest->non_fast_scrollable_region_); EXPECT_EQ(src->touch_event_handler_region_, @@ -249,7 +247,6 @@ class LayerSerializationTest : public testing::Test { layer->masks_to_bounds_ = true; layer->main_thread_scrolling_reasons_ = MainThreadScrollingReason::kNotScrollingOnMain; - layer->have_scroll_event_handlers_ = false; layer->non_fast_scrollable_region_ = Region(gfx::Rect(5, 1, 14, 3)); layer->touch_event_handler_region_ = Region(gfx::Rect(3, 14, 1, 5)); layer->contents_opaque_ = true; @@ -298,7 +295,6 @@ class LayerSerializationTest : public testing::Test { layer->masks_to_bounds_ = !layer->masks_to_bounds_; layer->main_thread_scrolling_reasons_ = MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; - layer->have_scroll_event_handlers_ = !layer->have_scroll_event_handlers_; layer->non_fast_scrollable_region_ = Region(gfx::Rect(5, 1, 14, 3)); layer->touch_event_handler_region_ = Region(gfx::Rect(3, 14, 1, 5)); layer->contents_opaque_ = !layer->contents_opaque_; @@ -966,7 +962,6 @@ TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { MainThreadScrollingReason::kEventHandlers)); EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNonFastScrollableRegion( Region(gfx::Rect(1, 1, 2, 2)))); - EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetHaveScrollEventHandlers(true)); EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform( gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0))); EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetDoubleSided(false)); diff --git a/cc/proto/layer_tree_host.proto b/cc/proto/layer_tree_host.proto index b601bc1..9a6ac11 100644 --- a/cc/proto/layer_tree_host.proto +++ b/cc/proto/layer_tree_host.proto @@ -54,4 +54,5 @@ message LayerTreeHost { optional uint32 surface_id_namespace = 32; optional uint32 next_surface_sequence = 33; optional bool have_wheel_event_handlers = 34; + optional bool have_scroll_event_handlers = 35; } diff --git a/cc/test/layer_tree_json_parser.cc b/cc/test/layer_tree_json_parser.cc index eff1302..086e023 100644 --- a/cc/test/layer_tree_json_parser.cc +++ b/cc/test/layer_tree_json_parser.cc @@ -125,10 +125,6 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val, new_layer->SetScrollClipLayerId(scrollable ? new_layer->id() : Layer::INVALID_ID); - bool scroll_handler; - if (dict->GetBoolean("ScrollHandler", &scroll_handler)) - new_layer->SetHaveScrollEventHandlers(scroll_handler); - bool is_3d_sorted; if (dict->GetBoolean("Is3DSorted", &is_3d_sorted)) { // A non-zero context ID will put the layer into a 3D sorting context diff --git a/cc/test/layer_tree_json_parser_unittest.cc b/cc/test/layer_tree_json_parser_unittest.cc index bb3e114..7fcacc2 100644 --- a/cc/test/layer_tree_json_parser_unittest.cc +++ b/cc/test/layer_tree_json_parser_unittest.cc @@ -42,9 +42,6 @@ bool LayerTreesMatch(LayerImpl* const layer_impl, RETURN_IF_EXPECTATION_FAILS(EXPECT_FLOAT_EQ(layer_impl->opacity(), layer->opacity())); RETURN_IF_EXPECTATION_FAILS( - EXPECT_EQ(layer_impl->have_scroll_event_handlers(), - layer->have_scroll_event_handlers())); - RETURN_IF_EXPECTATION_FAILS( EXPECT_EQ(layer_impl->touch_event_handler_region(), layer->touch_event_handler_region())); @@ -80,8 +77,6 @@ TEST_F(LayerTreeJsonParserSanityCheck, Basic) { parent->SetPosition(gfx::PointF(25.f, 25.f)); - child->SetHaveScrollEventHandlers(true); - parent->AddChild(std::move(child)); root_impl->AddChild(std::move(parent)); tree->SetRootLayer(std::move(root_impl)); diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 8223474..f68ce8d 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -183,6 +183,7 @@ LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) gpu_rasterization_histogram_recorded_(false), background_color_(SK_ColorWHITE), has_transparent_background_(false), + have_scroll_event_handlers_(false), have_wheel_event_handlers_(false), did_complete_scale_animation_(false), in_paint_layer_contents_(false), @@ -399,6 +400,7 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { sync_tree->set_background_color(background_color_); sync_tree->set_has_transparent_background(has_transparent_background_); + sync_tree->set_have_scroll_event_handlers(have_scroll_event_handlers_); sync_tree->set_have_wheel_event_handlers(have_wheel_event_handlers_); if (page_scale_layer_.get() && inner_viewport_scroll_layer_.get()) { @@ -1114,6 +1116,14 @@ void LayerTreeHost::RegisterSelection(const LayerSelection& selection) { SetNeedsCommit(); } +void LayerTreeHost::SetHaveScrollEventHandlers(bool have_event_handlers) { + if (have_scroll_event_handlers_ == have_event_handlers) + return; + + have_scroll_event_handlers_ = have_event_handlers; + SetNeedsCommit(); +} + void LayerTreeHost::SetHaveWheelEventHandlers(bool have_event_handlers) { if (have_wheel_event_handlers_ == have_event_handlers) return; @@ -1447,6 +1457,7 @@ void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) const { content_is_suitable_for_gpu_rasterization_); proto->set_background_color(background_color_); proto->set_has_transparent_background(has_transparent_background_); + proto->set_have_scroll_event_handlers(have_scroll_event_handlers_); proto->set_have_wheel_event_handlers(have_wheel_event_handlers_); proto->set_in_paint_layer_contents(in_paint_layer_contents_); proto->set_id(id_); @@ -1512,6 +1523,7 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { proto.content_is_suitable_for_gpu_rasterization(); background_color_ = proto.background_color(); has_transparent_background_ = proto.has_transparent_background(); + have_scroll_event_handlers_ = proto.have_scroll_event_handlers(); have_wheel_event_handlers_ = proto.have_wheel_event_handlers(); in_paint_layer_contents_ = proto.in_paint_layer_contents(); id_ = proto.id(); diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 6c4634c0..9118e12 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -224,6 +224,11 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { void RegisterSelection(const LayerSelection& selection); + bool have_scroll_event_handlers() const { + return have_scroll_event_handlers_; + } + void SetHaveScrollEventHandlers(bool have_event_handlers); + bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; } void SetHaveWheelEventHandlers(bool have_event_handlers); @@ -532,6 +537,7 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { SkColor background_color_; bool has_transparent_background_; + bool have_scroll_event_handlers_; bool have_wheel_event_handlers_; scoped_ptr<AnimationRegistrar> animation_registrar_; diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 50fc49f..1ccc3c8 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -552,7 +552,7 @@ bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( bool scroll_on_main_thread = false; uint32_t main_thread_scrolling_reasons; LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint( - device_viewport_point, type, layer_impl, &scroll_on_main_thread, nullptr, + device_viewport_point, type, layer_impl, &scroll_on_main_thread, &main_thread_scrolling_reasons); if (!test_layer_impl) @@ -2433,7 +2433,6 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( InputHandler::ScrollInputType type, LayerImpl* layer_impl, bool* scroll_on_main_thread, - bool* optional_has_ancestor_scroll_handler, uint32_t* main_thread_scrolling_reasons) const { DCHECK(scroll_on_main_thread); DCHECK(main_thread_scrolling_reasons); @@ -2467,10 +2466,6 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( return NULL; } - if (optional_has_ancestor_scroll_handler && - layer_impl->have_scroll_event_handlers()) - *optional_has_ancestor_scroll_handler = true; - if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && !potentially_scrolling_layer_impl) { potentially_scrolling_layer_impl = layer_impl; @@ -2598,9 +2593,12 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( bool scroll_on_main_thread = false; LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( device_viewport_point, type, layer_impl, &scroll_on_main_thread, - &scroll_affects_scroll_handler_, &scroll_status.main_thread_scrolling_reasons); + if (scrolling_layer_impl) + scroll_affects_scroll_handler_ = + scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers(); + if (scroll_on_main_thread) { RecordCompositorSlowScrollMetric(type, MAIN_THREAD); @@ -3075,7 +3073,7 @@ void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { uint32_t main_thread_scrolling_reasons; LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( device_viewport_point, InputHandler::GESTURE, layer_impl, - &scroll_on_main_thread, NULL, &main_thread_scrolling_reasons); + &scroll_on_main_thread, &main_thread_scrolling_reasons); if (scroll_layer_impl == InnerViewportScrollLayer()) scroll_layer_impl = OuterViewportScrollLayer(); if (scroll_on_main_thread || !scroll_layer_impl) diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index b8cbe2e..343cc77 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -683,7 +683,6 @@ class CC_EXPORT LayerTreeHostImpl InputHandler::ScrollInputType type, LayerImpl* layer_hit_by_point, bool* scroll_on_main_thread, - bool* optional_has_ancestor_scroll_handler, uint32_t* main_thread_scrolling_reason) const; float DeviceSpaceDistanceToLayer(const gfx::PointF& device_viewport_point, LayerImpl* layer_impl); diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index a66eb514..9ea8484 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -964,8 +964,8 @@ TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { } TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { - LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); - EXPECT_FALSE(scroll_layer->have_scroll_event_handlers()); + SetupScrollAndContentsLayers(gfx::Size(200, 200)); + EXPECT_FALSE(host_impl_->active_tree()->have_scroll_event_handlers()); host_impl_->SetViewportSize(gfx::Size(50, 50)); DrawFrame(); @@ -978,8 +978,8 @@ TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { } TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) { - LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); - scroll_layer->SetHaveScrollEventHandlers(true); + SetupScrollAndContentsLayers(gfx::Size(200, 200)); + host_impl_->active_tree()->set_have_scroll_event_handlers(true); host_impl_->SetViewportSize(gfx::Size(50, 50)); DrawFrame(); @@ -7982,7 +7982,7 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { &set_needs_commit_count, &set_needs_redraw_count, &forward_to_main_count)); - LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); + SetupScrollAndContentsLayers(gfx::Size(100, 100)); // Scrolling normally should not trigger any forwarding. EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, @@ -8001,7 +8001,7 @@ TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) { // Scrolling with a scroll handler should defer the swap to the main // thread. - scroll_layer->SetHaveScrollEventHandlers(true); + host_impl_->active_tree()->set_have_scroll_event_handlers(true); EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::GESTURE) diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 9313c4d..560df10 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -1334,6 +1334,7 @@ class LayerTreeHostTestCommit : public LayerTreeHostTest { layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); layer_tree_host()->set_background_color(SK_ColorGRAY); layer_tree_host()->SetHaveWheelEventHandlers(true); + layer_tree_host()->SetHaveScrollEventHandlers(true); PostSetNeedsCommitToMainThread(); } @@ -1342,6 +1343,7 @@ class LayerTreeHostTestCommit : public LayerTreeHostTest { EXPECT_EQ(gfx::Size(20, 20), impl->DrawViewportSize()); EXPECT_EQ(SK_ColorGRAY, impl->active_tree()->background_color()); EXPECT_TRUE(impl->active_tree()->have_wheel_event_handlers()); + EXPECT_TRUE(impl->active_tree()->have_scroll_event_handlers()); EndTest(); } diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 9e95011..156996d 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -76,6 +76,7 @@ LayerTreeImpl::LayerTreeImpl( next_activation_forces_redraw_(false), has_ever_been_drawn_(false), render_surface_layer_list_id_(0), + have_scroll_event_handlers_(false), have_wheel_event_handlers_(false), top_controls_shrink_blink_size_(false), top_controls_height_(0), @@ -346,6 +347,7 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { target_tree->set_source_frame_number(source_frame_number()); target_tree->set_background_color(background_color()); target_tree->set_has_transparent_background(has_transparent_background()); + target_tree->set_have_scroll_event_handlers(have_scroll_event_handlers()); target_tree->set_have_wheel_event_handlers(have_wheel_event_handlers()); if (ViewportSizeInvalid()) diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index ffb93bd..7f4c89c 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -436,6 +436,13 @@ class CC_EXPORT LayerTreeImpl { const gfx::BoxF& box, gfx::BoxF* bounds) const; + bool have_scroll_event_handlers() const { + return have_scroll_event_handlers_; + } + void set_have_scroll_event_handlers(bool have_event_handlers) { + have_scroll_event_handlers_ = have_event_handlers; + } + bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; } void set_have_wheel_event_handlers(bool have_event_handlers) { have_wheel_event_handlers_ = have_event_handlers; @@ -528,6 +535,7 @@ class CC_EXPORT LayerTreeImpl { int render_surface_layer_list_id_; + bool have_scroll_event_handlers_; bool have_wheel_event_handlers_; // Whether or not Blink's viewport size was shrunk by the height of the top diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 274fb80..9bd5b80 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -751,6 +751,14 @@ bool RenderWidgetCompositor::haveWheelEventHandlers() const { return layer_tree_host_->have_wheel_event_handlers(); } +void RenderWidgetCompositor::setHaveScrollEventHandlers(bool has_handlers) { + layer_tree_host_->SetHaveScrollEventHandlers(has_handlers); +} + +bool RenderWidgetCompositor::haveScrollEventHandlers() const { + return layer_tree_host_->have_scroll_event_handlers(); +} + void CompositeAndReadbackAsyncCallback( blink::WebCompositeAndReadbackAsyncCallback* callback, scoped_ptr<cc::CopyOutputResult> result) { diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h index 073fd77..2e19c20 100644 --- a/content/renderer/gpu/render_widget_compositor.h +++ b/content/renderer/gpu/render_widget_compositor.h @@ -137,6 +137,8 @@ class CONTENT_EXPORT RenderWidgetCompositor void clearSelection() override; void setHaveWheelEventHandlers(bool) override; bool haveWheelEventHandlers() const override; + void setHaveScrollEventHandlers(bool) override; + bool haveScrollEventHandlers() const override; int layerTreeId() const override; void setShowFPSCounter(bool show) override; void setShowPaintRects(bool show) override; diff --git a/content/test/web_layer_tree_view_impl_for_testing.cc b/content/test/web_layer_tree_view_impl_for_testing.cc index 7dbc162..929cde2 100644 --- a/content/test/web_layer_tree_view_impl_for_testing.cc +++ b/content/test/web_layer_tree_view_impl_for_testing.cc @@ -209,4 +209,13 @@ bool WebLayerTreeViewImplForTesting::haveWheelEventHandlers() const { return layer_tree_host_->have_wheel_event_handlers(); } +void WebLayerTreeViewImplForTesting::setHaveScrollEventHandlers( + bool have_event_handlers) { + layer_tree_host_->SetHaveScrollEventHandlers(have_event_handlers); +} + +bool WebLayerTreeViewImplForTesting::haveScrollEventHandlers() const { + return layer_tree_host_->have_scroll_event_handlers(); +} + } // namespace content diff --git a/content/test/web_layer_tree_view_impl_for_testing.h b/content/test/web_layer_tree_view_impl_for_testing.h index 9518a5b..d3d5ed0 100644 --- a/content/test/web_layer_tree_view_impl_for_testing.h +++ b/content/test/web_layer_tree_view_impl_for_testing.h @@ -69,6 +69,8 @@ class WebLayerTreeViewImplForTesting void clearSelection() override; void setHaveWheelEventHandlers(bool have_event_handlers) override; bool haveWheelEventHandlers() const override; + void setHaveScrollEventHandlers(bool) override; + bool haveScrollEventHandlers() const override; // cc::LayerTreeHostClient implementation. void WillBeginMainFrame() override {} diff --git a/third_party/WebKit/Source/core/frame/EventHandlerRegistry.cpp b/third_party/WebKit/Source/core/frame/EventHandlerRegistry.cpp index 2ce0f9e..1a8c32c 100644 --- a/third_party/WebKit/Source/core/frame/EventHandlerRegistry.cpp +++ b/third_party/WebKit/Source/core/frame/EventHandlerRegistry.cpp @@ -195,12 +195,9 @@ void EventHandlerRegistry::didRemoveAllEventHandlers(EventTarget& target) void EventHandlerRegistry::notifyHasHandlersChanged(EventHandlerClass handlerClass, bool hasActiveHandlers) { - ScrollingCoordinator* scrollingCoordinator = m_frameHost->page().scrollingCoordinator(); - switch (handlerClass) { case ScrollEvent: - if (scrollingCoordinator) - scrollingCoordinator->updateHaveScrollEventHandlers(); + m_frameHost->chromeClient().setHaveScrollEventHandlers(hasActiveHandlers); break; case WheelEvent: m_frameHost->chromeClient().setHaveWheelEventHandlers(hasActiveHandlers); diff --git a/third_party/WebKit/Source/core/loader/EmptyClients.h b/third_party/WebKit/Source/core/loader/EmptyClients.h index f241a68..f7eb8bf 100644 --- a/third_party/WebKit/Source/core/loader/EmptyClients.h +++ b/third_party/WebKit/Source/core/loader/EmptyClients.h @@ -159,6 +159,8 @@ public: void needTouchEvents(bool) override {} void setHaveWheelEventHandlers(bool) override {} bool haveWheelEventHandlers() const override { return false; } + void setHaveScrollEventHandlers(bool) override {} + bool haveScrollEventHandlers() const override { return false; } void setTouchAction(TouchAction) override {} diff --git a/third_party/WebKit/Source/core/page/ChromeClient.h b/third_party/WebKit/Source/core/page/ChromeClient.h index 1c934dc..9ae983b 100644 --- a/third_party/WebKit/Source/core/page/ChromeClient.h +++ b/third_party/WebKit/Source/core/page/ChromeClient.h @@ -201,6 +201,8 @@ public: virtual void needTouchEvents(bool) = 0; virtual void setHaveWheelEventHandlers(bool) = 0; virtual bool haveWheelEventHandlers() const = 0; + virtual void setHaveScrollEventHandlers(bool) = 0; + virtual bool haveScrollEventHandlers() const = 0; virtual void setTouchAction(TouchAction) = 0; diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp index d9e0257..3a64da2 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp @@ -680,22 +680,6 @@ void ScrollingCoordinator::willDestroyLayer(PaintLayer* layer) m_layersWithTouchRects.remove(layer); } -void ScrollingCoordinator::updateHaveScrollEventHandlers() -{ - ASSERT(isMainThread()); - ASSERT(m_page); - if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->view()) - return; - - // Currently the compositor only cares whether there are scroll handlers anywhere on the page - // instead on a per-layer basis. We therefore only update this information for the root - // scrolling layer. - if (WebLayer* scrollLayer = toWebLayer(m_page->deprecatedLocalMainFrame()->view()->layerForScrolling())) { - bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventHandlers(EventHandlerRegistry::ScrollEvent); - scrollLayer->setHaveScrollEventHandlers(haveHandlers); - } -} - void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons mainThreadScrollingReasons) { if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->view()) @@ -947,7 +931,6 @@ void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) return; notifyGeometryChanged(); - updateHaveScrollEventHandlers(); } #if OS(MACOSX) diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.h b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.h index 3cfdba7..fab9cdd 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.h +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.h @@ -76,8 +76,6 @@ public: void updateAfterCompositingChangeIfNeeded(); - void updateHaveScrollEventHandlers(); - // Should be called whenever a scrollable area is added or removed, or gains/loses a composited layer. void scrollableAreasDidChange(); diff --git a/third_party/WebKit/Source/web/ChromeClientImpl.cpp b/third_party/WebKit/Source/web/ChromeClientImpl.cpp index 7c169b2..02bb02e 100644 --- a/third_party/WebKit/Source/web/ChromeClientImpl.cpp +++ b/third_party/WebKit/Source/web/ChromeClientImpl.cpp @@ -894,6 +894,19 @@ bool ChromeClientImpl::haveWheelEventHandlers() const return false; } +void ChromeClientImpl::setHaveScrollEventHandlers(bool hasEventHandlers) +{ + if (WebLayerTreeView* treeView = m_webView->layerTreeView()) + treeView->setHaveScrollEventHandlers(hasEventHandlers); +} + +bool ChromeClientImpl::haveScrollEventHandlers() const +{ + if (WebLayerTreeView* treeView = m_webView->layerTreeView()) + return treeView->haveScrollEventHandlers(); + return false; +} + void ChromeClientImpl::setTouchAction(TouchAction touchAction) { if (WebViewClient* client = m_webView->client()) diff --git a/third_party/WebKit/Source/web/ChromeClientImpl.h b/third_party/WebKit/Source/web/ChromeClientImpl.h index 7c08ae8..a4deb53 100644 --- a/third_party/WebKit/Source/web/ChromeClientImpl.h +++ b/third_party/WebKit/Source/web/ChromeClientImpl.h @@ -114,6 +114,8 @@ public: void needTouchEvents(bool needTouchEvents) override; void setHaveWheelEventHandlers(bool hasEventHandlers) override; bool haveWheelEventHandlers() const override; + void setHaveScrollEventHandlers(bool hasEventHandlers) override; + bool haveScrollEventHandlers() const override; void setTouchAction(TouchAction) override; GraphicsLayerFactory* graphicsLayerFactory() const override; diff --git a/third_party/WebKit/Source/web/WebPagePopupImpl.cpp b/third_party/WebKit/Source/web/WebPagePopupImpl.cpp index 815cc54..61cb672 100644 --- a/third_party/WebKit/Source/web/WebPagePopupImpl.cpp +++ b/third_party/WebKit/Source/web/WebPagePopupImpl.cpp @@ -181,6 +181,19 @@ private: return false; } + void setHaveScrollEventHandlers(bool hasEventHandlers) override + { + if (m_popup->m_layerTreeView) + m_popup->m_layerTreeView->setHaveScrollEventHandlers(hasEventHandlers); + } + + bool haveScrollEventHandlers() const override + { + if (m_popup->m_layerTreeView) + return m_popup->m_layerTreeView->haveScrollEventHandlers(); + return false; + } + void setTouchAction(TouchAction touchAction) override { if (WebViewClient* client = m_popup->m_webView->client()) diff --git a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp index 9d089c9..84c605e 100644 --- a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp +++ b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp @@ -321,8 +321,7 @@ TEST_F(ScrollingCoordinatorTest, scrollEventHandler) navigateTo(m_baseURL + "scroll-event-handler.html"); forceFullCompositingUpdate(); - WebLayer* rootScrollLayer = getRootScrollLayer(); - ASSERT_TRUE(rootScrollLayer->haveScrollEventHandlers()); + ASSERT_TRUE(webLayerTreeView()->haveScrollEventHandlers()); } TEST_F(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) diff --git a/third_party/WebKit/public/platform/WebLayer.h b/third_party/WebKit/public/platform/WebLayer.h index d1e3877..08a76cd 100644 --- a/third_party/WebKit/public/platform/WebLayer.h +++ b/third_party/WebKit/public/platform/WebLayer.h @@ -197,9 +197,6 @@ public: virtual bool userScrollableHorizontal() const = 0; virtual bool userScrollableVertical() const = 0; - virtual void setHaveScrollEventHandlers(bool) = 0; - virtual bool haveScrollEventHandlers() const = 0; - // Indicates that this layer will always scroll on the main thread for the provided reason. virtual void addMainThreadScrollingReasons(uint32_t) = 0; // Indicates that the layer could scroll on the compositor thread. diff --git a/third_party/WebKit/public/platform/WebLayerTreeView.h b/third_party/WebKit/public/platform/WebLayerTreeView.h index ac3c757..fc9688d 100644 --- a/third_party/WebKit/public/platform/WebLayerTreeView.h +++ b/third_party/WebKit/public/platform/WebLayerTreeView.h @@ -143,10 +143,12 @@ public: // Input properties --------------------------------------------------- virtual void setHaveWheelEventHandlers(bool) { }; + virtual void setHaveScrollEventHandlers(bool) { }; // Debugging / dangerous --------------------------------------------- virtual bool haveWheelEventHandlers() const { return false; }; + virtual bool haveScrollEventHandlers() const { return false; }; virtual int layerTreeId() const { return 0; } |