Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2140 // We assume that the absence of synchronous_compositor_factory | 2140 // We assume that the absence of synchronous_compositor_factory |
| 2141 // means we are in Chrome. In chrome, we want to clip, i.e. | 2141 // means we are in Chrome. In chrome, we want to clip, i.e. |
| 2142 // *not* to record the full layer. | 2142 // *not* to record the full layer. |
| 2143 if (!synchronous_compositor_factory) | 2143 if (!synchronous_compositor_factory) |
| 2144 return false; | 2144 return false; |
| 2145 | 2145 |
| 2146 return synchronous_compositor_factory->RecordFullLayer(); | 2146 return synchronous_compositor_factory->RecordFullLayer(); |
| 2147 } | 2147 } |
| 2148 #endif | 2148 #endif |
| 2149 | 2149 |
| 2150 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 2151 bool RenderWidget::IsElasticOverscrollEnabled() const { | |
| 2152 return compositor_deps_->IsElasticOverscrollEnabled(); | |
| 2153 } | |
| 2154 #endif | |
| 2155 | |
| 2150 bool RenderWidget::CanComposeInline() { | 2156 bool RenderWidget::CanComposeInline() { |
| 2151 return true; | 2157 return true; |
| 2152 } | 2158 } |
| 2153 | 2159 |
| 2154 WebScreenInfo RenderWidget::screenInfo() { | 2160 WebScreenInfo RenderWidget::screenInfo() { |
| 2155 return screen_info_; | 2161 return screen_info_; |
| 2156 } | 2162 } |
| 2157 | 2163 |
| 2158 float RenderWidget::deviceScaleFactor() { | 2164 float RenderWidget::deviceScaleFactor() { |
| 2159 return device_scale_factor_; | 2165 return device_scale_factor_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2208 UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_NON_IME); | 2214 UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_NON_IME); |
| 2209 } | 2215 } |
| 2210 #endif | 2216 #endif |
| 2211 } | 2217 } |
| 2212 | 2218 |
| 2213 void RenderWidget::didOverscroll( | 2219 void RenderWidget::didOverscroll( |
| 2214 const blink::WebFloatSize& unusedDelta, | 2220 const blink::WebFloatSize& unusedDelta, |
| 2215 const blink::WebFloatSize& accumulatedRootOverScroll, | 2221 const blink::WebFloatSize& accumulatedRootOverScroll, |
| 2216 const blink::WebFloatPoint& position, | 2222 const blink::WebFloatPoint& position, |
| 2217 const blink::WebFloatSize& velocity) { | 2223 const blink::WebFloatSize& velocity) { |
| 2224 if (compositor_deps_->IsElasticOverscrollEnabled()) { | |
| 2225 unused_delta_on_wheel_overscroll_ = | |
| 2226 gfx::Vector2dF(-unusedDelta.width, -unusedDelta.height); | |
| 2227 return; | |
| 2228 } | |
| 2229 | |
| 2218 DidOverscrollParams params; | 2230 DidOverscrollParams params; |
| 2219 // TODO(jdduke): Consider bundling the overscroll with the input event ack to | 2231 // TODO(jdduke): Consider bundling the overscroll with the input event ack to |
| 2220 // save an IPC. | 2232 // save an IPC. |
| 2221 params.accumulated_overscroll = gfx::Vector2dF( | 2233 params.accumulated_overscroll = gfx::Vector2dF( |
| 2222 accumulatedRootOverScroll.width, accumulatedRootOverScroll.height); | 2234 accumulatedRootOverScroll.width, accumulatedRootOverScroll.height); |
| 2223 params.latest_overscroll_delta = | 2235 params.latest_overscroll_delta = |
| 2224 gfx::Vector2dF(unusedDelta.width, unusedDelta.height); | 2236 gfx::Vector2dF(unusedDelta.width, unusedDelta.height); |
| 2225 // TODO(sataya.m): don't negate velocity once http://crbug.com/499743 is | 2237 // TODO(sataya.m): don't negate velocity once http://crbug.com/499743 is |
| 2226 // fixed. | 2238 // fixed. |
| 2227 params.current_fling_velocity = | 2239 params.current_fling_velocity = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2279 } | 2291 } |
| 2280 | 2292 |
| 2281 bool RenderWidget::WillHandleGestureEvent( | 2293 bool RenderWidget::WillHandleGestureEvent( |
| 2282 const blink::WebGestureEvent& event) { | 2294 const blink::WebGestureEvent& event) { |
| 2283 return false; | 2295 return false; |
| 2284 } | 2296 } |
| 2285 | 2297 |
| 2286 void RenderWidget::ObserveWheelEventAndResult( | 2298 void RenderWidget::ObserveWheelEventAndResult( |
| 2287 const blink::WebMouseWheelEvent& wheel_event, | 2299 const blink::WebMouseWheelEvent& wheel_event, |
| 2288 bool event_processed) { | 2300 bool event_processed) { |
| 2289 if (!compositor_deps_->IsElasticOverscrollEnabled()) | 2301 if (!compositor_deps_->IsElasticOverscrollEnabled()) |
|
jdduke (slow)
2015/06/25 23:55:45
With https://codereview.chromium.org/1209043002/,
| |
| 2290 return; | 2302 return; |
| 2291 | 2303 |
| 2292 // Blink does not accurately compute scroll bubbling or overscroll. For now, | |
| 2293 // assume that an unprocessed event was entirely an overscroll, and that a | |
| 2294 // processed event was entirely scroll. | |
| 2295 // TODO(ccameron): Retrieve an accurate scroll result from Blink. | |
| 2296 // http://crbug.com/442859 | |
| 2297 cc::InputHandlerScrollResult scroll_result; | 2304 cc::InputHandlerScrollResult scroll_result; |
| 2298 if (event_processed) { | 2305 scroll_result.did_scroll = event_processed; |
| 2299 scroll_result.did_scroll = true; | 2306 scroll_result.did_overscroll_root = |
| 2300 } else { | 2307 !unused_delta_on_wheel_overscroll_.IsZero(); |
| 2301 scroll_result.did_overscroll_root = true; | 2308 scroll_result.unused_scroll_delta = unused_delta_on_wheel_overscroll_; |
| 2302 scroll_result.unused_scroll_delta = | 2309 unused_delta_on_wheel_overscroll_.set_x(0); |
| 2303 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY); | 2310 unused_delta_on_wheel_overscroll_.set_y(0); |
| 2304 } | |
| 2305 | 2311 |
| 2306 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 2312 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 2307 InputHandlerManager* input_handler_manager = | 2313 InputHandlerManager* input_handler_manager = |
| 2308 render_thread ? render_thread->input_handler_manager() : NULL; | 2314 render_thread ? render_thread->input_handler_manager() : NULL; |
| 2309 if (input_handler_manager) { | 2315 if (input_handler_manager) { |
| 2310 input_handler_manager->ObserveWheelEventAndResultOnMainThread( | 2316 input_handler_manager->ObserveWheelEventAndResultOnMainThread( |
| 2311 routing_id_, wheel_event, scroll_result); | 2317 routing_id_, wheel_event, scroll_result); |
| 2312 } | 2318 } |
| 2313 } | 2319 } |
| 2314 | 2320 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2450 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2456 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2451 video_hole_frames_.AddObserver(frame); | 2457 video_hole_frames_.AddObserver(frame); |
| 2452 } | 2458 } |
| 2453 | 2459 |
| 2454 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2460 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2455 video_hole_frames_.RemoveObserver(frame); | 2461 video_hole_frames_.RemoveObserver(frame); |
| 2456 } | 2462 } |
| 2457 #endif // defined(VIDEO_HOLE) | 2463 #endif // defined(VIDEO_HOLE) |
| 2458 | 2464 |
| 2459 } // namespace content | 2465 } // namespace content |
| OLD | NEW |