Implements reset button

This commit is contained in:
Matthew Rasmus 2014-12-07 11:18:53 -08:00
parent 7e0c39a82d
commit 4d0a6a6bd6
2 changed files with 27 additions and 1 deletions

View file

@ -27,7 +27,7 @@ use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
use dom::keyboardevent::KeyboardEvent;
use dom::htmlformelement::{InputElement, FormControl, HTMLFormElement, HTMLFormElementHelpers};
use dom::htmlformelement::{NotFromFormSubmitMethod};
use dom::htmlformelement::{NotFromFormSubmitMethod, NotFromFormResetMethod};
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, OtherNodeDamage};
use dom::node::{document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
@ -701,6 +701,15 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
});
}
},
InputReset => {
// https://html.spec.whatwg.org/multipage/forms.html#reset-button-state-(type=reset):activation-behavior
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
if self.mutable() /* and document owner is fully active */ {
self.form_owner().map(|o| {
o.root().reset(NotFromFormResetMethod)
});
}
},
InputCheckbox | InputRadio => {
// https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-(type=checkbox):activation-behavior
// https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio):activation-behavior