aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/document.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-06-10 17:48:42 +0200
committerMs2ger <ms2ger@gmail.com>2014-06-11 19:51:08 +0200
commit23a6b6823ba844b97dba7bf29f1c9ea31ba27130 (patch)
tree7221c0dabd87f6bdccf32c4b3bec20ab0d173aa5 /src/components/script/dom/document.rs
parente9b64dc361db2b068a0079e599ad0725c2eb8a0c (diff)
downloadservo-23a6b6823ba844b97dba7bf29f1c9ea31ba27130.tar.gz
servo-23a6b6823ba844b97dba7bf29f1c9ea31ba27130.zip
Use internal mutability for Document::{quirks_mode, encoding_name}.
Diffstat (limited to 'src/components/script/dom/document.rs')
-rw-r--r--src/components/script/dom/document.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index 87ca5c6c4c1..13e891ee5cc 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -49,7 +49,7 @@ use servo_util::str::{DOMString, null_str_as_empty_ref};
use collections::hashmap::HashMap;
use js::jsapi::JSContext;
use std::ascii::StrAsciiExt;
-use std::cell::Cell;
+use std::cell::{Cell, RefCell};
use url::{Url, from_str};
#[deriving(Eq,Encodable)]
@@ -66,10 +66,10 @@ pub struct Document {
pub idmap: HashMap<DOMString, Vec<JS<Element>>>,
pub implementation: Cell<Option<JS<DOMImplementation>>>,
pub content_type: DOMString,
- pub encoding_name: DOMString,
+ pub encoding_name: Untraceable<RefCell<DOMString>>,
pub is_html_document: bool,
pub url: Untraceable<Url>,
- pub quirks_mode: Untraceable<QuirksMode>,
+ pub quirks_mode: Untraceable<Cell<QuirksMode>>,
}
impl DocumentDerived for EventTarget {
@@ -81,8 +81,8 @@ impl DocumentDerived for EventTarget {
pub trait DocumentHelpers {
fn url<'a>(&'a self) -> &'a Url;
fn quirks_mode(&self) -> QuirksMode;
- fn set_quirks_mode(&mut self, mode: QuirksMode);
- fn set_encoding_name(&mut self, name: DOMString);
+ fn set_quirks_mode(&self, mode: QuirksMode);
+ fn set_encoding_name(&self, name: DOMString);
fn content_changed(&self);
fn damage_and_reflow(&self, damage: DocumentDamageLevel);
fn wait_until_safe_to_modify_dom(&self);
@@ -97,15 +97,15 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
}
fn quirks_mode(&self) -> QuirksMode {
- *self.quirks_mode
+ self.quirks_mode.deref().get()
}
- fn set_quirks_mode(&mut self, mode: QuirksMode) {
- *self.quirks_mode = mode;
+ fn set_quirks_mode(&self, mode: QuirksMode) {
+ self.quirks_mode.deref().set(mode);
}
- fn set_encoding_name(&mut self, name: DOMString) {
- self.encoding_name = name;
+ fn set_encoding_name(&self, name: DOMString) {
+ *self.encoding_name.deref().borrow_mut() = name;
}
fn content_changed(&self) {
@@ -227,9 +227,9 @@ impl Document {
},
url: Untraceable::new(url),
// http://dom.spec.whatwg.org/#concept-document-quirks
- quirks_mode: Untraceable::new(NoQuirks),
+ quirks_mode: Untraceable::new(Cell::new(NoQuirks)),
// http://dom.spec.whatwg.org/#concept-document-encoding
- encoding_name: "utf-8".to_string(),
+ encoding_name: Untraceable::new(RefCell::new("utf-8".to_string())),
is_html_document: is_html_document == HTMLDocument,
}
}
@@ -358,7 +358,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-compatmode
fn CompatMode(&self) -> DOMString {
- match *self.quirks_mode {
+ match self.quirks_mode.deref().get() {
NoQuirks => "CSS1Compat".to_string(),
LimitedQuirks | FullQuirks => "BackCompat".to_string()
}
@@ -366,7 +366,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-characterset
fn CharacterSet(&self) -> DOMString {
- self.encoding_name.as_slice().to_ascii_lower()
+ self.encoding_name.deref().borrow().as_slice().to_ascii_lower()
}
// http://dom.spec.whatwg.org/#dom-document-content_type