mirror of
https://github.com/servo/servo.git
synced 2025-06-27 18:43:40 +01:00
auto merge of #1377 : SimonSapin/servo/encoding, r=kmcallister
Depends on https://github.com/mozilla-servo/rust-cssparser/pull/33 being merged. Also (unrelated) pass around a base URL for stylesheets. Adds a new dependency: Upstream: https://github.com/lifthrasiir/rust-encoding Servo’s fork: https://github.com/mozilla-servo/rust-encoding As of this writing, upstream’s master branch targets Rust 0.8, and its rust-0.9-pre branch targets Rust master. Servo uses a Rust version in-between those. I pushed a rust-servo branch to our fork that backports from rust-0.9-pre, and also included some changes that have yet to be merged in upstream pull requests.
This commit is contained in:
commit
45c092cea4
13 changed files with 80 additions and 6861 deletions
|
@ -8,8 +8,10 @@ use std::cell::Cell;
|
|||
use std::comm;
|
||||
use std::comm::Port;
|
||||
use std::task;
|
||||
use encoding::EncodingRef;
|
||||
use encoding::all::UTF_8;
|
||||
use style::Stylesheet;
|
||||
use servo_net::resource_task::{Load, ProgressMsg, Payload, Done, ResourceTask};
|
||||
use servo_net::resource_task::{Load, LoadResponse, ProgressMsg, Payload, Done, ResourceTask};
|
||||
use extra::url::Url;
|
||||
|
||||
/// Where a style sheet comes from.
|
||||
|
@ -23,6 +25,9 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
|
|||
-> Port<Stylesheet> {
|
||||
let (result_port, result_chan) = comm::stream();
|
||||
|
||||
// TODO: Get the actual value. http://dev.w3.org/csswg/css-syntax/#environment-encoding
|
||||
let environment_encoding = UTF_8 as EncodingRef;
|
||||
|
||||
let provenance_cell = Cell::new(provenance);
|
||||
do task::spawn {
|
||||
// TODO: CSS parsing should take a base URL.
|
||||
|
@ -38,12 +43,16 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
|
|||
debug!("cssparse: loading style sheet at {:s}", url.to_str());
|
||||
let (input_port, input_chan) = comm::stream();
|
||||
resource_task.send(Load(url, input_chan));
|
||||
Stylesheet::from_iter(ProgressMsgPortIterator {
|
||||
progress_port: input_port.recv().progress_port
|
||||
})
|
||||
let LoadResponse { metadata: metadata, progress_port: progress_port }
|
||||
= input_port.recv();
|
||||
let protocol_encoding_label = metadata.charset.as_ref().map(|s| s.as_slice());
|
||||
let iter = ProgressMsgPortIterator { progress_port: progress_port };
|
||||
Stylesheet::from_bytes_iter(
|
||||
iter, metadata.final_url,
|
||||
protocol_encoding_label, Some(environment_encoding))
|
||||
}
|
||||
InlineProvenance(_, data) => {
|
||||
Stylesheet::from_str(data)
|
||||
InlineProvenance(base_url, data) => {
|
||||
Stylesheet::from_str(data, base_url, environment_encoding)
|
||||
}
|
||||
};
|
||||
result_chan.send(sheet);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue