Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1353)

Unified Diff: content/browser/renderer_host/text_input_manager.cc

Issue 2130133004: Tracking text selection on the browser side in OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase added GetSelectedText() and its unit test back Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 eed20121103d96cdaaec68cdcafea5ecacc241a6..3560ec630f87ba7c9c55f0564ff82b5fe5008306 100644
--- a/content/browser/renderer_host/text_input_manager.cc
+++ b/content/browser/renderer_host/text_input_manager.cc
@@ -4,10 +4,12 @@
#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/geometry/rect.h"
+#include "ui/gfx/range/range.h"
namespace content {
@@ -72,6 +74,14 @@ TextInputManager::GetCompositionCharacterBounds() {
: nullptr;
}
+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) {
@@ -174,6 +184,21 @@ void TextInputManager::ImeCompositionRangeChanged(
OnImeCompositionRangeChanged(this, view));
}
+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));
@@ -233,4 +258,12 @@ TextInputManager::CompositionRangeInfo::CompositionRangeInfo(
TextInputManager::CompositionRangeInfo::~CompositionRangeInfo() {}
+TextInputManager::TextSelection::TextSelection()
+ : offset(0), range(gfx::Range::InvalidRange()), text(base::string16()) {}
+
+TextInputManager::TextSelection::TextSelection(const TextSelection& other) =
+ default;
+
+TextInputManager::TextSelection::~TextSelection() {}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698