mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
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:
commit
841b91f1b6
4 changed files with 29 additions and 24 deletions
|
@ -410,11 +410,12 @@ impl<'self, View> AbstractNode<View> {
|
||||||
|
|
||||||
impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> {
|
impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> {
|
||||||
pub fn next(&mut self) -> Option<AbstractNode<View>> {
|
pub fn next(&mut self) -> Option<AbstractNode<View>> {
|
||||||
|
let node = self.current_node;
|
||||||
self.current_node = match self.current_node {
|
self.current_node = match self.current_node {
|
||||||
None => None,
|
None => None,
|
||||||
Some(node) => node.next_sibling(),
|
Some(node) => node.next_sibling(),
|
||||||
};
|
};
|
||||||
self.current_node
|
node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,7 @@ pub fn parse_html(url: Url,
|
||||||
debug!("created parser");
|
debug!("created parser");
|
||||||
parser.set_document_node(unsafe { root.to_hubbub_node() });
|
parser.set_document_node(unsafe { root.to_hubbub_node() });
|
||||||
parser.enable_scripting(true);
|
parser.enable_scripting(true);
|
||||||
|
parser.enable_styling(true);
|
||||||
|
|
||||||
let (css_chan2, css_chan3, js_chan2) = (css_chan.clone(), css_chan.clone(), js_chan.clone());
|
let (css_chan2, css_chan3, js_chan2) = (css_chan.clone(), css_chan.clone(), js_chan.clone());
|
||||||
parser.set_tree_handler(~hubbub::TreeHandler {
|
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()
|
Node::as_abstract_node(~Text::new(data)).to_hubbub_node()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ref_node: |_| { debug!("ref node"); },
|
ref_node: |_| {},
|
||||||
unref_node: |node| {
|
unref_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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| {
|
append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("append child %x %x", cast::transmute(parent), cast::transmute(child));
|
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());
|
complete_script(script, url3.clone(), js_chan2.clone());
|
||||||
debug!("complete script");
|
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");
|
debug!("set tree handler");
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 611df70c7ac8172323828be1107c9df826d87a0d
|
Subproject commit dfcdbc7562edb58672438f59ccfa8687cdd47e31
|
|
@ -1 +1 @@
|
||||||
Subproject commit 09a6c29e0a9432d67eeb583324c17766aa1155e3
|
Subproject commit 077de218a9c64608c60c536ef1e87de461852015
|
Loading…
Add table
Add a link
Reference in a new issue