servo: Merge #2987 - Add some blobs for DOM Bindings (from saneyuki:idl)

Source-Repo: https://github.com/servo/servo
Source-Revision: 8b3c9f64016fe05048f8d774dc7bf0b842bdbd9c
This commit is contained in:
Tetsuharu OHZEKI 2014-08-07 19:12:04 +01:00
parent 568ddea503
commit 6573b324d8
9 changed files with 289 additions and 0 deletions

View File

@ -0,0 +1,35 @@
/* 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::codegen::Bindings::NodeIteratorBinding;
use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
#[deriving(Encodable)]
pub struct NodeIterator {
pub reflector_: Reflector
}
impl NodeIterator {
pub fn new_inherited() -> NodeIterator {
NodeIterator {
reflector_: Reflector::new()
}
}
pub fn new(global: &GlobalRef) -> Temporary<NodeIterator> {
reflect_dom_object(box NodeIterator::new_inherited(), global, NodeIteratorBinding::Wrap)
}
}
impl<'a> NodeIteratorMethods for JSRef<'a, NodeIterator> {
}
impl Reflectable for NodeIterator {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
}

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::codegen::Bindings::RangeBinding;
use dom::bindings::codegen::Bindings::RangeBinding::RangeMethods;
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
#[deriving(Encodable)]
pub struct Range {
pub reflector_: Reflector
}
impl Range {
pub fn new_inherited() -> Range {
Range {
reflector_: Reflector::new()
}
}
pub fn new(global: &GlobalRef) -> Temporary<Range> {
reflect_dom_object(box Range::new_inherited(), global, RangeBinding::Wrap)
}
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Range>> {
Ok(Range::new(global))
}
}
impl<'a> RangeMethods for JSRef<'a, Range> {
}
impl Reflectable for Range {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
}

View File

@ -0,0 +1,35 @@
/* 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::codegen::Bindings::TreeWalkerBinding;
use dom::bindings::codegen::Bindings::TreeWalkerBinding::TreeWalkerMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
#[deriving(Encodable)]
pub struct TreeWalker {
pub reflector_: Reflector
}
impl TreeWalker {
pub fn new_inherited() -> TreeWalker {
TreeWalker {
reflector_: Reflector::new()
}
}
pub fn new(global: &GlobalRef) -> Temporary<TreeWalker> {
reflect_dom_object(box TreeWalker::new_inherited(), global, TreeWalkerBinding::Wrap)
}
}
impl<'a> TreeWalkerMethods for JSRef<'a, TreeWalker> {
}
impl Reflectable for TreeWalker {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
}

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://dom.spec.whatwg.org/#interface-nodefilter
*/
// Import form http://hg.mozilla.org/mozilla-central/file/a5a720259d79/dom/webidl/NodeFilter.webidl
callback interface NodeFilter {
// Constants for acceptNode()
// const unsigned short FILTER_ACCEPT = 1;
// const unsigned short FILTER_REJECT = 2;
// const unsigned short FILTER_SKIP = 3;
// Constants for whatToShow
// const unsigned long SHOW_ALL = 0xFFFFFFFF;
// const unsigned long SHOW_ELEMENT = 0x1;
// const unsigned long SHOW_ATTRIBUTE = 0x2; // historical
// const unsigned long SHOW_TEXT = 0x4;
// const unsigned long SHOW_CDATA_SECTION = 0x8; // historical
// const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // historical
// const unsigned long SHOW_ENTITY = 0x20; // historical
// const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x40;
// const unsigned long SHOW_COMMENT = 0x80;
// const unsigned long SHOW_DOCUMENT = 0x100;
// const unsigned long SHOW_DOCUMENT_TYPE = 0x200;
// const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400;
// const unsigned long SHOW_NOTATION = 0x800; // historical
unsigned short acceptNode(Node node);
};

View File

