Chromium Code Reviews| Index: content/browser/renderer_host/text_input_manager.h |
| diff --git a/content/browser/renderer_host/text_input_manager.h b/content/browser/renderer_host/text_input_manager.h |
| index 2bb4c16d9e5f27f2f7b754f4f3676a54daa74c2e..8aca04d0500c29e966ff739f3d5b5224ca8faefe 100644 |
| --- a/content/browser/renderer_host/text_input_manager.h |
| +++ b/content/browser/renderer_host/text_input_manager.h |
| @@ -6,10 +6,15 @@ |
| #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ |
| #include <unordered_map> |
| +#include <utility> |
| #include "base/observer_list.h" |
| #include "content/common/content_export.h" |
| #include "content/common/text_input_state.h" |
| +#include "ui/gfx/geometry/rect.h" |
| +#include "ui/gfx/selection_bound.h" |
| + |
| +struct ViewHostMsg_SelectionBounds_Params; |
| namespace content { |
| @@ -41,6 +46,10 @@ class CONTENT_EXPORT TextInputManager { |
| virtual void OnImeCancelComposition( |
| TextInputManager* text_input_manager, |
| RenderWidgetHostViewBase* updated_view) {} |
| + // Called when the selection bounds for the |updated_view| has changed. |
| + virtual void OnSelectionBoundsChanged( |
| + TextInputManager* text_input_manager, |
| + RenderWidgetHostViewBase* updated_view) {} |
| }; |
| TextInputManager(); |
| @@ -59,6 +68,9 @@ class CONTENT_EXPORT TextInputManager { |
| // dangling if the TextInputManager or |active_view_| might go away. |
| const TextInputState* GetTextInputState(); |
| + // Returns the rect between selection bounds for the |active_view_|. |
| + gfx::Rect GetSelectionBoundsRect(); |
| + |
| // --------------------------------------------------------------------------- |
| // The following methods are called by RWHVs on the tab to update their IME- |
| // related state. |
| @@ -71,6 +83,12 @@ class CONTENT_EXPORT TextInputManager { |
| // the widget corresponding to |view|. |
| void ImeCancelComposition(RenderWidgetHostViewBase* view); |
| + // Updates the selection bounds for the |view|. In Aura, selection bounds are |
| + // used to provide the InputMethod with the position of the caret, e.g., in |
| + // setting the position of the ui::ImeWindow. |
| + void SelectionBoundsChanged(RenderWidgetHostViewBase* view, |
| + const ViewHostMsg_SelectionBounds_Params& params); |
| + |
| // Registers the given |view| for tracking its TextInputState. This is called |
| // by any view which has updates in its TextInputState (whether tab's RWHV or |
| // that of a child frame). The |view| must unregister itself before being |
| @@ -100,6 +118,21 @@ class CONTENT_EXPORT TextInputManager { |
| RenderWidgetHostViewBase* view); |
| private: |
| + // Text selection bounds. |
| + struct SelectionRegion { |
| + SelectionRegion(); |
| + SelectionRegion(const SelectionRegion& other); |
| + |
| + // The begining of the selection region. |
| + gfx::SelectionBound anchor; |
| + // The end of the selection region (caret position). |
| + gfx::SelectionBound focus; |
| + }; |
| + |
| + template <class Value> |
| + class ViewMap : public std::unordered_map<RenderWidgetHostViewBase*, Value> { |
| + }; |
| + |
| void NotifyObserversAboutInputStateUpdate(RenderWidgetHostViewBase* view, |
| bool did_update_state); |
| @@ -108,8 +141,11 @@ class CONTENT_EXPORT TextInputManager { |
| // cannot have a |TextInputState.type| of ui::TEXT_INPUT_TYPE_NONE. |
| RenderWidgetHostViewBase* active_view_; |
| - std::unordered_map<RenderWidgetHostViewBase*, TextInputState> |
| - text_input_state_map_; |
| + ViewMap<TextInputState> text_input_state_map_; |
| + |
| + // Maps a registered view to a pair of selection bounds where the first bound |
| + // is selection anchor and the second is selection focus. |
|
Charlie Reis
2016/06/30 20:27:21
nit: Stale comment.
EhsanK
2016/06/30 21:01:15
Acknowledged.
|
| + ViewMap<SelectionRegion> selection_region_map_; |
| base::ObserverList<Observer> observer_list_; |