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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "content/browser/accessibility/browser_accessibility_manager.h" | 19 #include "content/browser/accessibility/browser_accessibility_manager.h" |
20 #include "content/browser/compositor/delegated_frame_host.h" | 20 #include "content/browser/compositor/delegated_frame_host.h" |
21 #include "content/browser/compositor/image_transport_factory.h" | 21 #include "content/browser/compositor/image_transport_factory.h" |
22 #include "content/browser/compositor/owned_mailbox.h" | 22 #include "content/browser/compositor/owned_mailbox.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/browser/renderer_host/touch_selection_controller_aura.h" |
24 #include "content/common/content_export.h" | 25 #include "content/common/content_export.h" |
25 #include "content/common/cursors/webcursor.h" | 26 #include "content/common/cursors/webcursor.h" |
26 #include "third_party/skia/include/core/SkRegion.h" | 27 #include "third_party/skia/include/core/SkRegion.h" |
27 #include "ui/aura/client/cursor_client_observer.h" | 28 #include "ui/aura/client/cursor_client_observer.h" |
28 #include "ui/aura/client/focus_change_observer.h" | 29 #include "ui/aura/client/focus_change_observer.h" |
29 #include "ui/aura/window_delegate.h" | 30 #include "ui/aura/window_delegate.h" |
30 #include "ui/aura/window_tree_host_observer.h" | 31 #include "ui/aura/window_tree_host_observer.h" |
31 #include "ui/base/ime/text_input_client.h" | 32 #include "ui/base/ime/text_input_client.h" |
32 #include "ui/gfx/display_observer.h" | 33 #include "ui/gfx/display_observer.h" |
33 #include "ui/gfx/insets.h" | 34 #include "ui/gfx/insets.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 : public RenderWidgetHostViewBase, | 80 : public RenderWidgetHostViewBase, |
80 public DelegatedFrameHostClient, | 81 public DelegatedFrameHostClient, |
81 public ui::TextInputClient, | 82 public ui::TextInputClient, |
82 public gfx::DisplayObserver, | 83 public gfx::DisplayObserver, |
83 public aura::WindowTreeHostObserver, | 84 public aura::WindowTreeHostObserver, |
84 public aura::WindowDelegate, | 85 public aura::WindowDelegate, |
85 public aura::client::ActivationDelegate, | 86 public aura::client::ActivationDelegate, |
86 public aura::client::ActivationChangeObserver, | 87 public aura::client::ActivationChangeObserver, |
87 public aura::client::FocusChangeObserver, | 88 public aura::client::FocusChangeObserver, |
88 public aura::client::CursorClientObserver, | 89 public aura::client::CursorClientObserver, |
89 public base::SupportsWeakPtr<RenderWidgetHostViewAura> { | 90 public base::SupportsWeakPtr<RenderWidgetHostViewAura>, |
| 91 public TouchSelectionControllerAuraClient { |
90 public: | 92 public: |
91 // Displays and controls touch editing elements such as selection handles. | |
92 class TouchEditingClient { | |
93 public: | |
94 TouchEditingClient() {} | |
95 | |
96 // Tells the client to start showing touch editing handles. | |
97 virtual void StartTouchEditing() = 0; | |
98 | |
99 // Notifies the client that touch editing is no longer needed. |quick| | |
100 // determines whether the handles should fade out quickly or slowly. | |
101 virtual void EndTouchEditing(bool quick) = 0; | |
102 | |
103 // Notifies the client that the selection bounds need to be updated. | |
104 virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor, | |
105 const gfx::Rect& focus) = 0; | |
106 | |
107 // Notifies the client that the current text input type as changed. | |
108 virtual void OnTextInputTypeChanged(ui::TextInputType type) = 0; | |
109 | |
110 // Notifies the client that an input event is about to be sent to the | |
111 // renderer. Returns true if the client wants to stop event propagation. | |
112 virtual bool HandleInputEvent(const ui::Event* event) = 0; | |
113 | |
114 // Notifies the client that a gesture event ack was received. | |
115 virtual void GestureEventAck(int gesture_event_type) = 0; | |
116 | |
117 // Notifies the client that the fling has ended, so it can activate touch | |
118 // editing if needed. | |
119 virtual void DidStopFlinging() = 0; | |
120 | |
121 // This is called when the view is destroyed, so that the client can | |
122 // perform any necessary clean-up. | |
123 virtual void OnViewDestroyed() = 0; | |
124 | |
125 protected: | |
126 virtual ~TouchEditingClient() {} | |
127 }; | |
128 | |
129 void set_touch_editing_client(TouchEditingClient* client) { | |
130 touch_editing_client_ = client; | |
131 } | |
132 | |
133 // When |is_guest_view_hack| is true, this view isn't really the view for | 93 // When |is_guest_view_hack| is true, this view isn't really the view for |
134 // the |widget|, a RenderWidgetHostViewGuest is. | 94 // the |widget|, a RenderWidgetHostViewGuest is. |
135 // | 95 // |
136 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated | 96 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated |
137 // to use RWHVChildFrame (http://crbug.com/330264). | 97 // to use RWHVChildFrame (http://crbug.com/330264). |
138 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack); | 98 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack); |
139 | 99 |
140 // RenderWidgetHostView implementation. | 100 // RenderWidgetHostView implementation. |
141 bool OnMessageReceived(const IPC::Message& msg) override; | 101 bool OnMessageReceived(const IPC::Message& msg) override; |
142 void InitAsChild(gfx::NativeView parent_view) override; | 102 void InitAsChild(gfx::NativeView parent_view) override; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 bool HasHitTestMask() const override; | 251 bool HasHitTestMask() const override; |
292 void GetHitTestMask(gfx::Path* mask) const override; | 252 void GetHitTestMask(gfx::Path* mask) const override; |
293 | 253 |
294 // Overridden from ui::EventHandler: | 254 // Overridden from ui::EventHandler: |
295 void OnKeyEvent(ui::KeyEvent* event) override; | 255 void OnKeyEvent(ui::KeyEvent* event) override; |
296 void OnMouseEvent(ui::MouseEvent* event) override; | 256 void OnMouseEvent(ui::MouseEvent* event) override; |
297 void OnScrollEvent(ui::ScrollEvent* event) override; | 257 void OnScrollEvent(ui::ScrollEvent* event) override; |
298 void OnTouchEvent(ui::TouchEvent* event) override; | 258 void OnTouchEvent(ui::TouchEvent* event) override; |
299 void OnGestureEvent(ui::GestureEvent* event) override; | 259 void OnGestureEvent(ui::GestureEvent* event) override; |
300 | 260 |
| 261 // Overriden from TouchSelectionControllerAuraClient: |
| 262 virtual float GetDeviceScaleFactor() override; |
| 263 virtual void MoveCaret(const gfx::PointF& position) override; |
| 264 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) override; |
| 265 virtual void SelectBetweenCoordinates(const gfx::PointF& base, |
| 266 const gfx::PointF& extent) override; |
| 267 virtual aura::Window* GetParentWindow() override; |
| 268 virtual bool IsCommandIdEnabled(int command_id) override; |
| 269 virtual void ExecuteCommand(int command_id, int event_flags) override; |
| 270 virtual void OpenContextMenu(const gfx::PointF& point) override; |
| 271 virtual gfx::Rect ConvertRectToScreen(const gfx::RectF& rect) const override; |
| 272 |
301 // Overridden from aura::client::ActivationDelegate: | 273 // Overridden from aura::client::ActivationDelegate: |
302 bool ShouldActivate() const override; | 274 bool ShouldActivate() const override; |
303 | 275 |
304 // Overridden from aura::client::ActivationChangeObserver: | 276 // Overridden from aura::client::ActivationChangeObserver: |
305 void OnWindowActivated(aura::Window* gained_activation, | 277 void OnWindowActivated(aura::Window* gained_activation, |
306 aura::Window* lost_activation) override; | 278 aura::Window* lost_activation) override; |
307 | 279 |
308 // Overridden from aura::client::CursorClientObserver: | 280 // Overridden from aura::client::CursorClientObserver: |
309 void OnCursorVisibilityChanged(bool is_visible) override; | 281 void OnCursorVisibilityChanged(bool is_visible) override; |
310 | 282 |
(...skipping 28 matching lines...) Expand all Loading... |
339 // Method to indicate if this instance is shutting down or closing. | 311 // Method to indicate if this instance is shutting down or closing. |
340 // TODO(shrikant): Discuss around to see if it makes sense to add this method | 312 // TODO(shrikant): Discuss around to see if it makes sense to add this method |
341 // as part of RenderWidgetHostView. | 313 // as part of RenderWidgetHostView. |
342 bool IsClosing() const { return in_shutdown_; } | 314 bool IsClosing() const { return in_shutdown_; } |
343 | 315 |
344 // Sets whether the overscroll controller should be enabled for this page. | 316 // Sets whether the overscroll controller should be enabled for this page. |
345 void SetOverscrollControllerEnabled(bool enabled); | 317 void SetOverscrollControllerEnabled(bool enabled); |
346 | 318 |
347 void SnapToPhysicalPixelBoundary(); | 319 void SnapToPhysicalPixelBoundary(); |
348 | 320 |
| 321 TouchSelectionControllerAura* selection_controller() { |
| 322 return selection_controller_.get(); |
| 323 } |
| 324 |
349 OverscrollController* overscroll_controller() const { | 325 OverscrollController* overscroll_controller() const { |
350 return overscroll_controller_.get(); | 326 return overscroll_controller_.get(); |
351 } | 327 } |
352 | 328 |
353 protected: | 329 protected: |
354 ~RenderWidgetHostViewAura() override; | 330 ~RenderWidgetHostViewAura() override; |
355 | 331 |
356 // Exposed for tests. | 332 // Exposed for tests. |
357 aura::Window* window() { return window_; } | 333 aura::Window* window() { return window_; } |
358 SkColorType PreferredReadbackFormat() override; | 334 SkColorType PreferredReadbackFormat() override; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; | 445 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; |
470 | 446 |
471 // Converts |rect| from screen coordinate to window coordinate. | 447 // Converts |rect| from screen coordinate to window coordinate. |
472 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; | 448 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; |
473 | 449 |
474 // Helper function to set keyboard focus to the main window. | 450 // Helper function to set keyboard focus to the main window. |
475 void SetKeyboardFocus(); | 451 void SetKeyboardFocus(); |
476 | 452 |
477 RenderFrameHostImpl* GetFocusedFrame(); | 453 RenderFrameHostImpl* GetFocusedFrame(); |
478 | 454 |
| 455 // ... |
| 456 void SelectionBoundsUpdated(const cc::ViewportSelectionBound& start, |
| 457 const cc::ViewportSelectionBound& end); |
| 458 |
479 // The model object. | 459 // The model object. |
480 RenderWidgetHostImpl* host_; | 460 RenderWidgetHostImpl* host_; |
481 | 461 |
482 aura::Window* window_; | 462 aura::Window* window_; |
483 | 463 |
484 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 464 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
485 | 465 |
486 scoped_ptr<WindowObserver> window_observer_; | 466 scoped_ptr<WindowObserver> window_observer_; |
487 | 467 |
488 // Are we in the process of closing? Tracked so fullscreen views can avoid | 468 // Are we in the process of closing? Tracked so fullscreen views can avoid |
(...skipping 29 matching lines...) Expand all Loading... |
518 blink::WebTouchEvent touch_event_; | 498 blink::WebTouchEvent touch_event_; |
519 | 499 |
520 // The current text input type. | 500 // The current text input type. |
521 ui::TextInputType text_input_type_; | 501 ui::TextInputType text_input_type_; |
522 // The current text input mode corresponding to HTML5 inputmode attribute. | 502 // The current text input mode corresponding to HTML5 inputmode attribute. |
523 ui::TextInputMode text_input_mode_; | 503 ui::TextInputMode text_input_mode_; |
524 // The current text input flags. | 504 // The current text input flags. |
525 int text_input_flags_; | 505 int text_input_flags_; |
526 bool can_compose_inline_; | 506 bool can_compose_inline_; |
527 | 507 |
528 // Rectangles for the selection anchor and focus. | |
529 gfx::Rect selection_anchor_rect_; | |
530 gfx::Rect selection_focus_rect_; | |
531 | |
532 // The current composition character bounds. | 508 // The current composition character bounds. |
533 std::vector<gfx::Rect> composition_character_bounds_; | 509 std::vector<gfx::Rect> composition_character_bounds_; |
534 | 510 |
535 // Indicates if there is onging composition text. | 511 // Indicates if there is onging composition text. |
536 bool has_composition_text_; | 512 bool has_composition_text_; |
537 | 513 |
538 // Whether return characters should be passed on to the RenderWidgetHostImpl. | 514 // Whether return characters should be passed on to the RenderWidgetHostImpl. |
539 bool accept_return_character_; | 515 bool accept_return_character_; |
540 | 516 |
541 // Current tooltip text. | 517 // Current tooltip text. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 566 |
591 // The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used | 567 // The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used |
592 // for accessibility, as the container for windowless plugins like | 568 // for accessibility, as the container for windowless plugins like |
593 // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads, | 569 // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads, |
594 // etc. | 570 // etc. |
595 content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_; | 571 content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_; |
596 #endif | 572 #endif |
597 | 573 |
598 bool has_snapped_to_boundary_; | 574 bool has_snapped_to_boundary_; |
599 | 575 |
600 TouchEditingClient* touch_editing_client_; | 576 scoped_ptr<TouchSelectionControllerAura> selection_controller_; |
601 | 577 |
602 scoped_ptr<OverscrollController> overscroll_controller_; | 578 scoped_ptr<OverscrollController> overscroll_controller_; |
603 | 579 |
604 // The last scroll offset of the view. | 580 // The last scroll offset of the view. |
605 gfx::Vector2dF last_scroll_offset_; | 581 gfx::Vector2dF last_scroll_offset_; |
606 | 582 |
607 gfx::Insets insets_; | 583 gfx::Insets insets_; |
608 | 584 |
609 std::vector<ui::LatencyInfo> software_latency_info_; | 585 std::vector<ui::LatencyInfo> software_latency_info_; |
610 | 586 |
(...skipping 11 matching lines...) Expand all Loading... |
622 // view, so we can ensure the window hasn't moved between copying from the | 598 // view, so we can ensure the window hasn't moved between copying from the |
623 // compositing surface and showing the disambiguation popup. | 599 // compositing surface and showing the disambiguation popup. |
624 gfx::Vector2dF disambiguation_scroll_offset_; | 600 gfx::Vector2dF disambiguation_scroll_offset_; |
625 | 601 |
626 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 602 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
627 }; | 603 }; |
628 | 604 |
629 } // namespace content | 605 } // namespace content |
630 | 606 |
631 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 607 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
OLD | NEW |