auto merge of #817 : jdm/servo/optgroupelem, r=kmcallister

Also remove all traces of the non-element Node bindings! Woo!
This commit is contained in:
bors-servo 2013-08-28 17:48:38 -07:00
commit d8f6008b0c
33 changed files with 1273 additions and 260 deletions

View file

@ -367,12 +367,6 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'getItem' ]
}],
'Text': {
'nativeType': 'AbstractNode<ScriptView>',
'concreteType': 'Text',
'pointerType': ''
},
'UIEvent': {
},
@ -548,12 +542,17 @@ def addExternalIface(iface, nativeType=None, headerFile=None, pointerType=None):
domInterface['pointerType'] = pointerType
DOMInterfaces[iface] = domInterface
def addHTMLElement(element):
def addHTMLElement(element, concrete=None):
DOMInterfaces[element] = {
'nativeType': 'AbstractNode<ScriptView>',
'pointerType': ''
'pointerType': '',
'concreteType': concrete if concrete else element
}
addHTMLElement('Comment')
addHTMLElement('DocumentType', concrete='DocumentType<ScriptView>')
addHTMLElement('Text')
addHTMLElement('HTMLAnchorElement')
addHTMLElement('HTMLAppletElement')
addHTMLElement('HTMLAreaElement')
@ -585,11 +584,19 @@ addHTMLElement('HTMLLIElement')
addHTMLElement('HTMLLinkElement')
addHTMLElement('HTMLMapElement')
addHTMLElement('HTMLMetaElement')
addHTMLElement('HTMLMeterElement')
addHTMLElement('HTMLModElement')
addHTMLElement('HTMLObjectElement')
addHTMLElement('HTMLOListElement')
addHTMLElement('HTMLOptGroupElement')
addHTMLElement('HTMLOptionElement')
addHTMLElement('HTMLOutputElement')
addHTMLElement('HTMLParagraphElement')
addHTMLElement('HTMLParamElement')
addHTMLElement('HTMLProgressElement')
addHTMLElement('HTMLQuoteElement')
addHTMLElement('HTMLScriptElement')
addHTMLElement('HTMLSelectElement')
addHTMLElement('HTMLSourceElement')
addHTMLElement('HTMLSpanElement')
addHTMLElement('HTMLStyleElement')
@ -603,6 +610,7 @@ addHTMLElement('HTMLTextAreaElement')
addHTMLElement('HTMLTimeElement')
addHTMLElement('HTMLTitleElement')
addHTMLElement('HTMLUListElement')
addHTMLElement('HTMLUnknownElement')
# If you add one of these, you need to make sure nsDOMQS.h has the relevant
# macros added for it
@ -611,8 +619,6 @@ def addExternalHTMLElement(element):
addExternalIface(element, nativeType=nativeElement,
headerFile=nativeElement + '.h')
addExternalHTMLElement('HTMLOptionElement')
addExternalHTMLElement('HTMLOptGroupElement')
addExternalHTMLElement('HTMLVideoElement')
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')

View file

