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

Side by Side Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 929053004: [KeyboardEvent] Add embedder APIs to translate between Dom |key| enum and strings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shell/renderer/test_runner/event_sender.h" 5 #include "content/shell/renderer/test_runner/event_sender.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 // FIXME: Should we also generate a KEY_UP? 1265 // FIXME: Should we also generate a KEY_UP?
1266 1266
1267 bool generate_char = false; 1267 bool generate_char = false;
1268 1268
1269 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when 1269 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when
1270 // Windows uses \r for "Enter". 1270 // Windows uses \r for "Enter".
1271 int code = 0; 1271 int code = 0;
1272 int text = 0; 1272 int text = 0;
1273 bool needs_shift_key_modifier = false; 1273 bool needs_shift_key_modifier = false;
1274 std::string domString; 1274 std::string domString;
1275 std::string domKey;
1275 1276
1276 if ("\n" == code_str) { 1277 if ("\n" == code_str) {
1277 generate_char = true; 1278 generate_char = true;
1278 text = code = ui::VKEY_RETURN; 1279 text = code = ui::VKEY_RETURN;
1279 domString.assign("Enter"); 1280 domString.assign("Enter");
1280 } else if ("rightArrow" == code_str) { 1281 } else if ("rightArrow" == code_str) {
1281 code = ui::VKEY_RIGHT; 1282 code = ui::VKEY_RIGHT;
1282 domString.assign("ArrowRight"); 1283 domString.assign("ArrowRight");
1283 } else if ("downArrow" == code_str) { 1284 } else if ("downArrow" == code_str) {
1284 code = ui::VKEY_DOWN; 1285 code = ui::VKEY_DOWN;
(...skipping 21 matching lines...) Expand all
1306 domString.assign("Home"); 1307 domString.assign("Home");
1307 } else if ("end" == code_str) { 1308 } else if ("end" == code_str) {
1308 code = ui::VKEY_END; 1309 code = ui::VKEY_END;
1309 domString.assign("End"); 1310 domString.assign("End");
1310 } else if ("printScreen" == code_str) { 1311 } else if ("printScreen" == code_str) {
1311 code = ui::VKEY_SNAPSHOT; 1312 code = ui::VKEY_SNAPSHOT;
1312 domString.assign("PrintScreen"); 1313 domString.assign("PrintScreen");
1313 } else if ("menu" == code_str) { 1314 } else if ("menu" == code_str) {
1314 code = ui::VKEY_APPS; 1315 code = ui::VKEY_APPS;
1315 domString.assign("ContextMenu"); 1316 domString.assign("ContextMenu");
1317 domKey.assign("MediaApps");
1316 } else if ("leftControl" == code_str) { 1318 } else if ("leftControl" == code_str) {
1317 code = ui::VKEY_LCONTROL; 1319 code = ui::VKEY_LCONTROL;
1318 domString.assign("ControlLeft"); 1320 domString.assign("ControlLeft");
1321 domKey.assign("Control");
1319 } else if ("rightControl" == code_str) { 1322 } else if ("rightControl" == code_str) {
1320 code = ui::VKEY_RCONTROL; 1323 code = ui::VKEY_RCONTROL;
1321 domString.assign("ControlRight"); 1324 domString.assign("ControlRight");
1325 domKey.assign("Control");
1322 } else if ("leftShift" == code_str) { 1326 } else if ("leftShift" == code_str) {
1323 code = ui::VKEY_LSHIFT; 1327 code = ui::VKEY_LSHIFT;
1324 domString.assign("ShiftLeft"); 1328 domString.assign("ShiftLeft");
1329 domKey.assign("Shift");
1325 } else if ("rightShift" == code_str) { 1330 } else if ("rightShift" == code_str) {
1326 code = ui::VKEY_RSHIFT; 1331 code = ui::VKEY_RSHIFT;
1327 domString.assign("ShiftRight"); 1332 domString.assign("ShiftRight");
1333 domKey.assign("Shift");
1328 } else if ("leftAlt" == code_str) { 1334 } else if ("leftAlt" == code_str) {
1329 code = ui::VKEY_LMENU; 1335 code = ui::VKEY_LMENU;
1330 domString.assign("AltLeft"); 1336 domString.assign("AltLeft");
1337 domKey.assign("Alt");
1331 } else if ("rightAlt" == code_str) { 1338 } else if ("rightAlt" == code_str) {
1332 code = ui::VKEY_RMENU; 1339 code = ui::VKEY_RMENU;
1333 domString.assign("AltRight"); 1340 domString.assign("AltRight");
1341 domKey.assign("AltGraph");
1334 } else if ("numLock" == code_str) { 1342 } else if ("numLock" == code_str) {
1335 code = ui::VKEY_NUMLOCK; 1343 code = ui::VKEY_NUMLOCK;
1336 domString.assign("NumLock"); 1344 domString.assign("NumLock");
1337 } else if ("backspace" == code_str) { 1345 } else if ("backspace" == code_str) {
1338 code = ui::VKEY_BACK; 1346 code = ui::VKEY_BACK;
1339 domString.assign("Backspace"); 1347 domString.assign("Backspace");
1340 } else if ("escape" == code_str) { 1348 } else if ("escape" == code_str) {
1341 code = ui::VKEY_ESCAPE; 1349 code = ui::VKEY_ESCAPE;
1342 domString.assign("Escape"); 1350 domString.assign("Escape");
1343 } else { 1351 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 // pair; 1392 // pair;
1385 // On Windows, we might also need to generate a char event to mimic the 1393 // On Windows, we might also need to generate a char event to mimic the
1386 // Windows event flow; on other platforms we create a merged event and test 1394 // Windows event flow; on other platforms we create a merged event and test
1387 // the event flow that that platform provides. 1395 // the event flow that that platform provides.
1388 WebKeyboardEvent event_down; 1396 WebKeyboardEvent event_down;
1389 event_down.type = WebInputEvent::RawKeyDown; 1397 event_down.type = WebInputEvent::RawKeyDown;
1390 event_down.modifiers = modifiers; 1398 event_down.modifiers = modifiers;
1391 event_down.windowsKeyCode = code; 1399 event_down.windowsKeyCode = code;
1392 event_down.domCode = static_cast<int>( 1400 event_down.domCode = static_cast<int>(
1393 ui::KeycodeConverter::CodeStringToDomCode(domString.c_str())); 1401 ui::KeycodeConverter::CodeStringToDomCode(domString.c_str()));
1402 if (domKey.empty())
1403 domKey = domString;
1404 event_down.domKey = static_cast<int>(
1405 ui::KeycodeConverter::KeyStringToDomKey(domKey.c_str()));
1394 1406
1395 if (generate_char) { 1407 if (generate_char) {
1396 event_down.text[0] = text; 1408 event_down.text[0] = text;
1397 event_down.unmodifiedText[0] = text; 1409 event_down.unmodifiedText[0] = text;
1398 } 1410 }
1399 1411
1400 event_down.setKeyIdentifierFromWindowsKeyCode(); 1412 event_down.setKeyIdentifierFromWindowsKeyCode();
1401 1413
1402 if (event_down.modifiers != 0) 1414 if (event_down.modifiers != 0)
1403 event_down.isSystemKey = IsSystemKeyEvent(event_down); 1415 event_down.isSystemKey = IsSystemKeyEvent(event_down);
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 2471
2460 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { 2472 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) {
2461 if (WebPagePopup* popup = view_->pagePopup()) { 2473 if (WebPagePopup* popup = view_->pagePopup()) {
2462 if (!WebInputEvent::isKeyboardEventType(event.type)) 2474 if (!WebInputEvent::isKeyboardEventType(event.type))
2463 return popup->handleInputEvent(event); 2475 return popup->handleInputEvent(event);
2464 } 2476 }
2465 return view_->handleInputEvent(event); 2477 return view_->handleInputEvent(event);
2466 } 2478 }
2467 2479
2468 } // namespace content 2480 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blink_platform_impl.cc ('k') | ui/events/event.cc » ('j') | ui/events/event.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698