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

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
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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 // We assume that the absence of synchronous_compositor_factory 2160 // We assume that the absence of synchronous_compositor_factory
2158 // means we are in Chrome. In chrome, we want to clip, i.e. 2161 // means we are in Chrome. In chrome, we want to clip, i.e.
2159 // *not* to record the full layer. 2162 // *not* to record the full layer.
2160 if (!synchronous_compositor_factory) 2163 if (!synchronous_compositor_factory)
2161 return false; 2164 return false;
2162 2165
2163 return synchronous_compositor_factory->RecordFullLayer(); 2166 return synchronous_compositor_factory->RecordFullLayer();
2164 } 2167 }
2165 #endif 2168 #endif
2166 2169
2170 bool RenderWidget::IsElasticOverscrollEnabled() const {
2171 return compositor_deps_->IsElasticOverscrollEnabled();
2172 }
2173
2167 bool RenderWidget::CanComposeInline() { 2174 bool RenderWidget::CanComposeInline() {
2168 return true; 2175 return true;
2169 } 2176 }
2170 2177
2171 WebScreenInfo RenderWidget::screenInfo() { 2178 WebScreenInfo RenderWidget::screenInfo() {
2172 return screen_info_; 2179 return screen_info_;
2173 } 2180 }
2174 2181
2175 float RenderWidget::deviceScaleFactor() { 2182 float RenderWidget::deviceScaleFactor() {
2176 return device_scale_factor_; 2183 return device_scale_factor_;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 return false; 2308 return false;
2302 } 2309 }
2303 2310
2304 bool RenderWidget::WillHandleGestureEvent( 2311 bool RenderWidget::WillHandleGestureEvent(
2305 const blink::WebGestureEvent& event) { 2312 const blink::WebGestureEvent& event) {
2306 return false; 2313 return false;
2307 } 2314 }
2308 2315
2309 void RenderWidget::ObserveWheelEventAndResult( 2316 void RenderWidget::ObserveWheelEventAndResult(
2310 const blink::WebMouseWheelEvent& wheel_event, 2317 const blink::WebMouseWheelEvent& wheel_event,
2318 const gfx::Vector2dF& wheel_unused_delta,
2311 bool event_processed) { 2319 bool event_processed) {
2312 if (!compositor_deps_->IsElasticOverscrollEnabled()) 2320 if (!compositor_deps_->IsElasticOverscrollEnabled())
2313 return; 2321 return;
2314 2322
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; 2323 cc::InputHandlerScrollResult scroll_result;
2321 if (event_processed) { 2324 scroll_result.did_scroll = event_processed;
2322 scroll_result.did_scroll = true; 2325 scroll_result.did_overscroll_root = !wheel_unused_delta.IsZero();
2323 } else { 2326 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 2327
2329 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 2328 RenderThreadImpl* render_thread = RenderThreadImpl::current();
2330 InputHandlerManager* input_handler_manager = 2329 InputHandlerManager* input_handler_manager =
2331 render_thread ? render_thread->input_handler_manager() : NULL; 2330 render_thread ? render_thread->input_handler_manager() : NULL;
2332 if (input_handler_manager) { 2331 if (input_handler_manager) {
2333 input_handler_manager->ObserveWheelEventAndResultOnMainThread( 2332 input_handler_manager->ObserveWheelEventAndResultOnMainThread(
2334 routing_id_, wheel_event, scroll_result); 2333 routing_id_, wheel_event, scroll_result);
2335 } 2334 }
2336 } 2335 }
2337 2336
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2472 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2474 video_hole_frames_.AddObserver(frame); 2473 video_hole_frames_.AddObserver(frame);
2475 } 2474 }
2476 2475
2477 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2476 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2478 video_hole_frames_.RemoveObserver(frame); 2477 video_hole_frames_.RemoveObserver(frame);
2479 } 2478 }
2480 #endif // defined(VIDEO_HOLE) 2479 #endif // defined(VIDEO_HOLE)
2481 2480
2482 } // namespace content 2481 } // namespace content
OLDNEW
« content/renderer/render_view_impl.cc ('K') | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698