| OLD | NEW |
| 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 3139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3150 // input handler. | 3150 // input handler. |
| 3151 UpdateRootLayerStateForSynchronousInputHandler(); | 3151 UpdateRootLayerStateForSynchronousInputHandler(); |
| 3152 } | 3152 } |
| 3153 | 3153 |
| 3154 // Update compositor worker mutations which may respond to scrolling. | 3154 // Update compositor worker mutations which may respond to scrolling. |
| 3155 Mutate(CurrentBeginFrameArgs().frame_time); | 3155 Mutate(CurrentBeginFrameArgs().frame_time); |
| 3156 | 3156 |
| 3157 return scroll_result; | 3157 return scroll_result; |
| 3158 } | 3158 } |
| 3159 | 3159 |
| 3160 // This implements scrolling by page as described here: | |
| 3161 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel | |
| 3162 // for events with WHEEL_PAGESCROLL set. | |
| 3163 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | |
| 3164 ScrollDirection direction) { | |
| 3165 DCHECK(wheel_scrolling_); | |
| 3166 | |
| 3167 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | |
| 3168 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | |
| 3169 if (scroll_node) { | |
| 3170 for (; scroll_tree.parent(scroll_node); | |
| 3171 scroll_node = scroll_tree.parent(scroll_node)) { | |
| 3172 // The inner viewport layer represents the viewport. | |
| 3173 if (!scroll_node->scrollable || | |
| 3174 scroll_node->is_outer_viewport_scroll_layer) | |
| 3175 continue; | |
| 3176 | |
| 3177 float height = | |
| 3178 scroll_tree.scroll_clip_layer_bounds(scroll_node->id).height(); | |
| 3179 | |
| 3180 // These magical values match WebKit and are designed to scroll nearly the | |
| 3181 // entire visible content height but leave a bit of overlap. | |
| 3182 float page = std::max(height * 0.875f, 1.f); | |
| 3183 if (direction == SCROLL_BACKWARD) | |
| 3184 page = -page; | |
| 3185 | |
| 3186 gfx::Vector2dF delta = gfx::Vector2dF(0.f, page); | |
| 3187 | |
| 3188 gfx::Vector2dF applied_delta = | |
| 3189 ScrollNodeWithLocalDelta(scroll_node, delta, 1.f, active_tree()); | |
| 3190 | |
| 3191 if (!applied_delta.IsZero()) { | |
| 3192 client_->SetNeedsCommitOnImplThread(); | |
| 3193 SetNeedsRedraw(); | |
| 3194 client_->RenewTreePriority(); | |
| 3195 return true; | |
| 3196 } | |
| 3197 | |
| 3198 scroll_tree.set_currently_scrolling_node(scroll_node->id); | |
| 3199 } | |
| 3200 } | |
| 3201 return false; | |
| 3202 } | |
| 3203 | |
| 3204 void LayerTreeHostImpl::RequestUpdateForSynchronousInputHandler() { | 3160 void LayerTreeHostImpl::RequestUpdateForSynchronousInputHandler() { |
| 3205 UpdateRootLayerStateForSynchronousInputHandler(); | 3161 UpdateRootLayerStateForSynchronousInputHandler(); |
| 3206 } | 3162 } |
| 3207 | 3163 |
| 3208 void LayerTreeHostImpl::SetSynchronousInputHandlerRootScrollOffset( | 3164 void LayerTreeHostImpl::SetSynchronousInputHandlerRootScrollOffset( |
| 3209 const gfx::ScrollOffset& root_offset) { | 3165 const gfx::ScrollOffset& root_offset) { |
| 3210 bool changed = active_tree_->DistributeRootScrollOffset(root_offset); | 3166 bool changed = active_tree_->DistributeRootScrollOffset(root_offset); |
| 3211 if (!changed) | 3167 if (!changed) |
| 3212 return; | 3168 return; |
| 3213 | 3169 |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4197 if (is_visible) { | 4153 if (is_visible) { |
| 4198 worker_context_visibility_ = | 4154 worker_context_visibility_ = |
| 4199 worker_context->CacheController()->ClientBecameVisible(); | 4155 worker_context->CacheController()->ClientBecameVisible(); |
| 4200 } else { | 4156 } else { |
| 4201 worker_context->CacheController()->ClientBecameNotVisible( | 4157 worker_context->CacheController()->ClientBecameNotVisible( |
| 4202 std::move(worker_context_visibility_)); | 4158 std::move(worker_context_visibility_)); |
| 4203 } | 4159 } |
| 4204 } | 4160 } |
| 4205 | 4161 |
| 4206 } // namespace cc | 4162 } // namespace cc |
| OLD | NEW |