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

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: Addressing sky@ comments 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // embedded within the RenderWidgetHostViewBase's Surface to the 243 // embedded within the RenderWidgetHostViewBase's Surface to the
237 // coordinate space of the embedding Surface. Typically this means that a 244 // coordinate space of the embedding Surface. Typically this means that a
238 // point was received from an out-of-process iframe's RenderWidget and needs 245 // point was received from an out-of-process iframe's RenderWidget and needs
239 // to be translated to viewport coordinates for the root RWHV, in which case 246 // to be translated to viewport coordinates for the root RWHV, in which case
240 // this method is called on the root RWHV with the out-of-process iframe's 247 // this method is called on the root RWHV with the out-of-process iframe's
241 // SurfaceId. 248 // SurfaceId.
242 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, 249 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point,
243 cc::SurfaceId original_surface, 250 cc::SurfaceId original_surface,
244 gfx::Point* transformed_point); 251 gfx::Point* transformed_point);
245 252
253 // Updates the state of the input method attached to the view.
254 // TODO(ekaramad): This method will not stay virtual. It will be moved up top
255 // with the other non-virtual methods after TextInputState tracking is fixed
256 // on all platforms (https://crbug.com/578168).
257 virtual void TextInputStateChanged(const TextInputState& text_input_state);
258
246 //---------------------------------------------------------------------------- 259 //----------------------------------------------------------------------------
247 // The following static methods are implemented by each platform. 260 // The following static methods are implemented by each platform.
248 261
249 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); 262 static void GetDefaultScreenInfo(blink::WebScreenInfo* results);
250 263
251 //---------------------------------------------------------------------------- 264 //----------------------------------------------------------------------------
252 // The following pure virtual methods are implemented by derived classes. 265 // The following pure virtual methods are implemented by derived classes.
253 266
254 // Perform all the initialization steps necessary for this object to represent 267 // Perform all the initialization steps necessary for this object to represent
255 // a popup (such as a <select> dropdown), then shows the popup at |pos|. 268 // a popup (such as a <select> dropdown), then shows the popup at |pos|.
256 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, 269 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
257 const gfx::Rect& bounds) = 0; 270 const gfx::Rect& bounds) = 0;
258 271
259 // Perform all the initialization steps necessary for this object to represent 272 // Perform all the initialization steps necessary for this object to represent
260 // a full screen window. 273 // a full screen window.
261 // |reference_host_view| is the view associated with the creating page that 274 // |reference_host_view| is the view associated with the creating page that
262 // helps to position the full screen widget on the correct monitor. 275 // helps to position the full screen widget on the correct monitor.
263 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; 276 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0;
264 277
265 // Sets the cursor to the one associated with the specified cursor_type 278 // Sets the cursor to the one associated with the specified cursor_type
266 virtual void UpdateCursor(const WebCursor& cursor) = 0; 279 virtual void UpdateCursor(const WebCursor& cursor) = 0;
267 280
268 // Indicates whether the page has finished loading. 281 // Indicates whether the page has finished loading.
269 virtual void SetIsLoading(bool is_loading) = 0; 282 virtual void SetIsLoading(bool is_loading) = 0;
270 283
271 // Updates the state of the input method attached to the view.
272 virtual void TextInputStateChanged(const TextInputState& params) = 0;
273
274 // Cancel the ongoing composition of the input method attached to the view. 284 // Cancel the ongoing composition of the input method attached to the view.
275 virtual void ImeCancelComposition() = 0; 285 virtual void ImeCancelComposition() = 0;
276 286
277 // Notifies the View that the renderer has ceased to exist. 287 // Notifies the View that the renderer has ceased to exist.
278 virtual void RenderProcessGone(base::TerminationStatus status, 288 virtual void RenderProcessGone(base::TerminationStatus status,
279 int error_code) = 0; 289 int error_code) = 0;
280 290
281 // Tells the View to destroy itself. 291 // Tells the View to destroy itself.
282 virtual void Destroy() = 0; 292 virtual void Destroy() = 0;
283 293
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // Exposed for testing. 391 // Exposed for testing.
382 virtual bool IsChildFrameForTesting() const; 392 virtual bool IsChildFrameForTesting() const;
383 virtual cc::SurfaceId SurfaceIdForTesting() const; 393 virtual cc::SurfaceId SurfaceIdForTesting() const;
384 394
385 protected: 395 protected:
386 // Interface class only, do not construct. 396 // Interface class only, do not construct.
387 RenderWidgetHostViewBase(); 397 RenderWidgetHostViewBase();
388 398
389 void NotifyObserversAboutShutdown(); 399 void NotifyObserversAboutShutdown();
390 400
401 // Returns a reference to the current instance of TextInputManager. The
402 // reference is obtained from RenderWidgetHostDelegate. The first time a non-
403 // null reference is obtained, its value is cached in |text_input_manager_|
404 // and this view is registered with it. The RWHV will unregister from the
405 // TextInputManager if it is destroyed or if the TextInputManager itself is
406 // destroyed. The unregistration of the RWHV from TextInputManager is
407 // necessary and must be done by explicitly calling
408 // TextInputManager::Unregister.
409 // It is safer to use this method rather than directly dereferencing
410 // |text_input_manager_|.
411 TextInputManager* GetTextInputManager();
412
391 // Whether this view is a popup and what kind of popup it is (select, 413 // Whether this view is a popup and what kind of popup it is (select,
392 // autofill...). 414 // autofill...).
393 blink::WebPopupType popup_type_; 415 blink::WebPopupType popup_type_;
394 416
395 // The background color of the web content. 417 // The background color of the web content.
396 SkColor background_color_; 418 SkColor background_color_;
397 419
398 // While the mouse is locked, the cursor is hidden from the user. Mouse events 420 // While the mouse is locked, the cursor is hidden from the user. Mouse events
399 // are still generated. However, the position they report is the last known 421 // are still generated. However, the position they report is the last known
400 // mouse position just as mouse lock was entered; the movement they report 422 // mouse position just as mouse lock was entered; the movement they report
401 // indicates what the change in position of the mouse would be had it not been 423 // indicates what the change in position of the mouse would be had it not been
402 // locked. 424 // locked.
403 bool mouse_locked_; 425 bool mouse_locked_;
404 426
405 // Whether we are showing a context menu. 427 // Whether we are showing a context menu.
406 bool showing_context_menu_; 428 bool showing_context_menu_;
407 429
408 // A buffer containing the text inside and around the current selection range. 430 // A buffer containing the text inside and around the current selection range.
409 base::string16 selection_text_; 431 base::string16 selection_text_;
410 432
411 // The offset of the text stored in |selection_text_| relative to the start of 433 // The offset of the text stored in |selection_text_| relative to the start of
412 // the web page. 434 // the web page.
413 size_t selection_text_offset_; 435 size_t selection_text_offset_;
414 436
415 // The current selection range relative to the start of the web page. 437 // The current selection range relative to the start of the web page.
416 gfx::Range selection_range_; 438 gfx::Range selection_range_;
417 439
418 protected:
419 // The scale factor of the display the renderer is currently on. 440 // The scale factor of the display the renderer is currently on.
420 float current_device_scale_factor_; 441 float current_device_scale_factor_;
421 442
422 // The orientation of the display the renderer is currently on. 443 // The orientation of the display the renderer is currently on.
423 display::Display::Rotation current_display_rotation_; 444 display::Display::Rotation current_display_rotation_;
424 445
425 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the 446 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the
426 // renderer. 447 // renderer.
427 bool pinch_zoom_enabled_; 448 bool pinch_zoom_enabled_;
428 449
450 // A reference to current TextInputManager instance this RWHV is registered
451 // with. This is initially nullptr until the first time the view calls
452 // GetTextInputManager(). It also becomes nullptr when TextInputManager is
453 // destroyed before the RWHV is destroyed.
454 TextInputManager* text_input_manager_;
455
429 private: 456 private:
430 void FlushInput(); 457 void FlushInput();
431 458
432 gfx::Rect current_display_area_; 459 gfx::Rect current_display_area_;
433 460
434 uint32_t renderer_frame_number_; 461 uint32_t renderer_frame_number_;
435 462
436 base::OneShotTimer flush_input_timer_; 463 base::OneShotTimer flush_input_timer_;
437 464
438 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; 465 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_;
439 466
440 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; 467 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_;
441 468
442 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); 469 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase);
443 }; 470 };
444 471
445 } // namespace content 472 } // namespace content
446 473
447 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ 474 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698