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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 1999423002: tyrbot test for commitText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetHasCompositionTextToTrue Created 4 years, 3 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/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 4c5d7a3e37e4de3e3fa88be809293cc7e867c2ec..617ceda3d5d98c49d0b595c70bab8a499c900ebd 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -1325,10 +1325,14 @@ void RenderFrameImpl::SimulateImeSetComposition(
selection_start, selection_end);
}
-void RenderFrameImpl::SimulateImeConfirmComposition(
+void RenderFrameImpl::SimulateImeCommitText(
const base::string16& text,
const gfx::Range& replacement_range) {
- render_view_->OnImeConfirmComposition(text, replacement_range, false);
+ render_view_->OnImeCommitText(text, replacement_range, 0);
+}
+
+void RenderFrameImpl::SimulateImeFinishComposingText(bool keep_selection) {
+ render_view_->OnImeFinishComposingText(keep_selection);
}
void RenderFrameImpl::OnImeSetComposition(
@@ -1362,37 +1366,62 @@ void RenderFrameImpl::OnImeSetComposition(
}
}
-void RenderFrameImpl::OnImeConfirmComposition(
- const base::string16& text,
- const gfx::Range& replacement_range,
- bool keep_selection) {
- // When a PPAPI plugin has focus, we bypass WebKit.
- // Here, text.empty() has a special meaning. It means to commit the last
- // update of composition text (see
- // RenderWidgetHost::ImeConfirmComposition()).
- const base::string16& last_text = text.empty() ? pepper_composition_text_
- : text;
-
- // last_text is empty only when both text and pepper_composition_text_ is.
- // Ignore it.
- if (last_text.empty())
+void RenderFrameImpl::OnImeCommitText(const base::string16& text,
+ const gfx::Range& replacement_range,
+ int relative_cursor_pos) {
+ if (text.empty())
+ return;
+
+ if (!IsPepperAcceptingCompositionEvents()) {
+ base::i18n::UTF16CharIterator iterator(&text);
+ int32_t i = 0;
+ while (iterator.Advance()) {
+ blink::WebKeyboardEvent char_event;
+ char_event.type = blink::WebInputEvent::Char;
+ char_event.timeStampSeconds = base::Time::Now().ToDoubleT();
+ char_event.modifiers = 0;
+ char_event.windowsKeyCode = text[i];
+ char_event.nativeKeyCode = text[i];
+
+ const int32_t char_start = i;
+ for (; i < iterator.array_pos(); ++i) {
+ char_event.text[i - char_start] = text[i];
+ char_event.unmodifiedText[i - char_start] = text[i];
+ }
+
+ if (GetRenderWidget()->webwidget())
+ GetRenderWidget()->webwidget()->handleInputEvent(char_event);
+ }
+ } else {
+ // Mimics the order of events sent by WebKit.
+ // See WebCore::Editor::setComposition() for the corresponding code.
+ focused_pepper_plugin_->HandleCompositionEnd(text);
+ focused_pepper_plugin_->HandleTextInput(text);
+ }
+ pepper_composition_text_.clear();
+}
+
+void RenderFrameImpl::OnImeFinishComposingText(bool keep_selection) {
+ const base::string16& text = pepper_composition_text_;
+
+ if (text.empty())
return;
if (!IsPepperAcceptingCompositionEvents()) {
- base::i18n::UTF16CharIterator iterator(&last_text);
+ base::i18n::UTF16CharIterator iterator(&text);
int32_t i = 0;
while (iterator.Advance()) {
blink::WebKeyboardEvent char_event;
char_event.type = blink::WebInputEvent::Char;
char_event.timeStampSeconds = base::Time::Now().ToDoubleT();
char_event.modifiers = 0;
- char_event.windowsKeyCode = last_text[i];
- char_event.nativeKeyCode = last_text[i];
+ char_event.windowsKeyCode = text[i];
+ char_event.nativeKeyCode = text[i];
const int32_t char_start = i;
for (; i < iterator.array_pos(); ++i) {
- char_event.text[i - char_start] = last_text[i];
- char_event.unmodifiedText[i - char_start] = last_text[i];
+ char_event.text[i - char_start] = text[i];
+ char_event.unmodifiedText[i - char_start] = text[i];
}
if (GetRenderWidget()->webwidget())
@@ -1401,8 +1430,8 @@ void RenderFrameImpl::OnImeConfirmComposition(
} else {
// Mimics the order of events sent by WebKit.
// See WebCore::Editor::setComposition() for the corresponding code.
- focused_pepper_plugin_->HandleCompositionEnd(last_text);
- focused_pepper_plugin_->HandleTextInput(last_text);
+ focused_pepper_plugin_->HandleCompositionEnd(text);
+ focused_pepper_plugin_->HandleTextInput(text);
}
pepper_composition_text_.clear();
}
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698