Chromium Code Reviews| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 | 182 |
| 183 // Create IPC messages from Windows messages and send them to our | 183 // Create IPC messages from Windows messages and send them to our |
| 184 // back-end. | 184 // back-end. |
| 185 // A keyboard event of Windows consists of three Windows messages: | 185 // A keyboard event of Windows consists of three Windows messages: |
| 186 // WM_KEYDOWN, WM_CHAR, and WM_KEYUP. | 186 // WM_KEYDOWN, WM_CHAR, and WM_KEYUP. |
| 187 // WM_KEYDOWN and WM_KEYUP sends virtual-key codes. On the other hand, | 187 // WM_KEYDOWN and WM_KEYUP sends virtual-key codes. On the other hand, |
| 188 // WM_CHAR sends a composed Unicode character. | 188 // WM_CHAR sends a composed Unicode character. |
| 189 MSG msg1 = { NULL, WM_KEYDOWN, key_code, 0 }; | 189 MSG msg1 = { NULL, WM_KEYDOWN, key_code, 0 }; |
| 190 #if defined(USE_AURA) | 190 #if defined(USE_AURA) |
| 191 ui::KeyEvent evt1(msg1); | 191 ui::KeyEvent evt1(msg1); |
| 192 NativeWebKeyboardEvent keydown_event(&evt1); | 192 NativeWebKeyboardEvent keydown_event(evt1); |
| 193 #else | 193 #else |
| 194 NativeWebKeyboardEvent keydown_event(msg1); | 194 NativeWebKeyboardEvent keydown_event(msg1); |
| 195 #endif | 195 #endif |
|
Andre
2014/11/20 01:01:43
Should I delete these USE_AURA guards?
sadrul
2014/11/21 19:33:42
Yeah, I think you can remove the non-USE_AURA code
Andre
2014/11/22 00:09:58
Done.
| |
| 196 SendNativeKeyEvent(keydown_event); | 196 SendNativeKeyEvent(keydown_event); |
| 197 | 197 |
| 198 MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 }; | 198 MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 }; |
| 199 #if defined(USE_AURA) | 199 #if defined(USE_AURA) |
| 200 ui::KeyEvent evt2(msg2); | 200 ui::KeyEvent evt2(msg2); |
| 201 NativeWebKeyboardEvent char_event(&evt2); | 201 NativeWebKeyboardEvent char_event(evt2); |
| 202 #else | 202 #else |
| 203 NativeWebKeyboardEvent char_event(msg2); | 203 NativeWebKeyboardEvent char_event(msg2); |
| 204 #endif | 204 #endif |
| 205 SendNativeKeyEvent(char_event); | 205 SendNativeKeyEvent(char_event); |
| 206 | 206 |
| 207 MSG msg3 = { NULL, WM_KEYUP, key_code, 0 }; | 207 MSG msg3 = { NULL, WM_KEYUP, key_code, 0 }; |
| 208 #if defined(USE_AURA) | 208 #if defined(USE_AURA) |
| 209 ui::KeyEvent evt3(msg3); | 209 ui::KeyEvent evt3(msg3); |
| 210 NativeWebKeyboardEvent keyup_event(&evt3); | 210 NativeWebKeyboardEvent keyup_event(evt3); |
| 211 #else | 211 #else |
| 212 NativeWebKeyboardEvent keyup_event(msg3); | 212 NativeWebKeyboardEvent keyup_event(msg3); |
| 213 #endif | 213 #endif |
| 214 SendNativeKeyEvent(keyup_event); | 214 SendNativeKeyEvent(keyup_event); |
| 215 | 215 |
| 216 return length; | 216 return length; |
| 217 #elif defined(USE_AURA) && defined(USE_X11) | 217 #elif defined(USE_AURA) && defined(USE_X11) |
| 218 // We ignore |layout|, which means we are only testing the layout of the | 218 // We ignore |layout|, which means we are only testing the layout of the |
| 219 // current locale. TODO(mazda): fix this to respect |layout|. | 219 // current locale. TODO(mazda): fix this to respect |layout|. |
| 220 CHECK(output); | 220 CHECK(output); |
| 221 const int flags = ConvertMockKeyboardModifier(modifiers); | 221 const int flags = ConvertMockKeyboardModifier(modifiers); |
| 222 | 222 |
| 223 ui::ScopedXI2Event xevent; | 223 ui::ScopedXI2Event xevent; |
| 224 xevent.InitKeyEvent(ui::ET_KEY_PRESSED, | 224 xevent.InitKeyEvent(ui::ET_KEY_PRESSED, |
| 225 static_cast<ui::KeyboardCode>(key_code), | 225 static_cast<ui::KeyboardCode>(key_code), |
| 226 flags); | 226 flags); |
| 227 ui::KeyEvent event1(xevent); | 227 ui::KeyEvent event1(xevent); |
| 228 NativeWebKeyboardEvent keydown_event(&event1); | 228 NativeWebKeyboardEvent keydown_event(event1); |
| 229 SendNativeKeyEvent(keydown_event); | 229 SendNativeKeyEvent(keydown_event); |
| 230 | 230 |
| 231 // X11 doesn't actually have native character events, but give the test | 231 // X11 doesn't actually have native character events, but give the test |
| 232 // what it wants. | 232 // what it wants. |
| 233 xevent.InitKeyEvent(ui::ET_KEY_PRESSED, | 233 xevent.InitKeyEvent(ui::ET_KEY_PRESSED, |
| 234 static_cast<ui::KeyboardCode>(key_code), | 234 static_cast<ui::KeyboardCode>(key_code), |
| 235 flags); | 235 flags); |
| 236 ui::KeyEvent event2(xevent); | 236 ui::KeyEvent event2(xevent); |
| 237 event2.set_character(GetCharacterFromKeyCode(event2.key_code(), | 237 event2.set_character(GetCharacterFromKeyCode(event2.key_code(), |
| 238 event2.flags())); | 238 event2.flags())); |
| 239 ui::KeyEventTestApi test_event2(&event2); | 239 ui::KeyEventTestApi test_event2(&event2); |
| 240 test_event2.set_is_char(true); | 240 test_event2.set_is_char(true); |
| 241 NativeWebKeyboardEvent char_event(&event2); | 241 NativeWebKeyboardEvent char_event(event2); |
| 242 SendNativeKeyEvent(char_event); | 242 SendNativeKeyEvent(char_event); |
| 243 | 243 |
| 244 xevent.InitKeyEvent(ui::ET_KEY_RELEASED, | 244 xevent.InitKeyEvent(ui::ET_KEY_RELEASED, |
| 245 static_cast<ui::KeyboardCode>(key_code), | 245 static_cast<ui::KeyboardCode>(key_code), |
| 246 flags); | 246 flags); |
| 247 ui::KeyEvent event3(xevent); | 247 ui::KeyEvent event3(xevent); |
| 248 NativeWebKeyboardEvent keyup_event(&event3); | 248 NativeWebKeyboardEvent keyup_event(event3); |
| 249 SendNativeKeyEvent(keyup_event); | 249 SendNativeKeyEvent(keyup_event); |
| 250 | 250 |
| 251 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), | 251 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), |
| 252 flags); | 252 flags); |
| 253 output->assign(1, static_cast<base::char16>(c)); | 253 output->assign(1, static_cast<base::char16>(c)); |
| 254 return 1; | 254 return 1; |
| 255 #elif defined(USE_OZONE) | 255 #elif defined(USE_OZONE) |
| 256 const int flags = ConvertMockKeyboardModifier(modifiers); | 256 const int flags = ConvertMockKeyboardModifier(modifiers); |
| 257 | 257 |
| 258 ui::KeyEvent keydown_event(ui::ET_KEY_PRESSED, | 258 ui::KeyEvent keydown_event(ui::ET_KEY_PRESSED, |
| 259 static_cast<ui::KeyboardCode>(key_code), | 259 static_cast<ui::KeyboardCode>(key_code), |
| 260 flags); | 260 flags); |
| 261 NativeWebKeyboardEvent keydown_web_event(&keydown_event); | 261 NativeWebKeyboardEvent keydown_web_event(keydown_event); |
| 262 SendNativeKeyEvent(keydown_web_event); | 262 SendNativeKeyEvent(keydown_web_event); |
| 263 | 263 |
| 264 ui::KeyEvent char_event(keydown_event.GetCharacter(), | 264 ui::KeyEvent char_event(keydown_event.GetCharacter(), |
| 265 static_cast<ui::KeyboardCode>(key_code), | 265 static_cast<ui::KeyboardCode>(key_code), |
| 266 flags); | 266 flags); |
| 267 NativeWebKeyboardEvent char_web_event(&char_event); | 267 NativeWebKeyboardEvent char_web_event(char_event); |
| 268 SendNativeKeyEvent(char_web_event); | 268 SendNativeKeyEvent(char_web_event); |
| 269 | 269 |
| 270 ui::KeyEvent keyup_event(ui::ET_KEY_RELEASED, | 270 ui::KeyEvent keyup_event(ui::ET_KEY_RELEASED, |
| 271 static_cast<ui::KeyboardCode>(key_code), | 271 static_cast<ui::KeyboardCode>(key_code), |
| 272 flags); | 272 flags); |
| 273 NativeWebKeyboardEvent keyup_web_event(&keyup_event); | 273 NativeWebKeyboardEvent keyup_web_event(keyup_event); |
| 274 SendNativeKeyEvent(keyup_web_event); | 274 SendNativeKeyEvent(keyup_web_event); |
| 275 | 275 |
| 276 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), | 276 long c = GetCharacterFromKeyCode(static_cast<ui::KeyboardCode>(key_code), |
| 277 flags); | 277 flags); |
| 278 output->assign(1, static_cast<base::char16>(c)); | 278 output->assign(1, static_cast<base::char16>(c)); |
| 279 return 1; | 279 return 1; |
| 280 #else | 280 #else |
| 281 NOTIMPLEMENTED(); | 281 NOTIMPLEMENTED(); |
| 282 return L'\0'; | 282 return L'\0'; |
| 283 #endif | 283 #endif |
| (...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2509 | 2509 |
| 2510 gfx::Size initial_size_; | 2510 gfx::Size initial_size_; |
| 2511 }; | 2511 }; |
| 2512 | 2512 |
| 2513 TEST_F(RenderViewImplInitialSizeTest, InitialSize) { | 2513 TEST_F(RenderViewImplInitialSizeTest, InitialSize) { |
| 2514 ASSERT_EQ(initial_size_, view_->GetSize()); | 2514 ASSERT_EQ(initial_size_, view_->GetSize()); |
| 2515 ASSERT_EQ(initial_size_, gfx::Size(view_->GetWebView()->size())); | 2515 ASSERT_EQ(initial_size_, gfx::Size(view_->GetWebView()->size())); |
| 2516 } | 2516 } |
| 2517 | 2517 |
| 2518 } // namespace content | 2518 } // namespace content |
| OLD | NEW |