mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Replace rust-encoding with encoding-rs
This commit is contained in:
parent
3c36a36cc9
commit
a3971eb686
25 changed files with 95 additions and 462 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue