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

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

Issue 1652483002: Browser Side Text Input State Tracking for OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged Created 4 years, 8 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 23 matching lines...) Expand all
34 #include "ui/gfx/display.h" 34 #include "ui/gfx/display.h"
35 #include "ui/gfx/geometry/rect.h" 35 #include "ui/gfx/geometry/rect.h"
36 #include "ui/gfx/native_widget_types.h" 36 #include "ui/gfx/native_widget_types.h"
37 #include "ui/gfx/range/range.h" 37 #include "ui/gfx/range/range.h"
38 #include "ui/surface/transport_dib.h" 38 #include "ui/surface/transport_dib.h"
39 39
40 class SkBitmap; 40 class SkBitmap;
41 41
42 struct AccessibilityHostMsg_EventParams; 42 struct AccessibilityHostMsg_EventParams;
43 struct ViewHostMsg_SelectionBounds_Params; 43 struct ViewHostMsg_SelectionBounds_Params;
44 struct ViewHostMsg_TextInputState_Params;
45 44
46 namespace media { 45 namespace media {
47 class VideoFrame; 46 class VideoFrame;
48 } 47 }
49 48
50 namespace blink { 49 namespace blink {
51 struct WebScreenInfo; 50 struct WebScreenInfo;
52 class WebMouseEvent; 51 class WebMouseEvent;
53 class WebMouseWheelEvent; 52 class WebMouseWheelEvent;
54 } 53 }
55 54
56 namespace cc { 55 namespace cc {
57 class SurfaceHittestDelegate; 56 class SurfaceHittestDelegate;
58 } 57 }
59 58
60 namespace ui { 59 namespace ui {
61 class LatencyInfo; 60 class LatencyInfo;
62 } 61 }
63 62
64 namespace content { 63 namespace content {
65 class BrowserAccessibilityDelegate; 64 class BrowserAccessibilityDelegate;
66 class BrowserAccessibilityManager; 65 class BrowserAccessibilityManager;
67 class RenderWidgetHostViewBaseObserver; 66 class RenderWidgetHostViewBaseObserver;
68 class SyntheticGesture; 67 class SyntheticGesture;
69 class SyntheticGestureTarget; 68 class SyntheticGestureTarget;
70 class WebCursor; 69 class WebCursor;
71 struct DidOverscrollParams; 70 struct DidOverscrollParams;
72 struct NativeWebKeyboardEvent; 71 struct NativeWebKeyboardEvent;
72 struct TextInputState;
73 73
74 // Basic implementation shared by concrete RenderWidgetHostView subclasses. 74 // Basic implementation shared by concrete RenderWidgetHostView subclasses.
75 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, 75 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
76 public IPC::Listener { 76 public IPC::Listener {
77 public: 77 public:
78 ~RenderWidgetHostViewBase() override; 78 ~RenderWidgetHostViewBase() override;
79 79
80 float current_device_scale_factor() const { 80 float current_device_scale_factor() const {
81 return current_device_scale_factor_; 81 return current_device_scale_factor_;
82 } 82 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // the renderer. 119 // the renderer.
120 void DidReceiveRendererFrame(); 120 void DidReceiveRendererFrame();
121 121
122 // Notification that a resize or move session ended on the native widget. 122 // Notification that a resize or move session ended on the native widget.
123 void UpdateScreenInfo(gfx::NativeView view); 123 void UpdateScreenInfo(gfx::NativeView view);
124 124
125 // Tells if the display property (work area/scale factor) has 125 // Tells if the display property (work area/scale factor) has
126 // changed since the last time. 126 // changed since the last time.
127 bool HasDisplayPropertyChanged(gfx::NativeView view); 127 bool HasDisplayPropertyChanged(gfx::NativeView view);
128 128
129 // This method is exclusively called by the owner RenderWidgetHost to inform
130 // the view about a change in the input state which originated in the
131 // corresponding RenderWidget. This state is stored at the RWHV.
132 // Also, this change does not necessarily reflect the current state of the
133 // input since the text input could be due to a change in the focused
134 // child-frame's (in OOPIF) or the out of process content managed by
135 // BrowserPlugin.
136 void TextInputStateChanged(const TextInputState& params);
137
138 // The current text input state for the corresponding widget. This is used by
139 // the WebContents in determining the top level text input state, which is
140 // in turn used by the IME.
141 const TextInputState* text_input_state() const {
142 return text_input_state_.get();
143 }
144
129 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); 145 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr();
130 146
131 //---------------------------------------------------------------------------- 147 //----------------------------------------------------------------------------
132 // The following methods can be overridden by derived classes. 148 // The following methods can be overridden by derived classes.
133 149
134 // Notifies the View that the renderer text selection has changed. 150 // Notifies the View that the renderer text selection has changed.
135 virtual void SelectionChanged(const base::string16& text, 151 virtual void SelectionChanged(const base::string16& text,
136 size_t offset, 152 size_t offset,
137 const gfx::Range& range); 153 const gfx::Range& range);
138 154
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // embedded within the RenderWidgetHostViewBase's Surface to the 247 // embedded within the RenderWidgetHostViewBase's Surface to the
232 // coordinate space of the embedding Surface. Typically this means that a 248 // coordinate space of the embedding Surface. Typically this means that a
233 // point was received from an out-of-process iframe's RenderWidget and needs 249 // point was received from an out-of-process iframe's RenderWidget and needs
234 // to be translated to viewport coordinates for the root RWHV, in which case 250 // to be translated to viewport coordinates for the root RWHV, in which case
235 // this method is called on the root RWHV with the out-of-process iframe's 251 // this method is called on the root RWHV with the out-of-process iframe's
236 // SurfaceId. 252 // SurfaceId.
237 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, 253 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point,
238 cc::SurfaceId original_surface, 254 cc::SurfaceId original_surface,
239 gfx::Point* transformed_point); 255 gfx::Point* transformed_point);
240 256
257 // This method is used by the WebContents owning this view to notify the view
258 // of a text input change in the tab. This method is called by the
259 // WebContentsImpl if the RenderWidgetHostView is a top-level view. The
260 // implementation is platform-specific.
261 virtual void UpdateInputMethodIfNecessary(bool text_input_state_changed) {}
262
241 //---------------------------------------------------------------------------- 263 //----------------------------------------------------------------------------
242 // The following static methods are implemented by each platform. 264 // The following static methods are implemented by each platform.
243 265
244 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); 266 static void GetDefaultScreenInfo(blink::WebScreenInfo* results);
245 267
246 //---------------------------------------------------------------------------- 268 //----------------------------------------------------------------------------
247 // The following pure virtual methods are implemented by derived classes. 269 // The following pure virtual methods are implemented by derived classes.
248 270
249 // Perform all the initialization steps necessary for this object to represent 271 // Perform all the initialization steps necessary for this object to represent
250 // a popup (such as a <select> dropdown), then shows the popup at |pos|. 272 // a popup (such as a <select> dropdown), then shows the popup at |pos|.
251 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, 273 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
252 const gfx::Rect& bounds) = 0; 274 const gfx::Rect& bounds) = 0;
253 275
254 // Perform all the initialization steps necessary for this object to represent 276 // Perform all the initialization steps necessary for this object to represent
255 // a full screen window. 277 // a full screen window.
256 // |reference_host_view| is the view associated with the creating page that 278 // |reference_host_view| is the view associated with the creating page that
257 // helps to position the full screen widget on the correct monitor. 279 // helps to position the full screen widget on the correct monitor.
258 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; 280 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0;
259 281
260 // Sets the cursor to the one associated with the specified cursor_type 282 // Sets the cursor to the one associated with the specified cursor_type
261 virtual void UpdateCursor(const WebCursor& cursor) = 0; 283 virtual void UpdateCursor(const WebCursor& cursor) = 0;
262 284
263 // Indicates whether the page has finished loading. 285 // Indicates whether the page has finished loading.
264 virtual void SetIsLoading(bool is_loading) = 0; 286 virtual void SetIsLoading(bool is_loading) = 0;
265 287
266 // Updates the state of the input method attached to the view.
267 virtual void TextInputStateChanged(
268 const ViewHostMsg_TextInputState_Params& params) = 0;
269
270 // Cancel the ongoing composition of the input method attached to the view. 288 // Cancel the ongoing composition of the input method attached to the view.
271 virtual void ImeCancelComposition() = 0; 289 virtual void ImeCancelComposition() = 0;
272 290
273 // Notifies the View that the renderer has ceased to exist. 291 // Notifies the View that the renderer has ceased to exist.
274 virtual void RenderProcessGone(base::TerminationStatus status, 292 virtual void RenderProcessGone(base::TerminationStatus status,
275 int error_code) = 0; 293 int error_code) = 0;
276 294
277 // Tells the View to destroy itself. 295 // Tells the View to destroy itself.
278 virtual void Destroy() = 0; 296 virtual void Destroy() = 0;
279 297
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // Exposed for testing. 395 // Exposed for testing.
378 virtual bool IsChildFrameForTesting() const; 396 virtual bool IsChildFrameForTesting() const;
379 virtual cc::SurfaceId SurfaceIdForTesting() const; 397 virtual cc::SurfaceId SurfaceIdForTesting() const;
380 398
381 protected: 399 protected:
382 // Interface class only, do not construct. 400 // Interface class only, do not construct.
383 RenderWidgetHostViewBase(); 401 RenderWidgetHostViewBase();
384 402
385 void NotifyObserversAboutShutdown(); 403 void NotifyObserversAboutShutdown();
386 404
405 // This method should be called by RWHV during destruction or after a crash
406 // to make sure WebContents does not hold invalid text input state.
407 // TODO(ekaramad): Do we need to call this for top-level RWHV as well?
408 void NotifyHostDelegateAboutShutdown();
409
387 // Whether this view is a popup and what kind of popup it is (select, 410 // Whether this view is a popup and what kind of popup it is (select,
388 // autofill...). 411 // autofill...).
389 blink::WebPopupType popup_type_; 412 blink::WebPopupType popup_type_;
390 413
391 // The background color of the web content. 414 // The background color of the web content.
392 SkColor background_color_; 415 SkColor background_color_;
393 416
394 // While the mouse is locked, the cursor is hidden from the user. Mouse events 417 // While the mouse is locked, the cursor is hidden from the user. Mouse events
395 // are still generated. However, the position they report is the last known 418 // are still generated. However, the position they report is the last known
396 // mouse position just as mouse lock was entered; the movement they report 419 // mouse position just as mouse lock was entered; the movement they report
397 // indicates what the change in position of the mouse would be had it not been 420 // indicates what the change in position of the mouse would be had it not been
398 // locked. 421 // locked.
399 bool mouse_locked_; 422 bool mouse_locked_;
400 423
401 // Whether we are showing a context menu. 424 // Whether we are showing a context menu.
402 bool showing_context_menu_; 425 bool showing_context_menu_;
403 426
404 // A buffer containing the text inside and around the current selection range. 427 // A buffer containing the text inside and around the current selection range.
405 base::string16 selection_text_; 428 base::string16 selection_text_;
406 429
407 // The offset of the text stored in |selection_text_| relative to the start of 430 // The offset of the text stored in |selection_text_| relative to the start of
408 // the web page. 431 // the web page.
409 size_t selection_text_offset_; 432 size_t selection_text_offset_;
410 433
411 // The current selection range relative to the start of the web page. 434 // The current selection range relative to the start of the web page.
412 gfx::Range selection_range_; 435 gfx::Range selection_range_;
413 436
414 protected:
415 // The scale factor of the display the renderer is currently on. 437 // The scale factor of the display the renderer is currently on.
416 float current_device_scale_factor_; 438 float current_device_scale_factor_;
417 439
418 // The orientation of the display the renderer is currently on. 440 // The orientation of the display the renderer is currently on.
419 gfx::Display::Rotation current_display_rotation_; 441 gfx::Display::Rotation current_display_rotation_;
420 442
421 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the 443 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the
422 // renderer. 444 // renderer.
423 bool pinch_zoom_enabled_; 445 bool pinch_zoom_enabled_;
424 446
425 private: 447 private:
426 void FlushInput(); 448 void FlushInput();
427 449
428 gfx::Rect current_display_area_; 450 gfx::Rect current_display_area_;
429 451
430 uint32_t renderer_frame_number_; 452 uint32_t renderer_frame_number_;
431 453
432 base::OneShotTimer flush_input_timer_; 454 base::OneShotTimer flush_input_timer_;
433 455
434 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; 456 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_;
435 457
458 // The last reported input state by the RenderWidget.
459 scoped_ptr<TextInputState> text_input_state_;
460
436 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; 461 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_;
437 462
438 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); 463 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase);
439 }; 464 };
440 465
441 } // namespace content 466 } // namespace content
442 467
443 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ 468 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698