diff options
author | Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com> | 2017-01-28 17:20:01 +0300 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-03-15 16:39:55 +0100 |
commit | 38a61712e41ddeebb52cace6a9787735947964a4 (patch) | |
tree | f9949282e968e9a8fd57a8c8aa1fd63a59d0a89c /components/script/dom/htmllegendelement.rs | |
parent | f90e19f7055387a14cabdf11f77335c7763e3fb7 (diff) | |
download | servo-38a61712e41ddeebb52cace6a9787735947964a4.tar.gz servo-38a61712e41ddeebb52cace6a9787735947964a4.zip |
Implement the form owner concept
Diffstat (limited to 'components/script/dom/htmllegendelement.rs')
-rw-r--r-- | components/script/dom/htmllegendelement.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index f05ec6bfd3b..86b34c27dd0 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::HTMLLegendElementBinding; use dom::bindings::codegen::Bindings::HTMLLegendElementBinding::HTMLLegendElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::Element; @@ -21,6 +21,7 @@ use html5ever_atoms::LocalName; #[dom_struct] pub struct HTMLLegendElement { htmlelement: HTMLElement, + form_owner: MutNullableJS<HTMLFormElement>, } impl HTMLLegendElement { @@ -28,7 +29,10 @@ impl HTMLLegendElement { prefix: Option<DOMString>, document: &Document) -> HTMLLegendElement { - HTMLLegendElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document) } + HTMLLegendElement { + htmlelement: HTMLElement::new_inherited(local_name, prefix, document), + form_owner: Default::default(), + } } #[allow(unrooted_must_root)] @@ -83,4 +87,16 @@ impl HTMLLegendElementMethods for HTMLLegendElement { } } -impl FormControl for HTMLLegendElement {} +impl FormControl for HTMLLegendElement { + fn form_owner(&self) -> Option<Root<HTMLFormElement>> { + self.form_owner.get() + } + + fn set_form_owner(&self, form: Option<&HTMLFormElement>) { + self.form_owner.set(form); + } + + fn to_element<'a>(&'a self) -> &'a Element { + self.upcast::<Element>() + } +} |