diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2017-10-31 19:06:34 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2017-11-01 10:16:11 +0100 |
commit | a3971eb686503641a0e9cc64f4844a6abdd5cda1 (patch) | |
tree | f443a6e5182bfb8c2b09afae3bbb95c4df3a7f0e /components/script/dom/document.rs | |
parent | 3c36a36cc942a6cce52d4575ad6c26bbde6e4bd7 (diff) | |
download | servo-a3971eb686503641a0e9cc64f4844a6abdd5cda1.tar.gz servo-a3971eb686503641a0e9cc64f4844a6abdd5cda1.zip |
Replace rust-encoding with encoding-rs
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index bf7d82bf0f8..0cb0bf2def5 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -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 |