| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 #include <gdk/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
| 10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 static gboolean MouseScrollEvent(GtkWidget* widget, GdkEventScroll* event, | 292 static gboolean MouseScrollEvent(GtkWidget* widget, GdkEventScroll* event, |
| 293 RenderWidgetHostViewGtk* host_view) { | 293 RenderWidgetHostViewGtk* host_view) { |
| 294 host_view->GetRenderWidgetHost()->ForwardWheelEvent( | 294 host_view->GetRenderWidgetHost()->ForwardWheelEvent( |
| 295 WebInputEventFactory::mouseWheelEvent(event)); | 295 WebInputEventFactory::mouseWheelEvent(event)); |
| 296 return FALSE; | 296 return FALSE; |
| 297 } | 297 } |
| 298 | 298 |
| 299 static void InputMethodCommit(GtkIMContext* im_context, | 299 static void InputMethodCommit(GtkIMContext* im_context, |
| 300 gchar* text, | 300 gchar* text, |
| 301 RenderWidgetHostViewGtk* host_view) { | 301 RenderWidgetHostViewGtk* host_view) { |
| 302 std::wstring im_text = UTF8ToWide(text); | 302 const string16& im_text = UTF8ToUTF16(text); |
| 303 if (!host_view->im_is_composing_cjk_text_ && im_text.length() == 1) { | 303 if (!host_view->im_is_composing_cjk_text_ && im_text.length() == 1) { |
| 304 // Send a Char event when we input a composed character without IMEs so | 304 // Send a Char event when we input a composed character without IMEs so |
| 305 // that this event is to be dispatched to onkeypress() handlers, | 305 // that this event is to be dispatched to onkeypress() handlers, |
| 306 // autofill, etc. | 306 // autofill, etc. |
| 307 ForwardCharEvent(host_view, im_text[0]); | 307 ForwardCharEvent(host_view, im_text[0]); |
| 308 } else { | 308 } else { |
| 309 // Send an IME event. | 309 // Send an IME event. |
| 310 // Unlike a Char event, an IME event is NOT dispatched to onkeypress() | 310 // Unlike a Char event, an IME event is NOT dispatched to onkeypress() |
| 311 // handlers or autofill. | 311 // handlers or autofill. |
| 312 host_view->GetRenderWidgetHost()->ImeConfirmComposition(im_text); | 312 host_view->GetRenderWidgetHost()->ImeConfirmComposition(im_text); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 337 RenderWidgetHostViewGtk* host_view) { | 337 RenderWidgetHostViewGtk* host_view) { |
| 338 // Send an IME event to update the composition node of the renderer. | 338 // Send an IME event to update the composition node of the renderer. |
| 339 // TODO(hbono): an IME intercepts all key events while composing a text, | 339 // TODO(hbono): an IME intercepts all key events while composing a text, |
| 340 // i.e. we cannot receive any GDK_KEY_PRESS (or GDK_KEY_UP) events. | 340 // i.e. we cannot receive any GDK_KEY_PRESS (or GDK_KEY_UP) events. |
| 341 // Should we send pseudo KeyDown (and KeyUp) events to emulate Windows? | 341 // Should we send pseudo KeyDown (and KeyUp) events to emulate Windows? |
| 342 gchar* preedit_text = NULL; | 342 gchar* preedit_text = NULL; |
| 343 gint cursor_position = 0; | 343 gint cursor_position = 0; |
| 344 gtk_im_context_get_preedit_string(im_context, &preedit_text, NULL, | 344 gtk_im_context_get_preedit_string(im_context, &preedit_text, NULL, |
| 345 &cursor_position); | 345 &cursor_position); |
| 346 host_view->GetRenderWidgetHost()->ImeSetComposition( | 346 host_view->GetRenderWidgetHost()->ImeSetComposition( |
| 347 UTF8ToWide(preedit_text), cursor_position, -1, -1); | 347 UTF8ToUTF16(preedit_text), cursor_position, -1, -1); |
| 348 g_free(preedit_text); | 348 g_free(preedit_text); |
| 349 } | 349 } |
| 350 | 350 |
| 351 static void ForwardCharEvent(RenderWidgetHostViewGtk* host_view, | 351 static void ForwardCharEvent(RenderWidgetHostViewGtk* host_view, |
| 352 wchar_t im_character) { | 352 wchar_t im_character) { |
| 353 if (!im_character) | 353 if (!im_character) |
| 354 return; | 354 return; |
| 355 | 355 |
| 356 NativeWebKeyboardEvent char_event(im_character, | 356 NativeWebKeyboardEvent char_event(im_character, |
| 357 host_view->im_modifier_state_, | 357 host_view->im_modifier_state_, |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 | 749 |
| 750 void RenderWidgetHostViewGtk::PluginProcessCrashed(base::ProcessId pid) { | 750 void RenderWidgetHostViewGtk::PluginProcessCrashed(base::ProcessId pid) { |
| 751 for (PluginPidMap::iterator i = plugin_pid_map_.find(pid); | 751 for (PluginPidMap::iterator i = plugin_pid_map_.find(pid); |
| 752 i != plugin_pid_map_.end() && i->first == pid; ++i) { | 752 i != plugin_pid_map_.end() && i->first == pid; ++i) { |
| 753 plugin_container_manager_.DestroyPluginContainer(i->second); | 753 plugin_container_manager_.DestroyPluginContainer(i->second); |
| 754 } | 754 } |
| 755 plugin_pid_map_.erase(pid); | 755 plugin_pid_map_.erase(pid); |
| 756 } | 756 } |
| OLD | NEW |