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 13 matching lines...) Expand all Loading... |
24 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 24 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
25 #include "content/common/content_export.h" | 25 #include "content/common/content_export.h" |
26 #include "content/common/cursors/webcursor.h" | 26 #include "content/common/cursors/webcursor.h" |
27 #include "third_party/skia/include/core/SkRegion.h" | 27 #include "third_party/skia/include/core/SkRegion.h" |
28 #include "ui/aura/client/cursor_client_observer.h" | 28 #include "ui/aura/client/cursor_client_observer.h" |
29 #include "ui/aura/client/focus_change_observer.h" | 29 #include "ui/aura/client/focus_change_observer.h" |
30 #include "ui/aura/window_delegate.h" | 30 #include "ui/aura/window_delegate.h" |
31 #include "ui/aura/window_tree_host_observer.h" | 31 #include "ui/aura/window_tree_host_observer.h" |
32 #include "ui/base/ime/text_input_client.h" | 32 #include "ui/base/ime/text_input_client.h" |
33 #include "ui/base/touch/selection_bound.h" | 33 #include "ui/base/touch/selection_bound.h" |
34 #include "ui/base/touch/touch_editing_controller.h" | |
35 #include "ui/events/gestures/motion_event_aura.h" | 34 #include "ui/events/gestures/motion_event_aura.h" |
36 #include "ui/gfx/display_observer.h" | 35 #include "ui/gfx/display_observer.h" |
37 #include "ui/gfx/geometry/insets.h" | 36 #include "ui/gfx/geometry/insets.h" |
38 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
39 #include "ui/wm/public/activation_delegate.h" | 38 #include "ui/wm/public/activation_delegate.h" |
40 | 39 |
41 struct ViewHostMsg_TextInputState_Params; | 40 struct ViewHostMsg_TextInputState_Params; |
42 | 41 |
43 namespace aura { | 42 namespace aura { |
44 class WindowTracker; | 43 class WindowTracker; |
(...skipping 15 matching lines...) Expand all Loading... |
60 | 59 |
61 namespace gpu { | 60 namespace gpu { |
62 struct Mailbox; | 61 struct Mailbox; |
63 } | 62 } |
64 | 63 |
65 namespace ui { | 64 namespace ui { |
66 class CompositorLock; | 65 class CompositorLock; |
67 class InputMethod; | 66 class InputMethod; |
68 class LocatedEvent; | 67 class LocatedEvent; |
69 class Texture; | 68 class Texture; |
| 69 class TouchSelectionController; |
70 } | 70 } |
71 | 71 |
72 namespace content { | 72 namespace content { |
73 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
74 class LegacyRenderWidgetHostHWND; | 74 class LegacyRenderWidgetHostHWND; |
75 #endif | 75 #endif |
76 | 76 |
77 class OverscrollController; | 77 class OverscrollController; |
78 class RenderFrameHostImpl; | 78 class RenderFrameHostImpl; |
79 class RenderWidgetHostImpl; | 79 class RenderWidgetHostImpl; |
80 class RenderWidgetHostView; | 80 class RenderWidgetHostView; |
| 81 class TouchSelectionControllerClientAura; |
81 | 82 |
82 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 83 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
83 class CONTENT_EXPORT RenderWidgetHostViewAura | 84 class CONTENT_EXPORT RenderWidgetHostViewAura |
84 : public RenderWidgetHostViewBase, | 85 : public RenderWidgetHostViewBase, |
85 public DelegatedFrameHostClient, | 86 public DelegatedFrameHostClient, |
86 public BeginFrameObserverProxyClient, | 87 public BeginFrameObserverProxyClient, |
87 public ui::TextInputClient, | 88 public ui::TextInputClient, |
88 public gfx::DisplayObserver, | 89 public gfx::DisplayObserver, |
89 public aura::WindowTreeHostObserver, | 90 public aura::WindowTreeHostObserver, |
90 public aura::WindowDelegate, | 91 public aura::WindowDelegate, |
91 public aura::client::ActivationDelegate, | 92 public aura::client::ActivationDelegate, |
92 public aura::client::FocusChangeObserver, | 93 public aura::client::FocusChangeObserver, |
93 public aura::client::CursorClientObserver { | 94 public aura::client::CursorClientObserver { |
94 public: | 95 public: |
95 // Displays and controls touch editing elements such as selection handles. | |
96 class TouchEditingClient { | |
97 public: | |
98 TouchEditingClient() {} | |
99 | |
100 // Tells the client to start showing touch editing handles. | |
101 virtual void StartTouchEditing() = 0; | |
102 | |
103 // Notifies the client that touch editing is no longer needed. |quick| | |
104 // determines whether the handles should fade out quickly or slowly. | |
105 virtual void EndTouchEditing(bool quick) = 0; | |
106 | |
107 // Notifies the client that the selection bounds need to be updated. | |
108 virtual void OnSelectionOrCursorChanged( | |
109 const ui::SelectionBound& anchor, | |
110 const ui::SelectionBound& focus) = 0; | |
111 | |
112 // Notifies the client that the current text input type as changed. | |
113 virtual void OnTextInputTypeChanged(ui::TextInputType type) = 0; | |
114 | |
115 // Notifies the client that an input event is about to be sent to the | |
116 // renderer. Returns true if the client wants to stop event propagation. | |
117 virtual bool HandleInputEvent(const ui::Event* event) = 0; | |
118 | |
119 // Notifies the client that a gesture event ack was received. | |
120 virtual void GestureEventAck(int gesture_event_type) = 0; | |
121 | |
122 // Notifies the client that the fling has ended, so it can activate touch | |
123 // editing if needed. | |
124 virtual void DidStopFlinging() = 0; | |
125 | |
126 // This is called when the view is destroyed, so that the client can | |
127 // perform any necessary clean-up. | |
128 virtual void OnViewDestroyed() = 0; | |
129 | |
130 protected: | |
131 virtual ~TouchEditingClient() {} | |
132 }; | |
133 | |
134 void set_touch_editing_client(TouchEditingClient* client) { | |
135 touch_editing_client_ = client; | |
136 } | |
137 | |
138 // When |is_guest_view_hack| is true, this view isn't really the view for | 96 // When |is_guest_view_hack| is true, this view isn't really the view for |
139 // the |widget|, a RenderWidgetHostViewGuest is. | 97 // the |widget|, a RenderWidgetHostViewGuest is. |
140 // | 98 // |
141 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated | 99 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated |
142 // to use RWHVChildFrame (http://crbug.com/330264). | 100 // to use RWHVChildFrame (http://crbug.com/330264). |
143 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack); | 101 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack); |
144 | 102 |
145 // RenderWidgetHostView implementation. | 103 // RenderWidgetHostView implementation. |
146 bool OnMessageReceived(const IPC::Message& msg) override; | 104 bool OnMessageReceived(const IPC::Message& msg) override; |
147 void InitAsChild(gfx::NativeView parent_view) override; | 105 void InitAsChild(gfx::NativeView parent_view) override; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // Method to indicate if this instance is shutting down or closing. | 295 // Method to indicate if this instance is shutting down or closing. |
338 // TODO(shrikant): Discuss around to see if it makes sense to add this method | 296 // TODO(shrikant): Discuss around to see if it makes sense to add this method |
339 // as part of RenderWidgetHostView. | 297 // as part of RenderWidgetHostView. |
340 bool IsClosing() const { return in_shutdown_; } | 298 bool IsClosing() const { return in_shutdown_; } |
341 | 299 |
342 // Sets whether the overscroll controller should be enabled for this page. | 300 // Sets whether the overscroll controller should be enabled for this page. |
343 void SetOverscrollControllerEnabled(bool enabled); | 301 void SetOverscrollControllerEnabled(bool enabled); |
344 | 302 |
345 void SnapToPhysicalPixelBoundary(); | 303 void SnapToPhysicalPixelBoundary(); |
346 | 304 |
| 305 ui::TouchSelectionController* selection_controller() const { |
| 306 return selection_controller_.get(); |
| 307 } |
| 308 |
| 309 TouchSelectionControllerClientAura* selection_controller_client() const { |
| 310 return selection_controller_client_.get(); |
| 311 } |
| 312 |
347 OverscrollController* overscroll_controller() const { | 313 OverscrollController* overscroll_controller() const { |
348 return overscroll_controller_.get(); | 314 return overscroll_controller_.get(); |
349 } | 315 } |
350 | 316 |
351 // Called when the context menu is about to be displayed. | 317 // Called when the context menu is about to be displayed. |
352 void OnShowContextMenu(); | 318 void OnShowContextMenu(); |
353 | 319 |
| 320 // Used in tests to set a mock client for touch selection controller. It will |
| 321 // create a new touch selection controller for the new client. |
| 322 void SetSelectionControllerClientForTest( |
| 323 scoped_ptr<TouchSelectionControllerClientAura> client); |
| 324 |
354 protected: | 325 protected: |
355 ~RenderWidgetHostViewAura() override; | 326 ~RenderWidgetHostViewAura() override; |
356 | 327 |
357 // Exposed for tests. | 328 // Exposed for tests. |
358 aura::Window* window() { return window_; } | 329 aura::Window* window() { return window_; } |
359 | 330 |
360 DelegatedFrameHost* GetDelegatedFrameHost() const { | 331 DelegatedFrameHost* GetDelegatedFrameHost() const { |
361 return delegated_frame_host_.get(); | 332 return delegated_frame_host_.get(); |
362 } | 333 } |
363 const ui::MotionEventAura& pointer_state() const { return pointer_state_; } | 334 const ui::MotionEventAura& pointer_state() const { return pointer_state_; } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 bool CanRendererHandleEvent(const ui::MouseEvent* event, | 474 bool CanRendererHandleEvent(const ui::MouseEvent* event, |
504 bool mouse_locked, | 475 bool mouse_locked, |
505 bool selection_popup); | 476 bool selection_popup); |
506 | 477 |
507 // Called when the parent window bounds change. | 478 // Called when the parent window bounds change. |
508 void HandleParentBoundsChanged(); | 479 void HandleParentBoundsChanged(); |
509 | 480 |
510 // Called when the parent window hierarchy for our window changes. | 481 // Called when the parent window hierarchy for our window changes. |
511 void ParentHierarchyChanged(); | 482 void ParentHierarchyChanged(); |
512 | 483 |
| 484 // Helper function to be called whenever new selection information is |
| 485 // received. It will update selection controller. |
| 486 void SelectionUpdated(bool is_editable, |
| 487 bool is_empty_text_form_control, |
| 488 const ui::SelectionBound& start, |
| 489 const ui::SelectionBound& end); |
| 490 |
| 491 // Helper function to create a selection controller. |
| 492 void CreateSelectionController(); |
| 493 |
| 494 // Performs gesture handling needed for touch text selection. Sets event as |
| 495 // handled if it should not be further processed. |
| 496 void HandleGestureForTouchSelection(ui::GestureEvent* event); |
| 497 |
513 // The model object. | 498 // The model object. |
514 RenderWidgetHostImpl* host_; | 499 RenderWidgetHostImpl* host_; |
515 | 500 |
516 aura::Window* window_; | 501 aura::Window* window_; |
517 | 502 |
518 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 503 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
519 | 504 |
520 scoped_ptr<WindowObserver> window_observer_; | 505 scoped_ptr<WindowObserver> window_observer_; |
521 | 506 |
522 // Tracks the ancestors of the RWHVA window for window location changes. | 507 // Tracks the ancestors of the RWHVA window for window location changes. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 // exercise. | 625 // exercise. |
641 bool legacy_window_destroyed_; | 626 bool legacy_window_destroyed_; |
642 | 627 |
643 // Set to true when a context menu is being displayed. Reset to false when | 628 // Set to true when a context menu is being displayed. Reset to false when |
644 // a mouse leave is received in this context. | 629 // a mouse leave is received in this context. |
645 bool showing_context_menu_; | 630 bool showing_context_menu_; |
646 #endif | 631 #endif |
647 | 632 |
648 bool has_snapped_to_boundary_; | 633 bool has_snapped_to_boundary_; |
649 | 634 |
650 TouchEditingClient* touch_editing_client_; | 635 scoped_ptr<TouchSelectionControllerClientAura> selection_controller_client_; |
| 636 scoped_ptr<ui::TouchSelectionController> selection_controller_; |
651 | 637 |
652 scoped_ptr<OverscrollController> overscroll_controller_; | 638 scoped_ptr<OverscrollController> overscroll_controller_; |
653 | 639 |
654 // The last scroll offset of the view. | 640 // The last scroll offset of the view. |
655 gfx::Vector2dF last_scroll_offset_; | 641 gfx::Vector2dF last_scroll_offset_; |
656 | 642 |
657 gfx::Insets insets_; | 643 gfx::Insets insets_; |
658 | 644 |
659 std::vector<ui::LatencyInfo> software_latency_info_; | 645 std::vector<ui::LatencyInfo> software_latency_info_; |
660 | 646 |
(...skipping 12 matching lines...) Expand all Loading... |
673 | 659 |
674 BeginFrameObserverProxy begin_frame_observer_proxy_; | 660 BeginFrameObserverProxy begin_frame_observer_proxy_; |
675 | 661 |
676 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_; | 662 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_; |
677 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 663 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
678 }; | 664 }; |
679 | 665 |
680 } // namespace content | 666 } // namespace content |
681 | 667 |
682 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 668 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
OLD | NEW |