diff options
author | Bruno de Oliveira Abinader <bruno.d@partner.samsung.com> | 2014-02-05 11:14:47 -0400 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno.d@partner.samsung.com> | 2014-02-06 14:41:55 -0400 |
commit | aa4b5bb9482dbaaca9b76e7c9e54d5654ba22007 (patch) | |
tree | cd10cb6d641e4b89151dce05a7b82733a63e15af /src/components/script/dom/htmlserializer.rs | |
parent | 5a7d22c43775264359b8ddea8f60d237f5715593 (diff) | |
download | servo-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/htmlserializer.rs')
-rw-r--r-- | src/components/script/dom/htmlserializer.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/components/script/dom/htmlserializer.rs b/src/components/script/dom/htmlserializer.rs index 8dbedcb2679..260fa437154 100644 --- a/src/components/script/dom/htmlserializer.rs +++ b/src/components/script/dom/htmlserializer.rs @@ -5,7 +5,9 @@ use servo_util::namespace; use dom::attr::Attr; use dom::node::NodeIterator; -use dom::node::{DoctypeNodeTypeId, DocumentFragmentNodeTypeId, CommentNodeTypeId, DocumentNodeTypeId, ElementNodeTypeId, TextNodeTypeId, AbstractNode}; +use dom::node::{DoctypeNodeTypeId, DocumentFragmentNodeTypeId, CommentNodeTypeId}; +use dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId}; +use dom::node::{TextNodeTypeId, AbstractNode}; pub fn serialize(iterator: &mut NodeIterator) -> ~str { let mut html = ~""; @@ -29,6 +31,9 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str { DoctypeNodeTypeId => { serialize_doctype(node) } + ProcessingInstructionNodeTypeId => { + serialize_processing_instruction(node) + } DocumentFragmentNodeTypeId => { ~"" } @@ -70,6 +75,12 @@ fn serialize_text(node: AbstractNode) -> ~str { }) } +fn serialize_processing_instruction(node: AbstractNode) -> ~str { + node.with_imm_processing_instruction(|processing_instruction| { + ~"<?" + processing_instruction.target + " " + processing_instruction.element.data + "?>" + }) +} + fn serialize_doctype(node: AbstractNode) -> ~str { node.with_imm_doctype(|doctype| { ~"<!DOCTYPE" + doctype.name + ">" |