| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "third_party/WebKit/public/web/WebDataSource.h" | 45 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 46 #include "third_party/WebKit/public/web/WebFrame.h" | 46 #include "third_party/WebKit/public/web/WebFrame.h" |
| 47 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 47 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 48 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 48 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 49 #include "third_party/WebKit/public/web/WebView.h" | 49 #include "third_party/WebKit/public/web/WebView.h" |
| 50 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 50 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 51 #include "ui/events/keycodes/keyboard_codes.h" | 51 #include "ui/events/keycodes/keyboard_codes.h" |
| 52 #include "ui/gfx/codec/jpeg_codec.h" | 52 #include "ui/gfx/codec/jpeg_codec.h" |
| 53 #include "ui/gfx/range/range.h" | 53 #include "ui/gfx/range/range.h" |
| 54 | 54 |
| 55 #if defined(OS_LINUX) && !defined(USE_AURA) | |
| 56 #include "ui/base/gtk/event_synthesis_gtk.h" | |
| 57 #endif | |
| 58 | |
| 59 #if defined(USE_AURA) | 55 #if defined(USE_AURA) |
| 60 #include "ui/events/event.h" | 56 #include "ui/events/event.h" |
| 61 #endif | 57 #endif |
| 62 | 58 |
| 63 #if defined(USE_AURA) && defined(USE_X11) | 59 #if defined(USE_AURA) && defined(USE_X11) |
| 64 #include <X11/Xlib.h> | 60 #include <X11/Xlib.h> |
| 65 #include "ui/events/event_constants.h" | 61 #include "ui/events/event_constants.h" |
| 66 #include "ui/events/keycodes/keyboard_code_conversion.h" | 62 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 67 #include "ui/events/test/events_test_utils_x11.h" | 63 #include "ui/events/test/events_test_utils_x11.h" |
| 68 #endif | 64 #endif |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 flags, | 259 flags, |
| 264 true); | 260 true); |
| 265 ui::KeyEvent keyup_event(&keyup_native_event, false); | 261 ui::KeyEvent keyup_event(&keyup_native_event, false); |
| 266 NativeWebKeyboardEvent keyup_web_event(&keyup_event); | 262 NativeWebKeyboardEvent keyup_web_event(&keyup_event); |
| 267 SendNativeKeyEvent(keyup_web_event); | 263 SendNativeKeyEvent(keyup_web_event); |
| 268 | 264 |
| 269 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), | 265 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), |
| 270 flags); | 266 flags); |
| 271 output->assign(1, static_cast<base::char16>(c)); | 267 output->assign(1, static_cast<base::char16>(c)); |
| 272 return 1; | 268 return 1; |
| 273 #elif defined(TOOLKIT_GTK) | |
| 274 // We ignore |layout|, which means we are only testing the layout of the | |
| 275 // current locale. TODO(estade): fix this to respect |layout|. | |
| 276 std::vector<GdkEvent*> events; | |
| 277 ui::SynthesizeKeyPressEvents( | |
| 278 NULL, static_cast<ui::KeyboardCode>(key_code), | |
| 279 modifiers & (MockKeyboard::LEFT_CONTROL | MockKeyboard::RIGHT_CONTROL), | |
| 280 modifiers & (MockKeyboard::LEFT_SHIFT | MockKeyboard::RIGHT_SHIFT), | |
| 281 modifiers & (MockKeyboard::LEFT_ALT | MockKeyboard::RIGHT_ALT), | |
| 282 &events); | |
| 283 | |
| 284 guint32 unicode_key = 0; | |
| 285 for (size_t i = 0; i < events.size(); ++i) { | |
| 286 // Only send the up/down events for key press itself (skip the up/down | |
| 287 // events for the modifier keys). | |
| 288 if ((i + 1) == (events.size() / 2) || i == (events.size() / 2)) { | |
| 289 unicode_key = gdk_keyval_to_unicode(events[i]->key.keyval); | |
| 290 NativeWebKeyboardEvent webkit_event(events[i]); | |
| 291 SendNativeKeyEvent(webkit_event); | |
| 292 | |
| 293 // Need to add a char event after the key down. | |
| 294 if (webkit_event.type == blink::WebInputEvent::RawKeyDown) { | |
| 295 NativeWebKeyboardEvent char_event = webkit_event; | |
| 296 char_event.type = blink::WebInputEvent::Char; | |
| 297 char_event.skip_in_browser = true; | |
| 298 SendNativeKeyEvent(char_event); | |
| 299 } | |
| 300 } | |
| 301 gdk_event_free(events[i]); | |
| 302 } | |
| 303 | |
| 304 output->assign(1, static_cast<base::char16>(unicode_key)); | |
| 305 return 1; | |
| 306 #else | 269 #else |
| 307 NOTIMPLEMENTED(); | 270 NOTIMPLEMENTED(); |
| 308 return L'\0'; | 271 return L'\0'; |
| 309 #endif | 272 #endif |
| 310 } | 273 } |
| 311 | 274 |
| 312 private: | 275 private: |
| 313 scoped_ptr<MockKeyboard> mock_keyboard_; | 276 scoped_ptr<MockKeyboard> mock_keyboard_; |
| 314 }; | 277 }; |
| 315 | 278 |
| (...skipping 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 view()->renderer_accessibility()->GetType()); | 2315 view()->renderer_accessibility()->GetType()); |
| 2353 | 2316 |
| 2354 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly); | 2317 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly); |
| 2355 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode()); | 2318 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode()); |
| 2356 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility()); | 2319 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility()); |
| 2357 ASSERT_EQ(RendererAccessibilityTypeFocusOnly, | 2320 ASSERT_EQ(RendererAccessibilityTypeFocusOnly, |
| 2358 view()->renderer_accessibility()->GetType()); | 2321 view()->renderer_accessibility()->GetType()); |
| 2359 } | 2322 } |
| 2360 | 2323 |
| 2361 } // namespace content | 2324 } // namespace content |
| OLD | NEW |