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

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

Powered by Google App Engine
This is Rietveld 408576698