@ -0,0 +1,32 @@
/* -*- 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.w3.org/TR/2012/WD-dom-20120105/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
// Import from http://hg.mozilla.org/mozilla-central/raw-file/a5a720259d79/dom/webidl/NodeIterator.webidl
interface NodeIterator {
// [Constant]
// readonly attribute Node root;
// [Pure]
// readonly attribute Node? referenceNode;
// [Pure]
// readonly attribute boolean pointerBeforeReferenceNode;
// [Constant]
// readonly attribute unsigned long whatToShow;
// [Constant]
// readonly attribute NodeFilter? filter;
// [Throws]
// Node? nextNode();
// [Throws]
// Node? previousNode();
// void detach();
};

View File

@ -0,0 +1,85 @@
/* -*- 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/#range
* http://domparsing.spec.whatwg.org/#dom-range-createcontextualfragment
* http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html#extensions-to-the-range-interface
*/
[Constructor]
interface Range {
// [Throws]
// readonly attribute Node startContainer;
// [Throws]
// readonly attribute unsigned long startOffset;
// [Throws]
// readonly attribute Node endContainer;
// [Throws]
// readonly attribute unsigned long endOffset;
// readonly attribute boolean collapsed;
// [Throws]
// readonly attribute Node commonAncestorContainer;
// [Throws]
// void setStart(Node refNode, unsigned long offset);
// [Throws]
// void setEnd(Node refNode, unsigned long offset);
// [Throws]
// void setStartBefore(Node refNode);
// [Throws]
// void setStartAfter(Node refNode);
// [Throws]
// void setEndBefore(Node refNode);
// [Throws]
// void setEndAfter(Node refNode);
// void collapse(optional boolean toStart = false);
// [Throws]
// void selectNode(Node refNode);
// [Throws]
// void selectNodeContents(Node refNode);
// const unsigned short START_TO_START = 0;
// const unsigned short START_TO_END = 1;
// const unsigned short END_TO_END = 2;
// const unsigned short END_TO_START = 3;
// [Throws]
// short compareBoundaryPoints(unsigned short how, Range sourceRange);
// [Throws]
// void deleteContents();
// [Throws]
// DocumentFragment extractContents();
// [Throws]
// DocumentFragment cloneContents();
// [Throws]
// void insertNode(Node node);
// [Throws]
// void surroundContents(Node newParent);
// Range cloneRange();
// void detach();
// [Throws]
// boolean isPointInRange(Node node, unsigned long offset);
// [Throws]
// short comparePoint(Node node, unsigned long offset);
// [Throws]
// boolean intersectsNode(Node node);
// stringifier;
};
// http://domparsing.spec.whatwg.org/#dom-range-createcontextualfragment
partial interface Range {
// [Throws]
// DocumentFragment createContextualFragment(DOMString fragment);
};//
//// http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html#extensions-to-the-range-interface
partial interface Range {
// DOMRectList? getClientRects();
// DOMRect getBoundingClientRect();
};

View File

@ -0,0 +1,23 @@
/* -*- 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/#interface-treewalker
*/
interface TreeWalker {
// [SameObject] readonly attribute Node root;
// readonly attribute unsigned long whatToShow;
// readonly attribute NodeFilter? filter;
// attribute Node currentNode;
// Node? parentNode();
// Node? firstChild();
// Node? lastChild();
// Node? previousSibling();
// Node? nextSibling();
// Node? previousNode();
// Node? nextNode();
};

View File

@ -173,13 +173,16 @@ pub mod dom {
pub mod mouseevent;
pub mod navigator;
pub mod node;
pub mod nodeiterator;
pub mod nodelist;
pub mod processinginstruction;
pub mod performance;
pub mod performancetiming;
pub mod progressevent;
pub mod range;
pub mod screen;
pub mod text;
pub mod treewalker;
pub mod uievent;
pub mod urlsearchparams;
pub mod validitystate;

View File

@ -147,14 +147,17 @@ var interfaceNamesInGlobalScope = [
"MouseEvent",
"Navigator",
"Node",
"NodeIterator",
"NodeList",
"Performance",
"PerformanceTiming",
"ProcessingInstruction",
"ProgressEvent",
"Range",
"Screen",
"TestBinding", // XXX
"Text",
"TreeWalker",
"UIEvent",
"URLSearchParams",
"ValidityState",