mirror of
https://github.com/servo/servo.git
synced 2025-06-18 05:14:28 +00:00
Generate bindings for HTMLHeadElement.
This commit is contained in:
parent
fd4efad70c
commit
9a545b13c3
13 changed files with 132 additions and 73 deletions
|
@ -234,6 +234,11 @@ DOMInterfaces = {
|
|||
'pointerType': ''
|
||||
},
|
||||
|
||||
'HTMLHeadElement': {
|
||||
'nativeType': 'AbstractNode<ScriptView>',
|
||||
'pointerType': ''
|
||||
},
|
||||
|
||||
'HTMLOptionsCollection': [
|
||||
{
|
||||
'nativeType': 'nsHTMLOptionCollection',
|
||||
|
@ -561,13 +566,9 @@ addExternalIface('CSSRule')
|
|||
addExternalIface('CSSValue')
|
||||
addExternalIface('DOMStringList', nativeType='nsDOMStringList',
|
||||
headerFile='nsDOMLists.h')
|
||||
#addExternalIface('Element', nativeType='AbstractNode<ScriptView>', pointerType='')
|
||||
addExternalIface('File')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
#addExternalIface('HTMLElement', nativeType='AbstractNode<ScriptView>', pointerType='')
|
||||
addExternalIface('HTMLHeadElement', nativeType='AbstractNode<ScriptView>', pointerType='')
|
||||
addExternalIface('ImageData', nativeType='mozilla::dom::ImageData')
|
||||
#addExternalIface('Node', nativeType='AbstractNode<ScriptView>', pointerType='')
|
||||
addExternalIface('PaintRequest')
|
||||
addExternalIface('SVGLength')
|
||||
addExternalIface('SVGMatrix')
|
||||
|
|
|
@ -4605,7 +4605,7 @@ class CGBindingRoot(CGThing):
|
|||
'dom::characterdata::CharacterData', #XXXjdm
|
||||
'dom::node::{AbstractNode, Node, Text}', #XXXjdm
|
||||
'dom::document::{Document, AbstractDocument}', #XXXjdm
|
||||
'dom::element::Element', #XXXjdm
|
||||
'dom::element::{Element, HTMLHeadElement}', #XXXjdm
|
||||
'dom::htmlelement::HTMLElement', #XXXjdm
|
||||
'dom::htmldocument::HTMLDocument', #XXXjdm
|
||||
'dom::bindings::utils::*',
|
||||
|
|
|
@ -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://www.whatwg.org/specs/web-apps/current-work/#the-head-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-head-element
|
||||
interface HTMLHeadElement : HTMLElement {};
|
|
@ -2,11 +2,11 @@
|
|||
* 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::codegen::TextBinding;
|
||||
use dom::bindings::element;
|
||||
use dom::bindings::text;
|
||||
use dom::bindings::utils;
|
||||
use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper};
|
||||
use dom::element::{HTMLHeadElementTypeId, HTMLHeadElement};
|
||||
use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId};
|
||||
use dom::node::{DoctypeNodeTypeId, ScriptView, Text};
|
||||
|
||||
|
@ -65,13 +65,16 @@ pub fn init(compartment: @mut Compartment) {
|
|||
#[allow(non_implicitly_copyable_typarams)]
|
||||
pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject {
|
||||
match node.type_id() {
|
||||
ElementNodeTypeId(HTMLHeadElementTypeId) => {
|
||||
let node: @mut HTMLHeadElement = unsafe { cast::transmute(node.raw_object()) };
|
||||
node.wrap_object_shared(cx, ptr::null())
|
||||
}
|
||||
ElementNodeTypeId(_) => element::create(cx, node).ptr,
|
||||
CommentNodeTypeId |
|
||||
DoctypeNodeTypeId => text::create(cx, node).ptr,
|
||||
TextNodeTypeId => {
|
||||
let mut unused = false;
|
||||
let node: @mut Text = unsafe { cast::transmute(node.raw_object()) };
|
||||
TextBinding::Wrap(cx, ptr::null(), node, &mut unused)
|
||||
node.wrap_object_shared(cx, ptr::null())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::PrototypeList;
|
||||
use dom::bindings::codegen::PrototypeList::MAX_PROTO_CHAIN_LENGTH;
|
||||
use dom::bindings::node;
|
||||
use dom::node::{AbstractNode, ScriptView};
|
||||
use script_task::page_from_context;
|
||||
|
@ -401,7 +402,7 @@ pub struct ConstantSpec {
|
|||
pub struct DOMClass {
|
||||
// A list of interfaces that this object implements, in order of decreasing
|
||||
// derivedness.
|
||||
interface_chain: [PrototypeList::id::ID, ..3 /*max prototype chain length*/],
|
||||
interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH],
|
||||
|
||||
unused: bool, // DOMObjectIsISupports (always false)
|
||||
native_hooks: *NativePropertyHooks
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
use dom::bindings::codegen::DocumentBinding;
|
||||
use dom::bindings::utils::{DOMString, WrapperCache, ErrorResult, null_string, str};
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box, DerivedWrapper};
|
||||
use dom::element::{HTMLHtmlElement, HTMLHtmlElementTypeId, Element};
|
||||
use dom::element::{HTMLHtmlElement, HTMLHtmlElementTypeId};
|
||||
use dom::event::Event;
|
||||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::htmldocument::HTMLDocument;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{AbstractNode, ScriptView, Node};
|
||||
use dom::window::Window;
|
||||
use dom::windowproxy::WindowProxy;
|
||||
|
@ -102,7 +103,7 @@ impl Document {
|
|||
|
||||
pub fn Constructor(owner: @mut Window, _rv: &mut ErrorResult) -> AbstractDocument {
|
||||
let root = @HTMLHtmlElement {
|
||||
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
|
||||
parent: HTMLElement::new(HTMLHtmlElementTypeId, ~"html")
|
||||
};
|
||||
|
||||
let cx = unsafe {(*owner.page).js_info.get_ref().js_compartment.cx.ptr};
|
||||
|
|
|
@ -6,8 +6,9 @@ use dom::bindings::codegen::DOMParserBinding;
|
|||
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
||||
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache, CacheableWrapper};
|
||||
use dom::document::{AbstractDocument, Document, XML};
|
||||
use dom::element::{Element, HTMLHtmlElement, HTMLHtmlElementTypeId};
|
||||
use dom::element::{HTMLHtmlElement, HTMLHtmlElementTypeId};
|
||||
use dom::htmldocument::HTMLDocument;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::Node;
|
||||
use dom::window::Window;
|
||||
|
||||
|
@ -42,7 +43,7 @@ impl DOMParser {
|
|||
-> AbstractDocument {
|
||||
unsafe {
|
||||
let root = @HTMLHtmlElement {
|
||||
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
|
||||
parent: HTMLElement::new(HTMLHtmlElementTypeId, ~"html")
|
||||
};
|
||||
|
||||
let root = Node::as_abstract_node((*self.owner.page).js_info.get_ref().js_compartment.cx.ptr, root);
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
|
||||
//! Element nodes.
|
||||
|
||||
use dom::bindings::codegen::HTMLHeadElementBinding;
|
||||
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::htmlcollection::HTMLCollection;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{ElementNodeTypeId, Node, ScriptView, AbstractNode};
|
||||
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
|
||||
use layout_interface::{ContentBoxesResponse};
|
||||
|
@ -30,6 +32,22 @@ pub struct Element {
|
|||
attrs: ~[Attr],
|
||||
}
|
||||
|
||||
impl CacheableWrapper for Element {
|
||||
fn get_wrappercache(&mut self) -> &mut WrapperCache {
|
||||
self.parent.get_wrappercache()
|
||||
}
|
||||
|
||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||
fail!("no wrapping")
|
||||
}
|
||||
}
|
||||
|
||||
impl BindingObject for Element {
|
||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper> {
|
||||
self.parent.GetParentObject(cx)
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
pub enum ElementTypeId {
|
||||
HTMLAnchorElementTypeId,
|
||||
|
@ -73,57 +91,74 @@ pub enum ElementTypeId {
|
|||
// Regular old elements
|
||||
//
|
||||
|
||||
pub struct HTMLAnchorElement { parent: Element }
|
||||
pub struct HTMLAsideElement { parent: Element }
|
||||
pub struct HTMLBRElement { parent: Element }
|
||||
pub struct HTMLBodyElement { parent: Element }
|
||||
pub struct HTMLBoldElement { parent: Element }
|
||||
pub struct HTMLDivElement { parent: Element }
|
||||
pub struct HTMLFontElement { parent: Element }
|
||||
pub struct HTMLFormElement { parent: Element }
|
||||
pub struct HTMLHRElement { parent: Element }
|
||||
pub struct HTMLHeadElement { parent: Element }
|
||||
pub struct HTMLHtmlElement { parent: Element }
|
||||
pub struct HTMLInputElement { parent: Element }
|
||||
pub struct HTMLItalicElement { parent: Element }
|
||||
pub struct HTMLLinkElement { parent: Element }
|
||||
pub struct HTMLListItemElement { parent: Element }
|
||||
pub struct HTMLMetaElement { parent: Element }
|
||||
pub struct HTMLOListElement { parent: Element }
|
||||
pub struct HTMLOptionElement { parent: Element }
|
||||
pub struct HTMLParagraphElement { parent: Element }
|
||||
pub struct HTMLScriptElement { parent: Element }
|
||||
pub struct HTMLSectionElement { parent: Element }
|
||||
pub struct HTMLSelectElement { parent: Element }
|
||||
pub struct HTMLSmallElement { parent: Element }
|
||||
pub struct HTMLSpanElement { parent: Element }
|
||||
pub struct HTMLStyleElement { parent: Element }
|
||||
pub struct HTMLTableBodyElement { parent: Element }
|
||||
pub struct HTMLTableCellElement { parent: Element }
|
||||
pub struct HTMLTableElement { parent: Element }
|
||||
pub struct HTMLTableRowElement { parent: Element }
|
||||
pub struct HTMLTitleElement { parent: Element }
|
||||
pub struct HTMLUListElement { parent: Element }
|
||||
pub struct UnknownElement { parent: Element }
|
||||
pub struct HTMLAnchorElement { parent: HTMLElement }
|
||||
pub struct HTMLAsideElement { parent: HTMLElement }
|
||||
pub struct HTMLBRElement { parent: HTMLElement }
|
||||
pub struct HTMLBodyElement { parent: HTMLElement }
|
||||
pub struct HTMLBoldElement { parent: HTMLElement }
|
||||
pub struct HTMLDivElement { parent: HTMLElement }
|
||||
pub struct HTMLFontElement { parent: HTMLElement }
|
||||
pub struct HTMLFormElement { parent: HTMLElement }
|
||||
pub struct HTMLHRElement { parent: HTMLElement }
|
||||
pub struct HTMLHeadElement { parent: HTMLElement }
|
||||
pub struct HTMLHtmlElement { parent: HTMLElement }
|
||||
pub struct HTMLInputElement { parent: HTMLElement }
|
||||
pub struct HTMLItalicElement { parent: HTMLElement }
|
||||
pub struct HTMLLinkElement { parent: HTMLElement }
|
||||
pub struct HTMLListItemElement { parent: HTMLElement }
|
||||
pub struct HTMLMetaElement { parent: HTMLElement }
|
||||
pub struct HTMLOListElement { parent: HTMLElement }
|
||||
pub struct HTMLOptionElement { parent: HTMLElement }
|
||||
pub struct HTMLParagraphElement { parent: HTMLElement }
|
||||
pub struct HTMLScriptElement { parent: HTMLElement }
|
||||
pub struct HTMLSectionElement { parent: HTMLElement }
|
||||
pub struct HTMLSelectElement { parent: HTMLElement }
|
||||
pub struct HTMLSmallElement { parent: HTMLElement }
|
||||
pub struct HTMLSpanElement { parent: HTMLElement }
|
||||
pub struct HTMLStyleElement { parent: HTMLElement }
|
||||
pub struct HTMLTableBodyElement { parent: HTMLElement }
|
||||
pub struct HTMLTableCellElement { parent: HTMLElement }
|
||||
pub struct HTMLTableElement { parent: HTMLElement }
|
||||
pub struct HTMLTableRowElement { parent: HTMLElement }
|
||||
pub struct HTMLTitleElement { parent: HTMLElement }
|
||||
pub struct HTMLUListElement { parent: HTMLElement }
|
||||
pub struct UnknownElement { parent: HTMLElement }
|
||||
|
||||
impl CacheableWrapper for HTMLHeadElement {
|
||||
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;
|
||||
HTMLHeadElementBinding::Wrap(cx, scope, self, &mut unused)
|
||||
}
|
||||
}
|
||||
|
||||
impl BindingObject for HTMLHeadElement {
|
||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper> {
|
||||
self.parent.GetParentObject(cx)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fancier elements
|
||||
//
|
||||
|
||||
pub struct HTMLHeadingElement {
|
||||
parent: Element,
|
||||
parent: HTMLElement,
|
||||
level: HeadingLevel,
|
||||
}
|
||||
|
||||
pub struct HTMLIframeElement {
|
||||
parent: Element,
|
||||
parent: HTMLElement,
|
||||
frame: Option<Url>,
|
||||
subpage_id: Option<SubpageId>,
|
||||
size_future_chan: Option<ChanOne<Size2D<uint>>>,
|
||||
}
|
||||
|
||||
pub struct HTMLImageElement {
|
||||
parent: Element,
|
||||
parent: HTMLElement,
|
||||
image: Option<Url>,
|
||||
}
|
||||
|
||||
|
@ -439,19 +474,3 @@ pub enum HeadingLevel {
|
|||
Heading5,
|
||||
Heading6,
|
||||
}
|
||||
|
||||
impl CacheableWrapper for Element {
|
||||
fn get_wrappercache(&mut self) -> &mut WrapperCache {
|
||||
self.parent.get_wrappercache()
|
||||
}
|
||||
|
||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||
fail!(~"need to implement wrapping");
|
||||
}
|
||||
}
|
||||
|
||||
impl BindingObject for Element {
|
||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper> {
|
||||
self.parent.GetParentObject(cx)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +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::codegen::HTMLElementBinding;
|
||||
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
|
||||
use dom::bindings::utils::{CacheableWrapper, BindingObject, WrapperCache};
|
||||
use dom::element::Element;
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::node::{AbstractNode, ScriptView};
|
||||
use js::jsapi::{JSObject, JSContext, JSVal};
|
||||
use js::JSVAL_NULL;
|
||||
|
@ -13,6 +14,14 @@ pub struct HTMLElement {
|
|||
parent: Element
|
||||
}
|
||||
|
||||
impl HTMLElement {
|
||||
pub fn new(type_id: ElementTypeId, tag_name: ~str) -> HTMLElement {
|
||||
HTMLElement {
|
||||
parent: Element::new(type_id, tag_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLElement {
|
||||
pub fn Title(&self) -> DOMString {
|
||||
null_string
|
||||
|
@ -134,8 +143,9 @@ impl CacheableWrapper for HTMLElement {
|
|||
self.parent.get_wrappercache()
|
||||
}
|
||||
|
||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||
fail!(~"need to implement wrapping");
|
||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||
let mut unused = false;
|
||||
HTMLElementBinding::Wrap(cx, scope, self, &mut unused)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
|
||||
|
||||
use dom::bindings::codegen::TextBinding;
|
||||
use dom::bindings::node;
|
||||
use dom::bindings::utils::{WrapperCache, DOMString, null_string, ErrorResult};
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper};
|
||||
|
@ -694,8 +695,9 @@ impl CacheableWrapper for Text {
|
|||
self.parent.get_wrappercache()
|
||||
}
|
||||
|
||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||
fail!(~"need to implement wrapping");
|
||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||
let mut unused = false;
|
||||
TextBinding::Wrap(cx, scope, self, &mut unused)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ use dom::element::{HTMLAnchorElement, HTMLAsideElement, HTMLBRElement, HTMLBodyE
|
|||
use dom::element::{HTMLHeadingElementTypeId, Heading1, Heading2, Heading3, Heading4, Heading5,
|
||||
Heading6};
|
||||
use dom::element::{Element, Attr};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{AbstractNode, Comment, Doctype, ElementNodeTypeId, Node, ScriptView};
|
||||
use dom::node::{Text};
|
||||
use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser};
|
||||
|
@ -57,7 +58,7 @@ macro_rules! handle_element(
|
|||
($cx: expr, $tag:expr, $string:expr, $type_id:expr, $ctor:ident, [ $(($field:ident : $field_init:expr)),* ]) => (
|
||||
if eq_slice($tag, $string) {
|
||||
let _element = @$ctor {
|
||||
parent: Element::new($type_id, ($tag).to_str()),
|
||||
parent: HTMLElement::new($type_id, ($tag).to_str()),
|
||||
$(
|
||||
$field: $field_init,
|
||||
)*
|
||||
|
@ -272,7 +273,7 @@ pub fn parse_html(cx: *JSContext,
|
|||
let url3 = url.clone();
|
||||
|
||||
// Build the root node.
|
||||
let root = @HTMLHtmlElement { parent: Element::new(HTMLHtmlElementTypeId, ~"html") };
|
||||
let root = @HTMLHtmlElement { parent: HTMLElement::new(HTMLHtmlElementTypeId, ~"html") };
|
||||
let root = unsafe { Node::as_abstract_node(cx, root) };
|
||||
debug!("created new node");
|
||||
let mut parser = hubbub::Parser("UTF-8", false);
|
||||
|
@ -337,7 +338,8 @@ pub fn parse_html(cx: *JSContext,
|
|||
|
||||
ElementNodeTypeId(HTMLIframeElementTypeId) => {
|
||||
do node.with_mut_iframe_element |iframe_element| {
|
||||
let src_opt = iframe_element.parent.get_attr("src").map(|x| x.to_str());
|
||||
let elem = &mut iframe_element.parent.parent;
|
||||
let src_opt = elem.get_attr("src").map(|x| x.to_str());
|
||||
for src_opt.iter().advance |src| {
|
||||
let iframe_url = make_url(src.clone(), Some(url2.clone()));
|
||||
iframe_element.frame = Some(iframe_url.clone());
|
||||
|
@ -359,7 +361,8 @@ pub fn parse_html(cx: *JSContext,
|
|||
|
||||
ElementNodeTypeId(HTMLImageElementTypeId) => {
|
||||
do node.with_mut_image_element |image_element| {
|
||||
let src_opt = image_element.parent.get_attr("src").map(|x| x.to_str());
|
||||
let elem = &mut image_element.parent.parent;
|
||||
let src_opt = elem.get_attr("src").map(|x| x.to_str());
|
||||
match src_opt {
|
||||
None => {}
|
||||
Some(src) => {
|
||||
|
|
|
@ -45,6 +45,7 @@ pub mod dom {
|
|||
pub mod HTMLCollectionBinding;
|
||||
pub mod HTMLDocumentBinding;
|
||||
pub mod HTMLElementBinding;
|
||||
pub mod HTMLHeadElementBinding;
|
||||
pub mod MouseEventBinding;
|
||||
pub mod NodeBinding;
|
||||
pub mod PrototypeList;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!-- comment -->
|
||||
<head>
|
||||
<script src="test_bindings.js"></script>
|
||||
</head>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue