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 4bf647597f9b6315d002c4fe47fa7c64792bb26a..4849ac34c6e9bed2b51e2d949bd37b41a17acea1 100644 |
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
@@ -1592,6 +1592,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, |
@@ -1603,6 +1607,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]; |
yzshen1
2012/05/15 18:03:48
spaces around '+', please.
kinaba
2012/05/16 10:13:57
Done.
|
+ 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. |