mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Merge pull request #2987 from saneyuki/idl
Add some blobs for DOM Bindings
This commit is contained in:
commit
8b3c9f6401
9 changed files with 289 additions and 0 deletions
35
src/components/script/dom/nodeiterator.rs
Normal file
35
src/components/script/dom/nodeiterator.rs
Normal 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_
|
||||||
|
}
|
||||||
|
}
|
40
src/components/script/dom/range.rs
Normal file
40
src/components/script/dom/range.rs
Normal 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_
|
||||||
|
}
|
||||||
|
}
|
35
src/components/script/dom/treewalker.rs
Normal file
35
src/components/script/dom/treewalker.rs
Normal 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_
|
||||||
|
}
|
||||||
|
}
|
33
src/components/script/dom/webidls/NodeFilter.webidl
Normal file
33
src/components/script/dom/webidls/NodeFilter.webidl
Normal 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);
|
||||||
|
};
|
32
src/components/script/dom/webidls/NodeIterator.webidl
Normal file
32
src/components/script/dom/webidls/NodeIterator.webidl
Normal 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();
|
||||||
|
};
|
85
src/components/script/dom/webidls/Range.webidl
Normal file
85
src/components/script/dom/webidls/Range.webidl
Normal 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();
|
||||||
|
};
|
23
src/components/script/dom/webidls/TreeWalker.webidl
Normal file
23
src/components/script/dom/webidls/TreeWalker.webidl
Normal 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();
|
||||||
|
};
|
|
@ -173,13 +173,16 @@ pub mod dom {
|
||||||
pub mod mouseevent;
|
pub mod mouseevent;
|
||||||
pub mod navigator;
|
pub mod navigator;
|
||||||
pub mod node;
|
pub mod node;
|
||||||
|
pub mod nodeiterator;
|
||||||
pub mod nodelist;
|
pub mod nodelist;
|
||||||
pub mod processinginstruction;
|
pub mod processinginstruction;
|
||||||
pub mod performance;
|
pub mod performance;
|
||||||
pub mod performancetiming;
|
pub mod performancetiming;
|
||||||
pub mod progressevent;
|
pub mod progressevent;
|
||||||
|
pub mod range;
|
||||||
pub mod screen;
|
pub mod screen;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
|
pub mod treewalker;
|
||||||
pub mod uievent;
|
pub mod uievent;
|
||||||
pub mod urlsearchparams;
|
pub mod urlsearchparams;
|
||||||
pub mod validitystate;
|
pub mod validitystate;
|
||||||
|
|
|
@ -147,14 +147,17 @@ var interfaceNamesInGlobalScope = [
|
||||||
"MouseEvent",
|
"MouseEvent",
|
||||||
"Navigator",
|
"Navigator",
|
||||||
"Node",
|
"Node",
|
||||||
|
"NodeIterator",
|
||||||
"NodeList",
|
"NodeList",
|
||||||
"Performance",
|
"Performance",
|
||||||
"PerformanceTiming",
|
"PerformanceTiming",
|
||||||
"ProcessingInstruction",
|
"ProcessingInstruction",
|
||||||
"ProgressEvent",
|
"ProgressEvent",
|
||||||
|
"Range",
|
||||||
"Screen",
|
"Screen",
|
||||||
"TestBinding", // XXX
|
"TestBinding", // XXX
|
||||||
"Text",
|
"Text",
|
||||||
|
"TreeWalker",
|
||||||
"UIEvent",
|
"UIEvent",
|
||||||
"URLSearchParams",
|
"URLSearchParams",
|
||||||
"ValidityState",
|
"ValidityState",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue