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 23 matching lines...) Expand all Loading... |
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 struct WebPluginGeometry; | 73 struct WebPluginGeometry; |
74 | 74 |
75 // Basic implementation shared by concrete RenderWidgetHostView subclasses. | 75 // Basic implementation shared by concrete RenderWidgetHostView subclasses. |
76 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, | 76 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, |
77 public IPC::Listener { | 77 public IPC::Listener { |
78 public: | 78 public: |
79 ~RenderWidgetHostViewBase() override; | 79 ~RenderWidgetHostViewBase() override; |
80 | 80 |
81 float current_device_scale_factor() const { | 81 float current_device_scale_factor() const { |
82 return current_device_scale_factor_; | 82 return current_device_scale_factor_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // the renderer. | 120 // the renderer. |
121 void DidReceiveRendererFrame(); | 121 void DidReceiveRendererFrame(); |
122 | 122 |
123 // 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. |
124 void UpdateScreenInfo(gfx::NativeView view); | 124 void UpdateScreenInfo(gfx::NativeView view); |
125 | 125 |
126 // Tells if the display property (work area/scale factor) has | 126 // Tells if the display property (work area/scale factor) has |
127 // changed since the last time. | 127 // changed since the last time. |
128 bool HasDisplayPropertyChanged(gfx::NativeView view); | 128 bool HasDisplayPropertyChanged(gfx::NativeView view); |
129 | 129 |
| 130 // This method is exclusively called by the owner RenderWidgetHost to inform |
| 131 // the view about a change in the input state which originated in the |
| 132 // corresponding RenderWidget. This state is stored at the RWHV. |
| 133 // Also, this change does not necessarily reflect the current state of the |
| 134 // input since the text input could be due to a change in the focused |
| 135 // child-frame's (in OOPIF) or the out of process content managed by |
| 136 // BrowserPlugin. |
| 137 void TextInputStateChanged(const TextInputState& params); |
| 138 |
| 139 // The current text input state for the corresponding widget. This is used by |
| 140 // the WebContents in determining the top level text input state, which is |
| 141 // in turn used by the IME. |
| 142 const TextInputState* text_input_state() const { |
| 143 return text_input_state_.get(); |
| 144 } |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // embedded within the RenderWidgetHostViewBase's Surface to the | 248 // embedded within the RenderWidgetHostViewBase's Surface to the |
233 // coordinate space of the embedding Surface. Typically this means that a | 249 // coordinate space of the embedding Surface. Typically this means that a |
234 // point was received from an out-of-process iframe's RenderWidget and needs | 250 // point was received from an out-of-process iframe's RenderWidget and needs |
235 // to be translated to viewport coordinates for the root RWHV, in which case | 251 // to be translated to viewport coordinates for the root RWHV, in which case |
236 // this method is called on the root RWHV with the out-of-process iframe's | 252 // this method is called on the root RWHV with the out-of-process iframe's |
237 // SurfaceId. | 253 // SurfaceId. |
238 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, | 254 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, |
239 cc::SurfaceId original_surface, | 255 cc::SurfaceId original_surface, |
240 gfx::Point* transformed_point); | 256 gfx::Point* transformed_point); |
241 | 257 |
| 258 // This method is used by the WebContents owning this view to notify the view |
| 259 // of a text input change in the tab. This method is called by the |
| 260 // WebContentsImpl if the RenderWidgetHostView is a top-level view. The |
| 261 // implementation is platform-specific. |
| 262 virtual void UpdateInputMethodIfNecessary(bool text_input_state_changed) {} |
| 263 |
242 //---------------------------------------------------------------------------- | 264 //---------------------------------------------------------------------------- |
243 // The following static methods are implemented by each platform. | 265 // The following static methods are implemented by each platform. |
244 | 266 |
245 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); | 267 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); |
246 | 268 |
247 //---------------------------------------------------------------------------- | 269 //---------------------------------------------------------------------------- |
248 // The following pure virtual methods are implemented by derived classes. | 270 // The following pure virtual methods are implemented by derived classes. |
249 | 271 |
250 // Perform all the initialization steps necessary for this object to represent | 272 // Perform all the initialization steps necessary for this object to represent |
251 // a popup (such as a <select> dropdown), then shows the popup at |pos|. | 273 // a popup (such as a <select> dropdown), then shows the popup at |pos|. |
252 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 274 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
253 const gfx::Rect& bounds) = 0; | 275 const gfx::Rect& bounds) = 0; |
254 | 276 |
255 // Perform all the initialization steps necessary for this object to represent | 277 // Perform all the initialization steps necessary for this object to represent |
256 // a full screen window. | 278 // a full screen window. |
257 // |reference_host_view| is the view associated with the creating page that | 279 // |reference_host_view| is the view associated with the creating page that |
258 // helps to position the full screen widget on the correct monitor. | 280 // helps to position the full screen widget on the correct monitor. |
259 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; | 281 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; |
260 | 282 |
261 // Sets the cursor to the one associated with the specified cursor_type | 283 // Sets the cursor to the one associated with the specified cursor_type |
262 virtual void UpdateCursor(const WebCursor& cursor) = 0; | 284 virtual void UpdateCursor(const WebCursor& cursor) = 0; |
263 | 285 |
264 // Indicates whether the page has finished loading. | 286 // Indicates whether the page has finished loading. |
265 virtual void SetIsLoading(bool is_loading) = 0; | 287 virtual void SetIsLoading(bool is_loading) = 0; |
266 | 288 |
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. | 289 // Cancel the ongoing composition of the input method attached to the view. |
272 virtual void ImeCancelComposition() = 0; | 290 virtual void ImeCancelComposition() = 0; |
273 | 291 |
274 // Notifies the View that the renderer has ceased to exist. | 292 // Notifies the View that the renderer has ceased to exist. |
275 virtual void RenderProcessGone(base::TerminationStatus status, | 293 virtual void RenderProcessGone(base::TerminationStatus status, |
276 int error_code) = 0; | 294 int error_code) = 0; |
277 | 295 |
278 // Tells the View to destroy itself. | 296 // Tells the View to destroy itself. |
279 virtual void Destroy() = 0; | 297 virtual void Destroy() = 0; |
280 | 298 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // Exposed for testing. | 405 // Exposed for testing. |
388 virtual bool IsChildFrameForTesting() const; | 406 virtual bool IsChildFrameForTesting() const; |
389 virtual cc::SurfaceId SurfaceIdForTesting() const; | 407 virtual cc::SurfaceId SurfaceIdForTesting() const; |
390 | 408 |
391 protected: | 409 protected: |
392 // Interface class only, do not construct. | 410 // Interface class only, do not construct. |
393 RenderWidgetHostViewBase(); | 411 RenderWidgetHostViewBase(); |
394 | 412 |
395 void NotifyObserversAboutShutdown(); | 413 void NotifyObserversAboutShutdown(); |
396 | 414 |
| 415 // This method should be called by RWHV during destruction or after a crash |
| 416 // to make sure WebContents does not hold invalid text input state. |
| 417 // TODO(ekaramad): Do we need to call this for top-level RWHV as well? |
| 418 void NotifyHostDelegateAboutShutdown(); |
| 419 |
397 // Whether this view is a popup and what kind of popup it is (select, | 420 // Whether this view is a popup and what kind of popup it is (select, |
398 // autofill...). | 421 // autofill...). |
399 blink::WebPopupType popup_type_; | 422 blink::WebPopupType popup_type_; |
400 | 423 |
401 // The background color of the web content. | 424 // The background color of the web content. |
402 SkColor background_color_; | 425 SkColor background_color_; |
403 | 426 |
404 // While the mouse is locked, the cursor is hidden from the user. Mouse events | 427 // While the mouse is locked, the cursor is hidden from the user. Mouse events |
405 // are still generated. However, the position they report is the last known | 428 // are still generated. However, the position they report is the last known |
406 // mouse position just as mouse lock was entered; the movement they report | 429 // mouse position just as mouse lock was entered; the movement they report |
407 // indicates what the change in position of the mouse would be had it not been | 430 // indicates what the change in position of the mouse would be had it not been |
408 // locked. | 431 // locked. |
409 bool mouse_locked_; | 432 bool mouse_locked_; |
410 | 433 |
411 // Whether we are showing a context menu. | 434 // Whether we are showing a context menu. |
412 bool showing_context_menu_; | 435 bool showing_context_menu_; |
413 | 436 |
414 // A buffer containing the text inside and around the current selection range. | 437 // A buffer containing the text inside and around the current selection range. |
415 base::string16 selection_text_; | 438 base::string16 selection_text_; |
416 | 439 |
417 // The offset of the text stored in |selection_text_| relative to the start of | 440 // The offset of the text stored in |selection_text_| relative to the start of |
418 // the web page. | 441 // the web page. |
419 size_t selection_text_offset_; | 442 size_t selection_text_offset_; |
420 | 443 |
421 // The current selection range relative to the start of the web page. | 444 // The current selection range relative to the start of the web page. |
422 gfx::Range selection_range_; | 445 gfx::Range selection_range_; |
423 | 446 |
424 protected: | |
425 // The scale factor of the display the renderer is currently on. | 447 // The scale factor of the display the renderer is currently on. |
426 float current_device_scale_factor_; | 448 float current_device_scale_factor_; |
427 | 449 |
428 // The orientation of the display the renderer is currently on. | 450 // The orientation of the display the renderer is currently on. |
429 gfx::Display::Rotation current_display_rotation_; | 451 gfx::Display::Rotation current_display_rotation_; |
430 | 452 |
431 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the | 453 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the |
432 // renderer. | 454 // renderer. |
433 bool pinch_zoom_enabled_; | 455 bool pinch_zoom_enabled_; |
434 | 456 |
435 private: | 457 private: |
436 void FlushInput(); | 458 void FlushInput(); |
437 | 459 |
438 gfx::Rect current_display_area_; | 460 gfx::Rect current_display_area_; |
439 | 461 |
440 uint32_t renderer_frame_number_; | 462 uint32_t renderer_frame_number_; |
441 | 463 |
442 base::OneShotTimer flush_input_timer_; | 464 base::OneShotTimer flush_input_timer_; |
443 | 465 |
444 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; | 466 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; |
445 | 467 |
| 468 // The last reported input state by the RenderWidget. |
| 469 scoped_ptr<TextInputState> text_input_state_; |
| 470 |
446 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; | 471 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; |
447 | 472 |
448 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); | 473 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); |
449 }; | 474 }; |
450 | 475 |
451 } // namespace content | 476 } // namespace content |
452 | 477 |
453 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ | 478 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ |
OLD | NEW |