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

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: weiliangc comment addressed 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3375 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 if (!CurrentlyScrollingNode()) { 3386 if (!CurrentlyScrollingNode()) {
3387 scroll_status.thread = SCROLL_IGNORED; 3387 scroll_status.thread = SCROLL_IGNORED;
3388 scroll_status.main_thread_scrolling_reasons = 3388 scroll_status.main_thread_scrolling_reasons =
3389 MainThreadScrollingReason::kNoScrollingLayer; 3389 MainThreadScrollingReason::kNoScrollingLayer;
3390 } else { 3390 } else {
3391 scroll_status.thread = SCROLL_ON_IMPL_THREAD; 3391 scroll_status.thread = SCROLL_ON_IMPL_THREAD;
3392 } 3392 }
3393 return scroll_status; 3393 return scroll_status;
3394 } 3394 }
3395 3395
3396 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
3397 const gfx::PointF& device_viewport_point,
3398 LayerImpl* layer_impl) {
3399 if (!layer_impl)
3400 return std::numeric_limits<float>::max();
3401
3402 gfx::Rect layer_impl_bounds(layer_impl->bounds());
3403
3404 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect(
3405 layer_impl->ScreenSpaceTransform(), gfx::RectF(layer_impl_bounds));
3406
3407 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint(
3408 device_viewport_point);
3409 }
3410
3411 void LayerTreeHostImpl::MouseDown() { 3396 void LayerTreeHostImpl::MouseDown() {
3412 ScrollbarAnimationController* animation_controller = 3397 ScrollbarAnimationController* animation_controller =
3413 ScrollbarAnimationControllerForElementId( 3398 ScrollbarAnimationControllerForElementId(
3414 scroll_element_id_mouse_currently_over_); 3399 scroll_element_id_mouse_currently_over_);
3415 if (animation_controller) { 3400 if (animation_controller) {
3416 animation_controller->DidMouseDown(); 3401 animation_controller->DidMouseDown();
3417 scroll_element_id_mouse_currently_captured_ = 3402 scroll_element_id_mouse_currently_captured_ =
3418 scroll_element_id_mouse_currently_over_; 3403 scroll_element_id_mouse_currently_over_;
3419 } 3404 }
3420 } 3405 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3468 old_animation_controller->DidMouseLeave(); 3453 old_animation_controller->DidMouseLeave();
3469 } 3454 }
3470 scroll_element_id_mouse_currently_over_ = scroll_element_id; 3455 scroll_element_id_mouse_currently_over_ = scroll_element_id;
3471 } 3456 }
3472 3457
3473 ScrollbarAnimationController* new_animation_controller = 3458 ScrollbarAnimationController* new_animation_controller =
3474 ScrollbarAnimationControllerForElementId(scroll_element_id); 3459 ScrollbarAnimationControllerForElementId(scroll_element_id);
3475 if (!new_animation_controller) 3460 if (!new_animation_controller)
3476 return; 3461 return;
3477 3462
3478 for (auto* scrollbar : active_tree_->ScrollbarsFor(scroll_element_id)) { 3463 new_animation_controller->DidMouseMove(device_viewport_point);
3479 new_animation_controller->DidMouseMoveNear(
3480 scrollbar->orientation(),
3481 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) /
3482 active_tree_->device_scale_factor());
3483 }
3484 } 3464 }
3485 3465
3486 void LayerTreeHostImpl::MouseLeave() { 3466 void LayerTreeHostImpl::MouseLeave() {
3487 for (auto& pair : scrollbar_animation_controllers_) 3467 for (auto& pair : scrollbar_animation_controllers_)
3488 pair.second->DidMouseLeave(); 3468 pair.second->DidMouseLeave();
3489 scroll_element_id_mouse_currently_over_ = ElementId(); 3469 scroll_element_id_mouse_currently_over_ = ElementId();
3490 } 3470 }
3491 3471
3492 void LayerTreeHostImpl::PinchGestureBegin() { 3472 void LayerTreeHostImpl::PinchGestureBegin() {
3493 pinch_gesture_active_ = true; 3473 pinch_gesture_active_ = true;
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 4291
4312 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { 4292 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) {
4313 if (!element_id) 4293 if (!element_id)
4314 return; 4294 return;
4315 if (ScrollbarAnimationController* animation_controller = 4295 if (ScrollbarAnimationController* animation_controller =
4316 ScrollbarAnimationControllerForElementId(element_id)) 4296 ScrollbarAnimationControllerForElementId(element_id))
4317 animation_controller->DidScrollUpdate(); 4297 animation_controller->DidScrollUpdate();
4318 } 4298 }
4319 4299
4320 } // namespace cc 4300 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698