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 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 Loading... | |
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 // The current text input state for the corresponding widget. This is used by | |
132 // the WebContents in determining the top level text input state, which is | |
133 // in turn used by the IME. | |
134 const TextInputState* text_input_state() const { | |
135 return text_input_state_.get(); | |
136 } | |
137 | |
130 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); | 138 base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); |
131 | 139 |
132 //---------------------------------------------------------------------------- | 140 //---------------------------------------------------------------------------- |
133 // The following methods can be overridden by derived classes. | 141 // The following methods can be overridden by derived classes. |
134 | 142 |
135 // Notifies the View that the renderer text selection has changed. | 143 // Notifies the View that the renderer text selection has changed. |
136 virtual void SelectionChanged(const base::string16& text, | 144 virtual void SelectionChanged(const base::string16& text, |
137 size_t offset, | 145 size_t offset, |
138 const gfx::Range& range); | 146 const gfx::Range& range); |
139 | 147 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 // embedded within the RenderWidgetHostViewBase's Surface to the | 237 // embedded within the RenderWidgetHostViewBase's Surface to the |
230 // coordinate space of the embedding Surface. Typically this means that a | 238 // coordinate space of the embedding Surface. Typically this means that a |
231 // point was received from an out-of-process iframe's RenderWidget and needs | 239 // point was received from an out-of-process iframe's RenderWidget and needs |
232 // to be translated to viewport coordinates for the root RWHV, in which case | 240 // to be translated to viewport coordinates for the root RWHV, in which case |
233 // this method is called on the root RWHV with the out-of-process iframe's | 241 // this method is called on the root RWHV with the out-of-process iframe's |
234 // SurfaceId. | 242 // SurfaceId. |
235 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, | 243 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, |
236 cc::SurfaceId original_surface, | 244 cc::SurfaceId original_surface, |
237 gfx::Point* transformed_point); | 245 gfx::Point* transformed_point); |
238 | 246 |
247 // This method is exclusively called by the owner RenderWidgetHost to inform | |
248 // the view about a change in the input state which originated in the | |
249 // corresponding RenderWidget. This state is stored at the RWHV. | |
250 // Also, this change does not necessarily reflect the current state of the | |
251 // input since the text input could be due to a change in the focused | |
252 // child-frame's (in OOPIF) or the out of process content managed by | |
253 // BrowserPlugin. | |
254 // TODO(ekaramad): This method should not stay virtual. | |
255 virtual void TextInputStateChanged(const TextInputState& params); | |
256 | |
257 // This method is used by the WebContents owning this view to notify the view | |
258 // of a text input change in the tab. This method is called by the | |
259 // WebContentsImp if the RenderWidgetHostView is a top-level view. The | |
Charlie Reis
2016/03/16 16:55:13
nit: WebContentsImpl
EhsanK
2016/03/30 20:46:03
Done.
| |
260 // implementation is platform-specific. | |
261 virtual void UpdateInputMethodIfNecessary(bool text_input_state_changed) {} | |
262 | |
239 //---------------------------------------------------------------------------- | 263 //---------------------------------------------------------------------------- |
240 // The following static methods are implemented by each platform. | 264 // The following static methods are implemented by each platform. |
241 | 265 |
242 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); | 266 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); |
243 | 267 |
244 //---------------------------------------------------------------------------- | 268 //---------------------------------------------------------------------------- |
245 // The following pure virtual methods are implemented by derived classes. | 269 // The following pure virtual methods are implemented by derived classes. |
246 | 270 |
247 // Perform all the initialization steps necessary for this object to represent | 271 // Perform all the initialization steps necessary for this object to represent |
248 // a popup (such as a <select> dropdown), then shows the popup at |pos|. | 272 // a popup (such as a <select> dropdown), then shows the popup at |pos|. |
(...skipping 10 matching lines...) Expand all Loading... | |
259 // |scroll_offset| is the scroll offset of the render view. | 283 // |scroll_offset| is the scroll offset of the render view. |
260 virtual void MovePluginWindows( | 284 virtual void MovePluginWindows( |
261 const std::vector<WebPluginGeometry>& moves) = 0; | 285 const std::vector<WebPluginGeometry>& moves) = 0; |
262 | 286 |
263 // Sets the cursor to the one associated with the specified cursor_type | 287 // Sets the cursor to the one associated with the specified cursor_type |
264 virtual void UpdateCursor(const WebCursor& cursor) = 0; | 288 virtual void UpdateCursor(const WebCursor& cursor) = 0; |
265 | 289 |
266 // Indicates whether the page has finished loading. | 290 // Indicates whether the page has finished loading. |
267 virtual void SetIsLoading(bool is_loading) = 0; | 291 virtual void SetIsLoading(bool is_loading) = 0; |
268 | 292 |
269 // Updates the state of the input method attached to the view. | |
270 virtual void TextInputStateChanged( | |
271 const ViewHostMsg_TextInputState_Params& params) = 0; | |
272 | |
273 // Cancel the ongoing composition of the input method attached to the view. | 293 // Cancel the ongoing composition of the input method attached to the view. |
274 virtual void ImeCancelComposition() = 0; | 294 virtual void ImeCancelComposition() = 0; |
275 | 295 |
276 // Notifies the View that the renderer has ceased to exist. | 296 // Notifies the View that the renderer has ceased to exist. |
277 virtual void RenderProcessGone(base::TerminationStatus status, | 297 virtual void RenderProcessGone(base::TerminationStatus status, |
278 int error_code) = 0; | 298 int error_code) = 0; |
279 | 299 |
280 // Tells the View to destroy itself. | 300 // Tells the View to destroy itself. |
281 virtual void Destroy() = 0; | 301 virtual void Destroy() = 0; |
282 | 302 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 | 421 |
402 // Exposed for testing. | 422 // Exposed for testing. |
403 virtual cc::SurfaceId SurfaceIdForTesting() const; | 423 virtual cc::SurfaceId SurfaceIdForTesting() const; |
404 | 424 |
405 protected: | 425 protected: |
406 // Interface class only, do not construct. | 426 // Interface class only, do not construct. |
407 RenderWidgetHostViewBase(); | 427 RenderWidgetHostViewBase(); |
408 | 428 |
409 void NotifyObserversAboutShutdown(); | 429 void NotifyObserversAboutShutdown(); |
410 | 430 |
431 // This method should be called by RWHV during destruction or after a crash | |
432 // to make sure WebContents does not hold invalid text input state. | |
433 // TODO(ekaramad): Do we need to call this for top-level RWHV as well? | |
434 void NotifyHostDelegateAboutShutdown(); | |
435 | |
411 #if defined(OS_WIN) | 436 #if defined(OS_WIN) |
412 // Shared implementation of MovePluginWindows for use by win and aura/wina. | 437 // Shared implementation of MovePluginWindows for use by win and aura/wina. |
413 static void MovePluginWindowsHelper( | 438 static void MovePluginWindowsHelper( |
414 HWND parent, | 439 HWND parent, |
415 const std::vector<WebPluginGeometry>& moves); | 440 const std::vector<WebPluginGeometry>& moves); |
416 | 441 |
417 static void PaintPluginWindowsHelper( | 442 static void PaintPluginWindowsHelper( |
418 HWND parent, | 443 HWND parent, |
419 const gfx::Rect& damaged_screen_rect); | 444 const gfx::Rect& damaged_screen_rect); |
420 | 445 |
(...skipping 22 matching lines...) Expand all Loading... | |
443 // A buffer containing the text inside and around the current selection range. | 468 // A buffer containing the text inside and around the current selection range. |
444 base::string16 selection_text_; | 469 base::string16 selection_text_; |
445 | 470 |
446 // The offset of the text stored in |selection_text_| relative to the start of | 471 // The offset of the text stored in |selection_text_| relative to the start of |
447 // the web page. | 472 // the web page. |
448 size_t selection_text_offset_; | 473 size_t selection_text_offset_; |
449 | 474 |
450 // The current selection range relative to the start of the web page. | 475 // The current selection range relative to the start of the web page. |
451 gfx::Range selection_range_; | 476 gfx::Range selection_range_; |
452 | 477 |
453 protected: | |
454 // The scale factor of the display the renderer is currently on. | 478 // The scale factor of the display the renderer is currently on. |
455 float current_device_scale_factor_; | 479 float current_device_scale_factor_; |
456 | 480 |
457 // The orientation of the display the renderer is currently on. | 481 // The orientation of the display the renderer is currently on. |
458 gfx::Display::Rotation current_display_rotation_; | 482 gfx::Display::Rotation current_display_rotation_; |
459 | 483 |
460 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the | 484 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the |
461 // renderer. | 485 // renderer. |
462 bool pinch_zoom_enabled_; | 486 bool pinch_zoom_enabled_; |
463 | 487 |
464 private: | 488 private: |
465 void FlushInput(); | 489 void FlushInput(); |
466 | 490 |
467 gfx::Rect current_display_area_; | 491 gfx::Rect current_display_area_; |
468 | 492 |
469 uint32_t renderer_frame_number_; | 493 uint32_t renderer_frame_number_; |
470 | 494 |
471 base::OneShotTimer flush_input_timer_; | 495 base::OneShotTimer flush_input_timer_; |
472 | 496 |
473 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; | 497 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; |
474 | 498 |
499 // The last reported input state by the RenderWidget. | |
500 scoped_ptr<TextInputState> text_input_state_; | |
501 | |
475 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; | 502 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; |
476 | 503 |
477 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); | 504 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); |
478 }; | 505 }; |
479 | 506 |
480 } // namespace content | 507 } // namespace content |
481 | 508 |
482 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ | 509 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ |
OLD | NEW |