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