diff options
author | Josh Matthews <josh@joshmatthews.net> | 2014-04-10 21:29:54 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2014-05-03 14:18:30 -0400 |
commit | 76783b029e5e10da7fd61ab356a8f80a1eaf32e0 (patch) | |
tree | 93697ff8906d2661434abc660ae57607b1871b59 /src/components/script/dom/htmlselectelement.rs | |
parent | dfdda0098a3f169a37c100b36d4dd36ec1d815aa (diff) | |
download | servo-76783b029e5e10da7fd61ab356a8f80a1eaf32e0.tar.gz servo-76783b029e5e10da7fd61ab356a8f80a1eaf32e0.zip |
Move WebIDL methods to traits implemented by JSRef types.
Diffstat (limited to 'src/components/script/dom/htmlselectelement.rs')
-rw-r--r-- | src/components/script/dom/htmlselectelement.rs | 111 |
1 files changed, 75 insertions, 36 deletions
diff --git a/src/components/script/dom/htmlselectelement.rs b/src/components/script/dom/htmlselectelement.rs index 666cb529774..6aa15a1e982 100644 --- a/src/components/script/dom/htmlselectelement.rs +++ b/src/components/script/dom/htmlselectelement.rs @@ -44,141 +44,180 @@ impl HTMLSelectElement { } } -impl HTMLSelectElement { - pub fn Autofocus(&self) -> bool { +pub trait HTMLSelectElementMethods { + fn Autofocus(&self) -> bool; + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult; + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn GetForm(&self) -> Option<Unrooted<HTMLFormElement>>; + fn Multiple(&self) -> bool; + fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Required(&self) -> bool; + fn SetRequired(&mut self, _multiple: bool) -> ErrorResult; + fn Size(&self) -> u32; + fn SetSize(&mut self, _size: u32) -> ErrorResult; + fn Type(&self) -> DOMString; + fn Length(&self) -> u32; + fn SetLength(&mut self, _length: u32) -> ErrorResult; + fn Item(&self, _index: u32) -> Option<Unrooted<Element>>; + fn NamedItem(&self, _name: DOMString) -> Option<Unrooted<HTMLOptionElement>>; + fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Unrooted<Element>>; + fn IndexedSetter(&mut self, _index: u32, _option: Option<JSRef<HTMLOptionElement>>) -> ErrorResult; + fn Remove_(&self); + fn Remove(&self, _index: i32); + fn SelectedIndex(&self) -> i32; + fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString); + fn WillValidate(&self) -> bool; + fn SetWillValidate(&mut self, _will_validate: bool); + fn Validity(&self) -> Unrooted<ValidityState>; + fn SetValidity(&mut self, _validity: JS<ValidityState>); + fn ValidationMessage(&self) -> DOMString; + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&mut self, _error: DOMString); + fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) -> ErrorResult; +} + +impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> { + fn Autofocus(&self) -> bool { false } - pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { Ok(()) } - pub fn Disabled(&self) -> bool { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn GetForm(&self) -> Option<Unrooted<HTMLFormElement>> { + fn GetForm(&self) -> Option<Unrooted<HTMLFormElement>> { None } - pub fn Multiple(&self) -> bool { + fn Multiple(&self) -> bool { false } - pub fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { + fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Required(&self) -> bool { + fn Required(&self) -> bool { false } - pub fn SetRequired(&mut self, _multiple: bool) -> ErrorResult { + fn SetRequired(&mut self, _multiple: bool) -> ErrorResult { Ok(()) } - pub fn Size(&self) -> u32 { + fn Size(&self) -> u32 { 0 } - pub fn SetSize(&mut self, _size: u32) -> ErrorResult { + fn SetSize(&mut self, _size: u32) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn Length(&self) -> u32 { + fn Length(&self) -> u32 { 0 } - pub fn SetLength(&mut self, _length: u32) -> ErrorResult { + fn SetLength(&mut self, _length: u32) -> ErrorResult { Ok(()) } - pub fn Item(&self, _index: u32) -> Option<Unrooted<Element>> { + fn Item(&self, _index: u32) -> Option<Unrooted<Element>> { None } - pub fn NamedItem(&self, _name: DOMString) -> Option<Unrooted<HTMLOptionElement>> { + fn NamedItem(&self, _name: DOMString) -> Option<Unrooted<HTMLOptionElement>> { None } - pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Unrooted<Element>> { + fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Unrooted<Element>> { None } - pub fn IndexedSetter(&mut self, _index: u32, _option: Option<JSRef<HTMLOptionElement>>) -> ErrorResult { + fn IndexedSetter(&mut self, _index: u32, _option: Option<JSRef<HTMLOptionElement>>) -> ErrorResult { Ok(()) } - pub fn Remove_(&self) { + fn Remove_(&self) { } - pub fn Remove(&self, _index: i32) { + fn Remove(&self, _index: i32) { } - pub fn SelectedIndex(&self) -> i32 { + fn SelectedIndex(&self) -> i32 { 0 } - pub fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult { + fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) { + fn SetValue(&mut self, _value: DOMString) { } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn SetWillValidate(&mut self, _will_validate: bool) { + fn SetWillValidate(&mut self, _will_validate: bool) { } - pub fn Validity(&self) -> Unrooted<ValidityState> { + fn Validity(&self) -> Unrooted<ValidityState> { let roots = RootCollection::new(); let doc = self.htmlelement.element.node.owner_doc().root(&roots); let window = doc.deref().window.root(&roots); ValidityState::new(&*window) } - pub fn SetValidity(&mut self, _validity: JS<ValidityState>) { + fn SetValidity(&mut self, _validity: JS<ValidityState>) { } - pub fn ValidationMessage(&self) -> DOMString { + fn ValidationMessage(&self) -> DOMString { ~"" } - pub fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { Ok(()) } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { true } - pub fn SetCustomValidity(&mut self, _error: DOMString) { + fn SetCustomValidity(&mut self, _error: DOMString) { } - pub fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) -> ErrorResult { + fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) -> ErrorResult { Ok(()) } } + |