Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: content/renderer/render_view.cc

Issue 6990072: The first step for enabling off-the-spot IME on Pepper on ChromeOS/Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved most changes into renderer, and several fixes on style. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" 82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h"
83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
84 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 84 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
85 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" 85 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h"
86 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" 86 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h"
87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h" 88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h"
89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" 89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h"
91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h"
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" 98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h"
98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" 100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h"
100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 navigation_gesture_(NavigationGestureUnknown), 344 navigation_gesture_(NavigationGestureUnknown),
344 opened_by_user_gesture_(true), 345 opened_by_user_gesture_(true),
345 opener_suppressed_(false), 346 opener_suppressed_(false),
346 page_id_(-1), 347 page_id_(-1),
347 last_page_id_sent_to_browser_(-1), 348 last_page_id_sent_to_browser_(-1),
348 history_list_offset_(-1), 349 history_list_offset_(-1),
349 history_list_length_(0), 350 history_list_length_(0),
350 has_unload_listener_(false), 351 has_unload_listener_(false),
351 target_url_status_(TARGET_NONE), 352 target_url_status_(TARGET_NONE),
352 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), 353 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
354 is_ppapi_plugin_focused_(false),
353 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), 355 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)),
354 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 356 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
355 geolocation_dispatcher_(NULL), 357 geolocation_dispatcher_(NULL),
356 speech_input_dispatcher_(NULL), 358 speech_input_dispatcher_(NULL),
357 device_orientation_dispatcher_(NULL), 359 device_orientation_dispatcher_(NULL),
358 accessibility_ack_pending_(false), 360 accessibility_ack_pending_(false),
359 p2p_socket_dispatcher_(NULL), 361 p2p_socket_dispatcher_(NULL),
360 session_storage_namespace_id_(session_storage_namespace_id) { 362 session_storage_namespace_id_(session_storage_namespace_id) {
361 routing_id_ = routing_id; 363 routing_id_ = routing_id;
362 if (opener_id != MSG_ROUTING_NONE) 364 if (opener_id != MSG_ROUTING_NONE)
(...skipping 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 (*plugin_it)->SetWindowFocus(true); 3931 (*plugin_it)->SetWindowFocus(true);
3930 #endif 3932 #endif
3931 (*plugin_it)->SetContentAreaFocus(enable); 3933 (*plugin_it)->SetContentAreaFocus(enable);
3932 } 3934 }
3933 3935
3934 // Notify all Pepper plugins. 3936 // Notify all Pepper plugins.
3935 pepper_delegate_.OnSetFocus(enable); 3937 pepper_delegate_.OnSetFocus(enable);
3936 } 3938 }
3937 } 3939 }
3938 3940
3941 void RenderView::PpapiPluginFocusChanged(bool focused) {
3942 is_ppapi_plugin_focused_ = focused;
3943 UpdateInputMethod();
3944 }
3945
3946 void RenderView::OnImeSetComposition(
3947 const string16& text,
3948 const std::vector<WebKit::WebCompositionUnderline>& underlines,
3949 int selection_start,
3950 int selection_end) {
3951 // Until PPAPI has an interface for handling IME events, we skip sending
3952 // OnImeSetComposition. Otherwise the composition is canceled when a
3953 // non-editable DOM element is focused.
3954 //
3955 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended
3956 // with an IME handling interface.
3957 if (!is_ppapi_plugin_focused_) {
3958 RenderWidget::OnImeSetComposition(text,
3959 underlines,
3960 selection_start,
3961 selection_end);
3962 }
3963 }
3964
3965 void RenderView::OnImeConfirmComposition(const string16& text) {
3966 if (is_ppapi_plugin_focused_) {
3967 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we
3968 // send character events.
3969 for (size_t i = 0; i < text.size(); ++i) {
3970 WebKit::WebKeyboardEvent char_event;
3971 char_event.type = WebKit::WebInputEvent::Char;
3972 char_event.timeStampSeconds = base::Time::Now().ToDoubleT();
3973 char_event.modifiers = 0;
3974 char_event.windowsKeyCode = text[i];
3975 char_event.nativeKeyCode = text[i];
3976 char_event.text[0] = text[i];
3977 char_event.unmodifiedText[0] = text[i];
3978 if (webwidget_)
3979 webwidget_->handleInputEvent(char_event);
3980 }
3981 } else {
3982 RenderWidget::OnImeConfirmComposition(text);
3983 }
3984 }
3985
3986 void RenderView::GetTextInputType(WebKit::WebTextInputType* type,
3987 WebKit::WebRect* caret_bounds) {
3988 if (is_ppapi_plugin_focused_) {
3989 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we
3990 // consider all the parts of PPAPI plugins are accepting text inputs.
3991 *type = WebKit::WebTextInputTypeText;
3992 } else {
3993 RenderWidget::GetTextInputType(type, caret_bounds);
3994 }
3995 }
3996
3939 #if defined(OS_MACOSX) 3997 #if defined(OS_MACOSX)
3940 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { 3998 void RenderView::PluginFocusChanged(bool focused, int plugin_id) {
3941 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), 3999 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(),
3942 focused, plugin_id); 4000 focused, plugin_id);
3943 Send(msg); 4001 Send(msg);
3944 } 4002 }
3945 4003
3946 void RenderView::StartPluginIme() { 4004 void RenderView::StartPluginIme() {
3947 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); 4005 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id());
3948 // This message can be sent during event-handling, and needs to be delivered 4006 // This message can be sent during event-handling, and needs to be delivered
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
4179 const webkit_glue::CustomContextMenuContext& custom_context) { 4237 const webkit_glue::CustomContextMenuContext& custom_context) {
4180 if (custom_context.is_pepper_menu) 4238 if (custom_context.is_pepper_menu)
4181 pepper_delegate_.OnContextMenuClosed(custom_context); 4239 pepper_delegate_.OnContextMenuClosed(custom_context);
4182 else 4240 else
4183 context_menu_node_.reset(); 4241 context_menu_node_.reset();
4184 } 4242 }
4185 4243
4186 void RenderView::OnNetworkStateChanged(bool online) { 4244 void RenderView::OnNetworkStateChanged(bool online) {
4187 WebNetworkStateNotifier::setOnLine(online); 4245 WebNetworkStateNotifier::setOnLine(online);
4188 } 4246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698