diff options
-rw-r--r-- | components/script/dom/htmlformelement.rs | 4 | ||||
-rw-r--r-- | components/script/dom/htmlinputelement.rs | 17 | ||||
-rw-r--r-- | components/script/dom/webidls/HTMLInputElement.webidl | 2 |
3 files changed, 19 insertions, 4 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index a8461618db9..3ac799fdc04 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -410,7 +410,7 @@ impl<'a> FormSubmitter<'a> { } } -pub trait FormOwner<'a> : Copy { +pub trait FormControl<'a> : Copy { fn form_owner(self) -> Option<Temporary<HTMLFormElement>>; fn get_form_attribute(self, attr: &Atom, @@ -423,4 +423,6 @@ pub trait FormOwner<'a> : Copy { } } fn to_element(self) -> JSRef<'a, Element>; + // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable + fn mutable(self) -> bool; } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 378952d4da3..30b4dcaa820 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -23,7 +23,7 @@ use dom::event::Event; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::htmlelement::HTMLElement; use dom::keyboardevent::KeyboardEvent; -use dom::htmlformelement::{InputElement, FormOwner, HTMLFormElement, HTMLFormElementHelpers, NotFromFormSubmitMethod}; +use dom::htmlformelement::{InputElement, FormControl, HTMLFormElement, HTMLFormElementHelpers, NotFromFormSubmitMethod}; use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use textinput::{Single, TextInput, TriggerDefaultAction, DispatchInput, Nothing}; @@ -151,6 +151,12 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> { // https://html.spec.whatwg.org/multipage/forms.html#dom-input-checked make_bool_setter!(SetChecked, "checked") + // https://html.spec.whatwg.org/multipage/forms.html#dom-input-readonly + make_bool_getter!(ReadOnly) + + // https://html.spec.whatwg.org/multipage/forms.html#dom-input-readonly + make_bool_setter!(SetReadOnly, "readonly") + // https://html.spec.whatwg.org/multipage/forms.html#dom-input-size make_uint_getter!(Size) @@ -457,7 +463,7 @@ impl Reflectable for HTMLInputElement { } } -impl<'a> FormOwner<'a> for JSRef<'a, HTMLInputElement> { +impl<'a> FormControl<'a> for JSRef<'a, HTMLInputElement> { // FIXME: This is wrong (https://github.com/servo/servo/issues/3553) // but we need html5ever to do it correctly fn form_owner(self) -> Option<Temporary<HTMLFormElement>> { @@ -485,4 +491,11 @@ impl<'a> FormOwner<'a> for JSRef<'a, HTMLInputElement> { fn to_element(self) -> JSRef<'a, Element> { ElementCast::from_ref(self) } + + // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable + 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-readonly-attribute:concept-fe-mutable + !(self.Disabled() || self.ReadOnly()) + } } diff --git a/components/script/dom/webidls/HTMLInputElement.webidl b/components/script/dom/webidls/HTMLInputElement.webidl index b69d8fcf4ff..32b4f04261b 100644 --- a/components/script/dom/webidls/HTMLInputElement.webidl +++ b/components/script/dom/webidls/HTMLInputElement.webidl @@ -32,7 +32,7 @@ interface HTMLInputElement : HTMLElement { attribute DOMString name; // attribute DOMString pattern; // attribute DOMString placeholder; - // attribute boolean readOnly; + attribute boolean readOnly; // attribute boolean required; attribute unsigned long size; // attribute DOMString src; |