aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/html
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2013-12-17 09:04:28 -0800
committerbors-servo <release+servo@mozilla.com>2013-12-17 09:04:28 -0800
commit45c092cea45bc6ece8cfd9b891617385ac2060b3 (patch)
tree5de5d1761d46bca8454802e153879620650be4bf /src/components/script/html
parentad7f3a95d4c3e22273e02bee3adc98286090a3a2 (diff)
parentc4c332b234ba907da43b7c2b9b320d7d06a09807 (diff)
downloadservo-45c092cea45bc6ece8cfd9b891617385ac2060b3.tar.gz
servo-45c092cea45bc6ece8cfd9b891617385ac2060b3.zip
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.
Diffstat (limited to 'src/components/script/html')
-rw-r--r--src/components/script/html/cssparse.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/components/script/html/cssparse.rs b/src/components/script/html/cssparse.rs
index ade3b58ed69..0ba1aadbe03 100644
--- a/src/components/script/html/cssparse.rs
+++ b/src/components/script/html/cssparse.rs
@@ -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);