mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Add DOM NodeIterator blob (include DOM NodeFilter interface).
This commit is contained in:
parent
880ae2bdb9
commit
bf85cdf0eb
5 changed files with 102 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_
|
||||||
|
}
|
||||||
|
}
|
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();
|
||||||
|
};
|
|
@ -173,6 +173,7 @@ 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;
|
||||||
|
|
|
@ -147,6 +147,7 @@ var interfaceNamesInGlobalScope = [
|
||||||
"MouseEvent",
|
"MouseEvent",
|
||||||
"Navigator",
|
"Navigator",
|
||||||
"Node",
|
"Node",
|
||||||
|
"NodeIterator",
|
||||||
"NodeList",
|
"NodeList",
|
||||||
"Performance",
|
"Performance",
|
||||||
"PerformanceTiming",
|
"PerformanceTiming",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue