Auto merge of #12365 - simartin:issue_12071, r=KiChjang

Issue #12071: Don't submit forms when typing Tab on an input.

<!-- Please describe your changes on the following line: -->
Fixes https://github.com/servo/servo/issues/12071
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12071

<!-- Either: -->
- [X] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12365)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-07-12 16:27:36 -07:00 committed by GitHub
commit 3c3c32f95e
3 changed files with 46 additions and 4 deletions

View file

@ -33,6 +33,7 @@ use dom::validation::Validatable;
use dom::virtualmethods::VirtualMethods;
use ipc_channel::ipc::{self, IpcSender};
use mime_guess;
use msg::constellation_msg::Key;
use net_traits::IpcSend;
use net_traits::filemanager_thread::{FileManagerThreadMsg, FilterPattern};
use script_traits::ScriptMsg as ConstellationMsg;
@ -1046,10 +1047,18 @@ impl VirtualMethods for HTMLInputElement {
let action = self.textinput.borrow_mut().handle_keydown(keyevent);
match action {
TriggerDefaultAction => {
self.implicit_submission(keyevent.CtrlKey(),
keyevent.ShiftKey(),
keyevent.AltKey(),
keyevent.MetaKey());
if let Some(key) = keyevent.get_key() {
match key {
Key::Enter | Key::KpEnter =>
self.implicit_submission(keyevent.CtrlKey(),
keyevent.ShiftKey(),
keyevent.AltKey(),
keyevent.MetaKey()),
// Issue #12071: Tab should not submit forms
// TODO(3982): Implement form keyboard navigation
_ => (),
}
};
},
DispatchInput => {
self.value_changed.set(true);