mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Wrap ValidityState eagerly.
This commit is contained in:
parent
f3f6e62f7f
commit
66a76961cc
6 changed files with 26 additions and 13 deletions
|
@ -104,7 +104,8 @@ impl HTMLButtonElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Validity(&self) -> @mut ValidityState {
|
pub fn Validity(&self) -> @mut ValidityState {
|
||||||
@mut ValidityState::valid()
|
let global = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
|
ValidityState::new(global)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
|
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
|
||||||
|
|
|
@ -47,7 +47,8 @@ impl HTMLFieldSetElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Validity(&self) -> @mut ValidityState {
|
pub fn Validity(&self) -> @mut ValidityState {
|
||||||
@mut ValidityState::valid()
|
let global = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
|
ValidityState::new(global)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ValidationMessage(&self) -> DOMString {
|
pub fn ValidationMessage(&self) -> DOMString {
|
||||||
|
|
|
@ -79,7 +79,8 @@ impl HTMLObjectElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Validity(&self) -> @mut ValidityState {
|
pub fn Validity(&self) -> @mut ValidityState {
|
||||||
@mut ValidityState::valid()
|
let global = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
|
ValidityState::new(global)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ValidationMessage(&self) -> DOMString {
|
pub fn ValidationMessage(&self) -> DOMString {
|
||||||
|
|
|
@ -52,7 +52,8 @@ impl HTMLOutputElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Validity(&self) -> @mut ValidityState {
|
pub fn Validity(&self) -> @mut ValidityState {
|
||||||
@mut ValidityState::valid()
|
let global = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
|
ValidityState::new(global)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
|
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
|
||||||
|
|
|
@ -121,7 +121,8 @@ impl HTMLSelectElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Validity(&self) -> @mut ValidityState {
|
pub fn Validity(&self) -> @mut ValidityState {
|
||||||
@mut ValidityState::valid()
|
let global = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
|
ValidityState::new(global)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
|
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
|
||||||
|
|
|
@ -2,22 +2,30 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::codegen::ValidityStateBinding;
|
use dom::bindings::codegen::ValidityStateBinding;
|
||||||
|
use dom::window::Window;
|
||||||
use js::jsapi::{JSContext, JSObject};
|
use js::jsapi::{JSContext, JSObject};
|
||||||
|
|
||||||
pub struct ValidityState {
|
pub struct ValidityState {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
state: u8
|
window: @mut Window,
|
||||||
|
state: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ValidityState {
|
impl ValidityState {
|
||||||
pub fn valid() -> ValidityState {
|
pub fn new_inherited(window: @mut Window) -> ValidityState {
|
||||||
ValidityState {
|
ValidityState {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
state: 0
|
window: window,
|
||||||
|
state: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new(window: @mut Window) -> @mut ValidityState {
|
||||||
|
reflect_dom_object(@mut ValidityState::new_inherited(window), window,
|
||||||
|
ValidityStateBinding::Wrap)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ValidityState {
|
impl ValidityState {
|
||||||
|
@ -67,11 +75,11 @@ impl Reflectable for ValidityState {
|
||||||
&mut self.reflector_
|
&mut self.reflector_
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||||
ValidityStateBinding::Wrap(cx, scope, self)
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
||||||
None
|
Some(self.window as @mut Reflectable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue