| OLD | NEW |
| 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 "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 | 392 |
| 393 return strings; | 393 return strings; |
| 394 } | 394 } |
| 395 | 395 |
| 396 // How much we should scroll per event - the value here is chosen to match the | 396 // How much we should scroll per event - the value here is chosen to match the |
| 397 // WebKit impl and layout test results. | 397 // WebKit impl and layout test results. |
| 398 const float kScrollbarPixelsPerTick = 40.0f; | 398 const float kScrollbarPixelsPerTick = 40.0f; |
| 399 | 399 |
| 400 bool NeedsShiftModifier(int keyCode) { | |
| 401 // If code is an uppercase letter, assign a SHIFT key to eventDown.modifier. | |
| 402 return (keyCode & 0xFF) >= 'A' && (keyCode & 0xFF) <= 'Z'; | |
| 403 } | |
| 404 | |
| 405 // Get the edit command corresponding to a keyboard event. | 400 // Get the edit command corresponding to a keyboard event. |
| 406 // Returns true if the specified event corresponds to an edit command, the name | 401 // Returns true if the specified event corresponds to an edit command, the name |
| 407 // of the edit command will be stored in |*name|. | 402 // of the edit command will be stored in |*name|. |
| 408 bool GetEditCommand(const WebKeyboardEvent& event, std::string* name) { | 403 bool GetEditCommand(const WebKeyboardEvent& event, std::string* name) { |
| 409 #if defined(OS_MACOSX) | 404 #if defined(OS_MACOSX) |
| 410 // We only cares about Left,Right,Up,Down keys with Command or Command+Shift | 405 // We only cares about Left,Right,Up,Down keys with Command or Command+Shift |
| 411 // modifiers. These key events correspond to some special movement and | 406 // modifiers. These key events correspond to some special movement and |
| 412 // selection editor commands. These keys will be marked as system key, which | 407 // selection editor commands. These keys will be marked as system key, which |
| 413 // prevents them from being handled. Thus they must be handled specially. | 408 // prevents them from being handled. Thus they must be handled specially. |
| 414 if ((event.modifiers & ~WebKeyboardEvent::ShiftKey) != | 409 if ((event.modifiers & ~WebKeyboardEvent::ShiftKey) != |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 } | 1517 } |
| 1523 if (!code) { | 1518 if (!code) { |
| 1524 base::string16 code_str16 = base::UTF8ToUTF16(code_str); | 1519 base::string16 code_str16 = base::UTF8ToUTF16(code_str); |
| 1525 if (code_str16.size() != 1u) { | 1520 if (code_str16.size() != 1u) { |
| 1526 v8::Isolate* isolate = blink::mainThreadIsolate(); | 1521 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 1527 isolate->ThrowException(v8::Exception::TypeError( | 1522 isolate->ThrowException(v8::Exception::TypeError( |
| 1528 gin::StringToV8(isolate, "Invalid web code."))); | 1523 gin::StringToV8(isolate, "Invalid web code."))); |
| 1529 return; | 1524 return; |
| 1530 } | 1525 } |
| 1531 text = code = code_str16[0]; | 1526 text = code = code_str16[0]; |
| 1532 needs_shift_key_modifier = NeedsShiftModifier(code); | 1527 needs_shift_key_modifier = base::IsAsciiUpper(code & 0xFF); |
| 1533 if ((code & 0xFF) >= 'a' && (code & 0xFF) <= 'z') | 1528 if (base::IsAsciiLower(code & 0xFF)) |
| 1534 code -= 'a' - 'A'; | 1529 code -= 'a' - 'A'; |
| 1535 if ((code >= 'A' && code <= 'Z') || (code >= 'a' && code <= 'z')) { | 1530 if (base::IsAsciiAlpha(code)) { |
| 1536 domString.assign("Key"); | 1531 domString.assign("Key"); |
| 1537 domString.push_back( | 1532 domString.push_back( |
| 1538 base::ToUpperASCII(static_cast<base::char16>(code))); | 1533 base::ToUpperASCII(static_cast<base::char16>(code))); |
| 1539 } else if (code >= '0' && code <= '9') { | 1534 } else if (base::IsAsciiDigit(code)) { |
| 1540 domString.assign("Digit"); | 1535 domString.assign("Digit"); |
| 1541 domString.push_back(code); | 1536 domString.push_back(code); |
| 1542 } else if (code == ' ') { | 1537 } else if (code == ' ') { |
| 1543 domString.assign("Space"); | 1538 domString.assign("Space"); |
| 1544 } else if (code == 9) { | 1539 } else if (code == 9) { |
| 1545 domString.assign("Tab"); | 1540 domString.assign("Tab"); |
| 1546 } | 1541 } |
| 1547 generate_char = true; | 1542 generate_char = true; |
| 1548 } | 1543 } |
| 1549 | 1544 |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 &end_event); | 2758 &end_event); |
| 2764 end_event.data.scrollEnd.deltaUnits = | 2759 end_event.data.scrollEnd.deltaUnits = |
| 2765 begin_event.data.scrollBegin.deltaHintUnits; | 2760 begin_event.data.scrollBegin.deltaHintUnits; |
| 2766 | 2761 |
| 2767 if (force_layout_on_events_) | 2762 if (force_layout_on_events_) |
| 2768 view_->updateAllLifecyclePhases(); | 2763 view_->updateAllLifecyclePhases(); |
| 2769 HandleInputEventOnViewOrPopup(end_event); | 2764 HandleInputEventOnViewOrPopup(end_event); |
| 2770 } | 2765 } |
| 2771 | 2766 |
| 2772 } // namespace test_runner | 2767 } // namespace test_runner |
| OLD | NEW |