Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.h

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test failures on Mac Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
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/common/content_export.h" 24 #include "content/common/content_export.h"
25 #include "content/common/cursors/webcursor.h" 25 #include "content/common/cursors/webcursor.h"
26 #include "third_party/skia/include/core/SkRegion.h" 26 #include "third_party/skia/include/core/SkRegion.h"
27 #include "ui/aura/client/cursor_client_observer.h" 27 #include "ui/aura/client/cursor_client_observer.h"
28 #include "ui/aura/client/focus_change_observer.h" 28 #include "ui/aura/client/focus_change_observer.h"
29 #include "ui/aura/window_delegate.h" 29 #include "ui/aura/window_delegate.h"
30 #include "ui/aura/window_tree_host_observer.h" 30 #include "ui/aura/window_tree_host_observer.h"
31 #include "ui/base/ime/text_input_client.h" 31 #include "ui/base/ime/text_input_client.h"
32 #include "ui/base/touch/selection_bound.h" 32 #include "ui/base/touch/selection_bound.h"
33 #include "ui/base/touch/touch_editing_controller.h"
34 #include "ui/events/gestures/motion_event_aura.h" 33 #include "ui/events/gestures/motion_event_aura.h"
35 #include "ui/gfx/display_observer.h" 34 #include "ui/gfx/display_observer.h"
36 #include "ui/gfx/geometry/insets.h" 35 #include "ui/gfx/geometry/insets.h"
37 #include "ui/gfx/geometry/rect.h" 36 #include "ui/gfx/geometry/rect.h"
38 #include "ui/wm/public/activation_delegate.h" 37 #include "ui/wm/public/activation_delegate.h"
39 38
40 namespace aura { 39 namespace aura {
41 class WindowTracker; 40 class WindowTracker;
42 namespace client { 41 namespace client {
43 class ScopedTooltipDisabler; 42 class ScopedTooltipDisabler;
(...skipping 13 matching lines...) Expand all
57 56
58 namespace gpu { 57 namespace gpu {
59 struct Mailbox; 58 struct Mailbox;
60 } 59 }
61 60
62 namespace ui { 61 namespace ui {
63 class CompositorLock; 62 class CompositorLock;
64 class InputMethod; 63 class InputMethod;
65 class LocatedEvent; 64 class LocatedEvent;
66 class Texture; 65 class Texture;
66 class TouchSelectionController;
67 class TouchSelectionControllerClient;
67 } 68 }
68 69
69 namespace content { 70 namespace content {
70 #if defined(OS_WIN) 71 #if defined(OS_WIN)
71 class LegacyRenderWidgetHostHWND; 72 class LegacyRenderWidgetHostHWND;
72 #endif 73 #endif
73 74
74 class OverscrollController; 75 class OverscrollController;
75 class RenderFrameHostImpl; 76 class RenderFrameHostImpl;
76 class RenderWidgetHostImpl; 77 class RenderWidgetHostImpl;
77 class RenderWidgetHostView; 78 class RenderWidgetHostView;
78 79
79 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. 80 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
80 class CONTENT_EXPORT RenderWidgetHostViewAura 81 class CONTENT_EXPORT RenderWidgetHostViewAura
81 : public RenderWidgetHostViewBase, 82 : public RenderWidgetHostViewBase,
82 public DelegatedFrameHostClient, 83 public DelegatedFrameHostClient,
83 public ui::TextInputClient, 84 public ui::TextInputClient,
84 public gfx::DisplayObserver, 85 public gfx::DisplayObserver,
85 public aura::WindowTreeHostObserver, 86 public aura::WindowTreeHostObserver,
86 public aura::WindowDelegate, 87 public aura::WindowDelegate,
87 public aura::client::ActivationDelegate, 88 public aura::client::ActivationDelegate,
88 public aura::client::FocusChangeObserver, 89 public aura::client::FocusChangeObserver,
89 public aura::client::CursorClientObserver { 90 public aura::client::CursorClientObserver {
90 public: 91 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(
105 const ui::SelectionBound& anchor,
106 const ui::SelectionBound& focus) = 0;
107
108 // Notifies the client that the current text input type as changed.
109 virtual void OnTextInputTypeChanged(ui::TextInputType type) = 0;
110
111 // Notifies the client that an input event is about to be sent to the
112 // renderer. Returns true if the client wants to stop event propagation.
113 virtual bool HandleInputEvent(const ui::Event* event) = 0;
114
115 // Notifies the client that a gesture event ack was received.
116 virtual void GestureEventAck(int gesture_event_type) = 0;
117
118 // Notifies the client that the fling has ended, so it can activate touch
119 // editing if needed.
120 virtual void DidStopFlinging() = 0;
121
122 // This is called when the view is destroyed, so that the client can
123 // perform any necessary clean-up.
124 virtual void OnViewDestroyed() = 0;
125
126 protected:
127 virtual ~TouchEditingClient() {}
128 };
129
130 void set_touch_editing_client(TouchEditingClient* client) {
131 touch_editing_client_ = client;
132 }
133
134 // When |is_guest_view_hack| is true, this view isn't really the view for 92 // When |is_guest_view_hack| is true, this view isn't really the view for
135 // the |widget|, a RenderWidgetHostViewGuest is. 93 // the |widget|, a RenderWidgetHostViewGuest is.
136 // 94 //
137 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated 95 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated
138 // to use RWHVChildFrame (http://crbug.com/330264). 96 // to use RWHVChildFrame (http://crbug.com/330264).
139 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack); 97 RenderWidgetHostViewAura(RenderWidgetHost* host, bool is_guest_view_hack);
140 98
141 // RenderWidgetHostView implementation. 99 // RenderWidgetHostView implementation.
142 bool OnMessageReceived(const IPC::Message& msg) override; 100 bool OnMessageReceived(const IPC::Message& msg) override;
143 void InitAsChild(gfx::NativeView parent_view) override; 101 void InitAsChild(gfx::NativeView parent_view) override;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 bool HasHitTestMask() const override; 249 bool HasHitTestMask() const override;
292 void GetHitTestMask(gfx::Path* mask) const override; 250 void GetHitTestMask(gfx::Path* mask) const override;
293 251
294 // Overridden from ui::EventHandler: 252 // Overridden from ui::EventHandler:
295 void OnKeyEvent(ui::KeyEvent* event) override; 253 void OnKeyEvent(ui::KeyEvent* event) override;
296 void OnMouseEvent(ui::MouseEvent* event) override; 254 void OnMouseEvent(ui::MouseEvent* event) override;
297 void OnScrollEvent(ui::ScrollEvent* event) override; 255 void OnScrollEvent(ui::ScrollEvent* event) override;
298 void OnTouchEvent(ui::TouchEvent* event) override; 256 void OnTouchEvent(ui::TouchEvent* event) override;
299 void OnGestureEvent(ui::GestureEvent* event) override; 257 void OnGestureEvent(ui::GestureEvent* event) override;
300 258
259 // Performs gesture handling needed for touch text selection. Sets event as
260 // handled if it should not be further processed.
261 void HandleGestureForTouchSelection(ui::GestureEvent* event);
262
301 // Overridden from aura::client::ActivationDelegate: 263 // Overridden from aura::client::ActivationDelegate:
302 bool ShouldActivate() const override; 264 bool ShouldActivate() const override;
303 265
304 // Overridden from aura::client::CursorClientObserver: 266 // Overridden from aura::client::CursorClientObserver:
305 void OnCursorVisibilityChanged(bool is_visible) override; 267 void OnCursorVisibilityChanged(bool is_visible) override;
306 268
307 // Overridden from aura::client::FocusChangeObserver: 269 // Overridden from aura::client::FocusChangeObserver:
308 void OnWindowFocused(aura::Window* gained_focus, 270 void OnWindowFocused(aura::Window* gained_focus,
309 aura::Window* lost_focus) override; 271 aura::Window* lost_focus) override;
310 272
(...skipping 28 matching lines...) Expand all
339 // Method to indicate if this instance is shutting down or closing. 301 // 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 302 // TODO(shrikant): Discuss around to see if it makes sense to add this method
341 // as part of RenderWidgetHostView. 303 // as part of RenderWidgetHostView.
342 bool IsClosing() const { return in_shutdown_; } 304 bool IsClosing() const { return in_shutdown_; }
343 305
344 // Sets whether the overscroll controller should be enabled for this page. 306 // Sets whether the overscroll controller should be enabled for this page.
345 void SetOverscrollControllerEnabled(bool enabled); 307 void SetOverscrollControllerEnabled(bool enabled);
346 308
347 void SnapToPhysicalPixelBoundary(); 309 void SnapToPhysicalPixelBoundary();
348 310
311 void InitSelectionController(scoped_ptr<ui::TouchSelectionControllerClient>
312 selection_controller_client);
313
314 ui::TouchSelectionController* selection_controller() const {
315 return selection_controller_.get();
316 }
317
349 OverscrollController* overscroll_controller() const { 318 OverscrollController* overscroll_controller() const {
350 return overscroll_controller_.get(); 319 return overscroll_controller_.get();
351 } 320 }
352 321
353 // Called when the context menu is about to be displayed. 322 // Called when the context menu is about to be displayed.
354 void OnShowContextMenu(); 323 void OnShowContextMenu();
355 324
356 protected: 325 protected:
357 ~RenderWidgetHostViewAura() override; 326 ~RenderWidgetHostViewAura() override;
358 327
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 bool CanRendererHandleEvent(const ui::MouseEvent* event, 471 bool CanRendererHandleEvent(const ui::MouseEvent* event,
503 bool mouse_locked, 472 bool mouse_locked,
504 bool selection_popup); 473 bool selection_popup);
505 474
506 // Called when the parent window bounds change. 475 // Called when the parent window bounds change.
507 void HandleParentBoundsChanged(); 476 void HandleParentBoundsChanged();
508 477
509 // Called when the parent window hierarchy for our window changes. 478 // Called when the parent window hierarchy for our window changes.
510 void ParentHierarchyChanged(); 479 void ParentHierarchyChanged();
511 480
481 // Helper function to be called whenever new selection information is
482 // received. It will update selection controller and notify IME.
483 void SelectionUpdated(bool is_editable,
484 bool is_empty_text_form_control,
485 const ui::SelectionBound& start,
486 const ui::SelectionBound& end);
487
512 // The model object. 488 // The model object.
513 RenderWidgetHostImpl* host_; 489 RenderWidgetHostImpl* host_;
514 490
515 aura::Window* window_; 491 aura::Window* window_;
516 492
517 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; 493 scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
518 494
519 scoped_ptr<WindowObserver> window_observer_; 495 scoped_ptr<WindowObserver> window_observer_;
520 496
521 // Tracks the ancestors of the RWHVA window for window location changes. 497 // Tracks the ancestors of the RWHVA window for window location changes.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 530
555 // The current text input type. 531 // The current text input type.
556 ui::TextInputType text_input_type_; 532 ui::TextInputType text_input_type_;
557 // The current text input mode corresponding to HTML5 inputmode attribute. 533 // The current text input mode corresponding to HTML5 inputmode attribute.
558 ui::TextInputMode text_input_mode_; 534 ui::TextInputMode text_input_mode_;
559 // The current text input flags. 535 // The current text input flags.
560 int text_input_flags_; 536 int text_input_flags_;
561 bool can_compose_inline_; 537 bool can_compose_inline_;
562 538
563 // Bounds for the selection. 539 // Bounds for the selection.
564 ui::SelectionBound selection_anchor_; 540 ui::SelectionBound selection_start_;
565 ui::SelectionBound selection_focus_; 541 ui::SelectionBound selection_end_;
566 542
567 // The current composition character bounds. 543 // The current composition character bounds.
568 std::vector<gfx::Rect> composition_character_bounds_; 544 std::vector<gfx::Rect> composition_character_bounds_;
569 545
570 // Indicates if there is onging composition text. 546 // Indicates if there is onging composition text.
571 bool has_composition_text_; 547 bool has_composition_text_;
572 548
573 // Whether return characters should be passed on to the RenderWidgetHostImpl. 549 // Whether return characters should be passed on to the RenderWidgetHostImpl.
574 bool accept_return_character_; 550 bool accept_return_character_;
575 551
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // exercise. 615 // exercise.
640 bool legacy_window_destroyed_; 616 bool legacy_window_destroyed_;
641 617
642 // Set to true when a context menu is being displayed. Reset to false when 618 // Set to true when a context menu is being displayed. Reset to false when
643 // a mouse leave is received in this context. 619 // a mouse leave is received in this context.
644 bool showing_context_menu_; 620 bool showing_context_menu_;
645 #endif 621 #endif
646 622
647 bool has_snapped_to_boundary_; 623 bool has_snapped_to_boundary_;
648 624
649 TouchEditingClient* touch_editing_client_; 625 scoped_ptr<ui::TouchSelectionControllerClient> selection_controller_client_;
626 scoped_ptr<ui::TouchSelectionController> selection_controller_;
650 627
651 scoped_ptr<OverscrollController> overscroll_controller_; 628 scoped_ptr<OverscrollController> overscroll_controller_;
652 629
653 // The last scroll offset of the view. 630 // The last scroll offset of the view.
654 gfx::Vector2dF last_scroll_offset_; 631 gfx::Vector2dF last_scroll_offset_;
655 632
656 gfx::Insets insets_; 633 gfx::Insets insets_;
657 634
658 std::vector<ui::LatencyInfo> software_latency_info_; 635 std::vector<ui::LatencyInfo> software_latency_info_;
659 636
(...skipping 10 matching lines...) Expand all
670 // compositing surface and showing the disambiguation popup. 647 // compositing surface and showing the disambiguation popup.
671 gfx::Vector2dF disambiguation_scroll_offset_; 648 gfx::Vector2dF disambiguation_scroll_offset_;
672 649
673 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_; 650 base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_;
674 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); 651 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura);
675 }; 652 };
676 653
677 } // namespace content 654 } // namespace content
678 655
679 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ 656 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698