diff options
Diffstat (limited to 'src/components/script')
-rw-r--r-- | src/components/script/dom/document.rs | 16 | ||||
-rw-r--r-- | src/components/script/dom/webidls/Document.webidl | 2 | ||||
-rw-r--r-- | src/components/script/html/hubbub_html_parser.rs | 7 |
3 files changed, 19 insertions, 6 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index b5d404ca1c2..84343959866 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -93,7 +93,8 @@ pub struct Document { implementation: Option<@mut DOMImplementation>, content_type: DOMString, url: Url, - quirks_mode: QuirksMode + quirks_mode: QuirksMode, + encoding_name: DOMString, } impl Document { @@ -140,7 +141,9 @@ impl Document { Some(_url) => _url }, // http://dom.spec.whatwg.org/#concept-document-quirks - quirks_mode: NoQuirks + quirks_mode: NoQuirks, + // http://dom.spec.whatwg.org/#concept-document-encoding + encoding_name: ~"utf-8", } } @@ -207,6 +210,15 @@ impl Document { self.quirks_mode = mode; } + // http://dom.spec.whatwg.org/#dom-document-characterset + pub fn CharacterSet(&self) -> DOMString { + self.encoding_name.to_ascii_lower() + } + + pub fn set_encoding_name(&mut self, name: DOMString) { + self.encoding_name = name; + } + // http://dom.spec.whatwg.org/#dom-document-content_type pub fn ContentType(&self) -> DOMString { self.content_type.clone() diff --git a/src/components/script/dom/webidls/Document.webidl b/src/components/script/dom/webidls/Document.webidl index 4fa78a479b1..975fac355e2 100644 --- a/src/components/script/dom/webidls/Document.webidl +++ b/src/components/script/dom/webidls/Document.webidl @@ -30,7 +30,7 @@ interface Document : Node { readonly attribute DOMString documentURI; // readonly attribute DOMString origin; readonly attribute DOMString compatMode; - // readonly attribute DOMString characterSet; + readonly attribute DOMString characterSet; readonly attribute DOMString contentType; readonly attribute DocumentType? doctype; diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index c9817dbd6ff..09956f6a6ef 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -443,12 +443,13 @@ pub fn parse_html(cx: *JSContext, add_attributes: |_node, _attributes| { debug!("add attributes"); }, - set_quirks_mode: |_mode| { + set_quirks_mode: |mode| { debug!("set quirks mode"); - document.mut_document().set_quirks_mode(_mode); + document.mut_document().set_quirks_mode(mode); }, - encoding_change: |_encname| { + encoding_change: |encname| { debug!("encoding change"); + document.mut_document().set_encoding_name(encname); }, complete_script: |script| { unsafe { |