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

Side by Side Diff: content/renderer/render_widget.cc

Issue 1203693003: Setting Accurate ScrollResult from Blink for Elastic Scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1201 ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1202 break; 1202 break;
1203 } 1203 }
1204 } 1204 }
1205 } 1205 }
1206 1206
1207 // Send mouse wheel events and their disposition to the compositor thread, so 1207 // Send mouse wheel events and their disposition to the compositor thread, so
1208 // that they can be used to produce the elastic overscroll effect on Mac. 1208 // that they can be used to produce the elastic overscroll effect on Mac.
1209 if (input_event->type == WebInputEvent::MouseWheel) { 1209 if (input_event->type == WebInputEvent::MouseWheel) {
1210 ObserveWheelEventAndResult( 1210 ObserveWheelEventAndResult(
1211 static_cast<const WebMouseWheelEvent&>(*input_event), processed); 1211 static_cast<const WebMouseWheelEvent&>(*input_event),
1212 event_overscroll ? event_overscroll->latest_overscroll_delta
1213 : gfx::Vector2dF(),
1214 processed);
1212 } 1215 }
1213 1216
1214 bool frame_pending = compositor_ && compositor_->BeginMainFrameRequested(); 1217 bool frame_pending = compositor_ && compositor_->BeginMainFrameRequested();
1215 1218
1216 // If we don't have a fast and accurate Now(), we assume the input handlers 1219 // If we don't have a fast and accurate Now(), we assume the input handlers
1217 // are heavy and rate limit them. 1220 // are heavy and rate limit them.
1218 bool rate_limiting_wanted = 1221 bool rate_limiting_wanted =
1219 input_event->type == WebInputEvent::MouseMove || 1222 input_event->type == WebInputEvent::MouseMove ||
1220 input_event->type == WebInputEvent::MouseWheel; 1223 input_event->type == WebInputEvent::MouseWheel;
1221 if (rate_limiting_wanted && !start_time.is_null()) { 1224 if (rate_limiting_wanted && !start_time.is_null()) {
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 return false; 2304 return false;
2302 } 2305 }
2303 2306
2304 bool RenderWidget::WillHandleGestureEvent( 2307 bool RenderWidget::WillHandleGestureEvent(
2305 const blink::WebGestureEvent& event) { 2308 const blink::WebGestureEvent& event) {
2306 return false; 2309 return false;
2307 } 2310 }
2308 2311
2309 void RenderWidget::ObserveWheelEventAndResult( 2312 void RenderWidget::ObserveWheelEventAndResult(
2310 const blink::WebMouseWheelEvent& wheel_event, 2313 const blink::WebMouseWheelEvent& wheel_event,
2314 const gfx::Vector2dF& wheel_unused_delta,
2311 bool event_processed) { 2315 bool event_processed) {
2312 if (!compositor_deps_->IsElasticOverscrollEnabled()) 2316 if (!compositor_deps_->IsElasticOverscrollEnabled())
2313 return; 2317 return;
2314 2318
2315 // Blink does not accurately compute scroll bubbling or overscroll. For now,
2316 // assume that an unprocessed event was entirely an overscroll, and that a
2317 // processed event was entirely scroll.
2318 // TODO(ccameron): Retrieve an accurate scroll result from Blink.
2319 // http://crbug.com/442859
2320 cc::InputHandlerScrollResult scroll_result; 2319 cc::InputHandlerScrollResult scroll_result;
2321 if (event_processed) { 2320 scroll_result.did_scroll = event_processed;
2322 scroll_result.did_scroll = true; 2321 scroll_result.did_overscroll_root = !wheel_unused_delta.IsZero();
2323 } else { 2322 scroll_result.unused_scroll_delta = wheel_unused_delta;
2324 scroll_result.did_overscroll_root = true;
2325 scroll_result.unused_scroll_delta =
2326 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY);
2327 }
2328 2323
2329 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 2324 RenderThreadImpl* render_thread = RenderThreadImpl::current();
2330 InputHandlerManager* input_handler_manager = 2325 InputHandlerManager* input_handler_manager =
2331 render_thread ? render_thread->input_handler_manager() : NULL; 2326 render_thread ? render_thread->input_handler_manager() : NULL;
2332 if (input_handler_manager) { 2327 if (input_handler_manager) {
2333 input_handler_manager->ObserveWheelEventAndResultOnMainThread( 2328 input_handler_manager->ObserveWheelEventAndResultOnMainThread(
2334 routing_id_, wheel_event, scroll_result); 2329 routing_id_, wheel_event, scroll_result);
2335 } 2330 }
2336 } 2331 }
2337 2332
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2468 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2474 video_hole_frames_.AddObserver(frame); 2469 video_hole_frames_.AddObserver(frame);
2475 } 2470 }
2476 2471
2477 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2472 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2478 video_hole_frames_.RemoveObserver(frame); 2473 video_hole_frames_.RemoveObserver(frame);
2479 } 2474 }
2480 #endif // defined(VIDEO_HOLE) 2475 #endif // defined(VIDEO_HOLE)
2481 2476
2482 } // namespace content 2477 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698