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_AURA_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 namespace gpu { | 59 namespace gpu { |
60 struct Mailbox; | 60 struct Mailbox; |
61 } | 61 } |
62 | 62 |
63 namespace ui { | 63 namespace ui { |
64 class CompositorLock; | 64 class CompositorLock; |
65 class InputMethod; | 65 class InputMethod; |
66 class LocatedEvent; | 66 class LocatedEvent; |
67 class Texture; | 67 class Texture; |
| 68 class TouchSelectionControllerAura; |
| 69 class TouchSelectionControllerAuraClient; |
68 } | 70 } |
69 | 71 |
70 namespace content { | 72 namespace content { |
71 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
72 class LegacyRenderWidgetHostHWND; | 74 class LegacyRenderWidgetHostHWND; |
73 #endif | 75 #endif |
74 | 76 |
75 class OverscrollController; | 77 class OverscrollController; |
76 class RenderFrameHostImpl; | 78 class RenderFrameHostImpl; |
77 class RenderWidgetHostImpl; | 79 class RenderWidgetHostImpl; |
78 class RenderWidgetHostView; | 80 class RenderWidgetHostView; |
79 | 81 |
80 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 82 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
81 class CONTENT_EXPORT RenderWidgetHostViewAura | 83 class CONTENT_EXPORT RenderWidgetHostViewAura |
82 : public RenderWidgetHostViewBase, | 84 : public RenderWidgetHostViewBase, |
83 public DelegatedFrameHostClient, | 85 public DelegatedFrameHostClient, |
84 public ui::TextInputClient, | 86 public ui::TextInputClient, |
85 public gfx::DisplayObserver, | 87 public gfx::DisplayObserver, |
86 public aura::WindowTreeHostObserver, | 88 public aura::WindowTreeHostObserver, |
87 public aura::WindowDelegate, | 89 public aura::WindowDelegate, |
88 public aura::client::ActivationDelegate, | 90 public aura::client::ActivationDelegate, |
89 public aura::client::ActivationChangeObserver, | 91 public aura::client::ActivationChangeObserver, |
90 public aura::client::FocusChangeObserver, | 92 public aura::client::FocusChangeObserver, |
91 public aura::client::CursorClientObserver { | 93 public aura::client::CursorClientObserver { |
92 public: | 94 public: |
93 // Displays and controls touch editing elements such as selection handles. | |
94 class TouchEditingClient { | |
95 public: | |
96 TouchEditingClient() {} | |
97 | |
98 // Tells the client to start showing touch editing handles. | |
99 virtual void StartTouchEditing() = 0; | |
100 | |
101 // Notifies the client that touch editing is no longer needed. |quick| | |
102 // determines whether the handles should fade out quickly or slowly. | |
103 virtual void EndTouchEditing(bool quick) = 0; | |
104 | |
105 // Notifies the client that the selection bounds need to be updated. | |
106 virtual void OnSelectionOrCursorChanged( | |
107 const ui::SelectionBound& anchor, | |
108 const ui::SelectionBound& focus) = 0; | |
109 | |
110 // Notifies the client that the current text input type as changed. | |
111 virtual void OnTextInputTypeChanged(ui::TextInputType type) = 0; | |
112 | |
113 // Notifies the client that an input event is about to be sent to the | |
114 // renderer. Returns true if the client wants to stop event propagation. | |
115 virtual bool HandleInputEvent(const ui::Event* event) = 0; | |
116 | |
117 // Notifies the client that a gesture event ack was received. | |
118 virtual void GestureEventAck(int gesture_event_type) = 0; | |
119 | |
120 // Notifies the client that the fling has ended, so it can activate touch | |
121 // editing if needed. | |
122 virtual void DidStopFlinging() = 0; | |
123 | |
124 // This is called when the view is destroyed, so that the client can | |
125 // perform any necessary clean-up. | |
126 virtual void OnViewDestroyed() = 0; | |
127 | |
128 protected: | |
129 virtual ~TouchEditingClient() {} | |
130 }; | |
131 | |
132 void set_touch_editing_client(TouchEditingClient* client) { | |
133 touch_editing_client_ = client; | |
134 } | |
135 | |
136 // When |is_guest_view_hack| is true, this view isn't really the view for | 95 // When |is_guest_view_hack| is true, this view isn't really the view for |
137 // the |widget|, a RenderWidgetHostViewGuest is. | 96 // the |widget|, a RenderWidgetHostViewGuest is. |
138 // | 97 // |
139 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated | 98 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated |
140 // to use RWHVChildFrame (http://crbug.com/330264). | 99 // to use RWHVChildFrame (http://crbug.com/330264). |
141 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack); | 100 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack); |
142 | 101 |
| 102 // TODO(mfomitchev): create to wm::ConvertRectToScreen and use that instead. |
| 103 // Converts |rect| from window coordinate to screen coordinate. |
| 104 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; |
| 105 |
143 // RenderWidgetHostView implementation. | 106 // RenderWidgetHostView implementation. |
144 bool OnMessageReceived(const IPC::Message& msg) override; | 107 bool OnMessageReceived(const IPC::Message& msg) override; |
145 void InitAsChild(gfx::NativeView parent_view) override; | 108 void InitAsChild(gfx::NativeView parent_view) override; |
146 RenderWidgetHost* GetRenderWidgetHost() const override; | 109 RenderWidgetHost* GetRenderWidgetHost() const override; |
147 void SetSize(const gfx::Size& size) override; | 110 void SetSize(const gfx::Size& size) override; |
148 void SetBounds(const gfx::Rect& rect) override; | 111 void SetBounds(const gfx::Rect& rect) override; |
149 gfx::Vector2dF GetLastScrollOffset() const override; | 112 gfx::Vector2dF GetLastScrollOffset() const override; |
150 gfx::NativeView GetNativeView() const override; | 113 gfx::NativeView GetNativeView() const override; |
151 gfx::NativeViewId GetNativeViewId() const override; | 114 gfx::NativeViewId GetNativeViewId() const override; |
152 gfx::NativeViewAccessible GetNativeViewAccessible() override; | 115 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // Method to indicate if this instance is shutting down or closing. | 306 // Method to indicate if this instance is shutting down or closing. |
344 // TODO(shrikant): Discuss around to see if it makes sense to add this method | 307 // TODO(shrikant): Discuss around to see if it makes sense to add this method |
345 // as part of RenderWidgetHostView. | 308 // as part of RenderWidgetHostView. |
346 bool IsClosing() const { return in_shutdown_; } | 309 bool IsClosing() const { return in_shutdown_; } |
347 | 310 |
348 // Sets whether the overscroll controller should be enabled for this page. | 311 // Sets whether the overscroll controller should be enabled for this page. |
349 void SetOverscrollControllerEnabled(bool enabled); | 312 void SetOverscrollControllerEnabled(bool enabled); |
350 | 313 |
351 void SnapToPhysicalPixelBoundary(); | 314 void SnapToPhysicalPixelBoundary(); |
352 | 315 |
| 316 void InitSelectionController( |
| 317 ui::TouchSelectionControllerAuraClient* selection_controller_client); |
| 318 |
| 319 ui::TouchSelectionControllerAura* selection_controller() { |
| 320 return selection_controller_.get(); |
| 321 } |
| 322 |
353 OverscrollController* overscroll_controller() const { | 323 OverscrollController* overscroll_controller() const { |
354 return overscroll_controller_.get(); | 324 return overscroll_controller_.get(); |
355 } | 325 } |
356 | 326 |
357 protected: | 327 protected: |
358 ~RenderWidgetHostViewAura() override; | 328 ~RenderWidgetHostViewAura() override; |
359 | 329 |
360 // Exposed for tests. | 330 // Exposed for tests. |
361 aura::Window* window() { return window_; } | 331 aura::Window* window() { return window_; } |
362 SkColorType PreferredReadbackFormat() override; | 332 SkColorType PreferredReadbackFormat() override; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 434 |
465 // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method | 435 // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method |
466 // calls our keybindings handler against the event and send matched | 436 // calls our keybindings handler against the event and send matched |
467 // edit commands to renderer instead. | 437 // edit commands to renderer instead. |
468 void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event); | 438 void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event); |
469 | 439 |
470 // Dismisses a Web Popup on a mouse or touch press outside the popup and its | 440 // Dismisses a Web Popup on a mouse or touch press outside the popup and its |
471 // parent. | 441 // parent. |
472 void ApplyEventFilterForPopupExit(ui::LocatedEvent* event); | 442 void ApplyEventFilterForPopupExit(ui::LocatedEvent* event); |
473 | 443 |
474 // Converts |rect| from window coordinate to screen coordinate. | |
475 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; | |
476 | |
477 // Converts |rect| from screen coordinate to window coordinate. | 444 // Converts |rect| from screen coordinate to window coordinate. |
478 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; | 445 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; |
479 | 446 |
480 // Helper function to set keyboard focus to the main window. | 447 // Helper function to set keyboard focus to the main window. |
481 void SetKeyboardFocus(); | 448 void SetKeyboardFocus(); |
482 | 449 |
483 RenderFrameHostImpl* GetFocusedFrame(); | 450 RenderFrameHostImpl* GetFocusedFrame(); |
484 | 451 |
| 452 // ... |
| 453 void SelectionBoundsUpdated(const ui::SelectionBound& start, |
| 454 const ui::SelectionBound& end); |
| 455 |
485 // The model object. | 456 // The model object. |
486 RenderWidgetHostImpl* host_; | 457 RenderWidgetHostImpl* host_; |
487 | 458 |
488 aura::Window* window_; | 459 aura::Window* window_; |
489 | 460 |
490 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 461 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
491 | 462 |
492 scoped_ptr<WindowObserver> window_observer_; | 463 scoped_ptr<WindowObserver> window_observer_; |
493 | 464 |
494 // Are we in the process of closing? Tracked so fullscreen views can avoid | 465 // Are we in the process of closing? Tracked so fullscreen views can avoid |
(...skipping 28 matching lines...) Expand all Loading... |
523 ui::MotionEventAura pointer_state_; | 494 ui::MotionEventAura pointer_state_; |
524 | 495 |
525 // The current text input type. | 496 // The current text input type. |
526 ui::TextInputType text_input_type_; | 497 ui::TextInputType text_input_type_; |
527 // The current text input mode corresponding to HTML5 inputmode attribute. | 498 // The current text input mode corresponding to HTML5 inputmode attribute. |
528 ui::TextInputMode text_input_mode_; | 499 ui::TextInputMode text_input_mode_; |
529 // The current text input flags. | 500 // The current text input flags. |
530 int text_input_flags_; | 501 int text_input_flags_; |
531 bool can_compose_inline_; | 502 bool can_compose_inline_; |
532 | 503 |
533 // Bounds for the selection. | |
534 ui::SelectionBound selection_anchor_; | |
535 ui::SelectionBound selection_focus_; | |
536 | |
537 // The current composition character bounds. | 504 // The current composition character bounds. |
538 std::vector<gfx::Rect> composition_character_bounds_; | 505 std::vector<gfx::Rect> composition_character_bounds_; |
539 | 506 |
540 // Indicates if there is onging composition text. | 507 // Indicates if there is onging composition text. |
541 bool has_composition_text_; | 508 bool has_composition_text_; |
542 | 509 |
543 // Whether return characters should be passed on to the RenderWidgetHostImpl. | 510 // Whether return characters should be passed on to the RenderWidgetHostImpl. |
544 bool accept_return_character_; | 511 bool accept_return_character_; |
545 | 512 |
546 // Current tooltip text. | 513 // Current tooltip text. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 // Set to true if the legacy_render_widget_host_HWND_ instance was destroyed | 572 // Set to true if the legacy_render_widget_host_HWND_ instance was destroyed |
606 // by Windows. This could happen if the browser window was destroyed by | 573 // by Windows. This could happen if the browser window was destroyed by |
607 // DestroyWindow for e.g. This flag helps ensure that we don't try to create | 574 // DestroyWindow for e.g. This flag helps ensure that we don't try to create |
608 // the LegacyRenderWidgetHostHWND instance again as that would be a futile | 575 // the LegacyRenderWidgetHostHWND instance again as that would be a futile |
609 // exercise. | 576 // exercise. |
610 bool legacy_window_destroyed_; | 577 bool legacy_window_destroyed_; |
611 #endif | 578 #endif |
612 | 579 |
613 bool has_snapped_to_boundary_; | 580 bool has_snapped_to_boundary_; |
614 | 581 |
615 TouchEditingClient* touch_editing_client_; | 582 scoped_ptr<ui::TouchSelectionControllerAuraClient> |
| 583 selection_controller_client_; |
| 584 scoped_ptr<ui::TouchSelectionControllerAura> selection_controller_; |
616 | 585 |
617 scoped_ptr<OverscrollController> overscroll_controller_; | 586 scoped_ptr<OverscrollController> overscroll_controller_; |
618 | 587 |
619 // The last scroll offset of the view. | 588 // The last scroll offset of the view. |
620 gfx::Vector2dF last_scroll_offset_; | 589 gfx::Vector2dF last_scroll_offset_; |
621 | 590 |
622 gfx::Insets insets_; | 591 gfx::Insets insets_; |
623 | 592 |
624 std::vector<ui::LatencyInfo> software_latency_info_; | 593 std::vector<ui::LatencyInfo> software_latency_info_; |
625 | 594 |
(...skipping 10 matching lines...) Expand all Loading... |
636 // compositing surface and showing the disambiguation popup. | 605 // compositing surface and showing the disambiguation popup. |
637 gfx::Vector2dF disambiguation_scroll_offset_; | 606 gfx::Vector2dF disambiguation_scroll_offset_; |
638 | 607 |
639 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_; | 608 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_; |
640 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 609 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
641 }; | 610 }; |
642 | 611 |
643 } // namespace content | 612 } // namespace content |
644 | 613 |
645 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 614 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
OLD | NEW |