aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmloutputelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmloutputelement.rs')
-rw-r--r--components/script/dom/htmloutputelement.rs41
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>()
+ }
+}