mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Implement form control mutability, rename FormOwner -> FormControl
This commit is contained in:
parent
2c2d741b1f
commit
7d51a543d8
3 changed files with 19 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue