Chromium Code Reviews| 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 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/process/kill.h" | 18 #include "base/process/kill.h" |
| 19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "cc/output/compositor_frame.h" | 21 #include "cc/output/compositor_frame.h" |
| 22 #include "cc/surfaces/surface_id.h" | 22 #include "cc/surfaces/surface_id.h" |
| 23 #include "content/browser/renderer_host/event_with_latency_info.h" | 23 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 24 #include "content/browser/renderer_host/text_input_manager.h" | |
| 24 #include "content/common/content_export.h" | 25 #include "content/common/content_export.h" |
| 25 #include "content/common/input/input_event_ack_state.h" | 26 #include "content/common/input/input_event_ack_state.h" |
| 26 #include "content/public/browser/readback_types.h" | 27 #include "content/public/browser/readback_types.h" |
| 27 #include "content/public/browser/render_widget_host_view.h" | 28 #include "content/public/browser/render_widget_host_view.h" |
| 28 #include "ipc/ipc_listener.h" | 29 #include "ipc/ipc_listener.h" |
| 29 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationType.h" | 30 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationType.h" |
| 30 #include "third_party/WebKit/public/web/WebPopupType.h" | 31 #include "third_party/WebKit/public/web/WebPopupType.h" |
| 31 #include "third_party/WebKit/public/web/WebTextDirection.h" | 32 #include "third_party/WebKit/public/web/WebTextDirection.h" |
| 32 #include "ui/base/ime/text_input_mode.h" | 33 #include "ui/base/ime/text_input_mode.h" |
| 33 #include "ui/base/ime/text_input_type.h" | 34 #include "ui/base/ime/text_input_type.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 struct TextInputState; |
| 73 | 74 |
| 74 // Basic implementation shared by concrete RenderWidgetHostView subclasses. | 75 // Basic implementation shared by concrete RenderWidgetHostView subclasses. |
| 75 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, | 76 class CONTENT_EXPORT RenderWidgetHostViewBase |
| 76 public IPC::Listener { | 77 : public RenderWidgetHostView, |
| 78 public IPC::Listener, | |
| 79 public TextInputManager::Observer { | |
| 77 public: | 80 public: |
| 78 ~RenderWidgetHostViewBase() override; | 81 ~RenderWidgetHostViewBase() override; |
| 79 | 82 |
| 80 float current_device_scale_factor() const { | 83 float current_device_scale_factor() const { |
| 81 return current_device_scale_factor_; | 84 return current_device_scale_factor_; |
| 82 } | 85 } |
| 83 | 86 |
| 84 // RenderWidgetHostView implementation. | 87 // RenderWidgetHostView implementation. |
| 85 void SetBackgroundColor(SkColor color) override; | 88 void SetBackgroundColor(SkColor color) override; |
| 86 void SetBackgroundColorToDefault() final; | 89 void SetBackgroundColorToDefault() final; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 // embedded within the RenderWidgetHostViewBase's Surface to the | 236 // embedded within the RenderWidgetHostViewBase's Surface to the |
| 234 // coordinate space of the embedding Surface. Typically this means that a | 237 // coordinate space of the embedding Surface. Typically this means that a |
| 235 // point was received from an out-of-process iframe's RenderWidget and needs | 238 // point was received from an out-of-process iframe's RenderWidget and needs |
| 236 // to be translated to viewport coordinates for the root RWHV, in which case | 239 // to be translated to viewport coordinates for the root RWHV, in which case |
| 237 // this method is called on the root RWHV with the out-of-process iframe's | 240 // this method is called on the root RWHV with the out-of-process iframe's |
| 238 // SurfaceId. | 241 // SurfaceId. |
| 239 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, | 242 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, |
| 240 cc::SurfaceId original_surface, | 243 cc::SurfaceId original_surface, |
| 241 gfx::Point* transformed_point); | 244 gfx::Point* transformed_point); |
| 242 | 245 |
| 246 // Updates the state of the input method attached to the view. | |
| 247 virtual void TextInputStateChanged(const TextInputState& text_input_state); | |
| 248 | |
| 243 //---------------------------------------------------------------------------- | 249 //---------------------------------------------------------------------------- |
| 244 // The following static methods are implemented by each platform. | 250 // The following static methods are implemented by each platform. |
| 245 | 251 |
| 246 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); | 252 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); |
| 247 | 253 |
| 248 //---------------------------------------------------------------------------- | 254 //---------------------------------------------------------------------------- |
| 249 // The following pure virtual methods are implemented by derived classes. | 255 // The following pure virtual methods are implemented by derived classes. |
| 250 | 256 |
| 251 // Perform all the initialization steps necessary for this object to represent | 257 // Perform all the initialization steps necessary for this object to represent |
| 252 // a popup (such as a <select> dropdown), then shows the popup at |pos|. | 258 // a popup (such as a <select> dropdown), then shows the popup at |pos|. |
| 253 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 259 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
| 254 const gfx::Rect& bounds) = 0; | 260 const gfx::Rect& bounds) = 0; |
| 255 | 261 |
| 256 // Perform all the initialization steps necessary for this object to represent | 262 // Perform all the initialization steps necessary for this object to represent |
| 257 // a full screen window. | 263 // a full screen window. |
| 258 // |reference_host_view| is the view associated with the creating page that | 264 // |reference_host_view| is the view associated with the creating page that |
| 259 // helps to position the full screen widget on the correct monitor. | 265 // helps to position the full screen widget on the correct monitor. |
| 260 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; | 266 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; |
| 261 | 267 |
| 262 // Sets the cursor to the one associated with the specified cursor_type | 268 // Sets the cursor to the one associated with the specified cursor_type |
| 263 virtual void UpdateCursor(const WebCursor& cursor) = 0; | 269 virtual void UpdateCursor(const WebCursor& cursor) = 0; |
| 264 | 270 |
| 265 // Indicates whether the page has finished loading. | 271 // Indicates whether the page has finished loading. |
| 266 virtual void SetIsLoading(bool is_loading) = 0; | 272 virtual void SetIsLoading(bool is_loading) = 0; |
| 267 | 273 |
| 268 // Updates the state of the input method attached to the view. | |
| 269 virtual void TextInputStateChanged(const TextInputState& params) = 0; | |
| 270 | |
| 271 // Cancel the ongoing composition of the input method attached to the view. | 274 // Cancel the ongoing composition of the input method attached to the view. |
| 272 virtual void ImeCancelComposition() = 0; | 275 virtual void ImeCancelComposition() = 0; |
| 273 | 276 |
| 274 // Notifies the View that the renderer has ceased to exist. | 277 // Notifies the View that the renderer has ceased to exist. |
| 275 virtual void RenderProcessGone(base::TerminationStatus status, | 278 virtual void RenderProcessGone(base::TerminationStatus status, |
| 276 int error_code) = 0; | 279 int error_code) = 0; |
| 277 | 280 |
| 278 // Tells the View to destroy itself. | 281 // Tells the View to destroy itself. |
| 279 virtual void Destroy() = 0; | 282 virtual void Destroy() = 0; |
| 280 | 283 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 // Exposed for testing. | 381 // Exposed for testing. |
| 379 virtual bool IsChildFrameForTesting() const; | 382 virtual bool IsChildFrameForTesting() const; |
| 380 virtual cc::SurfaceId SurfaceIdForTesting() const; | 383 virtual cc::SurfaceId SurfaceIdForTesting() const; |
| 381 | 384 |
| 382 protected: | 385 protected: |
| 383 // Interface class only, do not construct. | 386 // Interface class only, do not construct. |
| 384 RenderWidgetHostViewBase(); | 387 RenderWidgetHostViewBase(); |
| 385 | 388 |
| 386 void NotifyObserversAboutShutdown(); | 389 void NotifyObserversAboutShutdown(); |
| 387 | 390 |
| 391 // Returns a reference to the current instance of TextInputManager. If no | |
| 392 // no reference is found, this method tries to obtain one from the RWHD. | |
|
kenrb
2016/05/05 20:26:28
Expand RWHD to RenderWidgetHostDelegate. In this c
EhsanK
2016/05/06 18:23:43
Done.
| |
| 393 // Returns nullptr if no reference exists or obtained. | |
| 394 TextInputManager* GetTextInputManager(); | |
| 395 | |
| 388 // Whether this view is a popup and what kind of popup it is (select, | 396 // Whether this view is a popup and what kind of popup it is (select, |
| 389 // autofill...). | 397 // autofill...). |
| 390 blink::WebPopupType popup_type_; | 398 blink::WebPopupType popup_type_; |
| 391 | 399 |
| 392 // The background color of the web content. | 400 // The background color of the web content. |
| 393 SkColor background_color_; | 401 SkColor background_color_; |
| 394 | 402 |
| 395 // While the mouse is locked, the cursor is hidden from the user. Mouse events | 403 // 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 | 404 // 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 | 405 // 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 | 406 // indicates what the change in position of the mouse would be had it not been |
| 399 // locked. | 407 // locked. |
| 400 bool mouse_locked_; | 408 bool mouse_locked_; |
| 401 | 409 |
| 402 // Whether we are showing a context menu. | 410 // Whether we are showing a context menu. |
| 403 bool showing_context_menu_; | 411 bool showing_context_menu_; |
| 404 | 412 |
| 405 // A buffer containing the text inside and around the current selection range. | 413 // A buffer containing the text inside and around the current selection range. |
| 406 base::string16 selection_text_; | 414 base::string16 selection_text_; |
| 407 | 415 |
| 408 // The offset of the text stored in |selection_text_| relative to the start of | 416 // The offset of the text stored in |selection_text_| relative to the start of |
| 409 // the web page. | 417 // the web page. |
| 410 size_t selection_text_offset_; | 418 size_t selection_text_offset_; |
| 411 | 419 |
| 412 // The current selection range relative to the start of the web page. | 420 // The current selection range relative to the start of the web page. |
| 413 gfx::Range selection_range_; | 421 gfx::Range selection_range_; |
| 414 | 422 |
| 415 protected: | |
| 416 // The scale factor of the display the renderer is currently on. | 423 // The scale factor of the display the renderer is currently on. |
| 417 float current_device_scale_factor_; | 424 float current_device_scale_factor_; |
| 418 | 425 |
| 419 // The orientation of the display the renderer is currently on. | 426 // The orientation of the display the renderer is currently on. |
| 420 display::Display::Rotation current_display_rotation_; | 427 display::Display::Rotation current_display_rotation_; |
| 421 | 428 |
| 422 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the | 429 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the |
| 423 // renderer. | 430 // renderer. |
| 424 bool pinch_zoom_enabled_; | 431 bool pinch_zoom_enabled_; |
| 425 | 432 |
| 433 // A reference to the TextInputManager belonging to the top-level | |
| 434 // RenderWidgetHostDelegte. | |
| 435 TextInputManager* text_input_manager_; | |
| 436 | |
| 426 private: | 437 private: |
| 427 void FlushInput(); | 438 void FlushInput(); |
| 428 | 439 |
| 440 // TextInputManager::Observer overrides. | |
| 441 void OnTextInputManagerDestroyed( | |
| 442 TextInputManager* text_input_manager) override; | |
|
kenrb
2016/05/05 20:26:28
Why is this public in the base class but private h
EhsanK
2016/05/06 18:23:43
Actually, no good reason. I noticed RenderWidgetHo
| |
| 443 | |
| 429 gfx::Rect current_display_area_; | 444 gfx::Rect current_display_area_; |
| 430 | 445 |
| 431 uint32_t renderer_frame_number_; | 446 uint32_t renderer_frame_number_; |
| 432 | 447 |
| 433 base::OneShotTimer flush_input_timer_; | 448 base::OneShotTimer flush_input_timer_; |
| 434 | 449 |
| 435 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; | 450 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; |
| 436 | 451 |
| 437 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; | 452 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; |
| 438 | 453 |
| 439 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); | 454 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); |
| 440 }; | 455 }; |
| 441 | 456 |
| 442 } // namespace content | 457 } // namespace content |
| 443 | 458 |
| 444 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ | 459 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ |
| OLD | NEW |