OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_view.h" | 5 #include "content/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 | 4031 |
4032 // Notify all Pepper plugins. | 4032 // Notify all Pepper plugins. |
4033 pepper_delegate_.OnSetFocus(enable); | 4033 pepper_delegate_.OnSetFocus(enable); |
4034 } | 4034 } |
4035 } | 4035 } |
4036 | 4036 |
4037 void RenderView::PpapiPluginFocusChanged() { | 4037 void RenderView::PpapiPluginFocusChanged() { |
4038 UpdateInputMethod(); | 4038 UpdateInputMethod(); |
4039 } | 4039 } |
4040 | 4040 |
| 4041 void RenderView::PpapiPluginTextInputTypeChanged() { |
| 4042 UpdateInputMethod(); |
| 4043 } |
| 4044 |
| 4045 void RenderView::PpapiPluginCancelComposition() { |
| 4046 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 4047 ui::Range range(ui::Range::InvalidRange()); |
| 4048 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range)); |
| 4049 } |
| 4050 |
4041 void RenderView::RequestRemoteAccessClientFirewallTraversal() { | 4051 void RenderView::RequestRemoteAccessClientFirewallTraversal() { |
4042 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); | 4052 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); |
4043 } | 4053 } |
4044 | 4054 |
4045 void RenderView::OnImeSetComposition( | 4055 void RenderView::OnImeSetComposition( |
4046 const string16& text, | 4056 const string16& text, |
4047 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 4057 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
4048 int selection_start, | 4058 int selection_start, |
4049 int selection_end) { | 4059 int selection_end) { |
4050 // Until PPAPI has an interface for handling IME events, we skip sending | 4060 if (pepper_delegate_.IsPluginFocused()) { |
4051 // OnImeSetComposition. Otherwise the composition is canceled when a | 4061 // When a PPAPI plugin has focus, we bypass WebKit. |
4052 // non-editable DOM element is focused. | 4062 pepper_delegate_.OnImeSetComposition(text, |
4053 // | 4063 underlines, |
4054 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended | 4064 selection_start, |
4055 // with an IME handling interface. | 4065 selection_end); |
4056 if (!pepper_delegate_.IsPluginFocused()) { | 4066 } else { |
4057 #if defined(OS_WIN) | 4067 #if defined(OS_WIN) |
4058 // When a plug-in has focus, we create platform-specific IME data used by | 4068 // When a plug-in has focus, we create platform-specific IME data used by |
4059 // our IME emulator and send it directly to the focused plug-in, i.e. we | 4069 // our IME emulator and send it directly to the focused plug-in, i.e. we |
4060 // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its | 4070 // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its |
4061 // instance ID is the same one as the specified ID.) | 4071 // instance ID is the same one as the specified ID.) |
4062 if (focused_plugin_id_ >= 0) { | 4072 if (focused_plugin_id_ >= 0) { |
4063 std::vector<int> clauses; | 4073 std::vector<int> clauses; |
4064 std::vector<int> target; | 4074 std::vector<int> target; |
4065 for (size_t i = 0; i < underlines.size(); ++i) { | 4075 for (size_t i = 0; i < underlines.size(); ++i) { |
4066 clauses.push_back(underlines[i].startOffset); | 4076 clauses.push_back(underlines[i].startOffset); |
(...skipping 15 matching lines...) Expand all Loading... |
4082 #endif | 4092 #endif |
4083 RenderWidget::OnImeSetComposition(text, | 4093 RenderWidget::OnImeSetComposition(text, |
4084 underlines, | 4094 underlines, |
4085 selection_start, | 4095 selection_start, |
4086 selection_end); | 4096 selection_end); |
4087 } | 4097 } |
4088 } | 4098 } |
4089 | 4099 |
4090 void RenderView::OnImeConfirmComposition(const string16& text) { | 4100 void RenderView::OnImeConfirmComposition(const string16& text) { |
4091 if (pepper_delegate_.IsPluginFocused()) { | 4101 if (pepper_delegate_.IsPluginFocused()) { |
4092 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4102 // When a PPAPI plugin has focus, we bypass WebKit. |
4093 // send character events. | 4103 pepper_delegate_.OnImeConfirmComposition(text); |
4094 for (size_t i = 0; i < text.size(); ++i) { | |
4095 WebKit::WebKeyboardEvent char_event; | |
4096 char_event.type = WebKit::WebInputEvent::Char; | |
4097 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); | |
4098 char_event.modifiers = 0; | |
4099 char_event.windowsKeyCode = text[i]; | |
4100 char_event.nativeKeyCode = text[i]; | |
4101 char_event.text[0] = text[i]; | |
4102 char_event.unmodifiedText[0] = text[i]; | |
4103 if (webwidget_) | |
4104 webwidget_->handleInputEvent(char_event); | |
4105 } | |
4106 } else { | 4104 } else { |
4107 #if defined(OS_WIN) | 4105 #if defined(OS_WIN) |
4108 // Same as OnImeSetComposition(), we send the text from IMEs directly to | 4106 // Same as OnImeSetComposition(), we send the text from IMEs directly to |
4109 // plug-ins. When we send IME text directly to plug-ins, we should not send | 4107 // plug-ins. When we send IME text directly to plug-ins, we should not send |
4110 // it to WebKit to prevent WebKit from controlling IMEs. | 4108 // it to WebKit to prevent WebKit from controlling IMEs. |
4111 if (focused_plugin_id_ >= 0) { | 4109 if (focused_plugin_id_ >= 0) { |
4112 std::set<WebPluginDelegateProxy*>::iterator it; | 4110 std::set<WebPluginDelegateProxy*>::iterator it; |
4113 for (it = plugin_delegates_.begin(); | 4111 for (it = plugin_delegates_.begin(); |
4114 it != plugin_delegates_.end(); ++it) { | 4112 it != plugin_delegates_.end(); ++it) { |
4115 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); | 4113 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
4116 } | 4114 } |
4117 return; | 4115 return; |
4118 } | 4116 } |
4119 #endif | 4117 #endif |
4120 RenderWidget::OnImeConfirmComposition(text); | 4118 RenderWidget::OnImeConfirmComposition(text); |
4121 } | 4119 } |
4122 } | 4120 } |
4123 | 4121 |
4124 ui::TextInputType RenderView::GetTextInputType() { | 4122 ui::TextInputType RenderView::GetTextInputType() { |
4125 if (pepper_delegate_.IsPluginFocused()) { | 4123 return pepper_delegate_.IsPluginFocused() ? |
4126 #if !defined(TOUCH_UI) | 4124 pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); |
4127 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4125 } |
4128 // consider all the parts of PPAPI plugins are accepting text inputs. | 4126 |
4129 return ui::TEXT_INPUT_TYPE_TEXT; | 4127 gfx::Rect RenderView::GetCaretBounds() { |
4130 #else | 4128 return pepper_delegate_.IsPluginFocused() ? |
4131 // Disable keyboard input in flash for touch ui until PPAPI can support IME | 4129 pepper_delegate_.GetCaretBounds() : RenderWidget::GetCaretBounds(); |
4132 // events. | |
4133 return ui::TEXT_INPUT_TYPE_NONE; | |
4134 #endif | |
4135 } | |
4136 return RenderWidget::GetTextInputType(); | |
4137 } | 4130 } |
4138 | 4131 |
4139 bool RenderView::CanComposeInline() { | 4132 bool RenderView::CanComposeInline() { |
4140 if (pepper_delegate_.IsPluginFocused()) { | 4133 return pepper_delegate_.IsPluginFocused() ? |
4141 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there | 4134 pepper_delegate_.CanComposeInline() : true; |
4142 // is no way for the browser to know whether the plugin is capable of | |
4143 // drawing composition text. We assume plugins are incapable and let the | |
4144 // browser handle composition display for now. | |
4145 return false; | |
4146 } | |
4147 return true; | |
4148 } | 4135 } |
4149 | 4136 |
4150 #if defined(OS_WIN) | 4137 #if defined(OS_WIN) |
4151 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { | 4138 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { |
4152 if (focused) | 4139 if (focused) |
4153 focused_plugin_id_ = plugin_id; | 4140 focused_plugin_id_ = plugin_id; |
4154 else | 4141 else |
4155 focused_plugin_id_ = -1; | 4142 focused_plugin_id_ = -1; |
4156 } | 4143 } |
4157 #endif | 4144 #endif |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4453 main_frame->enableViewSourceMode(true); | 4440 main_frame->enableViewSourceMode(true); |
4454 } | 4441 } |
4455 | 4442 |
4456 void RenderView::OnLockMouseACK(bool succeeded) { | 4443 void RenderView::OnLockMouseACK(bool succeeded) { |
4457 pepper_delegate_.OnLockMouseACK(succeeded); | 4444 pepper_delegate_.OnLockMouseACK(succeeded); |
4458 } | 4445 } |
4459 | 4446 |
4460 void RenderView::OnMouseLockLost() { | 4447 void RenderView::OnMouseLockLost() { |
4461 pepper_delegate_.OnMouseLockLost(); | 4448 pepper_delegate_.OnMouseLockLost(); |
4462 } | 4449 } |
OLD | NEW |