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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <atlbase.h> | 9 #include <atlbase.h> |
10 #include <atlapp.h> | 10 #include <atlapp.h> |
11 #include <atlcrack.h> | 11 #include <atlcrack.h> |
12 #include <atlmisc.h> | 12 #include <atlmisc.h> |
13 #include <peninputpanel.h> | 13 #include <peninputpanel.h> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/time.h" | 20 #include "base/time.h" |
21 #include "base/win/scoped_comptr.h" | 21 #include "base/win/scoped_comptr.h" |
22 #include "content/browser/accessibility/browser_accessibility_manager.h" | 22 #include "content/browser/accessibility/browser_accessibility_manager.h" |
23 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 23 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
24 #include "content/common/content_export.h" | 24 #include "content/common/content_export.h" |
25 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
26 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 27 #include "ui/base/gestures/gesture_recognizer.h" |
| 28 #include "ui/base/gestures/gesture_types.h" |
27 #include "ui/base/win/ime_input.h" | 29 #include "ui/base/win/ime_input.h" |
28 #include "ui/gfx/native_widget_types.h" | 30 #include "ui/gfx/native_widget_types.h" |
29 #include "ui/gfx/point.h" | 31 #include "ui/gfx/point.h" |
30 #include "ui/surface/accelerated_surface_win.h" | 32 #include "ui/surface/accelerated_surface_win.h" |
31 #include "webkit/glue/webcursor.h" | 33 #include "webkit/glue/webcursor.h" |
32 | 34 |
33 class BackingStore; | 35 class BackingStore; |
34 class SkRegion; | 36 class SkRegion; |
| 37 class WebTouchState; |
35 | 38 |
36 namespace content { | 39 namespace content { |
37 class RenderWidgetHost; | 40 class RenderWidgetHost; |
38 } | 41 } |
39 | 42 |
40 namespace gfx { | 43 namespace gfx { |
41 class Size; | 44 class Size; |
42 class Rect; | 45 class Rect; |
43 } | 46 } |
44 | 47 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // If the render process dies, the RenderWidgetHostHWND goes away and all | 88 // If the render process dies, the RenderWidgetHostHWND goes away and all |
86 // references to it must become NULL." | 89 // references to it must become NULL." |
87 // | 90 // |
88 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 91 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
89 class RenderWidgetHostViewWin | 92 class RenderWidgetHostViewWin |
90 : public CWindowImpl<RenderWidgetHostViewWin, | 93 : public CWindowImpl<RenderWidgetHostViewWin, |
91 CWindow, | 94 CWindow, |
92 RenderWidgetHostHWNDTraits>, | 95 RenderWidgetHostHWNDTraits>, |
93 public content::RenderWidgetHostViewBase, | 96 public content::RenderWidgetHostViewBase, |
94 public content::NotificationObserver, | 97 public content::NotificationObserver, |
95 public BrowserAccessibilityDelegate { | 98 public BrowserAccessibilityDelegate, |
| 99 public ui::GestureConsumer, |
| 100 public ui::GestureEventHelper { |
96 public: | 101 public: |
97 virtual ~RenderWidgetHostViewWin(); | 102 virtual ~RenderWidgetHostViewWin(); |
98 | 103 |
99 CONTENT_EXPORT void CreateWnd(HWND parent); | 104 CONTENT_EXPORT void CreateWnd(HWND parent); |
100 | 105 |
101 void ScheduleComposite(); | 106 void ScheduleComposite(); |
102 | 107 |
103 DECLARE_WND_CLASS_EX(kRenderWidgetHostHWNDClass, CS_DBLCLKS, 0); | 108 DECLARE_WND_CLASS_EX(kRenderWidgetHostHWNDClass, CS_DBLCLKS, 0); |
104 | 109 |
105 BEGIN_MSG_MAP(RenderWidgetHostHWND) | 110 BEGIN_MSG_MAP(RenderWidgetHostHWND) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Implementation of BrowserAccessibilityDelegate: | 238 // Implementation of BrowserAccessibilityDelegate: |
234 virtual void SetAccessibilityFocus(int acc_obj_id) OVERRIDE; | 239 virtual void SetAccessibilityFocus(int acc_obj_id) OVERRIDE; |
235 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; | 240 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; |
236 virtual void AccessibilityScrollToMakeVisible( | 241 virtual void AccessibilityScrollToMakeVisible( |
237 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; | 242 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; |
238 virtual void AccessibilityScrollToPoint( | 243 virtual void AccessibilityScrollToPoint( |
239 int acc_obj_id, gfx::Point point) OVERRIDE; | 244 int acc_obj_id, gfx::Point point) OVERRIDE; |
240 virtual void AccessibilitySetTextSelection( | 245 virtual void AccessibilitySetTextSelection( |
241 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; | 246 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; |
242 | 247 |
| 248 // Overridden from ui::GestureEventHelper. |
| 249 virtual ui::GestureEvent* CreateGestureEvent( |
| 250 ui::EventType type, |
| 251 const gfx::Point& location, |
| 252 int flags, |
| 253 base::Time time, |
| 254 float param_first, |
| 255 float param_second, |
| 256 unsigned int touch_id_bitfield) OVERRIDE; |
| 257 virtual ui::TouchEvent* CreateTouchEvent( |
| 258 ui::EventType type, |
| 259 const gfx::Point& location, |
| 260 int touch_id, |
| 261 base::TimeDelta time_stamp) OVERRIDE; |
| 262 virtual bool DispatchLongPressGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 263 virtual bool DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; |
| 264 |
243 protected: | 265 protected: |
244 friend class content::RenderWidgetHostView; | 266 friend class content::RenderWidgetHostView; |
245 | 267 |
246 // Should construct only via RenderWidgetHostView::CreateViewForWidget. | 268 // Should construct only via RenderWidgetHostView::CreateViewForWidget. |
247 // | 269 // |
248 // The view will associate itself with the given widget. | 270 // The view will associate itself with the given widget. |
249 explicit RenderWidgetHostViewWin(content::RenderWidgetHost* widget); | 271 explicit RenderWidgetHostViewWin(content::RenderWidgetHost* widget); |
250 | 272 |
251 // Windows Message Handlers | 273 // Windows Message Handlers |
252 LRESULT OnCreate(CREATESTRUCT* create_struct); | 274 LRESULT OnCreate(CREATESTRUCT* create_struct); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 bool Send(IPC::Message* message); | 340 bool Send(IPC::Message* message); |
319 | 341 |
320 // Set the tooltip region to the size of the window, creating the tooltip | 342 // Set the tooltip region to the size of the window, creating the tooltip |
321 // hwnd if it has not been created yet. | 343 // hwnd if it has not been created yet. |
322 void EnsureTooltip(); | 344 void EnsureTooltip(); |
323 | 345 |
324 // Tooltips become invalid when the root ancestor changes. When the View | 346 // Tooltips become invalid when the root ancestor changes. When the View |
325 // becomes hidden, this method is called to reset the tooltip. | 347 // becomes hidden, this method is called to reset the tooltip. |
326 void ResetTooltip(); | 348 void ResetTooltip(); |
327 | 349 |
| 350 // Builds and forwards a WebKitGestureEvent to the renderer. |
| 351 bool ForwardGestureEventToRenderer( |
| 352 ui::GestureEvent* gesture); |
| 353 |
| 354 // Process all of the given gestures (passes them on to renderer) |
| 355 void ProcessGestures(ui::GestureRecognizer::Gestures* gestures); |
| 356 |
328 // Sends the specified mouse event to the renderer. | 357 // Sends the specified mouse event to the renderer. |
329 void ForwardMouseEventToRenderer(UINT message, WPARAM wparam, LPARAM lparam); | 358 void ForwardMouseEventToRenderer(UINT message, WPARAM wparam, LPARAM lparam); |
330 | 359 |
331 // Synthesize mouse wheel event. | 360 // Synthesize mouse wheel event. |
332 LRESULT SynthesizeMouseWheel(bool is_vertical, int scroll_code, | 361 LRESULT SynthesizeMouseWheel(bool is_vertical, int scroll_code, |
333 short scroll_position); | 362 short scroll_position); |
334 | 363 |
335 // Shuts down the render_widget_host_. This is a separate function so we can | 364 // Shuts down the render_widget_host_. This is a separate function so we can |
336 // invoke it from the message loop. | 365 // invoke it from the message loop. |
337 void ShutdownHost(); | 366 void ShutdownHost(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // Represents whether or not this browser process is receiving status | 447 // Represents whether or not this browser process is receiving status |
419 // messages about the focused edit control from a renderer process. | 448 // messages about the focused edit control from a renderer process. |
420 bool ime_notification_; | 449 bool ime_notification_; |
421 | 450 |
422 // true if Enter was hit when render widget host was in focus. | 451 // true if Enter was hit when render widget host was in focus. |
423 bool capture_enter_key_; | 452 bool capture_enter_key_; |
424 | 453 |
425 // true if the View is not visible. | 454 // true if the View is not visible. |
426 bool is_hidden_; | 455 bool is_hidden_; |
427 | 456 |
428 // Wrapper for maintaining touchstate associated with a WebTouchEvent. | |
429 class WebTouchState { | |
430 public: | |
431 explicit WebTouchState(const CWindowImpl* window); | |
432 | |
433 // Updates the current touchpoint state with the supplied touches. | |
434 // Touches will be consumed only if they are of the same type (e.g. down, | |
435 // up, move). Returns the number of consumed touches. | |
436 size_t UpdateTouchPoints(TOUCHINPUT* points, size_t count); | |
437 | |
438 // Marks all active touchpoints as released. | |
439 bool ReleaseTouchPoints(); | |
440 | |
441 // The contained WebTouchEvent. | |
442 const WebKit::WebTouchEvent& touch_event() { return touch_event_; } | |
443 | |
444 // Returns if any touches are modified in the event. | |
445 bool is_changed() { return touch_event_.changedTouchesLength != 0; } | |
446 | |
447 private: | |
448 // Adds a touch point or returns NULL if there's not enough space. | |
449 WebKit::WebTouchPoint* AddTouchPoint(TOUCHINPUT* touch_input); | |
450 | |
451 // Copy details from a TOUCHINPUT to an existing WebTouchPoint, returning | |
452 // true if the resulting point is a stationary move. | |
453 bool UpdateTouchPoint(WebKit::WebTouchPoint* touch_point, | |
454 TOUCHINPUT* touch_input); | |
455 | |
456 WebKit::WebTouchEvent touch_event_; | |
457 const CWindowImpl* const window_; | |
458 }; | |
459 | |
460 // The touch-state. Its touch-points are updated as necessary. A new | 457 // The touch-state. Its touch-points are updated as necessary. A new |
461 // touch-point is added from an TOUCHEVENTF_DOWN message, and a touch-point | 458 // touch-point is added from an TOUCHEVENTF_DOWN message, and a touch-point |
462 // is removed from the list on an TOUCHEVENTF_UP message. | 459 // is removed from the list on an TOUCHEVENTF_UP message. |
463 WebTouchState touch_state_; | 460 scoped_ptr<WebTouchState> touch_state_; |
464 | 461 |
465 // True if we're in the midst of a paint operation and should respond to | 462 // True if we're in the midst of a paint operation and should respond to |
466 // DidPaintRect() notifications by merely invalidating. See comments on | 463 // DidPaintRect() notifications by merely invalidating. See comments on |
467 // render_widget_host_view.h:DidPaintRect(). | 464 // render_widget_host_view.h:DidPaintRect(). |
468 bool about_to_validate_and_paint_; | 465 bool about_to_validate_and_paint_; |
469 | 466 |
470 // true if the View should be closed when its HWND is deactivated (used to | 467 // true if the View should be closed when its HWND is deactivated (used to |
471 // support SELECT popups which are closed when they are deactivated). | 468 // support SELECT popups which are closed when they are deactivated). |
472 bool close_on_deactivate_; | 469 bool close_on_deactivate_; |
473 | 470 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 | 557 |
561 // Set to true if we received a focus change after a WM_POINTERDOWN message. | 558 // Set to true if we received a focus change after a WM_POINTERDOWN message. |
562 bool received_focus_change_after_pointer_down_; | 559 bool received_focus_change_after_pointer_down_; |
563 | 560 |
564 // Region in which the view will be transparent to clicks. | 561 // Region in which the view will be transparent to clicks. |
565 scoped_ptr<SkRegion> transparent_region_; | 562 scoped_ptr<SkRegion> transparent_region_; |
566 | 563 |
567 // Are touch events currently enabled? | 564 // Are touch events currently enabled? |
568 bool touch_events_enabled_; | 565 bool touch_events_enabled_; |
569 | 566 |
| 567 scoped_ptr<ui::GestureRecognizer> gesture_recognizer_; |
| 568 |
570 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewWin); | 569 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewWin); |
571 }; | 570 }; |
572 | 571 |
573 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ | 572 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ |
OLD | NEW |