aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-04-17 22:04:07 -0400
committerbors-servo <release+servo@mozilla.com>2014-04-17 22:04:07 -0400
commit4379809e88c1696988c51c0cb2d50c2c4ebac90c (patch)
treefb7545fdff2c7154cf752d40d5cde9bab1f85d47 /src
parent0b1c8bf8d6a628c9483e94f048d1ff95e65d5da8 (diff)
parent8bfb5f8b6f9170d79f6dc5339bafdad1f0037f1b (diff)
downloadservo-4379809e88c1696988c51c0cb2d50c2c4ebac90c.tar.gz
servo-4379809e88c1696988c51c0cb2d50c2c4ebac90c.zip
auto merge of #2152 : jsanders/servo/fix-inline-css-resource-task-failure, r=jdm
Fixes #2121 I thought this would be better than passing an `Option<ResourceTask>` to `parse_css` because it avoids having to handle the potential failure at runtime when unwrapping. No test included, but the error was reproducible by running content/test_getBoundingClientRect.html, and this fixes it. Glad to find a way to add an explicit test if need be.
Diffstat (limited to 'src')
-rw-r--r--src/components/script/html/cssparse.rs16
-rw-r--r--src/components/script/html/hubbub_html_parser.rs4
2 files changed, 8 insertions, 12 deletions
diff --git a/src/components/script/html/cssparse.rs b/src/components/script/html/cssparse.rs
index b538676edac..1140eedca0b 100644
--- a/src/components/script/html/cssparse.rs
+++ b/src/components/script/html/cssparse.rs
@@ -14,23 +14,21 @@ use url::Url;
/// Where a style sheet comes from.
pub enum StylesheetProvenance {
- UrlProvenance(Url),
+ UrlProvenance(Url, ResourceTask),
InlineProvenance(Url, ~str),
}
// Parses the style data and returns the stylesheet
pub fn parse_inline_css(url: Url, data: ~str) -> Stylesheet {
- let resource_task = ResourceTask(); // Resource task is not used for inline parsing
- parse_css(InlineProvenance(url, data), resource_task)
+ parse_css(InlineProvenance(url, data))
}
-fn parse_css(provenance: StylesheetProvenance,
- resource_task: ResourceTask) -> Stylesheet {
+fn parse_css(provenance: StylesheetProvenance) -> Stylesheet {
// TODO: Get the actual value. http://dev.w3.org/csswg/css-syntax/#environment-encoding
let environment_encoding = UTF_8 as EncodingRef;
match provenance {
- UrlProvenance(url) => {
+ UrlProvenance(url, resource_task) => {
debug!("cssparse: loading style sheet at {:s}", url.to_str());
let (input_chan, input_port) = channel();
resource_task.send(Load(url, input_chan));
@@ -50,13 +48,11 @@ fn parse_css(provenance: StylesheetProvenance,
}
}
-pub fn spawn_css_parser(provenance: StylesheetProvenance,
- resource_task: ResourceTask)
- -> Receiver<Stylesheet> {
+pub fn spawn_css_parser(provenance: StylesheetProvenance) -> Receiver<Stylesheet> {
let (result_chan, result_port) = channel();
spawn_named("cssparser", proc() {
- result_chan.send(parse_css(provenance, resource_task));
+ result_chan.send(parse_css(provenance));
});
return result_port;
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs
index b9dd26311ff..5e4ef64e0f6 100644
--- a/src/components/script/html/hubbub_html_parser.rs
+++ b/src/components/script/html/hubbub_html_parser.rs
@@ -111,7 +111,7 @@ fn css_link_listener(to_parent: Sender<HtmlDiscoveryMessage>,
loop {
match from_parent.recv_opt() {
Some(CSSTaskNewFile(provenance)) => {
- result_vec.push(spawn_css_parser(provenance, resource_task.clone()));
+ result_vec.push(spawn_css_parser(provenance));
}
Some(CSSTaskExit) | None => {
break;
@@ -357,7 +357,7 @@ pub fn parse_html(page: &Page,
}) => {
debug!("found CSS stylesheet: {:s}", href.get().value_ref());
let url = parse_url(href.get().value_ref(), Some(url2.clone()));
- css_chan2.send(CSSTaskNewFile(UrlProvenance(url)));
+ css_chan2.send(CSSTaskNewFile(UrlProvenance(url, resource_task.clone())));
}
_ => {}
}