Use a Cell for HTMLScriptElement::block_character_encoding.

This commit is contained in:
Ms2ger 2016-03-18 16:38:17 +01:00
parent 89b8499df8
commit f1f53468a0

View file

@ -70,7 +70,7 @@ pub struct HTMLScriptElement {
#[ignore_heap_size_of = "Defined in rust-encoding"]
/// https://html.spec.whatwg.org/multipage/#concept-script-encoding
block_character_encoding: DOMRefCell<Option<EncodingRef>>,
block_character_encoding: Cell<Option<EncodingRef>>,
}
impl HTMLScriptElement {
@ -85,7 +85,7 @@ impl HTMLScriptElement {
ready_to_be_parser_executed: Cell::new(false),
parser_document: JS::from_ref(document),
load: DOMRefCell::new(None),
block_character_encoding: DOMRefCell::new(None),
block_character_encoding: Cell::new(None),
}
}
@ -247,7 +247,7 @@ impl HTMLScriptElement {
// Step 13.
if let Some(ref charset) = element.get_attribute(&ns!(), &atom!("charset")) {
if let Some(encodingRef) = encoding_from_whatwg_label(&charset.Value()) {
*self.block_character_encoding.borrow_mut() = Some(encodingRef);
self.block_character_encoding.set(Some(encodingRef));
}
}
@ -394,7 +394,7 @@ impl HTMLScriptElement {
let encoding = metadata.charset
.and_then(|encoding| encoding_from_whatwg_label(&encoding))
.or_else(|| *self.block_character_encoding.borrow())
.or_else(|| self.block_character_encoding.get())
.unwrap_or_else(|| self.parser_document.encoding());
(DOMString::from(encoding.decode(&*bytes, DecoderTrap::Replace).unwrap()),