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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 11416283: Attempt to linearize the scroll deltas created in RenderWidgetHostViewBase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/content_browser.gypi » ('j') | 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/browser/renderer_host/render_widget_host_view_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 8 #include "content/browser/accessibility/browser_accessibility_manager.h"
9 #include "content/browser/renderer_host/basic_mouse_wheel_smooth_scroll_gesture. h"
10 #include "content/browser/renderer_host/render_widget_host_impl.h" 10 #include "content/browser/renderer_host/render_widget_host_impl.h"
11 #include "content/port/browser/smooth_scroll_gesture.h" 11 #include "content/port/browser/smooth_scroll_gesture.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
13 #include "ui/gfx/display.h" 13 #include "ui/gfx/display.h"
14 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
15 15
16 #if defined(OS_WIN) 16 #if defined(OS_WIN)
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/message_loop.h" 18 #include "base/message_loop.h"
19 #include "base/win/wrapped_window_proc.h" 19 #include "base/win/wrapped_window_proc.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 GetViewBounds().origin()); 419 GetViewBounds().origin());
420 if (current_display_area_ == display.work_area() && 420 if (current_display_area_ == display.work_area() &&
421 current_device_scale_factor_ == display.device_scale_factor()) 421 current_device_scale_factor_ == display.device_scale_factor())
422 return; 422 return;
423 current_display_area_ = display.work_area(); 423 current_display_area_ = display.work_area();
424 current_device_scale_factor_ = display.device_scale_factor(); 424 current_device_scale_factor_ = display.device_scale_factor();
425 if (impl) 425 if (impl)
426 impl->NotifyScreenInfoChanged(); 426 impl->NotifyScreenInfoChanged();
427 } 427 }
428 428
429 class BasicMouseWheelSmoothScrollGesture
430 : public SmoothScrollGesture {
431 public:
432 BasicMouseWheelSmoothScrollGesture(bool scroll_down, int pixels_to_scroll,
433 int mouse_event_x, int mouse_event_y)
434 : scroll_down_(scroll_down),
435 pixels_scrolled_(0),
436 pixels_to_scroll_(pixels_to_scroll),
437 mouse_event_x_(mouse_event_x),
438 mouse_event_y_(mouse_event_y) { }
439
440 virtual bool ForwardInputEvents(base::TimeTicks now,
441 RenderWidgetHost* host) OVERRIDE {
442
443 if (pixels_scrolled_ >= pixels_to_scroll_)
444 return false;
445
446 WebKit::WebMouseWheelEvent event;
447 event.type = WebKit::WebInputEvent::MouseWheel;
448 // TODO(nduca): Figure out plausible value.
449 event.deltaY = scroll_down_ ? -10 : 10;
450 event.wheelTicksY = (scroll_down_ ? 1 : -1);
451 event.modifiers = 0;
452
453 // TODO(nduca): Figure out plausible x and y values.
454 event.globalX = 0;
455 event.globalY = 0;
456 event.x = mouse_event_x_;
457 event.y = mouse_event_y_;
458 event.windowX = event.x;
459 event.windowY = event.y;
460 host->ForwardWheelEvent(event);
461
462 pixels_scrolled_ += abs(event.deltaY);
463
464 TRACE_COUNTER_ID1("gpu", "smooth_scroll_by_pixels_scrolled", this,
465 pixels_scrolled_);
466
467 return true;
468 }
469
470 private:
471 virtual ~BasicMouseWheelSmoothScrollGesture() { }
472 bool scroll_down_;
473 int pixels_scrolled_;
474 int pixels_to_scroll_;
475 int mouse_event_x_;
476 int mouse_event_y_;
477 };
478
479 SmoothScrollGesture* RenderWidgetHostViewBase::CreateSmoothScrollGesture( 429 SmoothScrollGesture* RenderWidgetHostViewBase::CreateSmoothScrollGesture(
480 bool scroll_down, int pixels_to_scroll, int mouse_event_x, 430 bool scroll_down, int pixels_to_scroll, int mouse_event_x,
481 int mouse_event_y) { 431 int mouse_event_y) {
482 return new BasicMouseWheelSmoothScrollGesture(scroll_down, pixels_to_scroll, 432 return new BasicMouseWheelSmoothScrollGesture(scroll_down, pixels_to_scroll,
483 mouse_event_x, mouse_event_y); 433 mouse_event_x, mouse_event_y);
484 } 434 }
485 435
486 void RenderWidgetHostViewBase::ProcessAckedTouchEvent( 436 void RenderWidgetHostViewBase::ProcessAckedTouchEvent(
487 const WebKit::WebTouchEvent& touch, InputEventAckState ack_result) { 437 const WebKit::WebTouchEvent& touch, InputEventAckState ack_result) {
488 } 438 }
489 439
490 } // namespace content 440 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698