servo: Merge #19073 - Use encoding-rs instead of rust-encoding (from servo:encoding-rs); r=SimonSapin

Source-Repo: https://github.com/servo/servo
Source-Revision: 994ff4b66ee51bbfae431af0ca99497b38fb0e19

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : b21f5635f7f1e6160dab1dda00bd3d73ffa54262
This commit is contained in:
Simon Sapin 2017-11-01 06:37:54 -05:00
Родитель 8137c88d04
Коммит 6b4250586f
14 изменённых файлов: 147 добавлений и 229 удалений

112
servo/Cargo.lock сгенерированный
Просмотреть файл

@ -324,7 +324,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -788,62 +788,13 @@ dependencies = [
]
[[package]]
name = "encoding"
version = "0.2.33"
name = "encoding_rs"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "encoding-index-japanese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "encoding-index-korean"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "encoding-index-simpchinese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "encoding-index-singlebyte"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "encoding-index-tradchinese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "encoding_index_tests"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "energy-monitor"
version = "0.2.0"
@ -1284,7 +1235,7 @@ dependencies = [
"traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1317,12 +1268,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "idna"
version = "0.1.2"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-bidi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1734,7 +1685,7 @@ dependencies = [
"smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"string_cache 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.53.1 (git+https://github.com/servo/webrender)",
"xml5ever 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1965,7 +1916,7 @@ dependencies = [
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyfiledialogs 2.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.53.1 (git+https://github.com/servo/webrender)",
]
@ -2001,7 +1952,7 @@ dependencies = [
"servo_url 0.0.1",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2022,7 +1973,7 @@ dependencies = [
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_url 0.0.1",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.53.1 (git+https://github.com/servo/webrender)",
]
@ -2571,7 +2522,7 @@ dependencies = [
"devtools_traits 0.0.1",
"dom_struct 0.0.1",
"domobject_derive 0.0.1",
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2626,7 +2577,7 @@ dependencies = [
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyfiledialogs 2.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"utf-8 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.53.1 (git+https://github.com/servo/webrender)",
@ -2705,7 +2656,7 @@ dependencies = [
"servo_url 0.0.1",
"style_traits 0.0.1",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.53.1 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1",
]
@ -2901,7 +2852,7 @@ dependencies = [
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2945,7 +2896,7 @@ dependencies = [
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2999,7 +2950,7 @@ dependencies = [
"malloc_size_of_derive 0.0.1",
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_rand 0.0.1",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -3118,7 +3069,7 @@ dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible 0.0.1",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3376,7 +3327,7 @@ dependencies = [
[[package]]
name = "unicode-normalization"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -3412,11 +3363,10 @@ dependencies = [
[[package]]
name = "url"
version = "1.5.1"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"idna 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -3427,7 +3377,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3518,7 +3468,7 @@ dependencies = [
"script_traits 0.0.1",
"servo_config 0.0.1",
"servo_url 0.0.1",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webdriver 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -3623,7 +3573,7 @@ dependencies = [
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3771,13 +3721,7 @@ dependencies = [
"checksum dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07c4c7cc7b396419bc0a4d90371d0cee16cb5053b53647d287c0b728000c41fe"
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"
"checksum encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7"
"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
"checksum encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5215aabf22b83153be3ee44dfe3f940214541b2ce13d419c55e7a115c8c51a9"
"checksum energy-monitor 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe872d0664f1cc60db36349af245d892ee67d3c8f78055df0ebc43271fd4e05c"
"checksum energymon 0.3.0 (git+https://github.com/energymon/energymon-rust.git)" = "<none>"
"checksum energymon-builder 0.3.0 (git+https://github.com/energymon/energymon-sys.git)" = "<none>"
@ -3819,7 +3763,7 @@ dependencies = [
"checksum hyper-openssl 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "85a372eb692590b3fe014c196c30f9f52d4c42f58cd49dd94caeee1593c9cc37"
"checksum hyper_serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cbe43f514f80494e9329c9fc47d61b85b167d245685424637a0f4a409177e444"
"checksum ident_case 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c9826188e666f2ed92071d2dadef6edc430b11b158b5b2b3f4babbcc891eaaa"
"checksum idna 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2233d4940b1f19f0418c158509cd7396b8d70a5db5705ce410914dc8fa603b37"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum image 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e70634e5518ee89975b43c4bbd1667c4012c0313392aa2dfa2db5563c28e34c2"
"checksum immeta 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0b9260463a221bfe3f02100c56e2d14c050d5ffe7e44a43d0a1b2b1f2b523502"
"checksum inflate 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10ec05638adf7c5c788bc0cfa608cd479a13572beda20feb4898fe1d85d2c64b"
@ -3964,13 +3908,13 @@ dependencies = [
"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
"checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764"
"checksum unicode-bidi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a6a2c4e3710edd365cd7e78383153ed739fa31af19f9172f72d3575060f5a43a"
"checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff"
"checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f"
"checksum unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5430ae21ef212551680d0021fc7dbd936e8b268c5ea8fdae8814e0b2496d80f"
"checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91"
"checksum url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb819346883532a271eb626deb43c4a1bb4c4dd47c519bd78137c3e72a4fe27"
"checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2"
"checksum url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea"
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
"checksum utf-8 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f923c601c7ac48ef1d66f7d5b5b2d9a7ba9c51333ab75a3ddf8d0309185a56"

Просмотреть файл

@ -39,7 +39,7 @@ deny_public_fields = {path = "../deny_public_fields"}
devtools_traits = {path = "../devtools_traits"}
dom_struct = {path = "../dom_struct"}
domobject_derive = {path = "../domobject_derive"}
encoding = "0.2"
encoding_rs = "0.7"
euclid = "0.15"
fnv = "1.0"
gleam = "0.4"
@ -90,7 +90,7 @@ style_traits = {path = "../style_traits"}
swapper = "0.1"
time = "0.1.12"
unicode-segmentation = "1.1.0"
url = {version = "1.2", features = ["query_encoding"]}
url = "1.6"
utf-8 = "0.7"
uuid = {version = "0.5", features = ["v4"]}
xml5ever = {version = "0.11"}

Просмотреть файл

@ -46,7 +46,7 @@ use dom::bindings::root::{Dom, DomRoot};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::utils::WindowProxyHandler;
use dom::document::PendingRestyle;
use encoding::types::EncodingRef;
use encoding_rs::Encoding;
use euclid::{Transform2D, Transform3D, Point2D, Vector2D, Rect, TypedSize2D, ScaleFactor};
use euclid::Length as EuclidLength;
use html5ever::{Prefix, LocalName, Namespace, QualName};
@ -122,7 +122,7 @@ pub unsafe trait JSTraceable {
unsafe_no_jsmanaged_fields!(CSSError);
unsafe_no_jsmanaged_fields!(EncodingRef);
unsafe_no_jsmanaged_fields!(&'static Encoding);
unsafe_no_jsmanaged_fields!(Reflector);

Просмотреть файл

@ -90,8 +90,7 @@ use dom::webglcontextevent::WebGLContextEvent;
use dom::window::{ReflowReason, Window};
use dom::windowproxy::WindowProxy;
use dom_struct::dom_struct;
use encoding::EncodingRef;
use encoding::all::UTF_8;
use encoding_rs::{Encoding, UTF_8};
use euclid::Point2D;
use html5ever::{LocalName, Namespace, QualName};
use hyper::header::{Header, SetCookie};
@ -240,7 +239,7 @@ pub struct Document {
implementation: MutNullableDom<DOMImplementation>,
content_type: DOMString,
last_modified: Option<String>,
encoding: Cell<EncodingRef>,
encoding: Cell<&'static Encoding>,
has_browsing_context: bool,
is_html_document: bool,
activity: Cell<DocumentActivity>,
@ -576,11 +575,11 @@ impl Document {
}
}
pub fn encoding(&self) -> EncodingRef {
pub fn encoding(&self) -> &'static Encoding {
self.encoding.get()
}
pub fn set_encoding(&self, encoding: EncodingRef) {
pub fn set_encoding(&self, encoding: &'static Encoding) {
self.encoding.set(encoding);
}
@ -2828,34 +2827,7 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-document-characterset
fn CharacterSet(&self) -> DOMString {
DOMString::from(match self.encoding.get().name() {
"utf-8" => "UTF-8",
"ibm866" => "IBM866",
"iso-8859-2" => "ISO-8859-2",
"iso-8859-3" => "ISO-8859-3",
"iso-8859-4" => "ISO-8859-4",
"iso-8859-5" => "ISO-8859-5",
"iso-8859-6" => "ISO-8859-6",
"iso-8859-7" => "ISO-8859-7",
"iso-8859-8" => "ISO-8859-8",
"iso-8859-8-i" => "ISO-8859-8-I",
"iso-8859-10" => "ISO-8859-10",
"iso-8859-13" => "ISO-8859-13",
"iso-8859-14" => "ISO-8859-14",
"iso-8859-15" => "ISO-8859-15",
"iso-8859-16" => "ISO-8859-16",
"koi8-r" => "KOI8-R",
"koi8-u" => "KOI8-U",
"gbk" => "GBK",
"big5" => "Big5",
"euc-jp" => "EUC-JP",
"iso-2022-jp" => "ISO-2022-JP",
"shift_jis" => "Shift_JIS",
"euc-kr" => "EUC-KR",
"utf-16be" => "UTF-16BE",
"utf-16le" => "UTF-16LE",
name => name
})
DOMString::from(self.encoding.get().name())
}
// https://dom.spec.whatwg.org/#dom-document-charset

Просмотреть файл

@ -21,9 +21,7 @@ use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
use dom::progressevent::ProgressEvent;
use dom_struct::dom_struct;
use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, EncodingRef};
use encoding_rs::{Encoding, UTF_8};
use hyper::mime::{Attr, Mime};
use js::jsapi::Heap;
use js::jsapi::JSAutoCompartment;
@ -223,8 +221,8 @@ impl FileReader {
//https://w3c.github.io/FileAPI/#encoding-determination
// Steps 1 & 2 & 3
let mut encoding = blob_label.as_ref()
.map(|string| &**string)
.and_then(encoding_from_whatwg_label);
.map(|string| string.as_bytes())
.and_then(Encoding::for_label);
// Step 4 & 5
encoding = encoding.or_else(|| {
@ -232,16 +230,16 @@ impl FileReader {
resultmime.and_then(|Mime(_, _, ref parameters)| {
parameters.iter()
.find(|&&(ref k, _)| &Attr::Charset == k)
.and_then(|&(_, ref v)| encoding_from_whatwg_label(&v.to_string()))
.and_then(|&(_, ref v)| Encoding::for_label(v.as_str().as_bytes()))
})
});
// Step 6
let enc = encoding.unwrap_or(UTF_8 as EncodingRef);
let enc = encoding.unwrap_or(UTF_8);
let convert = blob_bytes;
// Step 7
let output = enc.decode(convert, DecoderTrap::Replace).unwrap();
let (output, _, _) = enc.decode(convert);
*result.borrow_mut() = Some(FileReaderResult::String(DOMString::from(output)));
}

Просмотреть файл

@ -42,9 +42,7 @@ use dom::node::{document_from_node, window_from_node};
use dom::validitystate::ValidationFlags;
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use encoding::EncodingRef;
use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label;
use encoding_rs::{Encoding, UTF_8};
use html5ever::{LocalName, Prefix};
use hyper::header::{Charset, ContentDisposition, ContentType, DispositionParam, DispositionType};
use hyper::method::Method;
@ -56,6 +54,8 @@ use std::cell::Cell;
use style::attr::AttrValue;
use style::str::split_html_space_chars;
use task_source::TaskSource;
use url::UrlQuery;
use url::form_urlencoded::Serializer;
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
pub struct GenerationId(u32);
@ -250,14 +250,15 @@ pub enum ResetFrom {
impl HTMLFormElement {
// https://html.spec.whatwg.org/multipage/#picking-an-encoding-for-the-form
fn pick_encoding(&self) -> EncodingRef {
fn pick_encoding(&self) -> &'static Encoding {
// Step 2
if self.upcast::<Element>().has_attribute(&local_name!("accept-charset")) {
// Substep 1
let input = self.upcast::<Element>().get_string_attribute(&local_name!("accept-charset"));
// Substep 2, 3, 4
let mut candidate_encodings = split_html_space_chars(&*input).filter_map(encoding_from_whatwg_label);
let mut candidate_encodings = split_html_space_chars(&*input)
.filter_map(|c| Encoding::for_label(c.as_bytes()));
// Substep 5, 6
return candidate_encodings.next().unwrap_or(UTF_8);
@ -276,7 +277,7 @@ impl HTMLFormElement {
let encoding = self.pick_encoding();
// Step 3
let charset = &*encoding.whatwg_name().unwrap();
let charset = encoding.name();
for entry in form_data.iter_mut() {
// Step 4, 5
@ -375,13 +376,11 @@ impl HTMLFormElement {
}
// https://html.spec.whatwg.org/multipage/#submit-mutate-action
fn mutate_action_url(&self, form_data: &mut Vec<FormDatum>, mut load_data: LoadData, encoding: EncodingRef) {
let charset = &*encoding.whatwg_name().unwrap();
fn mutate_action_url(&self, form_data: &mut Vec<FormDatum>, mut load_data: LoadData, encoding: &'static Encoding) {
let charset = encoding.name();
load_data.url
.as_mut_url()
.query_pairs_mut().clear()
.encoding_override(Some(self.pick_encoding()))
self.set_encoding_override(load_data.url.as_mut_url().query_pairs_mut())
.clear()
.extend_pairs(form_data.into_iter()
.map(|field| (field.name.clone(), field.replace_value(charset))));
@ -390,17 +389,15 @@ impl HTMLFormElement {
// https://html.spec.whatwg.org/multipage/#submit-body
fn submit_entity_body(&self, form_data: &mut Vec<FormDatum>, mut load_data: LoadData,
enctype: FormEncType, encoding: EncodingRef) {
enctype: FormEncType, encoding: &'static Encoding) {
let boundary = generate_boundary();
let bytes = match enctype {
FormEncType::UrlEncoded => {
let charset = &*encoding.whatwg_name().unwrap();
let charset = encoding.name();
load_data.headers.set(ContentType::form_url_encoded());
load_data.url
.as_mut_url()
.query_pairs_mut().clear()
.encoding_override(Some(self.pick_encoding()))
self.set_encoding_override(load_data.url.as_mut_url().query_pairs_mut())
.clear()
.extend_pairs(form_data.into_iter()
.map(|field| (field.name.clone(), field.replace_value(charset))));
@ -421,6 +418,13 @@ impl HTMLFormElement {
self.plan_to_navigate(load_data);
}
fn set_encoding_override<'a>(&self, mut serializer: Serializer<UrlQuery<'a>>)
-> Serializer<UrlQuery<'a>> {
let encoding = self.pick_encoding();
serializer.custom_encoding_override(move |s| encoding.encode(s).0);
serializer
}
/// [Planned navigation](https://html.spec.whatwg.org/multipage/#planned-navigation)
fn plan_to_navigate(&self, load_data: LoadData) {
let window = window_from_node(self);
@ -1109,12 +1113,12 @@ impl FormControlElementHelpers for Element {
// https://html.spec.whatwg.org/multipage/#multipart/form-data-encoding-algorithm
pub fn encode_multipart_form_data(form_data: &mut Vec<FormDatum>,
boundary: String, encoding: EncodingRef) -> Vec<u8> {
boundary: String, encoding: &'static Encoding) -> Vec<u8> {
// Step 1
let mut result = vec![];
// Step 2
let charset = &*encoding.whatwg_name().unwrap_or("UTF-8");
let charset = encoding.name();
// Step 3
for entry in form_data.iter_mut() {

Просмотреть файл

@ -23,8 +23,7 @@ use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
use dom::node::{document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, EncodingRef};
use encoding_rs::Encoding;
use html5ever::{LocalName, Prefix};
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
@ -147,7 +146,7 @@ struct ScriptContext {
kind: ExternalScriptKind,
/// The (fallback) character encoding argument to the "fetch a classic
/// script" algorithm.
character_encoding: EncodingRef,
character_encoding: &'static Encoding,
/// The response body received to date.
data: Vec<u8>,
/// The response metadata received to date.
@ -199,11 +198,11 @@ impl FetchResponseListener for ScriptContext {
// Step 6.
let encoding = metadata.charset
.and_then(|encoding| encoding_from_whatwg_label(&encoding))
.and_then(|encoding| Encoding::for_label(encoding.as_bytes()))
.unwrap_or(self.character_encoding);
// Step 7.
let source_text = encoding.decode(&self.data, DecoderTrap::Replace).unwrap();
let (source_text, _, _) = encoding.decode(&self.data);
ClassicScript::external(DOMString::from(source_text), metadata.final_url)
});
@ -232,7 +231,7 @@ fn fetch_a_classic_script(script: &HTMLScriptElement,
url: ServoUrl,
cors_setting: Option<CorsSettings>,
integrity_metadata: String,
character_encoding: EncodingRef) {
character_encoding: &'static Encoding) {
let doc = document_from_node(script);
// Step 1, 2.
@ -366,7 +365,7 @@ impl HTMLScriptElement {
// Step 14.
let encoding = element.get_attribute(&ns!(), &local_name!("charset"))
.and_then(|charset| encoding_from_whatwg_label(&charset.value()))
.and_then(|charset| Encoding::for_label(charset.value().as_bytes()))
.unwrap_or_else(|| doc.encoding());
// Step 15.

Просмотреть файл

@ -10,21 +10,20 @@ use dom::bindings::root::DomRoot;
use dom::bindings::str::{DOMString, USVString};
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, EncodingRef};
use encoding_rs::Encoding;
use js::jsapi::{JSContext, JSObject};
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
#[dom_struct]
pub struct TextDecoder {
reflector_: Reflector,
#[ignore_malloc_size_of = "Defined in rust-encoding"]
encoding: EncodingRef,
encoding: &'static Encoding,
fatal: bool,
}
impl TextDecoder {
fn new_inherited(encoding: EncodingRef, fatal: bool) -> TextDecoder {
fn new_inherited(encoding: &'static Encoding, fatal: bool) -> TextDecoder {
TextDecoder {
reflector_: Reflector::new(),
encoding: encoding,
@ -36,7 +35,7 @@ impl TextDecoder {
Err(Error::Range("The given encoding is not supported.".to_owned()))
}
pub fn new(global: &GlobalScope, encoding: EncodingRef, fatal: bool) -> DomRoot<TextDecoder> {
pub fn new(global: &GlobalScope, encoding: &'static Encoding, fatal: bool) -> DomRoot<TextDecoder> {
reflect_dom_object(Box::new(TextDecoder::new_inherited(encoding, fatal)),
global,
TextDecoderBinding::Wrap)
@ -47,19 +46,10 @@ impl TextDecoder {
label: DOMString,
options: &TextDecoderBinding::TextDecoderOptions)
-> Fallible<DomRoot<TextDecoder>> {
let encoding = match encoding_from_whatwg_label(&label) {
let encoding = match Encoding::for_label_no_replacement(label.as_bytes()) {
None => return TextDecoder::make_range_error(),
Some(enc) => enc
};
// The rust-encoding crate has WHATWG compatibility, so we are
// guaranteed to have a whatwg_name because we successfully got
// the encoding from encoding_from_whatwg_label.
// Use match + panic! instead of unwrap for better error message
match encoding.whatwg_name() {
None => panic!("Label {} fits valid encoding without valid name", label),
Some("replacement") => return TextDecoder::make_range_error(),
_ => ()
};
Ok(TextDecoder::new(global, encoding, options.fatal))
}
}
@ -68,7 +58,7 @@ impl TextDecoder {
impl TextDecoderMethods for TextDecoder {
// https://encoding.spec.whatwg.org/#dom-textdecoder-encoding
fn Encoding(&self) -> DOMString {
DOMString::from(self.encoding.whatwg_name().unwrap())
DOMString::from(self.encoding.name().to_ascii_lowercase())
}
// https://encoding.spec.whatwg.org/#dom-textdecoder-fatal
@ -93,15 +83,15 @@ impl TextDecoderMethods for TextDecoder {
}
};
let trap = if self.fatal {
DecoderTrap::Strict
let s = if self.fatal {
match self.encoding.decode_without_bom_handling_and_without_replacement(data.as_slice()) {
Some(s) => s,
None => return Err(Error::Type("Decoding failed".to_owned())),
}
} else {
DecoderTrap::Replace
let (s, _has_errors) = self.encoding.decode_without_bom_handling(data.as_slice());
s
};
match self.encoding.decode(data.as_slice(), trap) {
Ok(s) => Ok(USVString(s)),
Err(_) => Err(Error::Type("Decoding failed".to_owned())),
}
Ok(USVString(s.into_owned()))
}
}

Просмотреть файл

@ -15,7 +15,6 @@ use dom::bindings::weakref::MutableWeakRef;
use dom::globalscope::GlobalScope;
use dom::url::URL;
use dom_struct::dom_struct;
use encoding::types::EncodingRef;
use url::form_urlencoded;
// https://url.spec.whatwg.org/#interface-urlsearchparams
@ -140,17 +139,16 @@ impl URLSearchParamsMethods for URLSearchParams {
// https://url.spec.whatwg.org/#stringification-behavior
fn Stringifier(&self) -> DOMString {
DOMString::from(self.serialize(None))
DOMString::from(self.serialize_utf8())
}
}
impl URLSearchParams {
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
pub fn serialize(&self, encoding: Option<EncodingRef>) -> String {
pub fn serialize_utf8(&self) -> String {
let list = self.list.borrow();
form_urlencoded::Serializer::new(String::new())
.encoding_override(encoding)
.extend_pairs(&*list)
.finish()
}

Просмотреть файл

@ -36,9 +36,7 @@ use dom::workerglobalscope::WorkerGlobalScope;
use dom::xmlhttprequesteventtarget::XMLHttpRequestEventTarget;
use dom::xmlhttprequestupload::XMLHttpRequestUpload;
use dom_struct::dom_struct;
use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, EncoderTrap, Encoding, EncodingRef};
use encoding_rs::{Encoding, UTF_8};
use euclid::Length;
use html5ever::serialize;
use html5ever::serialize::SerializeOpts;
@ -66,6 +64,7 @@ use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
use std::default::Default;
use std::slice;
use std::str;
use std::sync::{Arc, Mutex};
use task_source::networking::NetworkingTaskSource;
@ -137,8 +136,7 @@ pub struct XMLHttpRequest {
response_headers: DomRefCell<Headers>,
#[ignore_malloc_size_of = "Defined in hyper"]
override_mime_type: DomRefCell<Option<Mime>>,
#[ignore_malloc_size_of = "Defined in rust-encoding"]
override_charset: DomRefCell<Option<EncodingRef>>,
override_charset: DomRefCell<Option<&'static Encoding>>,
// Associated concepts
#[ignore_malloc_size_of = "Defined in hyper"]
@ -726,7 +724,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
// Step 4
let value = override_mime.get_param(mime::Attr::Charset);
*self.override_charset.borrow_mut() = value.and_then(|value| {
encoding_from_whatwg_label(value)
Encoding::for_label(value.as_bytes())
});
Ok(())
}
@ -1085,7 +1083,9 @@ impl XMLHttpRequest {
// According to Simon, decode() should never return an error, so unwrap()ing
// the result should be fine. XXXManishearth have a closer look at this later
// Step 1, 2, 6
charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap()
let response = self.response.borrow();
let (text, _, _) = charset.decode(&response);
text.into_owned()
}
// https://xhr.spec.whatwg.org/#blob-response
@ -1164,8 +1164,22 @@ impl XMLHttpRequest {
return NullValue();
}
// Step 4
let json_text = UTF_8.decode(&bytes, DecoderTrap::Replace).unwrap();
let json_text: Vec<u16> = json_text.encode_utf16().collect();
fn decode_to_utf16(bytes: &[u8], encoding: &'static Encoding) -> Vec<u16> {
let mut decoder = encoding.new_decoder();
let capacity = decoder.max_utf16_buffer_length(bytes.len()).expect("Overflow");
let mut utf16 = Vec::with_capacity(capacity);
let extra = unsafe {
slice::from_raw_parts_mut(utf16.as_mut_ptr(), capacity)
};
let last = true;
let (_, read, written, _) = decoder.decode_to_utf16(bytes, extra, last);
assert!(read == bytes.len());
unsafe {
utf16.set_len(written)
}
utf16
}
let json_text = decode_to_utf16(&bytes, UTF_8);
// Step 5
rooted!(in(cx) let mut rval = UndefinedValue());
unsafe {
@ -1185,7 +1199,8 @@ impl XMLHttpRequest {
fn document_text_html(&self) -> DomRoot<Document> {
let charset = self.final_charset().unwrap_or(UTF_8);
let wr = self.global();
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
let response = self.response.borrow();
let (decoded, _, _) = charset.decode(&response);
let document = self.new_doc(IsHTMLDocument::HTMLDocument);
// TODO: Disable scripting while parsing
ServoParser::parse_html_document(
@ -1198,7 +1213,8 @@ impl XMLHttpRequest {
fn handle_xml(&self) -> DomRoot<Document> {
let charset = self.final_charset().unwrap_or(UTF_8);
let wr = self.global();
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
let response = self.response.borrow();
let (decoded, _, _) = charset.decode(&response);
let document = self.new_doc(IsHTMLDocument::NonHTMLDocument);
// TODO: Disable scripting while parsing
ServoParser::parse_xml_document(
@ -1307,7 +1323,7 @@ impl XMLHttpRequest {
Ok(())
}
fn final_charset(&self) -> Option<EncodingRef> {
fn final_charset(&self) -> Option<&'static Encoding> {
if self.override_charset.borrow().is_some() {
self.override_charset.borrow().clone()
} else {
@ -1315,7 +1331,7 @@ impl XMLHttpRequest {
Some(&ContentType(ref mime)) => {
let value = mime.get_param(mime::Attr::Charset);
value.and_then(|value|{
encoding_from_whatwg_label(value)
Encoding::for_label(value.as_bytes())
})
}
None => { None }
@ -1370,7 +1386,7 @@ impl Extractable for Blob {
impl Extractable for DOMString {
fn extract(&self) -> (Vec<u8>, Option<DOMString>) {
(UTF_8.encode(self, EncoderTrap::Replace).unwrap(),
(self.as_bytes().to_owned(),
Some(DOMString::from("text/plain;charset=UTF-8")))
}
}
@ -1378,16 +1394,14 @@ impl Extractable for DOMString {
impl Extractable for FormData {
fn extract(&self) -> (Vec<u8>, Option<DOMString>) {
let boundary = generate_boundary();
let bytes = encode_multipart_form_data(&mut self.datums(), boundary.clone(),
UTF_8 as EncodingRef);
let bytes = encode_multipart_form_data(&mut self.datums(), boundary.clone(), UTF_8);
(bytes, Some(DOMString::from(format!("multipart/form-data;boundary={}", boundary))))
}
}
impl Extractable for URLSearchParams {
fn extract(&self) -> (Vec<u8>, Option<DOMString>) {
// Default encoding is UTF-8.
(self.serialize(None).into_bytes(),
(self.serialize_utf8().into_bytes(),
Some(DOMString::from("application/x-www-form-urlencoded;charset=UTF-8")))
}
}

Просмотреть файл

@ -34,7 +34,7 @@ extern crate devtools_traits;
extern crate dom_struct;
#[macro_use]
extern crate domobject_derive;
extern crate encoding;
extern crate encoding_rs;
extern crate euclid;
extern crate fnv;
extern crate gleam;

Просмотреть файл

@ -13,8 +13,7 @@ use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
use dom::htmllinkelement::{RequestGenerationId, HTMLLinkElement};
use dom::node::{document_from_node, window_from_node};
use encoding::EncodingRef;
use encoding::all::UTF_8;
use encoding_rs::UTF_8;
use hyper::header::ContentType;
use hyper::mime::{Mime, TopLevel, SubLevel};
use hyper_serde::Serde;
@ -127,7 +126,7 @@ impl FetchResponseListener for StylesheetContext {
let data = if is_css { mem::replace(&mut self.data, vec![]) } else { vec![] };
// TODO: Get the actual value. http://dev.w3.org/csswg/css-syntax/#environment-encoding
let environment_encoding = UTF_8 as EncodingRef;
let environment_encoding = UTF_8;
let protocol_encoding_label = metadata.charset.as_ref().map(|s| &**s);
let final_url = metadata.final_url;

Просмотреть файл

@ -20,7 +20,7 @@ gecko = ["nsstring", "num_cpus",
"style_traits/gecko", "fallible/known_system_malloc"]
use_bindgen = ["bindgen", "regex", "toml"]
servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
"cssparser/serde", "encoding", "malloc_size_of/servo",
"cssparser/serde", "encoding_rs", "malloc_size_of/servo",
# FIXME: Uncomment when https://github.com/servo/servo/pull/16953 has landed:
#"arrayvec/use_union"
@ -36,7 +36,7 @@ bitflags = "1.0"
byteorder = "1.0"
cfg-if = "0.1.0"
cssparser = "0.22.0"
encoding = {version = "0.2", optional = true}
encoding_rs = {version = "0.7", optional = true}
euclid = "0.15"
fallible = { path = "../fallible" }
fnv = "1.0"

Просмотреть файл

@ -4,43 +4,45 @@
//! Parsing stylesheets from bytes (not `&str`).
extern crate encoding;
extern crate encoding_rs;
use context::QuirksMode;
use cssparser::{stylesheet_encoding, EncodingSupport};
use error_reporting::ParseErrorReporter;
use media_queries::MediaList;
use self::encoding::{EncodingRef, DecoderTrap};
use servo_arc::Arc;
use shared_lock::SharedRwLock;
use std::borrow::Cow;
use std::str;
use stylesheets::{Stylesheet, StylesheetLoader, Origin, UrlExtraData};
struct RustEncoding;
struct EncodingRs;
impl EncodingSupport for RustEncoding {
type Encoding = EncodingRef;
impl EncodingSupport for EncodingRs {
type Encoding = &'static encoding_rs::Encoding;
fn utf8() -> Self::Encoding {
encoding::all::UTF_8
encoding_rs::UTF_8
}
fn is_utf16_be_or_le(encoding: &Self::Encoding) -> bool {
matches!(encoding.name(), "utf-16be" | "utf-16le")
*encoding == encoding_rs::UTF_16LE ||
*encoding == encoding_rs::UTF_16BE
}
fn from_label(ascii_label: &[u8]) -> Option<Self::Encoding> {
str::from_utf8(ascii_label).ok().and_then(encoding::label::encoding_from_whatwg_label)
encoding_rs::Encoding::for_label(ascii_label)
}
}
fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>)
-> (String, EncodingRef) {
let fallback_encoding = stylesheet_encoding::<RustEncoding>(
fn decode_stylesheet_bytes<'a>(css: &'a [u8], protocol_encoding_label: Option<&str>,
environment_encoding: Option<&'static encoding_rs::Encoding>)
-> Cow<'a, str> {
let fallback_encoding = stylesheet_encoding::<EncodingRs>(
css, protocol_encoding_label.map(str::as_bytes), environment_encoding);
let (result, used_encoding) = encoding::decode(css, DecoderTrap::Replace, fallback_encoding);
(result.unwrap(), used_encoding)
let (result, _used_encoding, _) = fallback_encoding.decode(&css);
// FIXME record used encoding for environment encoding of @import
result
}
impl Stylesheet {
@ -52,7 +54,7 @@ impl Stylesheet {
pub fn from_bytes<R>(bytes: &[u8],
url_data: UrlExtraData,
protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>,
environment_encoding: Option<&'static encoding_rs::Encoding>,
origin: Origin,
media: MediaList,
shared_lock: SharedRwLock,
@ -62,8 +64,7 @@ impl Stylesheet {
-> Stylesheet
where R: ParseErrorReporter
{
let (string, _) = decode_stylesheet_bytes(
bytes, protocol_encoding_label, environment_encoding);
let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding);
Stylesheet::from_str(&string,
url_data,
origin,
@ -80,14 +81,13 @@ impl Stylesheet {
pub fn update_from_bytes<R>(existing: &Stylesheet,
bytes: &[u8],
protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>,
environment_encoding: Option<&'static encoding_rs::Encoding>,
url_data: UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: &R)
where R: ParseErrorReporter
{
let (string, _) = decode_stylesheet_bytes(
bytes, protocol_encoding_label, environment_encoding);
let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding);
Self::update_from_str(existing,
&string,
url_data,