mirror of
https://github.com/servo/servo.git
synced 2025-06-18 21:34:30 +00:00
Remove Untraceable/Traceable from document.rs
This commit is contained in:
parent
ad84dd7e47
commit
4f362ab5e6
3 changed files with 23 additions and 22 deletions
|
@ -42,6 +42,7 @@ use std::collections::hashmap::HashMap;
|
||||||
use collections::hash::Hash;
|
use collections::hash::Hash;
|
||||||
use style::PropertyDeclarationBlock;
|
use style::PropertyDeclarationBlock;
|
||||||
use std::comm::{Receiver, Sender};
|
use std::comm::{Receiver, Sender};
|
||||||
|
use hubbub::hubbub::QuirksMode;
|
||||||
use string_cache::{Atom, Namespace};
|
use string_cache::{Atom, Namespace};
|
||||||
|
|
||||||
impl<T: Reflectable> JSTraceable for JS<T> {
|
impl<T: Reflectable> JSTraceable for JS<T> {
|
||||||
|
@ -231,6 +232,7 @@ untraceable!(PropertyDeclarationBlock)
|
||||||
// These three are interdependent, if you plan to put jsmanaged data
|
// These three are interdependent, if you plan to put jsmanaged data
|
||||||
// in one of these make sure it is propagated properly to containing structs
|
// in one of these make sure it is propagated properly to containing structs
|
||||||
untraceable!(SubpageId, WindowSizeData, PipelineId)
|
untraceable!(SubpageId, WindowSizeData, PipelineId)
|
||||||
|
untraceable!(QuirksMode)
|
||||||
|
|
||||||
impl<'a> JSTraceable for &'a str {
|
impl<'a> JSTraceable for &'a str {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -23,7 +23,6 @@ use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::global;
|
use dom::bindings::global;
|
||||||
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary, OptionalSettable, TemporaryPushable};
|
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary, OptionalSettable, TemporaryPushable};
|
||||||
use dom::bindings::js::OptionalRootable;
|
use dom::bindings::js::OptionalRootable;
|
||||||
use dom::bindings::trace::{Traceable, Untraceable};
|
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::utils::{xml_name_type, InvalidXMLName, Name, QName};
|
use dom::bindings::utils::{xml_name_type, InvalidXMLName, Name, QName};
|
||||||
use dom::comment::Comment;
|
use dom::comment::Comment;
|
||||||
|
@ -81,14 +80,14 @@ pub struct Document {
|
||||||
pub node: Node,
|
pub node: Node,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
pub window: JS<Window>,
|
pub window: JS<Window>,
|
||||||
idmap: Traceable<RefCell<HashMap<Atom, Vec<JS<Element>>>>>,
|
idmap: RefCell<HashMap<Atom, Vec<JS<Element>>>>,
|
||||||
implementation: MutNullableJS<DOMImplementation>,
|
implementation: MutNullableJS<DOMImplementation>,
|
||||||
content_type: DOMString,
|
content_type: DOMString,
|
||||||
last_modified: Traceable<RefCell<Option<DOMString>>>,
|
last_modified: RefCell<Option<DOMString>>,
|
||||||
pub encoding_name: Traceable<RefCell<DOMString>>,
|
pub encoding_name: RefCell<DOMString>,
|
||||||
pub is_html_document: bool,
|
pub is_html_document: bool,
|
||||||
url: Untraceable<Url>,
|
url: Url,
|
||||||
quirks_mode: Untraceable<Cell<QuirksMode>>,
|
quirks_mode: Cell<QuirksMode>,
|
||||||
images: MutNullableJS<HTMLCollection>,
|
images: MutNullableJS<HTMLCollection>,
|
||||||
embeds: MutNullableJS<HTMLCollection>,
|
embeds: MutNullableJS<HTMLCollection>,
|
||||||
links: MutNullableJS<HTMLCollection>,
|
links: MutNullableJS<HTMLCollection>,
|
||||||
|
@ -177,23 +176,23 @@ pub trait DocumentHelpers<'a> {
|
||||||
|
|
||||||
impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
fn url(self) -> &'a Url {
|
fn url(self) -> &'a Url {
|
||||||
&*self.extended_deref().url
|
&self.extended_deref().url
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quirks_mode(self) -> QuirksMode {
|
fn quirks_mode(self) -> QuirksMode {
|
||||||
self.quirks_mode.deref().get()
|
self.quirks_mode.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_quirks_mode(self, mode: QuirksMode) {
|
fn set_quirks_mode(self, mode: QuirksMode) {
|
||||||
self.quirks_mode.deref().set(mode);
|
self.quirks_mode.set(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_last_modified(self, value: DOMString) {
|
fn set_last_modified(self, value: DOMString) {
|
||||||
*self.last_modified.deref().borrow_mut() = Some(value);
|
*self.last_modified.borrow_mut() = Some(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_encoding_name(self, name: DOMString) {
|
fn set_encoding_name(self, name: DOMString) {
|
||||||
*self.encoding_name.deref().borrow_mut() = name;
|
*self.encoding_name.borrow_mut() = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn content_changed(self) {
|
fn content_changed(self) {
|
||||||
|
@ -213,7 +212,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
fn unregister_named_element(self,
|
fn unregister_named_element(self,
|
||||||
to_unregister: JSRef<Element>,
|
to_unregister: JSRef<Element>,
|
||||||
id: Atom) {
|
id: Atom) {
|
||||||
let mut idmap = self.idmap.deref().borrow_mut();
|
let mut idmap = self.idmap.borrow_mut();
|
||||||
let is_empty = match idmap.find_mut(&id) {
|
let is_empty = match idmap.find_mut(&id) {
|
||||||
None => false,
|
None => false,
|
||||||
Some(elements) => {
|
Some(elements) => {
|
||||||
|
@ -240,7 +239,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
});
|
});
|
||||||
assert!(!id.as_slice().is_empty());
|
assert!(!id.as_slice().is_empty());
|
||||||
|
|
||||||
let mut idmap = self.idmap.deref().borrow_mut();
|
let mut idmap = self.idmap.borrow_mut();
|
||||||
|
|
||||||
// FIXME https://github.com/mozilla/rust/issues/13195
|
// FIXME https://github.com/mozilla/rust/issues/13195
|
||||||
// Use mangle() when it exists again.
|
// Use mangle() when it exists again.
|
||||||
|
@ -309,7 +308,7 @@ impl Document {
|
||||||
node: Node::new_without_doc(DocumentNodeTypeId),
|
node: Node::new_without_doc(DocumentNodeTypeId),
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
window: JS::from_rooted(window),
|
window: JS::from_rooted(window),
|
||||||
idmap: Traceable::new(RefCell::new(HashMap::new())),
|
idmap: RefCell::new(HashMap::new()),
|
||||||
implementation: Default::default(),
|
implementation: Default::default(),
|
||||||
content_type: match content_type {
|
content_type: match content_type {
|
||||||
Some(string) => string.clone(),
|
Some(string) => string.clone(),
|
||||||
|
@ -320,12 +319,12 @@ impl Document {
|
||||||
NonHTMLDocument => "application/xml".to_string()
|
NonHTMLDocument => "application/xml".to_string()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
last_modified: Traceable::new(RefCell::new(None)),
|
last_modified: RefCell::new(None),
|
||||||
url: Untraceable::new(url),
|
url: url,
|
||||||
// http://dom.spec.whatwg.org/#concept-document-quirks
|
// http://dom.spec.whatwg.org/#concept-document-quirks
|
||||||
quirks_mode: Untraceable::new(Cell::new(NoQuirks)),
|
quirks_mode: Cell::new(NoQuirks),
|
||||||
// http://dom.spec.whatwg.org/#concept-document-encoding
|
// http://dom.spec.whatwg.org/#concept-document-encoding
|
||||||
encoding_name: Traceable::new(RefCell::new("utf-8".to_string())),
|
encoding_name: RefCell::new("utf-8".to_string()),
|
||||||
is_html_document: is_html_document == HTMLDocument,
|
is_html_document: is_html_document == HTMLDocument,
|
||||||
images: Default::default(),
|
images: Default::default(),
|
||||||
embeds: Default::default(),
|
embeds: Default::default(),
|
||||||
|
@ -419,7 +418,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-document-compatmode
|
// http://dom.spec.whatwg.org/#dom-document-compatmode
|
||||||
fn CompatMode(self) -> DOMString {
|
fn CompatMode(self) -> DOMString {
|
||||||
match self.quirks_mode.deref().get() {
|
match self.quirks_mode.get() {
|
||||||
LimitedQuirks | NoQuirks => "CSS1Compat".to_string(),
|
LimitedQuirks | NoQuirks => "CSS1Compat".to_string(),
|
||||||
FullQuirks => "BackCompat".to_string()
|
FullQuirks => "BackCompat".to_string()
|
||||||
}
|
}
|
||||||
|
@ -427,7 +426,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-document-characterset
|
// http://dom.spec.whatwg.org/#dom-document-characterset
|
||||||
fn CharacterSet(self) -> DOMString {
|
fn CharacterSet(self) -> DOMString {
|
||||||
self.encoding_name.deref().borrow().as_slice().to_ascii_lower()
|
self.encoding_name.borrow().as_slice().to_ascii_lower()
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-document-content_type
|
// http://dom.spec.whatwg.org/#dom-document-content_type
|
||||||
|
@ -474,7 +473,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||||
fn GetElementById(self, id: DOMString) -> Option<Temporary<Element>> {
|
fn GetElementById(self, id: DOMString) -> Option<Temporary<Element>> {
|
||||||
let id = Atom::from_slice(id.as_slice());
|
let id = Atom::from_slice(id.as_slice());
|
||||||
match self.idmap.deref().borrow().find(&id) {
|
match self.idmap.borrow().find(&id) {
|
||||||
None => None,
|
None => None,
|
||||||
Some(ref elements) => Some(Temporary::new((*elements)[0].clone())),
|
Some(ref elements) => Some(Temporary::new((*elements)[0].clone())),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1412,7 +1412,7 @@ impl Node {
|
||||||
DocumentNodeTypeId => {
|
DocumentNodeTypeId => {
|
||||||
let node_doc: JSRef<Document> = DocumentCast::to_ref(node).unwrap();
|
let node_doc: JSRef<Document> = DocumentCast::to_ref(node).unwrap();
|
||||||
let copy_doc: JSRef<Document> = DocumentCast::to_ref(*copy).unwrap();
|
let copy_doc: JSRef<Document> = DocumentCast::to_ref(*copy).unwrap();
|
||||||
copy_doc.set_encoding_name(node_doc.encoding_name.deref().borrow().clone());
|
copy_doc.set_encoding_name(node_doc.encoding_name.borrow().clone());
|
||||||
copy_doc.set_quirks_mode(node_doc.quirks_mode());
|
copy_doc.set_quirks_mode(node_doc.quirks_mode());
|
||||||
},
|
},
|
||||||
ElementNodeTypeId(..) => {
|
ElementNodeTypeId(..) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue