Implement the form owner concept

This commit is contained in:
Mukilan Thiyagarajan 2017-01-28 17:20:01 +03:00 committed by Anthony Ramine
parent f90e19f705
commit 38a61712e4
25 changed files with 1004 additions and 165 deletions

View file

@ -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 {}