 Chromium Code Reviews
 Chromium Code Reviews Issue 698253004:
  Reland: Implement Aura side of unified touch text selection for contents  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 698253004:
  Reland: Implement Aura side of unified touch text selection for contents  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 | 
| 143 // RenderWidgetHostView implementation. | 102 // RenderWidgetHostView implementation. | 
| 144 bool OnMessageReceived(const IPC::Message& msg) override; | 103 bool OnMessageReceived(const IPC::Message& msg) override; | 
| 145 void InitAsChild(gfx::NativeView parent_view) override; | 104 void InitAsChild(gfx::NativeView parent_view) override; | 
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 // Method to indicate if this instance is shutting down or closing. | 304 // Method to indicate if this instance is shutting down or closing. | 
| 346 // TODO(shrikant): Discuss around to see if it makes sense to add this method | 305 // TODO(shrikant): Discuss around to see if it makes sense to add this method | 
| 347 // as part of RenderWidgetHostView. | 306 // as part of RenderWidgetHostView. | 
| 348 bool IsClosing() const { return in_shutdown_; } | 307 bool IsClosing() const { return in_shutdown_; } | 
| 349 | 308 | 
| 350 // Sets whether the overscroll controller should be enabled for this page. | 309 // Sets whether the overscroll controller should be enabled for this page. | 
| 351 void SetOverscrollControllerEnabled(bool enabled); | 310 void SetOverscrollControllerEnabled(bool enabled); | 
| 352 | 311 | 
| 353 void SnapToPhysicalPixelBoundary(); | 312 void SnapToPhysicalPixelBoundary(); | 
| 354 | 313 | 
| 314 void InitSelectionController( | |
| 315 ui::TouchSelectionControllerAuraClient* selection_controller_client); | |
| 
sadrul
2015/03/05 12:37:03
scoped_ptr<> so ownership transfer is clear.
 
mohsen
2015/03/06 23:10:08
Done.
 | |
