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

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: Rebased to latest 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.get(), processed);
1212 } 1213 }
1213 1214
1214 bool frame_pending = compositor_ && compositor_->BeginMainFrameRequested(); 1215 bool frame_pending = compositor_ && compositor_->BeginMainFrameRequested();
1215 1216
1216 // If we don't have a fast and accurate Now(), we assume the input handlers 1217 // If we don't have a fast and accurate Now(), we assume the input handlers
1217 // are heavy and rate limit them. 1218 // are heavy and rate limit them.
1218 bool rate_limiting_wanted = 1219 bool rate_limiting_wanted =
1219 input_event->type == WebInputEvent::MouseMove || 1220 input_event->type == WebInputEvent::MouseMove ||
1220 input_event->type == WebInputEvent::MouseWheel; 1221 input_event->type == WebInputEvent::MouseWheel;
1221 if (rate_limiting_wanted && !start_time.is_null()) { 1222 if (rate_limiting_wanted && !start_time.is_null()) {
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 // We assume that the absence of synchronous_compositor_factory 2158 // We assume that the absence of synchronous_compositor_factory
2158 // means we are in Chrome. In chrome, we want to clip, i.e. 2159 // means we are in Chrome. In chrome, we want to clip, i.e.
2159 // *not* to record the full layer. 2160 // *not* to record the full layer.
2160 if (!synchronous_compositor_factory) 2161 if (!synchronous_compositor_factory)
2161 return false; 2162 return false;
2162 2163
2163 return synchronous_compositor_factory->RecordFullLayer(); 2164 return synchronous_compositor_factory->RecordFullLayer();
2164 } 2165 }
2165 #endif 2166 #endif
2166 2167
2168 bool RenderWidget::IsElasticOverscrollEnabled() const {
2169 return compositor_deps_->IsElasticOverscrollEnabled();
2170 }
2171
2167 bool RenderWidget::CanComposeInline() { 2172 bool RenderWidget::CanComposeInline() {
2168 return true; 2173 return true;
2169 } 2174 }
2170 2175
2171 WebScreenInfo RenderWidget::screenInfo() { 2176 WebScreenInfo RenderWidget::screenInfo() {
2172 return screen_info_; 2177 return screen_info_;
2173 } 2178 }
2174 2179
2175 float RenderWidget::deviceScaleFactor() { 2180 float RenderWidget::deviceScaleFactor() {
2176 return device_scale_factor_; 2181 return device_scale_factor_;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 return false; 2306 return false;
2302 } 2307 }
2303 2308
2304 bool RenderWidget::WillHandleGestureEvent( 2309 bool RenderWidget::WillHandleGestureEvent(
2305 const blink::WebGestureEvent& event) { 2310 const blink::WebGestureEvent& event) {
2306 return false; 2311 return false;
2307 } 2312 }
2308 2313
2309 void RenderWidget::ObserveWheelEventAndResult( 2314 void RenderWidget::ObserveWheelEventAndResult(
2310 const blink::WebMouseWheelEvent& wheel_event, 2315 const blink::WebMouseWheelEvent& wheel_event,
2316 DidOverscrollParams* params,
2311 bool event_processed) { 2317 bool event_processed) {
2312 if (!compositor_deps_->IsElasticOverscrollEnabled()) 2318 if (!compositor_deps_->IsElasticOverscrollEnabled())
2313 return; 2319 return;
2314 2320
2315 // Blink does not accurately compute scroll bubbling or overscroll. For now, 2321 gfx::Vector2dF wheel_unused_delta;
jdduke (slow) 2015/06/26 15:15:45 Ah, I didn't realize we only use the "latest_overs
MuVen 2015/06/29 13:29:52 Done.
2316 // assume that an unprocessed event was entirely an overscroll, and that a 2322 if (params)
2317 // processed event was entirely scroll. 2323 wheel_unused_delta = params->latest_overscroll_delta;
2318 // TODO(ccameron): Retrieve an accurate scroll result from Blink. 2324
2319 // http://crbug.com/442859
2320 cc::InputHandlerScrollResult scroll_result; 2325 cc::InputHandlerScrollResult scroll_result;
2321 if (event_processed) { 2326 scroll_result.did_scroll = event_processed;
2322 scroll_result.did_scroll = true; 2327 scroll_result.did_overscroll_root = !wheel_unused_delta.IsZero();
2323 } else { 2328 ;
jdduke (slow) 2015/06/26 15:15:45 Looks like an extra ';'
MuVen 2015/06/29 13:29:52 Done.
2324 scroll_result.did_overscroll_root = true; 2329 scroll_result.unused_scroll_delta = wheel_unused_delta;
2325 scroll_result.unused_scroll_delta =
2326 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY);
2327 }
2328 2330
2329 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 2331 RenderThreadImpl* render_thread = RenderThreadImpl::current();
2330 InputHandlerManager* input_handler_manager = 2332 InputHandlerManager* input_handler_manager =
2331 render_thread ? render_thread->input_handler_manager() : NULL; 2333 render_thread ? render_thread->input_handler_manager() : NULL;
2332 if (input_handler_manager) { 2334 if (input_handler_manager) {
2333 input_handler_manager->ObserveWheelEventAndResultOnMainThread( 2335 input_handler_manager->ObserveWheelEventAndResultOnMainThread(
2334 routing_id_, wheel_event, scroll_result); 2336 routing_id_, wheel_event, scroll_result);
2335 } 2337 }
2336 } 2338 }
2337 2339
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2475 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2474 video_hole_frames_.AddObserver(frame); 2476 video_hole_frames_.AddObserver(frame);
2475 } 2477 }
2476 2478
2477 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2479 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2478 video_hole_frames_.RemoveObserver(frame); 2480 video_hole_frames_.RemoveObserver(frame);
2479 } 2481 }
2480 #endif // defined(VIDEO_HOLE) 2482 #endif // defined(VIDEO_HOLE)
2481 2483
2482 } // namespace content 2484 } // 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