Generate bindings for HTMLAnchorElement.

This commit is contained in:
Josh Matthews 2013-08-05 13:18:58 -04:00
parent e2468160b5
commit 7aa0027384
10 changed files with 172 additions and 7 deletions

View file

@ -544,6 +544,7 @@ def addHTMLElement(element):
'pointerType': ''
}
addHTMLElement('HTMLAnchorElement')
addHTMLElement('HTMLElement')
addHTMLElement('HTMLHeadElement')
addHTMLElement('HTMLHtmlElement')

View file

@ -4237,7 +4237,7 @@ class CGNamespacedEnum(CGThing):
entries.append(entry)
# Append a Count.
entries.append('_' + enumName + '_Count')
entries.append('_' + enumName + '_Count = ' + str(len(entries)))
# Indent.
entries = [' ' + e for e in entries]
@ -4606,6 +4606,7 @@ class CGBindingRoot(CGThing):
'dom::node::{AbstractNode, Node, Text}', #XXXjdm
'dom::document::{Document, AbstractDocument}', #XXXjdm
'dom::element::{Element, HTMLHeadElement, HTMLHtmlElement}', #XXXjdm
'dom::htmlanchorelement::HTMLAnchorElement', #XXXjdm
'dom::htmlelement::HTMLElement', #XXXjdm
'dom::htmldocument::HTMLDocument', #XXXjdm
'dom::bindings::utils::*',

View file