@ -92,7 +92,7 @@ class CastableObjectUnwrapper():
codeOnFailure is the code to run if unwrapping fails.
"""
def __init__(self, descriptor, source, target, codeOnFailure):
def __init__(self, descriptor, source, target, codeOnFailure, isOptional=False):
assert descriptor.castable
self.substitution = { "type" : descriptor.nativeType,
@ -101,7 +101,8 @@ class CastableObjectUnwrapper():
"protoID" : "PrototypeList::id::" + descriptor.name + " as uint",
"source" : source,
"target" : target,
"codeOnFailure" : CGIndenter(CGGeneric(codeOnFailure), 4).define() }
"codeOnFailure" : CGIndenter(CGGeneric(codeOnFailure), 4).define(),
"unwrapped_val" : "Some(val)" if isOptional else "val" }
if descriptor.hasXPConnectImpls:
# We don't use xpc_qsUnwrapThis because it will always throw on
# unwrap failure, whereas we want to control whether we throw or
@ -123,7 +124,7 @@ class CastableObjectUnwrapper():
def __str__(self):
return string.Template(
"""match unwrap_object(${source}, ${prototype}, ${depth}) {
Ok(val) => ${target} = val,
Ok(val) => ${target} = ${unwrapped_val},
Err(()) => {
${codeOnFailure}
}
@ -141,10 +142,11 @@ class FailureFatalCastableObjectUnwrapper(CastableObjectUnwrapper):
"""
As CastableObjectUnwrapper, but defaulting to throwing if unwrapping fails
"""
def __init__(self, descriptor, source, target):
def __init__(self, descriptor, source, target, isOptional):
CastableObjectUnwrapper.__init__(self, descriptor, source, target,
"return 0; //XXXjdm return Throw<%s>(cx, rv);" %
toStringBool(not descriptor.workers))
toStringBool(not descriptor.workers),
isOptional)
class CGThing():
"""
@ -229,9 +231,10 @@ class CGMethodCall(CGThing):
argCountCases.append(
CGCase(str(argCount), None, True))
else:
pass
sigIndex = signatures.index(signature)
argCountCases.append(
CGCase(str(argCount), getPerSignatureCall(signature)))
CGCase(str(argCount), getPerSignatureCall(signature,
signatureIndex=sigIndex)))
continue
distinguishingIndex = method.distinguishingIndexForArgCount(argCount)
@ -302,7 +305,7 @@ class CGMethodCall(CGThing):
# above.
caseBody.append(CGGeneric("if JSVAL_IS_OBJECT(%s) {" %
(distinguishingArg)))
for sig in interfacesSigs:
for idx, sig in enumerate(interfacesSigs):
caseBody.append(CGIndenter(CGGeneric("loop {")));
type = sig[1][distinguishingIndex].type
@ -326,7 +329,7 @@ class CGMethodCall(CGThing):
# distinguishingIndex + 1, since we already converted
# distinguishingIndex.
caseBody.append(CGIndenter(
getPerSignatureCall(sig, distinguishingIndex + 1), 4))
getPerSignatureCall(sig, distinguishingIndex + 1, idx), 4))
caseBody.append(CGIndenter(CGGeneric("}")))
caseBody.append(CGGeneric("}"))
@ -926,12 +929,14 @@ for (uint32_t i = 0; i < length; ++i) {
descriptor,
"JSVAL_TO_OBJECT(${val})",
"${declName}",
failureCode))
failureCode,
isOptional or argIsPointer or type.nullable()))
else:
templateBody += str(FailureFatalCastableObjectUnwrapper(
descriptor,
"JSVAL_TO_OBJECT(${val})",
"${declName}"))
"${declName}",
isOptional or argIsPointer or type.nullable()))
elif descriptor.interface.isCallback() and False:
#XXXjdm unfinished
templateBody += str(CallbackObjectUnwrapper(
@ -3532,8 +3537,8 @@ class CGProxySpecialOperation(CGPerSignatureCall):
templateValues = {
"declName": argument.identifier.name,
"holderName": argument.identifier.name + "_holder",
"val": "desc->value",
"valPtr": "&desc->value"
"val": "(*desc).value",
"valPtr": "&(*desc).value"
}
self.cgRoot.prepend(instantiateJSToNativeConversionTemplate(template, templateValues))
elif operation.isGetter():
@ -3636,7 +3641,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
if not 'IndexedCreator' in self.descriptor.operations:
# FIXME need to check that this is a 'supported property index'
assert False
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, JSVAL_VOID, false);\n" +
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, false);\n" +
" return 1;\n" +
" }\n")
if self.descriptor.operations['NamedSetter']:
@ -3644,7 +3649,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
if not 'NamedCreator' in self.descriptor.operations:
# FIXME need to check that this is a 'supported property name'
assert False
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, JSVAL_VOID, false);\n" +
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, false);\n" +
" return 1;\n" +
" }\n")
setOrIndexedGet += "}"
@ -3710,7 +3715,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
args = [Argument('*JSContext', 'cx'), Argument('*JSObject', 'proxy'),
Argument('jsid', 'id'),
Argument('*JSPropertyDescriptor', 'desc')]
CGAbstractExternMethod.__init__(self, descriptor, "defineProperty", "bool", args)
CGAbstractExternMethod.__init__(self, descriptor, "defineProperty", "JSBool", args)
self.descriptor = descriptor
def getBody(self):
set = ""
@ -3722,10 +3727,10 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
set += ("let index = GetArrayIndexFromId(cx, id);\n" +
"if index.is_some() {\n" +
" let index = index.unwrap();\n" +
" let this: *%s = UnwrapProxy(proxy);\n" +
" let this: *mut %s = UnwrapProxy(proxy) as *mut %s;\n" +
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
" return 1;\n" +
"}\n") % (self.descriptor.concreteType)
"}\n") % (self.descriptor.concreteType, self.descriptor.concreteType)
elif self.descriptor.operations['IndexedGetter']:
set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" +
" return 0;\n" +
@ -3771,7 +3776,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
" }\n" +
" return 1;\n"
"}\n") % (self.descriptor.concreteType, 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):
return self.getBody()
@ -4618,6 +4623,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::codegen::*', #XXXjdm
'script_task::{JSPageInfo, page_from_context}',
'dom::bindings::utils::EnumEntry',
'dom::bindings::proxyhandler',
'dom::bindings::proxyhandler::*',
'dom::document::AbstractDocument',
'dom::node::{AbstractNode, ScriptView}',

View file

@ -0,0 +1,15 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://dom.spec.whatwg.org/#comment
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
[Constructor(optional DOMString data = "")]
interface Comment : CharacterData {
};

View file

@ -0,0 +1,22 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://dom.spec.whatwg.org/#documenttype
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface DocumentType : Node {
readonly attribute DOMString name;
readonly attribute DOMString publicId;
readonly attribute DOMString systemId;
// Mozilla extension
//readonly attribute DOMString? internalSubset;
};
//DocumentType implements ChildNode;

View file

@ -0,0 +1,33 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-meter-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-meter-element
interface HTMLMeterElement : HTMLElement {
[SetterThrows]
attribute double value;
[SetterThrows]
attribute double min;
[SetterThrows]
attribute double max;
[SetterThrows]
attribute double low;
[SetterThrows]
attribute double high;
[SetterThrows]
attribute double optimum;
/**
* The labels attribute will be done with bug 556743.
*/
//readonly attribute NodeList labels;
};

View file

@ -0,0 +1,19 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#attributes-common-to-ins-and-del-elements
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
// http://www.whatwg.org/specs/web-apps/current-work/#attributes-common-to-ins-and-del-elements
interface HTMLModElement : HTMLElement {
[SetterThrows, Pure]
attribute DOMString cite;
[SetterThrows, Pure]
attribute DOMString dateTime;
};

View file

@ -0,0 +1,201 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-object-element
* http://www.whatwg.org/specs/web-apps/current-work/#HTMLObjectElement-partial
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-object-element
[NeedNewResolve]
interface HTMLObjectElement : HTMLElement {
[Pure, SetterThrows]
attribute DOMString data;
[Pure, SetterThrows]
attribute DOMString type;
// attribute boolean typeMustMatch;
[Pure, SetterThrows]
attribute DOMString name;
[Pure, SetterThrows]
attribute DOMString useMap;
[Pure]
readonly attribute HTMLFormElement? form;
[Pure, SetterThrows]
attribute DOMString width;
[Pure, SetterThrows]
attribute DOMString height;
// Not pure: can trigger about:blank instantiation
readonly attribute Document? contentDocument;
// Not pure: can trigger about:blank instantiation
readonly attribute WindowProxy? contentWindow;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(DOMString error);
/*[Throws]
legacycaller any (any... arguments);*/
};
// http://www.whatwg.org/specs/web-apps/current-work/#HTMLObjectElement-partial
partial interface HTMLObjectElement {
[Pure, SetterThrows]
attribute DOMString align;
[Pure, SetterThrows]
attribute DOMString archive;
[Pure, SetterThrows]
attribute DOMString code;
[Pure, SetterThrows]
attribute boolean declare;
[Pure, SetterThrows]
attribute unsigned long hspace;
[Pure, SetterThrows]
attribute DOMString standby;
[Pure, SetterThrows]
attribute unsigned long vspace;
[Pure, SetterThrows]
attribute DOMString codeBase;
[Pure, SetterThrows]
attribute DOMString codeType;
[TreatNullAs=EmptyString, Pure, SetterThrows]
attribute DOMString border;
};
partial interface HTMLObjectElement {
// GetSVGDocument
Document? getSVGDocument();
};
/*[NoInterfaceObject]
interface MozObjectLoadingContent {
// Mirrored chrome-only scriptable nsIObjectLoadingContent methods. Please
// make sure to update this list if nsIObjectLoadingContent changes. Also,
// make sure everything on here is [ChromeOnly].
[ChromeOnly]
const unsigned long TYPE_LOADING = 0;
[ChromeOnly]
const unsigned long TYPE_IMAGE = 1;
[ChromeOnly]
const unsigned long TYPE_PLUGIN = 2;
[ChromeOnly]
const unsigned long TYPE_DOCUMENT = 3;
[ChromeOnly]
const unsigned long TYPE_NULL = 4;
// The content type is not supported (e.g. plugin not installed)
[ChromeOnly]
const unsigned long PLUGIN_UNSUPPORTED = 0;
// Showing alternate content
[ChromeOnly]
const unsigned long PLUGIN_ALTERNATE = 1;
// The plugin exists, but is disabled
[ChromeOnly]
const unsigned long PLUGIN_DISABLED = 2;
// The plugin is blocklisted and disabled
[ChromeOnly]
const unsigned long PLUGIN_BLOCKLISTED = 3;
// The plugin is considered outdated, but not disabled
[ChromeOnly]
const unsigned long PLUGIN_OUTDATED = 4;
// The plugin has crashed
[ChromeOnly]
const unsigned long PLUGIN_CRASHED = 5;
// Suppressed by security policy
[ChromeOnly]
const unsigned long PLUGIN_SUPPRESSED = 6;
// Blocked by content policy
[ChromeOnly]
const unsigned long PLUGIN_USER_DISABLED = 7;
/// ** All values >= PLUGIN_CLICK_TO_PLAY are plugin placeholder types that
/// would be replaced by a real plugin if activated (playPlugin())
/// ** Furthermore, values >= PLUGIN_CLICK_TO_PLAY and
/// <= PLUGIN_VULNERABLE_NO_UPDATE are click-to-play types.
// The plugin is disabled until the user clicks on it
[ChromeOnly]
const unsigned long PLUGIN_CLICK_TO_PLAY = 8;
// The plugin is vulnerable (update available)
[ChromeOnly]
const unsigned long PLUGIN_VULNERABLE_UPDATABLE = 9;
// The plugin is vulnerable (no update available)
[ChromeOnly]
const unsigned long PLUGIN_VULNERABLE_NO_UPDATE = 10;
// The plugin is in play preview mode
[ChromeOnly]
const unsigned long PLUGIN_PLAY_PREVIEW = 11;*/
/**
* The actual mime type (the one we got back from the network
* request) for the element.
*/
/*[ChromeOnly]
readonly attribute DOMString actualType;*/
/**
* Gets the type of the content that's currently loaded. See
* the constants above for the list of possible values.
*/
/*[ChromeOnly]
readonly attribute unsigned long displayedType;*/
/**
* Gets the content type that corresponds to the give MIME type. See the
* constants above for the list of possible values. If nothing else fits,
* TYPE_NULL will be returned.
*/
/*[ChromeOnly]
unsigned long getContentTypeForMIMEType(DOMString aMimeType);*/
/**
* This method will play a plugin that has been stopped by the
* click-to-play plugins or play-preview features.
*/
/*[ChromeOnly, Throws]
void playPlugin();*/
/**
* This attribute will return true if the current content type has been
* activated, either explicitly or by passing checks that would have it be
* click-to-play or play-preview.
*/
/*[ChromeOnly]
readonly attribute boolean activated;*/
/**
* The URL of the data/src loaded in the object. This may be null (i.e.
* an <embed> with no src).
*/
/*[ChromeOnly]
readonly attribute URI? srcURI;
[ChromeOnly]
readonly attribute unsigned long defaultFallbackType;
[ChromeOnly]
readonly attribute unsigned long pluginFallbackType;*/
/**
* If this object currently owns a running plugin, regardless of whether or
* not one is pending spawn/despawn.
*/
/*[ChromeOnly]
readonly attribute boolean hasRunningPlugin;*/
/**
* This method will disable the play-preview plugin state.
*/
/*[ChromeOnly, Throws]
void cancelPlayPreview();*/
//};
/*HTMLObjectElement implements MozImageLoadingContent;
HTMLObjectElement implements MozFrameLoaderOwner;
HTMLObjectElement implements MozObjectLoadingContent;*/

View file

@ -0,0 +1,19 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-optgroup-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
interface HTMLOptGroupElement : HTMLElement {
[SetterThrows]
attribute boolean disabled;
[SetterThrows]
attribute DOMString label;
};

View file

@ -0,0 +1,31 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-option-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
[NamedConstructor=Option(optional DOMString text, optional DOMString value, optional boolean defaultSelected, optional boolean selected)]
interface HTMLOptionElement : HTMLElement {
[SetterThrows]
attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[SetterThrows]
attribute DOMString label;
[SetterThrows]
attribute boolean defaultSelected;
[SetterThrows]
attribute boolean selected;
[SetterThrows]
attribute DOMString value;
[SetterThrows]
attribute DOMString text;
readonly attribute long index;
};

View file

@ -0,0 +1,37 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-output-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-output-element
interface HTMLOutputElement : HTMLElement {
/*[PutForwards=value, Constant]
readonly attribute DOMSettableTokenList htmlFor;*/
readonly attribute HTMLFormElement? form;
[SetterThrows, Pure]
attribute DOMString name;
[Constant]
readonly attribute DOMString type;
[SetterThrows, Pure]
attribute DOMString defaultValue;
[SetterThrows, Pure]
attribute DOMString value;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(DOMString error);
// Not yet implemented (bug 556743).
// readonly attribute NodeList labels;
};

View file

@ -0,0 +1,29 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-param-element
* http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-param-element
interface HTMLParamElement : HTMLElement {
[SetterThrows, Pure]
attribute DOMString name;
[SetterThrows, Pure]
attribute DOMString value;
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLParamElement {
[SetterThrows, Pure]
attribute DOMString type;
[SetterThrows, Pure]
attribute DOMString valueType;
};

View file

@ -0,0 +1,57 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/html/#the-select-element
*/
interface HTMLSelectElement : HTMLElement {
[SetterThrows, Pure]
attribute boolean autofocus;
[SetterThrows, Pure]
attribute boolean disabled;
[Pure]
readonly attribute HTMLFormElement? form;
[SetterThrows, Pure]
attribute boolean multiple;
[SetterThrows, Pure]
attribute DOMString name;
[SetterThrows, Pure]
attribute boolean required;
[SetterThrows, Pure]
attribute unsigned long size;
[Pure]
readonly attribute DOMString type;
/*[Constant]
readonly attribute HTMLOptionsCollection options;*/
[SetterThrows, Pure]
attribute unsigned long length;
getter Element? item(unsigned long index);
HTMLOptionElement? namedItem(DOMString name);
/*[Throws]
void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);*/
void remove(long index);
[Throws]
setter creator void (unsigned long index, HTMLOptionElement? option);
// NYI: readonly attribute HTMLCollection selectedOptions;
[SetterThrows, Pure]
attribute long selectedIndex;
[Pure]
attribute DOMString value;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(DOMString error);
// NYI: readonly attribute NodeList labels;
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=20720
void remove();
};

View file

@ -0,0 +1,16 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/ and
* http://dev.w3.org/csswg/cssom-view/
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
interface HTMLUnknownElement : HTMLElement {
};

View file

@ -311,7 +311,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj {
}
pub macro_rules! generate_cacheable_wrapper(
($name: ident, $wrap: path) => (
($name: path, $wrap: path) => (
impl CacheableWrapper for $name {
fn get_wrappercache(&mut self) -> &mut WrapperCache {
self.parent.get_wrappercache()
@ -326,7 +326,7 @@ pub macro_rules! generate_cacheable_wrapper(
)
pub macro_rules! generate_binding_object(
($name: ident) => (
($name: path) => (
impl BindingObject for $name {
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper> {
self.parent.GetParentObject(cx)
@ -335,6 +335,12 @@ pub macro_rules! generate_binding_object(
)
)
generate_cacheable_wrapper!(Comment, CommentBinding::Wrap)
generate_binding_object!(Comment)
generate_cacheable_wrapper!(DocumentType<ScriptView>, DocumentTypeBinding::Wrap)
generate_binding_object!(DocumentType<ScriptView>)
generate_cacheable_wrapper!(Text, TextBinding::Wrap)
generate_binding_object!(Text)
generate_cacheable_wrapper!(HTMLHeadElement, HTMLHeadElementBinding::Wrap)
generate_binding_object!(HTMLHeadElement)
generate_cacheable_wrapper!(HTMLAnchorElement, HTMLAnchorElementBinding::Wrap)
@ -393,16 +399,32 @@ generate_cacheable_wrapper!(HTMLMapElement, HTMLMapElementBinding::Wrap)
generate_binding_object!(HTMLMapElement)
generate_cacheable_wrapper!(HTMLMetaElement, HTMLMetaElementBinding::Wrap)
generate_binding_object!(HTMLMetaElement)
generate_cacheable_wrapper!(HTMLMeterElement, HTMLMeterElementBinding::Wrap)
generate_binding_object!(HTMLMeterElement)
generate_cacheable_wrapper!(HTMLModElement, HTMLModElementBinding::Wrap)
generate_binding_object!(HTMLModElement)
generate_cacheable_wrapper!(HTMLObjectElement, HTMLObjectElementBinding::Wrap)
generate_binding_object!(HTMLObjectElement)
generate_cacheable_wrapper!(HTMLOListElement, HTMLOListElementBinding::Wrap)
generate_binding_object!(HTMLOListElement)
generate_cacheable_wrapper!(HTMLOptGroupElement, HTMLOptGroupElementBinding::Wrap)
generate_binding_object!(HTMLOptGroupElement)
generate_cacheable_wrapper!(HTMLOptionElement, HTMLOptionElementBinding::Wrap)
generate_binding_object!(HTMLOptionElement)
generate_cacheable_wrapper!(HTMLOutputElement, HTMLOutputElementBinding::Wrap)
generate_binding_object!(HTMLOutputElement)
generate_cacheable_wrapper!(HTMLParagraphElement, HTMLParagraphElementBinding::Wrap)
generate_binding_object!(HTMLParagraphElement)
generate_cacheable_wrapper!(HTMLParamElement, HTMLParamElementBinding::Wrap)
generate_binding_object!(HTMLParamElement)
generate_cacheable_wrapper!(HTMLProgressElement, HTMLProgressElementBinding::Wrap)
generate_binding_object!(HTMLProgressElement)
generate_cacheable_wrapper!(HTMLQuoteElement, HTMLQuoteElementBinding::Wrap)
generate_binding_object!(HTMLQuoteElement)
generate_cacheable_wrapper!(HTMLScriptElement, HTMLScriptElementBinding::Wrap)
generate_binding_object!(HTMLScriptElement)
generate_cacheable_wrapper!(HTMLSelectElement, HTMLSelectElementBinding::Wrap)
generate_binding_object!(HTMLSelectElement)
generate_cacheable_wrapper!(HTMLSourceElement, HTMLSourceElementBinding::Wrap)
generate_binding_object!(HTMLSourceElement)
generate_cacheable_wrapper!(HTMLSpanElement, HTMLSpanElementBinding::Wrap)
@ -429,3 +451,5 @@ generate_cacheable_wrapper!(HTMLTimeElement, HTMLTimeElementBinding::Wrap)
generate_binding_object!(HTMLTimeElement)
generate_cacheable_wrapper!(HTMLUListElement, HTMLUListElementBinding::Wrap)
generate_binding_object!(HTMLUListElement)
generate_cacheable_wrapper!(HTMLUnknownElement, HTMLUnknownElementBinding::Wrap)
generate_binding_object!(HTMLUnknownElement)

View file

@ -3,28 +3,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::element;
use dom::bindings::text;
use dom::bindings::utils;
use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper};
use dom::element::{HTMLElementTypeId,
HTMLAnchorElementTypeId, HTMLAppletElementTypeId,
HTMLAreaElementTypeId, HTMLBaseElementTypeId,
HTMLBodyElementTypeId, HTMLBRElementTypeId, HTMLButtonElementTypeId,
HTMLCanvasElementTypeId, HTMLDataElementTypeId, HTMLDataListElementTypeId,
HTMLDirectoryElementTypeId, HTMLDivElementTypeId, HTMLEmbedElementTypeId,
HTMLFieldSetElementTypeId, HTMLFontElementTypeId, HTMLFrameElementTypeId,
HTMLFrameSetElementTypeId, HTMLHeadElementTypeId, HTMLHeadingElementTypeId,
HTMLHRElementTypeId, HTMLHtmlElementTypeId, HTMLIframeElementTypeId,
HTMLImageElementTypeId, HTMLInputElementTypeId, HTMLLIElementTypeId,
HTMLLinkElementTypeId, HTMLMapElementTypeId, HTMLMetaElementTypeId,
HTMLOListElementTypeId, HTMLParagraphElementTypeId,
HTMLProgressElementTypeId, HTMLQuoteElementTypeId, HTMLScriptElementTypeId,
HTMLSpanElementTypeId, HTMLSourceElementTypeId,
HTMLStyleElementTypeId, HTMLTextAreaElementTypeId,
HTMLTableElementTypeId, HTMLTableCaptionElementTypeId, HTMLTableCellElementTypeId,
HTMLTableColElementTypeId,
HTMLTableRowElementTypeId, HTMLTableSectionElementTypeId, HTMLTimeElementTypeId,
HTMLTitleElementTypeId, HTMLUListElementTypeId, HTMLDListElementTypeId};
use dom::element::*;
use dom::types::*;
use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId};
use dom::node::{DoctypeNodeTypeId, ScriptView};
@ -82,7 +63,7 @@ pub fn init(compartment: @mut Compartment) {
}
macro_rules! generate_element(
($name: ident) => ({
($name: path) => ({
let node: @mut $name = unsafe { cast::transmute(node.raw_object()) };
node.wrap_object_shared(cx, ptr::null())
})
@ -120,11 +101,19 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
ElementNodeTypeId(HTMLLinkElementTypeId) => generate_element!(HTMLLinkElement),
ElementNodeTypeId(HTMLMapElementTypeId) => generate_element!(HTMLMapElement),
ElementNodeTypeId(HTMLMetaElementTypeId) => generate_element!(HTMLMetaElement),
ElementNodeTypeId(HTMLMeterElementTypeId) => generate_element!(HTMLMeterElement),
ElementNodeTypeId(HTMLModElementTypeId) => generate_element!(HTMLModElement),
ElementNodeTypeId(HTMLObjectElementTypeId) => generate_element!(HTMLObjectElement),
ElementNodeTypeId(HTMLOListElementTypeId) => generate_element!(HTMLOListElement),
ElementNodeTypeId(HTMLOptGroupElementTypeId) => generate_element!(HTMLOptGroupElement),
ElementNodeTypeId(HTMLOptionElementTypeId) => generate_element!(HTMLOptionElement),
ElementNodeTypeId(HTMLOutputElementTypeId) => generate_element!(HTMLOutputElement),
ElementNodeTypeId(HTMLParagraphElementTypeId) => generate_element!(HTMLParagraphElement),
ElementNodeTypeId(HTMLParamElementTypeId) => generate_element!(HTMLParamElement),
ElementNodeTypeId(HTMLProgressElementTypeId) => generate_element!(HTMLProgressElement),
ElementNodeTypeId(HTMLQuoteElementTypeId) => generate_element!(HTMLQuoteElement),
ElementNodeTypeId(HTMLScriptElementTypeId) => generate_element!(HTMLScriptElement),
ElementNodeTypeId(HTMLSelectElementTypeId) => generate_element!(HTMLSelectElement),
ElementNodeTypeId(HTMLSourceElementTypeId) => generate_element!(HTMLSourceElement),
ElementNodeTypeId(HTMLSpanElementTypeId) => generate_element!(HTMLSpanElement),
ElementNodeTypeId(HTMLStyleElementTypeId) => generate_element!(HTMLStyleElement),
@ -138,13 +127,11 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
ElementNodeTypeId(HTMLTimeElementTypeId) => generate_element!(HTMLTimeElement),
ElementNodeTypeId(HTMLTitleElementTypeId) => generate_element!(HTMLTitleElement),
ElementNodeTypeId(HTMLUListElementTypeId) => generate_element!(HTMLUListElement),
ElementNodeTypeId(HTMLUnknownElementTypeId) => generate_element!(HTMLUnknownElement),
ElementNodeTypeId(_) => element::create(cx, node).ptr,
CommentNodeTypeId |
DoctypeNodeTypeId => text::create(cx, node).ptr,
TextNodeTypeId => {
let node: @mut Text = unsafe { cast::transmute(node.raw_object()) };
node.wrap_object_shared(cx, ptr::null())
}
CommentNodeTypeId => generate_element!(Comment),
DoctypeNodeTypeId => generate_element!(DocumentType<ScriptView>),
TextNodeTypeId => generate_element!(Text)
}
}

View file

@ -44,8 +44,8 @@ pub extern fn getPropertyDescriptor(cx: *JSContext, proxy: *JSObject, id: jsid,
}
}
pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid,
desc: *JSPropertyDescriptor) -> JSBool {
pub fn defineProperty_(cx: *JSContext, proxy: *JSObject, id: jsid,
desc: *JSPropertyDescriptor) -> JSBool {
unsafe {
if ((*desc).attrs & JSPROP_GETTER) != 0 && (*desc).setter == JS_StrictPropertyStub {
/*return JS_ReportErrorFlagsAndNumber(cx,
@ -66,6 +66,11 @@ pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid,
}
}
pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid,
desc: *JSPropertyDescriptor) -> JSBool {
defineProperty_(cx, proxy, id, desc)
}
pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString {
unsafe {
let name = str::raw::from_c_str(className);

View file

@ -1,96 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::element;
use dom::bindings::node::unwrap;
use dom::bindings::utils;
use dom::bindings::utils::{DOM_OBJECT_SLOT, CacheableWrapper};
use dom::node::{AbstractNode, Comment, Doctype, TextNodeTypeId, CommentNodeTypeId};
use dom::node::{DoctypeNodeTypeId, ScriptView};
use dom::text::Text;
use js::jsapi::{JSFreeOp, JSObject, JSContext};
use js::jsapi::{JS_SetReservedSlot};
use js::glue::{RUST_PRIVATE_TO_JSVAL};
use js::rust::{Compartment, jsobj};
use std::cast;
use std::libc;
extern fn finalize_text(_fop: *JSFreeOp, obj: *JSObject) {
debug!("text finalize: %?!", obj as uint);
unsafe {
let node: AbstractNode<ScriptView> = unwrap(obj);
let _elem: ~Text = cast::transmute(node.raw_object());
}
}
extern fn finalize_comment(_fop: *JSFreeOp, obj: *JSObject) {
debug!("comment finalize: %?!", obj as uint);
unsafe {
let node: AbstractNode<ScriptView> = unwrap(obj);
let _elem: ~Comment = cast::transmute(node.raw_object());
}
}
extern fn finalize_doctype(_fop: *JSFreeOp, obj: *JSObject) {
debug!("doctype finalize: %?!", obj as uint);
unsafe {
let node: AbstractNode<ScriptView> = unwrap(obj);
let _elem: ~Doctype<ScriptView> = cast::transmute(node.raw_object());
}
}
pub fn init(compartment: @mut Compartment) {
let _ = utils::define_empty_prototype(~"CharacterData", Some(~"Node"), compartment);
let _ = utils::define_empty_prototype(~"TextPrototype",
Some(~"CharacterData"),
compartment);
let _ = utils::define_empty_prototype(~"CommentPrototype",
Some(~"CharacterData"),
compartment);
let _ = utils::define_empty_prototype(~"DocumentTypePrototype",
Some(~"Node"),
compartment);
compartment.register_class(utils::instance_jsclass(~"Text",
finalize_text,
element::trace));
compartment.register_class(utils::instance_jsclass(~"Comment",
finalize_comment,
element::trace));
compartment.register_class(utils::instance_jsclass(~"DocumentType",
finalize_doctype,
element::trace));
}
pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj {
let (proto, instance) = match node.type_id() {
TextNodeTypeId => (~"TextPrototype", ~"Text"),
CommentNodeTypeId => (~"CommentPrototype", ~"Comment"),
DoctypeNodeTypeId => (~"DocumentTypePrototype", ~"DocumentType"),
_ => fail!(~"text::create only handles textual nodes")
};
//XXXjdm the parent should probably be the node parent instead of the global
//TODO error checking
let compartment = utils::get_compartment(cx);
let obj = compartment.new_object_with_proto(instance,
proto,
compartment.global_obj.ptr).unwrap();
let cache = node.get_wrappercache();
assert!(cache.get_wrapper().is_null());
cache.set_wrapper(obj.ptr);
unsafe {
let raw_ptr = node.raw_object() as *libc::c_void;
JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT as u32, RUST_PRIVATE_TO_JSVAL(raw_ptr));
}
return obj;
}

View file

@ -0,0 +1,33 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, str, null_string, ErrorResult};
use dom::characterdata::CharacterData;
use dom::node::{AbstractNode, ScriptView, CommentNodeTypeId, Node};
use dom::window::Window;
/// An HTML comment.
pub struct Comment {
parent: CharacterData,
}
impl Comment {
/// Creates a new HTML comment.
pub fn new(text: ~str) -> Comment {
Comment {
parent: CharacterData::new(CommentNodeTypeId, text)
}
}
pub fn Constructor(owner: @mut Window, data: &DOMString, _rv: &mut ErrorResult) -> AbstractNode<ScriptView> {
let s = match *data {
str(ref s) => s.clone(),
null_string => ~""
};
unsafe {
let compartment = (*owner.page).js_info.get_ref().js_compartment;
Node::as_abstract_node(compartment.cx.ptr, @Comment::new(s))
}
}
}

View file

@ -0,0 +1,50 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, str, null_string};
use dom::node::{ScriptView, Node, DoctypeNodeTypeId};
/// The `DOCTYPE` tag.
pub struct DocumentType<View> {
parent: Node<View>,
name: ~str,
public_id: Option<~str>,
system_id: Option<~str>,
force_quirks: bool
}
impl DocumentType<ScriptView> {
/// Creates a new `DOCTYPE` tag.
pub fn new(name: ~str,
public_id: Option<~str>,
system_id: Option<~str>,
force_quirks: bool)
-> DocumentType<ScriptView> {
DocumentType {
parent: Node::new(DoctypeNodeTypeId),
name: name,
public_id: public_id,
system_id: system_id,
force_quirks: force_quirks,
}
}
pub fn Name(&self) -> DOMString {
str(self.name.clone())
}
pub fn PublicId(&self) -> DOMString {
match self.public_id {
Some(ref s) => str(s.clone()),
None => null_string
}
}
pub fn SystemId(&self) -> DOMString {
match self.system_id {
Some(ref s) => str(s.clone()),
None => null_string
}
}
}

View file

@ -78,9 +78,15 @@ pub enum ElementTypeId {
HTMLLIElementTypeId,
HTMLMapElementTypeId,
HTMLMetaElementTypeId,
HTMLMeterElementTypeId,
HTMLModElementTypeId,
HTMLObjectElementTypeId,
HTMLOListElementTypeId,
HTMLOptGroupElementTypeId,
HTMLOptionElementTypeId,
HTMLOutputElementTypeId,
HTMLParagraphElementTypeId,
HTMLParamElementTypeId,
HTMLProgressElementTypeId,
HTMLQuoteElementTypeId,
HTMLScriptElementTypeId,
@ -99,17 +105,14 @@ pub enum ElementTypeId {
HTMLTimeElementTypeId,
HTMLTitleElementTypeId,
HTMLUListElementTypeId,
UnknownElementTypeId,
HTMLUnknownElementTypeId,
}
//
// Regular old elements
//
pub struct HTMLOptionElement { parent: HTMLElement }
pub struct HTMLSelectElement { parent: HTMLElement }
pub struct HTMLSmallElement { parent: HTMLElement }
pub struct UnknownElement { parent: HTMLElement }
//
// Element methods

View file

@ -0,0 +1,54 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::ErrorResult;
use dom::htmlelement::HTMLElement;
pub struct HTMLMeterElement {
parent: HTMLElement
}
impl HTMLMeterElement {
pub fn Value(&self) -> f64 {
0.0
}
pub fn SetValue(&mut self, _value: f64, _rv: &mut ErrorResult) {
}
pub fn Min(&self) -> f64 {
0.0
}
pub fn SetMin(&mut self, _min: f64, _rv: &mut ErrorResult) {
}
pub fn Max(&self) -> f64 {
0.0
}
pub fn SetMax(&mut self, _max: f64, _rv: &mut ErrorResult) {
}
pub fn Low(&self) -> f64 {
0.0
}
pub fn SetLow(&mut self, _low: f64, _rv: &mut ErrorResult) {
}
pub fn High(&self) -> f64 {
0.0
}
pub fn SetHigh(&mut self, _high: f64, _rv: &mut ErrorResult) {
}
pub fn Optimum(&self) -> f64 {
0.0
}
pub fn SetOptimum(&mut self, _optimum: f64, _rv: &mut ErrorResult) {
}
}

View file

@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
use dom::htmlelement::HTMLElement;
pub struct HTMLModElement {
parent: HTMLElement
}
impl HTMLModElement {
pub fn Cite(&self) -> DOMString {
null_string
}
pub fn SetCite(&mut self, _cite: &DOMString, _rv: &mut ErrorResult) {
}
pub fn DateTime(&self) -> DOMString {
null_string
}
pub fn SetDateTime(&mut self, _datetime: &DOMString, _rv: &mut ErrorResult) {
}
}

View file

@ -0,0 +1,163 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
use dom::document::AbstractDocument;
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, ScriptView};
use dom::validitystate::ValidityState;
use dom::windowproxy::WindowProxy;
pub struct HTMLObjectElement {
parent: HTMLElement
}
impl HTMLObjectElement {
pub fn Data(&self) -> DOMString {
null_string
}
pub fn SetData(&mut self, _data: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Type(&self) -> DOMString {
null_string
}
pub fn SetType(&mut self, _type: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Name(&self) -> DOMString {
null_string
}
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
}
pub fn UseMap(&self) -> DOMString {
null_string
}
pub fn SetUseMap(&mut self, _use_map: &DOMString, _rv: &mut ErrorResult) {
}
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> {
None
}
pub fn Width(&self) -> DOMString {
null_string
}
pub fn SetWidth(&mut self, _width: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Height(&self) -> DOMString {
null_string
}
pub fn SetHeight(&mut self, _height: &DOMString, _rv: &mut ErrorResult) {
}
pub fn GetContentDocument(&self) -> Option<AbstractDocument> {
None
}
pub fn GetContentWindow(&self) -> Option<@mut WindowProxy> {
None
}
pub fn WillValidate(&self) -> bool {
false
}
pub fn Validity(&self) -> @mut ValidityState {
@mut ValidityState::valid()
}
pub fn ValidationMessage(&self) -> DOMString {
null_string
}
pub fn CheckValidity(&self) -> bool {
false
}
pub fn SetCustomValidity(&mut self, _error: &DOMString) {
}
pub fn Align(&self) -> DOMString {
null_string
}
pub fn SetAlign(&mut self, _align: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Archive(&self) -> DOMString {
null_string
}
pub fn SetArchive(&mut self, _archive: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Code(&self) -> DOMString {
null_string
}
pub fn SetCode(&mut self, _code: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Declare(&self) -> bool {
false
}
pub fn SetDeclare(&mut self, _declare: bool, _rv: &mut ErrorResult) {
}
pub fn Hspace(&self) -> u32 {
0
}
pub fn SetHspace(&mut self, _hspace: u32, _rv: &mut ErrorResult) {
}
pub fn Standby(&self) -> DOMString {
null_string
}
pub fn SetStandby(&mut self, _standby: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Vspace(&self) -> u32 {
0
}
pub fn SetVspace(&mut self, _vspace: u32, _rv: &mut ErrorResult) {
}
pub fn CodeBase(&self) -> DOMString {
null_string
}
pub fn SetCodeBase(&mut self, _codebase: &DOMString, _rv: &mut ErrorResult) {
}
pub fn CodeType(&self) -> DOMString {
null_string
}
pub fn SetCodeType(&mut self, _codetype: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Border(&self) -> DOMString {
null_string
}
pub fn SetBorder(&mut self, _border: &DOMString, _rv: &mut ErrorResult) {
}
pub fn GetSVGDocument(&self) -> Option<AbstractDocument> {
None
}
}

View file

@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, ErrorResult, null_string};
use dom::htmlelement::HTMLElement;
pub struct HTMLOptGroupElement {
parent: HTMLElement
}
impl HTMLOptGroupElement {
pub fn Disabled(&self) -> bool {
false
}
pub fn SetDisabled(&mut self, _disabled: bool, _rv: &mut ErrorResult) {
}
pub fn Label(&self) -> DOMString {
null_string
}
pub fn SetLabel(&mut self, _label: &DOMString, _rv: &mut ErrorResult) {
}
}

View file

@ -0,0 +1,63 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, ErrorResult, null_string};
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, ScriptView};
pub struct HTMLOptionElement {
parent: HTMLElement
}
impl HTMLOptionElement {
pub fn Disabled(&self) -> bool {
false
}
pub fn SetDisabled(&mut self, _disabled: bool, _rv: &mut ErrorResult) {
}
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> {
None
}
pub fn Label(&self) -> DOMString {
null_string
}
pub fn SetLabel(&mut self, _label: &DOMString, _rv: &mut ErrorResult) {
}
pub fn DefaultSelected(&self) -> bool {
false
}
pub fn SetDefaultSelected(&mut self, _default_selected: bool, _rv: &mut ErrorResult) {
}
pub fn Selected(&self) -> bool {
false
}
pub fn SetSelected(&mut self, _selected: bool, _rv: &mut ErrorResult) {
}
pub fn Value(&self) -> DOMString {
null_string
}
pub fn SetValue(&mut self, _value: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Text(&self) -> DOMString {
null_string
}
pub fn SetText(&mut self, _text: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Index(&self) -> i32 {
0
}
}

View file

@ -0,0 +1,71 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, ErrorResult, null_string};
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, ScriptView};
use dom::validitystate::ValidityState;
pub struct HTMLOutputElement {
parent: HTMLElement
}
impl HTMLOutputElement {
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> {
None
}
pub fn Name(&self) -> DOMString {
null_string
}
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Type(&self) -> DOMString {
null_string
}
pub fn DefaultValue(&self) -> DOMString {
null_string
}
pub fn SetDefaultValue(&mut self, _value: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Value(&self) -> DOMString {
null_string
}
pub fn SetValue(&mut self, _value: &DOMString, _rv: &mut ErrorResult) {
}
pub fn WillValidate(&self) -> bool {
false
}
pub fn SetWillValidate(&mut self, _will_validate: bool) {
}
pub fn Validity(&self) -> @mut ValidityState {
@mut ValidityState::valid()
}
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
}
pub fn ValidationMessage(&self) -> DOMString {
null_string
}
pub fn SetValidationMessage(&mut self, _message: &DOMString, _rv: &mut ErrorResult) {
}
pub fn CheckValidity(&self) -> bool {
true
}
pub fn SetCustomValidity(&mut self, _error: &DOMString) {
}
}

View file

@ -0,0 +1,40 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, ErrorResult, null_string};
use dom::htmlelement::HTMLElement;
pub struct HTMLParamElement {
parent: HTMLElement
}
impl HTMLParamElement {
pub fn Name(&self) -> DOMString {
null_string
}
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Value(&self) -> DOMString {
null_string
}
pub fn SetValue(&mut self, _value: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Type(&self) -> DOMString {
null_string
}
pub fn SetType(&mut self, _type: &DOMString, _rv: &mut ErrorResult) {
}
pub fn ValueType(&self) -> DOMString {
null_string
}
pub fn SetValueType(&mut self, _value_type: &DOMString, _rv: &mut ErrorResult) {
}
}

View file

@ -0,0 +1,134 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::bindings::utils::{DOMString, ErrorResult, null_string};
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, ScriptView};
use dom::validitystate::ValidityState;
pub struct HTMLSelectElement {
parent: HTMLElement
}
impl HTMLSelectElement {
pub fn Autofocus(&self) -> bool {
false
}
pub fn SetAutofocus(&mut self, _autofocus: bool, _rv: &mut ErrorResult) {
}
pub fn Disabled(&self) -> bool {
false
}
pub fn SetDisabled(&mut self, _disabled: bool, _rv: &mut ErrorResult) {
}
pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> {
None
}
pub fn Multiple(&self) -> bool {
false
}
pub fn SetMultiple(&mut self, _multiple: bool, _rv: &mut ErrorResult) {
}
pub fn Name(&self) -> DOMString {
null_string
}
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Required(&self) -> bool {
false
}
pub fn SetRequired(&mut self, _multiple: bool, _rv: &mut ErrorResult) {
}
pub fn Size(&self) -> u32 {
0
}
pub fn SetSize(&mut self, _size: u32, _rv: &mut ErrorResult) {
}
pub fn Type(&self) -> DOMString {
null_string
}
pub fn Length(&self) -> u32 {
0
}
pub fn SetLength(&mut self, _length: u32, _rv: &mut ErrorResult) {
}
pub fn Item(&self, _index: u32) -> Option<AbstractNode<ScriptView>> {
None
}
pub fn NamedItem(&self, _name: &DOMString) -> Option<AbstractNode<ScriptView>> {
None
}
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<AbstractNode<ScriptView>> {
None
}
pub fn IndexedSetter(&mut self, _index: u32, _option: Option<AbstractNode<ScriptView>>, _rv: &mut ErrorResult) {
}
pub fn Remove_(&self) {
}
pub fn Remove(&self, _index: i32) {
}
pub fn SelectedIndex(&self) -> i32 {
0
}
pub fn SetSelectedIndex(&mut self, _index: i32, _rv: &mut ErrorResult) {
}
pub fn Value(&self) -> DOMString {
null_string
}
pub fn SetValue(&mut self, _value: &DOMString) {
}
pub fn WillValidate(&self) -> bool {
false
}
pub fn SetWillValidate(&mut self, _will_validate: bool) {
}
pub fn Validity(&self) -> @mut ValidityState {
@mut ValidityState::valid()
}
pub fn SetValidity(&mut self, _validity: @mut ValidityState) {
}
pub fn ValidationMessage(&self) -> DOMString {
null_string
}
pub fn SetValidationMessage(&mut self, _message: &DOMString, _rv: &mut ErrorResult) {
}
pub fn CheckValidity(&self) -> bool {
true
}
pub fn SetCustomValidity(&mut self, _error: &DOMString) {
}
}

View file

@ -0,0 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
use dom::htmlelement::HTMLElement;
pub struct HTMLUnknownElement {
parent: HTMLElement
}

View file

@ -8,7 +8,6 @@ use dom::bindings::node;
use dom::bindings::utils::{WrapperCache, DOMString, null_string, ErrorResult};
use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box};
use dom::bindings;
use dom::characterdata::CharacterData;
use dom::document::AbstractDocument;
use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId};
use dom::element::{HTMLStyleElementTypeId};
@ -98,50 +97,6 @@ pub enum NodeTypeId {
TextNodeTypeId,
}
//
// Basic node types
//
/// The `DOCTYPE` tag.
pub struct Doctype<View> {
parent: Node<View>,
name: ~str,
public_id: Option<~str>,
system_id: Option<~str>,
force_quirks: bool
}
impl Doctype<ScriptView> {
/// Creates a new `DOCTYPE` tag.
pub fn new(name: ~str,
public_id: Option<~str>,
system_id: Option<~str>,
force_quirks: bool)
-> Doctype<ScriptView> {
Doctype {
parent: Node::new(DoctypeNodeTypeId),
name: name,
public_id: public_id,
system_id: system_id,
force_quirks: force_quirks,
}
}
}
/// An HTML comment.
pub struct Comment {
parent: CharacterData,
}
impl Comment {
/// Creates a new HTML comment.
pub fn new(text: ~str) -> Comment {
Comment {
parent: CharacterData::new(CommentNodeTypeId, text)
}
}
}
impl<View> Clone for AbstractNode<View> {
fn clone(&self) -> AbstractNode<View> {
*self
@ -655,7 +610,6 @@ impl VoidPtrLike for AbstractNode<LayoutView> {
pub fn define_bindings(compartment: @mut Compartment) {
bindings::node::init(compartment);
bindings::element::init(compartment);
bindings::text::init(compartment);
bindings::utils::initialize_global(compartment.global_obj.ptr);
bindings::codegen::RegisterBindings::Register(compartment);
}

View file

@ -2,13 +2,10 @@
* 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/. */
use dom::bindings::utils::{DOMString, ErrorResult, null_string, CacheableWrapper};
use dom::bindings::utils::{BindingObject, WrapperCache};
use dom::bindings::codegen::TextBinding;
use dom::bindings::utils::{DOMString, ErrorResult, null_string};
use dom::characterdata::CharacterData;
use dom::node::{AbstractNode, ScriptView, Node, TextNodeTypeId};
use dom::window::Window;
use js::jsapi::{JSContext, JSObject};
/// An HTML text node.
pub struct Text {
@ -36,20 +33,3 @@ impl Text {
null_string
}
}
impl CacheableWrapper for Text {
fn get_wrappercache(&mut self) -> &mut WrapperCache {
self.parent.get_wrappercache()
}
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
TextBinding::Wrap(cx, scope, self, &mut unused)
}
}
impl BindingObject for Text {
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper> {
self.parent.GetParentObject(cx)
}
}

View file

@ -2,37 +2,14 @@
* 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/. */
use dom::element::{HTMLElementTypeId,
HTMLAnchorElementTypeId, HTMLAppletElementTypeId,
HTMLAreaElementTypeId, HTMLBaseElementTypeId, HTMLBodyElementTypeId,
HTMLBRElementTypeId, HTMLButtonElementTypeId, HTMLCanvasElementTypeId,
HTMLDataElementTypeId, HTMLDataListElementTypeId, HTMLDivElementTypeId,
HTMLDirectoryElementTypeId, HTMLDListElementTypeId, HTMLEmbedElementTypeId,
HTMLFieldSetElementTypeId, HTMLFontElementTypeId, HTMLFormElementTypeId,
HTMLFrameElementTypeId, HTMLFrameSetElementTypeId, HTMLHRElementTypeId,
HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLImageElementTypeId,
HTMLIframeElementTypeId, HTMLInputElementTypeId, HTMLLinkElementTypeId,
HTMLLIElementTypeId, HTMLMapElementTypeId, HTMLMetaElementTypeId,
HTMLOListElementTypeId, HTMLOptionElementTypeId,
HTMLParagraphElementTypeId, HTMLProgressElementTypeId,
HTMLQuoteElementTypeId, HTMLScriptElementTypeId,
HTMLSelectElementTypeId, HTMLSmallElementTypeId, HTMLSourceElementTypeId,
HTMLSpanElementTypeId, HTMLStyleElementTypeId, HTMLTableSectionElementTypeId,
HTMLTableCellElementTypeId, HTMLTableElementTypeId,
HTMLTableCaptionElementTypeId, HTMLTableColElementTypeId,
HTMLTableRowElementTypeId, HTMLTextAreaElementTypeId,
HTMLTimeElementTypeId, HTMLTitleElementTypeId, HTMLUListElementTypeId,
UnknownElementTypeId};
use dom::element::{HTMLOptionElement, HTMLSelectElement, HTMLSmallElement};
use dom::element::{HTMLHeadingElementTypeId};
use dom::bindings::utils::str;
use dom::element::*;
use dom::htmlelement::HTMLElement;
use dom::htmlheadingelement::{Heading1, Heading2, Heading3, Heading4, Heading5, Heading6};
use dom::htmliframeelement::IFrameSize;
use dom::htmlformelement::HTMLFormElement;
use dom::node::{AbstractNode, ElementNodeTypeId, Node, ScriptView};
use dom::types::*;
use dom::element::Element;
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Comment, Doctype, ElementNodeTypeId, Node, ScriptView};
use dom::bindings::utils::str;
use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser};
use js::jsapi::JSContext;
use newcss::stylesheet::Stylesheet;
@ -235,9 +212,15 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
handle_element!(cx, tag, "li", HTMLLIElementTypeId, HTMLLIElement, []);
handle_element!(cx, tag, "map", HTMLMapElementTypeId, HTMLMapElement, []);
handle_element!(cx, tag, "meta", HTMLMetaElementTypeId, HTMLMetaElement, []);
handle_element!(cx, tag, "meter", HTMLMeterElementTypeId, HTMLMeterElement, []);
handle_element!(cx, tag, "mod", HTMLModElementTypeId, HTMLModElement, []);
handle_element!(cx, tag, "object", HTMLObjectElementTypeId, HTMLObjectElement, []);
handle_element!(cx, tag, "ol", HTMLOListElementTypeId, HTMLOListElement, []);
handle_element!(cx, tag, "option", HTMLOptionElementTypeId, HTMLOptionElement, []);
handle_element!(cx, tag, "optgroup",HTMLOptGroupElementTypeId, HTMLOptGroupElement, []);
handle_element!(cx, tag, "output", HTMLOutputElementTypeId, HTMLOutputElement, []);
handle_element!(cx, tag, "p", HTMLParagraphElementTypeId, HTMLParagraphElement, []);
handle_element!(cx, tag, "param", HTMLParamElementTypeId, HTMLParamElement, []);
handle_element!(cx, tag, "progress",HTMLProgressElementTypeId, HTMLProgressElement, []);
handle_element!(cx, tag, "q", HTMLQuoteElementTypeId, HTMLQuoteElement, []);
handle_element!(cx, tag, "script", HTMLScriptElementTypeId, HTMLScriptElement, []);
@ -275,7 +258,10 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
handle_htmlelement!(cx, tag, "section", HTMLElementTypeId, HTMLElement);
unsafe {
Node::as_abstract_node(cx, @Element::new(UnknownElementTypeId, tag.to_str()))
let element = @HTMLUnknownElement {
parent: HTMLElement::new(HTMLUnknownElementTypeId, tag.to_str())
};
Node::as_abstract_node(cx, element)
}
}
@ -340,10 +326,10 @@ pub fn parse_html(cx: *JSContext,
public_id: public_id,
system_id: system_id,
force_quirks: force_quirks } = doctype;
let node = @Doctype::new(name,
public_id,
system_id,
force_quirks);
let node = @DocumentType::new(name,
public_id,
system_id,
force_quirks);
unsafe {
Node::as_abstract_node(cx, node).to_hubbub_node()
}

View file

@ -26,7 +26,6 @@ pub mod dom {
pub mod bindings {
pub mod element;
pub mod node;
pub mod text;
pub mod utils;
pub mod conversions;
pub mod proxyhandler;
@ -48,7 +47,9 @@ pub mod dom {
pub mod characterdata;
pub mod clientrect;
pub mod clientrectlist;
pub mod comment;
pub mod document;
pub mod documenttype;
pub mod domparser;
pub mod element;
pub mod event;
@ -87,11 +88,19 @@ pub mod dom {
pub mod htmllinkelement;
pub mod htmlmapelement;
pub mod htmlmetaelement;
pub mod htmlmeterelement;
pub mod htmlmodelement;
pub mod htmlobjectelement;
pub mod htmlolistelement;
pub mod htmloptgroupelement;
pub mod htmloptionelement;
pub mod htmloutputelement;
pub mod htmlparagraphelement;
pub mod htmlparamelement;
pub mod htmlprogresselement;
pub mod htmlquoteelement;
pub mod htmlscriptelement;
pub mod htmlselectelement;
pub mod htmlspanelement;
pub mod htmlsourceelement;
pub mod htmlstyleelement;
@ -105,6 +114,7 @@ pub mod dom {
pub mod htmltimeelement;
pub mod htmltitleelement;
pub mod htmlulistelement;
pub mod htmlunknownelement;
pub mod mouseevent;
pub mod node;
pub mod uievent;