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 25 matching lines...) Expand all Loading... | |
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; |
70 class TextInputManager; | |
69 class WebCursor; | 71 class WebCursor; |
70 struct DidOverscrollParams; | 72 struct DidOverscrollParams; |
71 struct NativeWebKeyboardEvent; | 73 struct NativeWebKeyboardEvent; |
72 struct TextInputState; | 74 struct TextInputState; |
73 | 75 |
74 // Basic implementation shared by concrete RenderWidgetHostView subclasses. | 76 // Basic implementation shared by concrete RenderWidgetHostView subclasses. |
75 class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, | 77 class CONTENT_EXPORT RenderWidgetHostViewBase |
76 public IPC::Listener { | 78 : public RenderWidgetHostView, |
79 public IPC::Listener, | |
80 public TextInputManager::Observer { | |
77 public: | 81 public: |
78 ~RenderWidgetHostViewBase() override; | 82 ~RenderWidgetHostViewBase() override; |
79 | 83 |
80 float current_device_scale_factor() const { | 84 float current_device_scale_factor() const { |
81 return current_device_scale_factor_; | 85 return current_device_scale_factor_; |
82 } | 86 } |
83 | 87 |
84 // RenderWidgetHostView implementation. | 88 // RenderWidgetHostView implementation. |
85 void SetBackgroundColor(SkColor color) override; | 89 void SetBackgroundColor(SkColor color) override; |
86 void SetBackgroundColorToDefault() final; | 90 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 | 237 // embedded within the RenderWidgetHostViewBase's Surface to the |
234 // coordinate space of the embedding Surface. Typically this means that a | 238 // 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 | 239 // 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 | 240 // 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 | 241 // this method is called on the root RWHV with the out-of-process iframe's |
238 // SurfaceId. | 242 // SurfaceId. |
239 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, | 243 virtual void TransformPointToLocalCoordSpace(const gfx::Point& point, |
240 cc::SurfaceId original_surface, | 244 cc::SurfaceId original_surface, |
241 gfx::Point* transformed_point); | 245 gfx::Point* transformed_point); |
242 | 246 |
247 // Updates the state of the input method attached to the view. | |
248 virtual void TextInputStateChanged(const TextInputState& text_input_state); | |
249 | |
243 //---------------------------------------------------------------------------- | 250 //---------------------------------------------------------------------------- |
244 // The following static methods are implemented by each platform. | 251 // The following static methods are implemented by each platform. |
245 | 252 |
246 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); | 253 static void GetDefaultScreenInfo(blink::WebScreenInfo* results); |
247 | 254 |
248 //---------------------------------------------------------------------------- | 255 //---------------------------------------------------------------------------- |
249 // The following pure virtual methods are implemented by derived classes. | 256 // The following pure virtual methods are implemented by derived classes. |
250 | 257 |
251 // Perform all the initialization steps necessary for this object to represent | 258 // 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|. | 259 // a popup (such as a <select> dropdown), then shows the popup at |pos|. |
253 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 260 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
254 const gfx::Rect& bounds) = 0; | 261 const gfx::Rect& bounds) = 0; |
255 | 262 |
256 // Perform all the initialization steps necessary for this object to represent | 263 // Perform all the initialization steps necessary for this object to represent |
257 // a full screen window. | 264 // a full screen window. |
258 // |reference_host_view| is the view associated with the creating page that | 265 // |reference_host_view| is the view associated with the creating page that |
259 // helps to position the full screen widget on the correct monitor. | 266 // helps to position the full screen widget on the correct monitor. |
260 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; | 267 virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; |
261 | 268 |
262 // Sets the cursor to the one associated with the specified cursor_type | 269 // Sets the cursor to the one associated with the specified cursor_type |
263 virtual void UpdateCursor(const WebCursor& cursor) = 0; | 270 virtual void UpdateCursor(const WebCursor& cursor) = 0; |
264 | 271 |
265 // Indicates whether the page has finished loading. | 272 // Indicates whether the page has finished loading. |
266 virtual void SetIsLoading(bool is_loading) = 0; | 273 virtual void SetIsLoading(bool is_loading) = 0; |
267 | 274 |
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. | 275 // Cancel the ongoing composition of the input method attached to the view. |
272 virtual void ImeCancelComposition() = 0; | 276 virtual void ImeCancelComposition() = 0; |
273 | 277 |
274 // Notifies the View that the renderer has ceased to exist. | 278 // Notifies the View that the renderer has ceased to exist. |
275 virtual void RenderProcessGone(base::TerminationStatus status, | 279 virtual void RenderProcessGone(base::TerminationStatus status, |
276 int error_code) = 0; | 280 int error_code) = 0; |
277 | 281 |
278 // Tells the View to destroy itself. | 282 // Tells the View to destroy itself. |
279 virtual void Destroy() = 0; | 283 virtual void Destroy() = 0; |
280 | 284 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 virtual void LockCompositingSurface() = 0; | 368 virtual void LockCompositingSurface() = 0; |
365 virtual void UnlockCompositingSurface() = 0; | 369 virtual void UnlockCompositingSurface() = 0; |
366 | 370 |
367 // Updates the range of the marked text in an IME composition. | 371 // Updates the range of the marked text in an IME composition. |
368 virtual void ImeCompositionRangeChanged( | 372 virtual void ImeCompositionRangeChanged( |
369 const gfx::Range& range, | 373 const gfx::Range& range, |
370 const std::vector<gfx::Rect>& character_bounds) = 0; | 374 const std::vector<gfx::Rect>& character_bounds) = 0; |
371 | 375 |
372 // Add and remove observers for lifetime event notifications. The order in | 376 // Add and remove observers for lifetime event notifications. The order in |
373 // which notifications are sent to observers is undefined. Clients must be | 377 // which notifications are sent to observers is undefined. Clients must be |
374 // sure to remove the observer before they go away. | 378 // sure to remove the observer before they go away. |
Charlie Reis
2016/05/18 20:46:04
Maybe you can add a similar comment to the add/rem
EhsanK
2016/05/24 20:42:44
Done.
| |
375 void AddObserver(RenderWidgetHostViewBaseObserver* observer); | 379 void AddObserver(RenderWidgetHostViewBaseObserver* observer); |
376 void RemoveObserver(RenderWidgetHostViewBaseObserver* observer); | 380 void RemoveObserver(RenderWidgetHostViewBaseObserver* observer); |
377 | 381 |
378 // Exposed for testing. | 382 // Exposed for testing. |
379 virtual bool IsChildFrameForTesting() const; | 383 virtual bool IsChildFrameForTesting() const; |
380 virtual cc::SurfaceId SurfaceIdForTesting() const; | 384 virtual cc::SurfaceId SurfaceIdForTesting() const; |
381 | 385 |
386 // TextInputManager::Observer implementation. | |
387 void OnDestroyingTextInputManager( | |
388 TextInputManager* text_input_manager) override; | |
Charlie Reis
2016/05/18 20:46:04
nit: This belongs near the top, under "IPC::Listen
EhsanK
2016/05/24 20:42:45
Done. This is removed from this class since Render
Charlie Reis
2016/05/26 06:22:03
Thanks, though that isn't what my line 24 comment
| |
389 | |
382 protected: | 390 protected: |
383 // Interface class only, do not construct. | 391 // Interface class only, do not construct. |
384 RenderWidgetHostViewBase(); | 392 RenderWidgetHostViewBase(); |
385 | 393 |
386 void NotifyObserversAboutShutdown(); | 394 void NotifyObserversAboutShutdown(); |
387 | 395 |
396 // Returns a reference to the current instance of TextInputManager. If no | |
397 // no reference is found, this method tries to obtain one from the | |
Charlie Reis
2016/05/18 20:46:04
nit: "no no"
EhsanK
2016/05/24 20:42:44
Done.
| |
398 // RenderWidgetHostDelegate. Returns nullptr if no reference exists or | |
399 // can be obtained. Unless not possible, this method should be used internally | |
Charlie Reis
2016/05/18 20:46:04
I don't follow the "Unless not possible" part. Is
EhsanK
2016/05/24 20:42:45
What I meant to say is that, we should always use
| |
400 // to obtain TextInputManager. | |
401 TextInputManager* GetTextInputManager(); | |
402 | |
388 // Whether this view is a popup and what kind of popup it is (select, | 403 // Whether this view is a popup and what kind of popup it is (select, |
389 // autofill...). | 404 // autofill...). |
390 blink::WebPopupType popup_type_; | 405 blink::WebPopupType popup_type_; |
391 | 406 |
392 // The background color of the web content. | 407 // The background color of the web content. |
393 SkColor background_color_; | 408 SkColor background_color_; |
394 | 409 |
395 // While the mouse is locked, the cursor is hidden from the user. Mouse events | 410 // 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 | 411 // 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 | 412 // 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 | 413 // indicates what the change in position of the mouse would be had it not been |
399 // locked. | 414 // locked. |
400 bool mouse_locked_; | 415 bool mouse_locked_; |
401 | 416 |
402 // Whether we are showing a context menu. | 417 // Whether we are showing a context menu. |
403 bool showing_context_menu_; | 418 bool showing_context_menu_; |
404 | 419 |
405 // A buffer containing the text inside and around the current selection range. | 420 // A buffer containing the text inside and around the current selection range. |
406 base::string16 selection_text_; | 421 base::string16 selection_text_; |
407 | 422 |
408 // The offset of the text stored in |selection_text_| relative to the start of | 423 // The offset of the text stored in |selection_text_| relative to the start of |
409 // the web page. | 424 // the web page. |
410 size_t selection_text_offset_; | 425 size_t selection_text_offset_; |
411 | 426 |
412 // The current selection range relative to the start of the web page. | 427 // The current selection range relative to the start of the web page. |
413 gfx::Range selection_range_; | 428 gfx::Range selection_range_; |
414 | 429 |
415 protected: | |
416 // The scale factor of the display the renderer is currently on. | 430 // The scale factor of the display the renderer is currently on. |
417 float current_device_scale_factor_; | 431 float current_device_scale_factor_; |
418 | 432 |
419 // The orientation of the display the renderer is currently on. | 433 // The orientation of the display the renderer is currently on. |
420 display::Display::Rotation current_display_rotation_; | 434 display::Display::Rotation current_display_rotation_; |
421 | 435 |
422 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the | 436 // Whether pinch-to-zoom should be enabled and pinch events forwarded to the |
423 // renderer. | 437 // renderer. |
424 bool pinch_zoom_enabled_; | 438 bool pinch_zoom_enabled_; |
425 | 439 |
440 // A reference to current TextInputManager instance this RWHV is registered | |
441 // with. This is initially nullptr until the first time the view calls | |
442 // GetTextInputManager(). It can also become nullptr if the top-level | |
443 // RenderWidgetHostDelegate owning the TextInputManager is destroyed. | |
444 TextInputManager* text_input_manager_; | |
445 | |
426 private: | 446 private: |
427 void FlushInput(); | 447 void FlushInput(); |
428 | 448 |
429 gfx::Rect current_display_area_; | 449 gfx::Rect current_display_area_; |
430 | 450 |
431 uint32_t renderer_frame_number_; | 451 uint32_t renderer_frame_number_; |
432 | 452 |
433 base::OneShotTimer flush_input_timer_; | 453 base::OneShotTimer flush_input_timer_; |
434 | 454 |
435 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; | 455 base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; |
436 | 456 |
437 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; | 457 base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_; |
438 | 458 |
439 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); | 459 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase); |
440 }; | 460 }; |
441 | 461 |
442 } // namespace content | 462 } // namespace content |
443 | 463 |
444 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ | 464 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_ |
OLD | NEW |