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 bef6e813cffacadb550a8593ac6df16f5bb69d11..309334081f4066c3c330a2ad54fad5106356c149 100644 |
--- a/content/browser/renderer_host/text_input_manager.h |
+++ b/content/browser/renderer_host/text_input_manager.h |
@@ -9,17 +9,15 @@ |
#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; |
-namespace gfx { |
-class Range; |
-} |
- |
namespace content { |
class RenderWidgetHostImpl; |
@@ -58,6 +56,27 @@ class CONTENT_EXPORT TextInputManager { |
virtual void OnImeCompositionRangeChanged( |
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(); |
@@ -84,6 +103,12 @@ class CONTENT_EXPORT TextInputManager { |
// Returns a vector of rects representing the character bounds. |
const std::vector<gfx::Rect>* GetCompositionCharacterBounds(); |
+ // The following method return the text selection state for the given |view|. |
Charlie Reis
2016/07/20 23:00:30
nit: returns
EhsanK
2016/07/21 16:52:55
Done. Thanks!
|
+ // 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. |
@@ -108,6 +133,12 @@ class CONTENT_EXPORT TextInputManager { |
const gfx::Range& range, |
const std::vector<gfx::Rect>& character_bounds); |
+ // 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 |
@@ -176,6 +207,7 @@ class CONTENT_EXPORT TextInputManager { |
// Text selection bounds information for registered views. |
ViewMap<SelectionRegion> selection_region_map_; |
ViewMap<CompositionRangeInfo> composition_range_info_map_; |
+ ViewMap<TextSelection> text_selection_map_; |
base::ObserverList<Observer> observer_list_; |