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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // Exposed for testing. | 396 // Exposed for testing. |
379 virtual bool IsChildFrameForTesting() const; | 397 virtual bool IsChildFrameForTesting() const; |
380 virtual cc::SurfaceId SurfaceIdForTesting() const; | 398 virtual cc::SurfaceId SurfaceIdForTesting() const; |
381 | 399 |
382 protected: | 400 protected: |
383 // Interface class only, do not construct. | 401 // Interface class only, do not construct. |
384 RenderWidgetHostViewBase(); | 402 RenderWidgetHostViewBase(); |
385 | 403 |
386 void NotifyObserversAboutShutdown(); | 404 void NotifyObserversAboutShutdown(); |
387 | 405 |
| 406 // This method should be called by RWHV during destruction or after a crash |
| 407 // to make sure WebContents does not hold invalid text input state. |
| 408 // TODO(ekaramad): Do we need to call this for top-level RWHV as well? |
| 409 void NotifyHostDelegateAboutShutdown(); |
| 410 |
388 // Whether this view is a popup and what kind of popup it is (select, | 411 // Whether this view is a popup and what kind of popup it is (select, |
389 // autofill...). | 412 // autofill...). |
390 blink::WebPopupType popup_type_; | 413 blink::WebPopupType popup_type_; |
391 | 414 |
392 // The background color of the web content. | 415 // The background color of the web content. |
393 SkColor background_color_; | 416 SkColor background_color_; |
394 | 417 |
395 // While the mouse is locked, the cursor is hidden from the user. Mouse events | 418 // 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 | 419 // 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 | 420 // 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 | 421 // indicates what the change in position of the mouse would be had it not been |
399 // locked. | 422 // locked. |
400 bool mouse_locked_; | 423 bool mouse_locked_; |
401 | 424 |
402 // Whether we are showing a context menu. | 425 // Whether we are showing a context menu. |
403 bool showing_context_menu_; | 426 bool showing_context_menu_; |
404 | 427 |
405 // A buffer containing the text inside and around the current selection range. | 428 // A buffer containing the text inside and around the current selection range. |
406 base::string16 selection_text_; | 429 base::string16 selection_text_; |
407 | 430 |
408 // The offset of the text stored in |selection_text_| relative to the start of | 431 // The offset of the text stored in |selection_text_| relative to the start of |
409 // the web page. | 432 // the web page. |
410 size_t selection_text_offset_; | 433 size_t selection_text_offset_; |
411 | 434 |
412 // The current selection range relative to the start of the web page. | 435 // The current selection range relative to the start of the web page. |
413 gfx::Range selection_range_; | 436 gfx::Range selection_range_; |
414 | 437 |
415 protected: | |
416 // The scale factor of the display the renderer is currently on. | 438 // The scale factor of the display the renderer is currently on. |
417 float current_device_scale_factor_; | 439 float current_device_scale_factor_; |
418 | 440 |
419 // The orientation of the display the renderer is currently on. | 441 // The orientation of the display the renderer is currently on. |
420 gfx::Display::Rotation current_display_rotation_; | 442 gfx::Display::Rotation current_display_rotation_; |
421 | 443 |
422 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the | 444 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the |
423 // renderer. | 445 // renderer. |
424 bool pinch_zoom_enabled_; | 446 bool pinch_zoom_enabled_; |
425 | 447 |
426 private: | 448 private: |
427 void FlushInput(); | 449 void FlushInput(); |
428 | 450 |
429 gfx::Rect current_display_area_; | 451 gfx::Rect current_display_area_; |
430 | 452 |
431 uint32_t renderer_frame_number_; | 453 uint32_t renderer_frame_number_; |
432 | 454 |
433 base::OneShotTimer flush_input_timer_; | 455 base::OneShotTimer flush_input_timer_; |
434 | 456 |
435 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; | 457 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; |
436 | 458 |
| 459 // The last reported input state by the RenderWidget. |
| 460 scoped_ptr<TextInputState> text_input_state_; |
| 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 |