| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "core/events/KeyboardEvent.h" | 34 #include "core/events/KeyboardEvent.h" |
| 35 #include "core/html/HTMLInputElement.h" | 35 #include "core/html/HTMLInputElement.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 using namespace HTMLNames; | 39 using namespace HTMLNames; |
| 40 | 40 |
| 41 void KeyboardClickableInputTypeView::handleKeydownEvent(KeyboardEvent* event) | 41 void KeyboardClickableInputTypeView::handleKeydownEvent(KeyboardEvent* event) |
| 42 { | 42 { |
| 43 const String& key = event->keyIdentifier(); | 43 const String& key = event->key(); |
| 44 if (key == "U+0020") { | 44 if (key == " ") { |
| 45 element().setActive(true); | 45 element().setActive(true); |
| 46 // No setDefaultHandled(), because IE dispatches a keypress in this case | 46 // No setDefaultHandled(), because IE dispatches a keypress in this case |
| 47 // and the caller will only dispatch a keypress if we don't call setDefa
ultHandled(). | 47 // and the caller will only dispatch a keypress if we don't call setDefa
ultHandled(). |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void KeyboardClickableInputTypeView::handleKeypressEvent(KeyboardEvent* event) | 51 void KeyboardClickableInputTypeView::handleKeypressEvent(KeyboardEvent* event) |
| 52 { | 52 { |
| 53 int charCode = event->charCode(); | 53 int charCode = event->charCode(); |
| 54 if (charCode == '\r') { | 54 if (charCode == '\r') { |
| 55 element().dispatchSimulatedClick(event); | 55 element().dispatchSimulatedClick(event); |
| 56 event->setDefaultHandled(); | 56 event->setDefaultHandled(); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 if (charCode == ' ') { | 59 if (charCode == ' ') { |
| 60 // Prevent scrolling down the page. | 60 // Prevent scrolling down the page. |
| 61 event->setDefaultHandled(); | 61 event->setDefaultHandled(); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void KeyboardClickableInputTypeView::handleKeyupEvent(KeyboardEvent* event) | 65 void KeyboardClickableInputTypeView::handleKeyupEvent(KeyboardEvent* event) |
| 66 { | 66 { |
| 67 const String& key = event->keyIdentifier(); | 67 const String& key = event->key(); |
| 68 if (key != "U+0020") | 68 if (key != " ") |
| 69 return; | 69 return; |
| 70 // Simulate mouse click for spacebar for button types. | 70 // Simulate mouse click for spacebar for button types. |
| 71 dispatchSimulatedClickIfActive(event); | 71 dispatchSimulatedClickIfActive(event); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // FIXME: Could share this with BaseCheckableInputType and RangeInputType if we
had a common base class. | 74 // FIXME: Could share this with BaseCheckableInputType and RangeInputType if we
had a common base class. |
| 75 void KeyboardClickableInputTypeView::accessKeyAction(bool sendMouseEvents) | 75 void KeyboardClickableInputTypeView::accessKeyAction(bool sendMouseEvents) |
| 76 { | 76 { |
| 77 InputTypeView::accessKeyAction(sendMouseEvents); | 77 InputTypeView::accessKeyAction(sendMouseEvents); |
| 78 element().dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents
: SendNoEvents); | 78 element().dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents
: SendNoEvents); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |