Index: content/browser/renderer_host/text_input_manager.cc |
diff --git a/content/browser/renderer_host/text_input_manager.cc b/content/browser/renderer_host/text_input_manager.cc |
index 3029d932d0a91d01e6d0ce3553047f800bd56054..aad89f3056d4304a84ae51e12ace48306a5e9505 100644 |
--- a/content/browser/renderer_host/text_input_manager.cc |
+++ b/content/browser/renderer_host/text_input_manager.cc |
@@ -4,9 +4,11 @@ |
#include "content/browser/renderer_host/text_input_manager.h" |
+#include "base/strings/string16.h" |
#include "content/browser/renderer_host/render_widget_host_impl.h" |
#include "content/browser/renderer_host/render_widget_host_view_base.h" |
#include "content/common/view_messages.h" |
+#include "ui/gfx/range/range.h" |
namespace content { |
@@ -64,6 +66,14 @@ gfx::Rect TextInputManager::GetSelectionBoundsRect() { |
selection_region_map_[active_view_].focus); |
} |
+const TextInputManager::TextSelection* TextInputManager::GetTextSelection( |
+ RenderWidgetHostViewBase* view) { |
+ DCHECK(!view || IsRegistered(view)); |
+ if (!view) |
+ view = active_view_; |
+ return !!view ? &text_selection_map_[view] : nullptr; |
+} |
+ |
void TextInputManager::UpdateTextInputState( |
RenderWidgetHostViewBase* view, |
const TextInputState& text_input_state) { |
@@ -148,6 +158,21 @@ void TextInputManager::SelectionBoundsChanged( |
#endif |
} |
+void TextInputManager::SelectionChanged(RenderWidgetHostViewBase* view, |
+ const base::string16& text, |
+ size_t offset, |
+ const gfx::Range& range) { |
+ DCHECK(IsRegistered(view)); |
+ |
+ text_selection_map_[view].text = text; |
+ text_selection_map_[view].offset = offset; |
+ text_selection_map_[view].range.set_start(range.start()); |
+ text_selection_map_[view].range.set_end(range.end()); |
+ |
+ FOR_EACH_OBSERVER(Observer, observer_list_, |
+ OnTextSelectionChanged(this, view)); |
+} |
+ |
void TextInputManager::Register(RenderWidgetHostViewBase* view) { |
DCHECK(!IsRegistered(view)); |
@@ -200,4 +225,12 @@ TextInputManager::SelectionRegion::SelectionRegion() {} |
TextInputManager::SelectionRegion::SelectionRegion( |
const SelectionRegion& other) = default; |
-} // namespace content |
+TextInputManager::TextSelection::TextSelection() |
+ : offset(0), range(gfx::Range::InvalidRange()), text(base::string16()) {} |
+ |
+TextInputManager::TextSelection::TextSelection(const TextSelection& other) = |
+ default; |
+ |
+TextInputManager::TextSelection::~TextSelection() {} |
+ |
+} // namespace content |