OLD | NEW |
---|---|
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 namespace ui { | 59 namespace ui { |
60 class LatencyInfo; | 60 class LatencyInfo; |
61 } | 61 } |
62 | 62 |
63 namespace content { | 63 namespace content { |
64 class BrowserAccessibilityDelegate; | 64 class BrowserAccessibilityDelegate; |
65 class BrowserAccessibilityManager; | 65 class BrowserAccessibilityManager; |
66 class RenderWidgetHostViewBaseObserver; | 66 class RenderWidgetHostViewBaseObserver; |
67 class SyntheticGesture; | 67 class SyntheticGesture; |
68 class SyntheticGestureTarget; | 68 class SyntheticGestureTarget; |
69 class TextInputManager; | |
69 class WebCursor; | 70 class WebCursor; |
70 struct DidOverscrollParams; | 71 struct DidOverscrollParams; |
71 struct NativeWebKeyboardEvent; | 72 struct NativeWebKeyboardEvent; |
72 struct TextInputState; | 73 struct TextInputState; |
73 | 74 |
74 // Basic implementation shared by concrete RenderWidgetHostView subclasses. | 75 // Basic implementation shared by concrete RenderWidgetHostView subclasses. |
75 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, | 76 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, |
76 public IPC::Listener { | 77 public IPC::Listener { |
77 public: | 78 public: |
78 ~RenderWidgetHostViewBase() override; | 79 ~RenderWidgetHostViewBase() override; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // the renderer. | 120 // the renderer. |
120 void DidReceiveRendererFrame(); | 121 void DidReceiveRendererFrame(); |
121 | 122 |
122 // Notification that a resize or move session ended on the native widget. | 123 // Notification that a resize or move session ended on the native widget. |
123 void UpdateScreenInfo(gfx::NativeView view); | 124 void UpdateScreenInfo(gfx::NativeView view); |
124 | 125 |
125 // Tells if the display property (work area/scale factor) has | 126 // Tells if the display property (work area/scale factor) has |
126 // changed since the last time. | 127 // changed since the last time. |
127 bool HasDisplayPropertyChanged(gfx::NativeView view); | 128 bool HasDisplayPropertyChanged(gfx::NativeView view); |
128 | 129 |
130 // Called by the TextInputManager to notify the view about being removed from | |
131 // the list of registered views, i.e., TextInputManager is no longer tracking | |
132 // TextInputState from this view. The RWHV should reset |text_input_manager_| | |
133 // to nullptr. | |
134 void DidUnregisterFromTextInputManager(TextInputManager* text_input_manager); | |
135 | |
129 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); | 136 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); |
130 | 137 |
131 //---------------------------------------------------------------------------- | 138 //---------------------------------------------------------------------------- |
132 // The following methods can be overridden by derived classes. | 139 // The following methods can be overridden by derived classes. |
133 | 140 |
134 // Notifies the View that the renderer text selection has changed. | 141 // Notifies the View that the renderer text selection has changed. |
135 virtual void SelectionChanged(const base::string16& text, | 142 virtual void SelectionChanged(const base::string16& text, |
136 size_t offset, | 143 size_t offset, |
137 const gfx::Range& range); | 144 const gfx::Range& range); |
138 | 145 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // embedded within the RenderWidgetHostViewBase's Surface to the | 240 // embedded within the RenderWidgetHostViewBase's Surface to the |
234 // coordinate space of the embedding Surface. Typically this means that a | 241 // coordinate space of the embedding Surface. Typically this means that a |
235 // point was received from an out-of-process iframe's RenderWidget and needs | 242 // point was received from an out-of-process iframe's RenderWidget and needs |
236 // to be translated to viewport coordinates for the root RWHV, in which case | 243 // to be translated to viewport coordinates for the root RWHV, in which case |
237 // this method is called on the root RWHV with the out-of-process iframe's | 244 // this method is called on the root RWHV with the out-of-process iframe's |
238 // SurfaceId. | 245 // SurfaceId. |
239 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, | 246 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, |
240 cc::SurfaceId original_surface, | 247 cc::SurfaceId original_surface, |
241 gfx::Point* transformed_point); | 248 gfx::Point* transformed_point); |
242 | 249 |
250 // Updates the state of the input method attached to the view. | |
251 virtual void TextInputStateChanged(const TextInputState& text_input_state); | |
252 | |
243 //---------------------------------------------------------------------------- | 253 //---------------------------------------------------------------------------- |
244 // The following static methods are implemented by each platform. | 254 // The following static methods are implemented by each platform. |
245 | 255 |
246 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); | 256 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); |
247 | 257 |
248 //---------------------------------------------------------------------------- | 258 //---------------------------------------------------------------------------- |
249 // The following pure virtual methods are implemented by derived classes. | 259 // The following pure virtual methods are implemented by derived classes. |
250 | 260 |
251 // Perform all the initialization steps necessary for this object to represent | 261 // Perform all the initialization steps necessary for this object to represent |
252 // a popup (such as a <select> dropdown), then shows the popup at |pos|. | 262 // a popup (such as a <select> dropdown), then shows the popup at |pos|. |
253 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 263 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
254 const gfx::Rect& bounds) = 0; | 264 const gfx::Rect& bounds) = 0; |
255 | 265 |
256 // Perform all the initialization steps necessary for this object to represent | 266 // Perform all the initialization steps necessary for this object to represent |
257 // a full screen window. | 267 // a full screen window. |
258 // |reference_host_view| is the view associated with the creating page that | 268 // |reference_host_view| is the view associated with the creating page that |
259 // helps to position the full screen widget on the correct monitor. | 269 // helps to position the full screen widget on the correct monitor. |
260 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; | 270 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; |
261 | 271 |
262 // Sets the cursor to the one associated with the specified cursor_type | 272 // Sets the cursor to the one associated with the specified cursor_type |
263 virtual void UpdateCursor(const WebCursor& cursor) = 0; | 273 virtual void UpdateCursor(const WebCursor& cursor) = 0; |
264 | 274 |
265 // Indicates whether the page has finished loading. | 275 // Indicates whether the page has finished loading. |
266 virtual void SetIsLoading(bool is_loading) = 0; | 276 virtual void SetIsLoading(bool is_loading) = 0; |
267 | 277 |
268 // Updates the state of the input method attached to the view. | |
269 virtual void TextInputStateChanged(const TextInputState& params) = 0; | |
270 | |
271 // Cancel the ongoing composition of the input method attached to the view. | 278 // Cancel the ongoing composition of the input method attached to the view. |
272 virtual void ImeCancelComposition() = 0; | 279 virtual void ImeCancelComposition() = 0; |
273 | 280 |
274 // Notifies the View that the renderer has ceased to exist. | 281 // Notifies the View that the renderer has ceased to exist. |
275 virtual void RenderProcessGone(base::TerminationStatus status, | 282 virtual void RenderProcessGone(base::TerminationStatus status, |
276 int error_code) = 0; | 283 int error_code) = 0; |
277 | 284 |
278 // Tells the View to destroy itself. | 285 // Tells the View to destroy itself. |
279 virtual void Destroy() = 0; | 286 virtual void Destroy() = 0; |
280 | 287 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 // Exposed for testing. | 385 // Exposed for testing. |
379 virtual bool IsChildFrameForTesting() const; | 386 virtual bool IsChildFrameForTesting() const; |
380 virtual cc::SurfaceId SurfaceIdForTesting() const; | 387 virtual cc::SurfaceId SurfaceIdForTesting() const; |
381 | 388 |
382 protected: | 389 protected: |
383 // Interface class only, do not construct. | 390 // Interface class only, do not construct. |
384 RenderWidgetHostViewBase(); | 391 RenderWidgetHostViewBase(); |
385 | 392 |
386 void NotifyObserversAboutShutdown(); | 393 void NotifyObserversAboutShutdown(); |
387 | 394 |
395 // Returns a reference to the current instance of TextInputManager. The | |
396 // reference is obtained from RenderWidgetHostDelegate. The first time a | |
397 // reference is obtained (, which is not nullptr), its value is cached in | |
Charlie Reis
2016/05/26 06:22:04
nit: Commas go before the open paren. Also, you c
EhsanK
2016/05/30 15:06:08
Acknowledged.
| |
398 // |text_input_manager_|. Then this view is registered with TextInputManager | |
399 // (,i.e., the instance |text_input_manager_| referes to). The RWHV will | |
Charlie Reis
2016/05/26 06:22:05
nit: No comma before i.e.
EhsanK
2016/05/30 15:06:08
Done.
| |
400 // unregister from the TextInputManager if it is destroyed or if the | |
401 // TextInputManager itself is destroyed. The unregistration of the RWHV from | |
402 // TextInputManager is necessary and must be done by explicitly calling | |
403 // TextInputManager::Unregister. | |
404 // It is safer to use this method when required rather than dereferencing | |
Charlie Reis
2016/05/26 06:22:04
nit: Drop "when required"
EhsanK
2016/05/30 15:06:08
Done.
| |
405 // |text_input_manager_|. | |
406 TextInputManager* GetTextInputManager(); | |
407 | |
388 // Whether this view is a popup and what kind of popup it is (select, | 408 // Whether this view is a popup and what kind of popup it is (select, |
389 // autofill...). | 409 // autofill...). |
390 blink::WebPopupType popup_type_; | 410 blink::WebPopupType popup_type_; |
391 | 411 |
392 // The background color of the web content. | 412 // The background color of the web content. |
393 SkColor background_color_; | 413 SkColor background_color_; |
394 | 414 |
395 // While the mouse is locked, the cursor is hidden from the user. Mouse events | 415 // While the mouse is locked, the cursor is hidden from the user. Mouse events |
396 // are still generated. However, the position they report is the last known | 416 // are still generated. However, the position they report is the last known |
397 // mouse position just as mouse lock was entered; the movement they report | 417 // mouse position just as mouse lock was entered; the movement they report |
398 // indicates what the change in position of the mouse would be had it not been | 418 // indicates what the change in position of the mouse would be had it not been |
399 // locked. | 419 // locked. |
400 bool mouse_locked_; | 420 bool mouse_locked_; |
401 | 421 |
402 // Whether we are showing a context menu. | 422 // Whether we are showing a context menu. |
403 bool showing_context_menu_; | 423 bool showing_context_menu_; |
404 | 424 |
405 // A buffer containing the text inside and around the current selection range. | 425 // A buffer containing the text inside and around the current selection range. |
406 base::string16 selection_text_; | 426 base::string16 selection_text_; |
407 | 427 |
408 // The offset of the text stored in |selection_text_| relative to the start of | 428 // The offset of the text stored in |selection_text_| relative to the start of |
409 // the web page. | 429 // the web page. |
410 size_t selection_text_offset_; | 430 size_t selection_text_offset_; |
411 | 431 |
412 // The current selection range relative to the start of the web page. | 432 // The current selection range relative to the start of the web page. |
413 gfx::Range selection_range_; | 433 gfx::Range selection_range_; |
414 | 434 |
415 protected: | |
416 // The scale factor of the display the renderer is currently on. | 435 // The scale factor of the display the renderer is currently on. |
417 float current_device_scale_factor_; | 436 float current_device_scale_factor_; |
418 | 437 |
419 // The orientation of the display the renderer is currently on. | 438 // The orientation of the display the renderer is currently on. |
420 display::Display::Rotation current_display_rotation_; | 439 display::Display::Rotation current_display_rotation_; |
421 | 440 |
422 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the | 441 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the |
423 // renderer. | 442 // renderer. |
424 bool pinch_zoom_enabled_; | 443 bool pinch_zoom_enabled_; |
425 | 444 |
445 // A reference to current TextInputManager instance this RWHV is registered | |
446 // with. This is initially nullptr until the first time the view calls | |
447 // GetTextInputManager(). It can also become nullptr if the top-level | |
448 // RenderWidgetHostDelegate owning the TextInputManager is destroyed. | |
Charlie Reis
2016/05/26 06:22:04
Isn't that the WebContents? When does a RenderWid
EhsanK
2016/05/30 15:06:08
As far as I can tell, yes it is.
Charlie Reis
2016/06/02 22:03:28
Acknowledged.
| |
449 TextInputManager* text_input_manager_; | |
450 | |
426 private: | 451 private: |
427 void FlushInput(); | 452 void FlushInput(); |
428 | 453 |
429 gfx::Rect current_display_area_; | 454 gfx::Rect current_display_area_; |
430 | 455 |
431 uint32_t renderer_frame_number_; | 456 uint32_t renderer_frame_number_; |
432 | 457 |
433 base::OneShotTimer flush_input_timer_; | 458 base::OneShotTimer flush_input_timer_; |
434 | 459 |
435 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; | 460 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; |
436 | 461 |
437 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; | 462 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; |
438 | 463 |
439 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); | 464 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); |
440 }; | 465 }; |
441 | 466 |
442 } // namespace content | 467 } // namespace content |
443 | 468 |
444 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ | 469 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ |
OLD | NEW |