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/htmloutputelement.rs | |
parent | f90e19f7055387a14cabdf11f77335c7763e3fb7 (diff) | |
download | servo-38a61712e41ddeebb52cace6a9787735947964a4.tar.gz servo-38a61712e41ddeebb52cace6a9787735947964a4.zip |
Implement the form owner concept
Diffstat (limited to 'components/script/dom/htmloutputelement.rs')
-rw-r--r-- | components/script/dom/htmloutputelement.rs | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index 6f3154057ea..719efad95d3 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -2,23 +2,27 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLOutputElementBinding; use dom::bindings::codegen::Bindings::HTMLOutputElementBinding::HTMLOutputElementMethods; 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::{AttributeMutation, Element}; use dom::htmlelement::HTMLElement; use dom::htmlformelement::{FormControl, HTMLFormElement}; use dom::node::{Node, window_from_node}; use dom::nodelist::NodeList; use dom::validitystate::ValidityState; +use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever_atoms::LocalName; #[dom_struct] pub struct HTMLOutputElement { - htmlelement: HTMLElement + htmlelement: HTMLElement, + form_owner: MutNullableJS<HTMLFormElement>, } impl HTMLOutputElement { @@ -27,7 +31,8 @@ impl HTMLOutputElement { document: &Document) -> HTMLOutputElement { HTMLOutputElement { htmlelement: - HTMLElement::new_inherited(local_name, prefix, document) + HTMLElement::new_inherited(local_name, prefix, document), + form_owner: Default::default(), } } @@ -59,4 +64,32 @@ impl HTMLOutputElementMethods for HTMLOutputElement { } } -impl FormControl for HTMLOutputElement {} +impl VirtualMethods for HTMLOutputElement { + fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &VirtualMethods) + } + + fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { + self.super_type().unwrap().attribute_mutated(attr, mutation); + match attr.local_name() { + &local_name!("form") => { + self.form_attribute_mutated(mutation); + }, + _ => {}, + } + } +} + +impl FormControl for HTMLOutputElement { + 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>() + } +} |