auto merge of #609 : metajack/servo/broken-css, r=pcwalton

The fix for #606 broke all inline CSS, and this fixes it correctly.
This commit is contained in:
bors-servo 2013-07-19 18:12:22 -07:00
commit 841b91f1b6
4 changed files with 29 additions and 24 deletions

View file

@ -410,11 +410,12 @@ impl<'self, View> AbstractNode<View> {
impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> {
pub fn next(&mut self) -> Option<AbstractNode<View>> {
let node = self.current_node;
self.current_node = match self.current_node {
None => None,
Some(node) => node.next_sibling(),
};
self.current_node
node
}
}

View file

@ -274,6 +274,7 @@ pub fn parse_html(url: Url,
debug!("created parser");
parser.set_document_node(unsafe { root.to_hubbub_node() });
parser.enable_scripting(true);
parser.enable_styling(true);
let (css_chan2, css_chan3, js_chan2) = (css_chan.clone(), css_chan.clone(), js_chan.clone());
parser.set_tree_handler(~hubbub::TreeHandler {
@ -376,26 +377,8 @@ pub fn parse_html(url: Url,
Node::as_abstract_node(~Text::new(data)).to_hubbub_node()
}
},
ref_node: |_| { debug!("ref node"); },
unref_node: |node| {
// check for the end of a <style> so we can submit all the text to the parser.
unsafe {
let node: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(node);
if node.is_style_element() {
let url = url::from_str("http://example.com/"); // FIXME
let url_cell = Cell::new(url);
let mut data = ~[];
for node.children().advance |child| {
do child.with_imm_text() |text| {
data.push(text.parent.data.to_str()); // FIXME: Bad copy.
}
}
let provenance = InlineProvenance(result::unwrap(url_cell.take()), data.concat());
css_chan3.send(CSSTaskNewFile(provenance));
}
}
},
ref_node: |_| {},
unref_node: |_| {},
append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| {
unsafe {
debug!("append child %x %x", cast::transmute(parent), cast::transmute(child));
@ -464,7 +447,28 @@ pub fn parse_html(url: Url,
}
complete_script(script, url3.clone(), js_chan2.clone());
debug!("complete script");
}
},
complete_style: |style| {
// We've reached the end of a <style> so we can submit all the text to the parser.
unsafe {
let style: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(style);
let url = url::from_str("http://example.com/"); // FIXME
let url_cell = Cell::new(url);
let mut data = ~[];
debug!("iterating over children %?", style.first_child());
for style.children().advance |child| {
debug!("child = %?", child);
do child.with_imm_text() |text| {
data.push(text.parent.data.to_str()); // FIXME: Bad copy.
}
}
debug!("data = %?", data);
let provenance = InlineProvenance(result::unwrap(url_cell.take()), data.concat());
css_chan3.send(CSSTaskNewFile(provenance));
}
},
});
debug!("set tree handler");

@ -1 +1 @@
Subproject commit 611df70c7ac8172323828be1107c9df826d87a0d
Subproject commit dfcdbc7562edb58672438f59ccfa8687cdd47e31

@ -1 +1 @@
Subproject commit 09a6c29e0a9432d67eeb583324c17766aa1155e3
Subproject commit 077de218a9c64608c60c536ef1e87de461852015