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

Unified Diff: content/public/test/text_input_test_utils.cc

Issue 2954963003: Request Composition Range Updates for Focused GuestViews based on BrowserPlugins (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « content/public/test/text_input_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cbed2345122ed555231647ae60adcfa7fd1260e6..17d1ccaf6a973d21cd1b9bcbf9d3829afe729759 100644
--- a/content/public/test/text_input_test_utils.cc
+++ b/content/public/test/text_input_test_utils.cc
@@ -71,6 +71,10 @@ class TextInputManagerTester::InternalObserver
on_text_selection_changed_callback_ = callback;
}
+ const gfx::Range* last_composition_range() const {
+ return last_composition_range_.get();
+ }
+
RenderWidgetHostView* GetUpdatedView() const { return updated_view_; }
bool text_input_state_changed() const { return text_input_state_changed_; }
@@ -101,6 +105,10 @@ class TextInputManagerTester::InternalObserver
TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view) override {
updated_view_ = updated_view;
+ const gfx::Range* range =
+ text_input_manager_->GetCompositionRangeForTesting();
+ DCHECK(range);
+ last_composition_range_.reset(new gfx::Range(range->start(), range->end()));
if (!on_ime_composition_range_changed_callback_.is_null())
on_ime_composition_range_changed_callback_.Run();
}
@@ -119,6 +127,7 @@ class TextInputManagerTester::InternalObserver
TextInputManager* text_input_manager_;
RenderWidgetHostViewBase* updated_view_;
bool text_input_state_changed_;
+ std::unique_ptr<gfx::Range> last_composition_range_;
base::Closure update_text_input_state_callback_;
base::Closure on_selection_bounds_changed_callback_;
base::Closure on_ime_composition_range_changed_callback_;
@@ -279,6 +288,25 @@ void SendImeCommitTextToWidget(
text, web_composition_underlines, replacement_range, relative_cursor_pos);
}
+void SendImeSetCompositionTextToWidget(
+ RenderWidgetHost* rwh,
+ const base::string16& text,
+ const std::vector<ui::CompositionUnderline>& underlines,
+ const gfx::Range& replacement_range,
+ int selection_start,
+ int selection_end) {
+ std::vector<blink::WebCompositionUnderline> web_composition_underlines;
+ for (auto underline : underlines) {
+ web_composition_underlines.emplace_back(
+ static_cast<int>(underline.start_offset),
+ static_cast<int>(underline.end_offset), underline.color,
+ underline.thick, underline.background_color);
+ }
+ RenderWidgetHostImpl::From(rwh)->ImeSetComposition(
+ text, web_composition_underlines, replacement_range, selection_start,
+ selection_end);
+}
+
size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) {
std::unordered_set<RenderWidgetHostView*> views;
TextInputManager* manager =
@@ -356,6 +384,13 @@ bool TextInputManagerTester::GetCurrentTextSelectionLength(size_t* length) {
return true;
}
+bool TextInputManagerTester::GetLastCompositionRangeLength(uint32_t* length) {
+ if (!observer_->last_composition_range())
+ return false;
+ *length = observer_->last_composition_range()->length();
+ return true;
+}
+
bool TextInputManagerTester::IsTextInputStateChanged() {
return observer_->text_input_state_changed();
}
« no previous file with comments | « content/public/test/text_input_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698