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

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: Using the Old Logic for Determining the State Change Created 4 years, 9 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; 44 struct TextInputState;
45 45
46 namespace media { 46 namespace media {
47 class VideoFrame; 47 class VideoFrame;
48 } 48 }
49 49
50 namespace blink { 50 namespace blink {
51 struct WebScreenInfo; 51 struct WebScreenInfo;
52 class WebMouseEvent; 52 class WebMouseEvent;
53 class WebMouseWheelEvent; 53 class WebMouseWheelEvent;
54 } 54 }
55 55
56 namespace cc { 56 namespace cc {
57 class SurfaceHittestDelegate; 57 class SurfaceHittestDelegate;
58 } 58 }
59 59
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 WebCursor; 70 class WebCursor;
71 struct DidOverscrollParams; 71 struct DidOverscrollParams;
72 struct NativeWebKeyboardEvent; 72 struct NativeWebKeyboardEvent;
73 struct TextInputState;
73 struct WebPluginGeometry; 74 struct WebPluginGeometry;
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;
80 81
81 float current_device_scale_factor() const { 82 float current_device_scale_factor() const {
82 return current_device_scale_factor_; 83 return current_device_scale_factor_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // the renderer. 121 // the renderer.
121 void DidReceiveRendererFrame(); 122 void DidReceiveRendererFrame();
122 123
123 // Notification that a resize or move session ended on the native widget. 124 // Notification that a resize or move session ended on the native widget.
124 void UpdateScreenInfo(gfx::NativeView view); 125 void UpdateScreenInfo(gfx::NativeView view);
125 126
126 // Tells if the display property (work area/scale factor) has 127 // Tells if the display property (work area/scale factor) has
127 // changed since the last time. 128 // changed since the last time.
128 bool HasDisplayPropertyChanged(gfx::NativeView view); 129 bool HasDisplayPropertyChanged(gfx::NativeView view);
129 130
131 // Text input state as last reported by the RenderWidget.
132 const TextInputState* text_input_state() const {
133 return text_input_state_.get();
134 }
135
136 // Current (cached) value of text input state. It equals text_input_state()
137 // if this is the RWHV of a child frame. If this is a root RWHV, this value
138 // is the cached value of the last reported text input state by either the
139 // root RenderWidget or the RenderWidget of one of the child frames.
Charlie Reis 2016/03/09 00:09:33 This seems like a confusing method to use correctl
EhsanK 2016/03/14 19:58:08 Thanks for the suggestion. Your point is quite val
140 const TextInputState* current_text_input_state() const {
141 return cached_text_input_state_;
142 }
143
144 bool ShouldProcessTextInputState();
145
130 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); 146 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr();
131 147
132 //---------------------------------------------------------------------------- 148 //----------------------------------------------------------------------------
133 // The following methods can be overridden by derived classes. 149 // The following methods can be overridden by derived classes.
134 150
135 // Notifies the View that the renderer text selection has changed. 151 // Notifies the View that the renderer text selection has changed.
136 virtual void SelectionChanged(const base::string16& text, 152 virtual void SelectionChanged(const base::string16& text,
137 size_t offset, 153 size_t offset,
138 const gfx::Range& range); 154 const gfx::Range& range);
139 155
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // embedded within the RenderWidgetHostViewBase's Surface to the 243 // embedded within the RenderWidgetHostViewBase's Surface to the
228 // coordinate space of the embedding Surface. Typically this means that a 244 // coordinate space of the embedding Surface. Typically this means that a
229 // 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
230 // 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
231 // 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
232 // SurfaceId. 248 // SurfaceId.
233 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, 249 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point,
234 cc::SurfaceId original_surface, 250 cc::SurfaceId original_surface,
235 gfx::Point* transformed_point); 251 gfx::Point* transformed_point);
236 252
253 // This method is excusively called by the owner RenderWidgetHost to inform
254 // the view about a change in the input state which originated in the
255 // corresponding RenderWidget. This state is stored at the RWHV.
256 // Also, this change does not necessarily reflect the current state of the
257 // input since the text input could be due to a change in the focused
258 // child-frame's (in OOPIF) or the out of process content managed by
259 // BrowserPlugin.
260 // TODO(ekaramad): Make this non-virtual if possible.
261 virtual void TextInputStateChanged(const TextInputState& params);
262
263 // Notifies the top level RenderWidgetHostView or the corresponding
264 // ui::InputMethod of a change in text input state in either this RWHV or one
265 // of the child frame's RWHV.
266 virtual void UpdateTextInputState();
267
237 //---------------------------------------------------------------------------- 268 //----------------------------------------------------------------------------
238 // The following static methods are implemented by each platform. 269 // The following static methods are implemented by each platform.
239 270
240 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); 271 static void GetDefaultScreenInfo(blink::WebScreenInfo* results);
241 272
242 //---------------------------------------------------------------------------- 273 //----------------------------------------------------------------------------
243 // The following pure virtual methods are implemented by derived classes. 274 // The following pure virtual methods are implemented by derived classes.
244 275
245 // Perform all the initialization steps necessary for this object to represent 276 // Perform all the initialization steps necessary for this object to represent
246 // a popup (such as a <select> dropdown), then shows the popup at |pos|. 277 // a popup (such as a <select> dropdown), then shows the popup at |pos|.
(...skipping 10 matching lines...) Expand all
257 // |scroll_offset| is the scroll offset of the render view. 288 // |scroll_offset| is the scroll offset of the render view.
258 virtual void MovePluginWindows( 289 virtual void MovePluginWindows(
259 const std::vector<WebPluginGeometry>& moves) = 0; 290 const std::vector<WebPluginGeometry>& moves) = 0;
260 291
261 // Sets the cursor to the one associated with the specified cursor_type 292 // Sets the cursor to the one associated with the specified cursor_type
262 virtual void UpdateCursor(const WebCursor& cursor) = 0; 293 virtual void UpdateCursor(const WebCursor& cursor) = 0;
263 294
264 // Indicates whether the page has finished loading. 295 // Indicates whether the page has finished loading.
265 virtual void SetIsLoading(bool is_loading) = 0; 296 virtual void SetIsLoading(bool is_loading) = 0;
266 297
267 // Updates the state of the input method attached to the view.
268 virtual void TextInputStateChanged(
269 const ViewHostMsg_TextInputState_Params& params) = 0;
270
271 // Cancel the ongoing composition of the input method attached to the view. 298 // Cancel the ongoing composition of the input method attached to the view.
272 virtual void ImeCancelComposition() = 0; 299 virtual void ImeCancelComposition() = 0;
273 300
274 // Notifies the View that the renderer has ceased to exist. 301 // Notifies the View that the renderer has ceased to exist.
275 virtual void RenderProcessGone(base::TerminationStatus status, 302 virtual void RenderProcessGone(base::TerminationStatus status,
276 int error_code) = 0; 303 int error_code) = 0;
277 304
278 // Tells the View to destroy itself. 305 // Tells the View to destroy itself.
279 virtual void Destroy() = 0; 306 virtual void Destroy() = 0;
280 307
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 441
415 static void PaintPluginWindowsHelper( 442 static void PaintPluginWindowsHelper(
416 HWND parent, 443 HWND parent,
417 const gfx::Rect& damaged_screen_rect); 444 const gfx::Rect& damaged_screen_rect);
418 445
419 // Needs to be called before the HWND backing the view goes away to avoid 446 // Needs to be called before the HWND backing the view goes away to avoid
420 // crashes in Windowed plugins. 447 // crashes in Windowed plugins.
421 static void DetachPluginsHelper(HWND parent); 448 static void DetachPluginsHelper(HWND parent);
422 #endif 449 #endif
423 450
451 // Returns the currently focused RWHV.
Charlie Reis 2016/03/09 00:09:33 Maybe it's worth mentioning how this relates to cu
EhsanK 2016/03/14 19:58:08 It is removed now since the whole logic of getting
452 RenderWidgetHostViewBase* GetFocusedView();
453
424 // Whether this view is a popup and what kind of popup it is (select, 454 // Whether this view is a popup and what kind of popup it is (select,
425 // autofill...). 455 // autofill...).
426 blink::WebPopupType popup_type_; 456 blink::WebPopupType popup_type_;
427 457
428 // The background color of the web content. 458 // The background color of the web content.
429 SkColor background_color_; 459 SkColor background_color_;
430 460
431 // While the mouse is locked, the cursor is hidden from the user. Mouse events 461 // While the mouse is locked, the cursor is hidden from the user. Mouse events
432 // are still generated. However, the position they report is the last known 462 // are still generated. However, the position they report is the last known
433 // mouse position just as mouse lock was entered; the movement they report 463 // mouse position just as mouse lock was entered; the movement they report
434 // indicates what the change in position of the mouse would be had it not been 464 // indicates what the change in position of the mouse would be had it not been
435 // locked. 465 // locked.
436 bool mouse_locked_; 466 bool mouse_locked_;
437 467
438 // Whether we are showing a context menu. 468 // Whether we are showing a context menu.
439 bool showing_context_menu_; 469 bool showing_context_menu_;
440 470
441 // A buffer containing the text inside and around the current selection range. 471 // A buffer containing the text inside and around the current selection range.
442 base::string16 selection_text_; 472 base::string16 selection_text_;
443 473
444 // The offset of the text stored in |selection_text_| relative to the start of 474 // The offset of the text stored in |selection_text_| relative to the start of
445 // the web page. 475 // the web page.
446 size_t selection_text_offset_; 476 size_t selection_text_offset_;
447 477
448 // The current selection range relative to the start of the web page. 478 // The current selection range relative to the start of the web page.
449 gfx::Range selection_range_; 479 gfx::Range selection_range_;
450 480
451 protected:
452 // The scale factor of the display the renderer is currently on. 481 // The scale factor of the display the renderer is currently on.
453 float current_device_scale_factor_; 482 float current_device_scale_factor_;
454 483
455 // The orientation of the display the renderer is currently on. 484 // The orientation of the display the renderer is currently on.
456 gfx::Display::Rotation current_display_rotation_; 485 gfx::Display::Rotation current_display_rotation_;
457 486
458 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the 487 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the
459 // renderer. 488 // renderer.
460 bool pinch_zoom_enabled_; 489 bool pinch_zoom_enabled_;
461 490
491 // A cached value for the text input state which is used to avoid successive
492 // calls to GetFocusedView() whenever the text input state is required.
Charlie Reis 2016/03/09 00:09:33 Maybe mention whether this is valid on anything bu
EhsanK 2016/03/14 19:58:08 I guess removing it will make it simpler.
493 const TextInputState* cached_text_input_state_;
494
462 private: 495 private:
463 void FlushInput(); 496 void FlushInput();
464 497
465 gfx::Rect current_display_area_; 498 gfx::Rect current_display_area_;
466 499
467 uint32_t renderer_frame_number_; 500 uint32_t renderer_frame_number_;
468 501
469 base::OneShotTimer flush_input_timer_; 502 base::OneShotTimer flush_input_timer_;
470 503
471 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; 504 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_;
472 505
506 // The last reported input state by the RenderWidget.
507 scoped_ptr<TextInputState> text_input_state_;
508
509 // Whether there are changes in text input state which need further
510 // processing.
511 bool text_input_state_changed_;
512
473 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; 513 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_;
474 514
475 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); 515 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase);
476 }; 516 };
477 517
478 } // namespace content 518 } // namespace content
479 519
480 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ 520 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698