mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
auto merge of #4779 : Manishearth/servo/more-activation, r=jdm
This commit is contained in:
commit
1d7b1e5c31
3 changed files with 22 additions and 2 deletions
|
@ -17,6 +17,9 @@ use std::borrow::ToOwned;
|
||||||
pub trait Activatable : Copy {
|
pub trait Activatable : Copy {
|
||||||
fn as_element(&self) -> Temporary<Element>;
|
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
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps
|
||||||
fn pre_click_activation(&self);
|
fn pre_click_activation(&self);
|
||||||
|
|
||||||
|
|
|
@ -1449,7 +1449,11 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
|
||||||
match node.type_id() {
|
match node.type_id() {
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
|
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
|
||||||
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(self).unwrap();
|
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(self).unwrap();
|
||||||
|
if element.is_instance_activatable() {
|
||||||
Some(element as &'a (Activatable + 'a))
|
Some(element as &'a (Activatable + 'a))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
None
|
None
|
||||||
|
|
|
@ -588,7 +588,8 @@ impl<'a> FormControl<'a> for JSRef<'a, HTMLInputElement> {
|
||||||
fn mutable(self) -> bool {
|
fn mutable(self) -> bool {
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-fe-mutable
|
// https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-fe-mutable
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#the-readonly-attribute:concept-fe-mutable
|
// https://html.spec.whatwg.org/multipage/forms.html#the-readonly-attribute:concept-fe-mutable
|
||||||
!(self.Disabled() || self.ReadOnly())
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
!(node.get_disabled_state() || self.ReadOnly())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-form-reset-control
|
// https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-form-reset-control
|
||||||
|
@ -613,6 +614,18 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
|
||||||
Temporary::from_rooted(ElementCast::from_ref(*self))
|
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
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps
|
||||||
#[allow(unsafe_blocks)]
|
#[allow(unsafe_blocks)]
|
||||||
fn pre_click_activation(&self) {
|
fn pre_click_activation(&self) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue