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_impl.h" | 5 #include "content/renderer/render_view_impl.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 4138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4149 | 4149 |
4150 // Notify all Pepper plugins. | 4150 // Notify all Pepper plugins. |
4151 pepper_delegate_.OnSetFocus(enable); | 4151 pepper_delegate_.OnSetFocus(enable); |
4152 } | 4152 } |
4153 } | 4153 } |
4154 | 4154 |
4155 void RenderViewImpl::PpapiPluginFocusChanged() { | 4155 void RenderViewImpl::PpapiPluginFocusChanged() { |
4156 UpdateInputMethod(); | 4156 UpdateInputMethod(); |
4157 } | 4157 } |
4158 | 4158 |
| 4159 void RenderViewImpl::PpapiPluginTextInputTypeChanged() { |
| 4160 UpdateInputMethod(); |
| 4161 } |
| 4162 |
| 4163 void RenderViewImpl::PpapiPluginCancelComposition() { |
| 4164 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 4165 ui::Range range(ui::Range::InvalidRange()); |
| 4166 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range)); |
| 4167 } |
| 4168 |
4159 void RenderViewImpl::RequestRemoteAccessClientFirewallTraversal() { | 4169 void RenderViewImpl::RequestRemoteAccessClientFirewallTraversal() { |
4160 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); | 4170 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); |
4161 } | 4171 } |
4162 | 4172 |
4163 void RenderViewImpl::OnImeSetComposition( | 4173 void RenderViewImpl::OnImeSetComposition( |
4164 const string16& text, | 4174 const string16& text, |
4165 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 4175 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
4166 int selection_start, | 4176 int selection_start, |
4167 int selection_end) { | 4177 int selection_end) { |
4168 // Until PPAPI has an interface for handling IME events, we skip sending | 4178 if (pepper_delegate_.IsPluginFocused()) { |
4169 // OnImeSetComposition. Otherwise the composition is canceled when a | 4179 // When a PPAPI plugin has focus, we bypass WebKit. |
4170 // non-editable DOM element is focused. | 4180 pepper_delegate_.OnImeSetComposition(text, |
4171 // | 4181 underlines, |
4172 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended | 4182 selection_start, |
4173 // with an IME handling interface. | 4183 selection_end); |
4174 if (!pepper_delegate_.IsPluginFocused()) { | 4184 } else { |
4175 #if defined(OS_WIN) | 4185 #if defined(OS_WIN) |
4176 // When a plug-in has focus, we create platform-specific IME data used by | 4186 // When a plug-in has focus, we create platform-specific IME data used by |
4177 // our IME emulator and send it directly to the focused plug-in, i.e. we | 4187 // our IME emulator and send it directly to the focused plug-in, i.e. we |
4178 // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its | 4188 // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its |
4179 // instance ID is the same one as the specified ID.) | 4189 // instance ID is the same one as the specified ID.) |
4180 if (focused_plugin_id_ >= 0) { | 4190 if (focused_plugin_id_ >= 0) { |
4181 std::vector<int> clauses; | 4191 std::vector<int> clauses; |
4182 std::vector<int> target; | 4192 std::vector<int> target; |
4183 for (size_t i = 0; i < underlines.size(); ++i) { | 4193 for (size_t i = 0; i < underlines.size(); ++i) { |
4184 clauses.push_back(underlines[i].startOffset); | 4194 clauses.push_back(underlines[i].startOffset); |
(...skipping 15 matching lines...) Expand all Loading... |
4200 #endif | 4210 #endif |
4201 RenderWidget::OnImeSetComposition(text, | 4211 RenderWidget::OnImeSetComposition(text, |
4202 underlines, | 4212 underlines, |
4203 selection_start, | 4213 selection_start, |
4204 selection_end); | 4214 selection_end); |
4205 } | 4215 } |
4206 } | 4216 } |
4207 | 4217 |
4208 void RenderViewImpl::OnImeConfirmComposition(const string16& text) { | 4218 void RenderViewImpl::OnImeConfirmComposition(const string16& text) { |
4209 if (pepper_delegate_.IsPluginFocused()) { | 4219 if (pepper_delegate_.IsPluginFocused()) { |
4210 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4220 // When a PPAPI plugin has focus, we bypass WebKit. |
4211 // send character events. | 4221 pepper_delegate_.OnImeConfirmComposition(text); |
4212 for (size_t i = 0; i < text.size(); ++i) { | |
4213 WebKit::WebKeyboardEvent char_event; | |
4214 char_event.type = WebKit::WebInputEvent::Char; | |
4215 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); | |
4216 char_event.modifiers = 0; | |
4217 char_event.windowsKeyCode = text[i]; | |
4218 char_event.nativeKeyCode = text[i]; | |
4219 char_event.text[0] = text[i]; | |
4220 char_event.unmodifiedText[0] = text[i]; | |
4221 if (webwidget_) | |
4222 webwidget_->handleInputEvent(char_event); | |
4223 } | |
4224 } else { | 4222 } else { |
4225 #if defined(OS_WIN) | 4223 #if defined(OS_WIN) |
4226 // Same as OnImeSetComposition(), we send the text from IMEs directly to | 4224 // Same as OnImeSetComposition(), we send the text from IMEs directly to |
4227 // plug-ins. When we send IME text directly to plug-ins, we should not send | 4225 // plug-ins. When we send IME text directly to plug-ins, we should not send |
4228 // it to WebKit to prevent WebKit from controlling IMEs. | 4226 // it to WebKit to prevent WebKit from controlling IMEs. |
4229 if (focused_plugin_id_ >= 0) { | 4227 if (focused_plugin_id_ >= 0) { |
4230 std::set<WebPluginDelegateProxy*>::iterator it; | 4228 std::set<WebPluginDelegateProxy*>::iterator it; |
4231 for (it = plugin_delegates_.begin(); | 4229 for (it = plugin_delegates_.begin(); |
4232 it != plugin_delegates_.end(); ++it) { | 4230 it != plugin_delegates_.end(); ++it) { |
4233 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); | 4231 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
4234 } | 4232 } |
4235 return; | 4233 return; |
4236 } | 4234 } |
4237 #endif | 4235 #endif |
4238 RenderWidget::OnImeConfirmComposition(text); | 4236 RenderWidget::OnImeConfirmComposition(text); |
4239 } | 4237 } |
4240 } | 4238 } |
4241 | 4239 |
4242 ui::TextInputType RenderViewImpl::GetTextInputType() { | 4240 ui::TextInputType RenderViewImpl::GetTextInputType() { |
4243 if (pepper_delegate_.IsPluginFocused()) { | 4241 return pepper_delegate_.IsPluginFocused() ? |
4244 #if !defined(TOUCH_UI) | 4242 pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); |
4245 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4243 } |
4246 // consider all the parts of PPAPI plugins are accepting text inputs. | 4244 |
4247 return ui::TEXT_INPUT_TYPE_TEXT; | 4245 gfx::Rect RenderViewImpl::GetCaretBounds() { |
4248 #else | 4246 return pepper_delegate_.IsPluginFocused() ? |
4249 // Disable keyboard input in flash for touch ui until PPAPI can support IME | 4247 pepper_delegate_.GetCaretBounds() : RenderWidget::GetCaretBounds(); |
4250 // events. | |
4251 return ui::TEXT_INPUT_TYPE_NONE; | |
4252 #endif | |
4253 } | |
4254 return RenderWidget::GetTextInputType(); | |
4255 } | 4248 } |
4256 | 4249 |
4257 bool RenderViewImpl::CanComposeInline() { | 4250 bool RenderViewImpl::CanComposeInline() { |
4258 if (pepper_delegate_.IsPluginFocused()) { | 4251 return pepper_delegate_.IsPluginFocused() ? |
4259 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there | 4252 pepper_delegate_.CanComposeInline() : true; |
4260 // is no way for the browser to know whether the plugin is capable of | |
4261 // drawing composition text. We assume plugins are incapable and let the | |
4262 // browser handle composition display for now. | |
4263 return false; | |
4264 } | |
4265 return true; | |
4266 } | 4253 } |
4267 | 4254 |
4268 #if defined(OS_WIN) | 4255 #if defined(OS_WIN) |
4269 void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { | 4256 void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
4270 if (focused) | 4257 if (focused) |
4271 focused_plugin_id_ = plugin_id; | 4258 focused_plugin_id_ = plugin_id; |
4272 else | 4259 else |
4273 focused_plugin_id_ = -1; | 4260 focused_plugin_id_ = -1; |
4274 } | 4261 } |
4275 #endif | 4262 #endif |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4587 pepper_delegate_.OnLockMouseACK(succeeded); | 4574 pepper_delegate_.OnLockMouseACK(succeeded); |
4588 } | 4575 } |
4589 | 4576 |
4590 void RenderViewImpl::OnMouseLockLost() { | 4577 void RenderViewImpl::OnMouseLockLost() { |
4591 pepper_delegate_.OnMouseLockLost(); | 4578 pepper_delegate_.OnMouseLockLost(); |
4592 } | 4579 } |
4593 | 4580 |
4594 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 4581 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
4595 return webview()->settings()->useThreadedCompositor(); | 4582 return webview()->settings()->useThreadedCompositor(); |
4596 } | 4583 } |
OLD | NEW |