Skip to content

Commit

Permalink
Privatize ProcessingInstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
ttaubert committed Oct 13, 2014
1 parent ad6649d commit d0addd3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/script/dom/htmlserializer.rs
Expand Up @@ -93,9 +93,9 @@ fn serialize_text(text: JSRef<Text>, html: &mut String) {
fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInstruction>,
html: &mut String) {
html.push_str("<?");
html.push_str(processing_instruction.target.as_slice());
html.push_str(processing_instruction.target().as_slice());
html.push_char(' ');
html.push_str(processing_instruction.characterdata.data().as_slice());
html.push_str(processing_instruction.characterdata().data().as_slice());
html.push_str("?>");
}

Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/node.rs
Expand Up @@ -1496,8 +1496,8 @@ impl Node {
},
ProcessingInstructionNodeTypeId => {
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
let pi = ProcessingInstruction::new(pi.target.clone(),
pi.characterdata.data().clone(), *document);
let pi = ProcessingInstruction::new(pi.target().clone(),
pi.characterdata().data().clone(), *document);
NodeCast::from_temporary(pi)
},
}.root();
Expand Down Expand Up @@ -1974,8 +1974,8 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
fn is_equal_processinginstruction(node: JSRef<Node>, other: JSRef<Node>) -> bool {
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
let other_pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(other).unwrap();
(pi.target == other_pi.target) &&
(*pi.characterdata.data() == *other_pi.characterdata.data())
(*pi.target() == *other_pi.target()) &&
(*pi.characterdata().data() == *other_pi.characterdata().data())
}
fn is_equal_characterdata(node: JSRef<Node>, other: JSRef<Node>) -> bool {
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(node).unwrap();
Expand Down
13 changes: 11 additions & 2 deletions components/script/dom/processinginstruction.rs
Expand Up @@ -16,9 +16,10 @@ use servo_util::str::DOMString;
/// An HTML processing instruction node.
#[jstraceable]
#[must_root]
#[privatize]
pub struct ProcessingInstruction {
pub characterdata: CharacterData,
pub target: DOMString,
characterdata: CharacterData,
target: DOMString,
}

impl ProcessingInstructionDerived for EventTarget {
Expand All @@ -39,6 +40,14 @@ impl ProcessingInstruction {
Node::reflect_node(box ProcessingInstruction::new_inherited(target, data, document),
document, ProcessingInstructionBinding::Wrap)
}

pub fn characterdata<'a>(&'a self) -> &'a CharacterData {
&self.characterdata
}

pub fn target<'a>(&'a self) -> &'a DOMString {
&self.target
}
}

impl<'a> ProcessingInstructionMethods for JSRef<'a, ProcessingInstruction> {
Expand Down

0 comments on commit d0addd3

Please sign in to comment.