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; |
44 | 45 |
45 namespace media { | 46 namespace media { |
46 class VideoFrame; | 47 class VideoFrame; |
47 } | 48 } |
48 | 49 |
49 namespace blink { | 50 namespace blink { |
50 struct WebScreenInfo; | 51 struct WebScreenInfo; |
51 class WebMouseEvent; | 52 class WebMouseEvent; |
52 class WebMouseWheelEvent; | 53 class WebMouseWheelEvent; |
53 } | 54 } |
54 | 55 |
55 namespace cc { | 56 namespace cc { |
56 class SurfaceHittestDelegate; | 57 class SurfaceHittestDelegate; |
57 } | 58 } |
58 | 59 |
59 namespace ui { | 60 namespace ui { |
60 class LatencyInfo; | 61 class LatencyInfo; |
61 } | 62 } |
62 | 63 |
63 namespace content { | 64 namespace content { |
64 class BrowserAccessibilityDelegate; | 65 class BrowserAccessibilityDelegate; |
65 class BrowserAccessibilityManager; | 66 class BrowserAccessibilityManager; |
66 class RenderWidgetHostViewBaseObserver; | 67 class RenderWidgetHostViewBaseObserver; |
67 class SyntheticGesture; | 68 class SyntheticGesture; |
68 class SyntheticGestureTarget; | 69 class SyntheticGestureTarget; |
69 class WebCursor; | 70 class WebCursor; |
70 struct DidOverscrollParams; | 71 struct DidOverscrollParams; |
71 struct NativeWebKeyboardEvent; | 72 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 Loading... |
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 | |
145 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); | 129 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); |
146 | 130 |
147 //---------------------------------------------------------------------------- | 131 //---------------------------------------------------------------------------- |
148 // The following methods can be overridden by derived classes. | 132 // The following methods can be overridden by derived classes. |
149 | 133 |
150 // Notifies the View that the renderer text selection has changed. | 134 // Notifies the View that the renderer text selection has changed. |
151 virtual void SelectionChanged(const base::string16& text, | 135 virtual void SelectionChanged(const base::string16& text, |
152 size_t offset, | 136 size_t offset, |
153 const gfx::Range& range); | 137 const gfx::Range& range); |
154 | 138 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // embedded within the RenderWidgetHostViewBase's Surface to the | 233 // embedded within the RenderWidgetHostViewBase's Surface to the |
250 // coordinate space of the embedding Surface. Typically this means that a | 234 // coordinate space of the embedding Surface. Typically this means that a |
251 // point was received from an out-of-process iframe's RenderWidget and needs | 235 // point was received from an out-of-process iframe's RenderWidget and needs |
252 // to be translated to viewport coordinates for the root RWHV, in which case | 236 // to be translated to viewport coordinates for the root RWHV, in which case |
253 // this method is called on the root RWHV with the out-of-process iframe's | 237 // this method is called on the root RWHV with the out-of-process iframe's |
254 // SurfaceId. | 238 // SurfaceId. |
255 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, | 239 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, |
256 cc::SurfaceId original_surface, | 240 cc::SurfaceId original_surface, |
257 gfx::Point* transformed_point); | 241 gfx::Point* transformed_point); |
258 | 242 |
259 // This method is used by the WebContents owning this view to notify the view | |
260 // of a text input change in the tab. This method is called by the | |
261 // WebContentsImpl if the RenderWidgetHostView is a top-level view. The | |
262 // implementation is platform-specific. | |
263 virtual void UpdateInputMethodIfNecessary(bool text_input_state_changed) {} | |
264 | |
265 //---------------------------------------------------------------------------- | 243 //---------------------------------------------------------------------------- |
266 // The following static methods are implemented by each platform. | 244 // The following static methods are implemented by each platform. |
267 | 245 |
268 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); | 246 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); |
269 | 247 |
270 //---------------------------------------------------------------------------- | 248 //---------------------------------------------------------------------------- |
271 // The following pure virtual methods are implemented by derived classes. | 249 // The following pure virtual methods are implemented by derived classes. |
272 | 250 |
273 // Perform all the initialization steps necessary for this object to represent | 251 // Perform all the initialization steps necessary for this object to represent |
274 // a popup (such as a <select> dropdown), then shows the popup at |pos|. | 252 // a popup (such as a <select> dropdown), then shows the popup at |pos|. |
275 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 253 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
276 const gfx::Rect& bounds) = 0; | 254 const gfx::Rect& bounds) = 0; |
277 | 255 |
278 // Perform all the initialization steps necessary for this object to represent | 256 // Perform all the initialization steps necessary for this object to represent |
279 // a full screen window. | 257 // a full screen window. |
280 // |reference_host_view| is the view associated with the creating page that | 258 // |reference_host_view| is the view associated with the creating page that |
281 // helps to position the full screen widget on the correct monitor. | 259 // helps to position the full screen widget on the correct monitor. |
282 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; | 260 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; |
283 | 261 |
284 // Sets the cursor to the one associated with the specified cursor_type | 262 // Sets the cursor to the one associated with the specified cursor_type |
285 virtual void UpdateCursor(const WebCursor& cursor) = 0; | 263 virtual void UpdateCursor(const WebCursor& cursor) = 0; |
286 | 264 |
287 // Indicates whether the page has finished loading. | 265 // Indicates whether the page has finished loading. |
288 virtual void SetIsLoading(bool is_loading) = 0; | 266 virtual void SetIsLoading(bool is_loading) = 0; |
289 | 267 |
| 268 // Updates the state of the input method attached to the view. |
| 269 virtual void TextInputStateChanged( |
| 270 const ViewHostMsg_TextInputState_Params& params) = 0; |
| 271 |
290 // Cancel the ongoing composition of the input method attached to the view. | 272 // Cancel the ongoing composition of the input method attached to the view. |
291 virtual void ImeCancelComposition() = 0; | 273 virtual void ImeCancelComposition() = 0; |
292 | 274 |
293 // Notifies the View that the renderer has ceased to exist. | 275 // Notifies the View that the renderer has ceased to exist. |
294 virtual void RenderProcessGone(base::TerminationStatus status, | 276 virtual void RenderProcessGone(base::TerminationStatus status, |
295 int error_code) = 0; | 277 int error_code) = 0; |
296 | 278 |
297 // Tells the View to destroy itself. | 279 // Tells the View to destroy itself. |
298 virtual void Destroy() = 0; | 280 virtual void Destroy() = 0; |
299 | 281 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // Exposed for testing. | 379 // Exposed for testing. |
398 virtual bool IsChildFrameForTesting() const; | 380 virtual bool IsChildFrameForTesting() const; |
399 virtual cc::SurfaceId SurfaceIdForTesting() const; | 381 virtual cc::SurfaceId SurfaceIdForTesting() const; |
400 | 382 |
401 protected: | 383 protected: |
402 // Interface class only, do not construct. | 384 // Interface class only, do not construct. |
403 RenderWidgetHostViewBase(); | 385 RenderWidgetHostViewBase(); |
404 | 386 |
405 void NotifyObserversAboutShutdown(); | 387 void NotifyObserversAboutShutdown(); |
406 | 388 |
407 // This method should be called by RWHV during destruction or after a crash | |
408 // to make sure WebContents does not hold invalid text input state. | |
409 // TODO(ekaramad): Do we need to call this for top-level RWHV as well? | |
410 void NotifyHostDelegateAboutShutdown(); | |
411 | |
412 // Whether this view is a popup and what kind of popup it is (select, | 389 // Whether this view is a popup and what kind of popup it is (select, |
413 // autofill...). | 390 // autofill...). |
414 blink::WebPopupType popup_type_; | 391 blink::WebPopupType popup_type_; |
415 | 392 |
416 // The background color of the web content. | 393 // The background color of the web content. |
417 SkColor background_color_; | 394 SkColor background_color_; |
418 | 395 |
419 // While the mouse is locked, the cursor is hidden from the user. Mouse events | 396 // While the mouse is locked, the cursor is hidden from the user. Mouse events |
420 // are still generated. However, the position they report is the last known | 397 // are still generated. However, the position they report is the last known |
421 // mouse position just as mouse lock was entered; the movement they report | 398 // mouse position just as mouse lock was entered; the movement they report |
422 // indicates what the change in position of the mouse would be had it not been | 399 // indicates what the change in position of the mouse would be had it not been |
423 // locked. | 400 // locked. |
424 bool mouse_locked_; | 401 bool mouse_locked_; |
425 | 402 |
426 // Whether we are showing a context menu. | 403 // Whether we are showing a context menu. |
427 bool showing_context_menu_; | 404 bool showing_context_menu_; |
428 | 405 |
429 // A buffer containing the text inside and around the current selection range. | 406 // A buffer containing the text inside and around the current selection range. |
430 base::string16 selection_text_; | 407 base::string16 selection_text_; |
431 | 408 |
432 // The offset of the text stored in |selection_text_| relative to the start of | 409 // The offset of the text stored in |selection_text_| relative to the start of |
433 // the web page. | 410 // the web page. |
434 size_t selection_text_offset_; | 411 size_t selection_text_offset_; |
435 | 412 |
436 // The current selection range relative to the start of the web page. | 413 // The current selection range relative to the start of the web page. |
437 gfx::Range selection_range_; | 414 gfx::Range selection_range_; |
438 | 415 |
| 416 protected: |
439 // The scale factor of the display the renderer is currently on. | 417 // The scale factor of the display the renderer is currently on. |
440 float current_device_scale_factor_; | 418 float current_device_scale_factor_; |
441 | 419 |
442 // The orientation of the display the renderer is currently on. | 420 // The orientation of the display the renderer is currently on. |
443 gfx::Display::Rotation current_display_rotation_; | 421 gfx::Display::Rotation current_display_rotation_; |
444 | 422 |
445 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the | 423 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the |
446 // renderer. | 424 // renderer. |
447 bool pinch_zoom_enabled_; | 425 bool pinch_zoom_enabled_; |
448 | 426 |
449 private: | 427 private: |
450 void FlushInput(); | 428 void FlushInput(); |
451 | 429 |
452 gfx::Rect current_display_area_; | 430 gfx::Rect current_display_area_; |
453 | 431 |
454 uint32_t renderer_frame_number_; | 432 uint32_t renderer_frame_number_; |
455 | 433 |
456 base::OneShotTimer flush_input_timer_; | 434 base::OneShotTimer flush_input_timer_; |
457 | 435 |
458 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; | 436 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; |
459 | 437 |
460 // The last reported input state by the RenderWidget. | |
461 std::unique_ptr<TextInputState> text_input_state_; | |
462 | |
463 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; | 438 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; |
464 | 439 |
465 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); | 440 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); |
466 }; | 441 }; |
467 | 442 |
468 } // namespace content | 443 } // namespace content |
469 | 444 |
470 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ | 445 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ |
OLD | NEW |