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

Unified Diff: content/public/test/text_input_test_utils.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: Rebased 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/public/test/text_input_test_utils.cc
diff --git a/content/public/test/text_input_test_utils.cc b/content/public/test/text_input_test_utils.cc
index bc13104efcdbfa7d11867504c1d4d44357f451dc..79ab7378dac83b8c25ea529e0cac44d611cc9a7b 100644
--- a/content/public/test/text_input_test_utils.cc
+++ b/content/public/test/text_input_test_utils.cc
@@ -65,6 +65,10 @@ class TextInputManagerTester::InternalObserver
on_ime_composition_range_changed_callback_ = callback;
}
+ void set_on_text_selection_changed_callback(const base::Closure& callback) {
+ on_text_selection_changed_callback_ = callback;
+ }
+
const RenderWidgetHostView* GetUpdatedView() const { return updated_view_; }
bool text_input_state_changed() const { return text_input_state_changed_; }
@@ -99,6 +103,13 @@ class TextInputManagerTester::InternalObserver
on_ime_composition_range_changed_callback_.Run();
}
+ void OnTextSelectionChanged(TextInputManager* text_input_manager,
+ RenderWidgetHostViewBase* updated_view) override {
+ updated_view_ = updated_view;
+ if (!on_text_selection_changed_callback_.is_null())
+ on_text_selection_changed_callback_.Run();
+ }
+
// WebContentsObserver implementation.
void WebContentsDestroyed() override { text_input_manager_ = nullptr; }
@@ -109,6 +120,7 @@ class TextInputManagerTester::InternalObserver
base::Closure update_text_input_state_callback_;
base::Closure on_selection_bounds_changed_callback_;
base::Closure on_ime_composition_range_changed_callback_;
+ base::Closure on_text_selection_changed_callback_;
DISALLOW_COPY_AND_ASSIGN(InternalObserver);
};
@@ -284,6 +296,11 @@ void TextInputManagerTester::SetOnImeCompositionRangeChangedCallback(
observer_->set_on_ime_composition_range_changed_callback(callback);
}
+void TextInputManagerTester::SetOnTextSelectionChangedCallback(
+ const base::Closure& callback) {
+ observer_->set_on_text_selection_changed_callback(callback);
+}
+
bool TextInputManagerTester::GetTextInputType(ui::TextInputType* type) {
DCHECK(observer_->text_input_manager());
const TextInputState* state =
@@ -313,6 +330,16 @@ const RenderWidgetHostView* TextInputManagerTester::GetUpdatedView() {
return observer_->GetUpdatedView();
}
+bool TextInputManagerTester::GetCurrentTextSelectionLength(size_t* length) {
+ DCHECK(observer_->text_input_manager());
+
+ if (!observer_->text_input_manager()->GetActiveWidget())
+ return false;
+
+ *length = observer_->text_input_manager()->GetTextSelection()->text.size();
+ return true;
+}
+
bool TextInputManagerTester::IsTextInputStateChanged() {
return observer_->text_input_state_changed();
}

Powered by Google App Engine
This is Rietveld 408576698