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_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <InputScope.h> | 7 #include <InputScope.h> |
8 #include <wtsapi32.h> | 8 #include <wtsapi32.h> |
9 #pragma comment(lib, "wtsapi32.lib") | 9 #pragma comment(lib, "wtsapi32.lib") |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "ui/gfx/sequential_id_generator.h" | 76 #include "ui/gfx/sequential_id_generator.h" |
77 #include "ui/gfx/text_elider.h" | 77 #include "ui/gfx/text_elider.h" |
78 #include "ui/gfx/win/dpi.h" | 78 #include "ui/gfx/win/dpi.h" |
79 #include "ui/gfx/win/hwnd_util.h" | 79 #include "ui/gfx/win/hwnd_util.h" |
80 #include "webkit/common/cursors/webcursor.h" | 80 #include "webkit/common/cursors/webcursor.h" |
81 #include "win8/util/win8_util.h" | 81 #include "win8/util/win8_util.h" |
82 | 82 |
83 using base::TimeDelta; | 83 using base::TimeDelta; |
84 using base::TimeTicks; | 84 using base::TimeTicks; |
85 using ui::ViewProp; | 85 using ui::ViewProp; |
86 using WebKit::WebInputEvent; | 86 using blink::WebInputEvent; |
87 using WebKit::WebMouseEvent; | 87 using blink::WebMouseEvent; |
88 using WebKit::WebTextDirection; | 88 using blink::WebTextDirection; |
89 | 89 |
90 namespace content { | 90 namespace content { |
91 namespace { | 91 namespace { |
92 | 92 |
93 // Tooltips will wrap after this width. Yes, wrap. Imagine that! | 93 // Tooltips will wrap after this width. Yes, wrap. Imagine that! |
94 const int kTooltipMaxWidthPixels = 300; | 94 const int kTooltipMaxWidthPixels = 300; |
95 | 95 |
96 // Maximum number of characters we allow in a tooltip. | 96 // Maximum number of characters we allow in a tooltip. |
97 const int kMaxTooltipLength = 1024; | 97 const int kMaxTooltipLength = 1024; |
98 | 98 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } else { | 195 } else { |
196 delta->x = gi.ptsLocation.x - last_pt.x; | 196 delta->x = gi.ptsLocation.x - last_pt.x; |
197 delta->y = gi.ptsLocation.y - last_pt.y; | 197 delta->y = gi.ptsLocation.y - last_pt.y; |
198 } | 198 } |
199 last_pt.x = gi.ptsLocation.x; | 199 last_pt.x = gi.ptsLocation.x; |
200 last_pt.y = gi.ptsLocation.y; | 200 last_pt.y = gi.ptsLocation.y; |
201 *start = start_pt; | 201 *start = start_pt; |
202 return true; | 202 return true; |
203 } | 203 } |
204 | 204 |
205 WebKit::WebMouseWheelEvent MakeFakeScrollWheelEvent(HWND hwnd, | 205 blink::WebMouseWheelEvent MakeFakeScrollWheelEvent(HWND hwnd, |
206 POINT start, | 206 POINT start, |
207 POINT delta) { | 207 POINT delta) { |
208 WebKit::WebMouseWheelEvent result; | 208 blink::WebMouseWheelEvent result; |
209 result.type = WebInputEvent::MouseWheel; | 209 result.type = WebInputEvent::MouseWheel; |
210 result.timeStampSeconds = ::GetMessageTime() / 1000.0; | 210 result.timeStampSeconds = ::GetMessageTime() / 1000.0; |
211 result.button = WebMouseEvent::ButtonNone; | 211 result.button = WebMouseEvent::ButtonNone; |
212 result.globalX = start.x; | 212 result.globalX = start.x; |
213 result.globalY = start.y; | 213 result.globalY = start.y; |
214 // Map to window coordinates. | 214 // Map to window coordinates. |
215 POINT client_point = { result.globalX, result.globalY }; | 215 POINT client_point = { result.globalX, result.globalY }; |
216 MapWindowPoints(0, hwnd, &client_point, 1); | 216 MapWindowPoints(0, hwnd, &client_point, 1); |
217 result.x = client_point.x; | 217 result.x = client_point.x; |
218 result.y = client_point.y; | 218 result.y = client_point.y; |
(...skipping 10 matching lines...) Expand all Loading... |
229 static const int kTouchMask = 0x7; | 229 static const int kTouchMask = 0x7; |
230 | 230 |
231 inline int GetTouchType(const TOUCHINPUT& point) { | 231 inline int GetTouchType(const TOUCHINPUT& point) { |
232 return point.dwFlags & kTouchMask; | 232 return point.dwFlags & kTouchMask; |
233 } | 233 } |
234 | 234 |
235 inline void SetTouchType(TOUCHINPUT* point, int type) { | 235 inline void SetTouchType(TOUCHINPUT* point, int type) { |
236 point->dwFlags = (point->dwFlags & kTouchMask) | type; | 236 point->dwFlags = (point->dwFlags & kTouchMask) | type; |
237 } | 237 } |
238 | 238 |
239 ui::EventType ConvertToUIEvent(WebKit::WebTouchPoint::State t) { | 239 ui::EventType ConvertToUIEvent(blink::WebTouchPoint::State t) { |
240 switch (t) { | 240 switch (t) { |
241 case WebKit::WebTouchPoint::StatePressed: | 241 case blink::WebTouchPoint::StatePressed: |
242 return ui::ET_TOUCH_PRESSED; | 242 return ui::ET_TOUCH_PRESSED; |
243 case WebKit::WebTouchPoint::StateMoved: | 243 case blink::WebTouchPoint::StateMoved: |
244 return ui::ET_TOUCH_MOVED; | 244 return ui::ET_TOUCH_MOVED; |
245 case WebKit::WebTouchPoint::StateStationary: | 245 case blink::WebTouchPoint::StateStationary: |
246 return ui::ET_TOUCH_STATIONARY; | 246 return ui::ET_TOUCH_STATIONARY; |
247 case WebKit::WebTouchPoint::StateReleased: | 247 case blink::WebTouchPoint::StateReleased: |
248 return ui::ET_TOUCH_RELEASED; | 248 return ui::ET_TOUCH_RELEASED; |
249 case WebKit::WebTouchPoint::StateCancelled: | 249 case blink::WebTouchPoint::StateCancelled: |
250 return ui::ET_TOUCH_CANCELLED; | 250 return ui::ET_TOUCH_CANCELLED; |
251 default: | 251 default: |
252 DCHECK(false) << "Unexpected ui type. " << t; | 252 DCHECK(false) << "Unexpected ui type. " << t; |
253 return ui::ET_UNKNOWN; | 253 return ui::ET_UNKNOWN; |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
257 // Creates a WebGestureEvent corresponding to the given |gesture| | 257 // Creates a WebGestureEvent corresponding to the given |gesture| |
258 WebKit::WebGestureEvent CreateWebGestureEvent(HWND hwnd, | 258 blink::WebGestureEvent CreateWebGestureEvent(HWND hwnd, |
259 const ui::GestureEvent& gesture) { | 259 const ui::GestureEvent& gesture) { |
260 WebKit::WebGestureEvent gesture_event = | 260 blink::WebGestureEvent gesture_event = |
261 MakeWebGestureEventFromUIEvent(gesture); | 261 MakeWebGestureEventFromUIEvent(gesture); |
262 | 262 |
263 POINT client_point = gesture.location().ToPOINT(); | 263 POINT client_point = gesture.location().ToPOINT(); |
264 POINT screen_point = gesture.location().ToPOINT(); | 264 POINT screen_point = gesture.location().ToPOINT(); |
265 MapWindowPoints(hwnd, HWND_DESKTOP, &screen_point, 1); | 265 MapWindowPoints(hwnd, HWND_DESKTOP, &screen_point, 1); |
266 | 266 |
267 gesture_event.x = client_point.x; | 267 gesture_event.x = client_point.x; |
268 gesture_event.y = client_point.y; | 268 gesture_event.y = client_point.y; |
269 gesture_event.globalX = screen_point.x; | 269 gesture_event.globalX = screen_point.x; |
270 gesture_event.globalY = screen_point.y; | 270 gesture_event.globalY = screen_point.y; |
271 | 271 |
272 return gesture_event; | 272 return gesture_event; |
273 } | 273 } |
274 | 274 |
275 WebKit::WebGestureEvent CreateFlingCancelEvent(double time_stamp) { | 275 blink::WebGestureEvent CreateFlingCancelEvent(double time_stamp) { |
276 WebKit::WebGestureEvent gesture_event; | 276 blink::WebGestureEvent gesture_event; |
277 gesture_event.timeStampSeconds = time_stamp; | 277 gesture_event.timeStampSeconds = time_stamp; |
278 gesture_event.type = WebKit::WebGestureEvent::GestureFlingCancel; | 278 gesture_event.type = blink::WebGestureEvent::GestureFlingCancel; |
279 gesture_event.sourceDevice = WebKit::WebGestureEvent::Touchscreen; | 279 gesture_event.sourceDevice = blink::WebGestureEvent::Touchscreen; |
280 return gesture_event; | 280 return gesture_event; |
281 } | 281 } |
282 | 282 |
283 class TouchEventFromWebTouchPoint : public ui::TouchEvent { | 283 class TouchEventFromWebTouchPoint : public ui::TouchEvent { |
284 public: | 284 public: |
285 TouchEventFromWebTouchPoint(const WebKit::WebTouchPoint& touch_point, | 285 TouchEventFromWebTouchPoint(const blink::WebTouchPoint& touch_point, |
286 base::TimeDelta& timestamp) | 286 base::TimeDelta& timestamp) |
287 : ui::TouchEvent(ConvertToUIEvent(touch_point.state), | 287 : ui::TouchEvent(ConvertToUIEvent(touch_point.state), |
288 touch_point.position, | 288 touch_point.position, |
289 touch_point.id, | 289 touch_point.id, |
290 timestamp) { | 290 timestamp) { |
291 set_radius(touch_point.radiusX, touch_point.radiusY); | 291 set_radius(touch_point.radiusX, touch_point.radiusY); |
292 set_rotation_angle(touch_point.rotationAngle); | 292 set_rotation_angle(touch_point.rotationAngle); |
293 set_force(touch_point.force); | 293 set_force(touch_point.force); |
294 set_flags(ui::GetModifiersFromKeyState()); | 294 set_flags(ui::GetModifiersFromKeyState()); |
295 } | 295 } |
296 | 296 |
297 virtual ~TouchEventFromWebTouchPoint() {} | 297 virtual ~TouchEventFromWebTouchPoint() {} |
298 | 298 |
299 private: | 299 private: |
300 DISALLOW_COPY_AND_ASSIGN(TouchEventFromWebTouchPoint); | 300 DISALLOW_COPY_AND_ASSIGN(TouchEventFromWebTouchPoint); |
301 }; | 301 }; |
302 | 302 |
303 bool ShouldSendPinchGesture() { | 303 bool ShouldSendPinchGesture() { |
304 static bool pinch_allowed = | 304 static bool pinch_allowed = |
305 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); | 305 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); |
306 return pinch_allowed; | 306 return pinch_allowed; |
307 } | 307 } |
308 | 308 |
309 void GetScreenInfoForWindow(gfx::NativeViewId id, | 309 void GetScreenInfoForWindow(gfx::NativeViewId id, |
310 WebKit::WebScreenInfo* results) { | 310 blink::WebScreenInfo* results) { |
311 HWND window = gfx::NativeViewFromId(id); | 311 HWND window = gfx::NativeViewFromId(id); |
312 | 312 |
313 HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); | 313 HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); |
314 | 314 |
315 MONITORINFOEX monitor_info; | 315 MONITORINFOEX monitor_info; |
316 monitor_info.cbSize = sizeof(MONITORINFOEX); | 316 monitor_info.cbSize = sizeof(MONITORINFOEX); |
317 if (!base::win::GetMonitorInfoWrapper(monitor, &monitor_info)) | 317 if (!base::win::GetMonitorInfoWrapper(monitor, &monitor_info)) |
318 return; | 318 return; |
319 | 319 |
320 DEVMODE dev_mode; | 320 DEVMODE dev_mode; |
321 dev_mode.dmSize = sizeof(dev_mode); | 321 dev_mode.dmSize = sizeof(dev_mode); |
322 dev_mode.dmDriverExtra = 0; | 322 dev_mode.dmDriverExtra = 0; |
323 EnumDisplaySettings(monitor_info.szDevice, ENUM_CURRENT_SETTINGS, &dev_mode); | 323 EnumDisplaySettings(monitor_info.szDevice, ENUM_CURRENT_SETTINGS, &dev_mode); |
324 | 324 |
325 WebKit::WebScreenInfo screen_info; | 325 blink::WebScreenInfo screen_info; |
326 screen_info.depth = dev_mode.dmBitsPerPel; | 326 screen_info.depth = dev_mode.dmBitsPerPel; |
327 screen_info.depthPerComponent = 8; | 327 screen_info.depthPerComponent = 8; |
328 screen_info.deviceScaleFactor = gfx::win::GetDeviceScaleFactor(); | 328 screen_info.deviceScaleFactor = gfx::win::GetDeviceScaleFactor(); |
329 screen_info.isMonochrome = dev_mode.dmColor == DMCOLOR_MONOCHROME; | 329 screen_info.isMonochrome = dev_mode.dmColor == DMCOLOR_MONOCHROME; |
330 screen_info.rect = gfx::Rect(monitor_info.rcMonitor); | 330 screen_info.rect = gfx::Rect(monitor_info.rcMonitor); |
331 screen_info.availableRect = gfx::Rect(monitor_info.rcWork); | 331 screen_info.availableRect = gfx::Rect(monitor_info.rcWork); |
332 | 332 |
333 *results = screen_info; | 333 *results = screen_info; |
334 } | 334 } |
335 | 335 |
336 } // namespace | 336 } // namespace |
337 | 337 |
338 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; | 338 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; |
339 | 339 |
340 // Wrapper for maintaining touchstate associated with a WebTouchEvent. | 340 // Wrapper for maintaining touchstate associated with a WebTouchEvent. |
341 class WebTouchState { | 341 class WebTouchState { |
342 public: | 342 public: |
343 explicit WebTouchState(const RenderWidgetHostViewWin* window); | 343 explicit WebTouchState(const RenderWidgetHostViewWin* window); |
344 | 344 |
345 // Updates the current touchpoint state with the supplied touches. | 345 // Updates the current touchpoint state with the supplied touches. |
346 // Touches will be consumed only if they are of the same type (e.g. down, | 346 // Touches will be consumed only if they are of the same type (e.g. down, |
347 // up, move). Returns the number of consumed touches. | 347 // up, move). Returns the number of consumed touches. |
348 size_t UpdateTouchPoints(TOUCHINPUT* points, size_t count); | 348 size_t UpdateTouchPoints(TOUCHINPUT* points, size_t count); |
349 | 349 |
350 // Marks all active touchpoints as released. | 350 // Marks all active touchpoints as released. |
351 bool ReleaseTouchPoints(); | 351 bool ReleaseTouchPoints(); |
352 | 352 |
353 // The contained WebTouchEvent. | 353 // The contained WebTouchEvent. |
354 const WebKit::WebTouchEvent& touch_event() { return touch_event_; } | 354 const blink::WebTouchEvent& touch_event() { return touch_event_; } |
355 | 355 |
356 // Returns if any touches are modified in the event. | 356 // Returns if any touches are modified in the event. |
357 bool is_changed() { return touch_event_.changedTouchesLength != 0; } | 357 bool is_changed() { return touch_event_.changedTouchesLength != 0; } |
358 | 358 |
359 private: | 359 private: |
360 // Adds a touch point or returns NULL if there's not enough space. | 360 // Adds a touch point or returns NULL if there's not enough space. |
361 WebKit::WebTouchPoint* AddTouchPoint(TOUCHINPUT* touch_input); | 361 blink::WebTouchPoint* AddTouchPoint(TOUCHINPUT* touch_input); |
362 | 362 |
363 // Copy details from a TOUCHINPUT to an existing WebTouchPoint, returning | 363 // Copy details from a TOUCHINPUT to an existing WebTouchPoint, returning |
364 // true if the resulting point is a stationary move. | 364 // true if the resulting point is a stationary move. |
365 bool UpdateTouchPoint(WebKit::WebTouchPoint* touch_point, | 365 bool UpdateTouchPoint(blink::WebTouchPoint* touch_point, |
366 TOUCHINPUT* touch_input); | 366 TOUCHINPUT* touch_input); |
367 | 367 |
368 // Find (or create) a mapping for _os_touch_id_. | 368 // Find (or create) a mapping for _os_touch_id_. |
369 unsigned int GetMappedTouch(unsigned int os_touch_id); | 369 unsigned int GetMappedTouch(unsigned int os_touch_id); |
370 | 370 |
371 // Remove any mappings that are no longer in use. | 371 // Remove any mappings that are no longer in use. |
372 void RemoveExpiredMappings(); | 372 void RemoveExpiredMappings(); |
373 | 373 |
374 WebKit::WebTouchEvent touch_event_; | 374 blink::WebTouchEvent touch_event_; |
375 const RenderWidgetHostViewWin* const window_; | 375 const RenderWidgetHostViewWin* const window_; |
376 | 376 |
377 ui::SequentialIDGenerator id_generator_; | 377 ui::SequentialIDGenerator id_generator_; |
378 | 378 |
379 DISALLOW_COPY_AND_ASSIGN(WebTouchState); | 379 DISALLOW_COPY_AND_ASSIGN(WebTouchState); |
380 }; | 380 }; |
381 | 381 |
382 typedef void (*MetroSetFrameWindow)(HWND window); | 382 typedef void (*MetroSetFrameWindow)(HWND window); |
383 typedef void (*MetroCloseFrameWindow)(HWND window); | 383 typedef void (*MetroCloseFrameWindow)(HWND window); |
384 | 384 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 FROM_HERE, | 588 FROM_HERE, |
589 base::Bind(base::IgnoreResult(&::DestroyWindow), | 589 base::Bind(base::IgnoreResult(&::DestroyWindow), |
590 compositor_host_window_), | 590 compositor_host_window_), |
591 base::TimeDelta::FromMilliseconds(kDestroyCompositorHostWindowDelay)); | 591 base::TimeDelta::FromMilliseconds(kDestroyCompositorHostWindowDelay)); |
592 | 592 |
593 compositor_host_window_ = NULL; | 593 compositor_host_window_ = NULL; |
594 } | 594 } |
595 | 595 |
596 bool RenderWidgetHostViewWin::IsActivatable() const { | 596 bool RenderWidgetHostViewWin::IsActivatable() const { |
597 // Popups should not be activated. | 597 // Popups should not be activated. |
598 return popup_type_ == WebKit::WebPopupTypeNone; | 598 return popup_type_ == blink::WebPopupTypeNone; |
599 } | 599 } |
600 | 600 |
601 void RenderWidgetHostViewWin::Focus() { | 601 void RenderWidgetHostViewWin::Focus() { |
602 if (IsWindow()) | 602 if (IsWindow()) |
603 SetFocus(); | 603 SetFocus(); |
604 } | 604 } |
605 | 605 |
606 void RenderWidgetHostViewWin::Blur() { | 606 void RenderWidgetHostViewWin::Blur() { |
607 NOTREACHED(); | 607 NOTREACHED(); |
608 } | 608 } |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 ui::GestureEvent* event) { | 955 ui::GestureEvent* event) { |
956 ForwardGestureEventToRenderer(event); | 956 ForwardGestureEventToRenderer(event); |
957 } | 957 } |
958 | 958 |
959 void RenderWidgetHostViewWin::DispatchCancelTouchEvent( | 959 void RenderWidgetHostViewWin::DispatchCancelTouchEvent( |
960 ui::TouchEvent* event) { | 960 ui::TouchEvent* event) { |
961 if (!render_widget_host_ || !touch_events_enabled_ || | 961 if (!render_widget_host_ || !touch_events_enabled_ || |
962 !render_widget_host_->ShouldForwardTouchEvent()) { | 962 !render_widget_host_->ShouldForwardTouchEvent()) { |
963 return; | 963 return; |
964 } | 964 } |
965 DCHECK(event->type() == WebKit::WebInputEvent::TouchCancel); | 965 DCHECK(event->type() == blink::WebInputEvent::TouchCancel); |
966 WebKit::WebTouchEvent cancel_event; | 966 blink::WebTouchEvent cancel_event; |
967 cancel_event.type = WebKit::WebInputEvent::TouchCancel; | 967 cancel_event.type = blink::WebInputEvent::TouchCancel; |
968 cancel_event.timeStampSeconds = event->time_stamp().InSecondsF(); | 968 cancel_event.timeStampSeconds = event->time_stamp().InSecondsF(); |
969 render_widget_host_->ForwardTouchEventWithLatencyInfo( | 969 render_widget_host_->ForwardTouchEventWithLatencyInfo( |
970 cancel_event, *event->latency()); | 970 cancel_event, *event->latency()); |
971 } | 971 } |
972 | 972 |
973 void RenderWidgetHostViewWin::SetHasHorizontalScrollbar( | 973 void RenderWidgetHostViewWin::SetHasHorizontalScrollbar( |
974 bool has_horizontal_scrollbar) { | 974 bool has_horizontal_scrollbar) { |
975 } | 975 } |
976 | 976 |
977 void RenderWidgetHostViewWin::SetScrollOffsetPinning( | 977 void RenderWidgetHostViewWin::SetScrollOffsetPinning( |
978 bool is_pinned_to_left, bool is_pinned_to_right) { | 978 bool is_pinned_to_left, bool is_pinned_to_right) { |
979 } | 979 } |
980 | 980 |
981 void RenderWidgetHostViewWin::SetCompositionText( | 981 void RenderWidgetHostViewWin::SetCompositionText( |
982 const ui::CompositionText& composition) { | 982 const ui::CompositionText& composition) { |
983 if (!base::win::IsTSFAwareRequired()) { | 983 if (!base::win::IsTSFAwareRequired()) { |
984 NOTREACHED(); | 984 NOTREACHED(); |
985 return; | 985 return; |
986 } | 986 } |
987 if (!render_widget_host_) | 987 if (!render_widget_host_) |
988 return; | 988 return; |
989 // ui::CompositionUnderline should be identical to | 989 // ui::CompositionUnderline should be identical to |
990 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. | 990 // blink::WebCompositionUnderline, so that we can do reinterpret_cast safely. |
991 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == | 991 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == |
992 sizeof(WebKit::WebCompositionUnderline), | 992 sizeof(blink::WebCompositionUnderline), |
993 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); | 993 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); |
994 const std::vector<WebKit::WebCompositionUnderline>& underlines = | 994 const std::vector<blink::WebCompositionUnderline>& underlines = |
995 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( | 995 reinterpret_cast<const std::vector<blink::WebCompositionUnderline>&>( |
996 composition.underlines); | 996 composition.underlines); |
997 render_widget_host_->ImeSetComposition(composition.text, underlines, | 997 render_widget_host_->ImeSetComposition(composition.text, underlines, |
998 composition.selection.end(), | 998 composition.selection.end(), |
999 composition.selection.end()); | 999 composition.selection.end()); |
1000 } | 1000 } |
1001 | 1001 |
1002 void RenderWidgetHostViewWin::ConfirmCompositionText() { | 1002 void RenderWidgetHostViewWin::ConfirmCompositionText() { |
1003 if (!base::win::IsTSFAwareRequired()) { | 1003 if (!base::win::IsTSFAwareRequired()) { |
1004 NOTREACHED(); | 1004 NOTREACHED(); |
1005 return; | 1005 return; |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 LRESULT RenderWidgetHostViewWin::OnImeComposition( | 1657 LRESULT RenderWidgetHostViewWin::OnImeComposition( |
1658 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1658 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
1659 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeComposition"); | 1659 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeComposition"); |
1660 if (!render_widget_host_) | 1660 if (!render_widget_host_) |
1661 return 0; | 1661 return 0; |
1662 | 1662 |
1663 // At first, update the position of the IME window. | 1663 // At first, update the position of the IME window. |
1664 imm32_manager_->UpdateImeWindow(m_hWnd); | 1664 imm32_manager_->UpdateImeWindow(m_hWnd); |
1665 | 1665 |
1666 // ui::CompositionUnderline should be identical to | 1666 // ui::CompositionUnderline should be identical to |
1667 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. | 1667 // blink::WebCompositionUnderline, so that we can do reinterpret_cast safely. |
1668 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == | 1668 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == |
1669 sizeof(WebKit::WebCompositionUnderline), | 1669 sizeof(blink::WebCompositionUnderline), |
1670 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); | 1670 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); |
1671 | 1671 |
1672 // Retrieve the result string and its attributes of the ongoing composition | 1672 // Retrieve the result string and its attributes of the ongoing composition |
1673 // and send it to a renderer process. | 1673 // and send it to a renderer process. |
1674 ui::CompositionText composition; | 1674 ui::CompositionText composition; |
1675 if (imm32_manager_->GetResult(m_hWnd, lparam, &composition.text)) { | 1675 if (imm32_manager_->GetResult(m_hWnd, lparam, &composition.text)) { |
1676 render_widget_host_->ImeConfirmComposition( | 1676 render_widget_host_->ImeConfirmComposition( |
1677 composition.text, gfx::Range::InvalidRange(), false); | 1677 composition.text, gfx::Range::InvalidRange(), false); |
1678 imm32_manager_->ResetComposition(m_hWnd); | 1678 imm32_manager_->ResetComposition(m_hWnd); |
1679 // Fall though and try reading the composition string. | 1679 // Fall though and try reading the composition string. |
1680 // Japanese IMEs send a message containing both GCS_RESULTSTR and | 1680 // Japanese IMEs send a message containing both GCS_RESULTSTR and |
1681 // GCS_COMPSTR, which means an ongoing composition has been finished | 1681 // GCS_COMPSTR, which means an ongoing composition has been finished |
1682 // by the start of another composition. | 1682 // by the start of another composition. |
1683 } | 1683 } |
1684 // Retrieve the composition string and its attributes of the ongoing | 1684 // Retrieve the composition string and its attributes of the ongoing |
1685 // composition and send it to a renderer process. | 1685 // composition and send it to a renderer process. |
1686 if (imm32_manager_->GetComposition(m_hWnd, lparam, &composition)) { | 1686 if (imm32_manager_->GetComposition(m_hWnd, lparam, &composition)) { |
1687 // TODO(suzhe): due to a bug of webkit, we can't use selection range with | 1687 // TODO(suzhe): due to a bug of webkit, we can't use selection range with |
1688 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 | 1688 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 |
1689 composition.selection = gfx::Range(composition.selection.end()); | 1689 composition.selection = gfx::Range(composition.selection.end()); |
1690 | 1690 |
1691 // TODO(suzhe): convert both renderer_host and renderer to use | 1691 // TODO(suzhe): convert both renderer_host and renderer to use |
1692 // ui::CompositionText. | 1692 // ui::CompositionText. |
1693 const std::vector<WebKit::WebCompositionUnderline>& underlines = | 1693 const std::vector<blink::WebCompositionUnderline>& underlines = |
1694 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( | 1694 reinterpret_cast<const std::vector<blink::WebCompositionUnderline>&>( |
1695 composition.underlines); | 1695 composition.underlines); |
1696 render_widget_host_->ImeSetComposition( | 1696 render_widget_host_->ImeSetComposition( |
1697 composition.text, underlines, | 1697 composition.text, underlines, |
1698 composition.selection.start(), composition.selection.end()); | 1698 composition.selection.start(), composition.selection.end()); |
1699 } | 1699 } |
1700 // We have to prevent WTL from calling ::DefWindowProc() because we do not | 1700 // We have to prevent WTL from calling ::DefWindowProc() because we do not |
1701 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. | 1701 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. |
1702 handled = TRUE; | 1702 handled = TRUE; |
1703 if (!can_compose_inline_) { | 1703 if (!can_compose_inline_) { |
1704 // When the focus is on an element that does not draw composition by itself | 1704 // When the focus is on an element that does not draw composition by itself |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 // Bug 9718: http://crbug.com/9718 To investigate IE and notepad, this | 1921 // Bug 9718: http://crbug.com/9718 To investigate IE and notepad, this |
1922 // shortcut is enabled only on a PC having RTL keyboard layouts installed. | 1922 // shortcut is enabled only on a PC having RTL keyboard layouts installed. |
1923 // We should emulate them. | 1923 // We should emulate them. |
1924 if (ui::IMM32Manager::IsRTLKeyboardLayoutInstalled()) { | 1924 if (ui::IMM32Manager::IsRTLKeyboardLayoutInstalled()) { |
1925 if (message == WM_KEYDOWN) { | 1925 if (message == WM_KEYDOWN) { |
1926 if (wparam == VK_SHIFT) { | 1926 if (wparam == VK_SHIFT) { |
1927 base::i18n::TextDirection dir; | 1927 base::i18n::TextDirection dir; |
1928 if (ui::IMM32Manager::IsCtrlShiftPressed(&dir)) { | 1928 if (ui::IMM32Manager::IsCtrlShiftPressed(&dir)) { |
1929 render_widget_host_->UpdateTextDirection( | 1929 render_widget_host_->UpdateTextDirection( |
1930 dir == base::i18n::RIGHT_TO_LEFT ? | 1930 dir == base::i18n::RIGHT_TO_LEFT ? |
1931 WebKit::WebTextDirectionRightToLeft : | 1931 blink::WebTextDirectionRightToLeft : |
1932 WebKit::WebTextDirectionLeftToRight); | 1932 blink::WebTextDirectionLeftToRight); |
1933 } | 1933 } |
1934 } else if (wparam != VK_CONTROL) { | 1934 } else if (wparam != VK_CONTROL) { |
1935 // Bug 9762: http://crbug.com/9762 A user pressed a key except shift | 1935 // Bug 9762: http://crbug.com/9762 A user pressed a key except shift |
1936 // and control keys. | 1936 // and control keys. |
1937 // When a user presses a key while he/she holds control and shift keys, | 1937 // When a user presses a key while he/she holds control and shift keys, |
1938 // we cancel sending an IPC message in NotifyTextDirection() below and | 1938 // we cancel sending an IPC message in NotifyTextDirection() below and |
1939 // ignore succeeding UpdateTextDirection() calls while we call | 1939 // ignore succeeding UpdateTextDirection() calls while we call |
1940 // NotifyTextDirection(). | 1940 // NotifyTextDirection(). |
1941 // To cancel it, this call set a flag that prevents sending an IPC | 1941 // To cancel it, this call set a flag that prevents sending an IPC |
1942 // message in NotifyTextDirection() only if we are going to send it. | 1942 // message in NotifyTextDirection() only if we are going to send it. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 // dismiss them. | 1999 // dismiss them. |
2000 if (m_hWnd != GetForegroundWindow()) { | 2000 if (m_hWnd != GetForegroundWindow()) { |
2001 HWND toplevel_hwnd = ::GetAncestor(m_hWnd, GA_ROOT); | 2001 HWND toplevel_hwnd = ::GetAncestor(m_hWnd, GA_ROOT); |
2002 EnumThreadWindows( | 2002 EnumThreadWindows( |
2003 GetCurrentThreadId(), | 2003 GetCurrentThreadId(), |
2004 DismissOwnedPopups, | 2004 DismissOwnedPopups, |
2005 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2005 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
2006 } | 2006 } |
2007 | 2007 |
2008 if (render_widget_host_) { | 2008 if (render_widget_host_) { |
2009 WebKit::WebMouseWheelEvent wheel_event = | 2009 blink::WebMouseWheelEvent wheel_event = |
2010 WebMouseWheelEventBuilder::Build(m_hWnd, message, wparam, lparam); | 2010 WebMouseWheelEventBuilder::Build(m_hWnd, message, wparam, lparam); |
2011 float scale = gfx::win::GetDeviceScaleFactor(); | 2011 float scale = gfx::win::GetDeviceScaleFactor(); |
2012 wheel_event.x /= scale; | 2012 wheel_event.x /= scale; |
2013 wheel_event.y /= scale; | 2013 wheel_event.y /= scale; |
2014 wheel_event.deltaX /= scale; | 2014 wheel_event.deltaX /= scale; |
2015 wheel_event.deltaY /= scale; | 2015 wheel_event.deltaY /= scale; |
2016 | 2016 |
2017 render_widget_host_->ForwardWheelEvent(wheel_event); | 2017 render_widget_host_->ForwardWheelEvent(wheel_event); |
2018 } | 2018 } |
2019 handled = TRUE; | 2019 handled = TRUE; |
2020 return 0; | 2020 return 0; |
2021 } | 2021 } |
2022 | 2022 |
2023 WebTouchState::WebTouchState(const RenderWidgetHostViewWin* window) | 2023 WebTouchState::WebTouchState(const RenderWidgetHostViewWin* window) |
2024 : window_(window), | 2024 : window_(window), |
2025 id_generator_(0) { | 2025 id_generator_(0) { |
2026 } | 2026 } |
2027 | 2027 |
2028 size_t WebTouchState::UpdateTouchPoints( | 2028 size_t WebTouchState::UpdateTouchPoints( |
2029 TOUCHINPUT* points, size_t count) { | 2029 TOUCHINPUT* points, size_t count) { |
2030 // First we reset all touch event state. This involves removing any released | 2030 // First we reset all touch event state. This involves removing any released |
2031 // touchpoints and marking the rest as stationary. After that we go through | 2031 // touchpoints and marking the rest as stationary. After that we go through |
2032 // and alter/add any touchpoints (from the touch input buffer) that we can | 2032 // and alter/add any touchpoints (from the touch input buffer) that we can |
2033 // coalesce into a single message. The return value is the number of consumed | 2033 // coalesce into a single message. The return value is the number of consumed |
2034 // input message. | 2034 // input message. |
2035 WebKit::WebTouchPoint* point = touch_event_.touches; | 2035 blink::WebTouchPoint* point = touch_event_.touches; |
2036 WebKit::WebTouchPoint* end = point + touch_event_.touchesLength; | 2036 blink::WebTouchPoint* end = point + touch_event_.touchesLength; |
2037 while (point < end) { | 2037 while (point < end) { |
2038 if (point->state == WebKit::WebTouchPoint::StateReleased) { | 2038 if (point->state == blink::WebTouchPoint::StateReleased) { |
2039 *point = *(--end); | 2039 *point = *(--end); |
2040 --touch_event_.touchesLength; | 2040 --touch_event_.touchesLength; |
2041 } else { | 2041 } else { |
2042 point->state = WebKit::WebTouchPoint::StateStationary; | 2042 point->state = blink::WebTouchPoint::StateStationary; |
2043 point++; | 2043 point++; |
2044 } | 2044 } |
2045 } | 2045 } |
2046 touch_event_.changedTouchesLength = 0; | 2046 touch_event_.changedTouchesLength = 0; |
2047 touch_event_.modifiers = content::EventFlagsToWebEventModifiers( | 2047 touch_event_.modifiers = content::EventFlagsToWebEventModifiers( |
2048 ui::GetModifiersFromKeyState()); | 2048 ui::GetModifiersFromKeyState()); |
2049 | 2049 |
2050 // Consume all events of the same type and add them to the changed list. | 2050 // Consume all events of the same type and add them to the changed list. |
2051 int last_type = 0; | 2051 int last_type = 0; |
2052 for (size_t i = 0; i < count; ++i) { | 2052 for (size_t i = 0; i < count; ++i) { |
2053 unsigned int mapped_id = GetMappedTouch(points[i].dwID); | 2053 unsigned int mapped_id = GetMappedTouch(points[i].dwID); |
2054 | 2054 |
2055 WebKit::WebTouchPoint* point = NULL; | 2055 blink::WebTouchPoint* point = NULL; |
2056 for (unsigned j = 0; j < touch_event_.touchesLength; ++j) { | 2056 for (unsigned j = 0; j < touch_event_.touchesLength; ++j) { |
2057 if (static_cast<DWORD>(touch_event_.touches[j].id) == mapped_id) { | 2057 if (static_cast<DWORD>(touch_event_.touches[j].id) == mapped_id) { |
2058 point = &touch_event_.touches[j]; | 2058 point = &touch_event_.touches[j]; |
2059 break; | 2059 break; |
2060 } | 2060 } |
2061 } | 2061 } |
2062 | 2062 |
2063 // Use a move instead if we see a down on a point we already have. | 2063 // Use a move instead if we see a down on a point we already have. |
2064 int type = GetTouchType(points[i]); | 2064 int type = GetTouchType(points[i]); |
2065 if (point && type == TOUCHEVENTF_DOWN) | 2065 if (point && type == TOUCHEVENTF_DOWN) |
2066 SetTouchType(&points[i], TOUCHEVENTF_MOVE); | 2066 SetTouchType(&points[i], TOUCHEVENTF_MOVE); |
2067 | 2067 |
2068 // Stop processing when the event type changes. | 2068 // Stop processing when the event type changes. |
2069 if (touch_event_.changedTouchesLength && type != last_type) | 2069 if (touch_event_.changedTouchesLength && type != last_type) |
2070 return i; | 2070 return i; |
2071 | 2071 |
2072 touch_event_.timeStampSeconds = points[i].dwTime / 1000.0; | 2072 touch_event_.timeStampSeconds = points[i].dwTime / 1000.0; |
2073 | 2073 |
2074 last_type = type; | 2074 last_type = type; |
2075 switch (type) { | 2075 switch (type) { |
2076 case TOUCHEVENTF_DOWN: { | 2076 case TOUCHEVENTF_DOWN: { |
2077 if (!(point = AddTouchPoint(&points[i]))) | 2077 if (!(point = AddTouchPoint(&points[i]))) |
2078 continue; | 2078 continue; |
2079 touch_event_.type = WebKit::WebInputEvent::TouchStart; | 2079 touch_event_.type = blink::WebInputEvent::TouchStart; |
2080 break; | 2080 break; |
2081 } | 2081 } |
2082 | 2082 |
2083 case TOUCHEVENTF_UP: { | 2083 case TOUCHEVENTF_UP: { |
2084 if (!point) // Just throw away a stray up. | 2084 if (!point) // Just throw away a stray up. |
2085 continue; | 2085 continue; |
2086 point->state = WebKit::WebTouchPoint::StateReleased; | 2086 point->state = blink::WebTouchPoint::StateReleased; |
2087 UpdateTouchPoint(point, &points[i]); | 2087 UpdateTouchPoint(point, &points[i]); |
2088 touch_event_.type = WebKit::WebInputEvent::TouchEnd; | 2088 touch_event_.type = blink::WebInputEvent::TouchEnd; |
2089 break; | 2089 break; |
2090 } | 2090 } |
2091 | 2091 |
2092 case TOUCHEVENTF_MOVE: { | 2092 case TOUCHEVENTF_MOVE: { |
2093 if (point) { | 2093 if (point) { |
2094 point->state = WebKit::WebTouchPoint::StateMoved; | 2094 point->state = blink::WebTouchPoint::StateMoved; |
2095 // Don't update the message if the point didn't really move. | 2095 // Don't update the message if the point didn't really move. |
2096 if (UpdateTouchPoint(point, &points[i])) | 2096 if (UpdateTouchPoint(point, &points[i])) |
2097 continue; | 2097 continue; |
2098 touch_event_.type = WebKit::WebInputEvent::TouchMove; | 2098 touch_event_.type = blink::WebInputEvent::TouchMove; |
2099 } else if (touch_event_.changedTouchesLength) { | 2099 } else if (touch_event_.changedTouchesLength) { |
2100 RemoveExpiredMappings(); | 2100 RemoveExpiredMappings(); |
2101 // Can't add a point if we're already handling move events. | 2101 // Can't add a point if we're already handling move events. |
2102 return i; | 2102 return i; |
2103 } else { | 2103 } else { |
2104 // Treat a move with no existing point as a down. | 2104 // Treat a move with no existing point as a down. |
2105 if (!(point = AddTouchPoint(&points[i]))) | 2105 if (!(point = AddTouchPoint(&points[i]))) |
2106 continue; | 2106 continue; |
2107 last_type = TOUCHEVENTF_DOWN; | 2107 last_type = TOUCHEVENTF_DOWN; |
2108 SetTouchType(&points[i], TOUCHEVENTF_DOWN); | 2108 SetTouchType(&points[i], TOUCHEVENTF_DOWN); |
2109 touch_event_.type = WebKit::WebInputEvent::TouchStart; | 2109 touch_event_.type = blink::WebInputEvent::TouchStart; |
2110 } | 2110 } |
2111 break; | 2111 break; |
2112 } | 2112 } |
2113 | 2113 |
2114 default: | 2114 default: |
2115 NOTREACHED(); | 2115 NOTREACHED(); |
2116 continue; | 2116 continue; |
2117 } | 2117 } |
2118 touch_event_.changedTouches[touch_event_.changedTouchesLength++] = *point; | 2118 touch_event_.changedTouches[touch_event_.changedTouchesLength++] = *point; |
2119 } | 2119 } |
2120 | 2120 |
2121 RemoveExpiredMappings(); | 2121 RemoveExpiredMappings(); |
2122 return count; | 2122 return count; |
2123 } | 2123 } |
2124 | 2124 |
2125 void WebTouchState::RemoveExpiredMappings() { | 2125 void WebTouchState::RemoveExpiredMappings() { |
2126 WebKit::WebTouchPoint* point = touch_event_.touches; | 2126 blink::WebTouchPoint* point = touch_event_.touches; |
2127 WebKit::WebTouchPoint* end = point + touch_event_.touchesLength; | 2127 blink::WebTouchPoint* end = point + touch_event_.touchesLength; |
2128 for (; point < end; ++point) { | 2128 for (; point < end; ++point) { |
2129 if (point->state == WebKit::WebTouchPoint::StateReleased) | 2129 if (point->state == blink::WebTouchPoint::StateReleased) |
2130 id_generator_.ReleaseGeneratedID(point->id); | 2130 id_generator_.ReleaseGeneratedID(point->id); |
2131 } | 2131 } |
2132 } | 2132 } |
2133 | 2133 |
2134 | 2134 |
2135 bool WebTouchState::ReleaseTouchPoints() { | 2135 bool WebTouchState::ReleaseTouchPoints() { |
2136 if (touch_event_.touchesLength == 0) | 2136 if (touch_event_.touchesLength == 0) |
2137 return false; | 2137 return false; |
2138 // Mark every active touchpoint as released. | 2138 // Mark every active touchpoint as released. |
2139 touch_event_.type = WebKit::WebInputEvent::TouchEnd; | 2139 touch_event_.type = blink::WebInputEvent::TouchEnd; |
2140 touch_event_.changedTouchesLength = touch_event_.touchesLength; | 2140 touch_event_.changedTouchesLength = touch_event_.touchesLength; |
2141 for (unsigned int i = 0; i < touch_event_.touchesLength; ++i) { | 2141 for (unsigned int i = 0; i < touch_event_.touchesLength; ++i) { |
2142 touch_event_.touches[i].state = WebKit::WebTouchPoint::StateReleased; | 2142 touch_event_.touches[i].state = blink::WebTouchPoint::StateReleased; |
2143 touch_event_.changedTouches[i].state = | 2143 touch_event_.changedTouches[i].state = |
2144 WebKit::WebTouchPoint::StateReleased; | 2144 blink::WebTouchPoint::StateReleased; |
2145 } | 2145 } |
2146 | 2146 |
2147 return true; | 2147 return true; |
2148 } | 2148 } |
2149 | 2149 |
2150 WebKit::WebTouchPoint* WebTouchState::AddTouchPoint( | 2150 blink::WebTouchPoint* WebTouchState::AddTouchPoint( |
2151 TOUCHINPUT* touch_input) { | 2151 TOUCHINPUT* touch_input) { |
2152 DCHECK(touch_event_.touchesLength < | 2152 DCHECK(touch_event_.touchesLength < |
2153 WebKit::WebTouchEvent::touchesLengthCap); | 2153 blink::WebTouchEvent::touchesLengthCap); |
2154 if (touch_event_.touchesLength >= | 2154 if (touch_event_.touchesLength >= |
2155 WebKit::WebTouchEvent::touchesLengthCap) | 2155 blink::WebTouchEvent::touchesLengthCap) |
2156 return NULL; | 2156 return NULL; |
2157 WebKit::WebTouchPoint* point = | 2157 blink::WebTouchPoint* point = |
2158 &touch_event_.touches[touch_event_.touchesLength++]; | 2158 &touch_event_.touches[touch_event_.touchesLength++]; |
2159 point->state = WebKit::WebTouchPoint::StatePressed; | 2159 point->state = blink::WebTouchPoint::StatePressed; |
2160 point->id = GetMappedTouch(touch_input->dwID); | 2160 point->id = GetMappedTouch(touch_input->dwID); |
2161 UpdateTouchPoint(point, touch_input); | 2161 UpdateTouchPoint(point, touch_input); |
2162 return point; | 2162 return point; |
2163 } | 2163 } |
2164 | 2164 |
2165 bool WebTouchState::UpdateTouchPoint( | 2165 bool WebTouchState::UpdateTouchPoint( |
2166 WebKit::WebTouchPoint* touch_point, | 2166 blink::WebTouchPoint* touch_point, |
2167 TOUCHINPUT* touch_input) { | 2167 TOUCHINPUT* touch_input) { |
2168 CPoint coordinates( | 2168 CPoint coordinates( |
2169 TOUCH_COORD_TO_PIXEL(touch_input->x) / | 2169 TOUCH_COORD_TO_PIXEL(touch_input->x) / |
2170 gfx::win::GetUndocumentedDPITouchScale(), | 2170 gfx::win::GetUndocumentedDPITouchScale(), |
2171 TOUCH_COORD_TO_PIXEL(touch_input->y) / | 2171 TOUCH_COORD_TO_PIXEL(touch_input->y) / |
2172 gfx::win::GetUndocumentedDPITouchScale()); | 2172 gfx::win::GetUndocumentedDPITouchScale()); |
2173 int radius_x = 1; | 2173 int radius_x = 1; |
2174 int radius_y = 1; | 2174 int radius_y = 1; |
2175 if (touch_input->dwMask & TOUCHINPUTMASKF_CONTACTAREA) { | 2175 if (touch_input->dwMask & TOUCHINPUTMASKF_CONTACTAREA) { |
2176 // Some touch drivers send a contact area of "-1", yet flag it as valid. | 2176 // Some touch drivers send a contact area of "-1", yet flag it as valid. |
2177 radius_x = std::max(1, | 2177 radius_x = std::max(1, |
2178 static_cast<int>(TOUCH_COORD_TO_PIXEL(touch_input->cxContact) / | 2178 static_cast<int>(TOUCH_COORD_TO_PIXEL(touch_input->cxContact) / |
2179 gfx::win::GetUndocumentedDPITouchScale())); | 2179 gfx::win::GetUndocumentedDPITouchScale())); |
2180 radius_y = std::max(1, | 2180 radius_y = std::max(1, |
2181 static_cast<int>(TOUCH_COORD_TO_PIXEL(touch_input->cyContact) / | 2181 static_cast<int>(TOUCH_COORD_TO_PIXEL(touch_input->cyContact) / |
2182 gfx::win::GetUndocumentedDPITouchScale())); | 2182 gfx::win::GetUndocumentedDPITouchScale())); |
2183 } | 2183 } |
2184 | 2184 |
2185 // Detect and exclude stationary moves. | 2185 // Detect and exclude stationary moves. |
2186 if (GetTouchType(*touch_input) == TOUCHEVENTF_MOVE && | 2186 if (GetTouchType(*touch_input) == TOUCHEVENTF_MOVE && |
2187 touch_point->screenPosition.x == coordinates.x && | 2187 touch_point->screenPosition.x == coordinates.x && |
2188 touch_point->screenPosition.y == coordinates.y && | 2188 touch_point->screenPosition.y == coordinates.y && |
2189 touch_point->radiusX == radius_x && | 2189 touch_point->radiusX == radius_x && |
2190 touch_point->radiusY == radius_y) { | 2190 touch_point->radiusY == radius_y) { |
2191 touch_point->state = WebKit::WebTouchPoint::StateStationary; | 2191 touch_point->state = blink::WebTouchPoint::StateStationary; |
2192 return true; | 2192 return true; |
2193 } | 2193 } |
2194 | 2194 |
2195 touch_point->screenPosition.x = coordinates.x; | 2195 touch_point->screenPosition.x = coordinates.x; |
2196 touch_point->screenPosition.y = coordinates.y; | 2196 touch_point->screenPosition.y = coordinates.y; |
2197 window_->ScreenToClient(&coordinates); | 2197 window_->ScreenToClient(&coordinates); |
2198 static float scale = gfx::win::GetDeviceScaleFactor(); | 2198 static float scale = gfx::win::GetDeviceScaleFactor(); |
2199 touch_point->position.x = coordinates.x / scale; | 2199 touch_point->position.x = coordinates.x / scale; |
2200 touch_point->position.y = coordinates.y / scale; | 2200 touch_point->position.y = coordinates.y / scale; |
2201 touch_point->radiusX = radius_x; | 2201 touch_point->radiusX = radius_x; |
(...skipping 14 matching lines...) Expand all Loading... |
2216 // Finish the ongoing composition whenever a touch event happens. | 2216 // Finish the ongoing composition whenever a touch event happens. |
2217 // It matches IE's behavior. | 2217 // It matches IE's behavior. |
2218 if (base::win::IsTSFAwareRequired()) { | 2218 if (base::win::IsTSFAwareRequired()) { |
2219 ui::TSFBridge::GetInstance()->CancelComposition(); | 2219 ui::TSFBridge::GetInstance()->CancelComposition(); |
2220 } else { | 2220 } else { |
2221 imm32_manager_->CleanupComposition(m_hWnd); | 2221 imm32_manager_->CleanupComposition(m_hWnd); |
2222 } | 2222 } |
2223 | 2223 |
2224 // TODO(jschuh): Add support for an arbitrary number of touchpoints. | 2224 // TODO(jschuh): Add support for an arbitrary number of touchpoints. |
2225 size_t total = std::min(static_cast<int>(LOWORD(wparam)), | 2225 size_t total = std::min(static_cast<int>(LOWORD(wparam)), |
2226 static_cast<int>(WebKit::WebTouchEvent::touchesLengthCap)); | 2226 static_cast<int>(blink::WebTouchEvent::touchesLengthCap)); |
2227 TOUCHINPUT points[WebKit::WebTouchEvent::touchesLengthCap]; | 2227 TOUCHINPUT points[blink::WebTouchEvent::touchesLengthCap]; |
2228 | 2228 |
2229 if (!total || !ui::GetTouchInputInfoWrapper((HTOUCHINPUT)lparam, total, | 2229 if (!total || !ui::GetTouchInputInfoWrapper((HTOUCHINPUT)lparam, total, |
2230 points, sizeof(TOUCHINPUT))) { | 2230 points, sizeof(TOUCHINPUT))) { |
2231 TRACE_EVENT0("browser", "EarlyOut_NothingToDo"); | 2231 TRACE_EVENT0("browser", "EarlyOut_NothingToDo"); |
2232 return 0; | 2232 return 0; |
2233 } | 2233 } |
2234 | 2234 |
2235 if (total == 1 && (points[0].dwFlags & TOUCHEVENTF_DOWN)) { | 2235 if (total == 1 && (points[0].dwFlags & TOUCHEVENTF_DOWN)) { |
2236 pointer_down_context_ = true; | 2236 pointer_down_context_ = true; |
2237 last_touch_location_ = gfx::Point( | 2237 last_touch_location_ = gfx::Point( |
2238 TOUCH_COORD_TO_PIXEL(points[0].x) / | 2238 TOUCH_COORD_TO_PIXEL(points[0].x) / |
2239 gfx::win::GetUndocumentedDPITouchScale(), | 2239 gfx::win::GetUndocumentedDPITouchScale(), |
2240 TOUCH_COORD_TO_PIXEL(points[0].y) / | 2240 TOUCH_COORD_TO_PIXEL(points[0].y) / |
2241 gfx::win::GetUndocumentedDPITouchScale()); | 2241 gfx::win::GetUndocumentedDPITouchScale()); |
2242 } | 2242 } |
2243 | 2243 |
2244 bool should_forward = render_widget_host_->ShouldForwardTouchEvent() && | 2244 bool should_forward = render_widget_host_->ShouldForwardTouchEvent() && |
2245 touch_events_enabled_; | 2245 touch_events_enabled_; |
2246 | 2246 |
2247 // Send a copy of the touch events on to the gesture recognizer. | 2247 // Send a copy of the touch events on to the gesture recognizer. |
2248 for (size_t start = 0; start < total;) { | 2248 for (size_t start = 0; start < total;) { |
2249 start += touch_state_->UpdateTouchPoints(points + start, total - start); | 2249 start += touch_state_->UpdateTouchPoints(points + start, total - start); |
2250 if (should_forward) { | 2250 if (should_forward) { |
2251 if (touch_state_->is_changed()) | 2251 if (touch_state_->is_changed()) |
2252 render_widget_host_->ForwardTouchEventWithLatencyInfo( | 2252 render_widget_host_->ForwardTouchEventWithLatencyInfo( |
2253 touch_state_->touch_event(), ui::LatencyInfo()); | 2253 touch_state_->touch_event(), ui::LatencyInfo()); |
2254 } else { | 2254 } else { |
2255 const WebKit::WebTouchEvent& touch_event = touch_state_->touch_event(); | 2255 const blink::WebTouchEvent& touch_event = touch_state_->touch_event(); |
2256 base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds( | 2256 base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds( |
2257 touch_event.timeStampSeconds * 1000); | 2257 touch_event.timeStampSeconds * 1000); |
2258 for (size_t i = 0; i < touch_event.touchesLength; ++i) { | 2258 for (size_t i = 0; i < touch_event.touchesLength; ++i) { |
2259 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 2259 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
2260 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( | 2260 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( |
2261 TouchEventFromWebTouchPoint(touch_event.touches[i], timestamp), | 2261 TouchEventFromWebTouchPoint(touch_event.touches[i], timestamp), |
2262 ui::ER_UNHANDLED, this)); | 2262 ui::ER_UNHANDLED, this)); |
2263 ProcessGestures(gestures.get()); | 2263 ProcessGestures(gestures.get()); |
2264 } | 2264 } |
2265 } | 2265 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2476 } | 2476 } |
2477 } | 2477 } |
2478 | 2478 |
2479 void RenderWidgetHostViewWin::AcceleratedPaint(HDC dc) { | 2479 void RenderWidgetHostViewWin::AcceleratedPaint(HDC dc) { |
2480 if (render_widget_host_) | 2480 if (render_widget_host_) |
2481 render_widget_host_->ScheduleComposite(); | 2481 render_widget_host_->ScheduleComposite(); |
2482 if (accelerated_surface_) | 2482 if (accelerated_surface_) |
2483 accelerated_surface_->Present(dc); | 2483 accelerated_surface_->Present(dc); |
2484 } | 2484 } |
2485 | 2485 |
2486 void RenderWidgetHostViewWin::GetScreenInfo(WebKit::WebScreenInfo* results) { | 2486 void RenderWidgetHostViewWin::GetScreenInfo(blink::WebScreenInfo* results) { |
2487 GetScreenInfoForWindow(GetNativeViewId(), results); | 2487 GetScreenInfoForWindow(GetNativeViewId(), results); |
2488 } | 2488 } |
2489 | 2489 |
2490 gfx::Rect RenderWidgetHostViewWin::GetBoundsInRootWindow() { | 2490 gfx::Rect RenderWidgetHostViewWin::GetBoundsInRootWindow() { |
2491 RECT window_rect = {0}; | 2491 RECT window_rect = {0}; |
2492 HWND root_window = GetAncestor(m_hWnd, GA_ROOT); | 2492 HWND root_window = GetAncestor(m_hWnd, GA_ROOT); |
2493 ::GetWindowRect(root_window, &window_rect); | 2493 ::GetWindowRect(root_window, &window_rect); |
2494 gfx::Rect rect(window_rect); | 2494 gfx::Rect rect(window_rect); |
2495 | 2495 |
2496 // Maximized windows are outdented from the work area by the frame thickness | 2496 // Maximized windows are outdented from the work area by the frame thickness |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2868 | 2868 |
2869 // Pinch gestures are disabled by default on windows desktop. See | 2869 // Pinch gestures are disabled by default on windows desktop. See |
2870 // crbug.com/128477 and crbug.com/148816 | 2870 // crbug.com/128477 and crbug.com/148816 |
2871 if ((gesture->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2871 if ((gesture->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2872 gesture->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2872 gesture->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2873 gesture->type() == ui::ET_GESTURE_PINCH_END) && | 2873 gesture->type() == ui::ET_GESTURE_PINCH_END) && |
2874 !ShouldSendPinchGesture()) { | 2874 !ShouldSendPinchGesture()) { |
2875 return true; | 2875 return true; |
2876 } | 2876 } |
2877 | 2877 |
2878 WebKit::WebGestureEvent web_gesture = CreateWebGestureEvent(m_hWnd, *gesture); | 2878 blink::WebGestureEvent web_gesture = CreateWebGestureEvent(m_hWnd, *gesture); |
2879 if (web_gesture.type == WebKit::WebGestureEvent::Undefined) | 2879 if (web_gesture.type == blink::WebGestureEvent::Undefined) |
2880 return false; | 2880 return false; |
2881 if (web_gesture.type == WebKit::WebGestureEvent::GestureTapDown) { | 2881 if (web_gesture.type == blink::WebGestureEvent::GestureTapDown) { |
2882 render_widget_host_->ForwardGestureEvent( | 2882 render_widget_host_->ForwardGestureEvent( |
2883 CreateFlingCancelEvent(gesture->time_stamp().InSecondsF())); | 2883 CreateFlingCancelEvent(gesture->time_stamp().InSecondsF())); |
2884 } | 2884 } |
2885 render_widget_host_->ForwardGestureEventWithLatencyInfo(web_gesture, | 2885 render_widget_host_->ForwardGestureEventWithLatencyInfo(web_gesture, |
2886 *gesture->latency()); | 2886 *gesture->latency()); |
2887 return true; | 2887 return true; |
2888 } | 2888 } |
2889 | 2889 |
2890 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, | 2890 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, |
2891 WPARAM wparam, | 2891 WPARAM wparam, |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3197 // RenderWidgetHostView, public: | 3197 // RenderWidgetHostView, public: |
3198 | 3198 |
3199 // static | 3199 // static |
3200 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 3200 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
3201 RenderWidgetHost* widget) { | 3201 RenderWidgetHost* widget) { |
3202 return new RenderWidgetHostViewWin(widget); | 3202 return new RenderWidgetHostViewWin(widget); |
3203 } | 3203 } |
3204 | 3204 |
3205 // static | 3205 // static |
3206 void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 3206 void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
3207 WebKit::WebScreenInfo* results) { | 3207 blink::WebScreenInfo* results) { |
3208 GetScreenInfoForWindow(0, results); | 3208 GetScreenInfoForWindow(0, results); |
3209 } | 3209 } |
3210 | 3210 |
3211 } // namespace content | 3211 } // namespace content |
OLD | NEW |