diff options
author | vectorijk <jiangkai@gmail.com> | 2015-10-10 18:04:10 -0700 |
---|---|---|
committer | Keith Yeung <kungfukeith11@gmail.com> | 2015-12-21 03:17:52 -0800 |
commit | c559270b83a446e2059c6a8ae39dc3f2734cfc54 (patch) | |
tree | f7b8d282d879254d563a818e69fbce9c0477b203 /components/script/dom/document.rs | |
parent | 5b91daa92378d3b9fe80b2fc8f8072085d4949b3 (diff) | |
download | servo-c559270b83a446e2059c6a8ae39dc3f2734cfc54.tar.gz servo-c559270b83a446e2059c6a8ae39dc3f2734cfc54.zip |
implement document charset
- pre-compute the adjusted encoding name
Fix build errors and update test expectations
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 79b3dd41f85..b2033a2a92e 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -379,7 +379,35 @@ impl Document { } pub fn set_encoding_name(&self, name: DOMString) { - *self.encoding_name.borrow_mut() = name; + *self.encoding_name.borrow_mut() = DOMString::from( + match name.as_ref() { + "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 + }); } pub fn content_changed(&self, node: &Node, damage: NodeDamage) { @@ -1719,9 +1747,14 @@ impl DocumentMethods for Document { self.encoding_name.borrow().clone() } + // https://dom.spec.whatwg.org/#dom-document-charset + fn Charset(&self) -> DOMString { + self.CharacterSet() + } + // https://dom.spec.whatwg.org/#dom-document-inputencoding fn InputEncoding(&self) -> DOMString { - self.encoding_name.borrow().clone() + self.CharacterSet() } // https://dom.spec.whatwg.org/#dom-document-content_type |