@ -0,0 +1,54 @@
/* -*- 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-a-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-a-element
interface HTMLAnchorElement : HTMLElement {
// No support for stringifier attributes yet
//[SetterThrows]
//stringifier attribute DOMString href;
//stringifier;
[SetterThrows]
attribute DOMString href;
[SetterThrows]
attribute DOMString target;
[SetterThrows]
attribute DOMString download;
[SetterThrows]
attribute DOMString ping;
[SetterThrows]
attribute DOMString rel;
// relList not supported yet
//readonly attribute DOMTokenList relList;
[SetterThrows]
attribute DOMString hreflang;
[SetterThrows]
attribute DOMString type;
[SetterThrows]
attribute DOMString text;
};
//HTMLAnchorElement implements URLUtils;
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLAnchorElement {
[SetterThrows]
attribute DOMString coords;
[SetterThrows]
attribute DOMString charset;
[SetterThrows]
attribute DOMString name;
[SetterThrows]
attribute DOMString rev;
[SetterThrows]
attribute DOMString shape;
};

View file

@ -6,8 +6,9 @@ use dom::bindings::element;
use dom::bindings::text;
use dom::bindings::utils;
use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper};
use dom::element::{HTMLHeadElementTypeId, HTMLHtmlElementTypeId};
use dom::element::{HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLAnchorElementTypeId};
use dom::element::{HTMLHeadElement, HTMLHtmlElement};
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId};
use dom::node::{DoctypeNodeTypeId, ScriptView, Text};
@ -73,6 +74,7 @@ macro_rules! generate_element(
#[allow(non_implicitly_copyable_typarams)]
pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject {
match node.type_id() {
ElementNodeTypeId(HTMLAnchorElementTypeId) => generate_element!(HTMLAnchorElement),
ElementNodeTypeId(HTMLHeadElementTypeId) => generate_element!(HTMLHeadElement),
ElementNodeTypeId(HTMLHtmlElementTypeId) => generate_element!(HTMLHtmlElement),
ElementNodeTypeId(_) => element::create(cx, node).ptr,

View file

@ -617,7 +617,7 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: uint, _vp: *JSVal) ->
}
pub fn initialize_global(global: *JSObject) {
let protoArray = @mut ([0 as *JSObject, ..30]); //XXXjdm PrototyepList::id::_ID_Count
let protoArray = @mut ([0 as *JSObject, ..33]); //XXXjdm PrototyepList::id::_ID_Count
unsafe {
//XXXjdm we should be storing the box pointer instead of the inner
let box = squirrel_away(protoArray);

View file

@ -5,10 +5,12 @@
//! Element nodes.
use dom::bindings::codegen::{HTMLHeadElementBinding, HTMLHtmlElementBinding};
use dom::bindings::codegen::{HTMLAnchorElementBinding};
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
use dom::bindings::utils::{CacheableWrapper, BindingObject, WrapperCache};
use dom::clientrect::ClientRect;
use dom::clientrectlist::ClientRectList;
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement;
use dom::node::{ElementNodeTypeId, Node, ScriptView, AbstractNode};
@ -91,7 +93,6 @@ pub enum ElementTypeId {
// Regular old elements
//
pub struct HTMLAnchorElement { parent: HTMLElement }
pub struct HTMLAsideElement { parent: HTMLElement }
pub struct HTMLBRElement { parent: HTMLElement }
pub struct HTMLBodyElement { parent: HTMLElement }
@ -133,7 +134,7 @@ impl HTMLHtmlElement {
}
}
macro_rules! generate_cacheable_wrapper(
pub macro_rules! generate_cacheable_wrapper(
($name: ident, $wrap: path) => (
impl CacheableWrapper for $name {
fn get_wrappercache(&mut self) -> &mut WrapperCache {
@ -148,7 +149,7 @@ macro_rules! generate_cacheable_wrapper(
)
)
macro_rules! generate_binding_object(
pub macro_rules! generate_binding_object(
($name: ident) => (
impl BindingObject for $name {
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper> {
@ -162,6 +163,8 @@ generate_cacheable_wrapper!(HTMLHeadElement, HTMLHeadElementBinding::Wrap)
generate_binding_object!(HTMLHeadElement)
generate_cacheable_wrapper!(HTMLHtmlElement, HTMLHtmlElementBinding::Wrap)
generate_binding_object!(HTMLHtmlElement)
generate_cacheable_wrapper!(HTMLAnchorElement, HTMLAnchorElementBinding::Wrap)
generate_binding_object!(HTMLAnchorElement)
//
// Fancier elements

View file

@ -0,0 +1,99 @@
use dom::htmlelement::HTMLElement;
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
pub struct HTMLAnchorElement {
parent: HTMLElement
}
impl HTMLAnchorElement {
pub fn Href(&self) -> DOMString {
null_string
}
pub fn SetHref(&mut self, _href: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Target(&self) -> DOMString {
null_string
}
pub fn SetTarget(&self, _target: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Download(&self) -> DOMString {
null_string
}
pub fn SetDownload(&self, _download: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Ping(&self) -> DOMString {
null_string
}
pub fn SetPing(&self, _ping: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Rel(&self) -> DOMString {
null_string
}
pub fn SetRel(&self, _rel: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Hreflang(&self) -> DOMString {
null_string
}
pub fn SetHreflang(&self, _href_lang: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Type(&self) -> DOMString {
null_string
}
pub fn SetType(&mut self, _type: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Text(&self) -> DOMString {
null_string
}
pub fn SetText(&mut self, _text: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Coords(&self) -> DOMString {
null_string
}
pub fn SetCoords(&mut self, _coords: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Charset(&self) -> DOMString {
null_string
}
pub fn SetCharset(&mut self, _charset: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Name(&self) -> DOMString {
null_string
}
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Rev(&self) -> DOMString {
null_string
}
pub fn SetRev(&mut self, _rev: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Shape(&self) -> DOMString {
null_string
}
pub fn SetShape(&mut self, _shape: &DOMString, _rv: &mut ErrorResult) {
}
}

View file

@ -15,7 +15,7 @@ use dom::element::{HTMLAnchorElementTypeId, HTMLAsideElementTypeId, HTMLBRElemen
HTMLTableCellElementTypeId, HTMLTableElementTypeId,
HTMLTableRowElementTypeId, HTMLTitleElementTypeId, HTMLUListElementTypeId,
UnknownElementTypeId};
use dom::element::{HTMLAnchorElement, HTMLAsideElement, HTMLBRElement, HTMLBodyElement,
use dom::element::{HTMLAsideElement, HTMLBRElement, HTMLBodyElement,
HTMLBoldElement, HTMLDivElement, HTMLFontElement, HTMLFormElement,
HTMLHRElement, HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement,
HTMLInputElement, HTMLImageElement, HTMLIframeElement,
@ -27,6 +27,7 @@ use dom::element::{HTMLAnchorElement, HTMLAsideElement, HTMLBRElement, HTMLBodyE
HTMLTitleElement, HTMLUListElement};
use dom::element::{HTMLHeadingElementTypeId, Heading1, Heading2, Heading3, Heading4, Heading5,
Heading6};
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::element::{Element, Attr};
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Comment, Doctype, ElementNodeTypeId, Node, ScriptView};

View file

@ -42,6 +42,7 @@ pub mod dom {
pub mod EventBinding;
pub mod EventTargetBinding;
pub mod FormDataBinding;
pub mod HTMLAnchorElementBinding;
pub mod HTMLCollectionBinding;
pub mod HTMLDocumentBinding;
pub mod HTMLElementBinding;
@ -67,6 +68,7 @@ pub mod dom {
pub mod event;
pub mod eventtarget;
pub mod formdata;
pub mod htmlanchorelement;
pub mod htmlcollection;
pub mod htmldocument;
pub mod htmlelement;

View file

@ -124,6 +124,8 @@ window.alert(document.title);
document.title = "foo";
window.alert(document.title);
window.alert(document.links[0]);
//TODO: Doesn't work until we throw proper exceptions instead of returning 0 on
// unwrap failure.
/*try {