| 316 | |
| 317 ui::TouchSelectionControllerAura* selection_controller() const { | |
| 318 return selection_controller_.get(); | |
| 319 } | |
| 320 | |
| 355 OverscrollController* overscroll_controller() const { | 321 OverscrollController* overscroll_controller() const { | 
| 356 return overscroll_controller_.get(); | 322 return overscroll_controller_.get(); | 
| 357 } | 323 } | 
| 358 | 324 | 
| 359 protected: | 325 protected: | 
| 360 ~RenderWidgetHostViewAura() override; | 326 ~RenderWidgetHostViewAura() override; | 
| 361 | 327 | 
| 362 // Exposed for tests. | 328 // Exposed for tests. | 
| 363 aura::Window* window() { return window_; } | 329 aura::Window* window() { return window_; } | 
| 364 SkColorType PreferredReadbackFormat() override; | 330 SkColorType PreferredReadbackFormat() override; | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; | 455 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const; | 
| 490 | 456 | 
| 491 // Converts |rect| from screen coordinate to window coordinate. | 457 // Converts |rect| from screen coordinate to window coordinate. | 
| 492 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; | 458 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const; | 
| 493 | 459 | 
| 494 // Helper function to set keyboard focus to the main window. | 460 // Helper function to set keyboard focus to the main window. | 
| 495 void SetKeyboardFocus(); | 461 void SetKeyboardFocus(); | 
| 496 | 462 | 
| 497 RenderFrameHostImpl* GetFocusedFrame(); | 463 RenderFrameHostImpl* GetFocusedFrame(); | 
| 498 | 464 | 
| 465 // Helper function to be called whenever new selection bound information is | |
| 466 // received. It will update selection controller and notify IME. | |
| 467 void SelectionBoundsUpdated(const ui::SelectionBound& start, | |
| 468 const ui::SelectionBound& end); | |
| 469 | |
| 499 // The model object. | 470 // The model object. | 
| 500 RenderWidgetHostImpl* host_; | 471 RenderWidgetHostImpl* host_; | 
| 501 | 472 | 
| 502 aura::Window* window_; | 473 aura::Window* window_; | 
| 503 | 474 | 
| 504 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 475 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 
| 505 | 476 | 
| 506 scoped_ptr<WindowObserver> window_observer_; | 477 scoped_ptr<WindowObserver> window_observer_; | 
| 507 | 478 | 
| 508 // Are we in the process of closing? Tracked so fullscreen views can avoid | 479 // Are we in the process of closing? Tracked so fullscreen views can avoid | 
| (...skipping 29 matching lines...) Expand all Loading... | |
| 538 | 509 | 
| 539 // The current text input type. | 510 // The current text input type. | 
| 540 ui::TextInputType text_input_type_; | 511 ui::TextInputType text_input_type_; | 
| 541 // The current text input mode corresponding to HTML5 inputmode attribute. | 512 // The current text input mode corresponding to HTML5 inputmode attribute. | 
| 542 ui::TextInputMode text_input_mode_; | 513 ui::TextInputMode text_input_mode_; | 
| 543 // The current text input flags. | 514 // The current text input flags. | 
| 544 int text_input_flags_; | 515 int text_input_flags_; | 
| 545 bool can_compose_inline_; | 516 bool can_compose_inline_; | 
| 546 | 517 | 
| 547 // Bounds for the selection. | 518 // Bounds for the selection. | 
| 548 ui::SelectionBound selection_anchor_; | 519 ui::SelectionBound selection_start_; | 
| 549 ui::SelectionBound selection_focus_; | 520 ui::SelectionBound selection_end_; | 
| 550 | 521 | 
| 551 // The current composition character bounds. | 522 // The current composition character bounds. | 
| 552 std::vector<gfx::Rect> composition_character_bounds_; | 523 std::vector<gfx::Rect> composition_character_bounds_; | 
| 553 | 524 | 
| 554 // Indicates if there is onging composition text. | 525 // Indicates if there is onging composition text. | 
| 555 bool has_composition_text_; | 526 bool has_composition_text_; | 
| 556 | 527 | 
| 557 // Whether return characters should be passed on to the RenderWidgetHostImpl. | 528 // Whether return characters should be passed on to the RenderWidgetHostImpl. | 
| 558 bool accept_return_character_; | 529 bool accept_return_character_; | 
| 559 | 530 | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 // Set to true if the legacy_render_widget_host_HWND_ instance was destroyed | 590 // Set to true if the legacy_render_widget_host_HWND_ instance was destroyed | 
| 620 // by Windows. This could happen if the browser window was destroyed by | 591 // by Windows. This could happen if the browser window was destroyed by | 
| 621 // DestroyWindow for e.g. This flag helps ensure that we don't try to create | 592 // DestroyWindow for e.g. This flag helps ensure that we don't try to create | 
| 622 // the LegacyRenderWidgetHostHWND instance again as that would be a futile | 593 // the LegacyRenderWidgetHostHWND instance again as that would be a futile | 
| 623 // exercise. | 594 // exercise. | 
| 624 bool legacy_window_destroyed_; | 595 bool legacy_window_destroyed_; | 
| 625 #endif | 596 #endif | 
| 626 | 597 | 
| 627 bool has_snapped_to_boundary_; | 598 bool has_snapped_to_boundary_; | 
| 628 | 599 | 
| 629 TouchEditingClient* touch_editing_client_; | 600 scoped_ptr<ui::TouchSelectionControllerAuraClient> | 
| 601 selection_controller_client_; | |
| 602 scoped_ptr<ui::TouchSelectionControllerAura> selection_controller_; | |
| 630 | 603 | 
| 631 scoped_ptr<OverscrollController> overscroll_controller_; | 604 scoped_ptr<OverscrollController> overscroll_controller_; | 
| 632 | 605 | 
| 633 // The last scroll offset of the view. | 606 // The last scroll offset of the view. | 
| 634 gfx::Vector2dF last_scroll_offset_; | 607 gfx::Vector2dF last_scroll_offset_; | 
| 635 | 608 | 
| 636 gfx::Insets insets_; | 609 gfx::Insets insets_; | 
| 637 | 610 | 
| 638 std::vector<ui::LatencyInfo> software_latency_info_; | 611 std::vector<ui::LatencyInfo> software_latency_info_; | 
| 639 | 612 | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 650 // compositing surface and showing the disambiguation popup. | 623 // compositing surface and showing the disambiguation popup. | 
| 651 gfx::Vector2dF disambiguation_scroll_offset_; | 624 gfx::Vector2dF disambiguation_scroll_offset_; | 
| 652 | 625 | 
| 653 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_; | 626 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_; | 
| 654 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 627 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 
| 655 }; | 628 }; | 
| 656 | 629 | 
| 657 } // namespace content | 630 } // namespace content | 
| 658 | 631 | 
| 659 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 632 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 
| OLD | NEW |