| 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/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/logging.h" | 7 #include "base/logging.h" |
| 8 #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" |
| 9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 10 #include "content/port/browser/smooth_scroll_gesture.h" | 11 #include "content/port/browser/smooth_scroll_gesture.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 12 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
| 13 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
| 14 | 15 |
| 15 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 18 #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 Loading... |
| 418 GetViewBounds().origin()); | 419 GetViewBounds().origin()); |
| 419 if (current_display_area_ == display.work_area() && | 420 if (current_display_area_ == display.work_area() && |
| 420 current_device_scale_factor_ == display.device_scale_factor()) | 421 current_device_scale_factor_ == display.device_scale_factor()) |
| 421 return; | 422 return; |
| 422 current_display_area_ = display.work_area(); | 423 current_display_area_ = display.work_area(); |
| 423 current_device_scale_factor_ = display.device_scale_factor(); | 424 current_device_scale_factor_ = display.device_scale_factor(); |
| 424 if (impl) | 425 if (impl) |
| 425 impl->NotifyScreenInfoChanged(); | 426 impl->NotifyScreenInfoChanged(); |
| 426 } | 427 } |
| 427 | 428 |
| 428 class BasicMouseWheelSmoothScrollGesture | |
| 429 : public SmoothScrollGesture { | |
| 430 public: | |
| 431 BasicMouseWheelSmoothScrollGesture(bool scroll_down, int pixels_to_scroll, | |
| 432 int mouse_event_x, int mouse_event_y) | |
| 433 : scroll_down_(scroll_down), | |
| 434 pixels_scrolled_(0), | |
| 435 pixels_to_scroll_(pixels_to_scroll), | |
| 436 mouse_event_x_(mouse_event_x), | |
| 437 mouse_event_y_(mouse_event_y) { } | |
| 438 | |
| 439 virtual bool ForwardInputEvents(base::TimeTicks now, | |
| 440 RenderWidgetHost* host) OVERRIDE { | |
| 441 | |
| 442 if (pixels_scrolled_ >= pixels_to_scroll_) | |
| 443 return false; | |
| 444 | |
| 445 WebKit::WebMouseWheelEvent event; | |
| 446 event.type = WebKit::WebInputEvent::MouseWheel; | |
| 447 // TODO(nduca): Figure out plausible value. | |
| 448 event.deltaY = scroll_down_ ? -10 : 10; | |
| 449 event.wheelTicksY = (scroll_down_ ? 1 : -1); | |
| 450 event.modifiers = 0; | |
| 451 | |
| 452 // TODO(nduca): Figure out plausible x and y values. | |
| 453 event.globalX = 0; | |
| 454 event.globalY = 0; | |
| 455 event.x = mouse_event_x_; | |
| 456 event.y = mouse_event_y_; | |
| 457 event.windowX = event.x; | |
| 458 event.windowY = event.y; | |
| 459 host->ForwardWheelEvent(event); | |
| 460 | |
| 461 pixels_scrolled_ += abs(event.deltaY); | |
| 462 | |
| 463 return true; | |
| 464 } | |
| 465 | |
| 466 private: | |
| 467 virtual ~BasicMouseWheelSmoothScrollGesture() { } | |
| 468 bool scroll_down_; | |
| 469 int pixels_scrolled_; | |
| 470 int pixels_to_scroll_; | |
| 471 int mouse_event_x_; | |
| 472 int mouse_event_y_; | |
| 473 }; | |
| 474 | |
| 475 SmoothScrollGesture* RenderWidgetHostViewBase::CreateSmoothScrollGesture( | 429 SmoothScrollGesture* RenderWidgetHostViewBase::CreateSmoothScrollGesture( |
| 476 bool scroll_down, int pixels_to_scroll, int mouse_event_x, | 430 bool scroll_down, int pixels_to_scroll, int mouse_event_x, |
| 477 int mouse_event_y) { | 431 int mouse_event_y) { |
| 478 return new BasicMouseWheelSmoothScrollGesture(scroll_down, pixels_to_scroll, | 432 return new BasicMouseWheelSmoothScrollGesture(scroll_down, pixels_to_scroll, |
| 479 mouse_event_x, mouse_event_y); | 433 mouse_event_x, mouse_event_y); |
| 480 } | 434 } |
| 481 | 435 |
| 482 void RenderWidgetHostViewBase::ProcessAckedTouchEvent( | 436 void RenderWidgetHostViewBase::ProcessAckedTouchEvent( |
| 483 const WebKit::WebTouchEvent& touch, InputEventAckState ack_result) { | 437 const WebKit::WebTouchEvent& touch, InputEventAckState ack_result) { |
| 484 } | 438 } |
| 485 | 439 |
| 486 } // namespace content | 440 } // namespace content |
| OLD | NEW |