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