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

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

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: fix for fade in/out together Created 4 years 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 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 1651
1652 // Collect all resource ids in the render passes into a single array. 1652 // Collect all resource ids in the render passes into a single array.
1653 ResourceProvider::ResourceIdArray resources; 1653 ResourceProvider::ResourceIdArray resources;
1654 for (const auto& render_pass : frame->render_passes) { 1654 for (const auto& render_pass : frame->render_passes) {
1655 for (auto* quad : render_pass->quad_list) { 1655 for (auto* quad : render_pass->quad_list) {
1656 for (ResourceId resource_id : quad->resources) 1656 for (ResourceId resource_id : quad->resources)
1657 resources.push_back(resource_id); 1657 resources.push_back(resource_id);
1658 } 1658 }
1659 } 1659 }
1660 1660
1661
1662 CompositorFrame compositor_frame; 1661 CompositorFrame compositor_frame;
1663 compositor_frame.metadata = std::move(metadata); 1662 compositor_frame.metadata = std::move(metadata);
1664 resource_provider_->PrepareSendToParent(resources, 1663 resource_provider_->PrepareSendToParent(resources,
1665 &compositor_frame.resource_list); 1664 &compositor_frame.resource_list);
1666 compositor_frame.render_pass_list = std::move(frame->render_passes); 1665 compositor_frame.render_pass_list = std::move(frame->render_passes);
1667 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); 1666 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame));
1668 1667
1669 // The next frame should start by assuming nothing has changed, and changes 1668 // The next frame should start by assuming nothing has changed, and changes
1670 // are noted as they occur. 1669 // are noted as they occur.
1671 // TODO(boliu): If we did a temporary software renderer frame, propogate the 1670 // TODO(boliu): If we did a temporary software renderer frame, propogate the
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 } 3220 }
3222 3221
3223 void LayerTreeHostImpl::MouseUp() { 3222 void LayerTreeHostImpl::MouseUp() {
3224 ScrollbarAnimationController* animation_controller = 3223 ScrollbarAnimationController* animation_controller =
3225 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_); 3224 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_);
3226 if (animation_controller) 3225 if (animation_controller)
3227 animation_controller->DidMouseUp(); 3226 animation_controller->DidMouseUp();
3228 } 3227 }
3229 3228
3230 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { 3229 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
3231 float distance_to_scrollbar = std::numeric_limits<float>::max();
3232 gfx::PointF device_viewport_point = gfx::ScalePoint( 3230 gfx::PointF device_viewport_point = gfx::ScalePoint(
3233 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 3231 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
3234 LayerImpl* layer_impl = 3232 LayerImpl* layer_impl =
3235 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 3233 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
3236 3234
3237 // Check if mouse is over a scrollbar or not. 3235 // Check if mouse is over a scrollbar or not.
3238 // TODO(sahel): get rid of this extera checking when 3236 // TODO(sahel): get rid of this extera checking when
3239 // FindScrollLayerForDeviceViewportPoint finds the proper layer for 3237 // FindScrollLayerForDeviceViewportPoint finds the proper layer for
3240 // scrolling on main thread, as well. 3238 // scrolling on main thread, as well.
3241 int new_id = Layer::INVALID_ID; 3239 int new_id = Layer::INVALID_ID;
3242 if (layer_impl && layer_impl->ToScrollbarLayer()) 3240 if (layer_impl && layer_impl->ToScrollbarLayer())
3243 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); 3241 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId();
3244 if (new_id != Layer::INVALID_ID) { 3242 if (new_id == Layer::INVALID_ID) {
3245 // Mouse over a scrollbar.
3246 distance_to_scrollbar = 0;
3247 } else {
3248 bool scroll_on_main_thread = false; 3243 bool scroll_on_main_thread = false;
3249 uint32_t main_thread_scrolling_reasons; 3244 uint32_t main_thread_scrolling_reasons;
3250 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( 3245 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint(
3251 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, 3246 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl,
3252 &scroll_on_main_thread, &main_thread_scrolling_reasons); 3247 &scroll_on_main_thread, &main_thread_scrolling_reasons);
3253 3248
3254 // Scrollbars for the viewport are registered with the outer viewport layer. 3249 // Scrollbars for the viewport are registered with the outer viewport layer.
3255 if (scroll_layer_impl == InnerViewportScrollLayer()) 3250 if (scroll_layer_impl == InnerViewportScrollLayer())
3256 scroll_layer_impl = OuterViewportScrollLayer(); 3251 scroll_layer_impl = OuterViewportScrollLayer();
3257 3252
3258 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; 3253 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID;
3259 } 3254 }
3260 3255
3261 if (new_id != scroll_layer_id_mouse_currently_over_) { 3256 if (new_id != scroll_layer_id_mouse_currently_over_) {
3262 ScrollbarAnimationController* old_animation_controller = 3257 ScrollbarAnimationController* old_animation_controller =
3263 ScrollbarAnimationControllerForId( 3258 ScrollbarAnimationControllerForId(
3264 scroll_layer_id_mouse_currently_over_); 3259 scroll_layer_id_mouse_currently_over_);
3265 if (old_animation_controller) { 3260 if (old_animation_controller) {
3266 old_animation_controller->DidMouseLeave(); 3261 old_animation_controller->DidMouseLeave();
3267 } 3262 }
3268 scroll_layer_id_mouse_currently_over_ = new_id; 3263 scroll_layer_id_mouse_currently_over_ = new_id;
3269 } 3264 }
3270 3265
3271 ScrollbarAnimationController* new_animation_controller = 3266 ScrollbarAnimationController* new_animation_controller =
3272 ScrollbarAnimationControllerForId(new_id); 3267 ScrollbarAnimationControllerForId(new_id);
3273 if (!new_animation_controller) 3268 if (!new_animation_controller)
3274 return; 3269 return;
3275 3270
3276 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) 3271 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) {
3277 distance_to_scrollbar = 3272 new_animation_controller->DidMouseMoveNear(
3278 std::min(distance_to_scrollbar, 3273 scrollbar->orientation(),
3279 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); 3274 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) /
3280 new_animation_controller->DidMouseMoveNear( 3275 active_tree_->device_scale_factor());
3281 distance_to_scrollbar / active_tree_->device_scale_factor()); 3276 }
3277 new_animation_controller->EnsureScrollbarFadeIn();
bokan 2016/12/16 14:57:42 Make this private and move it into DidMouseMoveNea
chaopeng 2016/12/16 21:02:25 No, we need to keep scrollbar fade in while the mo
3282 } 3278 }
3283 3279
3284 void LayerTreeHostImpl::MouseLeave() { 3280 void LayerTreeHostImpl::MouseLeave() {
3285 for (auto& pair : scrollbar_animation_controllers_) 3281 for (auto& pair : scrollbar_animation_controllers_)
3286 pair.second->DidMouseLeave(); 3282 pair.second->DidMouseLeave();
3287 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; 3283 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID;
3288 } 3284 }
3289 3285
3290 void LayerTreeHostImpl::PinchGestureBegin() { 3286 void LayerTreeHostImpl::PinchGestureBegin() {
3291 pinch_gesture_active_ = true; 3287 pinch_gesture_active_ = true;
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
4083 worker_context_visibility_ = 4079 worker_context_visibility_ =
4084 worker_context->CacheController()->ClientBecameVisible(); 4080 worker_context->CacheController()->ClientBecameVisible();
4085 } else { 4081 } else {
4086 worker_context->CacheController()->ClientBecameNotVisible( 4082 worker_context->CacheController()->ClientBecameNotVisible(
4087 std::move(worker_context_visibility_)); 4083 std::move(worker_context_visibility_));
4088 } 4084 }
4089 } 4085 }
4090 } 4086 }
4091 4087
4092 } // namespace cc 4088 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698