diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2014-08-07 19:12:04 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2014-08-07 19:12:04 +0100 |
commit | 8b3c9f64016fe05048f8d774dc7bf0b842bdbd9c (patch) | |
tree | 6b518feee941568ef884b1765c0bfe7ab472f787 /src | |
parent | 1e3dc0341b48f3d6d81cc098c57a1aff6e17dfe5 (diff) | |
parent | bf85cdf0eb734513155af38663393fe7fcc03e83 (diff) | |
download | servo-8b3c9f64016fe05048f8d774dc7bf0b842bdbd9c.tar.gz servo-8b3c9f64016fe05048f8d774dc7bf0b842bdbd9c.zip |
Merge pull request #2987 from saneyuki/idl
Add some blobs for DOM Bindings
Diffstat (limited to 'src')
-rw-r--r-- | src/components/script/dom/nodeiterator.rs | 35 | ||||
-rw-r--r-- | src/components/script/dom/range.rs | 40 | ||||
-rw-r--r-- | src/components/script/dom/treewalker.rs | 35 | ||||
-rw-r--r-- | src/components/script/dom/webidls/NodeFilter.webidl | 33 | ||||
-rw-r--r-- | src/components/script/dom/webidls/NodeIterator.webidl | 32 | ||||
-rw-r--r-- | src/components/script/dom/webidls/Range.webidl | 85 | ||||
-rw-r--r-- | src/components/script/dom/webidls/TreeWalker.webidl | 23 | ||||
-rw-r--r-- | src/components/script/script.rs | 3 | ||||
-rw-r--r-- | src/test/content/test_interfaces.html | 3 |
9 files changed, 289 insertions, 0 deletions
diff --git a/src/components/script/dom/nodeiterator.rs b/src/components/script/dom/nodeiterator.rs new file mode 100644 index 00000000000..f890f71cf4f --- /dev/null +++ b/src/components/script/dom/nodeiterator.rs @@ -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_ + } +} diff --git a/src/components/script/dom/range.rs b/src/components/script/dom/range.rs new file mode 100644 index 00000000000..16449cabe1a --- /dev/null +++ b/src/components/script/dom/range.rs @@ -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_ + } +} diff --git a/src/components/script/dom/treewalker.rs b/src/components/script/dom/treewalker.rs new file mode 100644 index 00000000000..dc192c359ce --- /dev/null +++ b/src/components/script/dom/treewalker.rs @@ -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_ + } +} diff --git a/src/components/script/dom/webidls/NodeFilter.webidl b/src/components/script/dom/webidls/NodeFilter.webidl new file mode 100644 index 00000000000..b84b369829e --- /dev/null +++ b/src/components/script/dom/webidls/NodeFilter.webidl @@ -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); +}; diff --git a/src/components/script/dom/webidls/NodeIterator.webidl b/src/components/script/dom/webidls/NodeIterator.webidl new file mode 100644 index 00000000000..6eb684dd9f9 --- /dev/null +++ b/src/components/script/dom/webidls/NodeIterator.webidl @@ -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(); +}; diff --git a/src/components/script/dom/webidls/Range.webidl b/src/components/script/dom/webidls/Range.webidl new file mode 100644 index 00000000000..c0e8f630546 --- /dev/null +++ b/src/components/script/dom/webidls/Range.webidl @@ -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(); +}; diff --git a/src/components/script/dom/webidls/TreeWalker.webidl b/src/components/script/dom/webidls/TreeWalker.webidl new file mode 100644 index 00000000000..70987abb528 --- /dev/null +++ b/src/components/script/dom/webidls/TreeWalker.webidl @@ -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(); +}; diff --git a/src/components/script/script.rs b/src/components/script/script.rs index 80c71e0499f..134d032f635 100644 --- a/src/components/script/script.rs +++ b/src/components/script/script.rs @@ -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; diff --git a/src/test/content/test_interfaces.html b/src/test/content/test_interfaces.html index a5af62e377d..6f6d19c52cc 100644 --- a/src/test/content/test_interfaces.html +++ b/src/test/content/test_interfaces.html @@ -147,14 +147,17 @@ var interfaceNamesInGlobalScope = [ "MouseEvent", "Navigator", "Node", + "NodeIterator", "NodeList", "Performance", "PerformanceTiming", "ProcessingInstruction", "ProgressEvent", + "Range", "Screen", "TestBinding", // XXX "Text", + "TreeWalker", "UIEvent", "URLSearchParams", "ValidityState", |