Implement initial pieces of form validation.

This commit is contained in:
Sagar Muchhal 2016-03-18 19:53:34 -04:00 committed by Josh Matthews
parent 7a9dc57761
commit 051ffba0e5
14 changed files with 185 additions and 55 deletions

View file

@ -13,6 +13,7 @@ use dom::element::{AttributeMutation, Element};
use dom::htmlelement::HTMLElement;
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, window_from_node};
use dom::validation::Validatable;
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
use net_traits::image::base::Image;
@ -76,7 +77,7 @@ impl HTMLObjectElementMethods for HTMLObjectElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())
ValidityState::new(window.r(), self.upcast())
}
// https://html.spec.whatwg.org/multipage/#dom-object-type
@ -91,6 +92,8 @@ impl HTMLObjectElementMethods for HTMLObjectElement {
}
}
impl Validatable for HTMLObjectElement {}
impl VirtualMethods for HTMLObjectElement {
fn super_type(&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)