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 4168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4179 return; | 4179 return; |
4180 } | 4180 } |
4181 #endif | 4181 #endif |
4182 RenderWidget::OnImeSetComposition(text, | 4182 RenderWidget::OnImeSetComposition(text, |
4183 underlines, | 4183 underlines, |
4184 selection_start, | 4184 selection_start, |
4185 selection_end); | 4185 selection_end); |
4186 } | 4186 } |
4187 } | 4187 } |
4188 | 4188 |
4189 void RenderViewImpl::OnImeConfirmComposition(const string16& text) { | 4189 void RenderViewImpl::OnImeConfirmComposition( |
| 4190 const string16& text, const ui::Range& replacement_range) { |
4190 if (pepper_delegate_.IsPluginFocused()) { | 4191 if (pepper_delegate_.IsPluginFocused()) { |
4191 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4192 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
4192 // send character events. | 4193 // send character events. |
4193 for (size_t i = 0; i < text.size(); ++i) { | 4194 for (size_t i = 0; i < text.size(); ++i) { |
4194 WebKit::WebKeyboardEvent char_event; | 4195 WebKit::WebKeyboardEvent char_event; |
4195 char_event.type = WebKit::WebInputEvent::Char; | 4196 char_event.type = WebKit::WebInputEvent::Char; |
4196 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); | 4197 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); |
4197 char_event.modifiers = 0; | 4198 char_event.modifiers = 0; |
4198 char_event.windowsKeyCode = text[i]; | 4199 char_event.windowsKeyCode = text[i]; |
4199 char_event.nativeKeyCode = text[i]; | 4200 char_event.nativeKeyCode = text[i]; |
4200 char_event.text[0] = text[i]; | 4201 char_event.text[0] = text[i]; |
4201 char_event.unmodifiedText[0] = text[i]; | 4202 char_event.unmodifiedText[0] = text[i]; |
4202 if (webwidget_) | 4203 if (webwidget_) |
4203 webwidget_->handleInputEvent(char_event); | 4204 webwidget_->handleInputEvent(char_event); |
4204 } | 4205 } |
4205 } else { | 4206 } else { |
4206 #if defined(OS_WIN) | 4207 #if defined(OS_WIN) |
4207 // Same as OnImeSetComposition(), we send the text from IMEs directly to | 4208 // Same as OnImeSetComposition(), we send the text from IMEs directly to |
4208 // plug-ins. When we send IME text directly to plug-ins, we should not send | 4209 // plug-ins. When we send IME text directly to plug-ins, we should not send |
4209 // it to WebKit to prevent WebKit from controlling IMEs. | 4210 // it to WebKit to prevent WebKit from controlling IMEs. |
| 4211 // TODO(thakis): Honor |replacement_range| for plugins? |
4210 if (focused_plugin_id_ >= 0) { | 4212 if (focused_plugin_id_ >= 0) { |
4211 std::set<WebPluginDelegateProxy*>::iterator it; | 4213 std::set<WebPluginDelegateProxy*>::iterator it; |
4212 for (it = plugin_delegates_.begin(); | 4214 for (it = plugin_delegates_.begin(); |
4213 it != plugin_delegates_.end(); ++it) { | 4215 it != plugin_delegates_.end(); ++it) { |
4214 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); | 4216 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
4215 } | 4217 } |
4216 return; | 4218 return; |
4217 } | 4219 } |
4218 #endif | 4220 #endif |
4219 RenderWidget::OnImeConfirmComposition(text); | 4221 RenderWidget::OnImeConfirmComposition(text, replacement_range); |
4220 } | 4222 } |
4221 } | 4223 } |
4222 | 4224 |
4223 ui::TextInputType RenderViewImpl::GetTextInputType() { | 4225 ui::TextInputType RenderViewImpl::GetTextInputType() { |
4224 if (pepper_delegate_.IsPluginFocused()) { | 4226 if (pepper_delegate_.IsPluginFocused()) { |
4225 #if !defined(TOUCH_UI) | 4227 #if !defined(TOUCH_UI) |
4226 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4228 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
4227 // consider all the parts of PPAPI plugins are accepting text inputs. | 4229 // consider all the parts of PPAPI plugins are accepting text inputs. |
4228 return ui::TEXT_INPUT_TYPE_TEXT; | 4230 return ui::TEXT_INPUT_TYPE_TEXT; |
4229 #else | 4231 #else |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4559 pepper_delegate_.OnLockMouseACK(succeeded); | 4561 pepper_delegate_.OnLockMouseACK(succeeded); |
4560 } | 4562 } |
4561 | 4563 |
4562 void RenderViewImpl::OnMouseLockLost() { | 4564 void RenderViewImpl::OnMouseLockLost() { |
4563 pepper_delegate_.OnMouseLockLost(); | 4565 pepper_delegate_.OnMouseLockLost(); |
4564 } | 4566 } |
4565 | 4567 |
4566 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 4568 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
4567 return webview()->settings()->useThreadedCompositor(); | 4569 return webview()->settings()->useThreadedCompositor(); |
4568 } | 4570 } |
OLD | NEW |