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

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

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: for weiliangc's nit Created 3 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 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 3230 matching lines...) Expand 10 before | Expand all | Expand 10 after
3241 } 3241 }
3242 3242
3243 void LayerTreeHostImpl::MouseUp() { 3243 void LayerTreeHostImpl::MouseUp() {
3244 ScrollbarAnimationController* animation_controller = 3244 ScrollbarAnimationController* animation_controller =
3245 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_); 3245 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_);
3246 if (animation_controller) 3246 if (animation_controller)
3247 animation_controller->DidMouseUp(); 3247 animation_controller->DidMouseUp();
3248 } 3248 }
3249 3249
3250 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { 3250 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
3251 float distance_to_scrollbar = std::numeric_limits<float>::max();
3252 gfx::PointF device_viewport_point = gfx::ScalePoint( 3251 gfx::PointF device_viewport_point = gfx::ScalePoint(
3253 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 3252 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
3254 LayerImpl* layer_impl = 3253 LayerImpl* layer_impl =
3255 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 3254 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
3256 3255
3257 // Check if mouse is over a scrollbar or not. 3256 // Check if mouse is over a scrollbar or not.
3258 // TODO(sahel): get rid of this extera checking when 3257 // TODO(sahel): get rid of this extera checking when
3259 // FindScrollLayerForDeviceViewportPoint finds the proper layer for 3258 // FindScrollLayerForDeviceViewportPoint finds the proper layer for
3260 // scrolling on main thread when mouse is over scrollbar as well. 3259 // scrolling on main thread when mouse is over scrollbar as well.
3261 int new_id = Layer::INVALID_ID; 3260 int new_id = Layer::INVALID_ID;
3262 if (layer_impl && layer_impl->ToScrollbarLayer()) 3261 if (layer_impl && layer_impl->ToScrollbarLayer())
3263 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); 3262 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId();
3264 if (new_id != Layer::INVALID_ID) { 3263 if (new_id == Layer::INVALID_ID) {
3265 // Mouse over a scrollbar.
3266 distance_to_scrollbar = 0;
3267 } else {
3268 bool scroll_on_main_thread = false; 3264 bool scroll_on_main_thread = false;
3269 uint32_t main_thread_scrolling_reasons; 3265 uint32_t main_thread_scrolling_reasons;
3270 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( 3266 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint(
3271 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, 3267 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl,
3272 &scroll_on_main_thread, &main_thread_scrolling_reasons); 3268 &scroll_on_main_thread, &main_thread_scrolling_reasons);
3273 3269
3274 // Scrollbars for the viewport are registered with the outer viewport layer. 3270 // Scrollbars for the viewport are registered with the outer viewport layer.
3275 if (scroll_layer_impl == InnerViewportScrollLayer()) 3271 if (scroll_layer_impl == InnerViewportScrollLayer())
3276 scroll_layer_impl = OuterViewportScrollLayer(); 3272 scroll_layer_impl = OuterViewportScrollLayer();
3277 3273
3278 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; 3274 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID;
3279 } 3275 }
3280 3276
3281 if (new_id != scroll_layer_id_mouse_currently_over_) { 3277 if (new_id != scroll_layer_id_mouse_currently_over_) {
3282 ScrollbarAnimationController* old_animation_controller = 3278 ScrollbarAnimationController* old_animation_controller =
3283 ScrollbarAnimationControllerForId( 3279 ScrollbarAnimationControllerForId(
3284 scroll_layer_id_mouse_currently_over_); 3280 scroll_layer_id_mouse_currently_over_);
3285 if (old_animation_controller) { 3281 if (old_animation_controller) {
3286 old_animation_controller->DidMouseLeave(); 3282 old_animation_controller->DidMouseLeave();
3287 } 3283 }
3288 scroll_layer_id_mouse_currently_over_ = new_id; 3284 scroll_layer_id_mouse_currently_over_ = new_id;
3289 } 3285 }
3290 3286
3291 ScrollbarAnimationController* new_animation_controller = 3287 ScrollbarAnimationController* new_animation_controller =
3292 ScrollbarAnimationControllerForId(new_id); 3288 ScrollbarAnimationControllerForId(new_id);
3293 if (!new_animation_controller) 3289 if (!new_animation_controller)
3294 return; 3290 return;
3295 3291
3296 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) 3292 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) {
3297 distance_to_scrollbar = 3293 new_animation_controller->DidMouseMoveNear(
3298 std::min(distance_to_scrollbar, 3294 scrollbar->orientation(),
3299 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); 3295 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) /
3300 new_animation_controller->DidMouseMoveNear( 3296 active_tree_->device_scale_factor());
3301 distance_to_scrollbar / active_tree_->device_scale_factor()); 3297 }
3302 } 3298 }
3303 3299
3304 void LayerTreeHostImpl::MouseLeave() { 3300 void LayerTreeHostImpl::MouseLeave() {
3305 for (auto& pair : scrollbar_animation_controllers_) 3301 for (auto& pair : scrollbar_animation_controllers_)
3306 pair.second->DidMouseLeave(); 3302 pair.second->DidMouseLeave();
3307 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; 3303 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID;
3308 } 3304 }
3309 3305
3310 void LayerTreeHostImpl::PinchGestureBegin() { 3306 void LayerTreeHostImpl::PinchGestureBegin() {
3311 pinch_gesture_active_ = true; 3307 pinch_gesture_active_ = true;
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 worker_context_visibility_ = 4096 worker_context_visibility_ =
4101 worker_context->CacheController()->ClientBecameVisible(); 4097 worker_context->CacheController()->ClientBecameVisible();
4102 } else { 4098 } else {
4103 worker_context->CacheController()->ClientBecameNotVisible( 4099 worker_context->CacheController()->ClientBecameNotVisible(
4104 std::move(worker_context_visibility_)); 4100 std::move(worker_context_visibility_));
4105 } 4101 }
4106 } 4102 }
4107 } 4103 }
4108 4104
4109 } // namespace cc 4105 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/single_scrollbar_animation_controller_thinning_unittest.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698