auto merge of #2101 : jdm/servo/newroot_rebase, r=Ms2ger

As described in #1764, this strategy uses the following properties:
* DOM members are `JS<T>` types. These cannot be used with being explicitly rooted, but they are required for compiler-derived trace hooks.
* Methods that take DOM type arguments receive `&[mut] JSRef<T>`. These are rooted value references that are cloneable but cannot escape.
* Methods that return DOM values use `Unrooted<T>`. These are values that may or may not be rooted elsewhere, but callers must root them in order to interact with them in any way. One unsoundness hole exists - `Unrooted` values must be rooted ASAP, or there exists the danger that JSAPI calls could be made that could cause the underlying JS value to be GCed.
* All methods are implemented on `JSRef<T>`, enforcing the requirement that all DOM values are rooted for the duration of a method call (with a few exceptions for layout-related code, which cannot root values and therefore interacts with `JS<T>` and `&T` values - this is safe under the assumption that layout code interacts with DOM nodes that are in the tree, therefore rooted, and does not run concurrently with content code)
This commit is contained in:
bors-servo 2014-05-03 14:25:22 -04:00
commit 731e66ff13
118 changed files with 6224 additions and 3945 deletions

1
configure vendored
View file

@ -697,6 +697,7 @@ do
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-android-ndk=${CFG_ANDROID_NDK_PATH}" CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-android-ndk=${CFG_ANDROID_NDK_PATH}"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-android-toolchain=${CFG_ANDROID_CROSS_PATH}" CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-android-toolchain=${CFG_ANDROID_CROSS_PATH}"
fi fi
CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-gczeal"
;; ;;
support/skia/skia) support/skia/skia)
# Right now the skia configure script actually ignores --enable-debug and the # Right now the skia configure script actually ignores --enable-debug and the

View file

@ -45,7 +45,6 @@ use layout::wrapper::{Before, BeforeBlock, After, AfterBlock, Normal};
use gfx::display_list::OpaqueNode; use gfx::display_list::OpaqueNode;
use gfx::font_context::FontContext; use gfx::font_context::FontContext;
use script::dom::bindings::codegen::InheritTypes::TextCast;
use script::dom::bindings::js::JS; use script::dom::bindings::js::JS;
use script::dom::element::{HTMLIFrameElementTypeId, HTMLImageElementTypeId}; use script::dom::element::{HTMLIFrameElementTypeId, HTMLImageElementTypeId};
use script::dom::element::{HTMLObjectElementTypeId}; use script::dom::element::{HTMLObjectElementTypeId};
@ -1064,8 +1063,8 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
match self.type_id() { match self.type_id() {
Some(TextNodeTypeId) => { Some(TextNodeTypeId) => {
unsafe { unsafe {
let text: JS<Text> = TextCast::to(self.get_jsmanaged()).unwrap(); let text: JS<Text> = self.get_jsmanaged().transmute_copy();
if !is_whitespace(text.get().characterdata.data) { if !is_whitespace((*text.unsafe_get()).characterdata.data) {
return false return false
} }

View file

@ -37,10 +37,11 @@ use script::dom::bindings::codegen::InheritTypes::{HTMLIFrameElementDerived};
use script::dom::bindings::codegen::InheritTypes::{HTMLImageElementDerived, TextDerived}; use script::dom::bindings::codegen::InheritTypes::{HTMLImageElementDerived, TextDerived};
use script::dom::bindings::js::JS; use script::dom::bindings::js::JS;
use script::dom::element::{Element, HTMLAreaElementTypeId, HTMLAnchorElementTypeId}; use script::dom::element::{Element, HTMLAreaElementTypeId, HTMLAnchorElementTypeId};
use script::dom::element::{HTMLLinkElementTypeId}; use script::dom::element::{HTMLLinkElementTypeId, LayoutElementHelpers, RawLayoutElementHelpers};
use script::dom::htmliframeelement::HTMLIFrameElement; use script::dom::htmliframeelement::HTMLIFrameElement;
use script::dom::htmlimageelement::HTMLImageElement; use script::dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpers};
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, Node, NodeTypeId, NodeHelpers}; use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, Node, NodeTypeId};
use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers};
use script::dom::text::Text; use script::dom::text::Text;
use servo_msg::constellation_msg::{PipelineId, SubpageId}; use servo_msg::constellation_msg::{PipelineId, SubpageId};
use servo_util::namespace; use servo_util::namespace;
@ -95,7 +96,7 @@ pub trait TLayoutNode {
fail!("not an image!") fail!("not an image!")
} }
let image_element: JS<HTMLImageElement> = self.get_jsmanaged().transmute_copy(); let image_element: JS<HTMLImageElement> = self.get_jsmanaged().transmute_copy();
(*image_element.unsafe_get()).image().as_ref().map(|url| (*url).clone()) image_element.image().as_ref().map(|url| (*url).clone())
} }
} }
@ -163,7 +164,9 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
} }
fn type_id(&self) -> Option<NodeTypeId> { fn type_id(&self) -> Option<NodeTypeId> {
Some(self.node.type_id()) unsafe {
Some(self.node.type_id_for_layout())
}
} }
unsafe fn get_jsmanaged<'a>(&'a self) -> &'a JS<Node> { unsafe fn get_jsmanaged<'a>(&'a self) -> &'a JS<Node> {
@ -172,7 +175,7 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
fn first_child(&self) -> Option<LayoutNode<'ln>> { fn first_child(&self) -> Option<LayoutNode<'ln>> {
unsafe { unsafe {
self.get().first_child_ref().map(|node| self.new_with_this_lifetime(node)) self.get_jsmanaged().first_child_ref().map(|node| self.new_with_this_lifetime(node))
} }
} }
@ -221,19 +224,19 @@ impl<'ln> LayoutNode<'ln> {
impl<'ln> TNode<LayoutElement<'ln>> for LayoutNode<'ln> { impl<'ln> TNode<LayoutElement<'ln>> for LayoutNode<'ln> {
fn parent_node(&self) -> Option<LayoutNode<'ln>> { fn parent_node(&self) -> Option<LayoutNode<'ln>> {
unsafe { unsafe {
self.get().parent_node_ref().map(|node| self.new_with_this_lifetime(node)) self.node.parent_node_ref().map(|node| self.new_with_this_lifetime(node))
} }
} }
fn prev_sibling(&self) -> Option<LayoutNode<'ln>> { fn prev_sibling(&self) -> Option<LayoutNode<'ln>> {
unsafe { unsafe {
self.get().prev_sibling_ref().map(|node| self.new_with_this_lifetime(node)) self.node.prev_sibling_ref().map(|node| self.new_with_this_lifetime(node))
} }
} }
fn next_sibling(&self) -> Option<LayoutNode<'ln>> { fn next_sibling(&self) -> Option<LayoutNode<'ln>> {
unsafe { unsafe {
self.get().next_sibling_ref().map(|node| self.new_with_this_lifetime(node)) self.node.next_sibling_ref().map(|node| self.new_with_this_lifetime(node))
} }
} }
@ -241,8 +244,9 @@ impl<'ln> TNode<LayoutElement<'ln>> for LayoutNode<'ln> {
#[inline] #[inline]
fn as_element(&self) -> LayoutElement<'ln> { fn as_element(&self) -> LayoutElement<'ln> {
unsafe { unsafe {
assert!(self.node.is_element_for_layout());
let elem: JS<Element> = self.node.transmute_copy(); let elem: JS<Element> = self.node.transmute_copy();
let element = elem.get(); let element = &*elem.unsafe_get();
LayoutElement { LayoutElement {
element: cast::transmute_region(element), element: cast::transmute_region(element),
} }
@ -258,9 +262,9 @@ impl<'ln> TNode<LayoutElement<'ln>> for LayoutNode<'ln> {
} }
fn match_attr(&self, attr: &AttrSelector, test: |&str| -> bool) -> bool { fn match_attr(&self, attr: &AttrSelector, test: |&str| -> bool) -> bool {
let element = self.as_element();
let name = unsafe { let name = unsafe {
if element.element.html_element_in_html_document_for_layout() { let element: JS<Element> = self.node.transmute_copy();
if element.html_element_in_html_document_for_layout() {
attr.lower_name.as_slice() attr.lower_name.as_slice()
} else { } else {
attr.name.as_slice() attr.name.as_slice()
@ -268,6 +272,7 @@ impl<'ln> TNode<LayoutElement<'ln>> for LayoutNode<'ln> {
}; };
match attr.namespace { match attr.namespace {
SpecificNamespace(ref ns) => { SpecificNamespace(ref ns) => {
let element = self.as_element();
element.get_attr(ns, name) element.get_attr(ns, name)
.map_or(false, |attr| test(attr)) .map_or(false, |attr| test(attr))
}, },
@ -459,7 +464,7 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
} }
unsafe { unsafe {
self.get().first_child_ref().map(|node| self.new_with_this_lifetime(node)) self.get_jsmanaged().first_child_ref().map(|node| self.new_with_this_lifetime(node))
} }
} }
@ -509,10 +514,10 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
/// Returns the next sibling of this node. Unsafe and private because this can lead to races. /// Returns the next sibling of this node. Unsafe and private because this can lead to races.
unsafe fn next_sibling(&self) -> Option<ThreadSafeLayoutNode<'ln>> { unsafe fn next_sibling(&self) -> Option<ThreadSafeLayoutNode<'ln>> {
if self.pseudo == Before || self.pseudo == BeforeBlock { if self.pseudo == Before || self.pseudo == BeforeBlock {
return self.get().first_child_ref().map(|node| self.new_with_this_lifetime(node)) return self.get_jsmanaged().first_child_ref().map(|node| self.new_with_this_lifetime(node))
} }
self.node.get().next_sibling_ref().map(|node| self.new_with_this_lifetime(node)) self.get_jsmanaged().next_sibling_ref().map(|node| self.new_with_this_lifetime(node))
} }
/// Returns an iterator over this node's children. /// Returns an iterator over this node's children.
@ -527,7 +532,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
#[inline] #[inline]
pub fn as_element(&self) -> ThreadSafeLayoutElement { pub fn as_element(&self) -> ThreadSafeLayoutElement {
unsafe { unsafe {
let elem: JS<Element> = self.node.get_jsmanaged().transmute_copy(); assert!(self.get_jsmanaged().is_element_for_layout());
let elem: JS<Element> = self.get_jsmanaged().transmute_copy();
let element = elem.unsafe_get(); let element = elem.unsafe_get();
// FIXME(pcwalton): Workaround until Rust gets multiple lifetime parameters on // FIXME(pcwalton): Workaround until Rust gets multiple lifetime parameters on
// implementations. // implementations.

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::AttrBinding; use dom::bindings::codegen::BindingDeclarations::AttrBinding;
use dom::bindings::codegen::InheritTypes::NodeCast; use dom::bindings::codegen::InheritTypes::NodeCast;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::element::Element; use dom::element::Element;
use dom::node::Node; use dom::node::Node;
@ -45,7 +45,7 @@ impl Reflectable for Attr {
impl Attr { impl Attr {
fn new_inherited(local_name: DOMString, value: DOMString, fn new_inherited(local_name: DOMString, value: DOMString,
name: DOMString, namespace: Namespace, name: DOMString, namespace: Namespace,
prefix: Option<DOMString>, owner: JS<Element>) -> Attr { prefix: Option<DOMString>, owner: &JSRef<Element>) -> Attr {
Attr { Attr {
reflector_: Reflector::new(), reflector_: Reflector::new(),
local_name: local_name, local_name: local_name,
@ -53,25 +53,26 @@ impl Attr {
name: name, //TODO: Intern attribute names name: name, //TODO: Intern attribute names
namespace: namespace, namespace: namespace,
prefix: prefix, prefix: prefix,
owner: owner, owner: owner.unrooted(),
} }
} }
pub fn new(window: &JS<Window>, local_name: DOMString, value: DOMString, pub fn new(window: &JSRef<Window>, local_name: DOMString, value: DOMString,
name: DOMString, namespace: Namespace, name: DOMString, namespace: Namespace,
prefix: Option<DOMString>, owner: JS<Element>) -> JS<Attr> { prefix: Option<DOMString>, owner: &JSRef<Element>) -> Temporary<Attr> {
let attr = Attr::new_inherited(local_name, value, name, namespace, prefix, owner); let attr = Attr::new_inherited(local_name, value, name, namespace, prefix, owner);
reflect_dom_object(~attr, window, AttrBinding::Wrap) reflect_dom_object(~attr, window, AttrBinding::Wrap)
} }
pub fn set_value(&mut self, set_type: AttrSettingType, value: DOMString) { pub fn set_value(&mut self, set_type: AttrSettingType, value: DOMString) {
let node: JS<Node> = NodeCast::from(&self.owner); let mut owner = self.owner.root();
let node: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut *owner);
let namespace_is_null = self.namespace == namespace::Null; let namespace_is_null = self.namespace == namespace::Null;
match set_type { match set_type {
ReplacedAttr => { ReplacedAttr => {
if namespace_is_null { if namespace_is_null {
vtable_for(&node).before_remove_attr(self.local_name.clone(), self.value.clone()); vtable_for(node).before_remove_attr(self.local_name.clone(), self.value.clone());
} }
} }
FirstSetAttr => {} FirstSetAttr => {}
@ -80,7 +81,7 @@ impl Attr {
self.value = value; self.value = value;
if namespace_is_null { if namespace_is_null {
vtable_for(&node).after_set_attr(self.local_name.clone(), self.value.clone()); vtable_for(node).after_set_attr(self.local_name.clone(), self.value.clone());
} }
} }
@ -89,31 +90,40 @@ impl Attr {
} }
} }
impl Attr { pub trait AttrMethods {
pub fn LocalName(&self) -> DOMString { fn LocalName(&self) -> DOMString;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, value: DOMString);
fn Name(&self) -> DOMString;
fn GetNamespaceURI(&self) -> Option<DOMString>;
fn GetPrefix(&self) -> Option<DOMString>;
}
impl<'a> AttrMethods for JSRef<'a, Attr> {
fn LocalName(&self) -> DOMString {
self.local_name.clone() self.local_name.clone()
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
self.value.clone() self.value.clone()
} }
pub fn SetValue(&mut self, value: DOMString) { fn SetValue(&mut self, value: DOMString) {
self.set_value(ReplacedAttr, value); self.set_value(ReplacedAttr, value);
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
self.name.clone() self.name.clone()
} }
pub fn GetNamespaceURI(&self) -> Option<DOMString> { fn GetNamespaceURI(&self) -> Option<DOMString> {
match self.namespace.to_str() { match self.namespace.to_str() {
"" => None, "" => None,
url => Some(url.to_owned()), url => Some(url.to_owned()),
} }
} }
pub fn GetPrefix(&self) -> Option<DOMString> { fn GetPrefix(&self) -> Option<DOMString> {
self.prefix.clone() self.prefix.clone()
} }
} }

View file

@ -4,7 +4,7 @@
use dom::attr::Attr; use dom::attr::Attr;
use dom::bindings::codegen::BindingDeclarations::AttrListBinding; use dom::bindings::codegen::BindingDeclarations::AttrListBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::element::Element; use dom::element::Element;
use dom::window::Window; use dom::window::Window;
@ -17,28 +17,36 @@ pub struct AttrList {
} }
impl AttrList { impl AttrList {
pub fn new_inherited(window: JS<Window>, elem: JS<Element>) -> AttrList { pub fn new_inherited(window: &JSRef<Window>, elem: &JSRef<Element>) -> AttrList {
AttrList { AttrList {
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: window, window: window.unrooted(),
owner: elem owner: elem.unrooted(),
} }
} }
pub fn new(window: &JS<Window>, elem: &JS<Element>) -> JS<AttrList> { pub fn new(window: &JSRef<Window>, elem: &JSRef<Element>) -> Temporary<AttrList> {
reflect_dom_object(~AttrList::new_inherited(window.clone(), elem.clone()), reflect_dom_object(~AttrList::new_inherited(window, elem),
window, AttrListBinding::Wrap) window, AttrListBinding::Wrap)
} }
}
pub fn Length(&self) -> u32 { pub trait AttrListMethods {
self.owner.get().attrs.len() as u32 fn Length(&self) -> u32;
fn Item(&self, index: u32) -> Option<Temporary<Attr>>;
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<Attr>>;
}
impl<'a> AttrListMethods for JSRef<'a, AttrList> {
fn Length(&self) -> u32 {
self.owner.root().attrs.len() as u32
} }
pub fn Item(&self, index: u32) -> Option<JS<Attr>> { fn Item(&self, index: u32) -> Option<Temporary<Attr>> {
self.owner.get().attrs.as_slice().get(index as uint).map(|x| x.clone()) self.owner.root().attrs.as_slice().get(index as uint).map(|x| Temporary::new(x.clone()))
} }
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<JS<Attr>> { fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<Attr>> {
let item = self.Item(index); let item = self.Item(index);
*found = item.is_some(); *found = item.is_some();
item item

View file

@ -9,8 +9,6 @@
# The configuration table maps each interface name to a |descriptor|. # The configuration table maps each interface name to a |descriptor|.
# #
# Valid fields for all descriptors: # Valid fields for all descriptors:
# * needsAbstract: a list of members that require a JS<>-wrapped version of
# self to be passed to the native code.
# * createGlobal: True for global objects. # * createGlobal: True for global objects.
# * outerObjectHook: string to use in place of default value for outerObject and thisObject # * outerObjectHook: string to use in place of default value for outerObject and thisObject
# JS class hooks # JS class hooks
@ -26,123 +24,44 @@ DOMInterfaces = {
'ClientRect': {}, 'ClientRect': {},
'ClientRectList': {}, 'ClientRectList': {},
'Console': {}, 'Console': {},
'Document': { 'Document': {},
'needsAbstract': [
'adoptNode',
'anchors',
'applets',
'body',
'children',
'createComment',
'createDocumentFragment',
'createElement',
'createElementNS',
'createProcessingInstruction',
'createTextNode',
'embeds',
'forms',
'getElementsByClassName',
'getElementsByTagName',
'getElementsByTagNameNS',
'images',
'importNode',
'links',
'location',
'plugins',
'scripts',
'title',
],
},
'DOMException': {}, 'DOMException': {},
'DOMImplementation': {}, 'DOMImplementation': {},
'DOMParser': {}, 'DOMParser': {},
'Element': { 'Element': {},
'needsAbstract': [
'attributes',
'children',
'className',
'getAttribute',
'getAttributeNS',
'getBoundingClientRect',
'getClientRects',
'getElementsByClassName',
'getElementsByTagName',
'getElementsByTagNameNS',
'hasAttribute',
'hasAttributeNS',
'id',
'innerHTML',
'outerHTML',
'removeAttribute',
'removeAttributeNS',
'setAttribute',
'setAttributeNS',
]
},
'Event': {}, 'Event': {},
'EventListener': { 'EventListener': {
'nativeType': 'EventListenerBinding::EventListener', 'nativeType': 'EventListenerBinding::EventListener',
}, },
'EventTarget': { 'EventTarget': {},
'needsAbstract': ['dispatchEvent']
},
'FormData': {}, 'FormData': {},
'HTMLCollection': {}, 'HTMLCollection': {},
'Location': {}, 'Location': {},
'MouseEvent': {}, 'MouseEvent': {},
'Navigator': {}, 'Navigator': {},
'Node': { 'Node': {},
'needsAbstract': [
'appendChild',
'childNodes',
'cloneNode',
'compareDocumentPosition',
'contains',
'insertBefore',
'isEqualNode',
'namespaceURI',
'nodeName',
'nodeValue',
'normalize',
'removeChild',
'replaceChild',
'textContent',
]
},
'NodeList': {}, 'NodeList': {},
'UIEvent': {}, 'UIEvent': {},
'ValidityState': {}, 'ValidityState': {},
'Window': { 'Window': {
'createGlobal': True, 'createGlobal': True,
'outerObjectHook': 'Some(bindings::utils::outerize_global)', 'outerObjectHook': 'Some(bindings::utils::outerize_global)',
'needsAbstract': [
'console',
'location',
'navigator',
'self',
'window',
],
}, },
'XMLHttpRequest': {}, 'XMLHttpRequest': {},
'XMLHttpRequestEventTarget': {}, 'XMLHttpRequestEventTarget': {},
'XMLHttpRequestUpload': {}, 'XMLHttpRequestUpload': {},
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
'TestBinding': {}, 'TestBinding': {},
} }
# FIXME: This should be renamed: https://github.com/mozilla/servo/issues/1625 # FIXME: This should be renamed: https://github.com/mozilla/servo/issues/1625
def addHTMLElement(element, concrete=None, needsAbstract=[]): def addHTMLElement(element):
DOMInterfaces[element] = { DOMInterfaces[element] = {}
'nativeType': 'JS<%s>' % element,
'concreteType': concrete if concrete else element,
'needsAbstract': needsAbstract
}
addHTMLElement('Comment') addHTMLElement('Comment')
addHTMLElement('DocumentFragment', concrete='DocumentFragment', needsAbstract=['children']) addHTMLElement('DocumentFragment')
addHTMLElement('DocumentType') addHTMLElement('DocumentType')
addHTMLElement('Text') addHTMLElement('Text')
addHTMLElement('ProcessingInstruction') addHTMLElement('ProcessingInstruction')
@ -158,12 +77,12 @@ addHTMLElement('HTMLBRElement')
addHTMLElement('HTMLCanvasElement') addHTMLElement('HTMLCanvasElement')
addHTMLElement('HTMLDataElement') addHTMLElement('HTMLDataElement')
addHTMLElement('HTMLDivElement') addHTMLElement('HTMLDivElement')
addHTMLElement('HTMLDataListElement', needsAbstract=['options']) addHTMLElement('HTMLDataListElement')
addHTMLElement('HTMLDirectoryElement') addHTMLElement('HTMLDirectoryElement')
addHTMLElement('HTMLDListElement') addHTMLElement('HTMLDListElement')
addHTMLElement('HTMLElement') addHTMLElement('HTMLElement')
addHTMLElement('HTMLEmbedElement') addHTMLElement('HTMLEmbedElement')
addHTMLElement('HTMLFieldSetElement', needsAbstract=['elements']) addHTMLElement('HTMLFieldSetElement')
addHTMLElement('HTMLFontElement') addHTMLElement('HTMLFontElement')
addHTMLElement('HTMLFormElement') addHTMLElement('HTMLFormElement')
addHTMLElement('HTMLFrameElement') addHTMLElement('HTMLFrameElement')
@ -172,8 +91,8 @@ addHTMLElement('HTMLHeadElement')
addHTMLElement('HTMLHeadingElement') addHTMLElement('HTMLHeadingElement')
addHTMLElement('HTMLHtmlElement') addHTMLElement('HTMLHtmlElement')
addHTMLElement('HTMLHRElement') addHTMLElement('HTMLHRElement')
addHTMLElement('HTMLIFrameElement', needsAbstract=['sandbox']) addHTMLElement('HTMLIFrameElement')
addHTMLElement('HTMLImageElement', needsAbstract=['alt', 'src', 'useMap', 'isMap', 'width', 'height', 'name', 'align', 'hspace', 'vspace', 'longDesc', 'border']) addHTMLElement('HTMLImageElement')
addHTMLElement('HTMLInputElement') addHTMLElement('HTMLInputElement')
addHTMLElement('HTMLLabelElement') addHTMLElement('HTMLLabelElement')
addHTMLElement('HTMLLegendElement') addHTMLElement('HTMLLegendElement')
@ -195,7 +114,7 @@ addHTMLElement('HTMLParamElement')
addHTMLElement('HTMLPreElement') addHTMLElement('HTMLPreElement')
addHTMLElement('HTMLProgressElement') addHTMLElement('HTMLProgressElement')
addHTMLElement('HTMLQuoteElement') addHTMLElement('HTMLQuoteElement')
addHTMLElement('HTMLScriptElement', needsAbstract=['src']) addHTMLElement('HTMLScriptElement')
addHTMLElement('HTMLSelectElement') addHTMLElement('HTMLSelectElement')
addHTMLElement('HTMLSourceElement') addHTMLElement('HTMLSourceElement')
addHTMLElement('HTMLSpanElement') addHTMLElement('HTMLSpanElement')

View file

@ -394,6 +394,9 @@ def typeIsSequenceOrHasSequenceMember(type):
type.flatMemberTypes) type.flatMemberTypes)
return False return False
def typeNeedsRooting(type, descriptorProvider):
return type.isGeckoInterface() and descriptorProvider.getDescriptor(type.name).needsRooting
def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
isDefinitelyObject=False, isDefinitelyObject=False,
isMember=False, isMember=False,
@ -481,6 +484,8 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
if exceptionCode is None: if exceptionCode is None:
exceptionCode = "return 0;" exceptionCode = "return 0;"
needsRooting = typeNeedsRooting(type, descriptorProvider)
def handleOptional(template, declType, isOptional): def handleOptional(template, declType, isOptional):
if isOptional: if isOptional:
template = "Some(%s)" % template template = "Some(%s)" % template
@ -489,7 +494,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
else: else:
initialValue = None initialValue = None
return (template, declType, isOptional, initialValue) return (template, declType, isOptional, initialValue, needsRooting)
# Unfortunately, .capitalize() on a string will lowercase things inside the # Unfortunately, .capitalize() on a string will lowercase things inside the
# string, which we do not want. # string, which we do not want.
@ -551,7 +556,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
templateBody += ( templateBody += (
"} else {\n" + "} else {\n" +
CGIndenter(onFailureNotAnObject(failureCode)).define() + CGIndenter(onFailureNotAnObject(failureCode)).define() +
"}") "}\n")
if type.nullable(): if type.nullable():
templateBody = handleDefaultNull(templateBody, "None") templateBody = handleDefaultNull(templateBody, "None")
else: else:
@ -601,6 +606,8 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
failureCode) failureCode)
return handleOptional(template, declType, isOptional) return handleOptional(template, declType, isOptional)
descriptorType = descriptor.memberType if isMember else descriptor.nativeType
templateBody = "" templateBody = ""
if descriptor.interface.isConsequential(): if descriptor.interface.isConsequential():
raise TypeError("Consequential interface %s being used as an " raise TypeError("Consequential interface %s being used as an "
@ -616,11 +623,14 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
descriptor, descriptor,
"(${val}).to_object()")) "(${val}).to_object()"))
declType = CGGeneric(descriptor.nativeType) declType = CGGeneric(descriptorType)
if type.nullable(): if type.nullable():
templateBody = "Some(%s)" % templateBody templateBody = "Some(%s)" % templateBody
declType = CGWrapper(declType, pre="Option<", post=">") declType = CGWrapper(declType, pre="Option<", post=">")
if isMember:
templateBody += ".root()"
templateBody = wrapObjectTemplate(templateBody, isDefinitelyObject, templateBody = wrapObjectTemplate(templateBody, isDefinitelyObject,
type, failureCode) type, failureCode)
@ -745,7 +755,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
"} else {\n" "} else {\n"
" ${declName} = NULL;\n" " ${declName} = NULL;\n"
"}" % haveCallable, "}" % haveCallable,
CGGeneric("JSObject*"), isOptional, None) CGGeneric("JSObject*"), isOptional, None, needsRooting)
if type.isAny(): if type.isAny():
assert not isEnforceRange and not isClamp assert not isEnforceRange and not isClamp
@ -789,7 +799,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
assert not isOptional assert not isOptional
# This one only happens for return values, and its easy: Just # This one only happens for return values, and its easy: Just
# ignore the jsval. # ignore the jsval.
return ("", None, False, None) return ("", None, False, None, False)
if not type.isPrimitive(): if not type.isPrimitive():
raise TypeError("Need conversion for argument type '%s'" % str(type)) raise TypeError("Need conversion for argument type '%s'" % str(type))
@ -842,7 +852,7 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
replace ${argc} and ${index}, where ${index} is the index of this replace ${argc} and ${index}, where ${index} is the index of this
argument (0-based) and ${argc} is the total number of arguments. argument (0-based) and ${argc} is the total number of arguments.
""" """
(templateBody, declType, dealWithOptional, initialValue) = templateTuple (templateBody, declType, dealWithOptional, initialValue, needsRooting) = templateTuple
if dealWithOptional and argcAndIndex is None: if dealWithOptional and argcAndIndex is None:
raise TypeError("Have to deal with optional things, but don't know how") raise TypeError("Have to deal with optional things, but don't know how")
@ -888,6 +898,12 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
# Add an empty CGGeneric to get an extra newline after the argument # Add an empty CGGeneric to get an extra newline after the argument
# conversion. # conversion.
result.append(CGGeneric("")) result.append(CGGeneric(""))
if needsRooting:
rootBody = "let ${declName} = ${declName}.root();"
result.append(CGGeneric(string.Template(rootBody).substitute(replacements)))
result.append(CGGeneric(""))
return result; return result;
def convertConstIDLValueToJSVal(value): def convertConstIDLValueToJSVal(value):
@ -985,6 +1001,13 @@ def typeNeedsCx(type, retVal=False):
return True return True
return type.isCallback() or type.isAny() or type.isObject() return type.isCallback() or type.isAny() or type.isObject()
def typeRetValNeedsRooting(type):
if type is None:
return False
if type.nullable():
type = type.inner
return type.isGeckoInterface() and not type.isCallback()
def memberIsCreator(member): def memberIsCreator(member):
return member.getExtendedAttribute("Creator") is not None return member.getExtendedAttribute("Creator") is not None
@ -1016,7 +1039,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
if returnType.isGeckoInterface(): if returnType.isGeckoInterface():
descriptor = descriptorProvider.getDescriptor( descriptor = descriptorProvider.getDescriptor(
returnType.unroll().inner.identifier.name) returnType.unroll().inner.identifier.name)
result = CGGeneric(descriptor.nativeType) result = CGGeneric(descriptor.returnType)
if returnType.nullable(): if returnType.nullable():
result = CGWrapper(result, pre="Option<", post=">") result = CGWrapper(result, pre="Option<", post=">")
return result return result
@ -1365,7 +1388,7 @@ class CGImports(CGWrapper):
""" """
Generates the appropriate import/use statements. Generates the appropriate import/use statements.
""" """
def __init__(self, child, imports): def __init__(self, child, descriptors, imports):
""" """
Adds a set of imports. Adds a set of imports.
""" """
@ -1385,6 +1408,10 @@ class CGImports(CGWrapper):
'dead_code', 'dead_code',
] ]
for d in descriptors:
name = d.interface.identifier.name
imports.append('dom::%s::%sMethods' % (name.lower(), name))
statements = ['#![allow(%s)]' % ','.join(ignored_warnings)] statements = ['#![allow(%s)]' % ','.join(ignored_warnings)]
statements.extend('use %s;' % i for i in sorted(imports)) statements.extend('use %s;' % i for i in sorted(imports))
@ -1763,7 +1790,7 @@ class CGAbstractMethod(CGThing):
def _returnType(self): def _returnType(self):
return (" -> %s" % self.returnType) if self.returnType != "void" else "" return (" -> %s" % self.returnType) if self.returnType != "void" else ""
def _unsafe_open(self): def _unsafe_open(self):
return "\n unsafe {" if self.unsafe else "" return "\n unsafe {\n" if self.unsafe else ""
def _unsafe_close(self): def _unsafe_close(self):
return "\n }\n" if self.unsafe else "" return "\n }\n" if self.unsafe else ""
@ -1783,7 +1810,7 @@ def CreateBindingJSObject(descriptor, parent=None):
if descriptor.proxy: if descriptor.proxy:
assert not descriptor.createGlobal assert not descriptor.createGlobal
handler = """ handler = """
let js_info = aScope.get().page().js_info(); let js_info = aScope.deref().page().js_info();
let handler = js_info.get_ref().dom_static.proxy_handlers.deref().get(&(PrototypeList::id::%s as uint)); let handler = js_info.get_ref().dom_static.proxy_handlers.deref().get(&(PrototypeList::id::%s as uint));
""" % descriptor.name """ % descriptor.name
create += handler + """ let obj = NewProxyObject(aCx, *handler, create += handler + """ let obj = NewProxyObject(aCx, *handler,
@ -1809,7 +1836,7 @@ class CGWrapMethod(CGAbstractMethod):
def __init__(self, descriptor): def __init__(self, descriptor):
assert descriptor.interface.hasInterfacePrototypeObject() assert descriptor.interface.hasInterfacePrototypeObject()
if not descriptor.createGlobal: if not descriptor.createGlobal:
args = [Argument('*JSContext', 'aCx'), Argument('&JS<Window>', 'aScope'), args = [Argument('*JSContext', 'aCx'), Argument('&JSRef<Window>', 'aScope'),
Argument("~" + descriptor.concreteType, 'aObject', mutable=True)] Argument("~" + descriptor.concreteType, 'aObject', mutable=True)]
else: else:
args = [Argument('*JSContext', 'aCx'), args = [Argument('*JSContext', 'aCx'),
@ -2210,6 +2237,9 @@ class CGCallGenerator(CGThing):
self.cgRoot.append(CGGeneric("}")) self.cgRoot.append(CGGeneric("}"))
self.cgRoot.append(CGGeneric("result = result_fallible.unwrap();")) self.cgRoot.append(CGGeneric("result = result_fallible.unwrap();"))
if typeRetValNeedsRooting(returnType):
self.cgRoot.append(CGGeneric("let result = result.root();"))
def define(self): def define(self):
return self.cgRoot.define() return self.cgRoot.define()
@ -2277,7 +2307,12 @@ class CGPerSignatureCall(CGThing):
def getArgc(self): def getArgc(self):
return "argc" return "argc"
def getArguments(self): def getArguments(self):
return [(a, "arg" + str(i)) for (i, a) in enumerate(self.arguments)] def process(arg, i):
argVal = "arg" + str(i)
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
argVal += ".root_ref()"
return argVal
return [(a, process(a, i)) for (i, a) in enumerate(self.arguments)]
def isFallible(self): def isFallible(self):
return not 'infallible' in self.extendedAttributes return not 'infallible' in self.extendedAttributes
@ -2447,17 +2482,10 @@ class CGSpecializedMethod(CGAbstractExternMethod):
def definition_body(self): def definition_body(self):
name = self.method.identifier.name name = self.method.identifier.name
nativeName = MakeNativeName(name) return CGWrapper(CGMethodCall([], MakeNativeName(name), self.method.isStatic(),
extraPre = ''
argsPre = []
if name in self.descriptor.needsAbstract:
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
extraPre = ' let mut abstract_this = %s::from_raw(this);\n' % abstractName
argsPre = ['&mut abstract_this']
return CGWrapper(CGMethodCall(argsPre, nativeName, self.method.isStatic(),
self.descriptor, self.method), self.descriptor, self.method),
pre=extraPre + pre=" let this = JS::from_raw(this);\n" +
" let this = &mut *this;\n").define() " let mut this = this.root();\n").define()
class CGGenericGetter(CGAbstractBindingMethod): class CGGenericGetter(CGAbstractBindingMethod):
""" """
@ -2480,10 +2508,8 @@ class CGGenericGetter(CGAbstractBindingMethod):
def generate_code(self): def generate_code(self):
return CGIndenter(CGGeneric( return CGIndenter(CGGeneric(
"return with_gc_disabled(cx, || {\n" "let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, &*vp));\n"
" let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, &*vp));\n" "return CallJitPropertyOp(info, cx, obj, this.unsafe_get() as *libc::c_void, &*vp);\n"))
" CallJitPropertyOp(info, cx, obj, this.unsafe_get() as *libc::c_void, &*vp)\n"
"});\n"))
class CGSpecializedGetter(CGAbstractExternMethod): class CGSpecializedGetter(CGAbstractExternMethod):
""" """
@ -2502,21 +2528,15 @@ class CGSpecializedGetter(CGAbstractExternMethod):
def definition_body(self): def definition_body(self):
name = self.attr.identifier.name name = self.attr.identifier.name
nativeName = MakeNativeName(name) nativeName = MakeNativeName(name)
extraPre = ''
argsPre = []
infallible = ('infallible' in infallible = ('infallible' in
self.descriptor.getExtendedAttributes(self.attr, self.descriptor.getExtendedAttributes(self.attr,
getter=True)) getter=True))
if name in self.descriptor.needsAbstract:
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
extraPre = ' let mut abstract_this = %s::from_raw(this);\n' % abstractName
argsPre = ['&mut abstract_this']
if self.attr.type.nullable() or not infallible: if self.attr.type.nullable() or not infallible:
nativeName = "Get" + nativeName nativeName = "Get" + nativeName
return CGWrapper(CGIndenter(CGGetterCall(argsPre, self.attr.type, nativeName, return CGWrapper(CGIndenter(CGGetterCall([], self.attr.type, nativeName,
self.descriptor, self.attr)), self.descriptor, self.attr)),
pre=extraPre + pre=" let this = JS::from_raw(this);\n" +
" let this = &mut *this;\n").define() " let mut this = this.root();\n").define()
class CGGenericSetter(CGAbstractBindingMethod): class CGGenericSetter(CGAbstractBindingMethod):
""" """
@ -2541,10 +2561,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
"let undef = UndefinedValue();\n" "let undef = UndefinedValue();\n"
"let argv: *JSVal = if argc != 0 { JS_ARGV(cx, vp as *JSVal) } else { &undef as *JSVal };\n" "let argv: *JSVal = if argc != 0 { JS_ARGV(cx, vp as *JSVal) } else { &undef as *JSVal };\n"
"let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp as *JSVal));\n" "let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp as *JSVal));\n"
"let ok = with_gc_disabled(cx, || {\n" "if CallJitPropertyOp(info, cx, obj, this.unsafe_get() as *libc::c_void, argv) == 0 {\n"
" CallJitPropertyOp(info, cx, obj, this.unsafe_get() as *libc::c_void, argv)\n"
"});\n"
"if ok == 0 {\n"
" return 0;\n" " return 0;\n"
"}\n" "}\n"
"*vp = UndefinedValue();\n" "*vp = UndefinedValue();\n"
@ -2566,17 +2583,11 @@ class CGSpecializedSetter(CGAbstractExternMethod):
def definition_body(self): def definition_body(self):
name = self.attr.identifier.name name = self.attr.identifier.name
nativeName = "Set" + MakeNativeName(name) return CGWrapper(CGIndenter(CGSetterCall([], self.attr.type,
argsPre = [] "Set" + MakeNativeName(name),
extraPre = ''
if name in self.descriptor.needsAbstract:
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
extraPre = ' let mut abstract_this = %s::from_raw(this);\n' % abstractName
argsPre = ['&mut abstract_this']
return CGWrapper(CGIndenter(CGSetterCall(argsPre, self.attr.type, nativeName,
self.descriptor, self.attr)), self.descriptor, self.attr)),
pre=extraPre + pre=" let this = JS::from_raw(this);\n" +
" let this = &mut *this;\n").define() " let mut this = this.root();\n").define()
class CGMemberJITInfo(CGThing): class CGMemberJITInfo(CGThing):
@ -2744,7 +2755,7 @@ def getUnionTypeTemplateVars(type, descriptorProvider):
name = type.name name = type.name
typeName = "/*" + type.name + "*/" typeName = "/*" + type.name + "*/"
(template, _, _, _) = getJSToNativeConversionTemplate( (template, _, _, _, _) = getJSToNativeConversionTemplate(
type, descriptorProvider, failureCode="return Ok(None);", type, descriptorProvider, failureCode="return Ok(None);",
exceptionCode='return Err(());', exceptionCode='return Err(());',
isDefinitelyObject=True, isOptional=False) isDefinitelyObject=True, isOptional=False)
@ -3411,7 +3422,12 @@ class CGProxySpecialOperation(CGPerSignatureCall):
self.cgRoot.prepend(CGGeneric("let mut found = false;")) self.cgRoot.prepend(CGGeneric("let mut found = false;"))
def getArguments(self): def getArguments(self):
args = [(a, a.identifier.name) for a in self.arguments] def process(arg):
argVal = arg.identifier.name
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
argVal += ".root_ref()"
return argVal
args = [(a, process(a)) for a in self.arguments]
if self.idlNode.isGetter(): if self.idlNode.isGetter():
args.append((FakeArgument(BuiltinTypes[IDLBuiltinType.Types.boolean], args.append((FakeArgument(BuiltinTypes[IDLBuiltinType.Types.boolean],
self.idlNode), self.idlNode),
@ -3461,14 +3477,14 @@ class CGProxyNamedSetter(CGProxySpecialOperation):
class CGProxyUnwrap(CGAbstractMethod): class CGProxyUnwrap(CGAbstractMethod):
def __init__(self, descriptor): def __init__(self, descriptor):
args = [Argument('*JSObject', 'obj')] args = [Argument('*JSObject', 'obj')]
CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", '*' + descriptor.concreteType, args, alwaysInline=True) CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", '*mut ' + descriptor.concreteType, args, alwaysInline=True)
def definition_body(self): def definition_body(self):
return """ /*if (xpc::WrapperFactory::IsXrayWrapper(obj)) { return """ /*if (xpc::WrapperFactory::IsXrayWrapper(obj)) {
obj = js::UnwrapObject(obj); obj = js::UnwrapObject(obj);
}*/ }*/
//MOZ_ASSERT(IsProxy(obj)); //MOZ_ASSERT(IsProxy(obj));
let box_: *%s = cast::transmute(GetProxyPrivate(obj).to_private()); let box_: *mut %s = cast::transmute(GetProxyPrivate(obj).to_private());
return box_;""" % (self.descriptor.concreteType) return box_;""" % (self.descriptor.concreteType)
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
@ -3493,9 +3509,11 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
templateValues = {'jsvalRef': '(*desc).value', 'successCode': fillDescriptor} templateValues = {'jsvalRef': '(*desc).value', 'successCode': fillDescriptor}
get = ("if index.is_some() {\n" + get = ("if index.is_some() {\n" +
" let index = index.unwrap();\n" + " let index = index.unwrap();\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
"}\n") % (self.descriptor.concreteType) "}\n")
if indexedSetter or self.descriptor.operations['NamedSetter']: if indexedSetter or self.descriptor.operations['NamedSetter']:
setOrIndexedGet += "if set != 0 {\n" setOrIndexedGet += "if set != 0 {\n"
@ -3538,9 +3556,11 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
namedGet = ("\n" + namedGet = ("\n" +
"if set == 0 && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + "if set == 0 && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
" let name = Some(jsid_to_str(cx, id));\n" + " let name = Some(jsid_to_str(cx, id));\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" +
"}\n") % (self.descriptor.concreteType) "}\n")
else: else:
namedGet = "" namedGet = ""
@ -3581,10 +3601,12 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
set += ("let index = GetArrayIndexFromId(cx, id);\n" + set += ("let index = GetArrayIndexFromId(cx, id);\n" +
"if index.is_some() {\n" + "if index.is_some() {\n" +
" let index = index.unwrap();\n" + " let index = index.unwrap();\n" +
" let this: *mut %s = UnwrapProxy(proxy) as *mut %s;\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() + CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
" return 1;\n" + " return 1;\n" +
"}\n") % (self.descriptor.concreteType, self.descriptor.concreteType) "}\n")
elif self.descriptor.operations['IndexedGetter']: elif self.descriptor.operations['IndexedGetter']:
set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" + set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" +
" return 0;\n" + " return 0;\n" +
@ -3597,20 +3619,24 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
raise TypeError("Can't handle creator that's different from the setter") raise TypeError("Can't handle creator that's different from the setter")
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" + set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
" let name = Some(jsid_to_str(cx, id));\n" + " let name = Some(jsid_to_str(cx, id));\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" + CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" +
"}\n") % (self.descriptor.concreteType) "}\n")
elif self.descriptor.operations['NamedGetter']: elif self.descriptor.operations['NamedGetter']:
set += ("if RUST_JSID_IS_STRING(id) {\n" + set += ("if RUST_JSID_IS_STRING(id) {\n" +
" let name = Some(jsid_to_str(cx, id));\n" + " let name = Some(jsid_to_str(cx, id));\n" +
" let this: %%s = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
" if (found) {\n" " if (found) {\n"
" return 0;\n" + " return 0;\n" +
" //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" + " //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
" }\n" + " }\n" +
" return 1;\n" " return 1;\n"
"}\n") % (self.descriptor.concreteType, self.descriptor.name) "}\n") % (self.descriptor.name)
return set + """return proxyhandler::defineProperty_(%s);""" % ", ".join(a.name for a in self.args) return set + """return proxyhandler::defineProperty_(%s);""" % ", ".join(a.name for a in self.args)
def definition_body(self): def definition_body(self):
@ -3628,11 +3654,13 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
indexed = ("let index = GetArrayIndexFromId(cx, id);\n" + indexed = ("let index = GetArrayIndexFromId(cx, id);\n" +
"if index.is_some() {\n" + "if index.is_some() {\n" +
" let index = index.unwrap();\n" + " let index = index.unwrap();\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
" *bp = found as JSBool;\n" + " *bp = found as JSBool;\n" +
" return 1;\n" + " return 1;\n" +
"}\n\n") % (self.descriptor.concreteType) "}\n\n")
else: else:
indexed = "" indexed = ""
@ -3640,12 +3668,14 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
if namedGetter: if namedGetter:
named = ("if RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + named = ("if RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
" let name = Some(jsid_to_str(cx, id));\n" + " let name = Some(jsid_to_str(cx, id));\n" +
" let this: *%s = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" +
" *bp = found as JSBool;\n" " *bp = found as JSBool;\n"
" return 1;\n" " return 1;\n"
"}\n" + "}\n" +
"\n") % (self.descriptor.concreteType) "\n")
else: else:
named = "" named = ""
@ -3693,6 +3723,8 @@ if expando.is_not_null() {
"if index.is_some() {\n" + "if index.is_some() {\n" +
" let index = index.unwrap();\n" + " let index = index.unwrap();\n" +
" let this = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define()) CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
getIndexedOrExpando += """ getIndexedOrExpando += """
// Even if we don't have this index, we don't forward the // Even if we don't have this index, we don't forward the
@ -3709,6 +3741,8 @@ if expando.is_not_null() {
getNamed = ("if (JSID_IS_STRING(id)) {\n" + getNamed = ("if (JSID_IS_STRING(id)) {\n" +
" let name = Some(jsid_to_str(cx, id));\n" + " let name = Some(jsid_to_str(cx, id));\n" +
" let this = UnwrapProxy(proxy);\n" + " let this = UnwrapProxy(proxy);\n" +
" let this = JS::from_raw(this);\n" +
" let mut this = this.root();\n" +
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
"}\n") % (self.descriptor.concreteType) "}\n") % (self.descriptor.concreteType)
else: else:
@ -3825,11 +3859,11 @@ class CGClassConstructHook(CGAbstractExternMethod):
def generate_code(self): def generate_code(self):
preamble = """ preamble = """
let global = global_object_for_js_object(JS_CALLEE(cx, &*vp).to_object()); let global = global_object_for_js_object(JS_CALLEE(cx, &*vp).to_object()).root();
let obj = global.reflector().get_jsobject(); let obj = global.deref().reflector().get_jsobject();
""" """
nativeName = MakeNativeName(self._ctor.identifier.name) nativeName = MakeNativeName(self._ctor.identifier.name)
callGenerator = CGMethodCall(["&global"], nativeName, True, callGenerator = CGMethodCall(["&global.root_ref()"], nativeName, True,
self.descriptor, self._ctor) self.descriptor, self._ctor)
return preamble + callGenerator.define(); return preamble + callGenerator.define();
@ -4030,7 +4064,7 @@ class CGDictionary(CGThing):
def struct(self): def struct(self):
d = self.dictionary d = self.dictionary
if d.parent: if d.parent:
inheritance = " pub parent: %s::%s,\n" % (self.makeModuleName(d.parent), inheritance = " pub parent: %s::%s<'a, 'b>,\n" % (self.makeModuleName(d.parent),
self.makeClassName(d.parent)) self.makeClassName(d.parent))
else: else:
inheritance = "" inheritance = ""
@ -4039,7 +4073,7 @@ class CGDictionary(CGThing):
for m in self.memberInfo] for m in self.memberInfo]
return (string.Template( return (string.Template(
"pub struct ${selfName} {\n" + "pub struct ${selfName}<'a, 'b> {\n" +
"${inheritance}" + "${inheritance}" +
"\n".join(memberDecls) + "\n" + "\n".join(memberDecls) + "\n" +
"}").substitute( { "selfName": self.makeClassName(d), "}").substitute( { "selfName": self.makeClassName(d),
@ -4065,7 +4099,7 @@ class CGDictionary(CGThing):
memberInits = CGList([memberInit(m) for m in self.memberInfo]) memberInits = CGList([memberInit(m) for m in self.memberInfo])
return string.Template( return string.Template(
"impl ${selfName} {\n" "impl<'a, 'b> ${selfName}<'a, 'b> {\n"
" pub fn new(cx: *JSContext, val: JSVal) -> Result<${selfName}, ()> {\n" " pub fn new(cx: *JSContext, val: JSVal) -> Result<${selfName}, ()> {\n"
" let object = if val.is_null_or_undefined() {\n" " let object = if val.is_null_or_undefined() {\n"
" ptr::null()\n" " ptr::null()\n"
@ -4104,14 +4138,14 @@ class CGDictionary(CGThing):
def getMemberType(self, memberInfo): def getMemberType(self, memberInfo):
(member, (templateBody, declType, (member, (templateBody, declType,
dealWithOptional, initialValue)) = memberInfo dealWithOptional, initialValue, _)) = memberInfo
if dealWithOptional: if dealWithOptional:
declType = CGWrapper(declType, pre="Optional< ", post=" >") declType = CGWrapper(declType, pre="Optional< ", post=" >")
return declType.define() return declType.define()
def getMemberConversion(self, memberInfo): def getMemberConversion(self, memberInfo):
(member, (templateBody, declType, (member, (templateBody, declType,
dealWithOptional, initialValue)) = memberInfo dealWithOptional, initialValue, _)) = memberInfo
replacements = { "val": "value.unwrap()" } replacements = { "val": "value.unwrap()" }
if member.defaultValue: if member.defaultValue:
replacements["haveValue"] = "value.is_some()" replacements["haveValue"] = "value.is_some()"
@ -4238,7 +4272,7 @@ class CGBindingRoot(CGThing):
# Add imports # Add imports
#XXXjdm This should only import the namespace for the current binding, #XXXjdm This should only import the namespace for the current binding,
# not every binding ever. # not every binding ever.
curr = CGImports(curr, [ curr = CGImports(curr, descriptors, [
'js', 'js',
'js::{JS_ARGV, JS_CALLEE, JS_THIS_OBJECT}', 'js::{JS_ARGV, JS_CALLEE, JS_THIS_OBJECT}',
'js::{JSCLASS_GLOBAL_SLOT_COUNT, JSCLASS_IS_DOMJSCLASS}', 'js::{JSCLASS_GLOBAL_SLOT_COUNT, JSCLASS_IS_DOMJSCLASS}',
@ -4266,7 +4300,9 @@ class CGBindingRoot(CGThing):
'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING}', 'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
'dom::types::*', 'dom::types::*',
'dom::bindings', 'dom::bindings',
'dom::bindings::js::JS', 'dom::bindings::js::{JS, JSRef, Root, RootedReference, Temporary}',
'dom::bindings::js::{OptionalRootable, OptionalRootedRootable, ResultRootable}',
'dom::bindings::js::{OptionalRootedReference, OptionalOptionalRootedRootable}',
'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}', 'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}',
'dom::bindings::utils::{ConstantSpec, cx_for_dom_object, Default}', 'dom::bindings::utils::{ConstantSpec, cx_for_dom_object, Default}',
'dom::bindings::utils::{dom_object_slot, DOM_OBJECT_SLOT, DOMClass}', 'dom::bindings::utils::{dom_object_slot, DOM_OBJECT_SLOT, DOMClass}',
@ -4279,8 +4315,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::utils::{Reflectable}', 'dom::bindings::utils::{Reflectable}',
'dom::bindings::utils::{squirrel_away_unique}', 'dom::bindings::utils::{squirrel_away_unique}',
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}', 'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
'dom::bindings::utils::{VoidVal, with_gc_disabled}', 'dom::bindings::utils::VoidVal',
'dom::bindings::utils::{with_gc_enabled}',
'dom::bindings::utils::get_dictionary_property', 'dom::bindings::utils::get_dictionary_property',
'dom::bindings::trace::JSTraceable', 'dom::bindings::trace::JSTraceable',
'dom::bindings::callback::{CallbackContainer,CallbackInterface}', 'dom::bindings::callback::{CallbackContainer,CallbackInterface}',
@ -4549,7 +4584,7 @@ class CGNativeMember(ClassMethod):
else: else:
typeDecl = "%s" typeDecl = "%s"
descriptor = self.descriptorProvider.getDescriptor(iface.identifier.name) descriptor = self.descriptorProvider.getDescriptor(iface.identifier.name)
return (typeDecl % descriptor.nativeType, return (typeDecl % descriptor.argumentType,
False, False) False, False)
if type.isSpiderMonkeyInterface(): if type.isSpiderMonkeyInterface():
@ -5057,11 +5092,8 @@ class CallbackMethod(CallbackMember):
replacements["argc"] = "0" replacements["argc"] = "0"
return string.Template("${getCallable}" return string.Template("${getCallable}"
"let ok = unsafe {\n" "let ok = unsafe {\n"
" //JS_AllowGC(cx); // It's unsafe to enable GC at arbitrary points during Rust execution; leave it disabled\n" " JS_CallFunctionValue(cx, ${thisObj}, callable,\n"
" let ok = JS_CallFunctionValue(cx, ${thisObj}, callable,\n" " ${argc}, ${argv}, &rval)\n"
" ${argc}, ${argv}, &rval);\n"
" //JS_InhibitGC(cx);\n"
" ok\n"
"};\n" "};\n"
"if ok == 0 {\n" "if ok == 0 {\n"
" return${errorReturn};\n" " return${errorReturn};\n"
@ -5207,9 +5239,9 @@ class GlobalGenRoots():
@staticmethod @staticmethod
def RegisterBindings(config): def RegisterBindings(config):
# TODO - Generate the methods we want # TODO - Generate the methods we want
return CGImports(CGRegisterProtos(config), [ return CGImports(CGRegisterProtos(config), [], [
'dom::bindings::codegen', 'dom::bindings::codegen',
'dom::bindings::js::JS', 'dom::bindings::js::{JS, JSRef}',
'dom::window::Window', 'dom::window::Window',
'script_task::JSPageInfo', 'script_task::JSPageInfo',
]) ])
@ -5241,8 +5273,9 @@ class GlobalGenRoots():
descriptors = config.getDescriptors(register=True, hasInterfaceObject=True) descriptors = config.getDescriptors(register=True, hasInterfaceObject=True)
allprotos = [CGGeneric("#![allow(unused_imports)]\n"), allprotos = [CGGeneric("#![allow(unused_imports)]\n"),
CGGeneric("use dom::types::*;\n"), CGGeneric("use dom::types::*;\n"),
CGGeneric("use dom::bindings::js::JS;\n"), CGGeneric("use dom::bindings::js::{JS, JSRef, Temporary};\n"),
CGGeneric("use dom::bindings::trace::JSTraceable;\n"), CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
CGGeneric("use dom::bindings::utils::Reflectable;\n"),
CGGeneric("use serialize::{Encodable, Encoder};\n"), CGGeneric("use serialize::{Encodable, Encoder};\n"),
CGGeneric("use js::jsapi::JSTracer;\n\n")] CGGeneric("use js::jsapi::JSTracer;\n\n")]
for descriptor in descriptors: for descriptor in descriptors:
@ -5269,22 +5302,34 @@ class GlobalGenRoots():
cast = [CGGeneric(string.Template('''pub trait ${castTraitName} { cast = [CGGeneric(string.Template('''pub trait ${castTraitName} {
#[inline(always)] #[inline(always)]
fn from<T: ${fromBound}>(derived: &JS<T>) -> JS<Self> { fn to_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a JSRef<'b, T>) -> Option<&'a JSRef<'b, Self>> {
unsafe { derived.clone().transmute() } match base.deref().${checkFn}() {
} true => unsafe { Some(base.transmute()) },
#[inline(always)]
fn to<T: ${toBound}>(base: &JS<T>) -> Option<JS<Self>> {
match base.get().${checkFn}() {
true => unsafe { Some(base.clone().transmute()) },
false => None false => None
} }
} }
#[inline(always)] #[inline(always)]
unsafe fn to_unchecked<T: ${toBound}>(base: &JS<T>) -> JS<Self> { fn to_mut_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a mut JSRef<'b, T>) -> Option<&'a mut JSRef<'b, Self>> {
assert!(base.get().${checkFn}()); match base.deref().${checkFn}() {
base.clone().transmute() true => unsafe { Some(base.transmute_mut()) },
false => None
}
}
#[inline(always)]
fn from_ref<'a, 'b, T: ${fromBound}>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, Self> {
unsafe { derived.transmute() }
}
#[inline(always)]
fn from_mut_ref<'a, 'b, T: ${fromBound}>(derived: &'a mut JSRef<'b, T>) -> &'a mut JSRef<'b, Self> {
unsafe { derived.transmute_mut() }
}
#[inline(always)]
fn from_unrooted<T: ${fromBound}+Reflectable>(derived: Temporary<T>) -> Temporary<Self> {
unsafe { derived.transmute() }
} }
} }
''').substitute({'checkFn': 'is_' + name.lower(), ''').substitute({'checkFn': 'is_' + name.lower(),
@ -5313,7 +5358,7 @@ class GlobalGenRoots():
curr = UnionTypes(config.getDescriptors()) curr = UnionTypes(config.getDescriptors())
curr = CGImports(curr, [ curr = CGImports(curr, [], [
'dom::bindings::utils::unwrap_jsmanaged', 'dom::bindings::utils::unwrap_jsmanaged',
'dom::bindings::codegen::PrototypeList', 'dom::bindings::codegen::PrototypeList',
'dom::bindings::conversions::{FromJSValConvertible, ToJSValConvertible}', 'dom::bindings::conversions::{FromJSValConvertible, ToJSValConvertible}',

View file

@ -128,14 +128,19 @@ class Descriptor(DescriptorProvider):
# Read the desc, and fill in the relevant defaults. # Read the desc, and fill in the relevant defaults.
ifaceName = self.interface.identifier.name ifaceName = self.interface.identifier.name
if self.interface.isCallback():
nativeTypeDefault = "nsIDOM" + ifaceName
else:
nativeTypeDefault = 'JS<%s>' % ifaceName
self.nativeType = desc.get('nativeType', nativeTypeDefault) # Callback types do not use JS smart pointers, so we should not use the
# built-in rooting mechanisms for them.
if self.interface.isCallback():
self.needsRooting = False
else:
self.needsRooting = True
self.returnType = "Temporary<%s>" % ifaceName
self.argumentType = "JSRef<%s>" % ifaceName
self.memberType = "Root<'a, 'b, %s>" % ifaceName
self.nativeType = desc.get('nativeType', 'JS<%s>' % ifaceName)
self.concreteType = desc.get('concreteType', ifaceName) self.concreteType = desc.get('concreteType', ifaceName)
self.needsAbstract = desc.get('needsAbstract', [])
self.createGlobal = desc.get('createGlobal', False) self.createGlobal = desc.get('createGlobal', False)
self.register = desc.get('register', True) self.register = desc.get('register', True)
self.outerObjectHook = desc.get('outerObjectHook', 'None') self.outerObjectHook = desc.get('outerObjectHook', 'None')

View file

@ -2,9 +2,9 @@
* 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::js::JS; use dom::bindings::js::{JS, JSRef, Root};
use dom::bindings::str::ByteString; use dom::bindings::str::ByteString;
use dom::bindings::utils::Reflectable; use dom::bindings::utils::{Reflectable, Reflector};
use dom::bindings::utils::jsstring_to_str; use dom::bindings::utils::jsstring_to_str;
use dom::bindings::utils::unwrap_jsmanaged; use dom::bindings::utils::unwrap_jsmanaged;
use servo_util::str::DOMString; use servo_util::str::DOMString;
@ -293,9 +293,9 @@ impl FromJSValConvertible<()> for ByteString {
} }
} }
impl<T: Reflectable> ToJSValConvertible for JS<T> { impl ToJSValConvertible for Reflector {
fn to_jsval(&self, cx: *JSContext) -> JSVal { fn to_jsval(&self, cx: *JSContext) -> JSVal {
let obj = self.reflector().get_jsobject(); let obj = self.get_jsobject();
assert!(obj.is_not_null()); assert!(obj.is_not_null());
let mut value = ObjectValue(unsafe { &*obj }); let mut value = ObjectValue(unsafe { &*obj });
if unsafe { JS_WrapValue(cx, &mut value as *mut JSVal as *JSVal) } == 0 { if unsafe { JS_WrapValue(cx, &mut value as *mut JSVal as *JSVal) } == 0 {
@ -316,6 +316,18 @@ impl<T: Reflectable+IDLInterface> FromJSValConvertible<()> for JS<T> {
} }
} }
impl<'a, 'b, T: Reflectable> ToJSValConvertible for Root<'a, 'b, T> {
fn to_jsval(&self, cx: *JSContext) -> JSVal {
self.reflector().to_jsval(cx)
}
}
impl<'a, T: Reflectable> ToJSValConvertible for JSRef<'a, T> {
fn to_jsval(&self, cx: *JSContext) -> JSVal {
self.reflector().to_jsval(cx)
}
}
impl<T: ToJSValConvertible> ToJSValConvertible for Option<T> { impl<T: ToJSValConvertible> ToJSValConvertible for Option<T> {
fn to_jsval(&self, cx: *JSContext) -> JSVal { fn to_jsval(&self, cx: *JSContext) -> JSVal {
match self { match self {

View file

@ -2,14 +2,115 @@
* 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::{Reflector, Reflectable}; /// The DOM is made up of Rust types whose lifetime is entirely controlled by the whims of
use dom::window::Window; /// the SpiderMonkey garbage collector. The types in this module are designed to ensure
use js::jsapi::JSContext; /// that any interactions with said Rust types only occur on values that will remain alive
/// the entire time.
///
/// Here is a brief overview of the important types:
/// - JSRef<T>: a freely-copyable reference to a rooted value.
/// - JS<T>: a pointer to JS-owned memory that can automatically be traced by the GC when
/// encountered as a field of a Rust structure.
/// - Temporary<T>: a value that will remain rooted for the duration of its lifetime.
///
/// The rule of thumb is as follows:
/// - All methods return Temporary<T>, to ensure the value remains alive until it is stored
/// somewhere that is reachable by the GC.
/// - All functions take &JSRef<T> arguments, to ensure that they will remain uncollected for
/// the duration of their usage.
/// - All types contain JS<T> fields and derive the Encodable trait, to ensure that they are
/// transitively marked as reachable by the GC if the enclosing value is reachable.
/// - All methods for type T are implemented for JSRef<T>, to ensure that the self value
/// will not be collected for the duration of the method call.
///
/// Both Temporary<T> and JS<T> do not allow access to their inner value without explicitly
/// creating a stack-based root via the `root` method. This returns a Root<T>, which causes
/// the JS-owned value to be uncollectable for the duration of the Root type's lifetime.
/// A JSRef<T> can be obtained from a Root<T> either by dereferencing the Root<T> (`*rooted`)
/// or explicitly calling the `root_ref` method. These JSRef<T> values are not allowed to
/// outlive their originating Root<T>, to ensure that all interactions with the enclosed value
/// only occur when said value is uncollectable, and will cause static lifetime errors if
/// misused.
///
/// Other miscellaneous helper traits:
/// - OptionalRootable and OptionalRootedRootable: make rooting Option values easy via a `root` method
/// - ResultRootable: make rooting successful Result values easy
/// - TemporaryPushable: allows mutating vectors of JS<T> with new elements of JSRef/Temporary
/// - OptionalSettable: allows assigning Option values of JSRef/Temporary to fields of Option<JS<T>>
/// - RootedReference: makes obtaining an Option<JSRef<T>> from an Option<Root<T>> easy
use dom::bindings::utils::{Reflector, Reflectable, cx_for_dom_object};
use dom::node::Node;
use js::jsapi::{JSObject, JS_AddObjectRoot, JS_RemoveObjectRoot};
use layout_interface::TrustedNodeAddress; use layout_interface::TrustedNodeAddress;
use script_task::StackRoots;
use std::cast; use std::cast;
use std::cell::RefCell; use std::cell::RefCell;
use std::local_data;
/// A type that represents a JS-owned value that is rooted for the lifetime of this value.
/// Importantly, it requires explicit rooting in order to interact with the inner value.
/// Can be assigned into JS-owned member fields (ie. JS<T> types) safely via the
/// `JS<T>::assign` method or `OptionalSettable::assign` (for Option<JS<T>> fields).
pub struct Temporary<T> {
inner: JS<T>,
}
impl<T> Eq for Temporary<T> {
fn eq(&self, other: &Temporary<T>) -> bool {
self.inner == other.inner
}
}
#[unsafe_destructor]
impl<T: Reflectable> Drop for Temporary<T> {
fn drop(&mut self) {
let cx = cx_for_dom_object(&self.inner);
unsafe {
JS_RemoveObjectRoot(cx, self.inner.reflector().rootable());
}
}
}
impl<T: Reflectable> Temporary<T> {
/// Create a new Temporary value from a JS-owned value.
pub fn new(inner: JS<T>) -> Temporary<T> {
let cx = cx_for_dom_object(&inner);
unsafe {
JS_AddObjectRoot(cx, inner.reflector().rootable());
}
Temporary {
inner: inner,
}
}
/// Create a new Temporary value from a rooted value.
pub fn from_rooted<'a>(root: &JSRef<'a, T>) -> Temporary<T> {
Temporary::new(root.unrooted())
}
/// Create a stack-bounded root for this value.
pub fn root<'a, 'b>(self) -> Root<'a, 'b, T> {
local_data::get(StackRoots, |opt| {
let collection = opt.unwrap();
unsafe {
(**collection).new_root(&self.inner)
}
})
}
unsafe fn inner(&self) -> JS<T> {
self.inner.clone()
}
//XXXjdm It would be lovely if this could be private.
pub unsafe fn transmute<To>(self) -> Temporary<To> {
cast::transmute(self)
}
}
/// A rooted, JS-owned value. Must only be used as a field in other JS-owned types.
pub struct JS<T> { pub struct JS<T> {
ptr: RefCell<*mut T> ptr: RefCell<*mut T>
} }
@ -29,13 +130,18 @@ impl <T> Clone for JS<T> {
} }
} }
impl<T: Reflectable> JS<T> { impl JS<Node> {
pub fn new(obj: ~T, /// Create a new JS-owned value wrapped from an address known to be a Node pointer.
window: &JS<Window>, pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> JS<Node> {
wrap_fn: extern "Rust" fn(*JSContext, &JS<Window>, ~T) -> JS<T>) -> JS<T> { let TrustedNodeAddress(addr) = inner;
wrap_fn(window.get().get_cx(), window, obj) JS {
ptr: RefCell::new(addr as *mut Node)
}
} }
}
impl<T: Reflectable> JS<T> {
/// Create a new JS-owned value wrapped from a raw Rust pointer.
pub unsafe fn from_raw(raw: *mut T) -> JS<T> { pub unsafe fn from_raw(raw: *mut T) -> JS<T> {
JS { JS {
ptr: RefCell::new(raw) ptr: RefCell::new(raw)
@ -43,45 +149,47 @@ impl<T: Reflectable> JS<T> {
} }
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> JS<T> { /// Root this JS-owned value to prevent its collection as garbage.
let TrustedNodeAddress(addr) = inner; pub fn root<'a, 'b>(&self) -> Root<'a, 'b, T> {
JS { local_data::get(StackRoots, |opt| {
ptr: RefCell::new(addr as *mut T) let collection = opt.unwrap();
} unsafe {
(**collection).new_root(self)
}
})
} }
} }
//XXXjdm This is disappointing. This only gets called from trace hooks, in theory,
// so it's safe to assume that self is rooted and thereby safe to access.
impl<T: Reflectable> Reflectable for JS<T> { impl<T: Reflectable> Reflectable for JS<T> {
fn reflector<'a>(&'a self) -> &'a Reflector { fn reflector<'a>(&'a self) -> &'a Reflector {
self.get().reflector() unsafe {
(*self.unsafe_get()).reflector()
}
} }
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector { fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
self.get_mut().mut_reflector() unsafe {
(*self.unsafe_get()).mut_reflector()
}
} }
} }
impl<T> JS<T> { impl<T: Reflectable> JS<T> {
pub fn get<'a>(&'a self) -> &'a T {
let borrowed = self.ptr.borrow();
unsafe {
&**borrowed
}
}
pub fn get_mut<'a>(&'a mut self) -> &'a mut T {
let mut borrowed = self.ptr.borrow_mut();
unsafe {
&mut **borrowed
}
}
/// Returns an unsafe pointer to the interior of this JS object without touching the borrow /// Returns an unsafe pointer to the interior of this JS object without touching the borrow
/// flags. This is the only method that be safely accessed from layout. (The fact that this /// flags. This is the only method that be safely accessed from layout. (The fact that this
/// is unsafe is what necessitates the layout wrappers.) /// is unsafe is what necessitates the layout wrappers.)
pub unsafe fn unsafe_get(&self) -> *mut T { pub unsafe fn unsafe_get(&self) -> *mut T {
cast::transmute_copy(&self.ptr) cast::transmute_copy(&self.ptr)
} }
/// Store an unrooted value in this field. This is safe under the assumption that JS<T>
/// values are only used as fields in DOM types that are reachable in the GC graph,
/// so this unrooted value becomes transitively rooted for the lifetime of its new owner.
pub fn assign(&mut self, val: Temporary<T>) {
*self = unsafe { val.inner() };
}
} }
impl<From, To> JS<From> { impl<From, To> JS<From> {
@ -94,3 +202,304 @@ impl<From, To> JS<From> {
cast::transmute_copy(self) cast::transmute_copy(self)
} }
} }
/// Get an Option<JSRef<T>> out of an Option<Root<T>>
pub trait RootedReference<T> {
fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>>;
}
impl<'a, 'b, T: Reflectable> RootedReference<T> for Option<Root<'a, 'b, T>> {
fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>> {
self.as_ref().map(|root| root.root_ref())
}
}
/// Get an Option<Option<JSRef<T>>> out of an Option<Option<Root<T>>>
pub trait OptionalRootedReference<T> {
fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>>;
}
impl<'a, 'b, T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<'a, 'b, T>>> {
fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>> {
self.as_ref().map(|inner| inner.root_ref())
}
}
/// Trait that allows extracting a JS<T> value from a variety of rooting-related containers,
/// which in general is an unsafe operation since they can outlive the rooted lifetime of the
/// original value.
/*definitely not public*/ trait Assignable<T> {
unsafe fn get_js(&self) -> JS<T>;
}
impl<T> Assignable<T> for JS<T> {
unsafe fn get_js(&self) -> JS<T> {
self.clone()
}
}
impl<'a, T> Assignable<T> for JSRef<'a, T> {
unsafe fn get_js(&self) -> JS<T> {
self.unrooted()
}
}
impl<T: Reflectable> Assignable<T> for Temporary<T> {
unsafe fn get_js(&self) -> JS<T> {
self.inner()
}
}
/// Assign an optional rootable value (either of JS<T> or Temporary<T>) to an optional
/// field of a DOM type (ie. Option<JS<T>>)
pub trait OptionalSettable<T> {
fn assign(&mut self, val: Option<T>);
}
impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Option<JS<U>> {
fn assign(&mut self, val: Option<T>) {
*self = val.map(|val| unsafe { val.get_js() });
}
}
/// Root a rootable Option type (used for Option<Temporary<T>>)
pub trait OptionalRootable<T> {
fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>>;
}
impl<T: Reflectable> OptionalRootable<T> for Option<Temporary<T>> {
fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>> {
self.map(|inner| inner.root())
}
}
/// Return an unrooted type for storing in optional DOM fields
pub trait OptionalUnrootable<T> {
fn unrooted(&self) -> Option<JS<T>>;
}
impl<'a, T: Reflectable> OptionalUnrootable<T> for Option<JSRef<'a, T>> {
fn unrooted(&self) -> Option<JS<T>> {
self.as_ref().map(|inner| inner.unrooted())
}
}
/// Root a rootable Option type (used for Option<JS<T>>)
pub trait OptionalRootedRootable<T> {
fn root<'a, 'b>(&self) -> Option<Root<'a, 'b, T>>;
}
impl<T: Reflectable> OptionalRootedRootable<T> for Option<JS<T>> {
fn root<'a, 'b>(&self) -> Option<Root<'a, 'b, T>> {
self.as_ref().map(|inner| inner.root())
}
}
/// Root a rootable Option<Option> type (used for Option<Option<JS<T>>>)
pub trait OptionalOptionalRootedRootable<T> {
fn root<'a, 'b>(&self) -> Option<Option<Root<'a, 'b, T>>>;
}
impl<T: Reflectable> OptionalOptionalRootedRootable<T> for Option<Option<JS<T>>> {
fn root<'a, 'b>(&self) -> Option<Option<Root<'a, 'b, T>>> {
self.as_ref().map(|inner| inner.root())
}
}
/// Root a rootable Result type (any of Temporary<T> or JS<T>)
pub trait ResultRootable<T,U> {
fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U>;
}
impl<T: Reflectable, U> ResultRootable<T, U> for Result<Temporary<T>, U> {
fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U> {
self.map(|inner| inner.root())
}
}
impl<T: Reflectable, U> ResultRootable<T, U> for Result<JS<T>, U> {
fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U> {
self.map(|inner| inner.root())
}
}
/// Provides a facility to push unrooted values onto lists of rooted values. This is safe
/// under the assumption that said lists are reachable via the GC graph, and therefore the
/// new values are transitively rooted for the lifetime of their new owner.
pub trait TemporaryPushable<T> {
fn push_unrooted(&mut self, val: &T);
fn insert_unrooted(&mut self, index: uint, val: &T);
}
impl<T: Assignable<U>, U: Reflectable> TemporaryPushable<T> for Vec<JS<U>> {
fn push_unrooted(&mut self, val: &T) {
self.push(unsafe { val.get_js() });
}
fn insert_unrooted(&mut self, index: uint, val: &T) {
self.insert(index, unsafe { val.get_js() });
}
}
/// An opaque, LIFO rooting mechanism.
pub struct RootCollection {
roots: RefCell<Vec<*JSObject>>,
}
impl RootCollection {
/// Create an empty collection of roots
pub fn new() -> RootCollection {
RootCollection {
roots: RefCell::new(vec!()),
}
}
/// Create a new stack-bounded root that will not outlive this collection
fn new_root<'a, 'b, T: Reflectable>(&'a self, unrooted: &JS<T>) -> Root<'a, 'b, T> {
Root::new(self, unrooted)
}
/// Track a stack-based root to ensure LIFO root ordering
fn root<'a, 'b, T: Reflectable>(&self, untracked: &Root<'a, 'b, T>) {
let mut roots = self.roots.borrow_mut();
roots.push(untracked.js_ptr);
debug!(" rooting {:?}", untracked.js_ptr);
}
/// Stop tracking a stack-based root, asserting if LIFO root ordering has been violated
fn unroot<'a, 'b, T: Reflectable>(&self, rooted: &Root<'a, 'b, T>) {
let mut roots = self.roots.borrow_mut();
debug!("unrooting {:?} (expecting {:?}", roots.last().unwrap(), rooted.js_ptr);
assert!(*roots.last().unwrap() == rooted.js_ptr);
roots.pop().unwrap();
}
}
/// A rooted JS value. The JS value is pinned for the duration of this object's lifetime;
/// roots are additive, so this object's destruction will not invalidate other roots
/// for the same JS value. Roots cannot outlive the associated RootCollection object.
/// Attempts to transfer ownership of a Root via moving will trigger dynamic unrooting
/// failures due to incorrect ordering.
pub struct Root<'a, 'b, T> {
/// List that ensures correct dynamic root ordering
root_list: &'a RootCollection,
/// Reference to rooted value that must not outlive this container
jsref: JSRef<'b, T>,
/// Pointer to underlying Rust data
ptr: RefCell<*mut T>,
/// On-stack JS pointer to assuage conservative stack scanner
js_ptr: *JSObject,
}
impl<'a, 'b, T: Reflectable> Root<'a, 'b, T> {
/// Create a new stack-bounded root for the provided JS-owned value.
/// It cannot not outlive its associated RootCollection, and it contains a JSRef
/// which cannot outlive this new Root.
fn new(roots: &'a RootCollection, unrooted: &JS<T>) -> Root<'a, 'b, T> {
let root = Root {
root_list: roots,
jsref: JSRef {
ptr: unrooted.ptr.clone(),
chain: unsafe { cast::transmute_region(&()) },
},
ptr: unrooted.ptr.clone(),
js_ptr: unrooted.reflector().get_jsobject(),
};
roots.root(&root);
root
}
/// Obtain a safe reference to the wrapped JS owned-value that cannot outlive
/// the lifetime of this root.
pub fn root_ref<'b>(&'b self) -> JSRef<'b,T> {
self.jsref.clone()
}
}
#[unsafe_destructor]
impl<'a, 'b, T: Reflectable> Drop for Root<'a, 'b, T> {
fn drop(&mut self) {
self.root_list.unroot(self);
}
}
impl<'a, 'b, T: Reflectable> Deref<JSRef<'b, T>> for Root<'a, 'b, T> {
fn deref<'c>(&'c self) -> &'c JSRef<'b, T> {
&self.jsref
}
}
impl<'a, 'b, T: Reflectable> DerefMut<JSRef<'b, T>> for Root<'a, 'b, T> {
fn deref_mut<'c>(&'c mut self) -> &'c mut JSRef<'b, T> {
&mut self.jsref
}
}
impl<'a, T: Reflectable> Deref<T> for JSRef<'a, T> {
fn deref<'b>(&'b self) -> &'b T {
let borrow = self.ptr.borrow();
unsafe {
&**borrow
}
}
}
impl<'a, T: Reflectable> DerefMut<T> for JSRef<'a, T> {
fn deref_mut<'b>(&'b mut self) -> &'b mut T {
let mut borrowed = self.ptr.borrow_mut();
unsafe {
&mut **borrowed
}
}
}
/// Encapsulates a reference to something that is guaranteed to be alive. This is freely copyable.
pub struct JSRef<'a, T> {
ptr: RefCell<*mut T>,
chain: &'a (),
}
impl<'a, T> Clone for JSRef<'a, T> {
fn clone(&self) -> JSRef<'a, T> {
JSRef {
ptr: self.ptr.clone(),
chain: self.chain
}
}
}
impl<'a, T> Eq for JSRef<'a, T> {
fn eq(&self, other: &JSRef<T>) -> bool {
self.ptr == other.ptr
}
}
impl<'a,T> JSRef<'a,T> {
//XXXjdm It would be lovely if this could be private.
pub unsafe fn transmute<'b, To>(&'b self) -> &'b JSRef<'a, To> {
cast::transmute(self)
}
//XXXjdm It would be lovely if this could be private.
pub unsafe fn transmute_mut<'b, To>(&'b mut self) -> &'b mut JSRef<'a, To> {
cast::transmute(self)
}
pub fn unrooted(&self) -> JS<T> {
JS {
ptr: self.ptr.clone()
}
}
}
impl<'a, T: Reflectable> Reflectable for JSRef<'a, T> {
fn reflector<'a>(&'a self) -> &'a Reflector {
self.deref().reflector()
}
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
self.deref_mut().mut_reflector()
}
}

View file

@ -6,6 +6,7 @@ use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, Reflector}; use dom::bindings::utils::{Reflectable, Reflector};
use js::jsapi::{JSObject, JSTracer, JS_CallTracer, JSTRACE_OBJECT}; use js::jsapi::{JSObject, JSTracer, JS_CallTracer, JSTRACE_OBJECT};
use js::jsval::JSVal;
use libc; use libc;
use std::cast; use std::cast;
@ -42,6 +43,22 @@ pub trait JSTraceable {
fn trace(&self, trc: *mut JSTracer); fn trace(&self, trc: *mut JSTracer);
} }
pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: JSVal) {
if !val.is_gcthing() {
return;
}
unsafe {
description.to_c_str().with_ref(|name| {
(*tracer).debugPrinter = ptr::null();
(*tracer).debugPrintIndex = -1;
(*tracer).debugPrintArg = name as *libc::c_void;
debug!("tracing value {:s}", description);
JS_CallTracer(tracer as *JSTracer, val.to_gcthing(), val.trace_kind());
});
}
}
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) { pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
trace_object(tracer, description, reflector.get_jsobject()) trace_object(tracer, description, reflector.get_jsobject())
} }
@ -132,3 +149,10 @@ impl<S: Encoder<E>, E> Encodable<S, E> for Traceable<*JSObject> {
Ok(()) Ok(())
} }
} }
impl<S: Encoder<E>, E> Encodable<S, E> for Traceable<JSVal> {
fn encode(&self, s: &mut S) -> Result<(), E> {
trace_jsval(get_jstracer(s), "val", **self);
Ok(())
}
}

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::PrototypeList; use dom::bindings::codegen::PrototypeList;
use dom::bindings::codegen::PrototypeList::MAX_PROTO_CHAIN_LENGTH; use dom::bindings::codegen::PrototypeList::MAX_PROTO_CHAIN_LENGTH;
use dom::bindings::conversions::{FromJSValConvertible, IDLInterface}; use dom::bindings::conversions::{FromJSValConvertible, IDLInterface};
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary, Root};
use dom::bindings::trace::Untraceable; use dom::bindings::trace::Untraceable;
use dom::browsercontext; use dom::browsercontext;
use dom::window; use dom::window;
@ -37,7 +37,6 @@ use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative};
use js::jsapi::{JSFunctionSpec, JSPropertySpec}; use js::jsapi::{JSFunctionSpec, JSPropertySpec};
use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses}; use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses};
use js::jsapi::{JSString}; use js::jsapi::{JSString};
use js::jsapi::{JS_AllowGC, JS_InhibitGC};
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType; use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
use js::jsval::JSVal; use js::jsval::JSVal;
use js::jsval::{PrivateValue, ObjectValue, NullValue, ObjectOrNullValue}; use js::jsval::{PrivateValue, ObjectValue, NullValue, ObjectOrNullValue};
@ -390,10 +389,10 @@ pub trait Reflectable {
pub fn reflect_dom_object<T: Reflectable> pub fn reflect_dom_object<T: Reflectable>
(obj: ~T, (obj: ~T,
window: &JS<window::Window>, window: &JSRef<window::Window>,
wrap_fn: extern "Rust" fn(*JSContext, &JS<window::Window>, ~T) -> JS<T>) wrap_fn: extern "Rust" fn(*JSContext, &JSRef<window::Window>, ~T) -> JS<T>)
-> JS<T> { -> Temporary<T> {
JS::new(obj, window, wrap_fn) Temporary::new(wrap_fn(window.deref().get_cx(), window, obj))
} }
#[deriving(Eq)] #[deriving(Eq)]
@ -413,6 +412,13 @@ impl Reflector {
self.object = object; self.object = object;
} }
/// Return a pointer to the memory location at which the JS reflector object is stored.
/// Used by Temporary values to root the reflector, as required by the JSAPI rooting
/// APIs.
pub fn rootable<'a>(&'a self) -> &'a *JSObject {
&self.object
}
pub fn new() -> Reflector { pub fn new() -> Reflector {
Reflector { Reflector {
object: ptr::null(), object: ptr::null(),
@ -605,11 +611,13 @@ pub extern fn outerize_global(_cx: *JSContext, obj: JSHandleObject) -> *JSObject
unsafe { unsafe {
debug!("outerizing"); debug!("outerizing");
let obj = *obj.unnamed; let obj = *obj.unnamed;
let win: JS<window::Window> = let win: Root<window::Window> =
unwrap_jsmanaged(obj, unwrap_jsmanaged(obj,
IDLInterface::get_prototype_id(None::<window::Window>), IDLInterface::get_prototype_id(None::<window::Window>),
IDLInterface::get_prototype_depth(None::<window::Window>)).unwrap(); IDLInterface::get_prototype_depth(None::<window::Window>))
win.get().browser_context.get_ref().window_proxy() .unwrap()
.root();
win.deref().browser_context.get_ref().window_proxy()
} }
} }
@ -625,8 +633,8 @@ pub fn global_object_for_js_object(obj: *JSObject) -> JS<window::Window> {
} }
fn cx_for_dom_reflector(obj: *JSObject) -> *JSContext { fn cx_for_dom_reflector(obj: *JSObject) -> *JSContext {
let win = global_object_for_js_object(obj); let win = global_object_for_js_object(obj).root();
let js_info = win.get().page().js_info(); let js_info = win.deref().page().js_info();
match *js_info { match *js_info {
Some(ref info) => info.js_context.deref().deref().ptr, Some(ref info) => info.js_context.deref().deref().ptr,
None => fail!("no JS context for DOM global") None => fail!("no JS context for DOM global")
@ -637,26 +645,6 @@ pub fn cx_for_dom_object<T: Reflectable>(obj: &T) -> *JSContext {
cx_for_dom_reflector(obj.reflector().get_jsobject()) cx_for_dom_reflector(obj.reflector().get_jsobject())
} }
/// Execute arbitrary code with the JS GC enabled, then disable it afterwards.
pub fn with_gc_enabled<R>(cx: *JSContext, f: || -> R) -> R {
unsafe {
JS_AllowGC(cx);
let rv = f();
JS_InhibitGC(cx);
rv
}
}
/// Execute arbitrary code with the JS GC disabled, then enable it afterwards.
pub fn with_gc_disabled<R>(cx: *JSContext, f: || -> R) -> R {
unsafe {
JS_InhibitGC(cx);
let rv = f();
JS_AllowGC(cx);
rv
}
}
/// Check if an element name is valid. See http://www.w3.org/TR/xml/#NT-Name /// Check if an element name is valid. See http://www.w3.org/TR/xml/#NT-Name
/// for details. /// for details.
#[deriving(Eq)] #[deriving(Eq)]

View file

@ -2,7 +2,7 @@
* 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::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::bindings::codegen::BindingDeclarations::BlobBinding; use dom::bindings::codegen::BindingDeclarations::BlobBinding;
@ -16,38 +16,46 @@ pub struct Blob {
} }
impl Blob { impl Blob {
pub fn new_inherited(window: JS<Window>) -> Blob { pub fn new_inherited(window: &JSRef<Window>) -> Blob {
Blob { Blob {
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: window window: window.unrooted()
} }
} }
pub fn new(window: &JS<Window>) -> JS<Blob> { pub fn new(window: &JSRef<Window>) -> Temporary<Blob> {
reflect_dom_object(~Blob::new_inherited(window.clone()), reflect_dom_object(~Blob::new_inherited(window),
window, window,
BlobBinding::Wrap) BlobBinding::Wrap)
} }
}
impl Blob { pub fn Constructor(window: &JSRef<Window>) -> Fallible<Temporary<Blob>> {
pub fn Constructor(window: &JS<Window>) -> Fallible<JS<Blob>> {
Ok(Blob::new(window)) Ok(Blob::new(window))
} }
}
pub fn Size(&self) -> u64 { pub trait BlobMethods {
fn Size(&self) -> u64;
fn Type(&self) -> DOMString;
fn Slice(&self, _start: Option<i64>, _end: Option<i64>, _contentType: Option<DOMString>) -> Temporary<Blob>;
fn Close(&self);
}
impl<'a> BlobMethods for JSRef<'a, Blob> {
fn Size(&self) -> u64 {
0 0
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn Slice(&self, _start: Option<i64>, _end: Option<i64>, _contentType: Option<DOMString>) -> JS<Blob> { fn Slice(&self, _start: Option<i64>, _end: Option<i64>, _contentType: Option<DOMString>) -> Temporary<Blob> {
Blob::new(&self.window) let window = self.window.root();
Blob::new(&window.root_ref())
} }
pub fn Close(&self) {} fn Close(&self) {}
} }
impl Reflectable for Blob { impl Reflectable for Blob {

View file

@ -2,7 +2,7 @@
* 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::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::trace::Traceable; use dom::bindings::trace::Traceable;
use dom::bindings::utils::Reflectable; use dom::bindings::utils::Reflectable;
use dom::document::Document; use dom::document::Document;
@ -22,7 +22,7 @@ pub struct BrowserContext {
} }
impl BrowserContext { impl BrowserContext {
pub fn new(document: &JS<Document>) -> BrowserContext { pub fn new(document: &JSRef<Document>) -> BrowserContext {
let mut context = BrowserContext { let mut context = BrowserContext {
history: vec!(SessionHistoryEntry::new(document)), history: vec!(SessionHistoryEntry::new(document)),
active_index: 0, active_index: 0,
@ -32,13 +32,13 @@ impl BrowserContext {
context context
} }
pub fn active_document(&self) -> JS<Document> { pub fn active_document(&self) -> Temporary<Document> {
self.history.get(self.active_index).document.clone() Temporary::new(self.history.get(self.active_index).document.clone())
} }
pub fn active_window(&self) -> JS<Window> { pub fn active_window(&self) -> Temporary<Window> {
let doc = self.active_document(); let doc = self.active_document().root();
doc.get().window.clone() Temporary::new(doc.deref().window.clone())
} }
pub fn window_proxy(&self) -> *JSObject { pub fn window_proxy(&self) -> *JSObject {
@ -47,14 +47,14 @@ impl BrowserContext {
} }
pub fn create_window_proxy(&self) -> *JSObject { pub fn create_window_proxy(&self) -> *JSObject {
let win = self.active_window(); let win = self.active_window().root();
let page = win.get().page(); let page = win.deref().page();
let js_info = page.js_info(); let js_info = page.js_info();
let handler = js_info.get_ref().dom_static.windowproxy_handler; let handler = js_info.get_ref().dom_static.windowproxy_handler;
assert!(handler.deref().is_not_null()); assert!(handler.deref().is_not_null());
let parent = win.get().reflector().get_jsobject(); let parent = win.deref().reflector().get_jsobject();
let cx = js_info.get_ref().js_context.deref().deref().ptr; let cx = js_info.get_ref().js_context.deref().deref().ptr;
let wrapper = unsafe { let wrapper = unsafe {
WrapperNew(cx, parent, *handler.deref()) WrapperNew(cx, parent, *handler.deref())
@ -71,9 +71,9 @@ pub struct SessionHistoryEntry {
} }
impl SessionHistoryEntry { impl SessionHistoryEntry {
fn new(document: &JS<Document>) -> SessionHistoryEntry { fn new(document: &JSRef<Document>) -> SessionHistoryEntry {
SessionHistoryEntry { SessionHistoryEntry {
document: document.clone(), document: document.unrooted(),
children: vec!() children: vec!()
} }
} }

View file

@ -5,7 +5,7 @@
//! DOM bindings for `CharacterData`. //! DOM bindings for `CharacterData`.
use dom::bindings::codegen::InheritTypes::CharacterDataDerived; use dom::bindings::codegen::InheritTypes::CharacterDataDerived;
use dom::bindings::js::JS; use dom::bindings::js::JSRef;
use dom::bindings::error::{Fallible, ErrorResult, IndexSize}; use dom::bindings::error::{Fallible, ErrorResult, IndexSize};
use dom::bindings::utils::{Reflectable, Reflector}; use dom::bindings::utils::{Reflectable, Reflector};
use dom::document::Document; use dom::document::Document;
@ -31,44 +31,57 @@ impl CharacterDataDerived for EventTarget {
} }
impl CharacterData { impl CharacterData {
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JS<Document>) -> CharacterData { pub fn new_inherited(id: NodeTypeId, data: DOMString, document: &JSRef<Document>) -> CharacterData {
CharacterData { CharacterData {
node: Node::new_inherited(id, document), node: Node::new_inherited(id, document),
data: data data: data
} }
} }
}
pub fn Data(&self) -> DOMString { pub trait CharacterDataMethods {
fn Data(&self) -> DOMString;
fn SetData(&mut self, arg: DOMString) -> ErrorResult;
fn Length(&self) -> u32;
fn SubstringData(&self, offset: u32, count: u32) -> Fallible<DOMString>;
fn AppendData(&mut self, arg: DOMString) -> ErrorResult;
fn InsertData(&mut self, _offset: u32, _arg: DOMString) -> ErrorResult;
fn DeleteData(&mut self, _offset: u32, _count: u32) -> ErrorResult;
fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) -> ErrorResult;
}
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
fn Data(&self) -> DOMString {
self.data.clone() self.data.clone()
} }
pub fn SetData(&mut self, arg: DOMString) -> ErrorResult { fn SetData(&mut self, arg: DOMString) -> ErrorResult {
self.data = arg; self.data = arg;
Ok(()) Ok(())
} }
pub fn Length(&self) -> u32 { fn Length(&self) -> u32 {
self.data.len() as u32 self.data.len() as u32
} }
pub fn SubstringData(&self, offset: u32, count: u32) -> Fallible<DOMString> { fn SubstringData(&self, offset: u32, count: u32) -> Fallible<DOMString> {
Ok(self.data.slice(offset as uint, count as uint).to_str()) Ok(self.data.slice(offset as uint, count as uint).to_str())
} }
pub fn AppendData(&mut self, arg: DOMString) -> ErrorResult { fn AppendData(&mut self, arg: DOMString) -> ErrorResult {
self.data.push_str(arg); self.data.push_str(arg);
Ok(()) Ok(())
} }
pub fn InsertData(&mut self, offset: u32, arg: DOMString) -> ErrorResult { fn InsertData(&mut self, offset: u32, arg: DOMString) -> ErrorResult {
self.ReplaceData(offset, 0, arg) self.ReplaceData(offset, 0, arg)
} }
pub fn DeleteData(&mut self, offset: u32, count: u32) -> ErrorResult { fn DeleteData(&mut self, offset: u32, count: u32) -> ErrorResult {
self.ReplaceData(offset, count, ~"") self.ReplaceData(offset, count, ~"")
} }
pub fn ReplaceData(&mut self, offset: u32, count: u32, arg: DOMString) -> ErrorResult { fn ReplaceData(&mut self, offset: u32, count: u32, arg: DOMString) -> ErrorResult {
let length = self.data.len() as u32; let length = self.data.len() as u32;
if offset > length { if offset > length {
return Err(IndexSize); return Err(IndexSize);

View file

@ -3,7 +3,7 @@
* 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::codegen::BindingDeclarations::ClientRectBinding; use dom::bindings::codegen::BindingDeclarations::ClientRectBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::window::Window; use dom::window::Window;
use servo_util::geometry::Au; use servo_util::geometry::Au;
@ -19,7 +19,7 @@ pub struct ClientRect {
} }
impl ClientRect { impl ClientRect {
pub fn new_inherited(window: JS<Window>, pub fn new_inherited(window: &JSRef<Window>,
top: Au, bottom: Au, top: Au, bottom: Au,
left: Au, right: Au) -> ClientRect { left: Au, right: Au) -> ClientRect {
ClientRect { ClientRect {
@ -28,39 +28,49 @@ impl ClientRect {
left: left.to_nearest_px() as f32, left: left.to_nearest_px() as f32,
right: right.to_nearest_px() as f32, right: right.to_nearest_px() as f32,
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: window, window: window.unrooted(),
} }
} }
pub fn new(window: &JS<Window>, pub fn new(window: &JSRef<Window>,
top: Au, bottom: Au, top: Au, bottom: Au,
left: Au, right: Au) -> JS<ClientRect> { left: Au, right: Au) -> Temporary<ClientRect> {
let rect = ClientRect::new_inherited(window.clone(), top, bottom, left, right); let rect = ClientRect::new_inherited(window, top, bottom, left, right);
reflect_dom_object(~rect, window, ClientRectBinding::Wrap) reflect_dom_object(~rect, window, ClientRectBinding::Wrap)
} }
}
pub trait ClientRectMethods {
fn Top(&self) -> f32;
fn Bottom(&self) -> f32;
fn Left(&self) -> f32;
fn Right(&self) -> f32;
fn Width(&self) -> f32;
fn Height(&self) -> f32;
}
pub fn Top(&self) -> f32 { impl<'a> ClientRectMethods for JSRef<'a, ClientRect> {
fn Top(&self) -> f32 {
self.top self.top
} }
pub fn Bottom(&self) -> f32 { fn Bottom(&self) -> f32 {
self.bottom self.bottom
} }
pub fn Left(&self) -> f32 { fn Left(&self) -> f32 {
self.left self.left
} }
pub fn Right(&self) -> f32 { fn Right(&self) -> f32 {
self.right self.right
} }
pub fn Width(&self) -> f32 { fn Width(&self) -> f32 {
(self.right - self.left).abs() (self.right - self.left).abs()
} }
pub fn Height(&self) -> f32 { fn Height(&self) -> f32 {
(self.bottom - self.top).abs() (self.bottom - self.top).abs()
} }
} }

View file

@ -3,7 +3,7 @@
* 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::codegen::BindingDeclarations::ClientRectListBinding; use dom::bindings::codegen::BindingDeclarations::ClientRectListBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::clientrect::ClientRect; use dom::clientrect::ClientRect;
use dom::window::Window; use dom::window::Window;
@ -16,34 +16,42 @@ pub struct ClientRectList {
} }
impl ClientRectList { impl ClientRectList {
pub fn new_inherited(window: JS<Window>, pub fn new_inherited(window: &JSRef<Window>,
rects: Vec<JS<ClientRect>>) -> ClientRectList { rects: Vec<JSRef<ClientRect>>) -> ClientRectList {
ClientRectList { ClientRectList {
reflector_: Reflector::new(), reflector_: Reflector::new(),
rects: rects, rects: rects.iter().map(|rect| rect.unrooted()).collect(),
window: window, window: window.unrooted(),
} }
} }
pub fn new(window: &JS<Window>, pub fn new(window: &JSRef<Window>,
rects: Vec<JS<ClientRect>>) -> JS<ClientRectList> { rects: Vec<JSRef<ClientRect>>) -> Temporary<ClientRectList> {
reflect_dom_object(~ClientRectList::new_inherited(window.clone(), rects), reflect_dom_object(~ClientRectList::new_inherited(window, rects),
window, ClientRectListBinding::Wrap) window, ClientRectListBinding::Wrap)
} }
}
pub fn Length(&self) -> u32 { pub trait ClientRectListMethods {
fn Length(&self) -> u32;
fn Item(&self, index: u32) -> Option<Temporary<ClientRect>>;
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<ClientRect>>;
}
impl<'a> ClientRectListMethods for JSRef<'a, ClientRectList> {
fn Length(&self) -> u32 {
self.rects.len() as u32 self.rects.len() as u32
} }
pub fn Item(&self, index: u32) -> Option<JS<ClientRect>> { fn Item(&self, index: u32) -> Option<Temporary<ClientRect>> {
if index < self.rects.len() as u32 { if index < self.rects.len() as u32 {
Some(self.rects.get(index as uint).clone()) Some(Temporary::new(self.rects.get(index as uint).clone()))
} else { } else {
None None
} }
} }
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<JS<ClientRect>> { fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<ClientRect>> {
*found = index < self.rects.len() as u32; *found = index < self.rects.len() as u32;
self.Item(index) self.Item(index)
} }

View file

@ -4,13 +4,13 @@
use dom::bindings::codegen::InheritTypes::CommentDerived; use dom::bindings::codegen::InheritTypes::CommentDerived;
use dom::bindings::codegen::BindingDeclarations::CommentBinding; use dom::bindings::codegen::BindingDeclarations::CommentBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::characterdata::CharacterData; use dom::characterdata::CharacterData;
use dom::document::Document; use dom::document::Document;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::node::{CommentNodeTypeId, Node}; use dom::node::{CommentNodeTypeId, Node};
use dom::window::Window; use dom::window::{Window, WindowMethods};
use servo_util::str::DOMString; use servo_util::str::DOMString;
/// An HTML comment. /// An HTML comment.
@ -29,18 +29,22 @@ impl CommentDerived for EventTarget {
} }
impl Comment { impl Comment {
pub fn new_inherited(text: DOMString, document: JS<Document>) -> Comment { pub fn new_inherited(text: DOMString, document: &JSRef<Document>) -> Comment {
Comment { Comment {
characterdata: CharacterData::new_inherited(CommentNodeTypeId, text, document) characterdata: CharacterData::new_inherited(CommentNodeTypeId, text, document)
} }
} }
pub fn new(text: DOMString, document: &JS<Document>) -> JS<Comment> { pub fn new(text: DOMString, document: &JSRef<Document>) -> Temporary<Comment> {
let node = Comment::new_inherited(text, document.clone()); let node = Comment::new_inherited(text, document);
Node::reflect_node(~node, document, CommentBinding::Wrap) Node::reflect_node(~node, document, CommentBinding::Wrap)
} }
pub fn Constructor(owner: &JS<Window>, data: DOMString) -> Fallible<JS<Comment>> { pub fn Constructor(owner: &JSRef<Window>, data: DOMString) -> Fallible<Temporary<Comment>> {
Ok(Comment::new(data, &owner.get().Document())) let document = owner.Document().root();
Ok(Comment::new(data, &*document))
} }
} }
pub trait CommentMethods {
}

View file

@ -3,7 +3,7 @@
* 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::codegen::BindingDeclarations::ConsoleBinding; use dom::bindings::codegen::BindingDeclarations::ConsoleBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::window::Window; use dom::window::Window;
use servo_util::str::DOMString; use servo_util::str::DOMString;
@ -20,27 +20,37 @@ impl Console {
} }
} }
pub fn new(window: &JS<Window>) -> JS<Console> { pub fn new(window: &JSRef<Window>) -> Temporary<Console> {
reflect_dom_object(~Console::new_inherited(), window, ConsoleBinding::Wrap) reflect_dom_object(~Console::new_inherited(), window, ConsoleBinding::Wrap)
} }
}
pub fn Log(&self, message: DOMString) { pub trait ConsoleMethods {
fn Log(&self, message: DOMString);
fn Debug(&self, message: DOMString);
fn Info(&self, message: DOMString);
fn Warn(&self, message: DOMString);
fn Error(&self, message: DOMString);
}
impl<'a> ConsoleMethods for JSRef<'a, Console> {
fn Log(&self, message: DOMString) {
println!("{:s}", message); println!("{:s}", message);
} }
pub fn Debug(&self, message: DOMString) { fn Debug(&self, message: DOMString) {
println!("{:s}", message); println!("{:s}", message);
} }
pub fn Info(&self, message: DOMString) { fn Info(&self, message: DOMString) {
println!("{:s}", message); println!("{:s}", message);
} }
pub fn Warn(&self, message: DOMString) { fn Warn(&self, message: DOMString) {
println!("{:s}", message); println!("{:s}", message);
} }
pub fn Error(&self, message: DOMString) { fn Error(&self, message: DOMString) {
println!("{:s}", message); println!("{:s}", message);
} }
} }

View file

@ -3,11 +3,11 @@
* 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::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast};
use dom::bindings::codegen::InheritTypes::{DocumentBase, NodeCast, DocumentCast};
use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, TextCast, ElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, TextCast, ElementCast};
use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast}; use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast};
use dom::bindings::codegen::BindingDeclarations::DocumentBinding; use dom::bindings::codegen::BindingDeclarations::DocumentBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary, OptionalSettable, TemporaryPushable};
use dom::bindings::js::OptionalRootable;
use dom::bindings::trace::Untraceable; use dom::bindings::trace::Untraceable;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter, HierarchyRequest, NamespaceError}; use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter, HierarchyRequest, NamespaceError};
@ -22,18 +22,18 @@ use dom::element::{HTMLBodyElementTypeId, HTMLFrameSetElementTypeId};
use dom::event::Event; use dom::event::Event;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlcollection::{HTMLCollection, CollectionFilter}; use dom::htmlcollection::{HTMLCollection, CollectionFilter};
use dom::nodelist::NodeList;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::htmlheadelement::HTMLHeadElement; use dom::htmlheadelement::HTMLHeadElement;
use dom::htmlhtmlelement::HTMLHtmlElement; use dom::htmlhtmlelement::HTMLHtmlElement;
use dom::htmltitleelement::HTMLTitleElement; use dom::htmltitleelement::HTMLTitleElement;
use dom::mouseevent::MouseEvent; use dom::mouseevent::MouseEvent;
use dom::node::{Node, ElementNodeTypeId, DocumentNodeTypeId, NodeHelpers, INode}; use dom::node::{Node, ElementNodeTypeId, DocumentNodeTypeId, NodeHelpers, NodeMethods};
use dom::node::{CloneChildren, DoNotCloneChildren}; use dom::node::{CloneChildren, DoNotCloneChildren};
use dom::nodelist::NodeList;
use dom::text::Text; use dom::text::Text;
use dom::processinginstruction::ProcessingInstruction; use dom::processinginstruction::ProcessingInstruction;
use dom::uievent::UIEvent; use dom::uievent::UIEvent;
use dom::window::Window; use dom::window::{Window, WindowMethods};
use dom::location::Location; use dom::location::Location;
use html::hubbub_html_parser::build_element_from_tag; use html::hubbub_html_parser::build_element_from_tag;
use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks}; use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks};
@ -76,23 +76,127 @@ impl DocumentDerived for EventTarget {
} }
} }
impl Document { pub trait DocumentHelpers {
pub fn reflect_document<D: Reflectable+DocumentBase> fn url<'a>(&'a self) -> &'a Url;
(document: ~D, fn quirks_mode(&self) -> QuirksMode;
window: &JS<Window>, fn set_quirks_mode(&mut self, mode: QuirksMode);
wrap_fn: extern "Rust" fn(*JSContext, &JS<Window>, ~D) -> JS<D>) fn set_encoding_name(&mut self, name: DOMString);
-> JS<D> { fn content_changed(&self);
assert!(document.reflector().get_jsobject().is_null()); fn damage_and_reflow(&self, damage: DocumentDamageLevel);
let raw_doc = reflect_dom_object(document, window, wrap_fn); fn wait_until_safe_to_modify_dom(&self);
assert!(raw_doc.reflector().get_jsobject().is_not_null()); fn unregister_named_element(&mut self, to_unregister: &JSRef<Element>, id: DOMString);
fn register_named_element(&mut self, element: &JSRef<Element>, id: DOMString);
}
let document = DocumentCast::from(&raw_doc); impl<'a> DocumentHelpers for JSRef<'a, Document> {
let mut node: JS<Node> = NodeCast::from(&document); fn url<'a>(&'a self) -> &'a Url {
node.get_mut().set_owner_doc(&document); &*self.url
raw_doc
} }
pub fn new_inherited(window: JS<Window>, fn quirks_mode(&self) -> QuirksMode {
*self.quirks_mode
}
fn set_quirks_mode(&mut self, mode: QuirksMode) {
*self.quirks_mode = mode;
}
fn set_encoding_name(&mut self, name: DOMString) {
self.encoding_name = name;
}
fn content_changed(&self) {
self.damage_and_reflow(ContentChangedDocumentDamage);
}
fn damage_and_reflow(&self, damage: DocumentDamageLevel) {
self.window.root().damage_and_reflow(damage);
}
fn wait_until_safe_to_modify_dom(&self) {
self.window.root().wait_until_safe_to_modify_dom();
}
/// Remove any existing association between the provided id and any elements in this document.
fn unregister_named_element(&mut self,
to_unregister: &JSRef<Element>,
id: DOMString) {
let mut is_empty = false;
match self.idmap.find_mut(&id) {
None => {},
Some(elements) => {
let position = elements.iter()
.map(|elem| elem.root())
.position(|element| &*element == to_unregister)
.expect("This element should be in registered.");
elements.remove(position);
is_empty = elements.is_empty();
}
}
if is_empty {
self.idmap.remove(&id);
}
}
/// Associate an element present in this document with the provided id.
fn register_named_element(&mut self,
element: &JSRef<Element>,
id: DOMString) {
assert!({
let node: &JSRef<Node> = NodeCast::from_ref(element);
node.is_in_doc()
});
// FIXME https://github.com/mozilla/rust/issues/13195
// Use mangle() when it exists again.
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
match self.idmap.find_mut(&id) {
Some(elements) => {
let new_node: &JSRef<Node> = NodeCast::from_ref(element);
let mut head : uint = 0u;
let root: &JSRef<Node> = NodeCast::from_ref(&*root);
for node in root.traverse_preorder() {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node);
match elem {
Some(elem) => {
if &*elements.get(head).root() == elem {
head = head + 1;
}
if new_node == &node || head == elements.len() {
break;
}
}
None => {}
}
}
elements.insert_unrooted(head, element);
return;
},
None => (),
}
let mut elements = vec!();
elements.push_unrooted(element);
self.idmap.insert(id, elements);
}
}
impl Document {
pub fn reflect_document(document: ~Document,
window: &JSRef<Window>,
wrap_fn: extern "Rust" fn(*JSContext, &JSRef<Window>, ~Document) -> JS<Document>)
-> Temporary<Document> {
assert!(document.reflector().get_jsobject().is_null());
let mut raw_doc = reflect_dom_object(document, window, wrap_fn).root();
assert!(raw_doc.reflector().get_jsobject().is_not_null());
let mut doc_alias = raw_doc.clone();
let node: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut doc_alias);
node.set_owner_doc(&*raw_doc);
Temporary::from_rooted(&*raw_doc)
}
pub fn new_inherited(window: &JSRef<Window>,
url: Option<Url>, url: Option<Url>,
is_html_document: IsHTMLDocument, is_html_document: IsHTMLDocument,
content_type: Option<DOMString>) -> Document { content_type: Option<DOMString>) -> Document {
@ -101,7 +205,7 @@ impl Document {
Document { Document {
node: Node::new_without_doc(DocumentNodeTypeId), node: Node::new_without_doc(DocumentNodeTypeId),
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: window, window: window.unrooted(),
idmap: HashMap::new(), idmap: HashMap::new(),
implementation: None, implementation: None,
content_type: match content_type { content_type: match content_type {
@ -122,23 +226,15 @@ impl Document {
} }
} }
pub fn new(window: &JS<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> JS<Document> {
let document = Document::new_inherited(window.clone(), url, doctype, content_type);
Document::reflect_document(~document, window, DocumentBinding::Wrap)
}
}
impl Document {
pub fn url<'a>(&'a self) -> &'a Url {
&*self.url
}
}
impl Document {
// http://dom.spec.whatwg.org/#dom-document // http://dom.spec.whatwg.org/#dom-document
pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<Document>> { pub fn Constructor(owner: &JSRef<Window>) -> Fallible<Temporary<Document>> {
Ok(Document::new(owner, None, NonHTMLDocument, None)) Ok(Document::new(owner, None, NonHTMLDocument, None))
} }
pub fn new(window: &JSRef<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> Temporary<Document> {
let document = Document::new_inherited(window, url, doctype, content_type);
Document::reflect_document(~document, window, DocumentBinding::Wrap)
}
} }
impl Reflectable for Document { impl Reflectable for Document {
@ -151,108 +247,183 @@ impl Reflectable for Document {
} }
} }
impl Document { trait PrivateDocumentHelpers {
// http://dom.spec.whatwg.org/#dom-document-implementation fn createNodeList(&self, callback: |node: &JSRef<Node>| -> bool) -> Temporary<NodeList>;
pub fn Implementation(&mut self) -> JS<DOMImplementation> { fn get_html_element(&self) -> Option<Temporary<HTMLHtmlElement>>;
if self.implementation.is_none() { }
self.implementation = Some(DOMImplementation::new(&self.window));
impl<'a> PrivateDocumentHelpers for JSRef<'a, Document> {
fn createNodeList(&self, callback: |node: &JSRef<Node>| -> bool) -> Temporary<NodeList> {
let window = self.window.root();
match self.GetDocumentElement().root() {
None => {
NodeList::new_simple_list(&*window, vec!())
},
Some(root) => {
let mut nodes = vec!();
let root: &JSRef<Node> = NodeCast::from_ref(&*root);
for child in root.traverse_preorder() {
if callback(&child) {
nodes.push(child);
}
}
NodeList::new_simple_list(&*window, nodes)
}
} }
self.implementation.get_ref().clone()
}
fn get_html_element(&self) -> Option<Temporary<HTMLHtmlElement>> {
self.GetDocumentElement().root().filtered(|root| {
root.node.type_id == ElementNodeTypeId(HTMLHtmlElementTypeId)
}).map(|elem| {
Temporary::from_rooted(HTMLHtmlElementCast::to_ref(&*elem).unwrap())
})
}
}
pub trait DocumentMethods {
fn Implementation(&mut self) -> Temporary<DOMImplementation>;
fn URL(&self) -> DOMString;
fn DocumentURI(&self) -> DOMString;
fn CompatMode(&self) -> DOMString;
fn CharacterSet(&self) -> DOMString;
fn ContentType(&self) -> DOMString;
fn GetDoctype(&self) -> Option<Temporary<DocumentType>>;
fn GetDocumentElement(&self) -> Option<Temporary<Element>>;
fn GetElementsByTagName(&self, tag_name: DOMString) -> Temporary<HTMLCollection>;
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, tag_name: DOMString) -> Temporary<HTMLCollection>;
fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection>;
fn GetElementById(&self, id: DOMString) -> Option<Temporary<Element>>;
fn CreateElement(&self, local_name: DOMString) -> Fallible<Temporary<Element>>;
fn CreateElementNS(&self, namespace: Option<DOMString>, qualified_name: DOMString) -> Fallible<Temporary<Element>>;
fn CreateDocumentFragment(&self) -> Temporary<DocumentFragment>;
fn CreateTextNode(&self, data: DOMString) -> Temporary<Text>;
fn CreateComment(&self, data: DOMString) -> Temporary<Comment>;
fn CreateProcessingInstruction(&self, target: DOMString, data: DOMString) -> Fallible<Temporary<ProcessingInstruction>>;
fn ImportNode(&self, node: &JSRef<Node>, deep: bool) -> Fallible<Temporary<Node>>;
fn AdoptNode(&self, node: &mut JSRef<Node>) -> Fallible<Temporary<Node>>;
fn CreateEvent(&self, interface: DOMString) -> Fallible<Temporary<Event>>;
fn Title(&self) -> DOMString;
fn SetTitle(&self, title: DOMString) -> ErrorResult;
fn GetHead(&self) -> Option<Temporary<HTMLHeadElement>>;
fn GetBody(&self) -> Option<Temporary<HTMLElement>>;
fn SetBody(&self, new_body: Option<JSRef<HTMLElement>>) -> ErrorResult;
fn GetElementsByName(&self, name: DOMString) -> Temporary<NodeList>;
fn Images(&self) -> Temporary<HTMLCollection>;
fn Embeds(&self) -> Temporary<HTMLCollection>;
fn Plugins(&self) -> Temporary<HTMLCollection>;
fn Links(&self) -> Temporary<HTMLCollection>;
fn Forms(&self) -> Temporary<HTMLCollection>;
fn Scripts(&self) -> Temporary<HTMLCollection>;
fn Anchors(&self) -> Temporary<HTMLCollection>;
fn Applets(&self) -> Temporary<HTMLCollection>;
fn Location(&mut self) -> Temporary<Location>;
fn Children(&self) -> Temporary<HTMLCollection>;
}
impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-implementation
fn Implementation(&mut self) -> Temporary<DOMImplementation> {
if self.implementation.is_none() {
let window = self.window.root();
self.implementation.assign(Some(DOMImplementation::new(&*window)));
}
Temporary::new(self.implementation.get_ref().clone())
} }
// http://dom.spec.whatwg.org/#dom-document-url // http://dom.spec.whatwg.org/#dom-document-url
pub fn URL(&self) -> DOMString { fn URL(&self) -> DOMString {
self.url().to_str() self.url().to_str()
} }
// http://dom.spec.whatwg.org/#dom-document-documenturi // http://dom.spec.whatwg.org/#dom-document-documenturi
pub fn DocumentURI(&self) -> DOMString { fn DocumentURI(&self) -> DOMString {
self.URL() self.URL()
} }
// http://dom.spec.whatwg.org/#dom-document-compatmode // http://dom.spec.whatwg.org/#dom-document-compatmode
pub fn CompatMode(&self) -> DOMString { fn CompatMode(&self) -> DOMString {
match *self.quirks_mode { match *self.quirks_mode {
NoQuirks => ~"CSS1Compat", NoQuirks => ~"CSS1Compat",
LimitedQuirks | FullQuirks => ~"BackCompat" LimitedQuirks | FullQuirks => ~"BackCompat"
} }
} }
pub fn quirks_mode(&self) -> QuirksMode {
*self.quirks_mode
}
pub fn set_quirks_mode(&mut self, mode: QuirksMode) {
*self.quirks_mode = mode;
}
// http://dom.spec.whatwg.org/#dom-document-characterset // http://dom.spec.whatwg.org/#dom-document-characterset
pub fn CharacterSet(&self) -> DOMString { fn CharacterSet(&self) -> DOMString {
self.encoding_name.to_ascii_lower() self.encoding_name.to_ascii_lower()
} }
pub fn set_encoding_name(&mut self, name: DOMString) {
self.encoding_name = name;
}
// http://dom.spec.whatwg.org/#dom-document-content_type // http://dom.spec.whatwg.org/#dom-document-content_type
pub fn ContentType(&self) -> DOMString { fn ContentType(&self) -> DOMString {
self.content_type.clone() self.content_type.clone()
} }
// http://dom.spec.whatwg.org/#dom-document-doctype // http://dom.spec.whatwg.org/#dom-document-doctype
pub fn GetDoctype(&self) -> Option<JS<DocumentType>> { fn GetDoctype(&self) -> Option<Temporary<DocumentType>> {
self.node.children().find(|child| child.is_doctype()) let node: &JSRef<Node> = NodeCast::from_ref(self);
.map(|node| DocumentTypeCast::to(&node).unwrap()) node.children().find(|child| {
child.is_doctype()
}).map(|node| {
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(&node).unwrap();
Temporary::from_rooted(doctype)
})
} }
// http://dom.spec.whatwg.org/#dom-document-documentelement // http://dom.spec.whatwg.org/#dom-document-documentelement
pub fn GetDocumentElement(&self) -> Option<JS<Element>> { fn GetDocumentElement(&self) -> Option<Temporary<Element>> {
self.node.child_elements().next() let node: &JSRef<Node> = NodeCast::from_ref(self);
node.child_elements().next().map(|elem| Temporary::from_rooted(&elem))
} }
// http://dom.spec.whatwg.org/#dom-document-getelementsbytagname // http://dom.spec.whatwg.org/#dom-document-getelementsbytagname
pub fn GetElementsByTagName(&self, abstract_self: &JS<Document>, tag_name: DOMString) -> JS<HTMLCollection> { fn GetElementsByTagName(&self, tag_name: DOMString) -> Temporary<HTMLCollection> {
HTMLCollection::by_tag_name(&self.window, &NodeCast::from(abstract_self), tag_name) let window = self.window.root();
HTMLCollection::by_tag_name(&*window, NodeCast::from_ref(self), tag_name)
} }
// http://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens // http://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens
pub fn GetElementsByTagNameNS(&self, abstract_self: &JS<Document>, maybe_ns: Option<DOMString>, tag_name: DOMString) -> JS<HTMLCollection> { fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, tag_name: DOMString) -> Temporary<HTMLCollection> {
let window = self.window.root();
let namespace = match maybe_ns { let namespace = match maybe_ns {
Some(namespace) => Namespace::from_str(namespace), Some(namespace) => Namespace::from_str(namespace),
None => Null None => Null
}; };
HTMLCollection::by_tag_name_ns(&self.window, &NodeCast::from(abstract_self), tag_name, namespace) HTMLCollection::by_tag_name_ns(&*window, NodeCast::from_ref(self), tag_name, namespace)
} }
// http://dom.spec.whatwg.org/#dom-document-getelementsbyclassname // http://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
pub fn GetElementsByClassName(&self, abstract_self: &JS<Document>, classes: DOMString) -> JS<HTMLCollection> { fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> {
HTMLCollection::by_class_name(&self.window, &NodeCast::from(abstract_self), classes) let window = self.window.root();
HTMLCollection::by_class_name(&*window, NodeCast::from_ref(self), classes)
} }
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid // http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
pub fn GetElementById(&self, id: DOMString) -> Option<JS<Element>> { fn GetElementById(&self, id: DOMString) -> Option<Temporary<Element>> {
match self.idmap.find_equiv(&id) { match self.idmap.find_equiv(&id) {
None => None, None => None,
Some(ref elements) => Some(elements.get(0).clone()), Some(ref elements) => Some(Temporary::new(elements.get(0).clone())),
} }
} }
// http://dom.spec.whatwg.org/#dom-document-createelement // http://dom.spec.whatwg.org/#dom-document-createelement
pub fn CreateElement(&self, abstract_self: &JS<Document>, local_name: DOMString) fn CreateElement(&self, local_name: DOMString) -> Fallible<Temporary<Element>> {
-> Fallible<JS<Element>> {
if xml_name_type(local_name) == InvalidXMLName { if xml_name_type(local_name) == InvalidXMLName {
debug!("Not a valid element name"); debug!("Not a valid element name");
return Err(InvalidCharacter); return Err(InvalidCharacter);
} }
let local_name = local_name.to_ascii_lower(); let local_name = local_name.to_ascii_lower();
Ok(build_element_from_tag(local_name, abstract_self)) Ok(build_element_from_tag(local_name, self))
} }
// http://dom.spec.whatwg.org/#dom-document-createelementns // http://dom.spec.whatwg.org/#dom-document-createelementns
pub fn CreateElementNS(&self, abstract_self: &JS<Document>, fn CreateElementNS(&self,
namespace: Option<DOMString>, namespace: Option<DOMString>,
qualified_name: DOMString) -> Fallible<JS<Element>> { qualified_name: DOMString) -> Fallible<Temporary<Element>> {
let ns = Namespace::from_str(null_str_as_empty_ref(&namespace)); let ns = Namespace::from_str(null_str_as_empty_ref(&namespace));
match xml_name_type(qualified_name) { match xml_name_type(qualified_name) {
InvalidXMLName => { InvalidXMLName => {
@ -289,31 +460,31 @@ impl Document {
} }
if ns == namespace::HTML { if ns == namespace::HTML {
Ok(build_element_from_tag(local_name_from_qname, abstract_self)) Ok(build_element_from_tag(local_name_from_qname, self))
} else { } else {
Ok(Element::new(local_name_from_qname, ns, prefix_from_qname, abstract_self)) Ok(Element::new(local_name_from_qname, ns, prefix_from_qname, self))
} }
} }
// http://dom.spec.whatwg.org/#dom-document-createdocumentfragment // http://dom.spec.whatwg.org/#dom-document-createdocumentfragment
pub fn CreateDocumentFragment(&self, abstract_self: &JS<Document>) -> JS<DocumentFragment> { fn CreateDocumentFragment(&self) -> Temporary<DocumentFragment> {
DocumentFragment::new(abstract_self) DocumentFragment::new(self)
} }
// http://dom.spec.whatwg.org/#dom-document-createtextnode // http://dom.spec.whatwg.org/#dom-document-createtextnode
pub fn CreateTextNode(&self, abstract_self: &JS<Document>, data: DOMString) fn CreateTextNode(&self, data: DOMString)
-> JS<Text> { -> Temporary<Text> {
Text::new(data, abstract_self) Text::new(data, self)
} }
// http://dom.spec.whatwg.org/#dom-document-createcomment // http://dom.spec.whatwg.org/#dom-document-createcomment
pub fn CreateComment(&self, abstract_self: &JS<Document>, data: DOMString) -> JS<Comment> { fn CreateComment(&self, data: DOMString) -> Temporary<Comment> {
Comment::new(data, abstract_self) Comment::new(data, self)
} }
// http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction // http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
pub fn CreateProcessingInstruction(&self, abstract_self: &JS<Document>, target: DOMString, fn CreateProcessingInstruction(&self, target: DOMString,
data: DOMString) -> Fallible<JS<ProcessingInstruction>> { data: DOMString) -> Fallible<Temporary<ProcessingInstruction>> {
// Step 1. // Step 1.
if xml_name_type(target) == InvalidXMLName { if xml_name_type(target) == InvalidXMLName {
return Err(InvalidCharacter); return Err(InvalidCharacter);
@ -325,11 +496,11 @@ impl Document {
} }
// Step 3. // Step 3.
Ok(ProcessingInstruction::new(target, data, abstract_self)) Ok(ProcessingInstruction::new(target, data, self))
} }
// http://dom.spec.whatwg.org/#dom-document-importnode // http://dom.spec.whatwg.org/#dom-document-importnode
pub fn ImportNode(&self, abstract_self: &JS<Document>, node: &JS<Node>, deep: bool) -> Fallible<JS<Node>> { fn ImportNode(&self, node: &JSRef<Node>, deep: bool) -> Fallible<Temporary<Node>> {
// Step 1. // Step 1.
if node.is_document() { if node.is_document() {
return Err(NotSupported); return Err(NotSupported);
@ -341,47 +512,48 @@ impl Document {
false => DoNotCloneChildren false => DoNotCloneChildren
}; };
Ok(Node::clone(node, Some(abstract_self), clone_children)) Ok(Node::clone(node, Some(self), clone_children))
} }
// http://dom.spec.whatwg.org/#dom-document-adoptnode // http://dom.spec.whatwg.org/#dom-document-adoptnode
pub fn AdoptNode(&self, abstract_self: &JS<Document>, node: &JS<Node>) -> Fallible<JS<Node>> { fn AdoptNode(&self, node: &mut JSRef<Node>) -> Fallible<Temporary<Node>> {
// Step 1. // Step 1.
if node.is_document() { if node.is_document() {
return Err(NotSupported); return Err(NotSupported);
} }
// Step 2. // Step 2.
let mut adoptee = node.clone(); Node::adopt(node, self);
Node::adopt(&mut adoptee, abstract_self);
// Step 3. // Step 3.
Ok(adoptee) Ok(Temporary::from_rooted(node))
} }
// http://dom.spec.whatwg.org/#dom-document-createevent // http://dom.spec.whatwg.org/#dom-document-createevent
pub fn CreateEvent(&self, interface: DOMString) -> Fallible<JS<Event>> { fn CreateEvent(&self, interface: DOMString) -> Fallible<Temporary<Event>> {
let window = self.window.root();
match interface.to_ascii_lower().as_slice() { match interface.to_ascii_lower().as_slice() {
// FIXME: Implement CustomEvent (http://dom.spec.whatwg.org/#customevent) // FIXME: Implement CustomEvent (http://dom.spec.whatwg.org/#customevent)
"uievents" | "uievent" => Ok(EventCast::from(&UIEvent::new(&self.window))), "uievents" | "uievent" => Ok(EventCast::from_unrooted(UIEvent::new(&*window))),
"mouseevents" | "mouseevent" => Ok(EventCast::from(&MouseEvent::new(&self.window))), "mouseevents" | "mouseevent" => Ok(EventCast::from_unrooted(MouseEvent::new(&*window))),
"htmlevents" | "events" | "event" => Ok(Event::new(&self.window)), "htmlevents" | "events" | "event" => Ok(Event::new(&*window)),
_ => Err(NotSupported) _ => Err(NotSupported)
} }
} }
// http://www.whatwg.org/specs/web-apps/current-work/#document.title // http://www.whatwg.org/specs/web-apps/current-work/#document.title
pub fn Title(&self, _: &JS<Document>) -> DOMString { fn Title(&self) -> DOMString {
let mut title = ~""; let mut title = ~"";
self.GetDocumentElement().map(|root| { self.GetDocumentElement().root().map(|root| {
let root: JS<Node> = NodeCast::from(&root); let root: &JSRef<Node> = NodeCast::from_ref(&*root);
root.traverse_preorder() root.traverse_preorder()
.find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId)) .find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId))
.map(|title_elem| { .map(|title_elem| {
for child in title_elem.children() { for child in title_elem.children() {
if child.is_text() { if child.is_text() {
let text: JS<Text> = TextCast::to(&child).unwrap(); let text: &JSRef<Text> = TextCast::to_ref(&child).unwrap();
title.push_str(text.get().characterdata.data.as_slice()); title.push_str(text.deref().characterdata.data.as_slice());
} }
} }
}); });
@ -392,15 +564,15 @@ impl Document {
} }
// http://www.whatwg.org/specs/web-apps/current-work/#document.title // http://www.whatwg.org/specs/web-apps/current-work/#document.title
pub fn SetTitle(&self, abstract_self: &JS<Document>, title: DOMString) -> ErrorResult { fn SetTitle(&self, title: DOMString) -> ErrorResult {
self.GetDocumentElement().map(|root| { self.GetDocumentElement().root().map(|root| {
let root: JS<Node> = NodeCast::from(&root); let root: &JSRef<Node> = NodeCast::from_ref(&*root);
let mut head_node = root.traverse_preorder().find(|child| { let mut head_node = root.traverse_preorder().find(|child| {
child.get().type_id == ElementNodeTypeId(HTMLHeadElementTypeId) child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
}); });
head_node.as_mut().map(|head| { head_node.as_mut().map(|head| {
let mut title_node = head.children().find(|child| { let mut title_node = head.children().find(|child| {
child.get().type_id == ElementNodeTypeId(HTMLTitleElementTypeId) child.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId)
}); });
match title_node { match title_node {
@ -408,15 +580,18 @@ impl Document {
for mut title_child in title_node.children() { for mut title_child in title_node.children() {
assert!(title_node.RemoveChild(&mut title_child).is_ok()); assert!(title_node.RemoveChild(&mut title_child).is_ok());
} }
let new_text = self.CreateTextNode(abstract_self, title.clone()); let mut new_text = self.CreateTextNode(title.clone()).root();
assert!(title_node.AppendChild(&mut NodeCast::from(&new_text)).is_ok());
assert!(title_node.AppendChild(NodeCast::from_mut_ref(&mut *new_text)).is_ok());
}, },
None => { None => {
let mut new_title: JS<Node> = let mut new_title = HTMLTitleElement::new(~"title", self).root();
NodeCast::from(&HTMLTitleElement::new(~"title", abstract_self)); let new_title: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut *new_title);
let new_text = self.CreateTextNode(abstract_self, title.clone());
assert!(new_title.AppendChild(&mut NodeCast::from(&new_text)).is_ok()); let mut new_text = self.CreateTextNode(title.clone()).root();
assert!(head.AppendChild(&mut new_title).is_ok());
assert!(new_title.AppendChild(NodeCast::from_mut_ref(&mut *new_text)).is_ok());
assert!(head.AppendChild(&mut *new_title).is_ok());
}, },
} }
}); });
@ -424,42 +599,43 @@ impl Document {
Ok(()) Ok(())
} }
fn get_html_element(&self) -> Option<JS<HTMLHtmlElement>> {
self.GetDocumentElement().filtered(|root| {
root.get().node.type_id == ElementNodeTypeId(HTMLHtmlElementTypeId)
}).map(|elem| HTMLHtmlElementCast::to(&elem).unwrap())
}
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head
pub fn GetHead(&self) -> Option<JS<HTMLHeadElement>> { fn GetHead(&self) -> Option<Temporary<HTMLHeadElement>> {
self.get_html_element().and_then(|root| { self.get_html_element().and_then(|root| {
let node: JS<Node> = NodeCast::from(&root); let root = root.root();
let node: &JSRef<Node> = NodeCast::from_ref(&*root);
node.children().find(|child| { node.children().find(|child| {
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
}).map(|node| HTMLHeadElementCast::to(&node).unwrap()) }).map(|node| {
Temporary::from_rooted(HTMLHeadElementCast::to_ref(&node).unwrap())
})
}) })
} }
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body
pub fn GetBody(&self, _: &JS<Document>) -> Option<JS<HTMLElement>> { fn GetBody(&self) -> Option<Temporary<HTMLElement>> {
self.get_html_element().and_then(|root| { self.get_html_element().and_then(|root| {
let node: JS<Node> = NodeCast::from(&root); let root = root.root();
let node: &JSRef<Node> = NodeCast::from_ref(&*root);
node.children().find(|child| { node.children().find(|child| {
match child.type_id() { match child.type_id() {
ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLBodyElementTypeId) |
ElementNodeTypeId(HTMLFrameSetElementTypeId) => true, ElementNodeTypeId(HTMLFrameSetElementTypeId) => true,
_ => false _ => false
} }
}).map(|node| HTMLElementCast::to(&node).unwrap()) }).map(|node| {
Temporary::from_rooted(HTMLElementCast::to_ref(&node).unwrap())
})
}) })
} }
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body
pub fn SetBody(&self, abstract_self: &JS<Document>, new_body: Option<JS<HTMLElement>>) -> ErrorResult { fn SetBody(&self, new_body: Option<JSRef<HTMLElement>>) -> ErrorResult {
// Step 1. // Step 1.
match new_body { match new_body {
Some(ref node) => { Some(ref htmlelem) => {
match node.get().element.node.type_id { let node: &JSRef<Node> = NodeCast::from_ref(htmlelem);
match node.type_id() {
ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLFrameSetElementTypeId) => {} ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLFrameSetElementTypeId) => {}
_ => return Err(HierarchyRequest) _ => return Err(HierarchyRequest)
} }
@ -468,24 +644,28 @@ impl Document {
} }
// Step 2. // Step 2.
let old_body: Option<JS<HTMLElement>> = self.GetBody(abstract_self); let mut old_body = self.GetBody().root();
if old_body == new_body { //FIXME: covariant lifetime workaround. do not judge.
if old_body.as_ref().map(|body| body.deref()) == new_body.as_ref().map(|a| &*a) {
return Ok(()); return Ok(());
} }
// Step 3. // Step 3.
match self.get_html_element() { match self.get_html_element().root() {
// Step 4. // Step 4.
None => return Err(HierarchyRequest), None => return Err(HierarchyRequest),
Some(root) => { Some(ref mut root) => {
let mut new_body: JS<Node> = NodeCast::from(&new_body.unwrap()); let mut new_body_unwrapped = new_body.unwrap();
let mut root: JS<Node> = NodeCast::from(&root); let new_body: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut new_body_unwrapped);
let root: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut **root);
match old_body { match old_body {
Some(child) => { Some(ref mut child) => {
let mut child: JS<Node> = NodeCast::from(&child); let child: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut **child);
assert!(root.ReplaceChild(&mut new_body, &mut child).is_ok())
assert!(root.ReplaceChild(new_body, child).is_ok())
} }
None => assert!(root.AppendChild(&mut new_body).is_ok()) None => assert!(root.AppendChild(new_body).is_ok())
}; };
} }
} }
@ -493,204 +673,130 @@ impl Document {
} }
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyname // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyname
pub fn GetElementsByName(&self, name: DOMString) -> JS<NodeList> { fn GetElementsByName(&self, name: DOMString) -> Temporary<NodeList> {
self.createNodeList(|node| { self.createNodeList(|node| {
if !node.is_element() { if !node.is_element() {
return false; return false;
} }
let element: JS<Element> = ElementCast::to(node).unwrap(); let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
element.get_attribute(Null, "name").map_or(false, |attr| { element.get_attribute(Null, "name").root().map_or(false, |mut attr| {
attr.get().value_ref() == name attr.value_ref() == name
}) })
}) })
} }
pub fn Images(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Images(&self) -> Temporary<HTMLCollection> {
let window = self.window.root();
// FIXME: https://github.com/mozilla/servo/issues/1847 // FIXME: https://github.com/mozilla/servo/issues/1847
struct ImagesFilter; struct ImagesFilter;
impl CollectionFilter for ImagesFilter { impl CollectionFilter for ImagesFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == ~"img" elem.deref().local_name == ~"img"
} }
} }
let filter = ~ImagesFilter; let filter = ~ImagesFilter;
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) HTMLCollection::create(&*window, NodeCast::from_ref(self), filter)
} }
pub fn Embeds(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Embeds(&self) -> Temporary<HTMLCollection> {
let window = self.window.root();
// FIXME: https://github.com/mozilla/servo/issues/1847 // FIXME: https://github.com/mozilla/servo/issues/1847
struct EmbedsFilter; struct EmbedsFilter;
impl CollectionFilter for EmbedsFilter { impl CollectionFilter for EmbedsFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == ~"embed" elem.deref().local_name == ~"embed"
} }
} }
let filter = ~EmbedsFilter; let filter = ~EmbedsFilter;
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) HTMLCollection::create(&*window, NodeCast::from_ref(self), filter)
} }
pub fn Plugins(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Plugins(&self) -> Temporary<HTMLCollection> {
// FIXME: https://github.com/mozilla/servo/issues/1847 // FIXME: https://github.com/mozilla/servo/issues/1847
self.Embeds(abstract_self) self.Embeds()
} }
pub fn Links(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Links(&self) -> Temporary<HTMLCollection> {
let window = self.window.root();
// FIXME: https://github.com/mozilla/servo/issues/1847 // FIXME: https://github.com/mozilla/servo/issues/1847
struct LinksFilter; struct LinksFilter;
impl CollectionFilter for LinksFilter { impl CollectionFilter for LinksFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
(elem.get().local_name == ~"a" || elem.get().local_name == ~"area") && (elem.deref().local_name == ~"a" || elem.deref().local_name == ~"area") &&
elem.get_attribute(Null, "href").is_some() elem.get_attribute(Null, "href").is_some()
} }
} }
let filter = ~LinksFilter; let filter = ~LinksFilter;
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) HTMLCollection::create(&*window, NodeCast::from_ref(self), filter)
} }
pub fn Forms(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Forms(&self) -> Temporary<HTMLCollection> {
let window = self.window.root();
// FIXME: https://github.com/mozilla/servo/issues/1847 // FIXME: https://github.com/mozilla/servo/issues/1847
struct FormsFilter; struct FormsFilter;
impl CollectionFilter for FormsFilter { impl CollectionFilter for FormsFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == ~"form" elem.deref().local_name == ~"form"
} }
} }
let filter = ~FormsFilter; let filter = ~FormsFilter;
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) HTMLCollection::create(&*window, NodeCast::from_ref(self), filter)
} }
pub fn Scripts(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Scripts(&self) -> Temporary<HTMLCollection> {
let window = self.window.root();
// FIXME: https://github.com/mozilla/servo/issues/1847 // FIXME: https://github.com/mozilla/servo/issues/1847
struct ScriptsFilter; struct ScriptsFilter;
impl CollectionFilter for ScriptsFilter { impl CollectionFilter for ScriptsFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == ~"script" elem.deref().local_name == ~"script"
} }
} }
let filter = ~ScriptsFilter; let filter = ~ScriptsFilter;
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) HTMLCollection::create(&*window, NodeCast::from_ref(self), filter)
} }
pub fn Anchors(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Anchors(&self) -> Temporary<HTMLCollection> {
let window = self.window.root();
// FIXME: https://github.com/mozilla/servo/issues/1847 // FIXME: https://github.com/mozilla/servo/issues/1847
struct AnchorsFilter; struct AnchorsFilter;
impl CollectionFilter for AnchorsFilter { impl CollectionFilter for AnchorsFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == ~"a" && elem.get_attribute(Null, "name").is_some() elem.deref().local_name == ~"a" && elem.get_attribute(Null, "name").is_some()
} }
} }
let filter = ~AnchorsFilter; let filter = ~AnchorsFilter;
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) HTMLCollection::create(&*window, NodeCast::from_ref(self), filter)
} }
pub fn Applets(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Applets(&self) -> Temporary<HTMLCollection> {
let window = self.window.root();
// FIXME: This should be return OBJECT elements containing applets. // FIXME: This should be return OBJECT elements containing applets.
struct AppletsFilter; struct AppletsFilter;
impl CollectionFilter for AppletsFilter { impl CollectionFilter for AppletsFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == ~"applet" elem.deref().local_name == ~"applet"
} }
} }
let filter = ~AppletsFilter; let filter = ~AppletsFilter;
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) HTMLCollection::create(&*window, NodeCast::from_ref(self), filter)
} }
pub fn Location(&mut self, abstract_self: &JS<Document>) -> JS<Location> { fn Location(&mut self) -> Temporary<Location> {
self.window.get_mut().Location(&abstract_self.get().window) let mut window = self.window.root();
window.Location()
} }
pub fn Children(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> { fn Children(&self) -> Temporary<HTMLCollection> {
let doc = self.node.owner_doc(); let window = self.window.root();
let doc = doc.get(); HTMLCollection::children(&*window, NodeCast::from_ref(self))
HTMLCollection::children(&doc.window, &NodeCast::from(abstract_self))
}
pub fn createNodeList(&self, callback: |node: &JS<Node>| -> bool) -> JS<NodeList> {
let mut nodes = vec!();
match self.GetDocumentElement() {
None => {},
Some(root) => {
let root: JS<Node> = NodeCast::from(&root);
for child in root.traverse_preorder() {
if callback(&child) {
nodes.push(child.clone());
}
}
}
}
NodeList::new_simple_list(&self.window, nodes)
}
pub fn content_changed(&self) {
self.damage_and_reflow(ContentChangedDocumentDamage);
}
pub fn damage_and_reflow(&self, damage: DocumentDamageLevel) {
self.window.get().damage_and_reflow(damage);
}
pub fn wait_until_safe_to_modify_dom(&self) {
self.window.get().wait_until_safe_to_modify_dom();
}
/// Remove any existing association between the provided id and any elements in this document.
pub fn unregister_named_element(&mut self,
abstract_self: &JS<Element>,
id: DOMString) {
let mut is_empty = false;
match self.idmap.find_mut(&id) {
None => {},
Some(elements) => {
let position = elements.iter()
.position(|element| element == abstract_self)
.expect("This element should be in registered.");
elements.remove(position);
is_empty = elements.is_empty();
}
}
if is_empty {
self.idmap.remove(&id);
}
}
/// Associate an element present in this document with the provided id.
pub fn register_named_element(&mut self,
element: &JS<Element>,
id: DOMString) {
assert!({
let node: JS<Node> = NodeCast::from(element);
node.is_in_doc()
});
// FIXME https://github.com/mozilla/rust/issues/13195
// Use mangle() when it exists again.
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.");
match self.idmap.find_mut(&id) {
Some(elements) => {
let new_node = NodeCast::from(element);
let mut head : uint = 0u;
let root: JS<Node> = NodeCast::from(&root);
for node in root.traverse_preorder() {
match ElementCast::to(&node) {
Some(elem) => {
if elements.get(head) == &elem {
head = head + 1;
}
if new_node == node || head == elements.len() {
break;
}
}
None => {}
}
}
elements.insert(head, element.clone());
return;
},
None => (),
}
self.idmap.insert(id, vec!(element.clone()));
} }
} }

View file

@ -4,13 +4,13 @@
use dom::bindings::codegen::InheritTypes::{DocumentFragmentDerived, NodeCast}; use dom::bindings::codegen::InheritTypes::{DocumentFragmentDerived, NodeCast};
use dom::bindings::codegen::BindingDeclarations::DocumentFragmentBinding; use dom::bindings::codegen::BindingDeclarations::DocumentFragmentBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::document::Document; use dom::document::Document;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::node::{DocumentFragmentNodeTypeId, Node}; use dom::node::{DocumentFragmentNodeTypeId, Node, window_from_node};
use dom::window::Window; use dom::window::{Window, WindowMethods};
#[deriving(Encodable)] #[deriving(Encodable)]
pub struct DocumentFragment { pub struct DocumentFragment {
@ -28,28 +28,32 @@ impl DocumentFragmentDerived for EventTarget {
impl DocumentFragment { impl DocumentFragment {
/// Creates a new DocumentFragment. /// Creates a new DocumentFragment.
pub fn new_inherited(document: JS<Document>) -> DocumentFragment { pub fn new_inherited(document: &JSRef<Document>) -> DocumentFragment {
DocumentFragment { DocumentFragment {
node: Node::new_inherited(DocumentFragmentNodeTypeId, document), node: Node::new_inherited(DocumentFragmentNodeTypeId, document),
} }
} }
pub fn new(document: &JS<Document>) -> JS<DocumentFragment> { pub fn new(document: &JSRef<Document>) -> Temporary<DocumentFragment> {
let node = DocumentFragment::new_inherited(document.clone()); let node = DocumentFragment::new_inherited(document);
Node::reflect_node(~node, document, DocumentFragmentBinding::Wrap) Node::reflect_node(~node, document, DocumentFragmentBinding::Wrap)
} }
}
impl DocumentFragment { pub fn Constructor(owner: &JSRef<Window>) -> Fallible<Temporary<DocumentFragment>> {
pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<DocumentFragment>> { let document = owner.Document();
Ok(DocumentFragment::new(&owner.get().Document())) let document = document.root();
Ok(DocumentFragment::new(&document.root_ref()))
} }
} }
impl DocumentFragment { pub trait DocumentFragmentMethods {
pub fn Children(&self, abstract_self: &JS<DocumentFragment>) -> JS<HTMLCollection> { fn Children(&self) -> Temporary<HTMLCollection>;
let doc = self.node.owner_doc(); }
let doc = doc.get();
HTMLCollection::children(&doc.window, &NodeCast::from(abstract_self)) impl<'a> DocumentFragmentMethods for JSRef<'a, DocumentFragment> {
fn Children(&self) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root();
HTMLCollection::children(&window.root_ref(), NodeCast::from_ref(self))
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::InheritTypes::DocumentTypeDerived; use dom::bindings::codegen::InheritTypes::DocumentTypeDerived;
use dom::bindings::codegen::BindingDeclarations::DocumentTypeBinding; use dom::bindings::codegen::BindingDeclarations::DocumentTypeBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::node::{Node, DoctypeNodeTypeId}; use dom::node::{Node, DoctypeNodeTypeId};
@ -32,7 +32,7 @@ impl DocumentType {
pub fn new_inherited(name: DOMString, pub fn new_inherited(name: DOMString,
public_id: Option<DOMString>, public_id: Option<DOMString>,
system_id: Option<DOMString>, system_id: Option<DOMString>,
document: JS<Document>) document: &JSRef<Document>)
-> DocumentType { -> DocumentType {
DocumentType { DocumentType {
node: Node::new_inherited(DoctypeNodeTypeId, document), node: Node::new_inherited(DoctypeNodeTypeId, document),
@ -45,26 +45,32 @@ impl DocumentType {
pub fn new(name: DOMString, pub fn new(name: DOMString,
public_id: Option<DOMString>, public_id: Option<DOMString>,
system_id: Option<DOMString>, system_id: Option<DOMString>,
document: &JS<Document>) document: &JSRef<Document>)
-> JS<DocumentType> { -> Temporary<DocumentType> {
let documenttype = DocumentType::new_inherited(name, let documenttype = DocumentType::new_inherited(name,
public_id, public_id,
system_id, system_id,
document.clone()); document);
Node::reflect_node(~documenttype, document, DocumentTypeBinding::Wrap) Node::reflect_node(~documenttype, document, DocumentTypeBinding::Wrap)
} }
} }
impl DocumentType { pub trait DocumentTypeMethods {
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString;
fn PublicId(&self) -> DOMString;
fn SystemId(&self) -> DOMString;
}
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
fn Name(&self) -> DOMString {
self.name.clone() self.name.clone()
} }
pub fn PublicId(&self) -> DOMString { fn PublicId(&self) -> DOMString {
self.public_id.clone() self.public_id.clone()
} }
pub fn SystemId(&self) -> DOMString { fn SystemId(&self) -> DOMString {
self.system_id.clone() self.system_id.clone()
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::DOMExceptionBinding; use dom::bindings::codegen::BindingDeclarations::DOMExceptionBinding;
use dom::bindings::codegen::BindingDeclarations::DOMExceptionBinding::DOMExceptionConstants; use dom::bindings::codegen::BindingDeclarations::DOMExceptionBinding::DOMExceptionConstants;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::window::Window; use dom::window::Window;
use servo_util::str::DOMString; use servo_util::str::DOMString;
@ -49,7 +49,7 @@ impl DOMException {
} }
} }
pub fn new(window: &JS<Window>, code: DOMErrorName) -> JS<DOMException> { pub fn new(window: &JSRef<Window>, code: DOMErrorName) -> Temporary<DOMException> {
reflect_dom_object(~DOMException::new_inherited(code), window, DOMExceptionBinding::Wrap) reflect_dom_object(~DOMException::new_inherited(code), window, DOMExceptionBinding::Wrap)
} }
} }
@ -64,9 +64,15 @@ impl Reflectable for DOMException {
} }
} }
impl DOMException { pub trait DOMExceptionMethods {
fn Code(&self) -> u16;
fn Name(&self) -> DOMString;
fn Message(&self) -> DOMString;
}
impl<'a> DOMExceptionMethods for JSRef<'a, DOMException> {
// http://dom.spec.whatwg.org/#dom-domexception-code // http://dom.spec.whatwg.org/#dom-domexception-code
pub fn Code(&self) -> u16 { fn Code(&self) -> u16 {
match self.code { match self.code {
// http://dom.spec.whatwg.org/#concept-throw // http://dom.spec.whatwg.org/#concept-throw
EncodingError => 0, EncodingError => 0,
@ -75,12 +81,12 @@ impl DOMException {
} }
// http://dom.spec.whatwg.org/#error-names-0 // http://dom.spec.whatwg.org/#error-names-0
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
self.code.to_str() self.code.to_str()
} }
// http://dom.spec.whatwg.org/#error-names-0 // http://dom.spec.whatwg.org/#error-names-0
pub fn Message(&self) -> DOMString { fn Message(&self) -> DOMString {
match self.code { match self.code {
IndexSizeError => ~"The index is not in the allowed range.", IndexSizeError => ~"The index is not in the allowed range.",
HierarchyRequestError => ~"The operation would yield an incorrect node tree.", HierarchyRequestError => ~"The operation would yield an incorrect node tree.",

View file

@ -4,19 +4,19 @@
use dom::bindings::codegen::BindingDeclarations::DOMImplementationBinding; use dom::bindings::codegen::BindingDeclarations::DOMImplementationBinding;
use dom::bindings::codegen::InheritTypes::NodeCast; use dom::bindings::codegen::InheritTypes::NodeCast;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable};
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object}; use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
use dom::bindings::error::{Fallible, InvalidCharacter, NamespaceError}; use dom::bindings::error::{Fallible, InvalidCharacter, NamespaceError};
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type}; use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
use dom::document::{Document, HTMLDocument, NonHTMLDocument}; use dom::document::{Document, HTMLDocument, NonHTMLDocument, DocumentMethods};
use dom::documenttype::DocumentType; use dom::documenttype::DocumentType;
use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlheadelement::HTMLHeadElement; use dom::htmlheadelement::HTMLHeadElement;
use dom::htmlhtmlelement::HTMLHtmlElement; use dom::htmlhtmlelement::HTMLHtmlElement;
use dom::htmltitleelement::HTMLTitleElement; use dom::htmltitleelement::HTMLTitleElement;
use dom::node::{Node, INode}; use dom::node::{Node, NodeMethods};
use dom::text::Text; use dom::text::Text;
use dom::window::Window; use dom::window::{Window, WindowMethods};
use servo_util::str::DOMString; use servo_util::str::DOMString;
#[deriving(Encodable)] #[deriving(Encodable)]
@ -26,15 +26,15 @@ pub struct DOMImplementation {
} }
impl DOMImplementation { impl DOMImplementation {
pub fn new_inherited(owner: JS<Window>) -> DOMImplementation { pub fn new_inherited(owner: &JSRef<Window>) -> DOMImplementation {
DOMImplementation { DOMImplementation {
owner: owner, owner: owner.unrooted(),
reflector_: Reflector::new(), reflector_: Reflector::new(),
} }
} }
pub fn new(owner: &JS<Window>) -> JS<DOMImplementation> { pub fn new(owner: &JSRef<Window>) -> Temporary<DOMImplementation> {
reflect_dom_object(~DOMImplementation::new_inherited(owner.clone()), owner, reflect_dom_object(~DOMImplementation::new_inherited(owner), owner,
DOMImplementationBinding::Wrap) DOMImplementationBinding::Wrap)
} }
} }
@ -49,102 +49,124 @@ impl Reflectable for DOMImplementation {
} }
} }
pub trait DOMImplementationMethods {
fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible<Temporary<DocumentType>>;
fn CreateDocument(&self, namespace: Option<DOMString>, qname: DOMString,
mut maybe_doctype: Option<JSRef<DocumentType>>) -> Fallible<Temporary<Document>>;
fn CreateHTMLDocument(&self, title: Option<DOMString>) -> Temporary<Document>;
}
// http://dom.spec.whatwg.org/#domimplementation // http://dom.spec.whatwg.org/#domimplementation
impl DOMImplementation { impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
// http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype // http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
pub fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible<JS<DocumentType>> { fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible<Temporary<DocumentType>> {
match xml_name_type(qname) { match xml_name_type(qname) {
// Step 1. // Step 1.
InvalidXMLName => Err(InvalidCharacter), InvalidXMLName => Err(InvalidCharacter),
// Step 2. // Step 2.
Name => Err(NamespaceError), Name => Err(NamespaceError),
// Step 3. // Step 3.
QName => Ok(DocumentType::new(qname, Some(pubid), Some(sysid), &self.owner.get().Document())) QName => {
let owner = self.owner.root();
let document = owner.deref().Document().root();
Ok(DocumentType::new(qname, Some(pubid), Some(sysid), &*document))
}
} }
} }
// http://dom.spec.whatwg.org/#dom-domimplementation-createdocument // http://dom.spec.whatwg.org/#dom-domimplementation-createdocument
pub fn CreateDocument(&self, namespace: Option<DOMString>, qname: DOMString, fn CreateDocument(&self, namespace: Option<DOMString>, qname: DOMString,
maybe_doctype: Option<JS<DocumentType>>) -> Fallible<JS<Document>> { mut maybe_doctype: Option<JSRef<DocumentType>>) -> Fallible<Temporary<Document>> {
// Step 1. let win = self.owner.root();
let doc = Document::new(&self.owner, None, NonHTMLDocument, None);
let mut doc_node: JS<Node> = NodeCast::from(&doc);
// Step 1.
let mut doc = Document::new(&win.root_ref(), None, NonHTMLDocument, None).root();
// Step 2-3. // Step 2-3.
let maybe_elem = if qname.is_empty() { let mut maybe_elem = if qname.is_empty() {
None None
} else { } else {
match doc.get().CreateElementNS(&doc, namespace, qname) { match doc.CreateElementNS(namespace, qname) {
Err(error) => return Err(error), Err(error) => return Err(error),
Ok(elem) => Some(elem) Ok(elem) => Some(elem)
} }
}; };
// Step 4. {
match maybe_doctype { let doc_node: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut *doc);
None => (),
Some(ref doctype) => assert!(doc_node.AppendChild(&mut NodeCast::from(doctype)).is_ok())
}
// Step 5. // Step 4.
match maybe_elem { match maybe_doctype {
None => (), None => (),
Some(ref elem) => assert!(doc_node.AppendChild(&mut NodeCast::from(elem)).is_ok()) Some(ref mut doctype) => {
assert!(doc_node.AppendChild(NodeCast::from_mut_ref(doctype)).is_ok())
}
}
// Step 5.
match maybe_elem.root() {
None => (),
Some(mut elem) => {
assert!(doc_node.AppendChild(NodeCast::from_mut_ref(&mut *elem)).is_ok())
}
}
} }
// Step 6. // Step 6.
// FIXME: https://github.com/mozilla/servo/issues/1522 // FIXME: https://github.com/mozilla/servo/issues/1522
// Step 7. // Step 7.
Ok(doc) Ok(Temporary::from_rooted(&*doc))
} }
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument // http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
pub fn CreateHTMLDocument(&self, title: Option<DOMString>) -> JS<Document> { fn CreateHTMLDocument(&self, title: Option<DOMString>) -> Temporary<Document> {
let owner = self.owner.root();
// Step 1-2. // Step 1-2.
let doc = Document::new(&self.owner, None, HTMLDocument, None); let mut doc = Document::new(&owner.root_ref(), None, HTMLDocument, None).root();
let mut doc_node: JS<Node> = NodeCast::from(&doc); let mut doc_alias = doc.clone();
let doc_node: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut doc_alias);
{ {
// Step 3. // Step 3.
let doc_type = DocumentType::new(~"html", None, None, &doc); let mut doc_type = DocumentType::new(~"html", None, None, &*doc).root();
assert!(doc_node.AppendChild(&mut NodeCast::from(&doc_type)).is_ok()); assert!(doc_node.AppendChild(NodeCast::from_mut_ref(&mut *doc_type)).is_ok());
} }
{ {
// Step 4. // Step 4.
let mut doc_html = NodeCast::from(&HTMLHtmlElement::new(~"html", &doc)); let mut doc_html = NodeCast::from_unrooted(HTMLHtmlElement::new(~"html", &*doc)).root();
assert!(doc_node.AppendChild(&mut doc_html).is_ok()); assert!(doc_node.AppendChild(&mut *doc_html).is_ok());
{ {
// Step 5. // Step 5.
let mut doc_head = NodeCast::from(&HTMLHeadElement::new(~"head", &doc)); let mut doc_head = NodeCast::from_unrooted(HTMLHeadElement::new(~"head", &*doc)).root();
assert!(doc_html.AppendChild(&mut doc_head).is_ok()); assert!(doc_html.AppendChild(&mut *doc_head).is_ok());
// Step 6. // Step 6.
match title { match title {
None => (), None => (),
Some(title_str) => { Some(title_str) => {
// Step 6.1. // Step 6.1.
let mut doc_title = NodeCast::from(&HTMLTitleElement::new(~"title", &doc)); let mut doc_title = NodeCast::from_unrooted(HTMLTitleElement::new(~"title", &*doc)).root();
assert!(doc_head.AppendChild(&mut doc_title).is_ok()); assert!(doc_head.AppendChild(&mut *doc_title).is_ok());
// Step 6.2. // Step 6.2.
let title_text = Text::new(title_str, &doc); let mut title_text = Text::new(title_str, &*doc).root();
assert!(doc_title.AppendChild(&mut NodeCast::from(&title_text)).is_ok()); assert!(doc_title.AppendChild(NodeCast::from_mut_ref(&mut *title_text)).is_ok());
} }
} }
} }
// Step 7. // Step 7.
let doc_body = HTMLBodyElement::new(~"body", &doc); let mut doc_body = HTMLBodyElement::new(~"body", &*doc).root();
assert!(doc_html.AppendChild(&mut NodeCast::from(&doc_body)).is_ok()); assert!(doc_html.AppendChild(NodeCast::from_mut_ref(&mut *doc_body)).is_ok());
} }
// Step 8. // Step 8.
// FIXME: https://github.com/mozilla/servo/issues/1522 // FIXME: https://github.com/mozilla/servo/issues/1522
// Step 9. // Step 9.
doc Temporary::from_rooted(&*doc)
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::DOMParserBinding; use dom::bindings::codegen::BindingDeclarations::DOMParserBinding;
use dom::bindings::codegen::BindingDeclarations::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml}; use dom::bindings::codegen::BindingDeclarations::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object}; use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
use dom::bindings::error::{Fallible, FailureUnknown}; use dom::bindings::error::{Fallible, FailureUnknown};
use dom::document::{Document, HTMLDocument, NonHTMLDocument}; use dom::document::{Document, HTMLDocument, NonHTMLDocument};
@ -18,32 +18,40 @@ pub struct DOMParser {
} }
impl DOMParser { impl DOMParser {
pub fn new_inherited(owner: JS<Window>) -> DOMParser { pub fn new_inherited(owner: &JSRef<Window>) -> DOMParser {
DOMParser { DOMParser {
owner: owner, owner: owner.unrooted(),
reflector_: Reflector::new() reflector_: Reflector::new()
} }
} }
pub fn new(owner: &JS<Window>) -> JS<DOMParser> { pub fn new(owner: &JSRef<Window>) -> Temporary<DOMParser> {
reflect_dom_object(~DOMParser::new_inherited(owner.clone()), owner, reflect_dom_object(~DOMParser::new_inherited(owner), owner,
DOMParserBinding::Wrap) DOMParserBinding::Wrap)
} }
pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<DOMParser>> { pub fn Constructor(owner: &JSRef<Window>) -> Fallible<Temporary<DOMParser>> {
Ok(DOMParser::new(owner)) Ok(DOMParser::new(owner))
} }
}
pub fn ParseFromString(&self, pub trait DOMParserMethods {
_s: DOMString, fn ParseFromString(&self, _s: DOMString, ty: DOMParserBinding::SupportedType)
ty: DOMParserBinding::SupportedType) -> Fallible<Temporary<Document>>;
-> Fallible<JS<Document>> { }
impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
fn ParseFromString(&self,
_s: DOMString,
ty: DOMParserBinding::SupportedType)
-> Fallible<Temporary<Document>> {
let owner = self.owner.root();
match ty { match ty {
Text_html => { Text_html => {
Ok(Document::new(&self.owner, None, HTMLDocument, Some(~"text/html"))) Ok(Document::new(&owner.root_ref(), None, HTMLDocument, Some(~"text/html")))
} }
Text_xml => { Text_xml => {
Ok(Document::new(&self.owner, None, NonHTMLDocument, Some(~"text/xml"))) Ok(Document::new(&owner.root_ref(), None, NonHTMLDocument, Some(~"text/xml")))
} }
_ => { _ => {
Err(FailureUnknown) Err(FailureUnknown)

View file

@ -4,21 +4,23 @@
//! Element nodes. //! Element nodes.
use dom::attr::{Attr, AttrSettingType, ReplacedAttr, FirstSetAttr}; use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrMethods};
use dom::attrlist::AttrList; use dom::attrlist::AttrList;
use dom::bindings::codegen::BindingDeclarations::ElementBinding; use dom::bindings::codegen::BindingDeclarations::ElementBinding;
use dom::bindings::codegen::InheritTypes::{ElementDerived, NodeCast}; use dom::bindings::codegen::InheritTypes::{ElementDerived, NodeCast};
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary, TemporaryPushable};
use dom::bindings::js::{OptionalSettable, OptionalRootable, Root};
use dom::bindings::utils::{Reflectable, Reflector}; use dom::bindings::utils::{Reflectable, Reflector};
use dom::bindings::error::{ErrorResult, Fallible, NamespaceError, InvalidCharacter}; use dom::bindings::error::{ErrorResult, Fallible, NamespaceError, InvalidCharacter};
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type}; use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
use dom::clientrect::ClientRect; use dom::clientrect::ClientRect;
use dom::clientrectlist::ClientRectList; use dom::clientrectlist::ClientRectList;
use dom::document::Document; use dom::document::{Document, DocumentHelpers};
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::htmlserializer::serialize; use dom::htmlserializer::serialize;
use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator, document_from_node}; use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator, document_from_node};
use dom::node::{window_from_node, LayoutNodeHelpers};
use dom::virtualmethods::{VirtualMethods, vtable_for}; use dom::virtualmethods::{VirtualMethods, vtable_for};
use layout_interface::ContentChangedDocumentDamage; use layout_interface::ContentChangedDocumentDamage;
use layout_interface::MatchSelectorsDocumentDamage; use layout_interface::MatchSelectorsDocumentDamage;
@ -139,7 +141,7 @@ pub enum ElementTypeId {
// //
impl Element { impl Element {
pub fn new_inherited(type_id: ElementTypeId, local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: JS<Document>) -> Element { pub fn new_inherited(type_id: ElementTypeId, local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: &JSRef<Document>) -> Element {
Element { Element {
node: Node::new_inherited(ElementNodeTypeId(type_id), document), node: Node::new_inherited(ElementNodeTypeId(type_id), document),
local_name: local_name, local_name: local_name,
@ -151,53 +153,65 @@ impl Element {
} }
} }
pub fn new(local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: &JS<Document>) -> JS<Element> { pub fn new(local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: &JSRef<Document>) -> Temporary<Element> {
let element = Element::new_inherited(ElementTypeId, local_name, namespace, prefix, document.clone()); let element = Element::new_inherited(ElementTypeId, local_name, namespace, prefix, document);
Node::reflect_node(~element, document, ElementBinding::Wrap) Node::reflect_node(~element, document, ElementBinding::Wrap)
} }
pub fn html_element_in_html_document(&self) -> bool {
self.namespace == namespace::HTML &&
self.node.owner_doc().get().is_html_document
}
} }
impl Element { pub trait RawLayoutElementHelpers {
pub unsafe fn html_element_in_html_document_for_layout(&self) -> bool { unsafe fn get_attr_val_for_layout(&self, namespace: &Namespace, name: &str) -> Option<&'static str>;
if self.namespace != namespace::HTML { }
return false
}
let owner_doc: *JS<Document> = self.node.owner_doc();
let owner_doc: **Document = owner_doc as **Document;
(**owner_doc).is_html_document
}
impl RawLayoutElementHelpers for Element {
#[inline] #[inline]
pub unsafe fn get_attr_val_for_layout(&self, namespace: &Namespace, name: &str) unsafe fn get_attr_val_for_layout(&self, namespace: &Namespace, name: &str)
-> Option<&'static str> { -> Option<&'static str> {
self.attrs.iter().find(|attr: & &JS<Attr>| { self.attrs.iter().find(|attr: & &JS<Attr>| {
// unsafely avoid a borrow because this is accessed by many tasks let attr = attr.unsafe_get();
// during parallel layout name == (*attr).local_name && (*attr).namespace == *namespace
let attr: ***Attr = cast::transmute(attr);
name == (***attr).local_name && (***attr).namespace == *namespace
}).map(|attr| { }).map(|attr| {
let attr: **Attr = cast::transmute(attr); let attr = attr.unsafe_get();
cast::transmute((**attr).value.as_slice()) cast::transmute((*attr).value.as_slice())
}) })
} }
} }
pub trait LayoutElementHelpers {
unsafe fn html_element_in_html_document_for_layout(&self) -> bool;
}
impl LayoutElementHelpers for JS<Element> {
unsafe fn html_element_in_html_document_for_layout(&self) -> bool {
if (*self.unsafe_get()).namespace != namespace::HTML {
return false
}
let node: JS<Node> = self.transmute_copy();
let owner_doc = node.owner_doc_for_layout().unsafe_get();
(*owner_doc).is_html_document
}
}
pub trait ElementHelpers {
fn html_element_in_html_document(&self) -> bool;
}
impl<'a> ElementHelpers for JSRef<'a, Element> {
fn html_element_in_html_document(&self) -> bool {
let is_html = self.namespace == namespace::HTML;
let node: &JSRef<Node> = NodeCast::from_ref(self);
is_html && node.owner_doc().root().is_html_document
}
}
pub trait AttributeHandlers { pub trait AttributeHandlers {
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<JS<Attr>>; fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>>;
fn set_attr(&mut self, name: DOMString, value: DOMString) -> ErrorResult; fn set_attr(&mut self, name: DOMString, value: DOMString) -> ErrorResult;
fn set_attribute(&mut self, namespace: Namespace, name: DOMString, fn set_attribute(&mut self, namespace: Namespace, name: DOMString,
value: DOMString) -> ErrorResult; value: DOMString) -> ErrorResult;
fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString, fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString,
name: DOMString, namespace: Namespace, name: DOMString, namespace: Namespace,
prefix: Option<DOMString>, cb: |&JS<Attr>| -> bool); prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool);
fn SetAttribute(&mut self, name: DOMString, value: DOMString) -> ErrorResult;
fn SetAttributeNS(&mut self, namespace_url: Option<DOMString>,
name: DOMString, value: DOMString) -> ErrorResult;
fn remove_attribute(&mut self, namespace: Namespace, name: DOMString) -> ErrorResult; fn remove_attribute(&mut self, namespace: Namespace, name: DOMString) -> ErrorResult;
fn notify_attribute_changed(&self, local_name: DOMString); fn notify_attribute_changed(&self, local_name: DOMString);
@ -211,18 +225,16 @@ pub trait AttributeHandlers {
fn set_uint_attribute(&mut self, name: &str, value: u32); fn set_uint_attribute(&mut self, name: &str, value: u32);
} }
impl AttributeHandlers for JS<Element> { impl<'a> AttributeHandlers for JSRef<'a, Element> {
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<JS<Attr>> { fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>> {
if self.get().html_element_in_html_document() { if self.html_element_in_html_document() {
self.get().attrs.iter().find(|attr| { self.deref().attrs.iter().map(|attr| attr.root()).find(|attr| {
let attr = attr.get();
name.to_ascii_lower() == attr.local_name && attr.namespace == namespace name.to_ascii_lower() == attr.local_name && attr.namespace == namespace
}).map(|x| x.clone()) }).map(|x| Temporary::from_rooted(&*x))
} else { } else {
self.get().attrs.iter().find(|attr| { self.deref().attrs.iter().map(|attr| attr.root()).find(|attr| {
let attr = attr.get();
name == attr.local_name && attr.namespace == namespace name == attr.local_name && attr.namespace == namespace
}).map(|x| x.clone()) }).map(|x| Temporary::from_rooted(&*x))
} }
} }
@ -244,14 +256,15 @@ impl AttributeHandlers for JS<Element> {
None => {} None => {}
} }
let node: JS<Node> = NodeCast::from(self); let self_alias = self.clone();
node.get().wait_until_safe_to_modify_dom(); let node: &JSRef<Node> = NodeCast::from_ref(&self_alias);
node.wait_until_safe_to_modify_dom();
let position: |&JS<Attr>| -> bool = let position: |&JSRef<Attr>| -> bool =
if self.get().html_element_in_html_document() { if self.html_element_in_html_document() {
|attr| attr.get().local_name.eq_ignore_ascii_case(local_name) |attr| attr.deref().local_name.eq_ignore_ascii_case(local_name)
} else { } else {
|attr| attr.get().local_name == local_name |attr| attr.deref().local_name == local_name
}; };
self.do_set_attribute(name.clone(), value, name.clone(), namespace::Null, None, position); self.do_set_attribute(name.clone(), value, name.clone(), namespace::Null, None, position);
Ok(()) Ok(())
@ -259,31 +272,234 @@ impl AttributeHandlers for JS<Element> {
fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString, fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString,
name: DOMString, namespace: Namespace, name: DOMString, namespace: Namespace,
prefix: Option<DOMString>, cb: |&JS<Attr>| -> bool) { prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool) {
let node: JS<Node> = NodeCast::from(self); let idx = self.deref().attrs.iter()
let idx = self.get().attrs.iter().position(cb); .map(|attr| attr.root())
let (mut attr, set_type): (JS<Attr>, AttrSettingType) = match idx { .position(|attr| cb(&*attr));
Some(idx) => { let (idx, set_type) = match idx {
let attr = self.get_mut().attrs.get(idx).clone(); Some(idx) => (idx, ReplacedAttr),
(attr, ReplacedAttr)
}
None => { None => {
let doc = node.get().owner_doc().get(); let window = window_from_node(self).root();
let attr = Attr::new(&doc.window, local_name.clone(), value.clone(), let attr = Attr::new(&*window, local_name.clone(), value.clone(),
name, namespace.clone(), prefix, self.clone()); name, namespace.clone(), prefix, self);
self.get_mut().attrs.push(attr.clone()); self.deref_mut().attrs.push_unrooted(&attr);
(attr, FirstSetAttr) (self.deref().attrs.len() - 1, FirstSetAttr)
} }
}; };
attr.get_mut().set_value(set_type, value); self.deref_mut().attrs.get(idx).root().set_value(set_type, value);
}
fn remove_attribute(&mut self, namespace: Namespace, name: DOMString) -> ErrorResult {
let (_, local_name) = get_attribute_parts(name.clone());
let idx = self.deref().attrs.iter().map(|attr| attr.root()).position(|attr| {
attr.local_name == local_name
});
match idx {
None => (),
Some(idx) => {
{
let node: &mut JSRef<Node> = NodeCast::from_mut_ref(self);
node.wait_until_safe_to_modify_dom();
}
if namespace == namespace::Null {
let removed_raw_value = self.deref().attrs.get(idx).root().Value();
vtable_for(NodeCast::from_mut_ref(self))
.before_remove_attr(local_name.clone(), removed_raw_value);
}
self.deref_mut().attrs.remove(idx);
}
};
Ok(())
}
fn notify_attribute_changed(&self, local_name: DOMString) {
let node: &JSRef<Node> = NodeCast::from_ref(self);
if node.is_in_doc() {
let damage = match local_name.as_slice() {
"style" | "id" | "class" => MatchSelectorsDocumentDamage,
_ => ContentChangedDocumentDamage
};
let document = node.owner_doc().root();
document.deref().damage_and_reflow(damage);
}
}
fn has_class(&self, name: &str) -> bool {
let class_names = self.get_string_attribute("class");
let mut classes = split_html_space_chars(class_names);
classes.any(|class| name == class)
}
fn get_url_attribute(&self, name: &str) -> DOMString {
// XXX Resolve URL.
self.get_string_attribute(name)
}
fn set_url_attribute(&mut self, name: &str, value: DOMString) {
self.set_string_attribute(name, value);
}
fn get_string_attribute(&self, name: &str) -> DOMString {
match self.get_attribute(Null, name) {
Some(x) => {
let x = x.root();
x.deref().Value()
}
None => ~""
}
}
fn set_string_attribute(&mut self, name: &str, value: DOMString) {
assert!(name == name.to_ascii_lower());
assert!(self.set_attribute(Null, name.to_owned(), value).is_ok());
}
fn set_uint_attribute(&mut self, name: &str, value: u32) {
assert!(name == name.to_ascii_lower());
assert!(self.set_attribute(Null, name.to_owned(), value.to_str()).is_ok());
}
}
impl Element {
pub fn is_void(&self) -> bool {
if self.namespace != namespace::HTML {
return false
}
match self.local_name.as_slice() {
/* List of void elements from
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm */
"area" | "base" | "basefont" | "bgsound" | "br" | "col" | "embed" |
"frame" | "hr" | "img" | "input" | "keygen" | "link" | "menuitem" |
"meta" | "param" | "source" | "track" | "wbr" => true,
_ => false
}
}
}
pub trait ElementMethods {
fn NamespaceURI(&self) -> DOMString;
fn LocalName(&self) -> DOMString;
fn GetPrefix(&self) -> Option<DOMString>;
fn TagName(&self) -> DOMString;
fn Id(&self) -> DOMString;
fn SetId(&mut self, id: DOMString);
fn ClassName(&self) -> DOMString;
fn SetClassName(&mut self, class: DOMString);
fn Attributes(&mut self) -> Temporary<AttrList>;
fn GetAttribute(&self, name: DOMString) -> Option<DOMString>;
fn GetAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> Option<DOMString>;
fn SetAttribute(&mut self, name: DOMString, value: DOMString) -> ErrorResult;
fn SetAttributeNS(&mut self, namespace_url: Option<DOMString>, name: DOMString, value: DOMString) -> ErrorResult;
fn RemoveAttribute(&mut self, name: DOMString) -> ErrorResult;
fn RemoveAttributeNS(&mut self, namespace: Option<DOMString>, localname: DOMString) -> ErrorResult;
fn HasAttribute(&self, name: DOMString) -> bool;
fn HasAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> bool;
fn GetElementsByTagName(&self, localname: DOMString) -> Temporary<HTMLCollection>;
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, localname: DOMString) -> Temporary<HTMLCollection>;
fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection>;
fn GetClientRects(&self) -> Temporary<ClientRectList>;
fn GetBoundingClientRect(&self) -> Temporary<ClientRect>;
fn GetInnerHTML(&self) -> Fallible<DOMString>;
fn GetOuterHTML(&self) -> Fallible<DOMString>;
fn Children(&self) -> Temporary<HTMLCollection>;
}
impl<'a> ElementMethods for JSRef<'a, Element> {
// http://dom.spec.whatwg.org/#dom-element-namespaceuri
fn NamespaceURI(&self) -> DOMString {
self.namespace.to_str().to_owned()
}
fn LocalName(&self) -> DOMString {
self.local_name.clone()
}
// http://dom.spec.whatwg.org/#dom-element-prefix
fn GetPrefix(&self) -> Option<DOMString> {
self.prefix.clone()
}
// http://dom.spec.whatwg.org/#dom-element-tagname
fn TagName(&self) -> DOMString {
match self.prefix {
None => {
self.local_name.to_ascii_upper()
}
Some(ref prefix_str) => {
(*prefix_str + ":" + self.local_name).to_ascii_upper()
}
}
}
// http://dom.spec.whatwg.org/#dom-element-id
fn Id(&self) -> DOMString {
self.get_string_attribute("id")
}
// http://dom.spec.whatwg.org/#dom-element-id
fn SetId(&mut self, id: DOMString) {
self.set_string_attribute("id", id);
}
// http://dom.spec.whatwg.org/#dom-element-classname
fn ClassName(&self) -> DOMString {
self.get_string_attribute("class")
}
// http://dom.spec.whatwg.org/#dom-element-classname
fn SetClassName(&mut self, class: DOMString) {
self.set_string_attribute("class", class);
}
// http://dom.spec.whatwg.org/#dom-element-attributes
fn Attributes(&mut self) -> Temporary<AttrList> {
match self.attr_list {
None => (),
Some(ref list) => return Temporary::new(list.clone()),
}
let doc = {
let node: &JSRef<Node> = NodeCast::from_ref(self);
node.owner_doc().root()
};
let window = doc.deref().window.root();
let list = AttrList::new(&*window, self);
self.attr_list.assign(Some(list));
Temporary::new(self.attr_list.get_ref().clone())
}
// http://dom.spec.whatwg.org/#dom-element-getattribute
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
let name = if self.html_element_in_html_document() {
name.to_ascii_lower()
} else {
name
};
self.get_attribute(Null, name).root()
.map(|s| s.deref().Value())
}
// http://dom.spec.whatwg.org/#dom-element-getattributens
fn GetAttributeNS(&self,
namespace: Option<DOMString>,
local_name: DOMString) -> Option<DOMString> {
let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace));
self.get_attribute(namespace, local_name).root()
.map(|attr| attr.deref().Value())
} }
// http://dom.spec.whatwg.org/#dom-element-setattribute // http://dom.spec.whatwg.org/#dom-element-setattribute
fn SetAttribute(&mut self, name: DOMString, value: DOMString) -> ErrorResult { fn SetAttribute(&mut self,
let node: JS<Node> = NodeCast::from(self); name: DOMString,
node.get().wait_until_safe_to_modify_dom(); value: DOMString) -> ErrorResult {
{
let node: &JSRef<Node> = NodeCast::from_ref(self);
node.wait_until_safe_to_modify_dom();
}
// Step 1. // Step 1.
match xml_name_type(name) { match xml_name_type(name) {
@ -292,7 +508,7 @@ impl AttributeHandlers for JS<Element> {
} }
// Step 2. // Step 2.
let name = if self.get().html_element_in_html_document() { let name = if self.html_element_in_html_document() {
name.to_ascii_lower() name.to_ascii_lower()
} else { } else {
name name
@ -300,15 +516,20 @@ impl AttributeHandlers for JS<Element> {
// Step 3-5. // Step 3-5.
self.do_set_attribute(name.clone(), value, name.clone(), namespace::Null, None, |attr| { self.do_set_attribute(name.clone(), value, name.clone(), namespace::Null, None, |attr| {
attr.get().name == name attr.deref().name == name
}); });
Ok(()) Ok(())
} }
fn SetAttributeNS(&mut self, namespace_url: Option<DOMString>, // http://dom.spec.whatwg.org/#dom-element-setattributens
name: DOMString, value: DOMString) -> ErrorResult { fn SetAttributeNS(&mut self,
let node: JS<Node> = NodeCast::from(self); namespace_url: Option<DOMString>,
node.get().wait_until_safe_to_modify_dom(); name: DOMString,
value: DOMString) -> ErrorResult {
{
let node: &JSRef<Node> = NodeCast::from_ref(self);
node.wait_until_safe_to_modify_dom();
}
// Step 1. // Step 1.
let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace_url)); let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace_url));
@ -356,294 +577,106 @@ impl AttributeHandlers for JS<Element> {
// Step 9. // Step 9.
self.do_set_attribute(local_name.clone(), value, name, namespace.clone(), prefix, |attr| { self.do_set_attribute(local_name.clone(), value, name, namespace.clone(), prefix, |attr| {
attr.get().local_name == local_name && attr.deref().local_name == local_name &&
attr.get().namespace == namespace attr.deref().namespace == namespace
}); });
Ok(()) Ok(())
} }
fn remove_attribute(&mut self, namespace: Namespace, name: DOMString) -> ErrorResult {
let (_, local_name) = get_attribute_parts(name.clone());
let node: JS<Node> = NodeCast::from(self);
node.get().wait_until_safe_to_modify_dom();
let idx = self.get().attrs.iter().position(|attr| {
attr.get().local_name == local_name
});
match idx {
None => (),
Some(idx) => {
if namespace == namespace::Null {
let removed_raw_value = self.get().attrs.get(idx).get().Value();
vtable_for(&node).before_remove_attr(local_name.clone(), removed_raw_value);
}
self.get_mut().attrs.remove(idx);
}
};
Ok(())
}
fn notify_attribute_changed(&self, local_name: DOMString) {
let node: JS<Node> = NodeCast::from(self);
if node.is_in_doc() {
let damage = match local_name.as_slice() {
"style" | "id" | "class" => MatchSelectorsDocumentDamage,
_ => ContentChangedDocumentDamage
};
let document = node.get().owner_doc();
document.get().damage_and_reflow(damage);
}
}
fn has_class(&self, name: &str) -> bool {
let class_names = self.get_string_attribute("class");
let mut classes = split_html_space_chars(class_names);
classes.any(|class| name == class)
}
fn get_url_attribute(&self, name: &str) -> DOMString {
// XXX Resolve URL.
self.get_string_attribute(name)
}
fn set_url_attribute(&mut self, name: &str, value: DOMString) {
self.set_string_attribute(name, value);
}
fn get_string_attribute(&self, name: &str) -> DOMString {
match self.get_attribute(Null, name) {
Some(x) => x.get().Value(),
None => ~""
}
}
fn set_string_attribute(&mut self, name: &str, value: DOMString) {
assert!(name == name.to_ascii_lower());
assert!(self.set_attribute(Null, name.to_owned(), value).is_ok());
}
fn set_uint_attribute(&mut self, name: &str, value: u32) {
assert!(name == name.to_ascii_lower());
assert!(self.set_attribute(Null, name.to_owned(), value.to_str()).is_ok());
}
}
impl Element {
pub fn is_void(&self) -> bool {
if self.namespace != namespace::HTML {
return false
}
match self.local_name.as_slice() {
/* List of void elements from
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm */
"area" | "base" | "basefont" | "bgsound" | "br" | "col" | "embed" |
"frame" | "hr" | "img" | "input" | "keygen" | "link" | "menuitem" |
"meta" | "param" | "source" | "track" | "wbr" => true,
_ => false
}
}
}
impl Element {
// http://dom.spec.whatwg.org/#dom-element-namespaceuri
pub fn NamespaceURI(&self) -> DOMString {
self.namespace.to_str().to_owned()
}
pub fn LocalName(&self) -> DOMString {
self.local_name.clone()
}
// http://dom.spec.whatwg.org/#dom-element-prefix
pub fn GetPrefix(&self) -> Option<DOMString> {
self.prefix.clone()
}
// http://dom.spec.whatwg.org/#dom-element-tagname
pub fn TagName(&self) -> DOMString {
match self.prefix {
None => {
self.local_name.to_ascii_upper()
}
Some(ref prefix_str) => {
(*prefix_str + ":" + self.local_name).to_ascii_upper()
}
}
}
// http://dom.spec.whatwg.org/#dom-element-id
pub fn Id(&self, abstract_self: &JS<Element>) -> DOMString {
abstract_self.get_string_attribute("id")
}
// http://dom.spec.whatwg.org/#dom-element-id
pub fn SetId(&mut self, abstract_self: &mut JS<Element>, id: DOMString) {
abstract_self.set_string_attribute("id", id);
}
// http://dom.spec.whatwg.org/#dom-element-classname
pub fn ClassName(&self, abstract_self: &JS<Element>) -> DOMString {
abstract_self.get_string_attribute("class")
}
// http://dom.spec.whatwg.org/#dom-element-classname
pub fn SetClassName(&self, abstract_self: &mut JS<Element>, class: DOMString) {
abstract_self.set_string_attribute("class", class);
}
// http://dom.spec.whatwg.org/#dom-element-attributes
pub fn Attributes(&mut self, abstract_self: &JS<Element>) -> JS<AttrList> {
match self.attr_list {
None => {
let doc = self.node.owner_doc();
let doc = doc.get();
let list = AttrList::new(&doc.window, abstract_self);
self.attr_list = Some(list.clone());
list
}
Some(ref list) => list.clone()
}
}
// http://dom.spec.whatwg.org/#dom-element-getattribute
pub fn GetAttribute(&self, abstract_self: &JS<Element>, name: DOMString) -> Option<DOMString> {
let name = if abstract_self.get().html_element_in_html_document() {
name.to_ascii_lower()
} else {
name
};
abstract_self.get_attribute(Null, name).map(|s| s.get().Value())
}
// http://dom.spec.whatwg.org/#dom-element-getattributens
pub fn GetAttributeNS(&self, abstract_self: &JS<Element>,
namespace: Option<DOMString>,
local_name: DOMString) -> Option<DOMString> {
let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace));
abstract_self.get_attribute(namespace, local_name)
.map(|attr| attr.get().value.clone())
}
// http://dom.spec.whatwg.org/#dom-element-setattribute
pub fn SetAttribute(&self, abstract_self: &mut JS<Element>,
name: DOMString,
value: DOMString) -> ErrorResult {
abstract_self.SetAttribute(name, value)
}
// http://dom.spec.whatwg.org/#dom-element-setattributens
pub fn SetAttributeNS(&self,
abstract_self: &mut JS<Element>,
namespace_url: Option<DOMString>,
name: DOMString,
value: DOMString) -> ErrorResult {
abstract_self.SetAttributeNS(namespace_url, name, value)
}
// http://dom.spec.whatwg.org/#dom-element-removeattribute // http://dom.spec.whatwg.org/#dom-element-removeattribute
pub fn RemoveAttribute(&mut self, fn RemoveAttribute(&mut self,
abstract_self: &mut JS<Element>, name: DOMString) -> ErrorResult {
name: DOMString) -> ErrorResult {
let name = if self.html_element_in_html_document() { let name = if self.html_element_in_html_document() {
name.to_ascii_lower() name.to_ascii_lower()
} else { } else {
name name
}; };
abstract_self.remove_attribute(namespace::Null, name) self.remove_attribute(namespace::Null, name)
} }
// http://dom.spec.whatwg.org/#dom-element-removeattributens // http://dom.spec.whatwg.org/#dom-element-removeattributens
pub fn RemoveAttributeNS(&mut self, fn RemoveAttributeNS(&mut self,
abstract_self: &mut JS<Element>, namespace: Option<DOMString>,
namespace: Option<DOMString>, localname: DOMString) -> ErrorResult {
localname: DOMString) -> ErrorResult {
let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace)); let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace));
abstract_self.remove_attribute(namespace, localname) self.remove_attribute(namespace, localname)
} }
// http://dom.spec.whatwg.org/#dom-element-hasattribute // http://dom.spec.whatwg.org/#dom-element-hasattribute
pub fn HasAttribute(&self, abstract_self: &JS<Element>, fn HasAttribute(&self,
name: DOMString) -> bool { name: DOMString) -> bool {
self.GetAttribute(abstract_self, name).is_some() self.GetAttribute(name).is_some()
} }
// http://dom.spec.whatwg.org/#dom-element-hasattributens // http://dom.spec.whatwg.org/#dom-element-hasattributens
pub fn HasAttributeNS(&self, abstract_self: &JS<Element>, fn HasAttributeNS(&self,
namespace: Option<DOMString>, namespace: Option<DOMString>,
local_name: DOMString) -> bool { local_name: DOMString) -> bool {
self.GetAttributeNS(abstract_self, namespace, local_name).is_some() self.GetAttributeNS(namespace, local_name).is_some()
} }
pub fn GetElementsByTagName(&self, abstract_self: &JS<Element>, localname: DOMString) -> JS<HTMLCollection> { fn GetElementsByTagName(&self, localname: DOMString) -> Temporary<HTMLCollection> {
let doc = self.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); HTMLCollection::by_tag_name(&*window, NodeCast::from_ref(self), localname)
HTMLCollection::by_tag_name(&doc.window, &NodeCast::from(abstract_self), localname)
} }
pub fn GetElementsByTagNameNS(&self, abstract_self: &JS<Element>, maybe_ns: Option<DOMString>, fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>,
localname: DOMString) -> JS<HTMLCollection> { localname: DOMString) -> Temporary<HTMLCollection> {
let doc = self.node.owner_doc();
let doc = doc.get();
let namespace = match maybe_ns { let namespace = match maybe_ns {
Some(namespace) => Namespace::from_str(namespace), Some(namespace) => Namespace::from_str(namespace),
None => Null None => Null
}; };
HTMLCollection::by_tag_name_ns(&doc.window, &NodeCast::from(abstract_self), localname, namespace) let window = window_from_node(self).root();
HTMLCollection::by_tag_name_ns(&*window, NodeCast::from_ref(self), localname, namespace)
} }
pub fn GetElementsByClassName(&self, abstract_self: &JS<Element>, classes: DOMString) -> JS<HTMLCollection> { fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> {
let doc = self.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); HTMLCollection::by_class_name(&*window, NodeCast::from_ref(self), classes)
HTMLCollection::by_class_name(&doc.window, &NodeCast::from(abstract_self), classes)
} }
// http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects // http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects
pub fn GetClientRects(&self, abstract_self: &JS<Element>) -> JS<ClientRectList> { fn GetClientRects(&self) -> Temporary<ClientRectList> {
let doc = self.node.owner_doc(); let win = window_from_node(self).root();
let win = &doc.get().window; let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JS<Node> = NodeCast::from(abstract_self);
let rects = node.get_content_boxes(); let rects = node.get_content_boxes();
let rects = rects.iter().map(|r| { let rects: ~[Root<ClientRect>] = rects.iter().map(|r| {
ClientRect::new( ClientRect::new(
win, &*win,
r.origin.y, r.origin.y,
r.origin.y + r.size.height, r.origin.y + r.size.height,
r.origin.x, r.origin.x,
r.origin.x + r.size.width) r.origin.x + r.size.width).root()
}).collect(); }).collect();
ClientRectList::new(win, rects) ClientRectList::new(&*win, rects.iter().map(|rect| rect.deref().clone()).collect())
} }
// http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect // http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect
pub fn GetBoundingClientRect(&self, abstract_self: &JS<Element>) -> JS<ClientRect> { fn GetBoundingClientRect(&self) -> Temporary<ClientRect> {
let doc = self.node.owner_doc(); let win = window_from_node(self).root();
let win = &doc.get().window; let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JS<Node> = NodeCast::from(abstract_self);
let rect = node.get_bounding_content_box(); let rect = node.get_bounding_content_box();
ClientRect::new( ClientRect::new(
win, &*win,
rect.origin.y, rect.origin.y,
rect.origin.y + rect.size.height, rect.origin.y + rect.size.height,
rect.origin.x, rect.origin.x,
rect.origin.x + rect.size.width) rect.origin.x + rect.size.width)
} }
pub fn GetInnerHTML(&self, abstract_self: &JS<Element>) -> Fallible<DOMString> { fn GetInnerHTML(&self) -> Fallible<DOMString> {
//XXX TODO: XML case //XXX TODO: XML case
Ok(serialize(&mut NodeIterator::new(NodeCast::from(abstract_self), false, false))) Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(self), false, false)))
} }
pub fn GetOuterHTML(&self, abstract_self: &JS<Element>) -> Fallible<DOMString> { fn GetOuterHTML(&self) -> Fallible<DOMString> {
Ok(serialize(&mut NodeIterator::new(NodeCast::from(abstract_self), true, false))) Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(self), true, false)))
} }
pub fn Children(&self, abstract_self: &JS<Element>) -> JS<HTMLCollection> { fn Children(&self) -> Temporary<HTMLCollection> {
let doc = self.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); HTMLCollection::children(&*window, NodeCast::from_ref(self))
HTMLCollection::children(&doc.window, &NodeCast::from(abstract_self))
} }
} }
@ -660,10 +693,10 @@ pub fn get_attribute_parts(name: DOMString) -> (Option<~str>, ~str) {
(prefix, local_name) (prefix, local_name)
} }
impl VirtualMethods for JS<Element> { impl<'a> VirtualMethods for JSRef<'a, Element> {
fn super_type(&self) -> Option<~VirtualMethods:> { fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
let node: JS<Node> = NodeCast::from(self); let node: &mut JSRef<Node> = NodeCast::from_mut_ref(self);
Some(~node as ~VirtualMethods:) Some(node as &mut VirtualMethods:)
} }
fn after_set_attr(&mut self, name: DOMString, value: DOMString) { fn after_set_attr(&mut self, name: DOMString, value: DOMString) {
@ -672,19 +705,18 @@ impl VirtualMethods for JS<Element> {
_ => (), _ => (),
} }
let node: JS<Node> = NodeCast::from(self);
match name.as_slice() { match name.as_slice() {
"style" => { "style" => {
let doc = node.get().owner_doc(); let doc = document_from_node(self).root();
let base_url = doc.get().url().clone(); let base_url = doc.deref().url().clone();
self.get_mut().style_attribute = Some(style::parse_style_attribute(value, &base_url)) self.deref_mut().style_attribute = Some(style::parse_style_attribute(value, &base_url))
} }
"id" if node.is_in_doc() => { "id" => {
// XXX: this dual declaration are workaround to avoid the compile error: let node: &JSRef<Node> = NodeCast::from_ref(self);
// "borrowed value does not live long enough" if node.is_in_doc() {
let mut doc = node.get().owner_doc().clone(); let mut doc = document_from_node(self).root();
let doc = doc.get_mut(); doc.register_named_element(self, value.clone());
doc.register_named_element(self, value.clone()); }
} }
_ => () _ => ()
} }
@ -698,17 +730,16 @@ impl VirtualMethods for JS<Element> {
_ => (), _ => (),
} }
let node: JS<Node> = NodeCast::from(self);
match name.as_slice() { match name.as_slice() {
"style" => { "style" => {
self.get_mut().style_attribute = None self.deref_mut().style_attribute = None
} }
"id" if node.is_in_doc() => { "id" => {
// XXX: this dual declaration are workaround to avoid the compile error: let node: &JSRef<Node> = NodeCast::from_ref(self);
// "borrowed value does not live long enough" if node.is_in_doc() {
let mut doc = node.get().owner_doc().clone(); let mut doc = document_from_node(self).root();
let doc = doc.get_mut(); doc.unregister_named_element(self, value);
doc.unregister_named_element(self, value); }
} }
_ => () _ => ()
} }
@ -722,10 +753,10 @@ impl VirtualMethods for JS<Element> {
_ => (), _ => (),
} }
match self.get_attribute(Null, "id") { match self.get_attribute(Null, "id").root() {
Some(attr) => { Some(attr) => {
let mut doc = document_from_node(self); let mut doc = document_from_node(self).root();
doc.get_mut().register_named_element(self, attr.get().Value()); doc.register_named_element(self, attr.deref().Value());
} }
_ => () _ => ()
} }
@ -737,10 +768,10 @@ impl VirtualMethods for JS<Element> {
_ => (), _ => (),
} }
match self.get_attribute(Null, "id") { match self.get_attribute(Null, "id").root() {
Some(attr) => { Some(attr) => {
let mut doc = document_from_node(self); let mut doc = document_from_node(self).root();
doc.get_mut().unregister_named_element(self, attr.get().Value()); doc.unregister_named_element(self, attr.deref().Value());
} }
_ => () _ => ()
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::EventBinding; use dom::bindings::codegen::BindingDeclarations::EventBinding;
use dom::bindings::codegen::BindingDeclarations::EventBinding::EventConstants; use dom::bindings::codegen::BindingDeclarations::EventBinding::EventConstants;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::eventtarget::EventTarget; use dom::eventtarget::EventTarget;
@ -80,63 +80,89 @@ impl Event {
} }
} }
pub fn new(window: &JS<Window>) -> JS<Event> { pub fn new(window: &JSRef<Window>) -> Temporary<Event> {
reflect_dom_object(~Event::new_inherited(HTMLEventTypeId), reflect_dom_object(~Event::new_inherited(HTMLEventTypeId),
window, window,
EventBinding::Wrap) EventBinding::Wrap)
} }
pub fn EventPhase(&self) -> u16 { pub fn Constructor(global: &JSRef<Window>,
type_: DOMString,
init: &EventBinding::EventInit) -> Fallible<Temporary<Event>> {
let mut ev = Event::new(global).root();
ev.InitEvent(type_, init.bubbles, init.cancelable);
Ok(Temporary::from_rooted(&*ev))
}
}
pub trait EventMethods {
fn EventPhase(&self) -> u16;
fn Type(&self) -> DOMString;
fn GetTarget(&self) -> Option<Temporary<EventTarget>>;
fn GetCurrentTarget(&self) -> Option<Temporary<EventTarget>>;
fn DefaultPrevented(&self) -> bool;
fn PreventDefault(&mut self);
fn StopPropagation(&mut self);
fn StopImmediatePropagation(&mut self);
fn Bubbles(&self) -> bool;
fn Cancelable(&self) -> bool;
fn TimeStamp(&self) -> u64;
fn InitEvent(&mut self, type_: DOMString, bubbles: bool, cancelable: bool);
fn IsTrusted(&self) -> bool;
}
impl<'a> EventMethods for JSRef<'a, Event> {
fn EventPhase(&self) -> u16 {
self.phase as u16 self.phase as u16
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
self.type_.clone() self.type_.clone()
} }
pub fn GetTarget(&self) -> Option<JS<EventTarget>> { fn GetTarget(&self) -> Option<Temporary<EventTarget>> {
self.target.clone() self.target.as_ref().map(|target| Temporary::new(target.clone()))
} }
pub fn GetCurrentTarget(&self) -> Option<JS<EventTarget>> { fn GetCurrentTarget(&self) -> Option<Temporary<EventTarget>> {
self.current_target.clone() self.current_target.as_ref().map(|target| Temporary::new(target.clone()))
} }
pub fn DefaultPrevented(&self) -> bool { fn DefaultPrevented(&self) -> bool {
self.canceled self.canceled
} }
pub fn PreventDefault(&mut self) { fn PreventDefault(&mut self) {
if self.cancelable { if self.cancelable {
self.canceled = true self.canceled = true
} }
} }
pub fn StopPropagation(&mut self) { fn StopPropagation(&mut self) {
self.stop_propagation = true; self.stop_propagation = true;
} }
pub fn StopImmediatePropagation(&mut self) { fn StopImmediatePropagation(&mut self) {
self.stop_immediate = true; self.stop_immediate = true;
self.stop_propagation = true; self.stop_propagation = true;
} }
pub fn Bubbles(&self) -> bool { fn Bubbles(&self) -> bool {
self.bubbles self.bubbles
} }
pub fn Cancelable(&self) -> bool { fn Cancelable(&self) -> bool {
self.cancelable self.cancelable
} }
pub fn TimeStamp(&self) -> u64 { fn TimeStamp(&self) -> u64 {
self.timestamp self.timestamp
} }
pub fn InitEvent(&mut self, fn InitEvent(&mut self,
type_: DOMString, type_: DOMString,
bubbles: bool, bubbles: bool,
cancelable: bool) { cancelable: bool) {
self.initialized = true; self.initialized = true;
if self.dispatching { if self.dispatching {
return; return;
@ -151,17 +177,9 @@ impl Event {
self.cancelable = cancelable; self.cancelable = cancelable;
} }
pub fn IsTrusted(&self) -> bool { fn IsTrusted(&self) -> bool {
self.trusted self.trusted
} }
pub fn Constructor(global: &JS<Window>,
type_: DOMString,
init: &EventBinding::EventInit) -> Fallible<JS<Event>> {
let mut ev = Event::new(global);
ev.get_mut().InitEvent(type_, init.bubbles, init.cancelable);
Ok(ev)
}
} }
impl Reflectable for Event { impl Reflectable for Event {

View file

@ -4,58 +4,59 @@
use dom::bindings::callback::ReportExceptions; use dom::bindings::callback::ReportExceptions;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, NodeDerived}; use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, NodeDerived};
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, OptionalSettable, Root};
use dom::eventtarget::{Capturing, Bubbling, EventTarget}; use dom::eventtarget::{Capturing, Bubbling, EventTarget};
use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing}; use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing, EventMethods};
use dom::node::{Node, NodeHelpers}; use dom::node::{Node, NodeHelpers};
// See http://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm // See http://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
pub fn dispatch_event(target: &JS<EventTarget>, pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
pseudo_target: Option<JS<EventTarget>>, pseudo_target: Option<JSRef<'b, EventTarget>>,
event: &mut JS<Event>) -> bool { event: &mut JSRef<Event>) -> bool {
assert!(!event.get().dispatching); assert!(!event.deref().dispatching);
{ {
let event = event.get_mut(); let event = event.deref_mut();
event.target = pseudo_target.or_else(|| { event.target.assign(Some(match pseudo_target {
Some(target.clone()) Some(pseudo_target) => pseudo_target,
}); None => target.clone(),
}));
event.dispatching = true; event.dispatching = true;
} }
let type_ = event.get().type_.clone(); let type_ = event.deref().type_.clone();
//TODO: no chain if not participating in a tree //TODO: no chain if not participating in a tree
let chain: Vec<JS<EventTarget>> = if target.get().is_node() { let mut chain: Vec<Root<EventTarget>> = if target.deref().is_node() {
let target_node: JS<Node> = NodeCast::to(target).unwrap(); let target_node: &JSRef<Node> = NodeCast::to_ref(target).unwrap();
target_node.ancestors().map(|ancestor| { target_node.ancestors().map(|ancestor| {
let ancestor_target: JS<EventTarget> = EventTargetCast::from(&ancestor); let ancestor_target: &JSRef<EventTarget> = EventTargetCast::from_ref(&ancestor);
ancestor_target ancestor_target.unrooted().root()
}).collect() }).collect()
} else { } else {
vec!() vec!()
}; };
event.get_mut().phase = PhaseCapturing; event.deref_mut().phase = PhaseCapturing;
//FIXME: The "callback this value" should be currentTarget //FIXME: The "callback this value" should be currentTarget
/* capturing */ /* capturing */
for cur_target in chain.as_slice().rev_iter() { for cur_target in chain.as_slice().rev_iter() {
let stopped = match cur_target.get().get_listeners_for(type_, Capturing) { let stopped = match cur_target.get_listeners_for(type_, Capturing) {
Some(listeners) => { Some(listeners) => {
event.get_mut().current_target = Some(cur_target.clone()); event.current_target.assign(Some(cur_target.deref().clone()));
for listener in listeners.iter() { for listener in listeners.iter() {
//FIXME: this should have proper error handling, or explicitly //FIXME: this should have proper error handling, or explicitly
// drop the exception on the floor // drop the exception on the floor
assert!(listener.HandleEvent__(event, ReportExceptions).is_ok()); assert!(listener.HandleEvent__(event, ReportExceptions).is_ok());
if event.get().stop_immediate { if event.deref().stop_immediate {
break; break;
} }
} }
event.get().stop_propagation event.deref().stop_propagation
} }
None => false None => false
}; };
@ -66,20 +67,20 @@ pub fn dispatch_event(target: &JS<EventTarget>,
} }
/* at target */ /* at target */
if !event.get().stop_propagation { if !event.deref().stop_propagation {
{ {
let event = event.get_mut(); let event = event.deref_mut();
event.phase = PhaseAtTarget; event.phase = PhaseAtTarget;
event.current_target = Some(target.clone()); event.current_target.assign(Some(target.clone()));
} }
let opt_listeners = target.get().get_listeners(type_); let opt_listeners = target.deref().get_listeners(type_);
for listeners in opt_listeners.iter() { for listeners in opt_listeners.iter() {
for listener in listeners.iter() { for listener in listeners.iter() {
//FIXME: this should have proper error handling, or explicitly drop the //FIXME: this should have proper error handling, or explicitly drop the
// exception on the floor. // exception on the floor.
assert!(listener.HandleEvent__(event, ReportExceptions).is_ok()); assert!(listener.HandleEvent__(event, ReportExceptions).is_ok());
if event.get().stop_immediate { if event.deref().stop_immediate {
break; break;
} }
} }
@ -87,24 +88,24 @@ pub fn dispatch_event(target: &JS<EventTarget>,
} }
/* bubbling */ /* bubbling */
if event.get().bubbles && !event.get().stop_propagation { if event.deref().bubbles && !event.deref().stop_propagation {
event.get_mut().phase = PhaseBubbling; event.deref_mut().phase = PhaseBubbling;
for cur_target in chain.iter() { for cur_target in chain.iter() {
let stopped = match cur_target.get().get_listeners_for(type_, Bubbling) { let stopped = match cur_target.deref().get_listeners_for(type_, Bubbling) {
Some(listeners) => { Some(listeners) => {
event.get_mut().current_target = Some(cur_target.clone()); event.deref_mut().current_target.assign(Some(cur_target.deref().clone()));
for listener in listeners.iter() { for listener in listeners.iter() {
//FIXME: this should have proper error handling or explicitly //FIXME: this should have proper error handling or explicitly
// drop exceptions on the floor. // drop exceptions on the floor.
assert!(listener.HandleEvent__(event, ReportExceptions).is_ok()); assert!(listener.HandleEvent__(event, ReportExceptions).is_ok());
if event.get().stop_immediate { if event.deref().stop_immediate {
break; break;
} }
} }
event.get().stop_propagation event.deref().stop_propagation
} }
None => false None => false
}; };
@ -114,7 +115,12 @@ pub fn dispatch_event(target: &JS<EventTarget>,
} }
} }
let event = event.get_mut(); // Root ordering restrictions mean we need to unroot the chain entries
// in the same order they were rooted.
while chain.len() > 0 {
let _ = chain.pop();
}
event.dispatching = false; event.dispatching = false;
event.phase = PhaseNone; event.phase = PhaseNone;
event.current_target = None; event.current_target = None;

View file

@ -2,7 +2,7 @@
* 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::js::JS; use dom::bindings::js::JSRef;
use dom::bindings::utils::{Reflectable, Reflector}; use dom::bindings::utils::{Reflectable, Reflector};
use dom::bindings::error::{Fallible, InvalidState}; use dom::bindings::error::{Fallible, InvalidState};
use dom::bindings::codegen::BindingDeclarations::EventListenerBinding; use dom::bindings::codegen::BindingDeclarations::EventListenerBinding;
@ -64,11 +64,42 @@ impl EventTarget {
filtered.map(|entry| entry.listener).collect() filtered.map(|entry| entry.listener).collect()
}) })
} }
}
pub fn AddEventListener(&mut self, pub trait EventTargetHelpers {
ty: DOMString, fn dispatch_event_with_target<'a>(&self,
listener: Option<EventListener>, target: Option<JSRef<'a, EventTarget>>,
capture: bool) { event: &mut JSRef<Event>) -> Fallible<bool>;
}
impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
fn dispatch_event_with_target<'b>(&self,
target: Option<JSRef<'b, EventTarget>>,
event: &mut JSRef<Event>) -> Fallible<bool> {
if event.deref().dispatching || !event.deref().initialized {
return Err(InvalidState);
}
Ok(dispatch_event(self, target, event))
}
}
pub trait EventTargetMethods {
fn AddEventListener(&mut self,
ty: DOMString,
listener: Option<EventListener>,
capture: bool);
fn RemoveEventListener(&mut self,
ty: DOMString,
listener: Option<EventListener>,
capture: bool);
fn DispatchEvent(&self, event: &mut JSRef<Event>) -> Fallible<bool>;
}
impl<'a> EventTargetMethods for JSRef<'a, EventTarget> {
fn AddEventListener(&mut self,
ty: DOMString,
listener: Option<EventListener>,
capture: bool) {
for &listener in listener.iter() { for &listener in listener.iter() {
let entry = self.handlers.find_or_insert_with(ty.clone(), |_| vec!()); let entry = self.handlers.find_or_insert_with(ty.clone(), |_| vec!());
let phase = if capture { Capturing } else { Bubbling }; let phase = if capture { Capturing } else { Bubbling };
@ -82,10 +113,10 @@ impl EventTarget {
} }
} }
pub fn RemoveEventListener(&mut self, fn RemoveEventListener(&mut self,
ty: DOMString, ty: DOMString,
listener: Option<EventListener>, listener: Option<EventListener>,
capture: bool) { capture: bool) {
for &listener in listener.iter() { for &listener in listener.iter() {
let mut entry = self.handlers.find_mut(&ty); let mut entry = self.handlers.find_mut(&ty);
for entry in entry.mut_iter() { for entry in entry.mut_iter() {
@ -102,19 +133,8 @@ impl EventTarget {
} }
} }
pub fn DispatchEvent(&self, abstract_self: &JS<EventTarget>, fn DispatchEvent(&self, event: &mut JSRef<Event>) -> Fallible<bool> {
event: &mut JS<Event>) -> Fallible<bool> { self.dispatch_event_with_target(None, event)
self.dispatch_event_with_target(abstract_self, None, event)
}
pub fn dispatch_event_with_target(&self,
abstract_self: &JS<EventTarget>,
abstract_target: Option<JS<EventTarget>>,
event: &mut JS<Event>) -> Fallible<bool> {
if event.get().dispatching || !event.get().initialized {
return Err(InvalidState);
}
Ok(dispatch_event(abstract_self, abstract_target, event))
} }
} }
@ -128,8 +148,8 @@ impl Reflectable for EventTarget {
} }
} }
impl VirtualMethods for JS<EventTarget> { impl<'a> VirtualMethods for JSRef<'a, EventTarget> {
fn super_type(&self) -> Option<~VirtualMethods:> { fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
None None
} }
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::{Fallible}; use dom::bindings::error::{Fallible};
use dom::bindings::codegen::BindingDeclarations::FormDataBinding; use dom::bindings::codegen::BindingDeclarations::FormDataBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary, OptionalUnrootable};
use dom::blob::Blob; use dom::blob::Blob;
use dom::htmlformelement::HTMLFormElement; use dom::htmlformelement::HTMLFormElement;
use dom::window::Window; use dom::window::Window;
@ -28,33 +28,39 @@ pub struct FormData {
} }
impl FormData { impl FormData {
pub fn new_inherited(form: Option<JS<HTMLFormElement>>, window: JS<Window>) -> FormData { pub fn new_inherited(form: Option<JSRef<HTMLFormElement>>, window: &JSRef<Window>) -> FormData {
FormData { FormData {
data: HashMap::new(), data: HashMap::new(),
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: window, window: window.unrooted(),
form: form form: form.unrooted(),
} }
} }
pub fn new(form: Option<JS<HTMLFormElement>>, window: &JS<Window>) -> JS<FormData> { pub fn new(form: Option<JSRef<HTMLFormElement>>, window: &JSRef<Window>) -> Temporary<FormData> {
reflect_dom_object(~FormData::new_inherited(form, window.clone()), window, FormDataBinding::Wrap) reflect_dom_object(~FormData::new_inherited(form, window), window, FormDataBinding::Wrap)
} }
pub fn Constructor(window: &JS<Window>, form: Option<JS<HTMLFormElement>>) pub fn Constructor(window: &JSRef<Window>, form: Option<JSRef<HTMLFormElement>>) -> Fallible<Temporary<FormData>> {
-> Fallible<JS<FormData>> {
Ok(FormData::new(form, window)) Ok(FormData::new(form, window))
} }
}
pub fn Append(&mut self, name: DOMString, value: &JS<Blob>, filename: Option<DOMString>) { pub trait FormDataMethods {
fn Append(&mut self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>);
fn Append_(&mut self, name: DOMString, value: DOMString);
}
impl<'a> FormDataMethods for JSRef<'a, FormData> {
fn Append(&mut self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) {
let blob = BlobData { let blob = BlobData {
blob: value.clone(), blob: value.unrooted(),
name: filename.unwrap_or(~"default") name: filename.unwrap_or(~"default")
}; };
self.data.insert(name.clone(), blob); self.data.insert(name.clone(), blob);
} }
pub fn Append_(&mut self, name: DOMString, value: DOMString) { fn Append_(&mut self, name: DOMString, value: DOMString) {
self.data.insert(name, StringData(value)); self.data.insert(name, StringData(value));
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLAnchorElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLAnchorElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementDerived; use dom::bindings::codegen::InheritTypes::HTMLAnchorElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLAnchorElementTypeId; use dom::element::HTMLAnchorElementTypeId;
@ -28,120 +28,149 @@ impl HTMLAnchorElementDerived for EventTarget {
} }
impl HTMLAnchorElement { impl HTMLAnchorElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLAnchorElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAnchorElement {
HTMLAnchorElement { HTMLAnchorElement {
htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLAnchorElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAnchorElement> {
let element = HTMLAnchorElement::new_inherited(localName, document.clone()); let element = HTMLAnchorElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLAnchorElementBinding::Wrap) Node::reflect_node(~element, document, HTMLAnchorElementBinding::Wrap)
} }
} }
impl HTMLAnchorElement { pub trait HTMLAnchorElementMethods {
pub fn Href(&self) -> DOMString { fn Href(&self) -> DOMString;
fn SetHref(&mut self, _href: DOMString) -> ErrorResult;
fn Target(&self) -> DOMString;
fn SetTarget(&self, _target: DOMString) -> ErrorResult;
fn Download(&self) -> DOMString;
fn SetDownload(&self, _download: DOMString) -> ErrorResult;
fn Ping(&self) -> DOMString;
fn SetPing(&self, _ping: DOMString) -> ErrorResult;
fn Rel(&self) -> DOMString;
fn SetRel(&self, _rel: DOMString) -> ErrorResult;
fn Hreflang(&self) -> DOMString;
fn SetHreflang(&self, _href_lang: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Text(&self) -> DOMString;
fn SetText(&mut self, _text: DOMString) -> ErrorResult;
fn Coords(&self) -> DOMString;
fn SetCoords(&mut self, _coords: DOMString) -> ErrorResult;
fn Charset(&self) -> DOMString;
fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Rev(&self) -> DOMString;
fn SetRev(&mut self, _rev: DOMString) -> ErrorResult;
fn Shape(&self) -> DOMString;
fn SetShape(&mut self, _shape: DOMString) -> ErrorResult;
}
impl<'a> HTMLAnchorElementMethods for JSRef<'a, HTMLAnchorElement> {
fn Href(&self) -> DOMString {
~"" ~""
} }
pub fn SetHref(&mut self, _href: DOMString) -> ErrorResult { fn SetHref(&mut self, _href: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Target(&self) -> DOMString { fn Target(&self) -> DOMString {
~"" ~""
} }
pub fn SetTarget(&self, _target: DOMString) -> ErrorResult { fn SetTarget(&self, _target: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Download(&self) -> DOMString { fn Download(&self) -> DOMString {
~"" ~""
} }
pub fn SetDownload(&self, _download: DOMString) -> ErrorResult { fn SetDownload(&self, _download: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Ping(&self) -> DOMString { fn Ping(&self) -> DOMString {
~"" ~""
} }
pub fn SetPing(&self, _ping: DOMString) -> ErrorResult { fn SetPing(&self, _ping: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Rel(&self) -> DOMString { fn Rel(&self) -> DOMString {
~"" ~""
} }
pub fn SetRel(&self, _rel: DOMString) -> ErrorResult { fn SetRel(&self, _rel: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Hreflang(&self) -> DOMString { fn Hreflang(&self) -> DOMString {
~"" ~""
} }
pub fn SetHreflang(&self, _href_lang: DOMString) -> ErrorResult { fn SetHreflang(&self, _href_lang: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Text(&self) -> DOMString { fn Text(&self) -> DOMString {
~"" ~""
} }
pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { fn SetText(&mut self, _text: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Coords(&self) -> DOMString { fn Coords(&self) -> DOMString {
~"" ~""
} }
pub fn SetCoords(&mut self, _coords: DOMString) -> ErrorResult { fn SetCoords(&mut self, _coords: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Charset(&self) -> DOMString { fn Charset(&self) -> DOMString {
~"" ~""
} }
pub fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Rev(&self) -> DOMString { fn Rev(&self) -> DOMString {
~"" ~""
} }
pub fn SetRev(&mut self, _rev: DOMString) -> ErrorResult { fn SetRev(&mut self, _rev: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Shape(&self) -> DOMString { fn Shape(&self) -> DOMString {
~"" ~""
} }
pub fn SetShape(&mut self, _shape: DOMString) -> ErrorResult { fn SetShape(&mut self, _shape: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLAppletElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLAppletElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLAppletElementDerived; use dom::bindings::codegen::InheritTypes::HTMLAppletElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLAppletElementTypeId; use dom::element::HTMLAppletElementTypeId;
@ -28,104 +28,129 @@ impl HTMLAppletElementDerived for EventTarget {
} }
impl HTMLAppletElement { impl HTMLAppletElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLAppletElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAppletElement {
HTMLAppletElement { HTMLAppletElement {
htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLAppletElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAppletElement> {
let element = HTMLAppletElement::new_inherited(localName, document.clone()); let element = HTMLAppletElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLAppletElementBinding::Wrap) Node::reflect_node(~element, document, HTMLAppletElementBinding::Wrap)
} }
} }
impl HTMLAppletElement { pub trait HTMLAppletElementMethods {
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
fn Alt(&self) -> DOMString;
fn SetAlt(&self, _alt: DOMString) -> ErrorResult;
fn Archive(&self) -> DOMString;
fn SetArchive(&self, _archive: DOMString) -> ErrorResult;
fn Code(&self) -> DOMString;
fn SetCode(&self, _code: DOMString) -> ErrorResult;
fn CodeBase(&self) -> DOMString;
fn SetCodeBase(&self, _code_base: DOMString) -> ErrorResult;
fn Height(&self) -> DOMString;
fn SetHeight(&self, _height: DOMString) -> ErrorResult;
fn Hspace(&self) -> u32;
fn SetHspace(&mut self, _hspace: u32) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Object(&self) -> DOMString;
fn SetObject(&mut self, _object: DOMString) -> ErrorResult;
fn Vspace(&self) -> u32;
fn SetVspace(&mut self, _vspace: u32) -> ErrorResult;
fn Width(&self) -> DOMString;
fn SetWidth(&mut self, _width: DOMString) -> ErrorResult;
}
impl<'a> HTMLAppletElementMethods for JSRef<'a, HTMLAppletElement> {
fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Alt(&self) -> DOMString { fn Alt(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlt(&self, _alt: DOMString) -> ErrorResult { fn SetAlt(&self, _alt: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Archive(&self) -> DOMString { fn Archive(&self) -> DOMString {
~"" ~""
} }
pub fn SetArchive(&self, _archive: DOMString) -> ErrorResult { fn SetArchive(&self, _archive: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Code(&self) -> DOMString { fn Code(&self) -> DOMString {
~"" ~""
} }
pub fn SetCode(&self, _code: DOMString) -> ErrorResult { fn SetCode(&self, _code: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CodeBase(&self) -> DOMString { fn CodeBase(&self) -> DOMString {
~"" ~""
} }
pub fn SetCodeBase(&self, _code_base: DOMString) -> ErrorResult { fn SetCodeBase(&self, _code_base: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Height(&self) -> DOMString { fn Height(&self) -> DOMString {
~"" ~""
} }
pub fn SetHeight(&self, _height: DOMString) -> ErrorResult { fn SetHeight(&self, _height: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Hspace(&self) -> u32 { fn Hspace(&self) -> u32 {
0 0
} }
pub fn SetHspace(&mut self, _hspace: u32) -> ErrorResult { fn SetHspace(&mut self, _hspace: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Object(&self) -> DOMString { fn Object(&self) -> DOMString {
~"" ~""
} }
pub fn SetObject(&mut self, _object: DOMString) -> ErrorResult { fn SetObject(&mut self, _object: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Vspace(&self) -> u32 { fn Vspace(&self) -> u32 {
0 0
} }
pub fn SetVspace(&mut self, _vspace: u32) -> ErrorResult { fn SetVspace(&mut self, _vspace: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { fn SetWidth(&mut self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLAreaElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLAreaElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLAreaElementDerived; use dom::bindings::codegen::InheritTypes::HTMLAreaElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLAreaElementTypeId; use dom::element::HTMLAreaElementTypeId;
@ -28,80 +28,99 @@ impl HTMLAreaElementDerived for EventTarget {
} }
impl HTMLAreaElement { impl HTMLAreaElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLAreaElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAreaElement {
HTMLAreaElement { HTMLAreaElement {
htmlelement: HTMLElement::new_inherited(HTMLAreaElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLAreaElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLAreaElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAreaElement> {
let element = HTMLAreaElement::new_inherited(localName, document.clone()); let element = HTMLAreaElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLAreaElementBinding::Wrap) Node::reflect_node(~element, document, HTMLAreaElementBinding::Wrap)
} }
} }
impl HTMLAreaElement { pub trait HTMLAreaElementMethods {
pub fn Alt(&self) -> DOMString { fn Alt(&self) -> DOMString;
fn SetAlt(&self, _alt: DOMString) -> ErrorResult;
fn Coords(&self) -> DOMString;
fn SetCoords(&self, _coords: DOMString) -> ErrorResult;
fn Shape(&self) -> DOMString;
fn SetShape(&self, _shape: DOMString) -> ErrorResult;
fn Href(&self) -> DOMString;
fn SetHref(&self, _href: DOMString) -> ErrorResult;
fn Target(&self) -> DOMString;
fn SetTarget(&self, _target: DOMString) -> ErrorResult;
fn Download(&self) -> DOMString;
fn SetDownload(&self, _download: DOMString) -> ErrorResult;
fn Ping(&self) -> DOMString;
fn SetPing(&self, _ping: DOMString) -> ErrorResult;
fn NoHref(&self) -> bool;
fn SetNoHref(&mut self, _no_href: bool) -> ErrorResult;
}
impl<'a> HTMLAreaElementMethods for JSRef<'a, HTMLAreaElement> {
fn Alt(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlt(&self, _alt: DOMString) -> ErrorResult { fn SetAlt(&self, _alt: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Coords(&self) -> DOMString { fn Coords(&self) -> DOMString {
~"" ~""
} }
pub fn SetCoords(&self, _coords: DOMString) -> ErrorResult { fn SetCoords(&self, _coords: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Shape(&self) -> DOMString { fn Shape(&self) -> DOMString {
~"" ~""
} }
pub fn SetShape(&self, _shape: DOMString) -> ErrorResult { fn SetShape(&self, _shape: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Href(&self) -> DOMString { fn Href(&self) -> DOMString {
~"" ~""
} }
pub fn SetHref(&self, _href: DOMString) -> ErrorResult { fn SetHref(&self, _href: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Target(&self) -> DOMString { fn Target(&self) -> DOMString {
~"" ~""
} }
pub fn SetTarget(&self, _target: DOMString) -> ErrorResult { fn SetTarget(&self, _target: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Download(&self) -> DOMString { fn Download(&self) -> DOMString {
~"" ~""
} }
pub fn SetDownload(&self, _download: DOMString) -> ErrorResult { fn SetDownload(&self, _download: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Ping(&self) -> DOMString { fn Ping(&self) -> DOMString {
~"" ~""
} }
pub fn SetPing(&self, _ping: DOMString) -> ErrorResult { fn SetPing(&self, _ping: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn NoHref(&self) -> bool { fn NoHref(&self) -> bool {
false false
} }
pub fn SetNoHref(&mut self, _no_href: bool) -> ErrorResult { fn SetNoHref(&mut self, _no_href: bool) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLAudioElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLAudioElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLAudioElementDerived; use dom::bindings::codegen::InheritTypes::HTMLAudioElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLAudioElementTypeId; use dom::element::HTMLAudioElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLAudioElementDerived for EventTarget {
} }
impl HTMLAudioElement { impl HTMLAudioElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLAudioElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAudioElement {
HTMLAudioElement { HTMLAudioElement {
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLAudioElementTypeId, localName, document) htmlmediaelement: HTMLMediaElement::new_inherited(HTMLAudioElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLAudioElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAudioElement> {
let element = HTMLAudioElement::new_inherited(localName, document.clone()); let element = HTMLAudioElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLAudioElementBinding::Wrap) Node::reflect_node(~element, document, HTMLAudioElementBinding::Wrap)
} }
} }
pub trait HTMLAudioElementMethods {
}

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLBaseElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLBaseElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBaseElementDerived; use dom::bindings::codegen::InheritTypes::HTMLBaseElementDerived;
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLBaseElementTypeId; use dom::element::HTMLBaseElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -28,32 +28,39 @@ impl HTMLBaseElementDerived for EventTarget {
} }
impl HTMLBaseElement { impl HTMLBaseElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLBaseElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBaseElement {
HTMLBaseElement { HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(HTMLBaseElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLBaseElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLBaseElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, document.clone()); let element = HTMLBaseElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLBaseElementBinding::Wrap) Node::reflect_node(~element, document, HTMLBaseElementBinding::Wrap)
} }
} }
impl HTMLBaseElement { pub trait HTMLBaseElementMethods {
pub fn Href(&self) -> DOMString { fn Href(&self) -> DOMString;
fn SetHref(&self, _href: DOMString) -> ErrorResult;
fn Target(&self) -> DOMString;
fn SetTarget(&self, _target: DOMString) -> ErrorResult;
}
impl<'a> HTMLBaseElementMethods for JSRef<'a, HTMLBaseElement> {
fn Href(&self) -> DOMString {
~"" ~""
} }
pub fn SetHref(&self, _href: DOMString) -> ErrorResult { fn SetHref(&self, _href: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Target(&self) -> DOMString { fn Target(&self) -> DOMString {
~"" ~""
} }
pub fn SetTarget(&self, _target: DOMString) -> ErrorResult { fn SetTarget(&self, _target: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLBodyElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLBodyElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBodyElementDerived; use dom::bindings::codegen::InheritTypes::HTMLBodyElementDerived;
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLBodyElementTypeId; use dom::element::HTMLBodyElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -28,64 +28,79 @@ impl HTMLBodyElementDerived for EventTarget {
} }
impl HTMLBodyElement { impl HTMLBodyElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLBodyElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBodyElement {
HTMLBodyElement { HTMLBodyElement {
htmlelement: HTMLElement::new_inherited(HTMLBodyElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLBodyElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLBodyElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBodyElement> {
let element = HTMLBodyElement::new_inherited(localName, document.clone()); let element = HTMLBodyElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLBodyElementBinding::Wrap) Node::reflect_node(~element, document, HTMLBodyElementBinding::Wrap)
} }
} }
impl HTMLBodyElement { pub trait HTMLBodyElementMethods {
pub fn Text(&self) -> DOMString { fn Text(&self) -> DOMString;
fn SetText(&mut self, _text: DOMString) -> ErrorResult;
fn Link(&self) -> DOMString;
fn SetLink(&self, _link: DOMString) -> ErrorResult;
fn VLink(&self) -> DOMString;
fn SetVLink(&self, _v_link: DOMString) -> ErrorResult;
fn ALink(&self) -> DOMString;
fn SetALink(&self, _a_link: DOMString) -> ErrorResult;
fn BgColor(&self) -> DOMString;
fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult;
fn Background(&self) -> DOMString;
fn SetBackground(&self, _background: DOMString) -> ErrorResult;
}
impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
fn Text(&self) -> DOMString {
~"" ~""
} }
pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { fn SetText(&mut self, _text: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Link(&self) -> DOMString { fn Link(&self) -> DOMString {
~"" ~""
} }
pub fn SetLink(&self, _link: DOMString) -> ErrorResult { fn SetLink(&self, _link: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn VLink(&self) -> DOMString { fn VLink(&self) -> DOMString {
~"" ~""
} }
pub fn SetVLink(&self, _v_link: DOMString) -> ErrorResult { fn SetVLink(&self, _v_link: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ALink(&self) -> DOMString { fn ALink(&self) -> DOMString {
~"" ~""
} }
pub fn SetALink(&self, _a_link: DOMString) -> ErrorResult { fn SetALink(&self, _a_link: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn BgColor(&self) -> DOMString { fn BgColor(&self) -> DOMString {
~"" ~""
} }
pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Background(&self) -> DOMString { fn Background(&self) -> DOMString {
~"" ~""
} }
pub fn SetBackground(&self, _background: DOMString) -> ErrorResult { fn SetBackground(&self, _background: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLBRElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLBRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBRElementDerived; use dom::bindings::codegen::InheritTypes::HTMLBRElementDerived;
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLBRElementTypeId; use dom::element::HTMLBRElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -28,24 +28,29 @@ impl HTMLBRElementDerived for EventTarget {
} }
impl HTMLBRElement { impl HTMLBRElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLBRElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBRElement {
HTMLBRElement { HTMLBRElement {
htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLBRElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBRElement> {
let element = HTMLBRElement::new_inherited(localName, document.clone()); let element = HTMLBRElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLBRElementBinding::Wrap) Node::reflect_node(~element, document, HTMLBRElementBinding::Wrap)
} }
} }
impl HTMLBRElement { pub trait HTMLBRElementMethods {
pub fn Clear(&self) -> DOMString { fn Clear(&self) -> DOMString;
fn SetClear(&mut self, _text: DOMString) -> ErrorResult;
}
impl<'a> HTMLBRElementMethods for JSRef<'a, HTMLBRElement> {
fn Clear(&self) -> DOMString {
~"" ~""
} }
pub fn SetClear(&mut self, _text: DOMString) -> ErrorResult { fn SetClear(&mut self, _text: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,14 +4,14 @@
use dom::bindings::codegen::BindingDeclarations::HTMLButtonElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLButtonElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLButtonElementDerived; use dom::bindings::codegen::InheritTypes::HTMLButtonElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLButtonElementTypeId; use dom::element::HTMLButtonElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::htmlformelement::HTMLFormElement; use dom::htmlformelement::HTMLFormElement;
use dom::node::{Node, ElementNodeTypeId}; use dom::node::{Node, ElementNodeTypeId, window_from_node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
use servo_util::str::DOMString; use servo_util::str::DOMString;
@ -30,131 +30,158 @@ impl HTMLButtonElementDerived for EventTarget {
} }
impl HTMLButtonElement { impl HTMLButtonElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLButtonElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLButtonElement {
HTMLButtonElement { HTMLButtonElement {
htmlelement: HTMLElement::new_inherited(HTMLButtonElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLButtonElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLButtonElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLButtonElement> {
let element = HTMLButtonElement::new_inherited(localName, document.clone()); let element = HTMLButtonElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLButtonElementBinding::Wrap) Node::reflect_node(~element, document, HTMLButtonElementBinding::Wrap)
} }
} }
impl HTMLButtonElement { pub trait HTMLButtonElementMethods {
pub fn Autofocus(&self) -> bool { fn Autofocus(&self) -> bool;
fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult;
fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult;
fn GetForm(&self) -> Option<Temporary<HTMLFormElement>>;
fn FormAction(&self) -> DOMString;
fn SetFormAction(&mut self, _formaction: DOMString) -> ErrorResult;
fn FormEnctype(&self) -> DOMString;
fn SetFormEnctype(&mut self, _formenctype: DOMString) -> ErrorResult;
fn FormMethod(&self) -> DOMString;
fn SetFormMethod(&mut self, _formmethod: DOMString) -> ErrorResult;
fn FormNoValidate(&self) -> bool;
fn SetFormNoValidate(&mut self, _novalidate: bool) -> ErrorResult;
fn FormTarget(&self) -> DOMString;
fn SetFormTarget(&mut self, _formtarget: DOMString) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString) -> ErrorResult;
fn WillValidate(&self) -> bool;
fn SetWillValidate(&mut self, _will_validate: bool);
fn Validity(&self) -> Temporary<ValidityState>;
fn ValidationMessage(&self) -> DOMString;
fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult;
fn CheckValidity(&self) -> bool;
fn SetCustomValidity(&mut self, _error: DOMString);
}
impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> {
fn Autofocus(&self) -> bool {
false false
} }
pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<JS<HTMLFormElement>> { fn GetForm(&self) -> Option<Temporary<HTMLFormElement>> {
None None
} }
pub fn FormAction(&self) -> DOMString { fn FormAction(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormAction(&mut self, _formaction: DOMString) -> ErrorResult { fn SetFormAction(&mut self, _formaction: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormEnctype(&self) -> DOMString { fn FormEnctype(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormEnctype(&mut self, _formenctype: DOMString) -> ErrorResult { fn SetFormEnctype(&mut self, _formenctype: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormMethod(&self) -> DOMString { fn FormMethod(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormMethod(&mut self, _formmethod: DOMString) -> ErrorResult { fn SetFormMethod(&mut self, _formmethod: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormNoValidate(&self) -> bool { fn FormNoValidate(&self) -> bool {
false false
} }
pub fn SetFormNoValidate(&mut self, _novalidate: bool) -> ErrorResult { fn SetFormNoValidate(&mut self, _novalidate: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormTarget(&self) -> DOMString { fn FormTarget(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormTarget(&mut self, _formtarget: DOMString) -> ErrorResult { fn SetFormTarget(&mut self, _formtarget: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { fn SetValue(&mut self, _value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn WillValidate(&self) -> bool { fn WillValidate(&self) -> bool {
false false
} }
pub fn SetWillValidate(&mut self, _will_validate: bool) { fn SetWillValidate(&mut self, _will_validate: bool) {
} }
pub fn Validity(&self) -> JS<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let doc = self.htmlelement.element.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); ValidityState::new(&*window)
ValidityState::new(&doc.window)
} }
pub fn SetValidity(&mut self, _validity: JS<ValidityState>) { fn ValidationMessage(&self) -> DOMString {
}
pub fn ValidationMessage(&self) -> DOMString {
~"" ~""
} }
pub fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
true true
} }
pub fn SetCustomValidity(&mut self, _error: DOMString) { fn SetCustomValidity(&mut self, _error: DOMString) {
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLCanvasElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLCanvasElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLCanvasElementDerived; use dom::bindings::codegen::InheritTypes::HTMLCanvasElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::{ErrorResult}; use dom::bindings::error::{ErrorResult};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLCanvasElementTypeId; use dom::element::HTMLCanvasElementTypeId;
@ -28,32 +28,39 @@ impl HTMLCanvasElementDerived for EventTarget {
} }
impl HTMLCanvasElement { impl HTMLCanvasElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLCanvasElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLCanvasElement {
HTMLCanvasElement { HTMLCanvasElement {
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLCanvasElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLCanvasElement> {
let element = HTMLCanvasElement::new_inherited(localName, document.clone()); let element = HTMLCanvasElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLCanvasElementBinding::Wrap) Node::reflect_node(~element, document, HTMLCanvasElementBinding::Wrap)
} }
} }
impl HTMLCanvasElement { pub trait HTMLCanvasElementMethods {
pub fn Width(&self) -> u32 { fn Width(&self) -> u32;
fn SetWidth(&mut self, _width: u32) -> ErrorResult;
fn Height(&self) -> u32;
fn SetHeight(&mut self, _height: u32) -> ErrorResult;
}
impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
fn Width(&self) -> u32 {
0 0
} }
pub fn SetWidth(&mut self, _width: u32) -> ErrorResult { fn SetWidth(&mut self, _width: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Height(&self) -> u32 { fn Height(&self) -> u32 {
0 0
} }
pub fn SetHeight(&mut self, _height: u32) -> ErrorResult { fn SetHeight(&mut self, _height: u32) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::InheritTypes::{ElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, NodeCast};
use dom::bindings::codegen::BindingDeclarations::HTMLCollectionBinding; use dom::bindings::codegen::BindingDeclarations::HTMLCollectionBinding;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::element::{Element, AttributeHandlers}; use dom::element::{Element, AttributeHandlers};
use dom::node::{Node, NodeHelpers}; use dom::node::{Node, NodeHelpers};
@ -15,7 +15,7 @@ use servo_util::str::{DOMString, split_html_space_chars};
use serialize::{Encoder, Encodable}; use serialize::{Encoder, Encodable};
pub trait CollectionFilter { pub trait CollectionFilter {
fn filter(&self, elem: &JS<Element>, root: &JS<Node>) -> bool; fn filter(&self, elem: &JSRef<Element>, root: &JSRef<Node>) -> bool;
} }
impl<S: Encoder<E>, E> Encodable<S, E> for ~CollectionFilter { impl<S: Encoder<E>, E> Encodable<S, E> for ~CollectionFilter {
@ -38,33 +38,33 @@ pub struct HTMLCollection {
} }
impl HTMLCollection { impl HTMLCollection {
pub fn new_inherited(window: JS<Window>, collection: CollectionTypeId) -> HTMLCollection { pub fn new_inherited(window: &JSRef<Window>, collection: CollectionTypeId) -> HTMLCollection {
HTMLCollection { HTMLCollection {
collection: collection, collection: collection,
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: window, window: window.unrooted(),
} }
} }
pub fn new(window: &JS<Window>, collection: CollectionTypeId) -> JS<HTMLCollection> { pub fn new(window: &JSRef<Window>, collection: CollectionTypeId) -> Temporary<HTMLCollection> {
reflect_dom_object(~HTMLCollection::new_inherited(window.clone(), collection), reflect_dom_object(~HTMLCollection::new_inherited(window, collection),
window, HTMLCollectionBinding::Wrap) window, HTMLCollectionBinding::Wrap)
} }
} }
impl HTMLCollection { impl HTMLCollection {
pub fn create(window: &JS<Window>, root: &JS<Node>, filter: ~CollectionFilter) -> JS<HTMLCollection> { pub fn create(window: &JSRef<Window>, root: &JSRef<Node>, filter: ~CollectionFilter) -> Temporary<HTMLCollection> {
HTMLCollection::new(window, Live(root.clone(), filter)) HTMLCollection::new(window, Live(root.unrooted(), filter))
} }
pub fn by_tag_name(window: &JS<Window>, root: &JS<Node>, tag: DOMString) pub fn by_tag_name(window: &JSRef<Window>, root: &JSRef<Node>, tag: DOMString)
-> JS<HTMLCollection> { -> Temporary<HTMLCollection> {
struct TagNameFilter { struct TagNameFilter {
tag: DOMString tag: DOMString
} }
impl CollectionFilter for TagNameFilter { impl CollectionFilter for TagNameFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == self.tag elem.deref().local_name == self.tag
} }
} }
let filter = TagNameFilter { let filter = TagNameFilter {
@ -73,15 +73,15 @@ impl HTMLCollection {
HTMLCollection::create(window, root, ~filter) HTMLCollection::create(window, root, ~filter)
} }
pub fn by_tag_name_ns(window: &JS<Window>, root: &JS<Node>, tag: DOMString, pub fn by_tag_name_ns(window: &JSRef<Window>, root: &JSRef<Node>, tag: DOMString,
namespace: Namespace) -> JS<HTMLCollection> { namespace: Namespace) -> Temporary<HTMLCollection> {
struct TagNameNSFilter { struct TagNameNSFilter {
tag: DOMString, tag: DOMString,
namespace: Namespace namespace: Namespace
} }
impl CollectionFilter for TagNameNSFilter { impl CollectionFilter for TagNameNSFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().namespace == self.namespace && elem.get().local_name == self.tag elem.deref().namespace == self.namespace && elem.deref().local_name == self.tag
} }
} }
let filter = TagNameNSFilter { let filter = TagNameNSFilter {
@ -91,13 +91,13 @@ impl HTMLCollection {
HTMLCollection::create(window, root, ~filter) HTMLCollection::create(window, root, ~filter)
} }
pub fn by_class_name(window: &JS<Window>, root: &JS<Node>, classes: DOMString) pub fn by_class_name(window: &JSRef<Window>, root: &JSRef<Node>, classes: DOMString)
-> JS<HTMLCollection> { -> Temporary<HTMLCollection> {
struct ClassNameFilter { struct ClassNameFilter {
classes: Vec<DOMString> classes: Vec<DOMString>
} }
impl CollectionFilter for ClassNameFilter { impl CollectionFilter for ClassNameFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
self.classes.iter().all(|class| elem.has_class(*class)) self.classes.iter().all(|class| elem.has_class(*class))
} }
} }
@ -107,46 +107,65 @@ impl HTMLCollection {
HTMLCollection::create(window, root, ~filter) HTMLCollection::create(window, root, ~filter)
} }
pub fn children(window: &JS<Window>, root: &JS<Node>) -> JS<HTMLCollection> { pub fn children(window: &JSRef<Window>, root: &JSRef<Node>) -> Temporary<HTMLCollection> {
struct ElementChildFilter; struct ElementChildFilter;
impl CollectionFilter for ElementChildFilter { impl CollectionFilter for ElementChildFilter {
fn filter(&self, elem: &JS<Element>, root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, root: &JSRef<Node>) -> bool {
root.is_parent_of(&NodeCast::from(elem)) root.is_parent_of(NodeCast::from_ref(elem))
} }
} }
HTMLCollection::create(window, root, ~ElementChildFilter) HTMLCollection::create(window, root, ~ElementChildFilter)
} }
} }
impl HTMLCollection { pub trait HTMLCollectionMethods {
fn Length(&self) -> u32;
fn Item(&self, index: u32) -> Option<Temporary<Element>>;
fn NamedItem(&self, key: DOMString) -> Option<Temporary<Element>>;
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<Element>>;
fn NamedGetter(&self, maybe_name: Option<DOMString>, found: &mut bool) -> Option<Temporary<Element>>;
}
impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
// http://dom.spec.whatwg.org/#dom-htmlcollection-length // http://dom.spec.whatwg.org/#dom-htmlcollection-length
pub fn Length(&self) -> u32 { fn Length(&self) -> u32 {
match self.collection { match self.collection {
Static(ref elems) => elems.len() as u32, Static(ref elems) => elems.len() as u32,
Live(ref root, ref filter) => root.traverse_preorder() Live(ref root, ref filter) => {
.count(|child| { let root = root.root();
let elem: Option<JS<Element>> = ElementCast::to(&child); root.deref().traverse_preorder()
elem.map_or(false, |elem| filter.filter(&elem, root)) .count(|child| {
}) as u32 let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&child);
elem.map_or(false, |elem| filter.filter(elem, &*root))
}) as u32
}
} }
} }
// http://dom.spec.whatwg.org/#dom-htmlcollection-item // http://dom.spec.whatwg.org/#dom-htmlcollection-item
pub fn Item(&self, index: u32) -> Option<JS<Element>> { fn Item(&self, index: u32) -> Option<Temporary<Element>> {
match self.collection { match self.collection {
Static(ref elems) => elems Static(ref elems) => elems
.as_slice() .as_slice()
.get(index as uint) .get(index as uint)
.map(|elem| elem.clone()), .map(|elem| Temporary::new(elem.clone())),
Live(ref root, ref filter) => root.traverse_preorder() Live(ref root, ref filter) => {
.filter_map(|node| ElementCast::to(&node)) let root = root.root();
.filter(|elem| filter.filter(elem, root)) root.deref().traverse_preorder()
.nth(index as uint).clone() .filter_map(|node| {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node);
elem.filtered(|&elem| filter.filter(elem, &*root))
.map(|elem| elem.clone())
})
.nth(index as uint)
.clone()
.map(|elem| Temporary::from_rooted(&elem))
}
} }
} }
// http://dom.spec.whatwg.org/#dom-htmlcollection-nameditem // http://dom.spec.whatwg.org/#dom-htmlcollection-nameditem
pub fn NamedItem(&self, key: DOMString) -> Option<JS<Element>> { fn NamedItem(&self, key: DOMString) -> Option<Temporary<Element>> {
// Step 1. // Step 1.
if key.is_empty() { if key.is_empty() {
return None; return None;
@ -155,29 +174,34 @@ impl HTMLCollection {
// Step 2. // Step 2.
match self.collection { match self.collection {
Static(ref elems) => elems.iter() Static(ref elems) => elems.iter()
.map(|elem| elem.root())
.find(|elem| { .find(|elem| {
elem.get_string_attribute("name") == key || elem.get_string_attribute("name") == key ||
elem.get_string_attribute("id") == key }) elem.get_string_attribute("id") == key })
.map(|maybe_elem| maybe_elem.clone()), .map(|maybe_elem| Temporary::from_rooted(&*maybe_elem)),
Live(ref root, ref filter) => root.traverse_preorder() Live(ref root, ref filter) => {
.filter_map(|node| ElementCast::to(&node)) let root = root.root();
.filter(|elem| filter.filter(elem, root)) root.deref().traverse_preorder()
.find(|elem| { .filter_map(|node| {
elem.get_string_attribute("name") == key || let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node);
elem.get_string_attribute("id") == key }) elem.filtered(|&elem| filter.filter(elem, &*root))
.map(|maybe_elem| maybe_elem.clone()) .map(|elem| elem.clone())
})
.find(|elem| {
elem.get_string_attribute("name") == key ||
elem.get_string_attribute("id") == key })
.map(|maybe_elem| Temporary::from_rooted(&maybe_elem))
}
} }
} }
}
impl HTMLCollection { fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<Element>> {
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<JS<Element>> {
let maybe_elem = self.Item(index); let maybe_elem = self.Item(index);
*found = maybe_elem.is_some(); *found = maybe_elem.is_some();
maybe_elem maybe_elem
} }
pub fn NamedGetter(&self, maybe_name: Option<DOMString>, found: &mut bool) -> Option<JS<Element>> { fn NamedGetter(&self, maybe_name: Option<DOMString>, found: &mut bool) -> Option<Temporary<Element>> {
match maybe_name { match maybe_name {
Some(name) => { Some(name) => {
let maybe_elem = self.NamedItem(name); let maybe_elem = self.NamedItem(name);

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLDataElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLDataElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLDataElementDerived; use dom::bindings::codegen::InheritTypes::HTMLDataElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLDataElementTypeId; use dom::element::HTMLDataElementTypeId;
@ -28,24 +28,29 @@ impl HTMLDataElementDerived for EventTarget {
} }
impl HTMLDataElement { impl HTMLDataElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLDataElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDataElement {
HTMLDataElement { HTMLDataElement {
htmlelement: HTMLElement::new_inherited(HTMLDataElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDataElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLDataElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDataElement> {
let element = HTMLDataElement::new_inherited(localName, document.clone()); let element = HTMLDataElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLDataElementBinding::Wrap) Node::reflect_node(~element, document, HTMLDataElementBinding::Wrap)
} }
} }
impl HTMLDataElement { pub trait HTMLDataElementMethods {
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString) -> ErrorResult;
}
impl<'a> HTMLDataElementMethods for JSRef<'a, HTMLDataElement> {
fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { fn SetValue(&mut self, _value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLDataListElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLDataListElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLDataListElementDerived, NodeCast}; use dom::bindings::codegen::InheritTypes::{HTMLDataListElementDerived, NodeCast};
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, HTMLDataListElementTypeId}; use dom::element::{Element, HTMLDataListElementTypeId};
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -28,28 +28,33 @@ impl HTMLDataListElementDerived for EventTarget {
} }
impl HTMLDataListElement { impl HTMLDataListElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLDataListElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDataListElement {
HTMLDataListElement { HTMLDataListElement {
htmlelement: HTMLElement::new_inherited(HTMLDataListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDataListElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLDataListElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDataListElement> {
let element = HTMLDataListElement::new_inherited(localName, document.clone()); let element = HTMLDataListElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLDataListElementBinding::Wrap) Node::reflect_node(~element, document, HTMLDataListElementBinding::Wrap)
} }
} }
impl HTMLDataListElement { pub trait HTMLDataListElementMethods {
pub fn Options(&self, abstract_self: &JS<HTMLDataListElement>) -> JS<HTMLCollection> { fn Options(&self) -> Temporary<HTMLCollection>;
}
impl<'a> HTMLDataListElementMethods for JSRef<'a, HTMLDataListElement> {
fn Options(&self) -> Temporary<HTMLCollection> {
struct HTMLDataListOptionsFilter; struct HTMLDataListOptionsFilter;
impl CollectionFilter for HTMLDataListOptionsFilter { impl CollectionFilter for HTMLDataListOptionsFilter {
fn filter(&self, elem: &JS<Element>, _root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool {
elem.get().local_name == ~"option" elem.deref().local_name == ~"option"
} }
} }
let node: JS<Node> = NodeCast::from(abstract_self); let node: &JSRef<Node> = NodeCast::from_ref(self);
let filter = ~HTMLDataListOptionsFilter; let filter = ~HTMLDataListOptionsFilter;
HTMLCollection::create(&window_from_node(&node), &node, filter) let window = window_from_node(node).root();
HTMLCollection::create(&*window, node, filter)
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLDirectoryElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLDirectoryElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLDirectoryElementDerived; use dom::bindings::codegen::InheritTypes::HTMLDirectoryElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLDirectoryElementTypeId; use dom::element::HTMLDirectoryElementTypeId;
@ -28,24 +28,29 @@ impl HTMLDirectoryElementDerived for EventTarget {
} }
impl HTMLDirectoryElement { impl HTMLDirectoryElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLDirectoryElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDirectoryElement {
HTMLDirectoryElement { HTMLDirectoryElement {
htmlelement: HTMLElement::new_inherited(HTMLDirectoryElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDirectoryElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLDirectoryElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDirectoryElement> {
let element = HTMLDirectoryElement::new_inherited(localName, document.clone()); let element = HTMLDirectoryElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLDirectoryElementBinding::Wrap) Node::reflect_node(~element, document, HTMLDirectoryElementBinding::Wrap)
} }
} }
impl HTMLDirectoryElement { pub trait HTMLDirectoryElementMethods {
pub fn Compact(&self) -> bool { fn Compact(&self) -> bool;
fn SetCompact(&mut self, _compact: bool) -> ErrorResult;
}
impl<'a> HTMLDirectoryElementMethods for JSRef<'a, HTMLDirectoryElement> {
fn Compact(&self) -> bool {
false false
} }
pub fn SetCompact(&mut self, _compact: bool) -> ErrorResult { fn SetCompact(&mut self, _compact: bool) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLDivElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLDivElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLDivElementDerived; use dom::bindings::codegen::InheritTypes::HTMLDivElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLDivElementTypeId; use dom::element::HTMLDivElementTypeId;
@ -28,24 +28,29 @@ impl HTMLDivElementDerived for EventTarget {
} }
impl HTMLDivElement { impl HTMLDivElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLDivElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDivElement {
HTMLDivElement { HTMLDivElement {
htmlelement: HTMLElement::new_inherited(HTMLDivElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDivElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLDivElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDivElement> {
let element = HTMLDivElement::new_inherited(localName, document.clone()); let element = HTMLDivElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLDivElementBinding::Wrap) Node::reflect_node(~element, document, HTMLDivElementBinding::Wrap)
} }
} }
impl HTMLDivElement { pub trait HTMLDivElementMethods {
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
}
impl<'a> HTMLDivElementMethods for JSRef<'a, HTMLDivElement> {
fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLDListElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLDListElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLDListElementDerived; use dom::bindings::codegen::InheritTypes::HTMLDListElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLDListElementTypeId; use dom::element::HTMLDListElementTypeId;
@ -28,32 +28,40 @@ impl HTMLDListElementDerived for EventTarget {
} }
impl HTMLDListElement { impl HTMLDListElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLDListElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDListElement {
HTMLDListElement { HTMLDListElement {
htmlelement: HTMLElement::new_inherited(HTMLDListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDListElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLDListElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDListElement> {
let element = HTMLDListElement::new_inherited(localName, document.clone()); let element = HTMLDListElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLDListElementBinding::Wrap) Node::reflect_node(~element, document, HTMLDListElementBinding::Wrap)
} }
} }
impl HTMLDListElement { pub trait HTMLDListElementMethods {
pub fn Compact(&self) -> bool { fn Compact(&self) -> bool;
fn SetCompact(&mut self, _compact: bool) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
}
impl<'a> HTMLDListElementMethods for JSRef<'a, HTMLDListElement> {
fn Compact(&self) -> bool {
false false
} }
pub fn SetCompact(&mut self, _compact: bool) -> ErrorResult { fn SetCompact(&mut self, _compact: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLElementBinding;
use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::ElementCast;
use dom::bindings::codegen::InheritTypes::HTMLElementDerived; use dom::bindings::codegen::InheritTypes::HTMLElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::{ErrorResult, Fallible};
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, ElementTypeId, HTMLElementTypeId}; use dom::element::{Element, ElementTypeId, HTMLElementTypeId};
@ -33,140 +33,173 @@ impl HTMLElementDerived for EventTarget {
} }
impl HTMLElement { impl HTMLElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JS<Document>) -> HTMLElement { pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: &JSRef<Document>) -> HTMLElement {
HTMLElement { HTMLElement {
element: Element::new_inherited(type_id, tag_name, namespace::HTML, None, document) element: Element::new_inherited(type_id, tag_name, namespace::HTML, None, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLElement> {
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document.clone()); let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document);
Node::reflect_node(~element, document, HTMLElementBinding::Wrap) Node::reflect_node(~element, document, HTMLElementBinding::Wrap)
} }
} }
impl HTMLElement { pub trait HTMLElementMethods {
pub fn Title(&self) -> DOMString { fn Title(&self) -> DOMString;
fn SetTitle(&mut self, _title: DOMString);
fn Lang(&self) -> DOMString;
fn SetLang(&mut self, _lang: DOMString);
fn Dir(&self) -> DOMString;
fn SetDir(&mut self, _dir: DOMString) -> ErrorResult;
fn GetItemValue(&self, _cx: *JSContext) -> Fallible<JSVal>;
fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult;
fn Hidden(&self) -> bool;
fn SetHidden(&mut self, _hidden: bool) -> ErrorResult;
fn Click(&self);
fn TabIndex(&self) -> i32;
fn SetTabIndex(&mut self, _index: i32) -> ErrorResult;
fn Focus(&self) -> ErrorResult;
fn Blur(&self) -> ErrorResult;
fn AccessKey(&self) -> DOMString;
fn SetAccessKey(&self, _key: DOMString) -> ErrorResult;
fn AccessKeyLabel(&self) -> DOMString;
fn Draggable(&self) -> bool;
fn SetDraggable(&mut self, _draggable: bool) -> ErrorResult;
fn ContentEditable(&self) -> DOMString;
fn SetContentEditable(&mut self, _val: DOMString) -> ErrorResult;
fn IsContentEditable(&self) -> bool;
fn Spellcheck(&self) -> bool;
fn SetSpellcheck(&self, _val: bool) -> ErrorResult;
fn GetOffsetParent(&self) -> Option<Temporary<Element>>;
fn OffsetTop(&self) -> i32;
fn OffsetLeft(&self) -> i32;
fn OffsetWidth(&self) -> i32;
fn OffsetHeight(&self) -> i32;
}
impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
fn Title(&self) -> DOMString {
~"" ~""
} }
pub fn SetTitle(&mut self, _title: DOMString) { fn SetTitle(&mut self, _title: DOMString) {
} }
pub fn Lang(&self) -> DOMString { fn Lang(&self) -> DOMString {
~"" ~""
} }
pub fn SetLang(&mut self, _lang: DOMString) { fn SetLang(&mut self, _lang: DOMString) {
} }
pub fn Dir(&self) -> DOMString { fn Dir(&self) -> DOMString {
~"" ~""
} }
pub fn SetDir(&mut self, _dir: DOMString) -> ErrorResult { fn SetDir(&mut self, _dir: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetItemValue(&self, _cx: *JSContext) -> Fallible<JSVal> { fn GetItemValue(&self, _cx: *JSContext) -> Fallible<JSVal> {
Ok(NullValue()) Ok(NullValue())
} }
pub fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult { fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Hidden(&self) -> bool { fn Hidden(&self) -> bool {
false false
} }
pub fn SetHidden(&mut self, _hidden: bool) -> ErrorResult { fn SetHidden(&mut self, _hidden: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Click(&self) { fn Click(&self) {
} }
pub fn TabIndex(&self) -> i32 { fn TabIndex(&self) -> i32 {
0 0
} }
pub fn SetTabIndex(&mut self, _index: i32) -> ErrorResult { fn SetTabIndex(&mut self, _index: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Focus(&self) -> ErrorResult { fn Focus(&self) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Blur(&self) -> ErrorResult { fn Blur(&self) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn AccessKey(&self) -> DOMString { fn AccessKey(&self) -> DOMString {
~"" ~""
} }
pub fn SetAccessKey(&self, _key: DOMString) -> ErrorResult { fn SetAccessKey(&self, _key: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn AccessKeyLabel(&self) -> DOMString { fn AccessKeyLabel(&self) -> DOMString {
~"" ~""
} }
pub fn Draggable(&self) -> bool { fn Draggable(&self) -> bool {
false false
} }
pub fn SetDraggable(&mut self, _draggable: bool) -> ErrorResult { fn SetDraggable(&mut self, _draggable: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ContentEditable(&self) -> DOMString { fn ContentEditable(&self) -> DOMString {
~"" ~""
} }
pub fn SetContentEditable(&mut self, _val: DOMString) -> ErrorResult { fn SetContentEditable(&mut self, _val: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn IsContentEditable(&self) -> bool { fn IsContentEditable(&self) -> bool {
false false
} }
pub fn Spellcheck(&self) -> bool { fn Spellcheck(&self) -> bool {
false false
} }
pub fn SetSpellcheck(&self, _val: bool) -> ErrorResult { fn SetSpellcheck(&self, _val: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetOffsetParent(&self) -> Option<JS<Element>> { fn GetOffsetParent(&self) -> Option<Temporary<Element>> {
None None
} }
pub fn OffsetTop(&self) -> i32 { fn OffsetTop(&self) -> i32 {
0 0
} }
pub fn OffsetLeft(&self) -> i32 { fn OffsetLeft(&self) -> i32 {
0 0
} }
pub fn OffsetWidth(&self) -> i32 { fn OffsetWidth(&self) -> i32 {
0 0
} }
pub fn OffsetHeight(&self) -> i32 { fn OffsetHeight(&self) -> i32 {
0 0
} }
} }
impl VirtualMethods for JS<HTMLElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
fn super_type(&self) -> Option<~VirtualMethods:> { fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
let element: JS<Element> = ElementCast::from(self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
Some(~element as ~VirtualMethods:) Some(element as &mut VirtualMethods:)
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLEmbedElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLEmbedElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLEmbedElementDerived; use dom::bindings::codegen::InheritTypes::HTMLEmbedElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLEmbedElementTypeId; use dom::element::HTMLEmbedElementTypeId;
@ -28,68 +28,84 @@ impl HTMLEmbedElementDerived for EventTarget {
} }
impl HTMLEmbedElement { impl HTMLEmbedElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLEmbedElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLEmbedElement {
HTMLEmbedElement { HTMLEmbedElement {
htmlelement: HTMLElement::new_inherited(HTMLEmbedElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLEmbedElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLEmbedElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLEmbedElement> {
let element = HTMLEmbedElement::new_inherited(localName, document.clone()); let element = HTMLEmbedElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLEmbedElementBinding::Wrap) Node::reflect_node(~element, document, HTMLEmbedElementBinding::Wrap)
} }
} }
impl HTMLEmbedElement { pub trait HTMLEmbedElementMethods {
pub fn Src(&self) -> DOMString { fn Src(&self) -> DOMString;
fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Width(&self) -> DOMString;
fn SetWidth(&mut self, _width: DOMString) -> ErrorResult;
fn Height(&self) -> DOMString;
fn SetHeight(&mut self, _height: DOMString) -> ErrorResult;
fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _type: DOMString) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _type: DOMString) -> ErrorResult;
fn GetSVGDocument(&self) -> Option<Temporary<Document>>;
}
impl<'a> HTMLEmbedElementMethods for JSRef<'a, HTMLEmbedElement> {
fn Src(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { fn SetWidth(&mut self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Height(&self) -> DOMString { fn Height(&self) -> DOMString {
~"" ~""
} }
pub fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { fn SetHeight(&mut self, _height: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _type: DOMString) -> ErrorResult { fn SetAlign(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _type: DOMString) -> ErrorResult { fn SetName(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetSVGDocument(&self) -> Option<JS<Document>> { fn GetSVGDocument(&self) -> Option<Temporary<Document>> {
None None
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLFieldSetElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLFieldSetElementBinding;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFieldSetElementDerived, NodeCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFieldSetElementDerived, NodeCast};
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, HTMLFieldSetElementTypeId}; use dom::element::{Element, HTMLFieldSetElementTypeId};
@ -31,77 +31,92 @@ impl HTMLFieldSetElementDerived for EventTarget {
} }
impl HTMLFieldSetElement { impl HTMLFieldSetElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLFieldSetElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFieldSetElement {
HTMLFieldSetElement { HTMLFieldSetElement {
htmlelement: HTMLElement::new_inherited(HTMLFieldSetElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFieldSetElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLFieldSetElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFieldSetElement> {
let element = HTMLFieldSetElement::new_inherited(localName, document.clone()); let element = HTMLFieldSetElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLFieldSetElementBinding::Wrap) Node::reflect_node(~element, document, HTMLFieldSetElementBinding::Wrap)
} }
} }
impl HTMLFieldSetElement { pub trait HTMLFieldSetElementMethods {
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult;
fn GetForm(&self) -> Option<Temporary<HTMLFormElement>>;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn Elements(&self) -> Temporary<HTMLCollection>;
fn WillValidate(&self) -> bool;
fn Validity(&self) -> Temporary<ValidityState>;
fn ValidationMessage(&self) -> DOMString;
fn CheckValidity(&self) -> bool;
fn SetCustomValidity(&mut self, _error: DOMString);
}
impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<JS<HTMLFormElement>> { fn GetForm(&self) -> Option<Temporary<HTMLFormElement>> {
None None
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
// http://www.whatwg.org/html/#dom-fieldset-elements // http://www.whatwg.org/html/#dom-fieldset-elements
pub fn Elements(&self, abstract_self: &JS<HTMLFieldSetElement>) -> JS<HTMLCollection> { fn Elements(&self) -> Temporary<HTMLCollection> {
struct ElementsFilter; struct ElementsFilter;
impl CollectionFilter for ElementsFilter { impl CollectionFilter for ElementsFilter {
fn filter(&self, elem: &JS<Element>, root: &JS<Node>) -> bool { fn filter(&self, elem: &JSRef<Element>, root: &JSRef<Node>) -> bool {
static tag_names: StaticStringVec = &["button", "fieldset", "input", static tag_names: StaticStringVec = &["button", "fieldset", "input",
"keygen", "object", "output", "select", "textarea"]; "keygen", "object", "output", "select", "textarea"];
let root: &JS<Element> = &ElementCast::to(root).unwrap(); let root: &JSRef<Element> = ElementCast::to_ref(root).unwrap();
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.get().local_name) elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.deref().local_name)
} }
} }
let node: JS<Node> = NodeCast::from(abstract_self); let node: &JSRef<Node> = NodeCast::from_ref(self);
let filter = ~ElementsFilter; let filter = ~ElementsFilter;
HTMLCollection::create(&window_from_node(&node), &node, filter) let window = window_from_node(node).root();
HTMLCollection::create(&*window, node, filter)
} }
pub fn WillValidate(&self) -> bool { fn WillValidate(&self) -> bool {
false false
} }
pub fn Validity(&self) -> JS<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let doc = self.htmlelement.element.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); ValidityState::new(&*window)
ValidityState::new(&doc.window)
} }
pub fn ValidationMessage(&self) -> DOMString { fn ValidationMessage(&self) -> DOMString {
~"" ~""
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
false false
} }
pub fn SetCustomValidity(&mut self, _error: DOMString) { fn SetCustomValidity(&mut self, _error: DOMString) {
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLFontElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLFontElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFontElementDerived; use dom::bindings::codegen::InheritTypes::HTMLFontElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLFontElementTypeId; use dom::element::HTMLFontElementTypeId;
@ -28,40 +28,49 @@ impl HTMLFontElementDerived for EventTarget {
} }
impl HTMLFontElement { impl HTMLFontElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLFontElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFontElement {
HTMLFontElement { HTMLFontElement {
htmlelement: HTMLElement::new_inherited(HTMLFontElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFontElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLFontElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFontElement> {
let element = HTMLFontElement::new_inherited(localName, document.clone()); let element = HTMLFontElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLFontElementBinding::Wrap) Node::reflect_node(~element, document, HTMLFontElementBinding::Wrap)
} }
} }
impl HTMLFontElement { pub trait HTMLFontElementMethods {
pub fn Color(&self) -> DOMString { fn Color(&self) -> DOMString;
fn SetColor(&mut self, _color: DOMString) -> ErrorResult;
fn Face(&self) -> DOMString;
fn SetFace(&mut self, _face: DOMString) -> ErrorResult;
fn Size(&self) -> DOMString;
fn SetSize(&mut self, _size: DOMString) -> ErrorResult;
}
impl<'a> HTMLFontElementMethods for JSRef<'a, HTMLFontElement> {
fn Color(&self) -> DOMString {
~"" ~""
} }
pub fn SetColor(&mut self, _color: DOMString) -> ErrorResult { fn SetColor(&mut self, _color: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Face(&self) -> DOMString { fn Face(&self) -> DOMString {
~"" ~""
} }
pub fn SetFace(&mut self, _face: DOMString) -> ErrorResult { fn SetFace(&mut self, _face: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Size(&self) -> DOMString { fn Size(&self) -> DOMString {
~"" ~""
} }
pub fn SetSize(&mut self, _size: DOMString) -> ErrorResult { fn SetSize(&mut self, _size: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,14 +4,14 @@
use dom::bindings::codegen::BindingDeclarations::HTMLFormElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLFormElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFormElementDerived; use dom::bindings::codegen::InheritTypes::HTMLFormElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, HTMLFormElementTypeId}; use dom::element::{Element, HTMLFormElementTypeId};
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlcollection::{HTMLCollection, Static}; use dom::htmlcollection::{HTMLCollection, Static};
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{Node, ElementNodeTypeId}; use dom::node::{Node, ElementNodeTypeId, window_from_node};
use servo_util::str::DOMString; use servo_util::str::DOMString;
#[deriving(Encodable)] #[deriving(Encodable)]
@ -29,114 +29,140 @@ impl HTMLFormElementDerived for EventTarget {
} }
impl HTMLFormElement { impl HTMLFormElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLFormElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFormElement {
HTMLFormElement { HTMLFormElement {
htmlelement: HTMLElement::new_inherited(HTMLFormElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFormElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLFormElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFormElement> {
let element = HTMLFormElement::new_inherited(localName, document.clone()); let element = HTMLFormElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLFormElementBinding::Wrap) Node::reflect_node(~element, document, HTMLFormElementBinding::Wrap)
} }
} }
impl HTMLFormElement { pub trait HTMLFormElementMethods {
pub fn AcceptCharset(&self) -> DOMString { fn AcceptCharset(&self) -> DOMString;
fn SetAcceptCharset(&mut self, _accept_charset: DOMString) -> ErrorResult;
fn Action(&self) -> DOMString;
fn SetAction(&mut self, _action: DOMString) -> ErrorResult;
fn Autocomplete(&self) -> DOMString;
fn SetAutocomplete(&mut self, _autocomplete: DOMString) -> ErrorResult;
fn Enctype(&self) -> DOMString;
fn SetEnctype(&mut self, _enctype: DOMString) -> ErrorResult;
fn Encoding(&self) -> DOMString;
fn SetEncoding(&mut self, _encoding: DOMString) -> ErrorResult;
fn Method(&self) -> DOMString;
fn SetMethod(&mut self, _method: DOMString) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn NoValidate(&self) -> bool;
fn SetNoValidate(&mut self, _no_validate: bool) -> ErrorResult;
fn Target(&self) -> DOMString;
fn SetTarget(&mut self, _target: DOMString) -> ErrorResult;
fn Elements(&self) -> Temporary<HTMLCollection>;
fn Length(&self) -> i32;
fn Submit(&self) -> ErrorResult;
fn Reset(&self);
fn CheckValidity(&self) -> bool;
fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Temporary<Element>;
}
impl<'a> HTMLFormElementMethods for JSRef<'a, HTMLFormElement> {
fn AcceptCharset(&self) -> DOMString {
~"" ~""
} }
pub fn SetAcceptCharset(&mut self, _accept_charset: DOMString) -> ErrorResult { fn SetAcceptCharset(&mut self, _accept_charset: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Action(&self) -> DOMString { fn Action(&self) -> DOMString {
~"" ~""
} }
pub fn SetAction(&mut self, _action: DOMString) -> ErrorResult { fn SetAction(&mut self, _action: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Autocomplete(&self) -> DOMString { fn Autocomplete(&self) -> DOMString {
~"" ~""
} }
pub fn SetAutocomplete(&mut self, _autocomplete: DOMString) -> ErrorResult { fn SetAutocomplete(&mut self, _autocomplete: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Enctype(&self) -> DOMString { fn Enctype(&self) -> DOMString {
~"" ~""
} }
pub fn SetEnctype(&mut self, _enctype: DOMString) -> ErrorResult { fn SetEnctype(&mut self, _enctype: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Encoding(&self) -> DOMString { fn Encoding(&self) -> DOMString {
~"" ~""
} }
pub fn SetEncoding(&mut self, _encoding: DOMString) -> ErrorResult { fn SetEncoding(&mut self, _encoding: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Method(&self) -> DOMString { fn Method(&self) -> DOMString {
~"" ~""
} }
pub fn SetMethod(&mut self, _method: DOMString) -> ErrorResult { fn SetMethod(&mut self, _method: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn NoValidate(&self) -> bool { fn NoValidate(&self) -> bool {
false false
} }
pub fn SetNoValidate(&mut self, _no_validate: bool) -> ErrorResult { fn SetNoValidate(&mut self, _no_validate: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Target(&self) -> DOMString { fn Target(&self) -> DOMString {
~"" ~""
} }
pub fn SetTarget(&mut self, _target: DOMString) -> ErrorResult { fn SetTarget(&mut self, _target: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Elements(&self) -> JS<HTMLCollection> { fn Elements(&self) -> Temporary<HTMLCollection> {
// FIXME: https://github.com/mozilla/servo/issues/1844 // FIXME: https://github.com/mozilla/servo/issues/1844
let doc = self.htmlelement.element.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); HTMLCollection::new(&*window, Static(vec!()))
HTMLCollection::new(&doc.window, Static(vec!()))
} }
pub fn Length(&self) -> i32 { fn Length(&self) -> i32 {
0 0
} }
pub fn Submit(&self) -> ErrorResult { fn Submit(&self) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Reset(&self) { fn Reset(&self) {
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
false false
} }
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> JS<Element> { fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Temporary<Element> {
fail!("Not implemented.") fail!("Not implemented.")
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLFrameElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLFrameElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFrameElementDerived; use dom::bindings::codegen::InheritTypes::HTMLFrameElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLFrameElementTypeId; use dom::element::HTMLFrameElementTypeId;
@ -29,88 +29,109 @@ impl HTMLFrameElementDerived for EventTarget {
} }
impl HTMLFrameElement { impl HTMLFrameElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLFrameElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFrameElement {
HTMLFrameElement { HTMLFrameElement {
htmlelement: HTMLElement::new_inherited(HTMLFrameElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFrameElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLFrameElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFrameElement> {
let element = HTMLFrameElement::new_inherited(localName, document.clone()); let element = HTMLFrameElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLFrameElementBinding::Wrap) Node::reflect_node(~element, document, HTMLFrameElementBinding::Wrap)
} }
} }
impl HTMLFrameElement { pub trait HTMLFrameElementMethods {
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Scrolling(&self) -> DOMString;
fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult;
fn Src(&self) -> DOMString;
fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn FrameBorder(&self) -> DOMString;
fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult;
fn LongDesc(&self) -> DOMString;
fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult;
fn NoResize(&self) -> bool;
fn SetNoResize(&mut self, _no_resize: bool) -> ErrorResult;
fn GetContentDocument(&self) -> Option<Temporary<Document>>;
fn GetContentWindow(&self) -> Option<Temporary<Window>>;
fn MarginHeight(&self) -> DOMString;
fn SetMarginHeight(&mut self, _height: DOMString) -> ErrorResult;
fn MarginWidth(&self) -> DOMString;
fn SetMarginWidth(&mut self, _height: DOMString) -> ErrorResult;
}
impl<'a> HTMLFrameElementMethods for JSRef<'a, HTMLFrameElement> {
fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Scrolling(&self) -> DOMString { fn Scrolling(&self) -> DOMString {
~"" ~""
} }
pub fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult { fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Src(&self) -> DOMString { fn Src(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FrameBorder(&self) -> DOMString { fn FrameBorder(&self) -> DOMString {
~"" ~""
} }
pub fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult { fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn LongDesc(&self) -> DOMString { fn LongDesc(&self) -> DOMString {
~"" ~""
} }
pub fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult { fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn NoResize(&self) -> bool { fn NoResize(&self) -> bool {
false false
} }
pub fn SetNoResize(&mut self, _no_resize: bool) -> ErrorResult { fn SetNoResize(&mut self, _no_resize: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetContentDocument(&self) -> Option<JS<Document>> { fn GetContentDocument(&self) -> Option<Temporary<Document>> {
None None
} }
pub fn GetContentWindow(&self) -> Option<JS<Window>> { fn GetContentWindow(&self) -> Option<Temporary<Window>> {
None None
} }
pub fn MarginHeight(&self) -> DOMString { fn MarginHeight(&self) -> DOMString {
~"" ~""
} }
pub fn SetMarginHeight(&mut self, _height: DOMString) -> ErrorResult { fn SetMarginHeight(&mut self, _height: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn MarginWidth(&self) -> DOMString { fn MarginWidth(&self) -> DOMString {
~"" ~""
} }
pub fn SetMarginWidth(&mut self, _height: DOMString) -> ErrorResult { fn SetMarginWidth(&mut self, _height: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLFrameSetElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLFrameSetElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFrameSetElementDerived; use dom::bindings::codegen::InheritTypes::HTMLFrameSetElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLFrameSetElementTypeId; use dom::element::HTMLFrameSetElementTypeId;
@ -28,32 +28,39 @@ impl HTMLFrameSetElementDerived for EventTarget {
} }
impl HTMLFrameSetElement { impl HTMLFrameSetElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLFrameSetElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFrameSetElement {
HTMLFrameSetElement { HTMLFrameSetElement {
htmlelement: HTMLElement::new_inherited(HTMLFrameSetElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFrameSetElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLFrameSetElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFrameSetElement> {
let element = HTMLFrameSetElement::new_inherited(localName, document.clone()); let element = HTMLFrameSetElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLFrameSetElementBinding::Wrap) Node::reflect_node(~element, document, HTMLFrameSetElementBinding::Wrap)
} }
} }
impl HTMLFrameSetElement { pub trait HTMLFrameSetElementMethods {
pub fn Cols(&self) -> DOMString { fn Cols(&self) -> DOMString;
fn SetCols(&mut self, _cols: DOMString) -> ErrorResult;
fn Rows(&self) -> DOMString;
fn SetRows(&mut self, _rows: DOMString) -> ErrorResult;
}
impl<'a> HTMLFrameSetElementMethods for JSRef<'a, HTMLFrameSetElement> {
fn Cols(&self) -> DOMString {
~"" ~""
} }
pub fn SetCols(&mut self, _cols: DOMString) -> ErrorResult { fn SetCols(&mut self, _cols: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Rows(&self) -> DOMString { fn Rows(&self) -> DOMString {
~"" ~""
} }
pub fn SetRows(&mut self, _rows: DOMString) -> ErrorResult { fn SetRows(&mut self, _rows: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLHeadElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLHeadElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHeadElementDerived; use dom::bindings::codegen::InheritTypes::HTMLHeadElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLHeadElementTypeId; use dom::element::HTMLHeadElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLHeadElementDerived for EventTarget {
} }
impl HTMLHeadElement { impl HTMLHeadElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLHeadElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHeadElement {
HTMLHeadElement { HTMLHeadElement {
htmlelement: HTMLElement::new_inherited(HTMLHeadElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLHeadElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLHeadElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLHeadElement> {
let element = HTMLHeadElement::new_inherited(localName, document.clone()); let element = HTMLHeadElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLHeadElementBinding::Wrap) Node::reflect_node(~element, document, HTMLHeadElementBinding::Wrap)
} }
} }
pub trait HTMLHeadElementMethods {
}

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLHeadingElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLHeadingElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHeadingElementDerived; use dom::bindings::codegen::InheritTypes::HTMLHeadingElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLHeadingElementTypeId; use dom::element::HTMLHeadingElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -38,24 +38,29 @@ impl HTMLHeadingElementDerived for EventTarget {
} }
impl HTMLHeadingElement { impl HTMLHeadingElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>, level: HeadingLevel) -> HTMLHeadingElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>, level: HeadingLevel) -> HTMLHeadingElement {
HTMLHeadingElement { HTMLHeadingElement {
htmlelement: HTMLElement::new_inherited(HTMLHeadingElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLHeadingElementTypeId, localName, document),
level: level, level: level,
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>, level: HeadingLevel) -> JS<HTMLHeadingElement> { pub fn new(localName: DOMString, document: &JSRef<Document>, level: HeadingLevel) -> Temporary<HTMLHeadingElement> {
let element = HTMLHeadingElement::new_inherited(localName, document.clone(), level); let element = HTMLHeadingElement::new_inherited(localName, document, level);
Node::reflect_node(~element, document, HTMLHeadingElementBinding::Wrap) Node::reflect_node(~element, document, HTMLHeadingElementBinding::Wrap)
} }
} }
impl HTMLHeadingElement { pub trait HTMLHeadingElementMethods {
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString);
}
impl<'a> HTMLHeadingElementMethods for JSRef<'a, HTMLHeadingElement> {
fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) { fn SetAlign(&mut self, _align: DOMString) {
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLHRElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLHRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHRElementDerived; use dom::bindings::codegen::InheritTypes::HTMLHRElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLHRElementTypeId; use dom::element::HTMLHRElementTypeId;
@ -28,56 +28,69 @@ impl HTMLHRElementDerived for EventTarget {
} }
impl HTMLHRElement { impl HTMLHRElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLHRElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHRElement {
HTMLHRElement { HTMLHRElement {
htmlelement: HTMLElement::new_inherited(HTMLHRElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLHRElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLHRElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLHRElement> {
let element = HTMLHRElement::new_inherited(localName, document.clone()); let element = HTMLHRElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLHRElementBinding::Wrap) Node::reflect_node(~element, document, HTMLHRElementBinding::Wrap)
} }
} }
impl HTMLHRElement { pub trait HTMLHRElementMethods {
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
fn Color(&self) -> DOMString;
fn SetColor(&mut self, _color: DOMString) -> ErrorResult;
fn NoShade(&self) -> bool;
fn SetNoShade(&self, _no_shade: bool) -> ErrorResult;
fn Size(&self) -> DOMString;
fn SetSize(&mut self, _size: DOMString) -> ErrorResult;
fn Width(&self) -> DOMString;
fn SetWidth(&mut self, _width: DOMString) -> ErrorResult;
}
impl<'a> HTMLHRElementMethods for JSRef<'a, HTMLHRElement> {
fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Color(&self) -> DOMString { fn Color(&self) -> DOMString {
~"" ~""
} }
pub fn SetColor(&mut self, _color: DOMString) -> ErrorResult { fn SetColor(&mut self, _color: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn NoShade(&self) -> bool { fn NoShade(&self) -> bool {
false false
} }
pub fn SetNoShade(&self, _no_shade: bool) -> ErrorResult { fn SetNoShade(&self, _no_shade: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Size(&self) -> DOMString { fn Size(&self) -> DOMString {
~"" ~""
} }
pub fn SetSize(&mut self, _size: DOMString) -> ErrorResult { fn SetSize(&mut self, _size: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { fn SetWidth(&mut self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLHtmlElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLHtmlElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHtmlElementDerived; use dom::bindings::codegen::InheritTypes::HTMLHtmlElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLHtmlElementTypeId; use dom::element::HTMLHtmlElementTypeId;
@ -28,24 +28,29 @@ impl HTMLHtmlElementDerived for EventTarget {
} }
impl HTMLHtmlElement { impl HTMLHtmlElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLHtmlElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHtmlElement {
HTMLHtmlElement { HTMLHtmlElement {
htmlelement: HTMLElement::new_inherited(HTMLHtmlElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLHtmlElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLHtmlElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLHtmlElement> {
let element = HTMLHtmlElement::new_inherited(localName, document.clone()); let element = HTMLHtmlElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLHtmlElementBinding::Wrap) Node::reflect_node(~element, document, HTMLHtmlElementBinding::Wrap)
} }
} }
impl HTMLHtmlElement { pub trait HTMLHtmlElementMethods {
pub fn Version(&self) -> DOMString { fn Version(&self) -> DOMString;
fn SetVersion(&mut self, _version: DOMString) -> ErrorResult;
}
impl<'a> HTMLHtmlElementMethods for JSRef<'a, HTMLHtmlElement> {
fn Version(&self) -> DOMString {
~"" ~""
} }
pub fn SetVersion(&mut self, _version: DOMString) -> ErrorResult { fn SetVersion(&mut self, _version: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLIFrameElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLIFrameElementBinding;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLIFrameElementDerived, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLIFrameElementDerived, HTMLElementCast};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::trace::Untraceable; use dom::bindings::trace::Untraceable;
use dom::document::Document; use dom::document::Document;
use dom::element::{HTMLIFrameElementTypeId, Element}; use dom::element::{HTMLIFrameElementTypeId, Element};
@ -54,18 +54,23 @@ pub struct IFrameSize {
pub subpage_id: SubpageId, pub subpage_id: SubpageId,
} }
impl HTMLIFrameElement { pub trait HTMLIFrameElementHelpers {
pub fn is_sandboxed(&self) -> bool { fn is_sandboxed(&self) -> bool;
fn set_frame(&mut self, frame: Url);
}
impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
fn is_sandboxed(&self) -> bool {
self.sandbox.is_some() self.sandbox.is_some()
} }
pub fn set_frame(&mut self, frame: Url) { fn set_frame(&mut self, frame: Url) {
*self.frame = Some(frame); *self.frame = Some(frame);
} }
} }
impl HTMLIFrameElement { impl HTMLIFrameElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLIFrameElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLIFrameElement {
HTMLIFrameElement { HTMLIFrameElement {
htmlelement: HTMLElement::new_inherited(HTMLIFrameElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLIFrameElementTypeId, localName, document),
frame: Untraceable::new(None), frame: Untraceable::new(None),
@ -74,136 +79,168 @@ impl HTMLIFrameElement {
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLIFrameElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLIFrameElement> {
let element = HTMLIFrameElement::new_inherited(localName, document.clone()); let element = HTMLIFrameElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLIFrameElementBinding::Wrap) Node::reflect_node(~element, document, HTMLIFrameElementBinding::Wrap)
} }
} }
impl HTMLIFrameElement { pub trait HTMLIFrameElementMethods {
pub fn Src(&self) -> DOMString { fn Src(&self) -> DOMString;
fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn Srcdoc(&self) -> DOMString;
fn SetSrcdoc(&mut self, _srcdoc: DOMString) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Sandbox(&self) -> DOMString;
fn SetSandbox(&mut self, sandbox: DOMString);
fn AllowFullscreen(&self) -> bool;
fn SetAllowFullscreen(&mut self, _allow: bool) -> ErrorResult;
fn Width(&self) -> DOMString;
fn SetWidth(&mut self, _width: DOMString) -> ErrorResult;
fn Height(&self) -> DOMString;
fn SetHeight(&mut self, _height: DOMString) -> ErrorResult;
fn GetContentDocument(&self) -> Option<Temporary<Document>>;
fn GetContentWindow(&self) -> Option<Temporary<Window>>;
fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
fn Scrolling(&self) -> DOMString;
fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult;
fn FrameBorder(&self) -> DOMString;
fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult;
fn LongDesc(&self) -> DOMString;
fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult;
fn MarginHeight(&self) -> DOMString;
fn SetMarginHeight(&mut self, _marginheight: DOMString) -> ErrorResult;
fn MarginWidth(&self) -> DOMString;
fn SetMarginWidth(&mut self, _marginwidth: DOMString) -> ErrorResult;
fn GetSVGDocument(&self) -> Option<Temporary<Document>>;
}
impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
fn Src(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Srcdoc(&self) -> DOMString { fn Srcdoc(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrcdoc(&mut self, _srcdoc: DOMString) -> ErrorResult { fn SetSrcdoc(&mut self, _srcdoc: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Sandbox(&self, abstract_self: &JS<HTMLIFrameElement>) -> DOMString { fn Sandbox(&self) -> DOMString {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("sandbox") element.get_string_attribute("sandbox")
} }
pub fn SetSandbox(&mut self, abstract_self: &mut JS<HTMLIFrameElement>, sandbox: DOMString) { fn SetSandbox(&mut self, sandbox: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("sandbox", sandbox); element.set_string_attribute("sandbox", sandbox);
} }
pub fn AllowFullscreen(&self) -> bool { fn AllowFullscreen(&self) -> bool {
false false
} }
pub fn SetAllowFullscreen(&mut self, _allow: bool) -> ErrorResult { fn SetAllowFullscreen(&mut self, _allow: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { fn SetWidth(&mut self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Height(&self) -> DOMString { fn Height(&self) -> DOMString {
~"" ~""
} }
pub fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { fn SetHeight(&mut self, _height: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetContentDocument(&self) -> Option<JS<Document>> { fn GetContentDocument(&self) -> Option<Temporary<Document>> {
None None
} }
pub fn GetContentWindow(&self) -> Option<JS<Window>> { fn GetContentWindow(&self) -> Option<Temporary<Window>> {
None None
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Scrolling(&self) -> DOMString { fn Scrolling(&self) -> DOMString {
~"" ~""
} }
pub fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult { fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FrameBorder(&self) -> DOMString { fn FrameBorder(&self) -> DOMString {
~"" ~""
} }
pub fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult { fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn LongDesc(&self) -> DOMString { fn LongDesc(&self) -> DOMString {
~"" ~""
} }
pub fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult { fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn MarginHeight(&self) -> DOMString { fn MarginHeight(&self) -> DOMString {
~"" ~""
} }
pub fn SetMarginHeight(&mut self, _marginheight: DOMString) -> ErrorResult { fn SetMarginHeight(&mut self, _marginheight: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn MarginWidth(&self) -> DOMString { fn MarginWidth(&self) -> DOMString {
~"" ~""
} }
pub fn SetMarginWidth(&mut self, _marginwidth: DOMString) -> ErrorResult { fn SetMarginWidth(&mut self, _marginwidth: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetSVGDocument(&self) -> Option<JS<Document>> { fn GetSVGDocument(&self) -> Option<Temporary<Document>> {
None None
} }
} }
impl VirtualMethods for JS<HTMLIFrameElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
fn super_type(&self) -> Option<~VirtualMethods:> { fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
let htmlelement: JS<HTMLElement> = HTMLElementCast::from(self); let htmlelement: &mut JSRef<HTMLElement> = HTMLElementCast::from_mut_ref(self);
Some(~htmlelement as ~VirtualMethods:) Some(htmlelement as &mut VirtualMethods:)
} }
fn after_set_attr(&mut self, name: DOMString, value: DOMString) { fn after_set_attr(&mut self, name: DOMString, value: DOMString) {
@ -227,7 +264,7 @@ impl VirtualMethods for JS<HTMLIFrameElement> {
_ => AllowNothing _ => AllowNothing
} as u8; } as u8;
} }
self.get_mut().sandbox = Some(modes); self.deref_mut().sandbox = Some(modes);
} }
} }
@ -238,7 +275,7 @@ impl VirtualMethods for JS<HTMLIFrameElement> {
} }
if "sandbox" == name { if "sandbox" == name {
self.get_mut().sandbox = None; self.deref_mut().sandbox = None;
} }
} }
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLImageElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLImageElementBinding;
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, HTMLElementCast, HTMLImageElementDerived}; use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, HTMLElementCast, HTMLImageElementDerived};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::bindings::js::JS; use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::trace::Untraceable; use dom::bindings::trace::Untraceable;
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, HTMLImageElementTypeId}; use dom::element::{Element, HTMLImageElementTypeId};
@ -35,31 +35,18 @@ impl HTMLImageElementDerived for EventTarget {
} }
} }
impl HTMLImageElement { trait PrivateHTMLImageElementHelpers {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLImageElement { fn update_image(&mut self, value: Option<DOMString>, url: Option<Url>);
HTMLImageElement {
htmlelement: HTMLElement::new_inherited(HTMLImageElementTypeId, localName, document),
image: Untraceable::new(None),
}
}
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLImageElement> {
let element = HTMLImageElement::new_inherited(localName, document.clone());
Node::reflect_node(~element, document, HTMLImageElementBinding::Wrap)
}
} }
impl HTMLImageElement { impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> {
pub fn image<'a>(&'a self) -> &'a Option<Url> {
&*self.image
}
/// Makes the local `image` member match the status of the `src` attribute and starts /// Makes the local `image` member match the status of the `src` attribute and starts
/// prefetching the image. This method must be called after `src` is changed. /// prefetching the image. This method must be called after `src` is changed.
fn update_image(&mut self, value: Option<DOMString>, url: Option<Url>) { fn update_image(&mut self, value: Option<DOMString>, url: Option<Url>) {
let elem = &mut self.htmlelement.element; let self_alias = self.clone();
let document = elem.node.owner_doc(); let node_alias: &JSRef<Node> = NodeCast::from_ref(&self_alias);
let window = document.get().window.get(); let document = node_alias.owner_doc().root();
let window = document.deref().window.root();
let image_cache = &window.image_cache_task; let image_cache = &window.image_cache_task;
match value { match value {
None => { None => {
@ -78,154 +65,212 @@ impl HTMLImageElement {
} }
} }
} }
}
pub fn Alt(&self, abstract_self: &JS<HTMLImageElement>) -> DOMString { impl HTMLImageElement {
let element: JS<Element> = ElementCast::from(abstract_self); pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLImageElement {
HTMLImageElement {
htmlelement: HTMLElement::new_inherited(HTMLImageElementTypeId, localName, document),
image: Untraceable::new(None),
}
}
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLImageElement> {
let element = HTMLImageElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLImageElementBinding::Wrap)
}
}
pub trait LayoutHTMLImageElementHelpers {
unsafe fn image<'a>(&'a self) -> &'a Option<Url>;
}
impl LayoutHTMLImageElementHelpers for JS<HTMLImageElement> {
unsafe fn image<'a>(&'a self) -> &'a Option<Url> {
&*(*self.unsafe_get()).image
}
}
pub trait HTMLImageElementMethods {
fn Alt(&self) -> DOMString;
fn SetAlt(&mut self, alt: DOMString);
fn Src(&self) -> DOMString;
fn SetSrc(&mut self, src: DOMString);
fn CrossOrigin(&self) -> DOMString;
fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult;
fn UseMap(&self) -> DOMString;
fn SetUseMap(&mut self, use_map: DOMString);
fn IsMap(&self) -> bool;
fn SetIsMap(&mut self, is_map: bool);
fn Width(&self) -> u32;
fn SetWidth(&mut self, width: u32);
fn Height(&self) -> u32;
fn SetHeight(&mut self, height: u32);
fn NaturalWidth(&self) -> u32;
fn NaturalHeight(&self) -> u32;
fn Complete(&self) -> bool;
fn Name(&self) -> DOMString;
fn SetName(&mut self, name: DOMString);
fn Align(&self) -> DOMString;
fn SetAlign(&mut self, align: DOMString);
fn Hspace(&self) -> u32;
fn SetHspace(&mut self, hspace: u32);
fn Vspace(&self) -> u32;
fn SetVspace(&mut self, vspace: u32);
fn LongDesc(&self) -> DOMString;
fn SetLongDesc(&mut self, longdesc: DOMString);
fn Border(&self) -> DOMString;
fn SetBorder(&mut self, border: DOMString);
}
impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
fn Alt(&self) -> DOMString {
let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("alt") element.get_string_attribute("alt")
} }
pub fn SetAlt(&mut self, abstract_self: &JS<HTMLImageElement>, alt: DOMString) { fn SetAlt(&mut self, alt: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("alt", alt) element.set_string_attribute("alt", alt)
} }
pub fn Src(&self, abstract_self: &JS<HTMLImageElement>) -> DOMString { fn Src(&self) -> DOMString {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("src") element.get_string_attribute("src")
} }
pub fn SetSrc(&mut self, abstract_self: &mut JS<HTMLImageElement>, src: DOMString) { fn SetSrc(&mut self, src: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_url_attribute("src", src) element.set_url_attribute("src", src)
} }
pub fn CrossOrigin(&self) -> DOMString { fn CrossOrigin(&self) -> DOMString {
~"" ~""
} }
pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn UseMap(&self, abstract_self: &JS<HTMLImageElement>) -> DOMString { fn UseMap(&self) -> DOMString {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("useMap") element.get_string_attribute("useMap")
} }
pub fn SetUseMap(&mut self, abstract_self: &mut JS<HTMLImageElement>, use_map: DOMString) { fn SetUseMap(&mut self, use_map: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("useMap", use_map) element.set_string_attribute("useMap", use_map)
} }
pub fn IsMap(&self, abstract_self: &JS<HTMLImageElement>) -> bool { fn IsMap(&self) -> bool {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
from_str::<bool>(element.get_string_attribute("hspace")).unwrap() from_str::<bool>(element.get_string_attribute("hspace")).unwrap()
} }
pub fn SetIsMap(&self, abstract_self: &mut JS<HTMLImageElement>, is_map: bool) { fn SetIsMap(&mut self, is_map: bool) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("isMap", is_map.to_str()) element.set_string_attribute("isMap", is_map.to_str())
} }
pub fn Width(&self, abstract_self: &JS<HTMLImageElement>) -> u32 { fn Width(&self) -> u32 {
let node: JS<Node> = NodeCast::from(abstract_self); let node: &JSRef<Node> = NodeCast::from_ref(self);
let rect = node.get_bounding_content_box(); let rect = node.get_bounding_content_box();
to_px(rect.size.width) as u32 to_px(rect.size.width) as u32
} }
pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) { fn SetWidth(&mut self, width: u32) {
let mut elem: JS<Element> = ElementCast::from(abstract_self); let elem: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
elem.set_uint_attribute("width", width) elem.set_uint_attribute("width", width)
} }
pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 { fn Height(&self) -> u32 {
let node: JS<Node> = NodeCast::from(abstract_self); let node: &JSRef<Node> = NodeCast::from_ref(self);
let rect = node.get_bounding_content_box(); let rect = node.get_bounding_content_box();
to_px(rect.size.height) as u32 to_px(rect.size.height) as u32
} }
pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) { fn SetHeight(&mut self, height: u32) {
let mut elem: JS<Element> = ElementCast::from(abstract_self); let elem: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
elem.set_uint_attribute("height", height) elem.set_uint_attribute("height", height)
} }
pub fn NaturalWidth(&self) -> u32 { fn NaturalWidth(&self) -> u32 {
0 0
} }
pub fn NaturalHeight(&self) -> u32 { fn NaturalHeight(&self) -> u32 {
0 0
} }
pub fn Complete(&self) -> bool { fn Complete(&self) -> bool {
false false
} }
pub fn Name(&self, abstract_self: &JS<HTMLImageElement>) -> DOMString { fn Name(&self) -> DOMString {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("name") element.get_string_attribute("name")
} }
pub fn SetName(&mut self, abstract_self: &mut JS<HTMLImageElement>, name: DOMString) { fn SetName(&mut self, name: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("name", name) element.set_string_attribute("name", name)
} }
pub fn Align(&self, abstract_self: &JS<HTMLImageElement>) -> DOMString { fn Align(&self) -> DOMString {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("longdesc") element.get_string_attribute("align")
} }
pub fn SetAlign(&mut self, abstract_self: &mut JS<HTMLImageElement>, align: DOMString) { fn SetAlign(&mut self, align: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("align", align) element.set_string_attribute("align", align)
} }
pub fn Hspace(&self, abstract_self: &JS<HTMLImageElement>) -> u32 { fn Hspace(&self) -> u32 {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
from_str::<u32>(element.get_string_attribute("hspace")).unwrap() from_str::<u32>(element.get_string_attribute("hspace")).unwrap()
} }
pub fn SetHspace(&mut self, abstract_self: &mut JS<HTMLImageElement>, hspace: u32) { fn SetHspace(&mut self, hspace: u32) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_uint_attribute("hspace", hspace) element.set_uint_attribute("hspace", hspace)
} }
pub fn Vspace(&self, abstract_self: &JS<HTMLImageElement>) -> u32 { fn Vspace(&self) -> u32 {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
from_str::<u32>(element.get_string_attribute("vspace")).unwrap() from_str::<u32>(element.get_string_attribute("vspace")).unwrap()
} }
pub fn SetVspace(&mut self, abstract_self: &mut JS<HTMLImageElement>, vspace: u32) { fn SetVspace(&mut self, vspace: u32) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_uint_attribute("vspace", vspace) element.set_uint_attribute("vspace", vspace)
} }
pub fn LongDesc(&self, abstract_self: &JS<HTMLImageElement>) -> DOMString { fn LongDesc(&self) -> DOMString {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("longdesc") element.get_string_attribute("longdesc")
} }
pub fn SetLongDesc(&mut self, abstract_self: &mut JS<HTMLImageElement>, longdesc: DOMString) { fn SetLongDesc(&mut self, longdesc: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("longdesc", longdesc) element.set_string_attribute("longdesc", longdesc)
} }
pub fn Border(&self, abstract_self: &JS<HTMLImageElement>) -> DOMString { fn Border(&self) -> DOMString {
let element: JS<Element> = ElementCast::from(abstract_self); let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_string_attribute("border") element.get_string_attribute("border")
} }
pub fn SetBorder(&mut self, abstract_self: &mut JS<HTMLImageElement>, border: DOMString) { fn SetBorder(&mut self, border: DOMString) {
let mut element: JS<Element> = ElementCast::from(abstract_self); let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
element.set_string_attribute("border", border) element.set_string_attribute("border", border)
} }
} }
impl VirtualMethods for JS<HTMLImageElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
fn super_type(&self) -> Option<~VirtualMethods:> { fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
let htmlelement: JS<HTMLElement> = HTMLElementCast::from(self); let htmlelement: &mut JSRef<HTMLElement> = HTMLElementCast::from_mut_ref(self);
Some(~htmlelement as ~VirtualMethods:) Some(htmlelement as &mut VirtualMethods:)
} }
fn after_set_attr(&mut self, name: DOMString, value: DOMString) { fn after_set_attr(&mut self, name: DOMString, value: DOMString) {
@ -235,9 +280,9 @@ impl VirtualMethods for JS<HTMLImageElement> {
} }
if "src" == name { if "src" == name {
let window = window_from_node(self); let window = window_from_node(self).root();
let url = Some(window.get().get_url()); let url = Some(window.deref().get_url());
self.get_mut().update_image(Some(value), url); self.update_image(Some(value), url);
} }
} }
@ -248,7 +293,7 @@ impl VirtualMethods for JS<HTMLImageElement> {
} }
if "src" == name { if "src" == name {
self.get_mut().update_image(None, None); self.update_image(None, None);
} }
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLInputElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLInputElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLInputElementDerived; use dom::bindings::codegen::InheritTypes::HTMLInputElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::{ErrorResult, Fallible};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLInputElementTypeId; use dom::element::HTMLInputElementTypeId;
@ -28,322 +28,403 @@ impl HTMLInputElementDerived for EventTarget {
} }
impl HTMLInputElement { impl HTMLInputElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLInputElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLInputElement {
HTMLInputElement { HTMLInputElement {
htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLInputElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLInputElement> {
let element = HTMLInputElement::new_inherited(localName, document.clone()); let element = HTMLInputElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLInputElementBinding::Wrap) Node::reflect_node(~element, document, HTMLInputElementBinding::Wrap)
} }
} }
impl HTMLInputElement { pub trait HTMLInputElementMethods {
pub fn Accept(&self) -> DOMString { fn Accept(&self) -> DOMString;
fn SetAccept(&mut self, _accept: DOMString) -> ErrorResult;
fn Alt(&self) -> DOMString;
fn SetAlt(&mut self, _alt: DOMString) -> ErrorResult;
fn Autocomplete(&self) -> DOMString;
fn SetAutocomplete(&mut self, _autocomple: DOMString) -> ErrorResult;
fn Autofocus(&self) -> bool;
fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult;
fn DefaultChecked(&self) -> bool;
fn SetDefaultChecked(&mut self, _default_checked: bool) -> ErrorResult;
fn Checked(&self) -> bool;
fn SetChecked(&mut self, _checked: bool);
fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult;
fn FormAction(&self) -> DOMString;
fn SetFormAction(&mut self, _form_action: DOMString) -> ErrorResult;
fn FormEnctype(&self) -> DOMString;
fn SetFormEnctype(&mut self, _form_enctype: DOMString) -> ErrorResult;
fn FormMethod(&self) -> DOMString;
fn SetFormMethod(&mut self, _form_method: DOMString) -> ErrorResult;
fn FormNoValidate(&self) -> bool;
fn SetFormNoValidate(&mut self, _form_no_validate: bool) -> ErrorResult;
fn FormTarget(&self) -> DOMString;
fn SetFormTarget(&mut self, _form_target: DOMString) -> ErrorResult;
fn Height(&self) -> u32;
fn SetHeight(&mut self, _height: u32) -> ErrorResult;
fn Indeterminate(&self) -> bool;
fn SetIndeterminate(&mut self, _indeterminate: bool);
fn InputMode(&self) -> DOMString;
fn SetInputMode(&mut self, _input_mode: DOMString) -> ErrorResult;
fn Max(&self) -> DOMString;
fn SetMax(&mut self, _max: DOMString) -> ErrorResult;
fn MaxLength(&self) -> i32;
fn SetMaxLength(&mut self, _max_length: i32) -> ErrorResult;
fn Min(&self) -> DOMString;
fn SetMin(&mut self, _min: DOMString) -> ErrorResult;
fn Multiple(&self) -> bool;
fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Pattern(&self) -> DOMString;
fn SetPattern(&mut self, _pattern: DOMString) -> ErrorResult;
fn Placeholder(&self) -> DOMString;
fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult;
fn ReadOnly(&self) -> bool;
fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult;
fn Required(&self) -> bool;
fn SetRequired(&mut self, _required: bool) -> ErrorResult;
fn Size(&self) -> u32;
fn SetSize(&mut self, _size: u32) -> ErrorResult;
fn Src(&self) -> DOMString;
fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn Step(&self) -> DOMString;
fn SetStep(&mut self, _step: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn DefaultValue(&self) -> DOMString;
fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString) -> ErrorResult;
fn Width(&self) -> u32;
fn SetWidth(&mut self, _width: u32);
fn WillValidate(&self) -> bool;
fn SetWillValidate(&self, _will_validate: bool);
fn GetValidationMessage(&self) -> Fallible<DOMString>;
fn CheckValidity(&self) -> bool;
fn SetCustomValidity(&self, _error: DOMString);
fn Select(&self);
fn GetSelectionStart(&self) -> Fallible<i32>;
fn SetSelectionStart(&mut self, _selection_start: i32) -> ErrorResult;
fn GetSelectionEnd(&self) -> Fallible<i32>;
fn SetSelectionEnd(&mut self, _selection_end: i32) -> ErrorResult;
fn GetSelectionDirection(&self) -> Fallible<DOMString>;
fn SetSelectionDirection(&mut self, _selection_direction: DOMString) -> ErrorResult;
fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
fn UseMap(&self) -> DOMString;
fn SetUseMap(&mut self, _align: DOMString) -> ErrorResult;
}
impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
fn Accept(&self) -> DOMString {
~"" ~""
} }
pub fn SetAccept(&mut self, _accept: DOMString) -> ErrorResult { fn SetAccept(&mut self, _accept: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Alt(&self) -> DOMString { fn Alt(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlt(&mut self, _alt: DOMString) -> ErrorResult { fn SetAlt(&mut self, _alt: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Autocomplete(&self) -> DOMString { fn Autocomplete(&self) -> DOMString {
~"" ~""
} }
pub fn SetAutocomplete(&mut self, _autocomple: DOMString) -> ErrorResult { fn SetAutocomplete(&mut self, _autocomple: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Autofocus(&self) -> bool { fn Autofocus(&self) -> bool {
false false
} }
pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn DefaultChecked(&self) -> bool { fn DefaultChecked(&self) -> bool {
false false
} }
pub fn SetDefaultChecked(&mut self, _default_checked: bool) -> ErrorResult { fn SetDefaultChecked(&mut self, _default_checked: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Checked(&self) -> bool { fn Checked(&self) -> bool {
false false
} }
pub fn SetChecked(&mut self, _checked: bool) { fn SetChecked(&mut self, _checked: bool) {
} }
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormAction(&self) -> DOMString { fn FormAction(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormAction(&mut self, _form_action: DOMString) -> ErrorResult { fn SetFormAction(&mut self, _form_action: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormEnctype(&self) -> DOMString { fn FormEnctype(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormEnctype(&mut self, _form_enctype: DOMString) -> ErrorResult { fn SetFormEnctype(&mut self, _form_enctype: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormMethod(&self) -> DOMString { fn FormMethod(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormMethod(&mut self, _form_method: DOMString) -> ErrorResult { fn SetFormMethod(&mut self, _form_method: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormNoValidate(&self) -> bool { fn FormNoValidate(&self) -> bool {
false false
} }
pub fn SetFormNoValidate(&mut self, _form_no_validate: bool) -> ErrorResult { fn SetFormNoValidate(&mut self, _form_no_validate: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn FormTarget(&self) -> DOMString { fn FormTarget(&self) -> DOMString {
~"" ~""
} }
pub fn SetFormTarget(&mut self, _form_target: DOMString) -> ErrorResult { fn SetFormTarget(&mut self, _form_target: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Height(&self) -> u32 { fn Height(&self) -> u32 {
0 0
} }
pub fn SetHeight(&mut self, _height: u32) -> ErrorResult { fn SetHeight(&mut self, _height: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Indeterminate(&self) -> bool { fn Indeterminate(&self) -> bool {
false false
} }
pub fn SetIndeterminate(&mut self, _indeterminate: bool) { fn SetIndeterminate(&mut self, _indeterminate: bool) {
} }
pub fn InputMode(&self) -> DOMString { fn InputMode(&self) -> DOMString {
~"" ~""
} }
pub fn SetInputMode(&mut self, _input_mode: DOMString) -> ErrorResult { fn SetInputMode(&mut self, _input_mode: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Max(&self) -> DOMString { fn Max(&self) -> DOMString {
~"" ~""
} }
pub fn SetMax(&mut self, _max: DOMString) -> ErrorResult { fn SetMax(&mut self, _max: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn MaxLength(&self) -> i32 { fn MaxLength(&self) -> i32 {
0 0
} }
pub fn SetMaxLength(&mut self, _max_length: i32) -> ErrorResult { fn SetMaxLength(&mut self, _max_length: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Min(&self) -> DOMString { fn Min(&self) -> DOMString {
~"" ~""
} }
pub fn SetMin(&mut self, _min: DOMString) -> ErrorResult { fn SetMin(&mut self, _min: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Multiple(&self) -> bool { fn Multiple(&self) -> bool {
false false
} }
pub fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Pattern(&self) -> DOMString { fn Pattern(&self) -> DOMString {
~"" ~""
} }
pub fn SetPattern(&mut self, _pattern: DOMString) -> ErrorResult { fn SetPattern(&mut self, _pattern: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Placeholder(&self) -> DOMString { fn Placeholder(&self) -> DOMString {
~"" ~""
} }
pub fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult { fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ReadOnly(&self) -> bool { fn ReadOnly(&self) -> bool {
false false
} }
pub fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult { fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Required(&self) -> bool { fn Required(&self) -> bool {
false false
} }
pub fn SetRequired(&mut self, _required: bool) -> ErrorResult { fn SetRequired(&mut self, _required: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Size(&self) -> u32 { fn Size(&self) -> u32 {
0 0
} }
pub fn SetSize(&mut self, _size: u32) -> ErrorResult { fn SetSize(&mut self, _size: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Src(&self) -> DOMString { fn Src(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Step(&self) -> DOMString { fn Step(&self) -> DOMString {
~"" ~""
} }
pub fn SetStep(&mut self, _step: DOMString) -> ErrorResult { fn SetStep(&mut self, _step: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn DefaultValue(&self) -> DOMString { fn DefaultValue(&self) -> DOMString {
~"" ~""
} }
pub fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult { fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { fn SetValue(&mut self, _value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> u32 { fn Width(&self) -> u32 {
0 0
} }
pub fn SetWidth(&mut self, _width: u32) { fn SetWidth(&mut self, _width: u32) {
} }
pub fn WillValidate(&self) -> bool { fn WillValidate(&self) -> bool {
false false
} }
pub fn SetWillValidate(&self, _will_validate: bool) { fn SetWillValidate(&self, _will_validate: bool) {
} }
pub fn GetValidationMessage(&self) -> Fallible<DOMString> { fn GetValidationMessage(&self) -> Fallible<DOMString> {
Ok(~"") Ok(~"")
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
false false
} }
pub fn SetCustomValidity(&self, _error: DOMString) { fn SetCustomValidity(&self, _error: DOMString) {
} }
pub fn Select(&self) { fn Select(&self) {
} }
pub fn GetSelectionStart(&self) -> Fallible<i32> { fn GetSelectionStart(&self) -> Fallible<i32> {
Ok(0) Ok(0)
} }
pub fn SetSelectionStart(&mut self, _selection_start: i32) -> ErrorResult { fn SetSelectionStart(&mut self, _selection_start: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetSelectionEnd(&self) -> Fallible<i32> { fn GetSelectionEnd(&self) -> Fallible<i32> {
Ok(0) Ok(0)
} }
pub fn SetSelectionEnd(&mut self, _selection_end: i32) -> ErrorResult { fn SetSelectionEnd(&mut self, _selection_end: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetSelectionDirection(&self) -> Fallible<DOMString> { fn GetSelectionDirection(&self) -> Fallible<DOMString> {
Ok(~"") Ok(~"")
} }
pub fn SetSelectionDirection(&mut self, _selection_direction: DOMString) -> ErrorResult { fn SetSelectionDirection(&mut self, _selection_direction: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn UseMap(&self) -> DOMString { fn UseMap(&self) -> DOMString {
~"" ~""
} }
pub fn SetUseMap(&mut self, _align: DOMString) -> ErrorResult { fn SetUseMap(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLLabelElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLLabelElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLLabelElementDerived; use dom::bindings::codegen::InheritTypes::HTMLLabelElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLLabelElementTypeId; use dom::element::HTMLLabelElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,23 +27,28 @@ impl HTMLLabelElementDerived for EventTarget {
} }
impl HTMLLabelElement { impl HTMLLabelElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLLabelElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLabelElement {
HTMLLabelElement { HTMLLabelElement {
htmlelement: HTMLElement::new_inherited(HTMLLabelElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLabelElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLLabelElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLabelElement> {
let element = HTMLLabelElement::new_inherited(localName, document.clone()); let element = HTMLLabelElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLLabelElementBinding::Wrap) Node::reflect_node(~element, document, HTMLLabelElementBinding::Wrap)
} }
} }
impl HTMLLabelElement { pub trait HTMLLabelElementMethods {
pub fn HtmlFor(&self) -> DOMString { fn HtmlFor(&self) -> DOMString;
fn SetHtmlFor(&mut self, _html_for: DOMString);
}
impl<'a> HTMLLabelElementMethods for JSRef<'a, HTMLLabelElement> {
fn HtmlFor(&self) -> DOMString {
~"" ~""
} }
pub fn SetHtmlFor(&mut self, _html_for: DOMString) { fn SetHtmlFor(&mut self, _html_for: DOMString) {
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLLegendElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLLegendElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLLegendElementDerived; use dom::bindings::codegen::InheritTypes::HTMLLegendElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLLegendElementTypeId; use dom::element::HTMLLegendElementTypeId;
@ -28,24 +28,29 @@ impl HTMLLegendElementDerived for EventTarget {
} }
impl HTMLLegendElement { impl HTMLLegendElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLLegendElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLegendElement {
HTMLLegendElement { HTMLLegendElement {
htmlelement: HTMLElement::new_inherited(HTMLLegendElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLegendElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLLegendElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLegendElement> {
let element = HTMLLegendElement::new_inherited(localName, document.clone()); let element = HTMLLegendElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLLegendElementBinding::Wrap) Node::reflect_node(~element, document, HTMLLegendElementBinding::Wrap)
} }
} }
impl HTMLLegendElement { pub trait HTMLLegendElementMethods {
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
}
impl<'a> HTMLLegendElementMethods for JSRef<'a, HTMLLegendElement> {
fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLLIElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLLIElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLLIElementDerived; use dom::bindings::codegen::InheritTypes::HTMLLIElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLLIElementTypeId; use dom::element::HTMLLIElementTypeId;
@ -28,32 +28,39 @@ impl HTMLLIElementDerived for EventTarget {
} }
impl HTMLLIElement { impl HTMLLIElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLLIElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLIElement {
HTMLLIElement { HTMLLIElement {
htmlelement: HTMLElement::new_inherited(HTMLLIElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLIElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLLIElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLIElement> {
let element = HTMLLIElement::new_inherited(localName, document.clone()); let element = HTMLLIElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLLIElementBinding::Wrap) Node::reflect_node(~element, document, HTMLLIElementBinding::Wrap)
} }
} }
impl HTMLLIElement { pub trait HTMLLIElementMethods {
pub fn Value(&self) -> i32 { fn Value(&self) -> i32;
fn SetValue(&mut self, _value: i32) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
}
impl<'a> HTMLLIElementMethods for JSRef<'a, HTMLLIElement> {
fn Value(&self) -> i32 {
0 0
} }
pub fn SetValue(&mut self, _value: i32) -> ErrorResult { fn SetValue(&mut self, _value: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLLinkElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLLinkElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived; use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLLinkElementTypeId; use dom::element::HTMLLinkElementTypeId;
@ -28,95 +28,118 @@ impl HTMLLinkElementDerived for EventTarget {
} }
impl HTMLLinkElement { impl HTMLLinkElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLLinkElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLinkElement {
HTMLLinkElement { HTMLLinkElement {
htmlelement: HTMLElement::new_inherited(HTMLLinkElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLinkElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLLinkElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLinkElement> {
let element = HTMLLinkElement::new_inherited(localName, document.clone()); let element = HTMLLinkElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLLinkElementBinding::Wrap) Node::reflect_node(~element, document, HTMLLinkElementBinding::Wrap)
} }
} }
impl HTMLLinkElement { pub trait HTMLLinkElementMethods {
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disable: bool);
fn Href(&self) -> DOMString;
fn SetHref(&mut self, _href: DOMString) -> ErrorResult;
fn CrossOrigin(&self) -> DOMString;
fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult;
fn Rel(&self) -> DOMString;
fn SetRel(&mut self, _rel: DOMString) -> ErrorResult;
fn Media(&self) -> DOMString;
fn SetMedia(&mut self, _media: DOMString) -> ErrorResult;
fn Hreflang(&self) -> DOMString;
fn SetHreflang(&mut self, _href: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Charset(&self) -> DOMString;
fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult;
fn Rev(&self) -> DOMString;
fn SetRev(&mut self, _rev: DOMString) -> ErrorResult;
fn Target(&self) -> DOMString;
fn SetTarget(&mut self, _target: DOMString) -> ErrorResult;
}
impl<'a> HTMLLinkElementMethods for JSRef<'a, HTMLLinkElement> {
fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disable: bool) { fn SetDisabled(&mut self, _disable: bool) {
} }
pub fn Href(&self) -> DOMString { fn Href(&self) -> DOMString {
~"" ~""
} }
pub fn SetHref(&mut self, _href: DOMString) -> ErrorResult { fn SetHref(&mut self, _href: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CrossOrigin(&self) -> DOMString { fn CrossOrigin(&self) -> DOMString {
~"" ~""
} }
pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Rel(&self) -> DOMString { fn Rel(&self) -> DOMString {
~"" ~""
} }
pub fn SetRel(&mut self, _rel: DOMString) -> ErrorResult { fn SetRel(&mut self, _rel: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Media(&self) -> DOMString { fn Media(&self) -> DOMString {
~"" ~""
} }
pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { fn SetMedia(&mut self, _media: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Hreflang(&self) -> DOMString { fn Hreflang(&self) -> DOMString {
~"" ~""
} }
pub fn SetHreflang(&mut self, _href: DOMString) -> ErrorResult { fn SetHreflang(&mut self, _href: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Charset(&self) -> DOMString { fn Charset(&self) -> DOMString {
~"" ~""
} }
pub fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Rev(&self) -> DOMString { fn Rev(&self) -> DOMString {
~"" ~""
} }
pub fn SetRev(&mut self, _rev: DOMString) -> ErrorResult { fn SetRev(&mut self, _rev: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Target(&self) -> DOMString { fn Target(&self) -> DOMString {
~"" ~""
} }
pub fn SetTarget(&mut self, _target: DOMString) -> ErrorResult { fn SetTarget(&mut self, _target: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLMainElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLMainElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLMainElementDerived; use dom::bindings::codegen::InheritTypes::HTMLMainElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLMainElementTypeId; use dom::element::HTMLMainElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLMainElementDerived for EventTarget {
} }
impl HTMLMainElement { impl HTMLMainElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLMainElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMainElement {
HTMLMainElement { HTMLMainElement {
htmlelement: HTMLElement::new_inherited(HTMLMainElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLMainElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLMainElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLMainElement> {
let element = HTMLMainElement::new_inherited(localName, document.clone()); let element = HTMLMainElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLMainElementBinding::Wrap) Node::reflect_node(~element, document, HTMLMainElementBinding::Wrap)
} }
} }
pub trait HTMLMainElementMethods {
}

View file

@ -4,14 +4,14 @@
use dom::bindings::codegen::BindingDeclarations::HTMLMapElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLMapElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLMapElementDerived; use dom::bindings::codegen::InheritTypes::HTMLMapElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLMapElementTypeId; use dom::element::HTMLMapElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlcollection::{HTMLCollection, Static}; use dom::htmlcollection::{HTMLCollection, Static};
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{Node, ElementNodeTypeId}; use dom::node::{Node, ElementNodeTypeId, window_from_node};
use servo_util::str::DOMString; use servo_util::str::DOMString;
#[deriving(Encodable)] #[deriving(Encodable)]
@ -29,31 +29,37 @@ impl HTMLMapElementDerived for EventTarget {
} }
impl HTMLMapElement { impl HTMLMapElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLMapElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMapElement {
HTMLMapElement { HTMLMapElement {
htmlelement: HTMLElement::new_inherited(HTMLMapElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLMapElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLMapElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLMapElement> {
let element = HTMLMapElement::new_inherited(localName, document.clone()); let element = HTMLMapElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLMapElementBinding::Wrap) Node::reflect_node(~element, document, HTMLMapElementBinding::Wrap)
} }
} }
impl HTMLMapElement { pub trait HTMLMapElementMethods {
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Areas(&self) -> Temporary<HTMLCollection>;
}
impl<'a> HTMLMapElementMethods for JSRef<'a, HTMLMapElement> {
fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Areas(&self) -> JS<HTMLCollection> { fn Areas(&self) -> Temporary<HTMLCollection> {
// FIXME: https://github.com/mozilla/servo/issues/1845 // FIXME: https://github.com/mozilla/servo/issues/1845
let doc = self.htmlelement.element.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); HTMLCollection::new(&*window, Static(vec!()))
HTMLCollection::new(&doc.window, Static(vec!()))
} }
} }

View file

@ -2,7 +2,7 @@
* 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::js::JS; use dom::bindings::js::{JSRef};
use dom::bindings::codegen::InheritTypes::HTMLMediaElementDerived; use dom::bindings::codegen::InheritTypes::HTMLMediaElementDerived;
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
@ -28,146 +28,182 @@ impl HTMLMediaElementDerived for EventTarget {
} }
impl HTMLMediaElement { impl HTMLMediaElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JS<Document>) -> HTMLMediaElement { pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: &JSRef<Document>) -> HTMLMediaElement {
HTMLMediaElement { HTMLMediaElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, document) htmlelement: HTMLElement::new_inherited(type_id, tag_name, document)
} }
} }
} }
impl HTMLMediaElement { pub trait HTMLMediaElementMethods {
pub fn Src(&self) -> DOMString { fn Src(&self) -> DOMString;
fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn CurrentSrc(&self) -> DOMString;
fn CrossOrigin(&self) -> DOMString;
fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult;
fn Preload(&self) -> DOMString;
fn SetPreload(&mut self, _preload: DOMString) -> ErrorResult;
fn Load(&self);
fn CanPlayType(&self, _type: DOMString) -> DOMString;
fn ReadyState(&self) -> u16;
fn Seeking(&self) -> bool;
fn CurrentTime(&self) -> f64;
fn SetCurrentTime(&mut self, _current_time: f64) -> ErrorResult;
fn GetDuration(&self) -> f64;
fn Paused(&self) -> bool;
fn DefaultPlaybackRate(&self) -> f64;
fn SetDefaultPlaybackRate(&mut self, _default_playback_rate: f64) -> ErrorResult;
fn PlaybackRate(&self) -> f64;
fn SetPlaybackRate(&mut self, _playback_rate: f64) -> ErrorResult;
fn Ended(&self) -> bool;
fn Autoplay(&self) -> bool;
fn SetAutoplay(&mut self, _autoplay: bool) -> ErrorResult;
fn Loop(&self) -> bool;
fn SetLoop(&mut self, _loop: bool) -> ErrorResult;
fn Play(&self) -> ErrorResult;
fn Pause(&self) -> ErrorResult;
fn Controls(&self) -> bool;
fn SetControls(&mut self, _controls: bool) -> ErrorResult;
fn Volume(&self) -> f64;
fn SetVolume(&mut self, _volume: f64) -> ErrorResult;
fn Muted(&self) -> bool;
fn SetMuted(&mut self, _muted: bool);
fn DefaultMuted(&self) -> bool;
fn SetDefaultMuted(&mut self, _default_muted: bool) -> ErrorResult;
}
impl<'a> HTMLMediaElementMethods for JSRef<'a, HTMLMediaElement> {
fn Src(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CurrentSrc(&self) -> DOMString { fn CurrentSrc(&self) -> DOMString {
~"" ~""
} }
pub fn CrossOrigin(&self) -> DOMString { fn CrossOrigin(&self) -> DOMString {
~"" ~""
} }
pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Preload(&self) -> DOMString { fn Preload(&self) -> DOMString {
~"" ~""
} }
pub fn SetPreload(&mut self, _preload: DOMString) -> ErrorResult { fn SetPreload(&mut self, _preload: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Load(&self) { fn Load(&self) {
} }
pub fn CanPlayType(&self, _type: DOMString) -> DOMString { fn CanPlayType(&self, _type: DOMString) -> DOMString {
~"" ~""
} }
pub fn ReadyState(&self) -> u16 { fn ReadyState(&self) -> u16 {
0 0
} }
pub fn Seeking(&self) -> bool { fn Seeking(&self) -> bool {
false false
} }
pub fn CurrentTime(&self) -> f64 { fn CurrentTime(&self) -> f64 {
0f64 0f64
} }
pub fn SetCurrentTime(&mut self, _current_time: f64) -> ErrorResult { fn SetCurrentTime(&mut self, _current_time: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetDuration(&self) -> f64 { fn GetDuration(&self) -> f64 {
0f64 0f64
} }
pub fn Paused(&self) -> bool { fn Paused(&self) -> bool {
false false
} }
pub fn DefaultPlaybackRate(&self) -> f64 { fn DefaultPlaybackRate(&self) -> f64 {
0f64 0f64
} }
pub fn SetDefaultPlaybackRate(&mut self, _default_playback_rate: f64) -> ErrorResult { fn SetDefaultPlaybackRate(&mut self, _default_playback_rate: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn PlaybackRate(&self) -> f64 { fn PlaybackRate(&self) -> f64 {
0f64 0f64
} }
pub fn SetPlaybackRate(&mut self, _playback_rate: f64) -> ErrorResult { fn SetPlaybackRate(&mut self, _playback_rate: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Ended(&self) -> bool { fn Ended(&self) -> bool {
false false
} }
pub fn Autoplay(&self) -> bool { fn Autoplay(&self) -> bool {
false false
} }
pub fn SetAutoplay(&mut self, _autoplay: bool) -> ErrorResult { fn SetAutoplay(&mut self, _autoplay: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Loop(&self) -> bool { fn Loop(&self) -> bool {
false false
} }
pub fn SetLoop(&mut self, _loop: bool) -> ErrorResult { fn SetLoop(&mut self, _loop: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Play(&self) -> ErrorResult { fn Play(&self) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Pause(&self) -> ErrorResult { fn Pause(&self) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Controls(&self) -> bool { fn Controls(&self) -> bool {
false false
} }
pub fn SetControls(&mut self, _controls: bool) -> ErrorResult { fn SetControls(&mut self, _controls: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Volume(&self) -> f64 { fn Volume(&self) -> f64 {
0f64 0f64
} }
pub fn SetVolume(&mut self, _volume: f64) -> ErrorResult { fn SetVolume(&mut self, _volume: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Muted(&self) -> bool { fn Muted(&self) -> bool {
false false
} }
pub fn SetMuted(&mut self, _muted: bool) { fn SetMuted(&mut self, _muted: bool) {
} }
pub fn DefaultMuted(&self) -> bool { fn DefaultMuted(&self) -> bool {
false false
} }
pub fn SetDefaultMuted(&mut self, _default_muted: bool) -> ErrorResult { fn SetDefaultMuted(&mut self, _default_muted: bool) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLMetaElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLMetaElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLMetaElementDerived; use dom::bindings::codegen::InheritTypes::HTMLMetaElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLMetaElementTypeId; use dom::element::HTMLMetaElementTypeId;
@ -28,48 +28,59 @@ impl HTMLMetaElementDerived for EventTarget {
} }
impl HTMLMetaElement { impl HTMLMetaElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLMetaElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMetaElement {
HTMLMetaElement { HTMLMetaElement {
htmlelement: HTMLElement::new_inherited(HTMLMetaElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLMetaElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLMetaElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLMetaElement> {
let element = HTMLMetaElement::new_inherited(localName, document.clone()); let element = HTMLMetaElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLMetaElementBinding::Wrap) Node::reflect_node(~element, document, HTMLMetaElementBinding::Wrap)
} }
} }
impl HTMLMetaElement { pub trait HTMLMetaElementMethods {
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn HttpEquiv(&self) -> DOMString;
fn SetHttpEquiv(&mut self, _http_equiv: DOMString) -> ErrorResult;
fn Content(&self) -> DOMString;
fn SetContent(&mut self, _content: DOMString) -> ErrorResult;
fn Scheme(&self) -> DOMString;
fn SetScheme(&mut self, _scheme: DOMString) -> ErrorResult;
}
impl<'a> HTMLMetaElementMethods for JSRef<'a, HTMLMetaElement> {
fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn HttpEquiv(&self) -> DOMString { fn HttpEquiv(&self) -> DOMString {
~"" ~""
} }
pub fn SetHttpEquiv(&mut self, _http_equiv: DOMString) -> ErrorResult { fn SetHttpEquiv(&mut self, _http_equiv: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Content(&self) -> DOMString { fn Content(&self) -> DOMString {
~"" ~""
} }
pub fn SetContent(&mut self, _content: DOMString) -> ErrorResult { fn SetContent(&mut self, _content: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Scheme(&self) -> DOMString { fn Scheme(&self) -> DOMString {
~"" ~""
} }
pub fn SetScheme(&mut self, _scheme: DOMString) -> ErrorResult { fn SetScheme(&mut self, _scheme: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLMeterElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLMeterElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLMeterElementDerived; use dom::bindings::codegen::InheritTypes::HTMLMeterElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLMeterElementTypeId; use dom::element::HTMLMeterElementTypeId;
@ -28,64 +28,80 @@ impl HTMLMeterElementDerived for EventTarget {
} }
impl HTMLMeterElement { impl HTMLMeterElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLMeterElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMeterElement {
HTMLMeterElement { HTMLMeterElement {
htmlelement: HTMLElement::new_inherited(HTMLMeterElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLMeterElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLMeterElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLMeterElement> {
let element = HTMLMeterElement::new_inherited(localName, document.clone()); let element = HTMLMeterElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLMeterElementBinding::Wrap) Node::reflect_node(~element, document, HTMLMeterElementBinding::Wrap)
} }
} }
impl HTMLMeterElement { pub trait HTMLMeterElementMethods {
pub fn Value(&self) -> f64 { fn Value(&self) -> f64;
fn SetValue(&mut self, _value: f64) -> ErrorResult;
fn Min(&self) -> f64;
fn SetMin(&mut self, _min: f64) -> ErrorResult;
fn Max(&self) -> f64;
fn SetMax(&mut self, _max: f64) -> ErrorResult;
fn Low(&self) -> f64;
fn SetLow(&mut self, _low: f64) -> ErrorResult;
fn High(&self) -> f64;
fn SetHigh(&mut self, _high: f64) -> ErrorResult;
fn Optimum(&self) -> f64;
fn SetOptimum(&mut self, _optimum: f64) -> ErrorResult;
}
impl<'a> HTMLMeterElementMethods for JSRef<'a, HTMLMeterElement> {
fn Value(&self) -> f64 {
0.0 0.0
} }
pub fn SetValue(&mut self, _value: f64) -> ErrorResult { fn SetValue(&mut self, _value: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Min(&self) -> f64 { fn Min(&self) -> f64 {
0.0 0.0
} }
pub fn SetMin(&mut self, _min: f64) -> ErrorResult { fn SetMin(&mut self, _min: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Max(&self) -> f64 { fn Max(&self) -> f64 {
0.0 0.0
} }
pub fn SetMax(&mut self, _max: f64) -> ErrorResult { fn SetMax(&mut self, _max: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Low(&self) -> f64 { fn Low(&self) -> f64 {
0.0 0.0
} }
pub fn SetLow(&mut self, _low: f64) -> ErrorResult { fn SetLow(&mut self, _low: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn High(&self) -> f64 { fn High(&self) -> f64 {
0.0 0.0
} }
pub fn SetHigh(&mut self, _high: f64) -> ErrorResult { fn SetHigh(&mut self, _high: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Optimum(&self) -> f64 { fn Optimum(&self) -> f64 {
0.0 0.0
} }
pub fn SetOptimum(&mut self, _optimum: f64) -> ErrorResult { fn SetOptimum(&mut self, _optimum: f64) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLModElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLModElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLModElementDerived; use dom::bindings::codegen::InheritTypes::HTMLModElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLModElementTypeId; use dom::element::HTMLModElementTypeId;
@ -28,32 +28,39 @@ impl HTMLModElementDerived for EventTarget {
} }
impl HTMLModElement { impl HTMLModElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLModElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLModElement {
HTMLModElement { HTMLModElement {
htmlelement: HTMLElement::new_inherited(HTMLModElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLModElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLModElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLModElement> {
let element = HTMLModElement::new_inherited(localName, document.clone()); let element = HTMLModElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLModElementBinding::Wrap) Node::reflect_node(~element, document, HTMLModElementBinding::Wrap)
} }
} }
impl HTMLModElement { pub trait HTMLModElementMethods {
pub fn Cite(&self) -> DOMString { fn Cite(&self) -> DOMString;
fn SetCite(&mut self, _cite: DOMString) -> ErrorResult;
fn DateTime(&self) -> DOMString;
fn SetDateTime(&mut self, _datetime: DOMString) -> ErrorResult;
}
impl<'a> HTMLModElementMethods for JSRef<'a, HTMLModElement> {
fn Cite(&self) -> DOMString {
~"" ~""
} }
pub fn SetCite(&mut self, _cite: DOMString) -> ErrorResult { fn SetCite(&mut self, _cite: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn DateTime(&self) -> DOMString { fn DateTime(&self) -> DOMString {
~"" ~""
} }
pub fn SetDateTime(&mut self, _datetime: DOMString) -> ErrorResult { fn SetDateTime(&mut self, _datetime: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -2,10 +2,11 @@
* 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::attr::AttrMethods;
use dom::bindings::codegen::BindingDeclarations::HTMLObjectElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLObjectElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLObjectElementDerived; use dom::bindings::codegen::InheritTypes::HTMLObjectElementDerived;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, HTMLObjectElementTypeId}; use dom::element::{Element, HTMLObjectElementTypeId};
@ -41,14 +42,14 @@ impl HTMLObjectElementDerived for EventTarget {
} }
impl HTMLObjectElement { impl HTMLObjectElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLObjectElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLObjectElement {
HTMLObjectElement { HTMLObjectElement {
htmlelement: HTMLElement::new_inherited(HTMLObjectElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLObjectElementTypeId, localName, document),
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLObjectElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLObjectElement> {
let element = HTMLObjectElement::new_inherited(localName, document.clone()); let element = HTMLObjectElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLObjectElementBinding::Wrap) Node::reflect_node(~element, document, HTMLObjectElementBinding::Wrap)
} }
} }
@ -57,15 +58,15 @@ trait ProcessDataURL {
fn process_data_url(&mut self, image_cache: ImageCacheTask, url: Option<Url>); fn process_data_url(&mut self, image_cache: ImageCacheTask, url: Option<Url>);
} }
impl ProcessDataURL for JS<HTMLObjectElement> { impl<'a> ProcessDataURL for JSRef<'a, HTMLObjectElement> {
// Makes the local `data` member match the status of the `data` attribute and starts // Makes the local `data` member match the status of the `data` attribute and starts
/// prefetching the image. This method must be called after `data` is changed. /// prefetching the image. This method must be called after `data` is changed.
fn process_data_url(&mut self, image_cache: ImageCacheTask, url: Option<Url>) { fn process_data_url(&mut self, image_cache: ImageCacheTask, url: Option<Url>) {
let elem: JS<Element> = ElementCast::from(self); let elem: &JSRef<Element> = ElementCast::from_ref(self);
// TODO: support other values // TODO: support other values
match (elem.get_attribute(Null, "type").map(|x| x.get().Value()), match (elem.get_attribute(Null, "type").map(|x| x.root().Value()),
elem.get_attribute(Null, "data").map(|x| x.get().Value())) { elem.get_attribute(Null, "data").map(|x| x.root().Value())) {
(None, Some(uri)) => { (None, Some(uri)) => {
if is_image_data(uri) { if is_image_data(uri) {
let data_url = parse_url(uri, url); let data_url = parse_url(uri, url);
@ -78,177 +79,220 @@ impl ProcessDataURL for JS<HTMLObjectElement> {
} }
} }
impl HTMLObjectElement { pub trait HTMLObjectElementMethods {
pub fn Data(&self) -> DOMString { fn Data(&self) -> DOMString;
fn SetData(&mut self, _data: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn UseMap(&self) -> DOMString;
fn SetUseMap(&mut self, _use_map: DOMString) -> ErrorResult;
fn GetForm(&self) -> Option<Temporary<HTMLFormElement>>;
fn Width(&self) -> DOMString;
fn SetWidth(&mut self, _width: DOMString) -> ErrorResult;
fn Height(&self) -> DOMString;
fn SetHeight(&mut self, _height: DOMString) -> ErrorResult;
fn GetContentDocument(&self) -> Option<Temporary<Document>>;
fn GetContentWindow(&self) -> Option<Temporary<Window>>;
fn WillValidate(&self) -> bool;
fn Validity(&self) -> Temporary<ValidityState>;
fn ValidationMessage(&self) -> DOMString;
fn CheckValidity(&self) -> bool;
fn SetCustomValidity(&mut self, _error: DOMString);
fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
fn Archive(&self) -> DOMString;
fn SetArchive(&mut self, _archive: DOMString) -> ErrorResult;
fn Code(&self) -> DOMString;
fn SetCode(&mut self, _code: DOMString) -> ErrorResult;
fn Declare(&self) -> bool;
fn SetDeclare(&mut self, _declare: bool) -> ErrorResult;
fn Hspace(&self) -> u32;
fn SetHspace(&mut self, _hspace: u32) -> ErrorResult;
fn Standby(&self) -> DOMString;
fn SetStandby(&mut self, _standby: DOMString) -> ErrorResult;
fn Vspace(&self) -> u32;
fn SetVspace(&mut self, _vspace: u32) -> ErrorResult;
fn CodeBase(&self) -> DOMString;
fn SetCodeBase(&mut self, _codebase: DOMString) -> ErrorResult;
fn CodeType(&self) -> DOMString;
fn SetCodeType(&mut self, _codetype: DOMString) -> ErrorResult;
fn Border(&self) -> DOMString;
fn SetBorder(&mut self, _border: DOMString) -> ErrorResult;
fn GetSVGDocument(&self) -> Option<Temporary<Document>>;
}
impl<'a> HTMLObjectElementMethods for JSRef<'a, HTMLObjectElement> {
fn Data(&self) -> DOMString {
~"" ~""
} }
pub fn SetData(&mut self, _data: DOMString) -> ErrorResult { fn SetData(&mut self, _data: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn UseMap(&self) -> DOMString { fn UseMap(&self) -> DOMString {
~"" ~""
} }
pub fn SetUseMap(&mut self, _use_map: DOMString) -> ErrorResult { fn SetUseMap(&mut self, _use_map: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<JS<HTMLFormElement>> { fn GetForm(&self) -> Option<Temporary<HTMLFormElement>> {
None None
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { fn SetWidth(&mut self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Height(&self) -> DOMString { fn Height(&self) -> DOMString {
~"" ~""
} }
pub fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { fn SetHeight(&mut self, _height: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetContentDocument(&self) -> Option<JS<Document>> { fn GetContentDocument(&self) -> Option<Temporary<Document>> {
None None
} }
pub fn GetContentWindow(&self) -> Option<JS<Window>> { fn GetContentWindow(&self) -> Option<Temporary<Window>> {
None None
} }
pub fn WillValidate(&self) -> bool { fn WillValidate(&self) -> bool {
false false
} }
pub fn Validity(&self) -> JS<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let doc = self.htmlelement.element.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); ValidityState::new(&*window)
ValidityState::new(&doc.window)
} }
pub fn ValidationMessage(&self) -> DOMString { fn ValidationMessage(&self) -> DOMString {
~"" ~""
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
false false
} }
pub fn SetCustomValidity(&mut self, _error: DOMString) { fn SetCustomValidity(&mut self, _error: DOMString) {
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Archive(&self) -> DOMString { fn Archive(&self) -> DOMString {
~"" ~""
} }
pub fn SetArchive(&mut self, _archive: DOMString) -> ErrorResult { fn SetArchive(&mut self, _archive: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Code(&self) -> DOMString { fn Code(&self) -> DOMString {
~"" ~""
} }
pub fn SetCode(&mut self, _code: DOMString) -> ErrorResult { fn SetCode(&mut self, _code: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Declare(&self) -> bool { fn Declare(&self) -> bool {
false false
} }
pub fn SetDeclare(&mut self, _declare: bool) -> ErrorResult { fn SetDeclare(&mut self, _declare: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Hspace(&self) -> u32 { fn Hspace(&self) -> u32 {
0 0
} }
pub fn SetHspace(&mut self, _hspace: u32) -> ErrorResult { fn SetHspace(&mut self, _hspace: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Standby(&self) -> DOMString { fn Standby(&self) -> DOMString {
~"" ~""
} }
pub fn SetStandby(&mut self, _standby: DOMString) -> ErrorResult { fn SetStandby(&mut self, _standby: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Vspace(&self) -> u32 { fn Vspace(&self) -> u32 {
0 0
} }
pub fn SetVspace(&mut self, _vspace: u32) -> ErrorResult { fn SetVspace(&mut self, _vspace: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CodeBase(&self) -> DOMString { fn CodeBase(&self) -> DOMString {
~"" ~""
} }
pub fn SetCodeBase(&mut self, _codebase: DOMString) -> ErrorResult { fn SetCodeBase(&mut self, _codebase: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CodeType(&self) -> DOMString { fn CodeType(&self) -> DOMString {
~"" ~""
} }
pub fn SetCodeType(&mut self, _codetype: DOMString) -> ErrorResult { fn SetCodeType(&mut self, _codetype: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Border(&self) -> DOMString { fn Border(&self) -> DOMString {
~"" ~""
} }
pub fn SetBorder(&mut self, _border: DOMString) -> ErrorResult { fn SetBorder(&mut self, _border: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetSVGDocument(&self) -> Option<JS<Document>> { fn GetSVGDocument(&self) -> Option<Temporary<Document>> {
None None
} }
} }
impl VirtualMethods for JS<HTMLObjectElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
fn super_type(&self) -> Option<~VirtualMethods:> { fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
let htmlelement: JS<HTMLElement> = HTMLElementCast::from(self); let htmlelement: &mut JSRef<HTMLElement> = HTMLElementCast::from_mut_ref(self);
Some(~htmlelement as ~VirtualMethods:) Some(htmlelement as &mut VirtualMethods:)
} }
fn after_set_attr(&mut self, name: DOMString, value: DOMString) { fn after_set_attr(&mut self, name: DOMString, value: DOMString) {
@ -258,9 +302,9 @@ impl VirtualMethods for JS<HTMLObjectElement> {
} }
if "data" == name { if "data" == name {
let window = window_from_node(self); let window = window_from_node(self).root();
let url = Some(window.get().get_url()); let url = Some(window.deref().get_url());
self.process_data_url(window.get().image_cache_task.clone(), url); self.process_data_url(window.deref().image_cache_task.clone(), url);
} }
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLOListElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLOListElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLOListElementDerived; use dom::bindings::codegen::InheritTypes::HTMLOListElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLOListElementTypeId; use dom::element::HTMLOListElementTypeId;
@ -28,48 +28,59 @@ impl HTMLOListElementDerived for EventTarget {
} }
impl HTMLOListElement { impl HTMLOListElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLOListElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOListElement {
HTMLOListElement { HTMLOListElement {
htmlelement: HTMLElement::new_inherited(HTMLOListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOListElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLOListElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOListElement> {
let element = HTMLOListElement::new_inherited(localName, document.clone()); let element = HTMLOListElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLOListElementBinding::Wrap) Node::reflect_node(~element, document, HTMLOListElementBinding::Wrap)
} }
} }
impl HTMLOListElement { pub trait HTMLOListElementMethods {
pub fn Reversed(&self) -> bool { fn Reversed(&self) -> bool;
fn SetReversed(&self, _reversed: bool) -> ErrorResult;
fn Start(&self) -> i32;
fn SetStart(&mut self, _start: i32) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Compact(&self) -> bool;
fn SetCompact(&self, _compact: bool) -> ErrorResult;
}
impl<'a> HTMLOListElementMethods for JSRef<'a, HTMLOListElement> {
fn Reversed(&self) -> bool {
false false
} }
pub fn SetReversed(&self, _reversed: bool) -> ErrorResult { fn SetReversed(&self, _reversed: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Start(&self) -> i32 { fn Start(&self) -> i32 {
0 0
} }
pub fn SetStart(&mut self, _start: i32) -> ErrorResult { fn SetStart(&mut self, _start: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Compact(&self) -> bool { fn Compact(&self) -> bool {
false false
} }
pub fn SetCompact(&self, _compact: bool) -> ErrorResult { fn SetCompact(&self, _compact: bool) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLOptGroupElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLOptGroupElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLOptGroupElementDerived; use dom::bindings::codegen::InheritTypes::HTMLOptGroupElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLOptGroupElementTypeId; use dom::element::HTMLOptGroupElementTypeId;
@ -28,32 +28,39 @@ impl HTMLOptGroupElementDerived for EventTarget {
} }
impl HTMLOptGroupElement { impl HTMLOptGroupElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLOptGroupElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOptGroupElement {
HTMLOptGroupElement { HTMLOptGroupElement {
htmlelement: HTMLElement::new_inherited(HTMLOptGroupElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOptGroupElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLOptGroupElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOptGroupElement> {
let element = HTMLOptGroupElement::new_inherited(localName, document.clone()); let element = HTMLOptGroupElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLOptGroupElementBinding::Wrap) Node::reflect_node(~element, document, HTMLOptGroupElementBinding::Wrap)
} }
} }
impl HTMLOptGroupElement { pub trait HTMLOptGroupElementMethods {
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult;
fn Label(&self) -> DOMString;
fn SetLabel(&mut self, _label: DOMString) -> ErrorResult;
}
impl<'a> HTMLOptGroupElementMethods for JSRef<'a, HTMLOptGroupElement> {
fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Label(&self) -> DOMString { fn Label(&self) -> DOMString {
~"" ~""
} }
pub fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { fn SetLabel(&mut self, _label: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLOptionElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLOptionElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLOptionElementDerived; use dom::bindings::codegen::InheritTypes::HTMLOptionElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLOptionElementTypeId; use dom::element::HTMLOptionElementTypeId;
@ -29,72 +29,89 @@ impl HTMLOptionElementDerived for EventTarget {
} }
impl HTMLOptionElement { impl HTMLOptionElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLOptionElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOptionElement {
HTMLOptionElement { HTMLOptionElement {
htmlelement: HTMLElement::new_inherited(HTMLOptionElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOptionElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLOptionElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOptionElement> {
let element = HTMLOptionElement::new_inherited(localName, document.clone()); let element = HTMLOptionElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLOptionElementBinding::Wrap) Node::reflect_node(~element, document, HTMLOptionElementBinding::Wrap)
} }
} }
impl HTMLOptionElement { pub trait HTMLOptionElementMethods {
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult;
fn GetForm(&self) -> Option<Temporary<HTMLFormElement>>;
fn Label(&self) -> DOMString;
fn SetLabel(&mut self, _label: DOMString) -> ErrorResult;
fn DefaultSelected(&self) -> bool;
fn SetDefaultSelected(&mut self, _default_selected: bool) -> ErrorResult;
fn Selected(&self) -> bool;
fn SetSelected(&mut self, _selected: bool) -> ErrorResult;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString) -> ErrorResult;
fn Text(&self) -> DOMString;
fn SetText(&mut self, _text: DOMString) -> ErrorResult;
fn Index(&self) -> i32;
}
impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> {
fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<JS<HTMLFormElement>> { fn GetForm(&self) -> Option<Temporary<HTMLFormElement>> {
None None
} }
pub fn Label(&self) -> DOMString { fn Label(&self) -> DOMString {
~"" ~""
} }
pub fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { fn SetLabel(&mut self, _label: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn DefaultSelected(&self) -> bool { fn DefaultSelected(&self) -> bool {
false false
} }
pub fn SetDefaultSelected(&mut self, _default_selected: bool) -> ErrorResult { fn SetDefaultSelected(&mut self, _default_selected: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Selected(&self) -> bool { fn Selected(&self) -> bool {
false false
} }
pub fn SetSelected(&mut self, _selected: bool) -> ErrorResult { fn SetSelected(&mut self, _selected: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { fn SetValue(&mut self, _value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Text(&self) -> DOMString { fn Text(&self) -> DOMString {
~"" ~""
} }
pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { fn SetText(&mut self, _text: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Index(&self) -> i32 { fn Index(&self) -> i32 {
0 0
} }
} }

View file

@ -4,14 +4,14 @@
use dom::bindings::codegen::BindingDeclarations::HTMLOutputElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLOutputElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLOutputElementDerived; use dom::bindings::codegen::InheritTypes::HTMLOutputElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLOutputElementTypeId; use dom::element::HTMLOutputElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::htmlformelement::HTMLFormElement; use dom::htmlformelement::HTMLFormElement;
use dom::node::{Node, ElementNodeTypeId}; use dom::node::{Node, ElementNodeTypeId, window_from_node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
use servo_util::str::DOMString; use servo_util::str::DOMString;
@ -30,79 +30,93 @@ impl HTMLOutputElementDerived for EventTarget {
} }
impl HTMLOutputElement { impl HTMLOutputElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLOutputElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOutputElement {
HTMLOutputElement { HTMLOutputElement {
htmlelement: HTMLElement::new_inherited(HTMLOutputElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOutputElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLOutputElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOutputElement> {
let element = HTMLOutputElement::new_inherited(localName, document.clone()); let element = HTMLOutputElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLOutputElementBinding::Wrap) Node::reflect_node(~element, document, HTMLOutputElementBinding::Wrap)
} }
} }
impl HTMLOutputElement { pub trait HTMLOutputElementMethods {
pub fn GetForm(&self) -> Option<JS<HTMLFormElement>> { fn GetForm(&self) -> Option<Temporary<HTMLFormElement>>;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn DefaultValue(&self) -> DOMString;
fn SetDefaultValue(&mut self, _value: DOMString) -> ErrorResult;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString) -> ErrorResult;
fn WillValidate(&self) -> bool;
fn SetWillValidate(&mut self, _will_validate: bool);
fn Validity(&self) -> Temporary<ValidityState>;
fn ValidationMessage(&self) -> DOMString;
fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult;
fn CheckValidity(&self) -> bool;
fn SetCustomValidity(&mut self, _error: DOMString);
}
impl<'a> HTMLOutputElementMethods for JSRef<'a, HTMLOutputElement> {
fn GetForm(&self) -> Option<Temporary<HTMLFormElement>> {
None None
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn DefaultValue(&self) -> DOMString { fn DefaultValue(&self) -> DOMString {
~"" ~""
} }
pub fn SetDefaultValue(&mut self, _value: DOMString) -> ErrorResult { fn SetDefaultValue(&mut self, _value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { fn SetValue(&mut self, _value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn WillValidate(&self) -> bool { fn WillValidate(&self) -> bool {
false false
} }
pub fn SetWillValidate(&mut self, _will_validate: bool) { fn SetWillValidate(&mut self, _will_validate: bool) {
} }
pub fn Validity(&self) -> JS<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let doc = self.htmlelement.element.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); ValidityState::new(&*window)
ValidityState::new(&doc.window)
} }
pub fn SetValidity(&mut self, _validity: JS<ValidityState>) { fn ValidationMessage(&self) -> DOMString {
}
pub fn ValidationMessage(&self) -> DOMString {
~"" ~""
} }
pub fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
true true
} }
pub fn SetCustomValidity(&mut self, _error: DOMString) { fn SetCustomValidity(&mut self, _error: DOMString) {
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLParagraphElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLParagraphElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLParagraphElementDerived; use dom::bindings::codegen::InheritTypes::HTMLParagraphElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLParagraphElementTypeId; use dom::element::HTMLParagraphElementTypeId;
@ -28,24 +28,29 @@ impl HTMLParagraphElementDerived for EventTarget {
} }
impl HTMLParagraphElement { impl HTMLParagraphElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLParagraphElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLParagraphElement {
HTMLParagraphElement { HTMLParagraphElement {
htmlelement: HTMLElement::new_inherited(HTMLParagraphElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLParagraphElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLParagraphElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLParagraphElement> {
let element = HTMLParagraphElement::new_inherited(localName, document.clone()); let element = HTMLParagraphElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLParagraphElementBinding::Wrap) Node::reflect_node(~element, document, HTMLParagraphElementBinding::Wrap)
} }
} }
impl HTMLParagraphElement { pub trait HTMLParagraphElementMethods {
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
}
impl<'a> HTMLParagraphElementMethods for JSRef<'a, HTMLParagraphElement> {
fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLParamElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLParamElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLParamElementDerived; use dom::bindings::codegen::InheritTypes::HTMLParamElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLParamElementTypeId; use dom::element::HTMLParamElementTypeId;
@ -28,48 +28,59 @@ impl HTMLParamElementDerived for EventTarget {
} }
impl HTMLParamElement { impl HTMLParamElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLParamElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLParamElement {
HTMLParamElement { HTMLParamElement {
htmlelement: HTMLElement::new_inherited(HTMLParamElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLParamElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLParamElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLParamElement> {
let element = HTMLParamElement::new_inherited(localName, document.clone()); let element = HTMLParamElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLParamElementBinding::Wrap) Node::reflect_node(~element, document, HTMLParamElementBinding::Wrap)
} }
} }
impl HTMLParamElement { pub trait HTMLParamElementMethods {
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn ValueType(&self) -> DOMString;
fn SetValueType(&mut self, _value_type: DOMString) -> ErrorResult;
}
impl<'a> HTMLParamElementMethods for JSRef<'a, HTMLParamElement> {
fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { fn SetValue(&mut self, _value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ValueType(&self) -> DOMString { fn ValueType(&self) -> DOMString {
~"" ~""
} }
pub fn SetValueType(&mut self, _value_type: DOMString) -> ErrorResult { fn SetValueType(&mut self, _value_type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLPreElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLPreElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLPreElementDerived; use dom::bindings::codegen::InheritTypes::HTMLPreElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLPreElementTypeId; use dom::element::HTMLPreElementTypeId;
@ -28,24 +28,29 @@ impl HTMLPreElementDerived for EventTarget {
} }
impl HTMLPreElement { impl HTMLPreElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLPreElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLPreElement {
HTMLPreElement { HTMLPreElement {
htmlelement: HTMLElement::new_inherited(HTMLPreElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLPreElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLPreElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLPreElement> {
let element = HTMLPreElement::new_inherited(localName, document.clone()); let element = HTMLPreElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLPreElementBinding::Wrap) Node::reflect_node(~element, document, HTMLPreElementBinding::Wrap)
} }
} }
impl HTMLPreElement { pub trait HTMLPreElementMethods {
pub fn Width(&self) -> i32 { fn Width(&self) -> i32;
fn SetWidth(&mut self, _width: i32) -> ErrorResult;
}
impl<'a> HTMLPreElementMethods for JSRef<'a, HTMLPreElement> {
fn Width(&self) -> i32 {
0 0
} }
pub fn SetWidth(&mut self, _width: i32) -> ErrorResult { fn SetWidth(&mut self, _width: i32) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLProgressElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLProgressElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLProgressElementDerived; use dom::bindings::codegen::InheritTypes::HTMLProgressElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::{ErrorResult, Fallible};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLProgressElementTypeId; use dom::element::HTMLProgressElementTypeId;
@ -28,40 +28,49 @@ impl HTMLProgressElementDerived for EventTarget {
} }
impl HTMLProgressElement { impl HTMLProgressElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLProgressElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLProgressElement {
HTMLProgressElement { HTMLProgressElement {
htmlelement: HTMLElement::new_inherited(HTMLProgressElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLProgressElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLProgressElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLProgressElement> {
let element = HTMLProgressElement::new_inherited(localName, document.clone()); let element = HTMLProgressElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLProgressElementBinding::Wrap) Node::reflect_node(~element, document, HTMLProgressElementBinding::Wrap)
} }
} }
impl HTMLProgressElement { pub trait HTMLProgressElementMethods {
pub fn Value(&self) -> f64 { fn Value(&self) -> f64;
fn SetValue(&mut self, _value: f64) -> ErrorResult;
fn Max(&self) -> f64;
fn SetMax(&mut self, _max: f64) -> ErrorResult;
fn Position(&self) -> f64;
fn GetPositiom(&self) -> Fallible<f64>;
}
impl<'a> HTMLProgressElementMethods for JSRef<'a, HTMLProgressElement> {
fn Value(&self) -> f64 {
0f64 0f64
} }
pub fn SetValue(&mut self, _value: f64) -> ErrorResult { fn SetValue(&mut self, _value: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Max(&self) -> f64 { fn Max(&self) -> f64 {
0f64 0f64
} }
pub fn SetMax(&mut self, _max: f64) -> ErrorResult { fn SetMax(&mut self, _max: f64) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Position(&self) -> f64 { fn Position(&self) -> f64 {
0f64 0f64
} }
pub fn GetPositiom(&self) -> Fallible<f64> { fn GetPositiom(&self) -> Fallible<f64> {
Ok(0f64) Ok(0f64)
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLQuoteElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLQuoteElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLQuoteElementDerived; use dom::bindings::codegen::InheritTypes::HTMLQuoteElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLQuoteElementTypeId; use dom::element::HTMLQuoteElementTypeId;
@ -28,24 +28,29 @@ impl HTMLQuoteElementDerived for EventTarget {
} }
impl HTMLQuoteElement { impl HTMLQuoteElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLQuoteElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLQuoteElement {
HTMLQuoteElement { HTMLQuoteElement {
htmlelement: HTMLElement::new_inherited(HTMLQuoteElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLQuoteElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLQuoteElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLQuoteElement> {
let element = HTMLQuoteElement::new_inherited(localName, document.clone()); let element = HTMLQuoteElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLQuoteElementBinding::Wrap) Node::reflect_node(~element, document, HTMLQuoteElementBinding::Wrap)
} }
} }
impl HTMLQuoteElement { pub trait HTMLQuoteElementMethods {
pub fn Cite(&self) -> DOMString { fn Cite(&self) -> DOMString;
fn SetCite(&self, _cite: DOMString) -> ErrorResult;
}
impl<'a> HTMLQuoteElementMethods for JSRef<'a, HTMLQuoteElement> {
fn Cite(&self) -> DOMString {
~"" ~""
} }
pub fn SetCite(&self, _cite: DOMString) -> ErrorResult { fn SetCite(&self, _cite: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLScriptElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLScriptElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLScriptElementDerived; use dom::bindings::codegen::InheritTypes::HTMLScriptElementDerived;
use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::ElementCast;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::{HTMLScriptElementTypeId, Element, AttributeHandlers}; use dom::element::{HTMLScriptElementTypeId, Element, AttributeHandlers};
@ -29,89 +29,110 @@ impl HTMLScriptElementDerived for EventTarget {
} }
impl HTMLScriptElement { impl HTMLScriptElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLScriptElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLScriptElement {
HTMLScriptElement { HTMLScriptElement {
htmlelement: HTMLElement::new_inherited(HTMLScriptElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLScriptElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLScriptElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLScriptElement> {
let element = HTMLScriptElement::new_inherited(localName, document.clone()); let element = HTMLScriptElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLScriptElementBinding::Wrap) Node::reflect_node(~element, document, HTMLScriptElementBinding::Wrap)
} }
} }
impl HTMLScriptElement { pub trait HTMLScriptElementMethods {
pub fn Src(&self, abstract_self: &JS<HTMLScriptElement>) -> DOMString { fn Src(&self) -> DOMString;
let element: JS<Element> = ElementCast::from(abstract_self); fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Charset(&self) -> DOMString;
fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult;
fn Async(&self) -> bool;
fn SetAsync(&self, _async: bool) -> ErrorResult;
fn Defer(&self) -> bool;
fn SetDefer(&self, _defer: bool) -> ErrorResult;
fn CrossOrigin(&self) -> DOMString;
fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult;
fn Text(&self) -> DOMString;
fn SetText(&mut self, _text: DOMString) -> ErrorResult;
fn Event(&self) -> DOMString;
fn SetEvent(&mut self, _event: DOMString) -> ErrorResult;
fn HtmlFor(&self) -> DOMString;
fn SetHtmlFor(&mut self, _html_for: DOMString) -> ErrorResult;
}
impl<'a> HTMLScriptElementMethods for JSRef<'a, HTMLScriptElement> {
fn Src(&self) -> DOMString {
let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_url_attribute("src") element.get_url_attribute("src")
} }
pub fn SetSrc(&mut self, _abstract_self: &JS<HTMLScriptElement>, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Charset(&self) -> DOMString { fn Charset(&self) -> DOMString {
~"" ~""
} }
pub fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Async(&self) -> bool { fn Async(&self) -> bool {
false false
} }
pub fn SetAsync(&self, _async: bool) -> ErrorResult { fn SetAsync(&self, _async: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Defer(&self) -> bool { fn Defer(&self) -> bool {
false false
} }
pub fn SetDefer(&self, _defer: bool) -> ErrorResult { fn SetDefer(&self, _defer: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CrossOrigin(&self) -> DOMString { fn CrossOrigin(&self) -> DOMString {
~"" ~""
} }
pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Text(&self) -> DOMString { fn Text(&self) -> DOMString {
~"" ~""
} }
pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { fn SetText(&mut self, _text: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Event(&self) -> DOMString { fn Event(&self) -> DOMString {
~"" ~""
} }
pub fn SetEvent(&mut self, _event: DOMString) -> ErrorResult { fn SetEvent(&mut self, _event: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn HtmlFor(&self) -> DOMString { fn HtmlFor(&self) -> DOMString {
~"" ~""
} }
pub fn SetHtmlFor(&mut self, _html_for: DOMString) -> ErrorResult { fn SetHtmlFor(&mut self, _html_for: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -5,14 +5,14 @@
use dom::bindings::codegen::BindingDeclarations::HTMLSelectElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLSelectElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLSelectElementDerived; use dom::bindings::codegen::InheritTypes::HTMLSelectElementDerived;
use dom::bindings::codegen::UnionTypes::{HTMLElementOrLong, HTMLOptionElementOrHTMLOptGroupElement}; use dom::bindings::codegen::UnionTypes::{HTMLElementOrLong, HTMLOptionElementOrHTMLOptGroupElement};
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, HTMLSelectElementTypeId}; use dom::element::{Element, HTMLSelectElementTypeId};
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::htmlformelement::HTMLFormElement; use dom::htmlformelement::HTMLFormElement;
use dom::node::{Node, ElementNodeTypeId}; use dom::node::{Node, ElementNodeTypeId, window_from_node};
use dom::htmloptionelement::HTMLOptionElement; use dom::htmloptionelement::HTMLOptionElement;
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
use servo_util::str::DOMString; use servo_util::str::DOMString;
@ -32,152 +32,185 @@ impl HTMLSelectElementDerived for EventTarget {
} }
impl HTMLSelectElement { impl HTMLSelectElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLSelectElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSelectElement {
HTMLSelectElement { HTMLSelectElement {
htmlelement: HTMLElement::new_inherited(HTMLSelectElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLSelectElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLSelectElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLSelectElement> {
let element = HTMLSelectElement::new_inherited(localName, document.clone()); let element = HTMLSelectElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLSelectElementBinding::Wrap) Node::reflect_node(~element, document, HTMLSelectElementBinding::Wrap)
} }
} }
impl HTMLSelectElement { pub trait HTMLSelectElementMethods {
pub fn Autofocus(&self) -> bool { fn Autofocus(&self) -> bool;
fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult;
fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult;
fn GetForm(&self) -> Option<Temporary<HTMLFormElement>>;
fn Multiple(&self) -> bool;
fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Required(&self) -> bool;
fn SetRequired(&mut self, _multiple: bool) -> ErrorResult;
fn Size(&self) -> u32;
fn SetSize(&mut self, _size: u32) -> ErrorResult;
fn Type(&self) -> DOMString;
fn Length(&self) -> u32;
fn SetLength(&mut self, _length: u32) -> ErrorResult;
fn Item(&self, _index: u32) -> Option<Temporary<Element>>;
fn NamedItem(&self, _name: DOMString) -> Option<Temporary<HTMLOptionElement>>;
fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Temporary<Element>>;
fn IndexedSetter(&mut self, _index: u32, _option: Option<JSRef<HTMLOptionElement>>) -> ErrorResult;
fn Remove_(&self);
fn Remove(&self, _index: i32);
fn SelectedIndex(&self) -> i32;
fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString);
fn WillValidate(&self) -> bool;
fn SetWillValidate(&mut self, _will_validate: bool);
fn Validity(&self) -> Temporary<ValidityState>;
fn ValidationMessage(&self) -> DOMString;
fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult;
fn CheckValidity(&self) -> bool;
fn SetCustomValidity(&mut self, _error: DOMString);
fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) -> ErrorResult;
}
impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> {
fn Autofocus(&self) -> bool {
false false
} }
pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetForm(&self) -> Option<JS<HTMLFormElement>> { fn GetForm(&self) -> Option<Temporary<HTMLFormElement>> {
None None
} }
pub fn Multiple(&self) -> bool { fn Multiple(&self) -> bool {
false false
} }
pub fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Required(&self) -> bool { fn Required(&self) -> bool {
false false
} }
pub fn SetRequired(&mut self, _multiple: bool) -> ErrorResult { fn SetRequired(&mut self, _multiple: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Size(&self) -> u32 { fn Size(&self) -> u32 {
0 0
} }
pub fn SetSize(&mut self, _size: u32) -> ErrorResult { fn SetSize(&mut self, _size: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn Length(&self) -> u32 { fn Length(&self) -> u32 {
0 0
} }
pub fn SetLength(&mut self, _length: u32) -> ErrorResult { fn SetLength(&mut self, _length: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Item(&self, _index: u32) -> Option<JS<Element>> { fn Item(&self, _index: u32) -> Option<Temporary<Element>> {
None None
} }
pub fn NamedItem(&self, _name: DOMString) -> Option<JS<HTMLOptionElement>> { fn NamedItem(&self, _name: DOMString) -> Option<Temporary<HTMLOptionElement>> {
None None
} }
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<JS<Element>> { fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Temporary<Element>> {
None None
} }
pub fn IndexedSetter(&mut self, _index: u32, _option: Option<JS<HTMLOptionElement>>) -> ErrorResult { fn IndexedSetter(&mut self, _index: u32, _option: Option<JSRef<HTMLOptionElement>>) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Remove_(&self) { fn Remove_(&self) {
} }
pub fn Remove(&self, _index: i32) { fn Remove(&self, _index: i32) {
} }
pub fn SelectedIndex(&self) -> i32 { fn SelectedIndex(&self) -> i32 {
0 0
} }
pub fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult { fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) { fn SetValue(&mut self, _value: DOMString) {
} }
pub fn WillValidate(&self) -> bool { fn WillValidate(&self) -> bool {
false false
} }
pub fn SetWillValidate(&mut self, _will_validate: bool) { fn SetWillValidate(&mut self, _will_validate: bool) {
} }
pub fn Validity(&self) -> JS<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let doc = self.htmlelement.element.node.owner_doc(); let window = window_from_node(self).root();
let doc = doc.get(); ValidityState::new(&*window)
ValidityState::new(&doc.window)
} }
pub fn SetValidity(&mut self, _validity: JS<ValidityState>) { fn ValidationMessage(&self) -> DOMString {
}
pub fn ValidationMessage(&self) -> DOMString {
~"" ~""
} }
pub fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
true true
} }
pub fn SetCustomValidity(&mut self, _error: DOMString) { fn SetCustomValidity(&mut self, _error: DOMString) {
} }
pub fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) -> ErrorResult { fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,15 +4,15 @@
use servo_util::namespace; use servo_util::namespace;
use dom::attr::Attr; use dom::attr::Attr;
use dom::bindings::codegen::InheritTypes::{ElementCast, TextCast, CommentCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, TextCast, CommentCast, NodeCast};
use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, CharacterDataCast}; use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, CharacterDataCast};
use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast; use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast;
use dom::bindings::js::JS; use dom::bindings::js::JSRef;
use dom::characterdata::CharacterData; use dom::characterdata::CharacterData;
use dom::comment::Comment; use dom::comment::Comment;
use dom::documenttype::DocumentType; use dom::documenttype::DocumentType;
use dom::element::Element; use dom::element::Element;
use dom::node::NodeIterator; use dom::node::{Node, NodeIterator};
use dom::node::{DoctypeNodeTypeId, DocumentFragmentNodeTypeId, CommentNodeTypeId}; use dom::node::{DoctypeNodeTypeId, DocumentFragmentNodeTypeId, CommentNodeTypeId};
use dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId}; use dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId};
use dom::node::{TextNodeTypeId, NodeHelpers}; use dom::node::{TextNodeTypeId, NodeHelpers};
@ -30,24 +30,25 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
html.push_str( html.push_str(
match node.type_id() { match node.type_id() {
ElementNodeTypeId(..) => { ElementNodeTypeId(..) => {
let elem: JS<Element> = ElementCast::to(&node).unwrap(); let elem: &JSRef<Element> = ElementCast::to_ref(&node).unwrap();
serialize_elem(&elem, &mut open_elements) serialize_elem(elem, &mut open_elements)
} }
CommentNodeTypeId => { CommentNodeTypeId => {
let comment: JS<Comment> = CommentCast::to(&node).unwrap(); let comment: &JSRef<Comment> = CommentCast::to_ref(&node).unwrap();
serialize_comment(&comment) serialize_comment(comment)
} }
TextNodeTypeId => { TextNodeTypeId => {
let text: JS<Text> = TextCast::to(&node).unwrap(); let text: &JSRef<Text> = TextCast::to_ref(&node).unwrap();
serialize_text(&text) serialize_text(text)
} }
DoctypeNodeTypeId => { DoctypeNodeTypeId => {
let doctype: JS<DocumentType> = DocumentTypeCast::to(&node).unwrap(); let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(&node).unwrap();
serialize_doctype(&doctype) serialize_doctype(doctype)
} }
ProcessingInstructionNodeTypeId => { ProcessingInstructionNodeTypeId => {
let processing_instruction: JS<ProcessingInstruction> = ProcessingInstructionCast::to(&node).unwrap(); let processing_instruction: &JSRef<ProcessingInstruction> =
serialize_processing_instruction(&processing_instruction) ProcessingInstructionCast::to_ref(&node).unwrap();
serialize_processing_instruction(processing_instruction)
} }
DocumentFragmentNodeTypeId => { DocumentFragmentNodeTypeId => {
~"" ~""
@ -64,47 +65,50 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
html html
} }
fn serialize_comment(comment: &JS<Comment>) -> ~str { fn serialize_comment(comment: &JSRef<Comment>) -> ~str {
~"<!--" + comment.get().characterdata.data + "-->" ~"<!--" + comment.deref().characterdata.data + "-->"
} }
fn serialize_text(text: &JS<Text>) -> ~str { fn serialize_text(text: &JSRef<Text>) -> ~str {
match text.get().characterdata.node.parent_node { let text_node: &JSRef<Node> = NodeCast::from_ref(text);
match text_node.parent_node().map(|node| node.root()) {
Some(ref parent) if parent.is_element() => { Some(ref parent) if parent.is_element() => {
let elem: JS<Element> = ElementCast::to(parent).unwrap(); let elem: &JSRef<Element> = ElementCast::to_ref(&**parent).unwrap();
match elem.get().local_name.as_slice() { match elem.deref().local_name.as_slice() {
"style" | "script" | "xmp" | "iframe" | "style" | "script" | "xmp" | "iframe" |
"noembed" | "noframes" | "plaintext" | "noembed" | "noframes" | "plaintext" |
"noscript" if elem.get().namespace == namespace::HTML => { "noscript" if elem.deref().namespace == namespace::HTML => {
text.get().characterdata.data.clone() text.deref().characterdata.data.clone()
}, },
_ => escape(text.get().characterdata.data, false) _ => escape(text.deref().characterdata.data, false)
} }
} }
_ => escape(text.get().characterdata.data, false) _ => escape(text.deref().characterdata.data, false)
} }
} }
fn serialize_processing_instruction(processing_instruction: &JS<ProcessingInstruction>) -> ~str { fn serialize_processing_instruction(processing_instruction: &JSRef<ProcessingInstruction>) -> ~str {
~"<?" + processing_instruction.get().target + " " + processing_instruction.get().characterdata.data + "?>" ~"<?" + processing_instruction.deref().target + " " + processing_instruction.deref().characterdata.data + "?>"
} }
fn serialize_doctype(doctype: &JS<DocumentType>) -> ~str { fn serialize_doctype(doctype: &JSRef<DocumentType>) -> ~str {
~"<!DOCTYPE" + doctype.get().name + ">" ~"<!DOCTYPE" + doctype.deref().name + ">"
} }
fn serialize_elem(elem: &JS<Element>, open_elements: &mut Vec<~str>) -> ~str { fn serialize_elem(elem: &JSRef<Element>, open_elements: &mut Vec<~str>) -> ~str {
let mut rv = ~"<" + elem.get().local_name; let mut rv = ~"<" + elem.deref().local_name;
for attr in elem.get().attrs.iter() { for attr in elem.deref().attrs.iter() {
rv.push_str(serialize_attr(attr)); let attr = attr.root();
rv.push_str(serialize_attr(&*attr));
}; };
rv.push_str(">"); rv.push_str(">");
match elem.get().local_name.as_slice() { match elem.deref().local_name.as_slice() {
"pre" | "listing" | "textarea" if elem.get().namespace == namespace::HTML => { "pre" | "listing" | "textarea" if elem.deref().namespace == namespace::HTML => {
match elem.get().node.first_child { let node: &JSRef<Node> = NodeCast::from_ref(elem);
match node.first_child().map(|child| child.root()) {
Some(ref child) if child.is_text() => { Some(ref child) if child.is_text() => {
let text: JS<CharacterData> = CharacterDataCast::to(child).unwrap(); let text: &JSRef<CharacterData> = CharacterDataCast::to_ref(&**child).unwrap();
if text.get().data.len() > 0 && text.get().data[0] == 0x0A as u8 { if text.deref().data.len() > 0 && text.deref().data[0] == 0x0A as u8 {
rv.push_str("\x0A"); rv.push_str("\x0A");
} }
}, },
@ -113,26 +117,26 @@ fn serialize_elem(elem: &JS<Element>, open_elements: &mut Vec<~str>) -> ~str {
}, },
_ => {} _ => {}
} }
if !elem.get().is_void() { if !elem.deref().is_void() {
open_elements.push(elem.get().local_name.clone()); open_elements.push(elem.deref().local_name.clone());
} }
rv rv
} }
fn serialize_attr(attr: &JS<Attr>) -> ~str { fn serialize_attr(attr: &JSRef<Attr>) -> ~str {
let attr_name = if attr.get().namespace == namespace::XML { let attr_name = if attr.deref().namespace == namespace::XML {
~"xml:" + attr.get().local_name.clone() ~"xml:" + attr.deref().local_name.clone()
} else if attr.get().namespace == namespace::XMLNS && } else if attr.deref().namespace == namespace::XMLNS &&
attr.get().local_name.as_slice() == "xmlns" { attr.deref().local_name.as_slice() == "xmlns" {
~"xmlns" ~"xmlns"
} else if attr.get().namespace == namespace::XMLNS { } else if attr.deref().namespace == namespace::XMLNS {
~"xmlns:" + attr.get().local_name.clone() ~"xmlns:" + attr.deref().local_name.clone()
} else if attr.get().namespace == namespace::XLink { } else if attr.deref().namespace == namespace::XLink {
~"xlink:" + attr.get().local_name.clone() ~"xlink:" + attr.deref().local_name.clone()
} else { } else {
attr.get().name.clone() attr.deref().name.clone()
}; };
~" " + attr_name + "=\"" + escape(attr.get().value, true) + "\"" ~" " + attr_name + "=\"" + escape(attr.deref().value, true) + "\""
} }
fn escape(string: &str, attr_mode: bool) -> ~str { fn escape(string: &str, attr_mode: bool) -> ~str {

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLSourceElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLSourceElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLSourceElementDerived; use dom::bindings::codegen::InheritTypes::HTMLSourceElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLSourceElementTypeId; use dom::element::HTMLSourceElementTypeId;
@ -28,40 +28,49 @@ impl HTMLSourceElementDerived for EventTarget {
} }
impl HTMLSourceElement { impl HTMLSourceElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLSourceElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSourceElement {
HTMLSourceElement { HTMLSourceElement {
htmlelement: HTMLElement::new_inherited(HTMLSourceElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLSourceElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLSourceElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLSourceElement> {
let element = HTMLSourceElement::new_inherited(localName, document.clone()); let element = HTMLSourceElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLSourceElementBinding::Wrap) Node::reflect_node(~element, document, HTMLSourceElementBinding::Wrap)
} }
} }
impl HTMLSourceElement { pub trait HTMLSourceElementMethods {
pub fn Src(&self) -> DOMString { fn Src(&self) -> DOMString;
fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Media(&self) -> DOMString;
fn SetMedia(&mut self, _media: DOMString) -> ErrorResult;
}
impl<'a> HTMLSourceElementMethods for JSRef<'a, HTMLSourceElement> {
fn Src(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Media(&self) -> DOMString { fn Media(&self) -> DOMString {
~"" ~""
} }
pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { fn SetMedia(&mut self, _media: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLSpanElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLSpanElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLSpanElementDerived; use dom::bindings::codegen::InheritTypes::HTMLSpanElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLSpanElementTypeId; use dom::element::HTMLSpanElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLSpanElementDerived for EventTarget {
} }
impl HTMLSpanElement { impl HTMLSpanElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLSpanElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSpanElement {
HTMLSpanElement { HTMLSpanElement {
htmlelement: HTMLElement::new_inherited(HTMLSpanElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLSpanElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLSpanElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLSpanElement> {
let element = HTMLSpanElement::new_inherited(localName, document.clone()); let element = HTMLSpanElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLSpanElementBinding::Wrap) Node::reflect_node(~element, document, HTMLSpanElementBinding::Wrap)
} }
} }
pub trait HTMLSpanElementMethods {
}

View file

@ -4,13 +4,13 @@
use dom::bindings::codegen::BindingDeclarations::HTMLStyleElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLStyleElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLStyleElementDerived, NodeCast}; use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLStyleElementDerived, NodeCast};
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLStyleElementTypeId; use dom::element::HTMLStyleElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::{Node, ElementNodeTypeId, window_from_node}; use dom::node::{Node, NodeMethods, ElementNodeTypeId, window_from_node};
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
use html::cssparse::parse_inline_css; use html::cssparse::parse_inline_css;
use layout_interface::{AddStylesheetMsg, LayoutChan}; use layout_interface::{AddStylesheetMsg, LayoutChan};
@ -31,47 +31,58 @@ impl HTMLStyleElementDerived for EventTarget {
} }
impl HTMLStyleElement { impl HTMLStyleElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLStyleElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLStyleElement {
HTMLStyleElement { HTMLStyleElement {
htmlelement: HTMLElement::new_inherited(HTMLStyleElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLStyleElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLStyleElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLStyleElement> {
let element = HTMLStyleElement::new_inherited(localName, document.clone()); let element = HTMLStyleElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLStyleElementBinding::Wrap) Node::reflect_node(~element, document, HTMLStyleElementBinding::Wrap)
} }
} }
impl HTMLStyleElement { pub trait HTMLStyleElementMethods {
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool;
fn SetDisabled(&self, _disabled: bool);
fn Media(&self) -> DOMString;
fn SetMedia(&mut self, _media: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
fn Scoped(&self) -> bool;
fn SetScoped(&self, _scoped: bool) -> ErrorResult;
}
impl<'a> HTMLStyleElementMethods for JSRef<'a, HTMLStyleElement> {
fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&self, _disabled: bool) { fn SetDisabled(&self, _disabled: bool) {
} }
pub fn Media(&self) -> DOMString { fn Media(&self) -> DOMString {
~"" ~""
} }
pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { fn SetMedia(&mut self, _media: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Scoped(&self) -> bool { fn Scoped(&self) -> bool {
false false
} }
pub fn SetScoped(&self, _scoped: bool) -> ErrorResult { fn SetScoped(&self, _scoped: bool) -> ErrorResult {
Ok(()) Ok(())
} }
} }
@ -80,26 +91,26 @@ pub trait StyleElementHelpers {
fn parse_own_css(&self); fn parse_own_css(&self);
} }
impl StyleElementHelpers for JS<HTMLStyleElement> { impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
fn parse_own_css(&self) { fn parse_own_css(&self) {
let node: JS<Node> = NodeCast::from(self); let node: &JSRef<Node> = NodeCast::from_ref(self);
let win = window_from_node(&node); let win = window_from_node(node).root();
let url = win.get().page().get_url(); let url = win.deref().page().get_url();
let data = node.get().GetTextContent(&node).expect("Element.textContent must be a string"); let data = node.GetTextContent().expect("Element.textContent must be a string");
let sheet = parse_inline_css(url, data); let sheet = parse_inline_css(url, data);
let LayoutChan(ref layout_chan) = *win.get().page().layout_chan; let LayoutChan(ref layout_chan) = *win.deref().page().layout_chan;
layout_chan.send(AddStylesheetMsg(sheet)); layout_chan.send(AddStylesheetMsg(sheet));
} }
} }
impl VirtualMethods for JS<HTMLStyleElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> {
fn super_type(&self) -> Option<~VirtualMethods:> { fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
let htmlelement: JS<HTMLElement> = HTMLElementCast::from(self); let htmlelement: &mut JSRef<HTMLElement> = HTMLElementCast::from_mut_ref(self);
Some(~htmlelement as ~VirtualMethods:) Some(htmlelement as &mut VirtualMethods:)
} }
fn child_inserted(&mut self, child: &JS<Node>) { fn child_inserted(&mut self, child: &JSRef<Node>) {
match self.super_type() { match self.super_type() {
Some(ref mut s) => s.child_inserted(child), Some(ref mut s) => s.child_inserted(child),
_ => (), _ => (),

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTableCaptionElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTableCaptionElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTableCaptionElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableCaptionElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTableCaptionElementTypeId; use dom::element::HTMLTableCaptionElementTypeId;
@ -28,24 +28,29 @@ impl HTMLTableCaptionElementDerived for EventTarget {
} }
impl HTMLTableCaptionElement { impl HTMLTableCaptionElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTableCaptionElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableCaptionElement {
HTMLTableCaptionElement { HTMLTableCaptionElement {
htmlelement: HTMLElement::new_inherited(HTMLTableCaptionElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableCaptionElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTableCaptionElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableCaptionElement> {
let element = HTMLTableCaptionElement::new_inherited(localName, document.clone()); let element = HTMLTableCaptionElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTableCaptionElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTableCaptionElementBinding::Wrap)
} }
} }
impl HTMLTableCaptionElement { pub trait HTMLTableCaptionElementMethods {
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
}
impl<'a> HTMLTableCaptionElementMethods for JSRef<'a, HTMLTableCaptionElement> {
fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -3,7 +3,7 @@
* 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::codegen::InheritTypes::HTMLTableCellElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableCellElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::JSRef;
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::{ElementTypeId, HTMLTableDataCellElementTypeId, HTMLTableHeaderCellElementTypeId}; use dom::element::{ElementTypeId, HTMLTableDataCellElementTypeId, HTMLTableHeaderCellElementTypeId};
@ -28,132 +28,164 @@ impl HTMLTableCellElementDerived for EventTarget {
} }
impl HTMLTableCellElement { impl HTMLTableCellElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JS<Document>) -> HTMLTableCellElement { pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: &JSRef<Document>) -> HTMLTableCellElement {
HTMLTableCellElement { HTMLTableCellElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, document) htmlelement: HTMLElement::new_inherited(type_id, tag_name, document)
} }
} }
} }
impl HTMLTableCellElement { pub trait HTMLTableCellElementMethods {
pub fn ColSpan(&self) -> u32 { fn ColSpan(&self) -> u32;
fn SetColSpan(&self, _col_span: u32) -> ErrorResult;
fn RowSpan(&self) -> u32;
fn SetRowSpan(&self, _col_span: u32) -> ErrorResult;
fn Headers(&self) -> DOMString;
fn SetHeaders(&self, _headers: DOMString) -> ErrorResult;
fn CellIndex(&self) -> i32;
fn GetCellIndex(&self, _cell_index: i32) -> ErrorResult;
fn Abbr(&self) -> DOMString;
fn SetAbbr(&self, _abbr: DOMString) -> ErrorResult;
fn Scope(&self) -> DOMString;
fn SetScope(&self, _abbr: DOMString) -> ErrorResult;
fn Align(&self) -> DOMString;
fn SetAlign(&self, _align: DOMString) -> ErrorResult;
fn Axis(&self) -> DOMString;
fn SetAxis(&self, _axis: DOMString) -> ErrorResult;
fn Height(&self) -> DOMString;
fn SetHeight(&self, _height: DOMString) -> ErrorResult;
fn Width(&self) -> DOMString;
fn SetWidth(&self, _width: DOMString) -> ErrorResult;
fn Ch(&self) -> DOMString;
fn SetCh(&self, _ch: DOMString) -> ErrorResult;
fn ChOff(&self) -> DOMString;
fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult;
fn NoWrap(&self) -> bool;
fn SetNoWrap(&self, _no_wrap: bool) -> ErrorResult;
fn VAlign(&self) -> DOMString;
fn SetVAlign(&self, _valign: DOMString) -> ErrorResult;
fn BgColor(&self) -> DOMString;
fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult;
}
impl<'a> HTMLTableCellElementMethods for JSRef<'a, HTMLTableCellElement> {
fn ColSpan(&self) -> u32 {
0 0
} }
pub fn SetColSpan(&self, _col_span: u32) -> ErrorResult { fn SetColSpan(&self, _col_span: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn RowSpan(&self) -> u32 { fn RowSpan(&self) -> u32 {
0 0
} }
pub fn SetRowSpan(&self, _col_span: u32) -> ErrorResult { fn SetRowSpan(&self, _col_span: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Headers(&self) -> DOMString { fn Headers(&self) -> DOMString {
~"" ~""
} }
pub fn SetHeaders(&self, _headers: DOMString) -> ErrorResult { fn SetHeaders(&self, _headers: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CellIndex(&self) -> i32 { fn CellIndex(&self) -> i32 {
0 0
} }
pub fn GetCellIndex(&self, _cell_index: i32) -> ErrorResult { fn GetCellIndex(&self, _cell_index: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Abbr(&self) -> DOMString { fn Abbr(&self) -> DOMString {
~"" ~""
} }
pub fn SetAbbr(&self, _abbr: DOMString) -> ErrorResult { fn SetAbbr(&self, _abbr: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Scope(&self) -> DOMString { fn Scope(&self) -> DOMString {
~"" ~""
} }
pub fn SetScope(&self, _abbr: DOMString) -> ErrorResult { fn SetScope(&self, _abbr: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&self, _align: DOMString) -> ErrorResult { fn SetAlign(&self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Axis(&self) -> DOMString { fn Axis(&self) -> DOMString {
~"" ~""
} }
pub fn SetAxis(&self, _axis: DOMString) -> ErrorResult { fn SetAxis(&self, _axis: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Height(&self) -> DOMString { fn Height(&self) -> DOMString {
~"" ~""
} }
pub fn SetHeight(&self, _height: DOMString) -> ErrorResult { fn SetHeight(&self, _height: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&self, _width: DOMString) -> ErrorResult { fn SetWidth(&self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Ch(&self) -> DOMString { fn Ch(&self) -> DOMString {
~"" ~""
} }
pub fn SetCh(&self, _ch: DOMString) -> ErrorResult { fn SetCh(&self, _ch: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ChOff(&self) -> DOMString { fn ChOff(&self) -> DOMString {
~"" ~""
} }
pub fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult { fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn NoWrap(&self) -> bool { fn NoWrap(&self) -> bool {
false false
} }
pub fn SetNoWrap(&self, _no_wrap: bool) -> ErrorResult { fn SetNoWrap(&self, _no_wrap: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn VAlign(&self) -> DOMString { fn VAlign(&self) -> DOMString {
~"" ~""
} }
pub fn SetVAlign(&self, _valign: DOMString) -> ErrorResult { fn SetVAlign(&self, _valign: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn BgColor(&self) -> DOMString { fn BgColor(&self) -> DOMString {
~"" ~""
} }
pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTableColElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTableColElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTableColElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableColElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTableColElementTypeId; use dom::element::HTMLTableColElementTypeId;
@ -28,64 +28,79 @@ impl HTMLTableColElementDerived for EventTarget {
} }
impl HTMLTableColElement { impl HTMLTableColElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTableColElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableColElement {
HTMLTableColElement { HTMLTableColElement {
htmlelement: HTMLElement::new_inherited(HTMLTableColElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableColElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTableColElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableColElement> {
let element = HTMLTableColElement::new_inherited(localName, document.clone()); let element = HTMLTableColElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTableColElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTableColElementBinding::Wrap)
} }
} }
impl HTMLTableColElement { pub trait HTMLTableColElementMethods {
pub fn Span(&self) -> u32 { fn Span(&self) -> u32;
fn SetSpan(&mut self, _span: u32) -> ErrorResult;
fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
fn Ch(&self) -> DOMString;
fn SetCh(&mut self, _ch: DOMString) -> ErrorResult;
fn ChOff(&self) -> DOMString;
fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult;
fn VAlign(&self) -> DOMString;
fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult;
fn Width(&self) -> DOMString;
fn SetWidth(&mut self, _width: DOMString) -> ErrorResult;
}
impl<'a> HTMLTableColElementMethods for JSRef<'a, HTMLTableColElement> {
fn Span(&self) -> u32 {
0 0
} }
pub fn SetSpan(&mut self, _span: u32) -> ErrorResult { fn SetSpan(&mut self, _span: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Ch(&self) -> DOMString { fn Ch(&self) -> DOMString {
~"" ~""
} }
pub fn SetCh(&mut self, _ch: DOMString) -> ErrorResult { fn SetCh(&mut self, _ch: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ChOff(&self) -> DOMString { fn ChOff(&self) -> DOMString {
~"" ~""
} }
pub fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult { fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn VAlign(&self) -> DOMString { fn VAlign(&self) -> DOMString {
~"" ~""
} }
pub fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult { fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { fn SetWidth(&mut self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTableDataCellElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTableDataCellElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTableDataCellElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableDataCellElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTableDataCellElementTypeId; use dom::element::HTMLTableDataCellElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLTableDataCellElementDerived for EventTarget {
} }
impl HTMLTableDataCellElement { impl HTMLTableDataCellElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTableDataCellElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableDataCellElement {
HTMLTableDataCellElement { HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document) htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTableDataCellElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableDataCellElement> {
let element = HTMLTableDataCellElement::new_inherited(localName, document.clone()); let element = HTMLTableDataCellElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTableDataCellElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTableDataCellElementBinding::Wrap)
} }
} }
pub trait HTMLTableDataCellElementMethods {
}

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTableElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTableElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTableElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTableElementTypeId; use dom::element::HTMLTableElementTypeId;
@ -28,111 +28,139 @@ impl HTMLTableElementDerived for EventTarget {
} }
impl HTMLTableElement { impl HTMLTableElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTableElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableElement {
HTMLTableElement { HTMLTableElement {
htmlelement: HTMLElement::new_inherited(HTMLTableElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTableElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableElement> {
let element = HTMLTableElement::new_inherited(localName, document.clone()); let element = HTMLTableElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTableElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTableElementBinding::Wrap)
} }
} }
impl HTMLTableElement { pub trait HTMLTableElementMethods {
pub fn DeleteCaption(&self) { fn DeleteCaption(&self);
fn DeleteTHead(&self);
fn DeleteTFoot(&self);
fn DeleteRow(&mut self, _index: i32) -> ErrorResult;
fn Sortable(&self) -> bool;
fn SetSortable(&self, _sortable: bool);
fn StopSorting(&self);
fn Align(&self) -> DOMString;
fn SetAlign(&self, _align: DOMString) -> ErrorResult;
fn Border(&self) -> DOMString;
fn SetBorder(&self, _border: DOMString) -> ErrorResult;
fn Frame(&self) -> DOMString;
fn SetFrame(&self, _frame: DOMString) -> ErrorResult;
fn Rules(&self) -> DOMString;
fn SetRules(&self, _rules: DOMString) -> ErrorResult;
fn Summary(&self) -> DOMString;
fn SetSummary(&self, _summary: DOMString) -> ErrorResult;
fn Width(&self) -> DOMString;
fn SetWidth(&self, _width: DOMString) -> ErrorResult;
fn BgColor(&self) -> DOMString;
fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult;
fn CellPadding(&self) -> DOMString;
fn SetCellPadding(&self, _cell_padding: DOMString) -> ErrorResult;
fn CellSpacing(&self) -> DOMString;
fn SetCellSpacing(&self, _cell_spacing: DOMString) -> ErrorResult;
}
impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> {
fn DeleteCaption(&self) {
} }
pub fn DeleteTHead(&self) { fn DeleteTHead(&self) {
} }
pub fn DeleteTFoot(&self) { fn DeleteTFoot(&self) {
} }
pub fn DeleteRow(&mut self, _index: i32) -> ErrorResult { fn DeleteRow(&mut self, _index: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Sortable(&self) -> bool { fn Sortable(&self) -> bool {
false false
} }
pub fn SetSortable(&self, _sortable: bool) { fn SetSortable(&self, _sortable: bool) {
} }
pub fn StopSorting(&self) { fn StopSorting(&self) {
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&self, _align: DOMString) -> ErrorResult { fn SetAlign(&self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Border(&self) -> DOMString { fn Border(&self) -> DOMString {
~"" ~""
} }
pub fn SetBorder(&self, _border: DOMString) -> ErrorResult { fn SetBorder(&self, _border: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Frame(&self) -> DOMString { fn Frame(&self) -> DOMString {
~"" ~""
} }
pub fn SetFrame(&self, _frame: DOMString) -> ErrorResult { fn SetFrame(&self, _frame: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Rules(&self) -> DOMString { fn Rules(&self) -> DOMString {
~"" ~""
} }
pub fn SetRules(&self, _rules: DOMString) -> ErrorResult { fn SetRules(&self, _rules: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Summary(&self) -> DOMString { fn Summary(&self) -> DOMString {
~"" ~""
} }
pub fn SetSummary(&self, _summary: DOMString) -> ErrorResult { fn SetSummary(&self, _summary: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Width(&self) -> DOMString { fn Width(&self) -> DOMString {
~"" ~""
} }
pub fn SetWidth(&self, _width: DOMString) -> ErrorResult { fn SetWidth(&self, _width: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn BgColor(&self) -> DOMString { fn BgColor(&self) -> DOMString {
~"" ~""
} }
pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CellPadding(&self) -> DOMString { fn CellPadding(&self) -> DOMString {
~"" ~""
} }
pub fn SetCellPadding(&self, _cell_padding: DOMString) -> ErrorResult { fn SetCellPadding(&self, _cell_padding: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn CellSpacing(&self) -> DOMString { fn CellSpacing(&self) -> DOMString {
~"" ~""
} }
pub fn SetCellSpacing(&self, _cell_spacing: DOMString) -> ErrorResult { fn SetCellSpacing(&self, _cell_spacing: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTableHeaderCellElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTableHeaderCellElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTableHeaderCellElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableHeaderCellElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTableHeaderCellElementTypeId; use dom::element::HTMLTableHeaderCellElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLTableHeaderCellElementDerived for EventTarget {
} }
impl HTMLTableHeaderCellElement { impl HTMLTableHeaderCellElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTableHeaderCellElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableHeaderCellElement {
HTMLTableHeaderCellElement { HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableHeaderCellElementTypeId, localName, document) htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableHeaderCellElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTableHeaderCellElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableHeaderCellElement> {
let element = HTMLTableHeaderCellElement::new_inherited(localName, document.clone()); let element = HTMLTableHeaderCellElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTableHeaderCellElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTableHeaderCellElementBinding::Wrap)
} }
} }
pub trait HTMLTableHeaderCellElementMethods {
}

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTableRowElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTableRowElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTableRowElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableRowElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTableRowElementTypeId; use dom::element::HTMLTableRowElementTypeId;
@ -28,76 +28,94 @@ impl HTMLTableRowElementDerived for EventTarget {
} }
impl HTMLTableRowElement { impl HTMLTableRowElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTableRowElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableRowElement {
HTMLTableRowElement { HTMLTableRowElement {
htmlelement: HTMLElement::new_inherited(HTMLTableRowElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableRowElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTableRowElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableRowElement> {
let element = HTMLTableRowElement::new_inherited(localName, document.clone()); let element = HTMLTableRowElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTableRowElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTableRowElementBinding::Wrap)
} }
} }
impl HTMLTableRowElement { pub trait HTMLTableRowElementMethods {
pub fn RowIndex(&self) -> i32 { fn RowIndex(&self) -> i32;
fn GetRowIndex(&self) -> i32;
fn SectionRowIndex(&self) -> i32;
fn GetSectionRowIndex(&self) -> i32;
fn DeleteCell(&mut self, _index: i32) -> ErrorResult;
fn Align(&self) -> DOMString;
fn SetAlign(&self, _align: DOMString) -> ErrorResult;
fn Ch(&self) -> DOMString;
fn SetCh(&self, _ch: DOMString) -> ErrorResult;
fn ChOff(&self) -> DOMString;
fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult;
fn VAlign(&self) -> DOMString;
fn SetVAlign(&self, _v_align: DOMString) -> ErrorResult;
fn BgColor(&self) -> DOMString;
fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult;
}
impl<'a> HTMLTableRowElementMethods for JSRef<'a, HTMLTableRowElement> {
fn RowIndex(&self) -> i32 {
0 0
} }
pub fn GetRowIndex(&self) -> i32 { fn GetRowIndex(&self) -> i32 {
0 0
} }
pub fn SectionRowIndex(&self) -> i32 { fn SectionRowIndex(&self) -> i32 {
0 0
} }
pub fn GetSectionRowIndex(&self) -> i32 { fn GetSectionRowIndex(&self) -> i32 {
0 0
} }
pub fn DeleteCell(&mut self, _index: i32) -> ErrorResult { fn DeleteCell(&mut self, _index: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&self, _align: DOMString) -> ErrorResult { fn SetAlign(&self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Ch(&self) -> DOMString { fn Ch(&self) -> DOMString {
~"" ~""
} }
pub fn SetCh(&self, _ch: DOMString) -> ErrorResult { fn SetCh(&self, _ch: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ChOff(&self) -> DOMString { fn ChOff(&self) -> DOMString {
~"" ~""
} }
pub fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult { fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn VAlign(&self) -> DOMString { fn VAlign(&self) -> DOMString {
~"" ~""
} }
pub fn SetVAlign(&self, _v_align: DOMString) -> ErrorResult { fn SetVAlign(&self, _v_align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn BgColor(&self) -> DOMString { fn BgColor(&self) -> DOMString {
~"" ~""
} }
pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTableSectionElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTableSectionElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTableSectionElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTableSectionElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTableSectionElementTypeId; use dom::element::HTMLTableSectionElementTypeId;
@ -28,52 +28,64 @@ impl HTMLTableSectionElementDerived for EventTarget {
} }
impl HTMLTableSectionElement { impl HTMLTableSectionElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTableSectionElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableSectionElement {
HTMLTableSectionElement { HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(HTMLTableSectionElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableSectionElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTableSectionElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableSectionElement> {
let element = HTMLTableSectionElement::new_inherited(localName, document.clone()); let element = HTMLTableSectionElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTableSectionElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTableSectionElementBinding::Wrap)
} }
} }
impl HTMLTableSectionElement { pub trait HTMLTableSectionElementMethods {
pub fn DeleteRow(&mut self, _index: i32) -> ErrorResult { fn DeleteRow(&mut self, _index: i32) -> ErrorResult;
fn Align(&self) -> DOMString;
fn SetAlign(&mut self, _align: DOMString) -> ErrorResult;
fn Ch(&self) -> DOMString;
fn SetCh(&mut self, _ch: DOMString) -> ErrorResult;
fn ChOff(&self) -> DOMString;
fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult;
fn VAlign(&self) -> DOMString;
fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult;
}
impl<'a> HTMLTableSectionElementMethods for JSRef<'a, HTMLTableSectionElement> {
fn DeleteRow(&mut self, _index: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {
~"" ~""
} }
pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { fn SetAlign(&mut self, _align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Ch(&self) -> DOMString { fn Ch(&self) -> DOMString {
~"" ~""
} }
pub fn SetCh(&mut self, _ch: DOMString) -> ErrorResult { fn SetCh(&mut self, _ch: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ChOff(&self) -> DOMString { fn ChOff(&self) -> DOMString {
~"" ~""
} }
pub fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult { fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn VAlign(&self) -> DOMString { fn VAlign(&self) -> DOMString {
~"" ~""
} }
pub fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult { fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTemplateElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTemplateElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTemplateElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTemplateElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTemplateElementTypeId; use dom::element::HTMLTemplateElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLTemplateElementDerived for EventTarget {
} }
impl HTMLTemplateElement { impl HTMLTemplateElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTemplateElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTemplateElement {
HTMLTemplateElement { HTMLTemplateElement {
htmlelement: HTMLElement::new_inherited(HTMLTemplateElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTemplateElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTemplateElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTemplateElement> {
let element = HTMLTemplateElement::new_inherited(localName, document.clone()); let element = HTMLTemplateElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTemplateElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTemplateElementBinding::Wrap)
} }
} }
pub trait HTMLTemplateElementMethods {
}

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTextAreaElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTextAreaElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTextAreaElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTextAreaElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::{ErrorResult, Fallible};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTextAreaElementTypeId; use dom::element::HTMLTextAreaElementTypeId;
@ -28,175 +28,219 @@ impl HTMLTextAreaElementDerived for EventTarget {
} }
impl HTMLTextAreaElement { impl HTMLTextAreaElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTextAreaElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTextAreaElement {
HTMLTextAreaElement { HTMLTextAreaElement {
htmlelement: HTMLElement::new_inherited(HTMLTextAreaElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTextAreaElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTextAreaElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTextAreaElement> {
let element = HTMLTextAreaElement::new_inherited(localName, document.clone()); let element = HTMLTextAreaElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTextAreaElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTextAreaElementBinding::Wrap)
} }
} }
impl HTMLTextAreaElement { pub trait HTMLTextAreaElementMethods {
pub fn Autofocus(&self) -> bool { fn Autofocus(&self) -> bool;
fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult;
fn Cols(&self) -> u32;
fn SetCols(&self, _cols: u32) -> ErrorResult;
fn Disabled(&self) -> bool;
fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult;
fn MaxLength(&self) -> i32;
fn SetMaxLength(&self, _max_length: i32) -> ErrorResult;
fn Name(&self) -> DOMString;
fn SetName(&mut self, _name: DOMString) -> ErrorResult;
fn Placeholder(&self) -> DOMString;
fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult;
fn ReadOnly(&self) -> bool;
fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult;
fn Required(&self) -> bool;
fn SetRequired(&mut self, _required: bool) -> ErrorResult;
fn Rows(&self) -> u32;
fn SetRows(&self, _rows: u32) -> ErrorResult;
fn Wrap(&self) -> DOMString;
fn SetWrap(&mut self, _wrap: DOMString) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString);
fn DefaultValue(&self) -> DOMString;
fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult;
fn Value(&self) -> DOMString;
fn SetValue(&mut self, _value: DOMString);
fn TextLength(&self) -> u32;
fn SetTextLength(&self, _text_length: u32) -> ErrorResult;
fn WillValidate(&self) -> bool;
fn SetWillValidate(&mut self, _will_validate: bool) -> ErrorResult;
fn ValidationMessage(&self) -> DOMString;
fn CheckValidity(&self) -> bool;
fn SetCustomValidity(&self, _error: DOMString);
fn Select(&self);
fn GetSelectionStart(&self) -> Fallible<u32>;
fn SetSelectionStart(&self, _selection_start: u32) -> ErrorResult;
fn GetSelectionEnd(&self) -> Fallible<u32>;
fn SetSelectionEnd(&self, _selection_end: u32) -> ErrorResult;
fn GetSelectionDirection(&self) -> Fallible<DOMString>;
fn SetSelectionDirection(&self, _selection_direction: DOMString) -> ErrorResult;
fn SetRangeText(&self, _replacement: DOMString);
}
impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> {
fn Autofocus(&self) -> bool {
false false
} }
pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Cols(&self) -> u32 { fn Cols(&self) -> u32 {
0 0
} }
pub fn SetCols(&self, _cols: u32) -> ErrorResult { fn SetCols(&self, _cols: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Disabled(&self) -> bool { fn Disabled(&self) -> bool {
false false
} }
pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn MaxLength(&self) -> i32 { fn MaxLength(&self) -> i32 {
0 0
} }
pub fn SetMaxLength(&self, _max_length: i32) -> ErrorResult { fn SetMaxLength(&self, _max_length: i32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Name(&self) -> DOMString { fn Name(&self) -> DOMString {
~"" ~""
} }
pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { fn SetName(&mut self, _name: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Placeholder(&self) -> DOMString { fn Placeholder(&self) -> DOMString {
~"" ~""
} }
pub fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult { fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ReadOnly(&self) -> bool { fn ReadOnly(&self) -> bool {
false false
} }
pub fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult { fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Required(&self) -> bool { fn Required(&self) -> bool {
false false
} }
pub fn SetRequired(&mut self, _required: bool) -> ErrorResult { fn SetRequired(&mut self, _required: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Rows(&self) -> u32 { fn Rows(&self) -> u32 {
0 0
} }
pub fn SetRows(&self, _rows: u32) -> ErrorResult { fn SetRows(&self, _rows: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Wrap(&self) -> DOMString { fn Wrap(&self) -> DOMString {
~"" ~""
} }
pub fn SetWrap(&mut self, _wrap: DOMString) -> ErrorResult { fn SetWrap(&mut self, _wrap: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) { fn SetType(&mut self, _type: DOMString) {
} }
pub fn DefaultValue(&self) -> DOMString { fn DefaultValue(&self) -> DOMString {
~"" ~""
} }
pub fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult { fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Value(&self) -> DOMString { fn Value(&self) -> DOMString {
~"" ~""
} }
pub fn SetValue(&mut self, _value: DOMString) { fn SetValue(&mut self, _value: DOMString) {
} }
pub fn TextLength(&self) -> u32 { fn TextLength(&self) -> u32 {
0 0
} }
pub fn SetTextLength(&self, _text_length: u32) -> ErrorResult { fn SetTextLength(&self, _text_length: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn WillValidate(&self) -> bool { fn WillValidate(&self) -> bool {
false false
} }
pub fn SetWillValidate(&mut self, _will_validate: bool) -> ErrorResult { fn SetWillValidate(&mut self, _will_validate: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ValidationMessage(&self) -> DOMString { fn ValidationMessage(&self) -> DOMString {
~"" ~""
} }
pub fn CheckValidity(&self) -> bool { fn CheckValidity(&self) -> bool {
false false
} }
pub fn SetCustomValidity(&self, _error: DOMString) { fn SetCustomValidity(&self, _error: DOMString) {
} }
pub fn Select(&self) { fn Select(&self) {
} }
pub fn GetSelectionStart(&self) -> Fallible<u32> { fn GetSelectionStart(&self) -> Fallible<u32> {
Ok(0) Ok(0)
} }
pub fn SetSelectionStart(&self, _selection_start: u32) -> ErrorResult { fn SetSelectionStart(&self, _selection_start: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetSelectionEnd(&self) -> Fallible<u32> { fn GetSelectionEnd(&self) -> Fallible<u32> {
Ok(0) Ok(0)
} }
pub fn SetSelectionEnd(&self, _selection_end: u32) -> ErrorResult { fn SetSelectionEnd(&self, _selection_end: u32) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn GetSelectionDirection(&self) -> Fallible<DOMString> { fn GetSelectionDirection(&self) -> Fallible<DOMString> {
Ok(~"") Ok(~"")
} }
pub fn SetSelectionDirection(&self, _selection_direction: DOMString) -> ErrorResult { fn SetSelectionDirection(&self, _selection_direction: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn SetRangeText(&self, _replacement: DOMString) { fn SetRangeText(&self, _replacement: DOMString) {
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTimeElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTimeElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTimeElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTimeElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTimeElementTypeId; use dom::element::HTMLTimeElementTypeId;
@ -28,24 +28,29 @@ impl HTMLTimeElementDerived for EventTarget {
} }
impl HTMLTimeElement { impl HTMLTimeElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTimeElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTimeElement {
HTMLTimeElement { HTMLTimeElement {
htmlelement: HTMLElement::new_inherited(HTMLTimeElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTimeElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTimeElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTimeElement> {
let element = HTMLTimeElement::new_inherited(localName, document.clone()); let element = HTMLTimeElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTimeElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTimeElementBinding::Wrap)
} }
} }
impl HTMLTimeElement { pub trait HTMLTimeElementMethods {
pub fn DateTime(&self) -> DOMString { fn DateTime(&self) -> DOMString;
fn SetDateTime(&mut self, _dateTime: DOMString) -> ErrorResult;
}
impl<'a> HTMLTimeElementMethods for JSRef<'a, HTMLTimeElement> {
fn DateTime(&self) -> DOMString {
~"" ~""
} }
pub fn SetDateTime(&mut self, _dateTime: DOMString) -> ErrorResult { fn SetDateTime(&mut self, _dateTime: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTitleElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTitleElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTitleElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTitleElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTitleElementTypeId; use dom::element::HTMLTitleElementTypeId;
@ -28,24 +28,29 @@ impl HTMLTitleElementDerived for EventTarget {
} }
impl HTMLTitleElement { impl HTMLTitleElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTitleElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTitleElement {
HTMLTitleElement { HTMLTitleElement {
htmlelement: HTMLElement::new_inherited(HTMLTitleElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTitleElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTitleElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTitleElement> {
let element = HTMLTitleElement::new_inherited(localName, document.clone()); let element = HTMLTitleElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTitleElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTitleElementBinding::Wrap)
} }
} }
impl HTMLTitleElement { pub trait HTMLTitleElementMethods {
pub fn Text(&self) -> DOMString { fn Text(&self) -> DOMString;
fn SetText(&mut self, _text: DOMString) -> ErrorResult;
}
impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
fn Text(&self) -> DOMString {
~"" ~""
} }
pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { fn SetText(&mut self, _text: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLTrackElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLTrackElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLTrackElementDerived; use dom::bindings::codegen::InheritTypes::HTMLTrackElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLTrackElementTypeId; use dom::element::HTMLTrackElementTypeId;
@ -28,60 +28,74 @@ impl HTMLTrackElementDerived for EventTarget {
} }
impl HTMLTrackElement { impl HTMLTrackElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLTrackElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTrackElement {
HTMLTrackElement { HTMLTrackElement {
htmlelement: HTMLElement::new_inherited(HTMLTrackElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTrackElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLTrackElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTrackElement> {
let element = HTMLTrackElement::new_inherited(localName, document.clone()); let element = HTMLTrackElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLTrackElementBinding::Wrap) Node::reflect_node(~element, document, HTMLTrackElementBinding::Wrap)
} }
} }
impl HTMLTrackElement { pub trait HTMLTrackElementMethods {
pub fn Kind(&self) -> DOMString { fn Kind(&self) -> DOMString;
fn SetKind(&mut self, _kind: DOMString) -> ErrorResult;
fn Src(&self) -> DOMString;
fn SetSrc(&mut self, _src: DOMString) -> ErrorResult;
fn Srclang(&self) -> DOMString;
fn SetSrclang(&mut self, _srclang: DOMString) -> ErrorResult;
fn Label(&self) -> DOMString;
fn SetLabel(&mut self, _label: DOMString) -> ErrorResult;
fn Default(&self) -> bool;
fn SetDefault(&mut self, _default: bool) -> ErrorResult;
fn ReadyState(&self) -> u16;
}
impl<'a> HTMLTrackElementMethods for JSRef<'a, HTMLTrackElement> {
fn Kind(&self) -> DOMString {
~"" ~""
} }
pub fn SetKind(&mut self, _kind: DOMString) -> ErrorResult { fn SetKind(&mut self, _kind: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Src(&self) -> DOMString { fn Src(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Srclang(&self) -> DOMString { fn Srclang(&self) -> DOMString {
~"" ~""
} }
pub fn SetSrclang(&mut self, _srclang: DOMString) -> ErrorResult { fn SetSrclang(&mut self, _srclang: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Label(&self) -> DOMString { fn Label(&self) -> DOMString {
~"" ~""
} }
pub fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { fn SetLabel(&mut self, _label: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Default(&self) -> bool { fn Default(&self) -> bool {
false false
} }
pub fn SetDefault(&mut self, _default: bool) -> ErrorResult { fn SetDefault(&mut self, _default: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn ReadyState(&self) -> u16 { fn ReadyState(&self) -> u16 {
0 0
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLUListElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLUListElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLUListElementDerived; use dom::bindings::codegen::InheritTypes::HTMLUListElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLUListElementTypeId; use dom::element::HTMLUListElementTypeId;
@ -28,32 +28,39 @@ impl HTMLUListElementDerived for EventTarget {
} }
impl HTMLUListElement { impl HTMLUListElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLUListElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLUListElement {
HTMLUListElement { HTMLUListElement {
htmlelement: HTMLElement::new_inherited(HTMLUListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLUListElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLUListElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLUListElement> {
let element = HTMLUListElement::new_inherited(localName, document.clone()); let element = HTMLUListElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLUListElementBinding::Wrap) Node::reflect_node(~element, document, HTMLUListElementBinding::Wrap)
} }
} }
impl HTMLUListElement { pub trait HTMLUListElementMethods {
pub fn Compact(&self) -> bool { fn Compact(&self) -> bool;
fn SetCompact(&mut self, _compact: bool) -> ErrorResult;
fn Type(&self) -> DOMString;
fn SetType(&mut self, _type: DOMString) -> ErrorResult;
}
impl<'a> HTMLUListElementMethods for JSRef<'a, HTMLUListElement> {
fn Compact(&self) -> bool {
false false
} }
pub fn SetCompact(&mut self, _compact: bool) -> ErrorResult { fn SetCompact(&mut self, _compact: bool) -> ErrorResult {
Ok(()) Ok(())
} }
pub fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
~"" ~""
} }
pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(()) Ok(())
} }
} }

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLUnknownElementBinding; use dom::bindings::codegen::BindingDeclarations::HTMLUnknownElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLUnknownElementDerived; use dom::bindings::codegen::InheritTypes::HTMLUnknownElementDerived;
use dom::bindings::js::JS; use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document; use dom::document::Document;
use dom::element::HTMLUnknownElementTypeId; use dom::element::HTMLUnknownElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -27,14 +27,17 @@ impl HTMLUnknownElementDerived for EventTarget {
} }
impl HTMLUnknownElement { impl HTMLUnknownElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLUnknownElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLUnknownElement {
HTMLUnknownElement { HTMLUnknownElement {
htmlelement: HTMLElement::new_inherited(HTMLUnknownElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLUnknownElementTypeId, localName, document)
} }
} }
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLUnknownElement> { pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLUnknownElement> {
let element = HTMLUnknownElement::new_inherited(localName, document.clone()); let element = HTMLUnknownElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLUnknownElementBinding::Wrap) Node::reflect_node(~element, document, HTMLUnknownElementBinding::Wrap)
} }
} }
pub trait HTMLUnknownElementMethods {
}

Some files were not shown because too many files have changed in this diff Show more