| 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 4244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4255 | 4255 |
| 4256 // Notify all Pepper plugins. | 4256 // Notify all Pepper plugins. |
| 4257 pepper_delegate_.OnSetFocus(enable); | 4257 pepper_delegate_.OnSetFocus(enable); |
| 4258 } | 4258 } |
| 4259 } | 4259 } |
| 4260 | 4260 |
| 4261 void RenderView::PpapiPluginFocusChanged() { | 4261 void RenderView::PpapiPluginFocusChanged() { |
| 4262 UpdateInputMethod(); | 4262 UpdateInputMethod(); |
| 4263 } | 4263 } |
| 4264 | 4264 |
| 4265 void RenderView::PpapiPluginTextInputTypeChanged() { |
| 4266 UpdateInputMethod(); |
| 4267 } |
| 4268 |
| 4269 void RenderView::PpapiPluginCancelComposition() { |
| 4270 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 4271 ui::Range range(ui::Range::InvalidRange()); |
| 4272 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range)); |
| 4273 } |
| 4274 |
| 4265 void RenderView::RequestRemoteAccessClientFirewallTraversal() { | 4275 void RenderView::RequestRemoteAccessClientFirewallTraversal() { |
| 4266 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); | 4276 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); |
| 4267 } | 4277 } |
| 4268 | 4278 |
| 4269 void RenderView::OnImeSetComposition( | 4279 void RenderView::OnImeSetComposition( |
| 4270 const string16& text, | 4280 const string16& text, |
| 4271 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 4281 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 4272 int selection_start, | 4282 int selection_start, |
| 4273 int selection_end) { | 4283 int selection_end) { |
| 4274 // Until PPAPI has an interface for handling IME events, we skip sending | 4284 if (pepper_delegate_.IsPluginFocused()) { |
| 4275 // OnImeSetComposition. Otherwise the composition is canceled when a | 4285 pepper_delegate_.OnImeSetComposition(text, |
| 4276 // non-editable DOM element is focused. | 4286 underlines, |
| 4277 // | 4287 selection_start, |
| 4278 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended | 4288 selection_end); |
| 4279 // with an IME handling interface. | 4289 } else { |
| 4280 if (!pepper_delegate_.IsPluginFocused()) { | |
| 4281 RenderWidget::OnImeSetComposition(text, | 4290 RenderWidget::OnImeSetComposition(text, |
| 4282 underlines, | 4291 underlines, |
| 4283 selection_start, | 4292 selection_start, |
| 4284 selection_end); | 4293 selection_end); |
| 4285 } | 4294 } |
| 4286 } | 4295 } |
| 4287 | 4296 |
| 4288 void RenderView::OnImeConfirmComposition(const string16& text) { | 4297 void RenderView::OnImeConfirmComposition(const string16& text) { |
| 4289 if (pepper_delegate_.IsPluginFocused()) { | 4298 if (pepper_delegate_.IsPluginFocused()) |
| 4290 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4299 pepper_delegate_.OnImeConfirmComposition(text); |
| 4291 // send character events. | 4300 else |
| 4292 for (size_t i = 0; i < text.size(); ++i) { | |
| 4293 WebKit::WebKeyboardEvent char_event; | |
| 4294 char_event.type = WebKit::WebInputEvent::Char; | |
| 4295 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); | |
| 4296 char_event.modifiers = 0; | |
| 4297 char_event.windowsKeyCode = text[i]; | |
| 4298 char_event.nativeKeyCode = text[i]; | |
| 4299 char_event.text[0] = text[i]; | |
| 4300 char_event.unmodifiedText[0] = text[i]; | |
| 4301 if (webwidget_) | |
| 4302 webwidget_->handleInputEvent(char_event); | |
| 4303 } | |
| 4304 } else { | |
| 4305 RenderWidget::OnImeConfirmComposition(text); | 4301 RenderWidget::OnImeConfirmComposition(text); |
| 4306 } | |
| 4307 } | 4302 } |
| 4308 | 4303 |
| 4309 ui::TextInputType RenderView::GetTextInputType() { | 4304 ui::TextInputType RenderView::GetTextInputType() { |
| 4310 if (pepper_delegate_.IsPluginFocused()) { | 4305 return pepper_delegate_.IsPluginFocused() ? |
| 4311 #if !defined(TOUCH_UI) | 4306 pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); |
| 4312 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4307 } |
| 4313 // consider all the parts of PPAPI plugins are accepting text inputs. | 4308 |
| 4314 return ui::TEXT_INPUT_TYPE_TEXT; | 4309 gfx::Rect RenderView::GetCaretBounds() { |
| 4315 #else | 4310 return pepper_delegate_.IsPluginFocused() ? |
| 4316 // Disable keyboard input in flash for touch ui until PPAPI can support IME | 4311 pepper_delegate_.GetCaretBounds() : RenderWidget::GetCaretBounds(); |
| 4317 // events. | |
| 4318 return ui::TEXT_INPUT_TYPE_NONE; | |
| 4319 #endif | |
| 4320 } | |
| 4321 return RenderWidget::GetTextInputType(); | |
| 4322 } | 4312 } |
| 4323 | 4313 |
| 4324 bool RenderView::CanComposeInline() { | 4314 bool RenderView::CanComposeInline() { |
| 4325 if (pepper_delegate_.IsPluginFocused()) { | 4315 return pepper_delegate_.IsPluginFocused() ? |
| 4326 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there | 4316 pepper_delegate_.CanComposeInline() : true; |
| 4327 // is no way for the browser to know whether the plugin is capable of | |
| 4328 // drawing composition text. We assume plugins are incapable and let the | |
| 4329 // browser handle composition display for now. | |
| 4330 return false; | |
| 4331 } | |
| 4332 return true; | |
| 4333 } | 4317 } |
| 4334 | 4318 |
| 4335 #if defined(OS_MACOSX) | 4319 #if defined(OS_MACOSX) |
| 4336 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { | 4320 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { |
| 4337 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), | 4321 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |
| 4338 focused, plugin_id); | 4322 focused, plugin_id); |
| 4339 Send(msg); | 4323 Send(msg); |
| 4340 } | 4324 } |
| 4341 | 4325 |
| 4342 void RenderView::StartPluginIme() { | 4326 void RenderView::StartPluginIme() { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4637 main_frame->enableViewSourceMode(true); | 4621 main_frame->enableViewSourceMode(true); |
| 4638 } | 4622 } |
| 4639 | 4623 |
| 4640 void RenderView::OnLockMouseACK(bool succeeded) { | 4624 void RenderView::OnLockMouseACK(bool succeeded) { |
| 4641 pepper_delegate_.OnLockMouseACK(succeeded); | 4625 pepper_delegate_.OnLockMouseACK(succeeded); |
| 4642 } | 4626 } |
| 4643 | 4627 |
| 4644 void RenderView::OnMouseLockLost() { | 4628 void RenderView::OnMouseLockLost() { |
| 4645 pepper_delegate_.OnMouseLockLost(); | 4629 pepper_delegate_.OnMouseLockLost(); |
| 4646 } | 4630 } |
| 4647 | |
| OLD | NEW |