mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +01:00
Auto merge of #9036 - KiChjang:document-charset, r=Ms2ger
Implement Document charset Rebase of #7966. Fixes #7718. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9036) <!-- Reviewable:end -->
This commit is contained in:
commit
df087cc6cf
9 changed files with 36 additions and 270 deletions
|
@ -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
|
||||
|
|
|
@ -20,6 +20,7 @@ interface Document : Node {
|
|||
readonly attribute DOMString documentURI;
|
||||
readonly attribute DOMString compatMode;
|
||||
readonly attribute DOMString characterSet;
|
||||
readonly attribute DOMString charset; // legacy alias of .characterSet
|
||||
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
|
||||
[Constant]
|
||||
readonly attribute DOMString contentType;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue