mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
formcontrol trait to element trait
mutable function and reset function in formcontrol move into trait of single element currently only TextArea element and Input element
This commit is contained in:
parent
c5a5db6324
commit
c0867ec90a
3 changed files with 42 additions and 41 deletions
|
@ -187,6 +187,24 @@ impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLTextAreaElementHelpers {
|
||||
fn mutable(self) -> bool;
|
||||
fn reset(self);
|
||||
}
|
||||
|
||||
impl<'a> HTMLTextAreaElementHelpers for JSRef<'a, HTMLTextAreaElement> {
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable
|
||||
fn mutable(self) -> bool {
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-fe-mutable
|
||||
!(self.Disabled() || self.ReadOnly())
|
||||
}
|
||||
fn reset(self) {
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-form-reset-control
|
||||
self.SetValue(self.DefaultValue());
|
||||
self.value_changed.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateHTMLTextAreaElementHelpers {
|
||||
fn force_relayout(self);
|
||||
}
|
||||
|
@ -335,16 +353,4 @@ impl<'a> FormControl<'a> for JSRef<'a, HTMLTextAreaElement> {
|
|||
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-textarea-element:concept-fe-mutable
|
||||
!(self.Disabled() || self.ReadOnly())
|
||||
}
|
||||
|
||||
fn reset(self) {
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-form-reset-control
|
||||
self.SetValue(self.DefaultValue());
|
||||
self.value_changed.set(false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue