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

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

Issue 2384053002: cancel overlay-scrollbar hover state when moving pointer out of window for ChromeOS (Closed)
Patch Set: reset scroll_layer_id_when_mouse_over_scrollbar_ when mouse out of windows Created 4 years, 2 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 content_is_suitable_for_gpu_rasterization_(true), 202 content_is_suitable_for_gpu_rasterization_(true),
203 has_gpu_rasterization_trigger_(false), 203 has_gpu_rasterization_trigger_(false),
204 use_gpu_rasterization_(false), 204 use_gpu_rasterization_(false),
205 use_msaa_(false), 205 use_msaa_(false),
206 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), 206 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE),
207 input_handler_client_(NULL), 207 input_handler_client_(NULL),
208 did_lock_scrolling_layer_(false), 208 did_lock_scrolling_layer_(false),
209 wheel_scrolling_(false), 209 wheel_scrolling_(false),
210 scroll_affects_scroll_handler_(false), 210 scroll_affects_scroll_handler_(false),
211 scroll_layer_id_when_mouse_over_scrollbar_(Layer::INVALID_ID), 211 scroll_layer_id_when_mouse_over_scrollbar_(Layer::INVALID_ID),
212 scroll_layer_id_when_mouse_near_scrollbar_(Layer::INVALID_ID),
212 captured_scrollbar_layer_id_(Layer::INVALID_ID), 213 captured_scrollbar_layer_id_(Layer::INVALID_ID),
213 tile_priorities_dirty_(false), 214 tile_priorities_dirty_(false),
214 settings_(settings), 215 settings_(settings),
215 visible_(false), 216 visible_(false),
216 cached_managed_memory_policy_(settings.gpu_memory_policy), 217 cached_managed_memory_policy_(settings.gpu_memory_policy),
217 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() && 218 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() &&
218 !settings.single_thread_proxy_scheduler), 219 !settings.single_thread_proxy_scheduler),
219 // Must be initialized after is_synchronous_single_threaded_ and 220 // Must be initialized after is_synchronous_single_threaded_ and
220 // task_runner_provider_. 221 // task_runner_provider_.
221 tile_manager_(this, 222 tile_manager_(this,
(...skipping 3008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 return; 3231 return;
3231 3232
3232 ScrollbarAnimationController* animation_controller = 3233 ScrollbarAnimationController* animation_controller =
3233 ScrollbarAnimationControllerForId(captured_scrollbar_layer_id_); 3234 ScrollbarAnimationControllerForId(captured_scrollbar_layer_id_);
3234 if (animation_controller) 3235 if (animation_controller)
3235 animation_controller->DidCaptureScrollbarEnd(); 3236 animation_controller->DidCaptureScrollbarEnd();
3236 captured_scrollbar_layer_id_ = Layer::INVALID_ID; 3237 captured_scrollbar_layer_id_ = Layer::INVALID_ID;
3237 } 3238 }
3238 3239
3239 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { 3240 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
3241 scroll_layer_id_when_mouse_near_scrollbar_ = Layer::INVALID_ID;
3240 gfx::PointF device_viewport_point = gfx::ScalePoint( 3242 gfx::PointF device_viewport_point = gfx::ScalePoint(
3241 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 3243 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
3242 LayerImpl* layer_impl = 3244 LayerImpl* layer_impl =
3243 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 3245 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
3244 HandleMouseOverScrollbar(layer_impl); 3246 HandleMouseOverScrollbar(layer_impl);
3245 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) 3247 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID)
3246 return; 3248 return;
3247 3249
3248 bool scroll_on_main_thread = false; 3250 bool scroll_on_main_thread = false;
3249 uint32_t main_thread_scrolling_reasons; 3251 uint32_t main_thread_scrolling_reasons;
3250 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( 3252 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint(
3251 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, 3253 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl,
3252 &scroll_on_main_thread, &main_thread_scrolling_reasons); 3254 &scroll_on_main_thread, &main_thread_scrolling_reasons);
3253 // Scrollbars for the viewport are registered with the outer viewport layer. 3255 // Scrollbars for the viewport are registered with the outer viewport layer.
3254 if (scroll_layer_impl == InnerViewportScrollLayer()) 3256 if (scroll_layer_impl == InnerViewportScrollLayer())
3255 scroll_layer_impl = OuterViewportScrollLayer(); 3257 scroll_layer_impl = OuterViewportScrollLayer();
3256 if (scroll_on_main_thread || !scroll_layer_impl) 3258 if (scroll_on_main_thread || !scroll_layer_impl)
3257 return; 3259 return;
3258 3260
3259 ScrollbarAnimationController* animation_controller = 3261 ScrollbarAnimationController* animation_controller =
3260 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); 3262 ScrollbarAnimationControllerForId(scroll_layer_impl->id());
3261 if (!animation_controller) 3263 if (!animation_controller)
3262 return; 3264 return;
3263 3265
3266 scroll_layer_id_when_mouse_near_scrollbar_ = scroll_layer_impl->id();
3267
3264 float distance_to_scrollbar = std::numeric_limits<float>::max(); 3268 float distance_to_scrollbar = std::numeric_limits<float>::max();
3265 for (ScrollbarLayerImplBase* scrollbar : 3269 for (ScrollbarLayerImplBase* scrollbar :
3266 ScrollbarsFor(scroll_layer_impl->id())) 3270 ScrollbarsFor(scroll_layer_impl->id()))
3267 distance_to_scrollbar = 3271 distance_to_scrollbar =
3268 std::min(distance_to_scrollbar, 3272 std::min(distance_to_scrollbar,
3269 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); 3273 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar));
3270 3274
3271 animation_controller->DidMouseMoveNear(distance_to_scrollbar / 3275 animation_controller->DidMouseMoveNear(distance_to_scrollbar /
3272 active_tree_->device_scale_factor()); 3276 active_tree_->device_scale_factor());
3273 } 3277 }
3274 3278
3279 void LayerTreeHostImpl::MouseLeave() {
3280 // scroll_layer_id_when_mouse_near_scrollbar_ and
3281 // scroll_layer_id_when_mouse_over_scrollbar_ should not be both true
3282 DCHECK(scroll_layer_id_when_mouse_near_scrollbar_ == Layer::INVALID_ID ||
3283 scroll_layer_id_when_mouse_over_scrollbar_ == Layer::INVALID_ID);
3284
3285 int scroll_layer_id =
3286 scroll_layer_id_when_mouse_near_scrollbar_ != Layer::INVALID_ID
3287 ? scroll_layer_id_when_mouse_near_scrollbar_
3288 : scroll_layer_id_when_mouse_over_scrollbar_;
3289
3290 ScrollbarAnimationController* animation_controller =
3291 ScrollbarAnimationControllerForId(scroll_layer_id);
3292
3293 if (animation_controller)
3294 animation_controller->DidMouseMoveOffScrollbar();
3295
3296 scroll_layer_id_when_mouse_over_scrollbar_ = Layer::INVALID_ID;
3297 }
3298
3275 void LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl) { 3299 void LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl) {
3276 int new_id = Layer::INVALID_ID; 3300 int new_id = Layer::INVALID_ID;
3277 if (layer_impl && layer_impl->ToScrollbarLayer()) 3301 if (layer_impl && layer_impl->ToScrollbarLayer())
3278 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); 3302 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId();
3279 3303
3280 if (new_id == scroll_layer_id_when_mouse_over_scrollbar_) 3304 if (new_id == scroll_layer_id_when_mouse_over_scrollbar_)
3281 return; 3305 return;
3282 3306
3283 ScrollbarAnimationController* old_animation_controller = 3307 ScrollbarAnimationController* old_animation_controller =
3284 ScrollbarAnimationControllerForId( 3308 ScrollbarAnimationControllerForId(
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 if (is_visible) { 4112 if (is_visible) {
4089 worker_context_visibility_ = 4113 worker_context_visibility_ =
4090 worker_context->CacheController()->ClientBecameVisible(); 4114 worker_context->CacheController()->ClientBecameVisible();
4091 } else { 4115 } else {
4092 worker_context->CacheController()->ClientBecameNotVisible( 4116 worker_context->CacheController()->ClientBecameNotVisible(
4093 std::move(worker_context_visibility_)); 4117 std::move(worker_context_visibility_));
4094 } 4118 }
4095 } 4119 }
4096 4120
4097 } // namespace cc 4121 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698