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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 page_id_(-1), | 316 page_id_(-1), |
317 last_page_id_sent_to_browser_(-1), | 317 last_page_id_sent_to_browser_(-1), |
318 history_list_offset_(-1), | 318 history_list_offset_(-1), |
319 history_list_length_(0), | 319 history_list_length_(0), |
320 target_url_status_(TARGET_NONE), | 320 target_url_status_(TARGET_NONE), |
321 cached_is_main_frame_pinned_to_left_(false), | 321 cached_is_main_frame_pinned_to_left_(false), |
322 cached_is_main_frame_pinned_to_right_(false), | 322 cached_is_main_frame_pinned_to_right_(false), |
323 cached_has_main_frame_horizontal_scrollbar_(false), | 323 cached_has_main_frame_horizontal_scrollbar_(false), |
324 cached_has_main_frame_vertical_scrollbar_(false), | 324 cached_has_main_frame_vertical_scrollbar_(false), |
325 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 325 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
| 326 #if defined(OS_WIN) |
| 327 focused_plugin_id_(-1), |
| 328 #endif |
326 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 329 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
327 geolocation_dispatcher_(NULL), | 330 geolocation_dispatcher_(NULL), |
328 speech_input_dispatcher_(NULL), | 331 speech_input_dispatcher_(NULL), |
329 device_orientation_dispatcher_(NULL), | 332 device_orientation_dispatcher_(NULL), |
330 p2p_socket_dispatcher_(NULL), | 333 p2p_socket_dispatcher_(NULL), |
331 devtools_agent_(NULL), | 334 devtools_agent_(NULL), |
332 renderer_accessibility_(NULL), | 335 renderer_accessibility_(NULL), |
333 session_storage_namespace_id_(session_storage_namespace_id), | 336 session_storage_namespace_id_(session_storage_namespace_id), |
334 handling_select_range_(false) { | 337 handling_select_range_(false) { |
335 routing_id_ = routing_id; | 338 routing_id_ = routing_id; |
(...skipping 3694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4030 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 4033 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
4031 int selection_start, | 4034 int selection_start, |
4032 int selection_end) { | 4035 int selection_end) { |
4033 // Until PPAPI has an interface for handling IME events, we skip sending | 4036 // Until PPAPI has an interface for handling IME events, we skip sending |
4034 // OnImeSetComposition. Otherwise the composition is canceled when a | 4037 // OnImeSetComposition. Otherwise the composition is canceled when a |
4035 // non-editable DOM element is focused. | 4038 // non-editable DOM element is focused. |
4036 // | 4039 // |
4037 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended | 4040 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended |
4038 // with an IME handling interface. | 4041 // with an IME handling interface. |
4039 if (!pepper_delegate_.IsPluginFocused()) { | 4042 if (!pepper_delegate_.IsPluginFocused()) { |
| 4043 #if defined(OS_WIN) |
| 4044 // When a plug-in has focus, we create platform-specific IME data used by |
| 4045 // our IME emulator and send it directly to the focused plug-in, i.e. we |
| 4046 // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its |
| 4047 // instance ID is the same one as the specified ID.) |
| 4048 if (focused_plugin_id_ >= 0) { |
| 4049 std::vector<int> clauses; |
| 4050 std::vector<int> target; |
| 4051 for (size_t i = 0; i < underlines.size(); ++i) { |
| 4052 clauses.push_back(underlines[i].startOffset); |
| 4053 clauses.push_back(underlines[i].endOffset); |
| 4054 if (underlines[i].thick) { |
| 4055 target.clear(); |
| 4056 target.push_back(underlines[i].startOffset); |
| 4057 target.push_back(underlines[i].endOffset); |
| 4058 } |
| 4059 } |
| 4060 std::set<WebPluginDelegateProxy*>::iterator it; |
| 4061 for (it = plugin_delegates_.begin(); |
| 4062 it != plugin_delegates_.end(); ++it) { |
| 4063 (*it)->ImeCompositionUpdated(text, clauses, target, selection_end, |
| 4064 focused_plugin_id_); |
| 4065 } |
| 4066 return; |
| 4067 } |
| 4068 #endif |
4040 RenderWidget::OnImeSetComposition(text, | 4069 RenderWidget::OnImeSetComposition(text, |
4041 underlines, | 4070 underlines, |
4042 selection_start, | 4071 selection_start, |
4043 selection_end); | 4072 selection_end); |
4044 } | 4073 } |
4045 } | 4074 } |
4046 | 4075 |
4047 void RenderView::OnImeConfirmComposition(const string16& text) { | 4076 void RenderView::OnImeConfirmComposition(const string16& text) { |
4048 if (pepper_delegate_.IsPluginFocused()) { | 4077 if (pepper_delegate_.IsPluginFocused()) { |
4049 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4078 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
4050 // send character events. | 4079 // send character events. |
4051 for (size_t i = 0; i < text.size(); ++i) { | 4080 for (size_t i = 0; i < text.size(); ++i) { |
4052 WebKit::WebKeyboardEvent char_event; | 4081 WebKit::WebKeyboardEvent char_event; |
4053 char_event.type = WebKit::WebInputEvent::Char; | 4082 char_event.type = WebKit::WebInputEvent::Char; |
4054 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); | 4083 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); |
4055 char_event.modifiers = 0; | 4084 char_event.modifiers = 0; |
4056 char_event.windowsKeyCode = text[i]; | 4085 char_event.windowsKeyCode = text[i]; |
4057 char_event.nativeKeyCode = text[i]; | 4086 char_event.nativeKeyCode = text[i]; |
4058 char_event.text[0] = text[i]; | 4087 char_event.text[0] = text[i]; |
4059 char_event.unmodifiedText[0] = text[i]; | 4088 char_event.unmodifiedText[0] = text[i]; |
4060 if (webwidget_) | 4089 if (webwidget_) |
4061 webwidget_->handleInputEvent(char_event); | 4090 webwidget_->handleInputEvent(char_event); |
4062 } | 4091 } |
4063 } else { | 4092 } else { |
| 4093 #if defined(OS_WIN) |
| 4094 // Same as OnImeSetComposition(), we send the text from IMEs directly to |
| 4095 // plug-ins. When we send IME text directly to plug-ins, we should not send |
| 4096 // it to WebKit to prevent WebKit from controlling IMEs. |
| 4097 if (focused_plugin_id_ >= 0) { |
| 4098 std::set<WebPluginDelegateProxy*>::iterator it; |
| 4099 for (it = plugin_delegates_.begin(); |
| 4100 it != plugin_delegates_.end(); ++it) { |
| 4101 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
| 4102 } |
| 4103 return; |
| 4104 } |
| 4105 #endif |
4064 RenderWidget::OnImeConfirmComposition(text); | 4106 RenderWidget::OnImeConfirmComposition(text); |
4065 } | 4107 } |
4066 } | 4108 } |
4067 | 4109 |
4068 ui::TextInputType RenderView::GetTextInputType() { | 4110 ui::TextInputType RenderView::GetTextInputType() { |
4069 if (pepper_delegate_.IsPluginFocused()) { | 4111 if (pepper_delegate_.IsPluginFocused()) { |
4070 #if !defined(TOUCH_UI) | 4112 #if !defined(TOUCH_UI) |
4071 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4113 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
4072 // consider all the parts of PPAPI plugins are accepting text inputs. | 4114 // consider all the parts of PPAPI plugins are accepting text inputs. |
4073 return ui::TEXT_INPUT_TYPE_TEXT; | 4115 return ui::TEXT_INPUT_TYPE_TEXT; |
(...skipping 10 matching lines...) Expand all Loading... |
4084 if (pepper_delegate_.IsPluginFocused()) { | 4126 if (pepper_delegate_.IsPluginFocused()) { |
4085 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there | 4127 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there |
4086 // is no way for the browser to know whether the plugin is capable of | 4128 // is no way for the browser to know whether the plugin is capable of |
4087 // drawing composition text. We assume plugins are incapable and let the | 4129 // drawing composition text. We assume plugins are incapable and let the |
4088 // browser handle composition display for now. | 4130 // browser handle composition display for now. |
4089 return false; | 4131 return false; |
4090 } | 4132 } |
4091 return true; | 4133 return true; |
4092 } | 4134 } |
4093 | 4135 |
| 4136 #if defined(OS_WIN) |
| 4137 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { |
| 4138 if (focused) |
| 4139 focused_plugin_id_ = plugin_id; |
| 4140 else |
| 4141 focused_plugin_id_ = -1; |
| 4142 } |
| 4143 #endif |
| 4144 |
4094 #if defined(OS_MACOSX) | 4145 #if defined(OS_MACOSX) |
4095 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { | 4146 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { |
4096 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), | 4147 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |
4097 focused, plugin_id); | 4148 focused, plugin_id); |
4098 Send(msg); | 4149 Send(msg); |
4099 } | 4150 } |
4100 | 4151 |
4101 void RenderView::StartPluginIme() { | 4152 void RenderView::StartPluginIme() { |
4102 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); | 4153 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); |
4103 // This message can be sent during event-handling, and needs to be delivered | 4154 // This message can be sent during event-handling, and needs to be delivered |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4397 } | 4448 } |
4398 | 4449 |
4399 void RenderView::OnLockMouseACK(bool succeeded) { | 4450 void RenderView::OnLockMouseACK(bool succeeded) { |
4400 pepper_delegate_.OnLockMouseACK(succeeded); | 4451 pepper_delegate_.OnLockMouseACK(succeeded); |
4401 } | 4452 } |
4402 | 4453 |
4403 void RenderView::OnMouseLockLost() { | 4454 void RenderView::OnMouseLockLost() { |
4404 pepper_delegate_.OnMouseLockLost(); | 4455 pepper_delegate_.OnMouseLockLost(); |
4405 } | 4456 } |
4406 | 4457 |
OLD | NEW |