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

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

Issue 1948343002: [reland] Browser Side Text Input State Tracking for OOPIF (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (Code changed during CQ Dry-run) Created 4 years, 6 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_BASE_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 namespace ui { 60 namespace ui {
61 class LatencyInfo; 61 class LatencyInfo;
62 } 62 }
63 63
64 namespace content { 64 namespace content {
65 class BrowserAccessibilityDelegate; 65 class BrowserAccessibilityDelegate;
66 class BrowserAccessibilityManager; 66 class BrowserAccessibilityManager;
67 class RenderWidgetHostViewBaseObserver; 67 class RenderWidgetHostViewBaseObserver;
68 class SyntheticGesture; 68 class SyntheticGesture;
69 class SyntheticGestureTarget; 69 class SyntheticGestureTarget;
70 class TextInputManager;
70 class WebCursor; 71 class WebCursor;
71 struct DidOverscrollParams; 72 struct DidOverscrollParams;
72 struct NativeWebKeyboardEvent; 73 struct NativeWebKeyboardEvent;
73 struct TextInputState; 74 struct TextInputState;
74 75
75 // Basic implementation shared by concrete RenderWidgetHostView subclasses. 76 // Basic implementation shared by concrete RenderWidgetHostView subclasses.
76 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, 77 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
77 public IPC::Listener { 78 public IPC::Listener {
78 public: 79 public:
79 ~RenderWidgetHostViewBase() override; 80 ~RenderWidgetHostViewBase() override;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // the renderer. 123 // the renderer.
123 void DidReceiveRendererFrame(); 124 void DidReceiveRendererFrame();
124 125
125 // Notification that a resize or move session ended on the native widget. 126 // Notification that a resize or move session ended on the native widget.
126 void UpdateScreenInfo(gfx::NativeView view); 127 void UpdateScreenInfo(gfx::NativeView view);
127 128
128 // Tells if the display property (work area/scale factor) has 129 // Tells if the display property (work area/scale factor) has
129 // changed since the last time. 130 // changed since the last time.
130 bool HasDisplayPropertyChanged(gfx::NativeView view); 131 bool HasDisplayPropertyChanged(gfx::NativeView view);
131 132
133 // Called by the TextInputManager to notify the view about being removed from
134 // the list of registered views, i.e., TextInputManager is no longer tracking
135 // TextInputState from this view. The RWHV should reset |text_input_manager_|
136 // to nullptr.
137 void DidUnregisterFromTextInputManager(TextInputManager* text_input_manager);
138
132 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); 139 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr();
133 140
134 //---------------------------------------------------------------------------- 141 //----------------------------------------------------------------------------
135 // The following methods can be overridden by derived classes. 142 // The following methods can be overridden by derived classes.
136 143
137 // Notifies the View that the renderer text selection has changed. 144 // Notifies the View that the renderer text selection has changed.
138 virtual void SelectionChanged(const base::string16& text, 145 virtual void SelectionChanged(const base::string16& text,
139 size_t offset, 146 size_t offset,
140 const gfx::Range& range); 147 const gfx::Range& range);
141 148
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // embedded within the RenderWidgetHostViewBase's Surface to the 245 // embedded within the RenderWidgetHostViewBase's Surface to the
239 // coordinate space of the embedding Surface. Typically this means that a 246 // coordinate space of the embedding Surface. Typically this means that a
240 // point was received from an out-of-process iframe's RenderWidget and needs 247 // point was received from an out-of-process iframe's RenderWidget and needs
241 // to be translated to viewport coordinates for the root RWHV, in which case 248 // to be translated to viewport coordinates for the root RWHV, in which case
242 // this method is called on the root RWHV with the out-of-process iframe's 249 // this method is called on the root RWHV with the out-of-process iframe's
243 // SurfaceId. 250 // SurfaceId.
244 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, 251 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point,
245 cc::SurfaceId original_surface, 252 cc::SurfaceId original_surface,
246 gfx::Point* transformed_point); 253 gfx::Point* transformed_point);
247 254
255 // Updates the state of the input method attached to the view.
256 // TODO(ekaramad): This method will not stay virtual. It will be moved up top
257 // with the other non-virtual methods after TextInputState tracking is fixed
258 // on all platforms (https://crbug.com/578168).
259 virtual void TextInputStateChanged(const TextInputState& text_input_state);
260
248 //---------------------------------------------------------------------------- 261 //----------------------------------------------------------------------------
249 // The following static methods are implemented by each platform. 262 // The following static methods are implemented by each platform.
250 263
251 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); 264 static void GetDefaultScreenInfo(blink::WebScreenInfo* results);
252 265
253 //---------------------------------------------------------------------------- 266 //----------------------------------------------------------------------------
254 // The following pure virtual methods are implemented by derived classes. 267 // The following pure virtual methods are implemented by derived classes.
255 268
256 // Perform all the initialization steps necessary for this object to represent 269 // Perform all the initialization steps necessary for this object to represent
257 // a popup (such as a <select> dropdown), then shows the popup at |pos|. 270 // a popup (such as a <select> dropdown), then shows the popup at |pos|.
258 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, 271 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
259 const gfx::Rect& bounds) = 0; 272 const gfx::Rect& bounds) = 0;
260 273
261 // Perform all the initialization steps necessary for this object to represent 274 // Perform all the initialization steps necessary for this object to represent
262 // a full screen window. 275 // a full screen window.
263 // |reference_host_view| is the view associated with the creating page that 276 // |reference_host_view| is the view associated with the creating page that
264 // helps to position the full screen widget on the correct monitor. 277 // helps to position the full screen widget on the correct monitor.
265 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; 278 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0;
266 279
267 // Sets the cursor to the one associated with the specified cursor_type 280 // Sets the cursor to the one associated with the specified cursor_type
268 virtual void UpdateCursor(const WebCursor& cursor) = 0; 281 virtual void UpdateCursor(const WebCursor& cursor) = 0;
269 282
270 // Indicates whether the page has finished loading. 283 // Indicates whether the page has finished loading.
271 virtual void SetIsLoading(bool is_loading) = 0; 284 virtual void SetIsLoading(bool is_loading) = 0;
272 285
273 // Updates the state of the input method attached to the view.
274 virtual void TextInputStateChanged(const TextInputState& params) = 0;
275
276 // Cancel the ongoing composition of the input method attached to the view. 286 // Cancel the ongoing composition of the input method attached to the view.
277 virtual void ImeCancelComposition() = 0; 287 virtual void ImeCancelComposition() = 0;
278 288
279 // Notifies the View that the renderer has ceased to exist. 289 // Notifies the View that the renderer has ceased to exist.
280 virtual void RenderProcessGone(base::TerminationStatus status, 290 virtual void RenderProcessGone(base::TerminationStatus status,
281 int error_code) = 0; 291 int error_code) = 0;
282 292
283 // Tells the View to destroy itself. 293 // Tells the View to destroy itself.
284 virtual void Destroy() = 0; 294 virtual void Destroy() = 0;
285 295
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // Exposed for testing. 393 // Exposed for testing.
384 virtual bool IsChildFrameForTesting() const; 394 virtual bool IsChildFrameForTesting() const;
385 virtual cc::SurfaceId SurfaceIdForTesting() const; 395 virtual cc::SurfaceId SurfaceIdForTesting() const;
386 396
387 protected: 397 protected:
388 // Interface class only, do not construct. 398 // Interface class only, do not construct.
389 RenderWidgetHostViewBase(); 399 RenderWidgetHostViewBase();
390 400
391 void NotifyObserversAboutShutdown(); 401 void NotifyObserversAboutShutdown();
392 402
403 // Returns a reference to the current instance of TextInputManager. The
404 // reference is obtained from RenderWidgetHostDelegate. The first time a non-
405 // null reference is obtained, its value is cached in |text_input_manager_|
406 // and this view is registered with it. The RWHV will unregister from the
407 // TextInputManager if it is destroyed or if the TextInputManager itself is
408 // destroyed. The unregistration of the RWHV from TextInputManager is
409 // necessary and must be done by explicitly calling
410 // TextInputManager::Unregister.
411 // It is safer to use this method rather than directly dereferencing
412 // |text_input_manager_|.
413 TextInputManager* GetTextInputManager();
414
393 // Whether this view is a popup and what kind of popup it is (select, 415 // Whether this view is a popup and what kind of popup it is (select,
394 // autofill...). 416 // autofill...).
395 blink::WebPopupType popup_type_; 417 blink::WebPopupType popup_type_;
396 418
397 // The background color of the web content. 419 // The background color of the web content.
398 SkColor background_color_; 420 SkColor background_color_;
399 421
400 // While the mouse is locked, the cursor is hidden from the user. Mouse events 422 // While the mouse is locked, the cursor is hidden from the user. Mouse events
401 // are still generated. However, the position they report is the last known 423 // are still generated. However, the position they report is the last known
402 // mouse position just as mouse lock was entered; the movement they report 424 // mouse position just as mouse lock was entered; the movement they report
403 // indicates what the change in position of the mouse would be had it not been 425 // indicates what the change in position of the mouse would be had it not been
404 // locked. 426 // locked.
405 bool mouse_locked_; 427 bool mouse_locked_;
406 428
407 // Whether we are showing a context menu. 429 // Whether we are showing a context menu.
408 bool showing_context_menu_; 430 bool showing_context_menu_;
409 431
410 // A buffer containing the text inside and around the current selection range. 432 // A buffer containing the text inside and around the current selection range.
411 base::string16 selection_text_; 433 base::string16 selection_text_;
412 434
413 // The offset of the text stored in |selection_text_| relative to the start of 435 // The offset of the text stored in |selection_text_| relative to the start of
414 // the web page. 436 // the web page.
415 size_t selection_text_offset_; 437 size_t selection_text_offset_;
416 438
417 // The current selection range relative to the start of the web page. 439 // The current selection range relative to the start of the web page.
418 gfx::Range selection_range_; 440 gfx::Range selection_range_;
419 441
420 protected:
421 // The scale factor of the display the renderer is currently on. 442 // The scale factor of the display the renderer is currently on.
422 float current_device_scale_factor_; 443 float current_device_scale_factor_;
423 444
424 // The orientation of the display the renderer is currently on. 445 // The orientation of the display the renderer is currently on.
425 display::Display::Rotation current_display_rotation_; 446 display::Display::Rotation current_display_rotation_;
426 447
427 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the 448 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the
428 // renderer. 449 // renderer.
429 bool pinch_zoom_enabled_; 450 bool pinch_zoom_enabled_;
430 451
452 // A reference to current TextInputManager instance this RWHV is registered
453 // with. This is initially nullptr until the first time the view calls
454 // GetTextInputManager(). It also becomes nullptr when TextInputManager is
455 // destroyed before the RWHV is destroyed.
456 TextInputManager* text_input_manager_;
457
431 private: 458 private:
432 void FlushInput(); 459 void FlushInput();
433 460
434 gfx::Rect current_display_area_; 461 gfx::Rect current_display_area_;
435 462
436 uint32_t renderer_frame_number_; 463 uint32_t renderer_frame_number_;
437 464
438 base::OneShotTimer flush_input_timer_; 465 base::OneShotTimer flush_input_timer_;
439 466
440 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; 467 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_;
441 468
442 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; 469 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_;
443 470
444 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); 471 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase);
445 }; 472 };
446 473
447 } // namespace content 474 } // namespace content
448 475
449 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ 476 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698