aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/processinginstruction.rs
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-02-05 11:14:47 -0400
committerBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-02-06 14:41:55 -0400
commitaa4b5bb9482dbaaca9b76e7c9e54d5654ba22007 (patch)
treecd10cb6d641e4b89151dce05a7b82733a63e15af /src/components/script/dom/processinginstruction.rs
parent5a7d22c43775264359b8ddea8f60d237f5715593 (diff)
downloadservo-aa4b5bb9482dbaaca9b76e7c9e54d5654ba22007.tar.gz
servo-aa4b5bb9482dbaaca9b76e7c9e54d5654ba22007.zip
Implement ProcessingInstruction DOM interface
Spec: http://dom.spec.whatwg.org/#interface-processinginstruction Closes #1619.
Diffstat (limited to 'src/components/script/dom/processinginstruction.rs')
-rw-r--r--src/components/script/dom/processinginstruction.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/components/script/dom/processinginstruction.rs b/src/components/script/dom/processinginstruction.rs
new file mode 100644
index 00000000000..a8a0e666560
--- /dev/null
+++ b/src/components/script/dom/processinginstruction.rs
@@ -0,0 +1,36 @@
+/* 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::ProcessingInstructionBinding;
+use dom::bindings::utils::DOMString;
+use dom::characterdata::CharacterData;
+use dom::document::AbstractDocument;
+use dom::node::{AbstractNode, Node, ProcessingInstructionNodeTypeId};
+
+/// An HTML processing instruction node.
+pub struct ProcessingInstruction {
+ // FIXME: s/element/characterdata/ https://github.com/mozilla/servo/issues/1594
+ element: CharacterData,
+ target: DOMString,
+}
+
+impl ProcessingInstruction {
+ pub fn new_inherited(target: DOMString, data: DOMString, document: AbstractDocument) -> ProcessingInstruction {
+ ProcessingInstruction {
+ element: CharacterData::new_inherited(ProcessingInstructionNodeTypeId, data, document),
+ target: target
+ }
+ }
+
+ pub fn new(target: DOMString, data: DOMString, document: AbstractDocument) -> AbstractNode {
+ let node = ProcessingInstruction::new_inherited(target, data, document);
+ Node::reflect_node(@mut node, document, ProcessingInstructionBinding::Wrap)
+ }
+}
+
+impl ProcessingInstruction {
+ pub fn Target(&self) -> DOMString {
+ self.target.clone()
+ }
+}