Auto merge of #17457 - cynicaldevil:trim-parse-node-data, r=nox

Remove target and data fields from parse_node_data

<!-- Please describe your changes on the following line: -->
`parse_node_data` does not need to store `data` and `target`, they can automatically be passed as parameters to the parser operation (`ParseOperation::CreatePI`) that we already create to be processed.

Also, this frees up `process_op` from depending on the sink's `parse_node_data` field, which will later allow for the sink to exist on the parser thread separately.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17457)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-22 09:09:07 -07:00 committed by GitHub
commit 0fce761bb3

View file

@ -138,8 +138,6 @@ pub struct ParseNode {
#[derive(JSTraceable, HeapSizeOf)]
struct ParseNodeData {
target: Option<String>,
data: Option<String>,
contents: Option<ParseNode>,
is_integration_point: bool,
}
@ -147,8 +145,6 @@ struct ParseNodeData {
impl Default for ParseNodeData {
fn default() -> ParseNodeData {
ParseNodeData {
target: None,
data: None,
contents: None,
is_integration_point: false,
}
@ -169,7 +165,7 @@ enum ParseOperation {
MarkScriptAlreadyStarted(ParseNodeID),
ReparentChildren(ParseNodeID, ParseNodeID),
AssociateWithForm(ParseNodeID, ParseNodeID),
CreatePI(ParseNodeID),
CreatePI(ParseNodeID, StrTendril, StrTendril),
Pop(ParseNodeID),
}
@ -329,15 +325,11 @@ impl Sink {
ParseOperation::Pop(node) => {
vtable_for(self.get_node(&node)).pop();
}
ParseOperation::CreatePI(node) => {
let pi;
{
let data = self.get_parse_node_data(&node);
pi = ProcessingInstruction::new(
DOMString::from(data.target.clone().unwrap()),
DOMString::from(data.data.clone().unwrap()),
ParseOperation::CreatePI(node, target, data) => {
let pi = ProcessingInstruction::new(
DOMString::from(String::from(target)),
DOMString::from(String::from(data)),
document);
}
self.insert_node(node, JS::from_ref(pi.upcast()));
}
}
@ -411,12 +403,7 @@ impl TreeSink for Sink {
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> ParseNode {
let node = self.new_parse_node();
{
let mut node_data = self.get_parse_node_data_mut(&node.id);
node_data.target = Some(String::from(target));
node_data.data = Some(String::from(data));
}
self.process_operation(ParseOperation::CreatePI(node.id));
self.process_operation(ParseOperation::CreatePI(node.id, target, data));
node
}