| 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 4226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4237 | 4237 |
| 4238 void RenderView::RequestRemoteAccessClientFirewallTraversal() { | 4238 void RenderView::RequestRemoteAccessClientFirewallTraversal() { |
| 4239 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); | 4239 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); |
| 4240 } | 4240 } |
| 4241 | 4241 |
| 4242 void RenderView::OnImeSetComposition( | 4242 void RenderView::OnImeSetComposition( |
| 4243 const string16& text, | 4243 const string16& text, |
| 4244 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 4244 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 4245 int selection_start, | 4245 int selection_start, |
| 4246 int selection_end) { | 4246 int selection_end) { |
| 4247 // Until PPAPI has an interface for handling IME events, we skip sending | 4247 if (pepper_delegate_.IsPluginFocused()) { |
| 4248 // OnImeSetComposition. Otherwise the composition is canceled when a | 4248 pepper_delegate_.OnImeSetComposition(text, |
| 4249 // non-editable DOM element is focused. | 4249 underlines, |
| 4250 // | 4250 selection_start, |
| 4251 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended | 4251 selection_end); |
| 4252 // with an IME handling interface. | 4252 } else { |
| 4253 if (!pepper_delegate_.IsPluginFocused()) { | |
| 4254 RenderWidget::OnImeSetComposition(text, | 4253 RenderWidget::OnImeSetComposition(text, |
| 4255 underlines, | 4254 underlines, |
| 4256 selection_start, | 4255 selection_start, |
| 4257 selection_end); | 4256 selection_end); |
| 4258 } | 4257 } |
| 4259 } | 4258 } |
| 4260 | 4259 |
| 4261 void RenderView::OnImeConfirmComposition(const string16& text) { | 4260 void RenderView::OnImeConfirmComposition(const string16& text) { |
| 4262 if (pepper_delegate_.IsPluginFocused()) { | 4261 if (pepper_delegate_.IsPluginFocused()) { |
| 4263 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4262 pepper_delegate_.OnImeConfirmComposition(text); |
| 4264 // send character events. | |
| 4265 for (size_t i = 0; i < text.size(); ++i) { | |
| 4266 WebKit::WebKeyboardEvent char_event; | |
| 4267 char_event.type = WebKit::WebInputEvent::Char; | |
| 4268 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); | |
| 4269 char_event.modifiers = 0; | |
| 4270 char_event.windowsKeyCode = text[i]; | |
| 4271 char_event.nativeKeyCode = text[i]; | |
| 4272 char_event.text[0] = text[i]; | |
| 4273 char_event.unmodifiedText[0] = text[i]; | |
| 4274 if (webwidget_) | |
| 4275 webwidget_->handleInputEvent(char_event); | |
| 4276 } | |
| 4277 } else { | 4263 } else { |
| 4278 RenderWidget::OnImeConfirmComposition(text); | 4264 RenderWidget::OnImeConfirmComposition(text); |
| 4279 } | 4265 } |
| 4280 } | 4266 } |
| 4281 | 4267 |
| 4282 ui::TextInputType RenderView::GetTextInputType() { | 4268 WebKit::WebTextInputType RenderView::GetTextInputType() { |
| 4283 if (pepper_delegate_.IsPluginFocused()) { | 4269 if (pepper_delegate_.IsPluginFocused()) { |
| 4284 #if !defined(TOUCH_UI) | 4270 #if !defined(TOUCH_UI) |
| 4285 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4271 return pepper_delegate_.GetTextInputType(); |
| 4286 // consider all the parts of PPAPI plugins are accepting text inputs. | |
| 4287 return ui::TEXT_INPUT_TYPE_TEXT; | |
| 4288 #else | 4272 #else |
| 4289 // Disable keyboard input in flash for touch ui until PPAPI can support IME | 4273 // Disable keyboard input in flash for touch ui until PPAPI can support IME |
| 4290 // events. | 4274 // events. |
| 4291 return ui::TEXT_INPUT_TYPE_NONE; | 4275 // TODO(kinaba): remove after IME-aware PPAPI flash is ready. |
| 4276 return WebKit::WebTextInputTypeNone; |
| 4292 #endif | 4277 #endif |
| 4293 } | 4278 } |
| 4294 return RenderWidget::GetTextInputType(); | 4279 return RenderWidget::GetTextInputType(); |
| 4295 } | 4280 } |
| 4296 | 4281 |
| 4282 WebKit::WebRect RenderView::GetCaretBounds() { |
| 4283 if (pepper_delegate_.IsPluginFocused()) |
| 4284 return pepper_delegate_.GetCaretBounds(); |
| 4285 return RenderWidget::GetCaretBounds(); |
| 4286 } |
| 4287 |
| 4297 bool RenderView::CanComposeInline() { | 4288 bool RenderView::CanComposeInline() { |
| 4298 if (pepper_delegate_.IsPluginFocused()) { | 4289 if (pepper_delegate_.IsPluginFocused()) |
| 4299 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there | 4290 return pepper_delegate_.CanComposeInline(); |
| 4300 // is no way for the browser to know whether the plugin is capable of | |
| 4301 // drawing composition text. We assume plugins are incapable and let the | |
| 4302 // browser handle composition display for now. | |
| 4303 return false; | |
| 4304 } | |
| 4305 return true; | 4291 return true; |
| 4306 } | 4292 } |
| 4307 | 4293 |
| 4308 #if defined(OS_MACOSX) | 4294 #if defined(OS_MACOSX) |
| 4309 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { | 4295 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { |
| 4310 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), | 4296 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |
| 4311 focused, plugin_id); | 4297 focused, plugin_id); |
| 4312 Send(msg); | 4298 Send(msg); |
| 4313 } | 4299 } |
| 4314 | 4300 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4590 } | 4576 } |
| 4591 | 4577 |
| 4592 void RenderView::OnEnableViewSourceMode() { | 4578 void RenderView::OnEnableViewSourceMode() { |
| 4593 if (!webview()) | 4579 if (!webview()) |
| 4594 return; | 4580 return; |
| 4595 WebFrame* main_frame = webview()->mainFrame(); | 4581 WebFrame* main_frame = webview()->mainFrame(); |
| 4596 if (!main_frame) | 4582 if (!main_frame) |
| 4597 return; | 4583 return; |
| 4598 main_frame->enableViewSourceMode(true); | 4584 main_frame->enableViewSourceMode(true); |
| 4599 } | 4585 } |
| OLD | NEW |