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/htmltextareaelement.rs | |
parent | f90e19f7055387a14cabdf11f77335c7763e3fb7 (diff) | |
download | servo-38a61712e41ddeebb52cace6a9787735947964a4.tar.gz servo-38a61712e41ddeebb52cace6a9787735947964a4.zip |
Implement the form owner concept
Diffstat (limited to 'components/script/dom/htmltextareaelement.rs')
-rwxr-xr-x | components/script/dom/htmltextareaelement.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index e7db7565adf..8a4e9f41cd3 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding; use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, Root}; +use dom::bindings::js::{LayoutJS, MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -30,6 +30,7 @@ use html5ever_atoms::LocalName; use ipc_channel::ipc::IpcSender; use script_traits::ScriptMsg as ConstellationMsg; use std::cell::Cell; +use std::default::Default; use std::ops::Range; use style::attr::AttrValue; use style::element_state::*; @@ -43,6 +44,7 @@ pub struct HTMLTextAreaElement { placeholder: DOMRefCell<DOMString>, // https://html.spec.whatwg.org/multipage/#concept-textarea-dirty value_changed: Cell<bool>, + form_owner: MutNullableJS<HTMLFormElement>, } pub trait LayoutHTMLTextAreaElementHelpers { @@ -116,6 +118,7 @@ impl HTMLTextAreaElement { textinput: DOMRefCell::new(TextInput::new( Lines::Multiple, DOMString::new(), chan, None, None, SelectionDirection::None)), value_changed: Cell::new(false), + form_owner: Default::default(), } } @@ -342,7 +345,10 @@ impl VirtualMethods for HTMLTextAreaElement { el.set_read_write_state(!el.disabled_state()); } } - } + }, + local_name!("form") => { + self.form_attribute_mutated(mutation); + }, _ => {}, } } @@ -435,7 +441,19 @@ impl VirtualMethods for HTMLTextAreaElement { } } -impl FormControl for HTMLTextAreaElement {} +impl FormControl for HTMLTextAreaElement { + 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>() + } +} impl Validatable for HTMLTextAreaElement {} |