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

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10391101: Test for Pepper IME events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments from kochi & merge master. Created 8 years, 7 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 | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | webkit/plugins/ppapi/resource_creation_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 390f8dcec831e8c35799980655c33120b2e6d96d..429dd03d4c65297cf1180a606232516017f62711 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1611,6 +1611,10 @@ void PluginInstance::SimulateInputEvent(const InputEventData& input_event) {
return;
}
+ bool handled = SimulateIMEEvent(input_event);
+ if (handled)
+ return;
+
std::vector<linked_ptr<WebInputEvent> > events =
CreateSimulatedWebInputEvents(
input_event,
@@ -1622,6 +1626,52 @@ void PluginInstance::SimulateInputEvent(const InputEventData& input_event) {
}
}
+bool PluginInstance::SimulateIMEEvent(const InputEventData& input_event) {
+ switch (input_event.event_type) {
+ case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START:
+ case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE:
+ SimulateImeSetCompositionEvent(input_event);
+ break;
+ case PP_INPUTEVENT_TYPE_IME_COMPOSITION_END:
+ DCHECK(input_event.character_text.empty());
+ SimulateImeSetCompositionEvent(input_event);
+ break;
+ case PP_INPUTEVENT_TYPE_IME_TEXT:
+ delegate()->SimulateImeConfirmComposition(
+ UTF8ToUTF16(input_event.character_text));
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+void PluginInstance::SimulateImeSetCompositionEvent(
+ const InputEventData& input_event) {
+ std::vector<size_t> offsets;
+ offsets.push_back(input_event.composition_selection_start);
+ offsets.push_back(input_event.composition_selection_end);
+ offsets.insert(offsets.end(),
+ input_event.composition_segment_offsets.begin(),
+ input_event.composition_segment_offsets.end());
+
+ string16 utf16_text =
+ UTF8ToUTF16AndAdjustOffsets(input_event.character_text, &offsets);
+
+ std::vector<WebKit::WebCompositionUnderline> underlines;
+ for (size_t i = 2; i + 1 < offsets.size(); ++i) {
+ WebKit::WebCompositionUnderline underline;
+ underline.startOffset = offsets[i];
+ underline.endOffset = offsets[i + 1];
+ if (input_event.composition_target_segment == static_cast<int32_t>(i - 2))
+ underline.thick = true;
+ underlines.push_back(underline);
+ }
+
+ delegate()->SimulateImeSetComposition(
+ utf16_text, underlines, offsets[0], offsets[1]);
+}
+
void PluginInstance::ClosePendingUserGesture(PP_Instance instance,
PP_TimeTicks timestamp) {
// Close the pending user gesture if the plugin had a chance to respond.
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | webkit/plugins/ppapi/resource_creation_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698