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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2203 bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point, | 2203 bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point, |
2204 const gfx::Vector2dF& scroll_delta) { | 2204 const gfx::Vector2dF& scroll_delta) { |
2205 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); | 2205 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); |
2206 if (!CurrentlyScrollingLayer()) | 2206 if (!CurrentlyScrollingLayer()) |
2207 return false; | 2207 return false; |
2208 | 2208 |
2209 gfx::Vector2dF pending_delta = scroll_delta; | 2209 gfx::Vector2dF pending_delta = scroll_delta; |
2210 gfx::Vector2dF unused_root_delta; | 2210 gfx::Vector2dF unused_root_delta; |
2211 bool did_scroll_x = false; | 2211 bool did_scroll_x = false; |
2212 bool did_scroll_y = false; | 2212 bool did_scroll_y = false; |
2213 bool did_scroll_top_controls = false; | |
2213 // TODO(wjmaclean) Should we guard against CurrentlyScrollingLayer() == 0 | 2214 // TODO(wjmaclean) Should we guard against CurrentlyScrollingLayer() == 0 |
2214 // here? | 2215 // here? |
2215 bool consume_by_top_controls = | 2216 bool consume_by_top_controls = |
2216 top_controls_manager_ && | 2217 top_controls_manager_ && |
2217 (((CurrentlyScrollingLayer() == InnerViewportScrollLayer() || | 2218 (((CurrentlyScrollingLayer() == InnerViewportScrollLayer() || |
2218 CurrentlyScrollingLayer() == OuterViewportScrollLayer()) && | 2219 CurrentlyScrollingLayer() == OuterViewportScrollLayer()) && |
2219 InnerViewportScrollLayer()->MaxScrollOffset().y() > 0) || | 2220 InnerViewportScrollLayer()->MaxScrollOffset().y() > 0) || |
2220 scroll_delta.y() < 0); | 2221 scroll_delta.y() < 0); |
2221 | 2222 |
2222 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); | 2223 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); |
2223 layer_impl; | 2224 layer_impl; |
2224 layer_impl = layer_impl->parent()) { | 2225 layer_impl = layer_impl->parent()) { |
2225 if (!layer_impl->scrollable()) | 2226 if (!layer_impl->scrollable()) |
2226 continue; | 2227 continue; |
2227 | 2228 |
2228 if (layer_impl == InnerViewportScrollLayer()) { | 2229 if (layer_impl == InnerViewportScrollLayer()) { |
2229 // Only allow bubble scrolling when the scroll is in the direction to make | 2230 // Only allow bubble scrolling when the scroll is in the direction to make |
2230 // the top controls visible. | 2231 // the top controls visible. |
2231 gfx::Vector2dF applied_delta; | 2232 gfx::Vector2dF applied_delta; |
2232 gfx::Vector2dF excess_delta; | 2233 gfx::Vector2dF excess_delta; |
2233 if (consume_by_top_controls) { | 2234 if (consume_by_top_controls) { |
2234 excess_delta = top_controls_manager_->ScrollBy(pending_delta); | 2235 excess_delta = top_controls_manager_->ScrollBy(pending_delta); |
2235 applied_delta = pending_delta - excess_delta; | 2236 applied_delta = pending_delta - excess_delta; |
2236 pending_delta = excess_delta; | 2237 pending_delta = excess_delta; |
2237 // Force updating of vertical adjust values if needed. | 2238 // Force updating of vertical adjust values if needed. |
2238 if (applied_delta.y() != 0) | 2239 if (applied_delta.y() != 0) { |
2240 did_scroll_top_controls = true; | |
2239 layer_impl->ScrollbarParametersDidChange(); | 2241 layer_impl->ScrollbarParametersDidChange(); |
2242 } | |
2240 } | 2243 } |
2241 // Track root layer deltas for reporting overscroll. | 2244 // Track root layer deltas for reporting overscroll. |
2242 unused_root_delta = pending_delta; | 2245 unused_root_delta = pending_delta; |
2243 } | 2246 } |
2244 | 2247 |
2245 gfx::Vector2dF applied_delta; | 2248 gfx::Vector2dF applied_delta; |
2246 // Gesture events need to be transformed from viewport coordinates to local | 2249 // Gesture events need to be transformed from viewport coordinates to local |
2247 // layer coordinates so that the scrolling contents exactly follow the | 2250 // layer coordinates so that the scrolling contents exactly follow the |
2248 // user's finger. In contrast, wheel events represent a fixed amount of | 2251 // user's finger. In contrast, wheel events represent a fixed amount of |
2249 // scrolling so we can just apply them directly. | 2252 // scrolling so we can just apply them directly. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2293 | 2296 |
2294 // Allow further movement only on an axis perpendicular to the direction in | 2297 // Allow further movement only on an axis perpendicular to the direction in |
2295 // which the layer moved. | 2298 // which the layer moved. |
2296 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); | 2299 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); |
2297 pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis); | 2300 pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis); |
2298 | 2301 |
2299 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) | 2302 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) |
2300 break; | 2303 break; |
2301 } | 2304 } |
2302 | 2305 |
2303 bool did_scroll = did_scroll_x || did_scroll_y; | 2306 bool did_scroll_content = did_scroll_x || did_scroll_y; |
2304 if (did_scroll) { | 2307 if (did_scroll_content) { |
aelias_OOO_until_Jul13
2014/03/07 21:09:09
I think this should also have "|| did_scroll_top_c
aelias_OOO_until_Jul13
2014/03/07 21:12:32
Sorry, ignore that comment. Of course, you didn't
| |
2305 client_->SetNeedsCommitOnImplThread(); | 2308 client_->SetNeedsCommitOnImplThread(); |
2306 SetNeedsRedraw(); | 2309 SetNeedsRedraw(); |
2307 client_->RenewTreePriority(); | 2310 client_->RenewTreePriority(); |
2308 } | 2311 } |
2309 | 2312 |
2310 // Scrolling along an axis resets accumulated root overscroll for that axis. | 2313 // Scrolling along an axis resets accumulated root overscroll for that axis. |
2311 if (did_scroll_x) | 2314 if (did_scroll_x) |
2312 accumulated_root_overscroll_.set_x(0); | 2315 accumulated_root_overscroll_.set_x(0); |
2313 if (did_scroll_y) | 2316 if (did_scroll_y) |
2314 accumulated_root_overscroll_.set_y(0); | 2317 accumulated_root_overscroll_.set_y(0); |
2315 | 2318 |
2316 accumulated_root_overscroll_ += unused_root_delta; | 2319 accumulated_root_overscroll_ += unused_root_delta; |
2317 bool did_overscroll = !gfx::ToRoundedVector2d(unused_root_delta).IsZero(); | 2320 bool did_overscroll = !gfx::ToRoundedVector2d(unused_root_delta).IsZero(); |
2318 if (did_overscroll && input_handler_client_) { | 2321 if (did_overscroll && input_handler_client_) { |
2319 DidOverscrollParams params; | 2322 DidOverscrollParams params; |
2320 params.accumulated_overscroll = accumulated_root_overscroll_; | 2323 params.accumulated_overscroll = accumulated_root_overscroll_; |
2321 params.latest_overscroll_delta = unused_root_delta; | 2324 params.latest_overscroll_delta = unused_root_delta; |
2322 params.current_fling_velocity = current_fling_velocity_; | 2325 params.current_fling_velocity = current_fling_velocity_; |
2323 input_handler_client_->DidOverscroll(params); | 2326 input_handler_client_->DidOverscroll(params); |
2324 } | 2327 } |
2325 | 2328 |
2326 return did_scroll; | 2329 return did_scroll_content || did_scroll_top_controls; |
2327 } | 2330 } |
2328 | 2331 |
2329 // This implements scrolling by page as described here: | 2332 // This implements scrolling by page as described here: |
2330 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel | 2333 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel |
2331 // for events with WHEEL_PAGESCROLL set. | 2334 // for events with WHEEL_PAGESCROLL set. |
2332 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 2335 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
2333 ScrollDirection direction) { | 2336 ScrollDirection direction) { |
2334 DCHECK(wheel_scrolling_); | 2337 DCHECK(wheel_scrolling_); |
2335 | 2338 |
2336 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); | 2339 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3026 swap_promise_monitor_.erase(monitor); | 3029 swap_promise_monitor_.erase(monitor); |
3027 } | 3030 } |
3028 | 3031 |
3029 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3032 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3030 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3033 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3031 for (; it != swap_promise_monitor_.end(); it++) | 3034 for (; it != swap_promise_monitor_.end(); it++) |
3032 (*it)->OnSetNeedsRedrawOnImpl(); | 3035 (*it)->OnSetNeedsRedrawOnImpl(); |
3033 } | 3036 } |
3034 | 3037 |
3035 } // namespace cc | 3038 } // namespace cc |
OLD | NEW |