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