diff options
Diffstat (limited to 'components/script/dom/htmllabelelement.rs')
-rw-r--r-- | components/script/dom/htmllabelelement.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index 448e5075ba5..62fbec44731 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::activation::Activatable; use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLLabelElementBinding; use dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods; @@ -9,6 +10,8 @@ use dom::bindings::conversions::Castable; use dom::bindings::js::Root; use dom::document::Document; use dom::element::Element; +use dom::event::Event; +use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; use dom::htmlformelement::{FormControl, HTMLFormElement}; use dom::node::{document_from_node, Node}; @@ -40,6 +43,40 @@ impl HTMLLabelElement { } } +impl Activatable for HTMLLabelElement { + fn as_element(&self) -> &Element { + self.upcast::<Element>() + } + + fn is_instance_activatable(&self) -> bool { + return true; + } + + // https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps + // https://html.spec.whatwg.org/multipage/#the-button-element:activation-behavior + fn pre_click_activation(&self) { + } + + // https://html.spec.whatwg.org/multipage/#run-canceled-activation-steps + fn canceled_activation(&self) { + } + + // https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps + fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { + self.upcast::<Element>() + .as_maybe_activatable() + .map(|a| a.synthetic_click_activation(false, false, false, false)); + } + + // https://html.spec.whatwg.org/multipage/#implicit-submission + fn implicit_submission(&self, _ctrlKey: bool, _shiftKey: bool, _altKey: bool, _metaKey: bool) { + //FIXME: Investigate and implement implicit submission for label elements + // Issue filed at https://github.com/servo/servo/issues/8263 + } + + +} + impl HTMLLabelElementMethods for HTMLLabelElement { // https://html.spec.whatwg.org/multipage/#dom-fae-form fn GetForm(&self) -> Option<Root<HTMLFormElement>> { |