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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: add tests Created 3 years, 7 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 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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3380 if (!CurrentlyScrollingNode()) { 3380 if (!CurrentlyScrollingNode()) {
3381 scroll_status.thread = SCROLL_IGNORED; 3381 scroll_status.thread = SCROLL_IGNORED;
3382 scroll_status.main_thread_scrolling_reasons = 3382 scroll_status.main_thread_scrolling_reasons =
3383 MainThreadScrollingReason::kNoScrollingLayer; 3383 MainThreadScrollingReason::kNoScrollingLayer;
3384 } else { 3384 } else {
3385 scroll_status.thread = SCROLL_ON_IMPL_THREAD; 3385 scroll_status.thread = SCROLL_ON_IMPL_THREAD;
3386 } 3386 }
3387 return scroll_status; 3387 return scroll_status;
3388 } 3388 }
3389 3389
3390 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
3391 const gfx::PointF& device_viewport_point,
3392 LayerImpl* layer_impl) {
3393 if (!layer_impl)
3394 return std::numeric_limits<float>::max();
3395
3396 gfx::Rect layer_impl_bounds(layer_impl->bounds());
3397
3398 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect(
3399 layer_impl->ScreenSpaceTransform(), gfx::RectF(layer_impl_bounds));
3400
3401 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint(
3402 device_viewport_point);
3403 }
3404
3405 void LayerTreeHostImpl::MouseDown() { 3390 void LayerTreeHostImpl::MouseDown() {
3406 ScrollbarAnimationController* animation_controller = 3391 ScrollbarAnimationController* animation_controller =
3407 ScrollbarAnimationControllerForElementId( 3392 ScrollbarAnimationControllerForElementId(
3408 scroll_element_id_mouse_currently_over_); 3393 scroll_element_id_mouse_currently_over_);
3409 if (animation_controller) { 3394 if (animation_controller) {
3410 animation_controller->DidMouseDown(); 3395 animation_controller->DidMouseDown();
3411 scroll_element_id_mouse_currently_captured_ = 3396 scroll_element_id_mouse_currently_captured_ =
3412 scroll_element_id_mouse_currently_over_; 3397 scroll_element_id_mouse_currently_over_;
3413 } 3398 }
3414 } 3399 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3462 old_animation_controller->DidMouseLeave(); 3447 old_animation_controller->DidMouseLeave();
3463 } 3448 }
3464 scroll_element_id_mouse_currently_over_ = scroll_element_id; 3449 scroll_element_id_mouse_currently_over_ = scroll_element_id;
3465 } 3450 }
3466 3451
3467 ScrollbarAnimationController* new_animation_controller = 3452 ScrollbarAnimationController* new_animation_controller =
3468 ScrollbarAnimationControllerForElementId(scroll_element_id); 3453 ScrollbarAnimationControllerForElementId(scroll_element_id);
3469 if (!new_animation_controller) 3454 if (!new_animation_controller)
3470 return; 3455 return;
3471 3456
3472 for (auto* scrollbar : active_tree_->ScrollbarsFor(scroll_element_id)) { 3457 new_animation_controller->DidMouseMove(device_viewport_point);
3473 new_animation_controller->DidMouseMoveNear(
3474 scrollbar->orientation(),
3475 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) /
3476 active_tree_->device_scale_factor());
3477 }
3478 } 3458 }
3479 3459
3480 void LayerTreeHostImpl::MouseLeave() { 3460 void LayerTreeHostImpl::MouseLeave() {
3481 for (auto& pair : scrollbar_animation_controllers_) 3461 for (auto& pair : scrollbar_animation_controllers_)
3482 pair.second->DidMouseLeave(); 3462 pair.second->DidMouseLeave();
3483 scroll_element_id_mouse_currently_over_ = ElementId(); 3463 scroll_element_id_mouse_currently_over_ = ElementId();
3484 } 3464 }
3485 3465
3486 void LayerTreeHostImpl::PinchGestureBegin() { 3466 void LayerTreeHostImpl::PinchGestureBegin() {
3487 pinch_gesture_active_ = true; 3467 pinch_gesture_active_ = true;
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
4296 } 4276 }
4297 4277
4298 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { 4278 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) {
4299 if (is_wheel_scroll) 4279 if (is_wheel_scroll)
4300 has_scrolled_by_wheel_ = true; 4280 has_scrolled_by_wheel_ = true;
4301 else 4281 else
4302 has_scrolled_by_touch_ = true; 4282 has_scrolled_by_touch_ = true;
4303 } 4283 }
4304 4284
4305 } // namespace cc 4285 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698