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 f240a1b9b7408130b72f6711ee0cd6cd15e76202..032b7e9b14ea998eaa91d880bb7e4d5e4579c540 100644 |
--- a/content/browser/renderer_host/text_input_manager.h |
+++ b/content/browser/renderer_host/text_input_manager.h |
@@ -9,9 +9,11 @@ |
#include <utility> |
#include "base/observer_list.h" |
+#include "base/strings/string16.h" |
#include "content/common/content_export.h" |
#include "content/common/text_input_state.h" |
#include "ui/gfx/geometry/rect.h" |
+#include "ui/gfx/range/range.h" |
#include "ui/gfx/selection_bound.h" |
struct ViewHostMsg_SelectionBounds_Params; |
@@ -49,6 +51,27 @@ class CONTENT_EXPORT TextInputManager { |
virtual void OnSelectionBoundsChanged( |
TextInputManager* text_input_manager, |
RenderWidgetHostViewBase* updated_view) {} |
+ // Called when the text selection for the |updated_view_| has changed. |
+ virtual void OnTextSelectionChanged( |
+ TextInputManager* text_input_manager, |
+ RenderWidgetHostViewBase* updated_view) {} |
+ }; |
+ |
+ // This struct is used to store text selection related information for views. |
+ struct TextSelection { |
+ TextSelection(); |
+ TextSelection(const TextSelection& other); |
+ ~TextSelection(); |
+ |
+ // The offset of the text stored in |text| relative to the start of the web |
+ // page. |
+ size_t offset; |
+ |
+ // The current selection range relative to the start of the web page. |
+ gfx::Range range; |
+ |
+ // The text inside and around the current selection range. |
+ base::string16 text; |
}; |
TextInputManager(); |
@@ -71,6 +94,13 @@ class CONTENT_EXPORT TextInputManager { |
gfx::Rect GetSelectionBoundsRect(); |
// --------------------------------------------------------------------------- |
+ // The following method return the text selection state for the given |view|. |
+ // If |view| == nullptr, it will assume |active_view_| and return its state. |
+ // In the case of |active_view_| == nullptr, the method will return nullptr. |
+ const TextSelection* GetTextSelection( |
+ RenderWidgetHostViewBase* view = nullptr); |
+ |
+ // --------------------------------------------------------------------------- |
// The following methods are called by RWHVs on the tab to update their IME- |
// related state. |
@@ -88,6 +118,12 @@ class CONTENT_EXPORT TextInputManager { |
void SelectionBoundsChanged(RenderWidgetHostViewBase* view, |
const ViewHostMsg_SelectionBounds_Params& params); |
+ // Updates the new text selection information for the |view|. |
+ void SelectionChanged(RenderWidgetHostViewBase* view, |
+ const base::string16& text, |
+ size_t offset, |
+ const gfx::Range& range); |
+ |
// 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 |
@@ -147,10 +183,12 @@ class CONTENT_EXPORT TextInputManager { |
// Text selection bounds information for registered views. |
ViewMap<SelectionRegion> selection_region_map_; |
+ ViewMap<TextSelection> text_selection_map_; |
+ |
base::ObserverList<Observer> observer_list_; |
DISALLOW_COPY_AND_ASSIGN(TextInputManager); |
}; |
} |
-#endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ |
+#endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ |