Skip to content

Commit

Permalink
Associate ResourceTask with UrlProvenance
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanders committed Apr 18, 2014
1 parent 0b1c8bf commit 8bfb5f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/components/script/html/cssparse.rs
Expand Up @@ -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));
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/components/script/html/hubbub_html_parser.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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())));
}
_ => {}
}
Expand Down

5 comments on commit 8bfb5f8

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at jsanders@8bfb5f8

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jsanders/servo/fix-inline-css-resource-task-failure = 8bfb5f8 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsanders/servo/fix-inline-css-resource-task-failure = 8bfb5f8 merged ok, testing candidate = 4379809

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4379809

Please sign in to comment.