| 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 SelectBetweenCoordinates(const gfx::PointF& start, |
| 265 const gfx::PointF& end) override; |
| 266 virtual aura::Window* GetParentWindow() override; |
| 267 virtual bool IsCommandIdEnabled(int command_id) override; |
| 268 virtual void ExecuteCommand(int command_id, int event_flags) override; |
| 269 virtual void OpenContextMenu(const gfx::PointF& point) override; |
| 270 virtual gfx::Rect ConvertRectToScreen(const gfx::RectF& rect) const override; |
| 271 |
| 301 // Overridden from aura::client::ActivationDelegate: | 272 // Overridden from aura::client::ActivationDelegate: |
| 302 bool ShouldActivate() const override; | 273 bool ShouldActivate() const override; |
| 303 | 274 |
| 304 // Overridden from aura::client::ActivationChangeObserver: | 275 // Overridden from aura::client::ActivationChangeObserver: |
| 305 void OnWindowActivated(aura::Window* gained_activation, | 276 void OnWindowActivated(aura::Window* gained_activation, |
| 306 aura::Window* lost_activation) override; | 277 aura::Window* lost_activation) override; |
| 307 | 278 |
| 308 // Overridden from aura::client::CursorClientObserver: | 279 // Overridden from aura::client::CursorClientObserver: |
| 309 void OnCursorVisibilityChanged(bool is_visible) override; | 280 void OnCursorVisibilityChanged(bool is_visible) override; |
| 310 | 281 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 339 // Method to indicate if this instance is shutting down or closing. | 310 // 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 | 311 // TODO(shrikant): Discuss around to see if it makes sense to add this method |
| 341 // as part of RenderWidgetHostView. | 312 // as part of RenderWidgetHostView. |
| 342 bool IsClosing() const { return in_shutdown_; } | 313 bool IsClosing() const { return in_shutdown_; } |
| 343 | 314 |
| 344 // Sets whether the overscroll controller should be enabled for this page. | 315 // Sets whether the overscroll controller should be enabled for this page. |
| 345 void SetOverscrollControllerEnabled(bool enabled); | 316 void SetOverscrollControllerEnabled(bool enabled); |
| 346 | 317 |
| 347 void SnapToPhysicalPixelBoundary(); | 318 void SnapToPhysicalPixelBoundary(); |
| 348 | 319 |
| 320 TouchSelectionControllerAura* selection_controller() { |
| 321 return selection_controller_.get(); |
| 322 } |
| 323 |
| 349 OverscrollController* overscroll_controller() const { | 324 OverscrollController* overscroll_controller() const { |
| 350 return overscroll_controller_.get(); | 325 return overscroll_controller_.get(); |
| 351 } | 326 } |
| 352 | 327 |
| 353 protected: | 328 protected: |
| 354 ~RenderWidgetHostViewAura() override; | 329 ~RenderWidgetHostViewAura() override; |
| 355 | 330 |
| 356 // Exposed for tests. | 331 // Exposed for tests. |
| 357 aura::Window* window() { return window_; } | 332 aura::Window* window() { return window_; } |
| 358 SkColorType PreferredReadbackFormat() override; | 333 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; | 444 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; |
| 470 | 445 |
| 471 // Converts |rect| from screen coordinate to window coordinate. | 446 // Converts |rect| from screen coordinate to window coordinate. |
| 472 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; | 447 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; |
| 473 | 448 |
| 474 // Helper function to set keyboard focus to the main window. | 449 // Helper function to set keyboard focus to the main window. |
| 475 void SetKeyboardFocus(); | 450 void SetKeyboardFocus(); |
| 476 | 451 |
| 477 RenderFrameHostImpl* GetFocusedFrame(); | 452 RenderFrameHostImpl* GetFocusedFrame(); |
| 478 | 453 |
| 454 // ... |
| 455 void SelectionBoundsUpdated(const cc::ViewportSelectionBound& start, |
| 456 const cc::ViewportSelectionBound& end); |
| 457 |
| 479 // The model object. | 458 // The model object. |
| 480 RenderWidgetHostImpl* host_; | 459 RenderWidgetHostImpl* host_; |
| 481 | 460 |
| 482 aura::Window* window_; | 461 aura::Window* window_; |
| 483 | 462 |
| 484 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 463 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
| 485 | 464 |
| 486 scoped_ptr<WindowObserver> window_observer_; | 465 scoped_ptr<WindowObserver> window_observer_; |
| 487 | 466 |
| 488 // Are we in the process of closing? Tracked so fullscreen views can avoid | 467 // 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_; | 497 blink::WebTouchEvent touch_event_; |
| 519 | 498 |
| 520 // The current text input type. | 499 // The current text input type. |
| 521 ui::TextInputType text_input_type_; | 500 ui::TextInputType text_input_type_; |
| 522 // The current text input mode corresponding to HTML5 inputmode attribute. | 501 // The current text input mode corresponding to HTML5 inputmode attribute. |
| 523 ui::TextInputMode text_input_mode_; | 502 ui::TextInputMode text_input_mode_; |
| 524 // The current text input flags. | 503 // The current text input flags. |
| 525 int text_input_flags_; | 504 int text_input_flags_; |
| 526 bool can_compose_inline_; | 505 bool can_compose_inline_; |
| 527 | 506 |
| 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. | 507 // The current composition character bounds. |
| 533 std::vector<gfx::Rect> composition_character_bounds_; | 508 std::vector<gfx::Rect> composition_character_bounds_; |
| 534 | 509 |
| 535 // Indicates if there is onging composition text. | 510 // Indicates if there is onging composition text. |
| 536 bool has_composition_text_; | 511 bool has_composition_text_; |
| 537 | 512 |
| 538 // Whether return characters should be passed on to the RenderWidgetHostImpl. | 513 // Whether return characters should be passed on to the RenderWidgetHostImpl. |
| 539 bool accept_return_character_; | 514 bool accept_return_character_; |
| 540 | 515 |
| 541 // Current tooltip text. | 516 // Current tooltip text. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 565 |
| 591 // The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used | 566 // The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used |
| 592 // for accessibility, as the container for windowless plugins like | 567 // for accessibility, as the container for windowless plugins like |
| 593 // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads, | 568 // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads, |
| 594 // etc. | 569 // etc. |
| 595 content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_; | 570 content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_; |
| 596 #endif | 571 #endif |
| 597 | 572 |
| 598 bool has_snapped_to_boundary_; | 573 bool has_snapped_to_boundary_; |
| 599 | 574 |
| 600 TouchEditingClient* touch_editing_client_; | 575 scoped_ptr<TouchSelectionControllerAura> selection_controller_; |
| 601 | 576 |
| 602 scoped_ptr<OverscrollController> overscroll_controller_; | 577 scoped_ptr<OverscrollController> overscroll_controller_; |
| 603 | 578 |
| 604 // The last scroll offset of the view. | 579 // The last scroll offset of the view. |
| 605 gfx::Vector2dF last_scroll_offset_; | 580 gfx::Vector2dF last_scroll_offset_; |
| 606 | 581 |
| 607 gfx::Insets insets_; | 582 gfx::Insets insets_; |
| 608 | 583 |
| 609 std::vector<ui::LatencyInfo> software_latency_info_; | 584 std::vector<ui::LatencyInfo> software_latency_info_; |
| 610 | 585 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 622 // view, so we can ensure the window hasn't moved between copying from the | 597 // view, so we can ensure the window hasn't moved between copying from the |
| 623 // compositing surface and showing the disambiguation popup. | 598 // compositing surface and showing the disambiguation popup. |
| 624 gfx::Vector2dF disambiguation_scroll_offset_; | 599 gfx::Vector2dF disambiguation_scroll_offset_; |
| 625 | 600 |
| 626 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 601 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
| 627 }; | 602 }; |
| 628 | 603 |
| 629 } // namespace content | 604 } // namespace content |
| 630 | 605 |
| 631 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 606 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
| OLD | NEW |