aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-01-30 20:34:23 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-01-31 06:08:38 +0530
commit26732403b99ca2550d25c2b22aee35a2cdaf3967 (patch)
treeaa9c806226faea114daa166e006d39fdafbc2581
parenta7e29939a1df679bd865573dc71f7ba65f0268c4 (diff)
downloadservo-26732403b99ca2550d25c2b22aee35a2cdaf3967.tar.gz
servo-26732403b99ca2550d25c2b22aee35a2cdaf3967.zip
Specific instances of activatable elements may not be activatable (fixes #4765
-rw-r--r--components/script/dom/activation.rs3
-rw-r--r--components/script/dom/element.rs6
-rw-r--r--components/script/dom/htmlinputelement.rs12
3 files changed, 20 insertions, 1 deletions
diff --git a/components/script/dom/activation.rs b/components/script/dom/activation.rs
index 78e3d6cd4bb..9bd7d4d8f36 100644
--- a/components/script/dom/activation.rs
+++ b/components/script/dom/activation.rs
@@ -17,6 +17,9 @@ use std::borrow::ToOwned;
pub trait Activatable : Copy {
fn as_element(&self) -> Temporary<Element>;
+ // Is this particular instance of the element activatable?
+ fn is_instance_activatable(&self) -> bool;
+
// https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps
fn pre_click_activation(&self);
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 84f3d88ac7d..9b74c0cb5c9 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -1449,7 +1449,11 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(self).unwrap();
- Some(element as &'a (Activatable + 'a))
+ if element.is_instance_activatable() {
+ Some(element as &'a (Activatable + 'a))
+ } else {
+ None
+ }
},
_ => {
None
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 0a5624b77ea..f0af836c983 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -613,6 +613,18 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
Temporary::from_rooted(ElementCast::from_ref(*self))
}
+ fn is_instance_activatable(&self) -> bool {
+ match self.input_type.get() {
+ // https://html.spec.whatwg.org/multipage/forms.html#submit-button-state-%28type=submit%29:activation-behaviour-2
+ // https://html.spec.whatwg.org/multipage/forms.html#reset-button-state-%28type=reset%29:activation-behaviour-2
+ // https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-%28type=checkbox%29:activation-behaviour-2
+ // https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-%28type=radio%29:activation-behaviour-2
+ InputType::InputSubmit | InputType::InputReset
+ | InputType::InputCheckbox | InputType::InputRadio => self.mutable(),
+ _ => false
+ }
+ }
+
// https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps
#[allow(unsafe_blocks)]
fn pre_click_activation(&self) {