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/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
10 #include "content/port/browser/smooth_scroll_gesture.h" | 10 #include "content/port/browser/smooth_scroll_gesture.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
12 #include "ui/gfx/display.h" | 12 #include "ui/gfx/display.h" |
13 #include "ui/gfx/screen.h" | 13 #include "ui/gfx/screen.h" |
14 | 14 |
15 #if defined(TOOLKIT_GTK) | 15 #if defined(TOOLKIT_GTK) |
16 #include <gdk/gdkx.h> | 16 #include <gdk/gdkx.h> |
17 #include <gtk/gtk.h> | 17 #include <gtk/gtk.h> |
18 | 18 |
19 #include "content/browser/renderer_host/gtk_window_utils.h" | 19 #include "content/browser/renderer_host/gtk_window_utils.h" |
20 #endif | 20 #endif |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 // How long a smooth scroll gesture should run when it is a near scroll. | 24 // How long a smooth scroll gesture should run when it is a near scroll. |
25 static const double kDurationOfNearScrollGestureSec = 0.15; | 25 static const int64 kDurationOfNearScrollGestureMs = 150; |
26 | 26 |
27 // How long a smooth scroll gesture should run when it is a far scroll. | 27 // How long a smooth scroll gesture should run when it is a far scroll. |
28 static const double kDurationOfFarScrollGestureSec = 0.5; | 28 static const int64 kDurationOfFarScrollGestureMs = 500; |
29 | 29 |
30 // static | 30 // static |
31 RenderWidgetHostViewPort* RenderWidgetHostViewPort::FromRWHV( | 31 RenderWidgetHostViewPort* RenderWidgetHostViewPort::FromRWHV( |
32 RenderWidgetHostView* rwhv) { | 32 RenderWidgetHostView* rwhv) { |
33 return static_cast<RenderWidgetHostViewPort*>(rwhv); | 33 return static_cast<RenderWidgetHostViewPort*>(rwhv); |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
37 RenderWidgetHostViewPort* RenderWidgetHostViewPort::CreateViewForWidget( | 37 RenderWidgetHostViewPort* RenderWidgetHostViewPort::CreateViewForWidget( |
38 content::RenderWidgetHost* widget) { | 38 content::RenderWidgetHost* widget) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 class BasicMouseWheelSmoothScrollGesture | 123 class BasicMouseWheelSmoothScrollGesture |
124 : public SmoothScrollGesture { | 124 : public SmoothScrollGesture { |
125 public: | 125 public: |
126 BasicMouseWheelSmoothScrollGesture(bool scroll_down, bool scroll_far) | 126 BasicMouseWheelSmoothScrollGesture(bool scroll_down, bool scroll_far) |
127 : start_time_(base::TimeTicks::HighResNow()), | 127 : start_time_(base::TimeTicks::HighResNow()), |
128 scroll_down_(scroll_down), | 128 scroll_down_(scroll_down), |
129 scroll_far_(scroll_far) { } | 129 scroll_far_(scroll_far) { } |
130 | 130 |
131 virtual bool ForwardInputEvents(base::TimeTicks now, | 131 virtual bool ForwardInputEvents(base::TimeTicks now, |
132 RenderWidgetHost* host) OVERRIDE { | 132 RenderWidgetHost* host) OVERRIDE { |
133 double duration_in_seconds; | 133 double duration_in_ms; |
piman
2012/08/17 19:45:44
here too?
| |
134 if (scroll_far_) | 134 if (scroll_far_) |
135 duration_in_seconds = kDurationOfFarScrollGestureSec; | 135 duration_in_ms = kDurationOfFarScrollGestureMs; |
136 else | 136 else |
137 duration_in_seconds = kDurationOfNearScrollGestureSec; | 137 duration_in_ms = kDurationOfNearScrollGestureMs; |
138 | 138 |
139 if (now - start_time_ > base::TimeDelta::FromSeconds(duration_in_seconds)) | 139 if (now - start_time_ > base::TimeDelta::FromMilliseconds(duration_in_ms)) |
140 return false; | 140 return false; |
141 | 141 |
142 WebKit::WebMouseWheelEvent event; | 142 WebKit::WebMouseWheelEvent event; |
143 event.type = WebKit::WebInputEvent::MouseWheel; | 143 event.type = WebKit::WebInputEvent::MouseWheel; |
144 // TODO(nduca): Figure out plausible value. | 144 // TODO(nduca): Figure out plausible value. |
145 event.deltaY = scroll_down_ ? -10 : 10; | 145 event.deltaY = scroll_down_ ? -10 : 10; |
146 event.wheelTicksY = scroll_down_ ? 1 : -1; | 146 event.wheelTicksY = scroll_down_ ? 1 : -1; |
147 event.modifiers = 0; | 147 event.modifiers = 0; |
148 | 148 |
149 // TODO(nduca): Figure out plausible x and y values. | 149 // TODO(nduca): Figure out plausible x and y values. |
(...skipping 12 matching lines...) Expand all Loading... | |
162 bool scroll_down_; | 162 bool scroll_down_; |
163 bool scroll_far_; | 163 bool scroll_far_; |
164 }; | 164 }; |
165 | 165 |
166 SmoothScrollGesture* RenderWidgetHostViewBase::CreateSmoothScrollGesture( | 166 SmoothScrollGesture* RenderWidgetHostViewBase::CreateSmoothScrollGesture( |
167 bool scroll_down, bool scroll_far) { | 167 bool scroll_down, bool scroll_far) { |
168 return new BasicMouseWheelSmoothScrollGesture(scroll_down, scroll_far); | 168 return new BasicMouseWheelSmoothScrollGesture(scroll_down, scroll_far); |
169 } | 169 } |
170 | 170 |
171 } // namespace content | 171 } // namespace content |
OLD | NEW |