Make script build without impl<T: HeapSizeOf> HeapSizeOf for Arc<T>.

The removal of this impl is not included in this commit.
CC https://github.com/servo/heapsize/issues/37#issuecomment-249861171
This commit is contained in:
Simon Sapin 2016-09-27 15:30:55 +02:00
parent 29c72d15a9
commit aeb3efda1f
8 changed files with 21 additions and 3 deletions

View file

@ -146,6 +146,14 @@ enum ParserBlockedByScript {
Unblocked, Unblocked,
} }
#[derive(JSTraceable, HeapSizeOf)]
#[must_root]
struct StylesheetInDocument {
node: JS<Node>,
#[ignore_heap_size_of = "Arc"]
stylesheet: Arc<Stylesheet>,
}
// https://dom.spec.whatwg.org/#document // https://dom.spec.whatwg.org/#document
#[dom_struct] #[dom_struct]
pub struct Document { pub struct Document {
@ -174,7 +182,7 @@ pub struct Document {
anchors: MutNullableHeap<JS<HTMLCollection>>, anchors: MutNullableHeap<JS<HTMLCollection>>,
applets: MutNullableHeap<JS<HTMLCollection>>, applets: MutNullableHeap<JS<HTMLCollection>>,
/// List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed. /// List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed.
stylesheets: DOMRefCell<Option<Vec<(JS<Node>, Arc<Stylesheet>)>>>, stylesheets: DOMRefCell<Option<Vec<StylesheetInDocument>>>,
/// Whether the list of stylesheets has changed since the last reflow was triggered. /// Whether the list of stylesheets has changed since the last reflow was triggered.
stylesheets_changed_since_reflow: Cell<bool>, stylesheets_changed_since_reflow: Cell<bool>,
ready_state: Cell<DocumentReadyState>, ready_state: Cell<DocumentReadyState>,
@ -1891,13 +1899,16 @@ impl Document {
node.get_stylesheet() node.get_stylesheet()
} else { } else {
None None
}.map(|stylesheet| (JS::from_ref(&*node), stylesheet)) }.map(|stylesheet| StylesheetInDocument {
node: JS::from_ref(&*node),
stylesheet: stylesheet
})
}) })
.collect()); .collect());
}; };
} }
self.stylesheets.borrow().as_ref().unwrap().iter() self.stylesheets.borrow().as_ref().unwrap().iter()
.map(|&(_, ref stylesheet)| stylesheet.clone()) .map(|s| s.stylesheet.clone())
.collect() .collect()
} }

View file

@ -109,6 +109,7 @@ pub struct Element {
prefix: Option<DOMString>, prefix: Option<DOMString>,
attrs: DOMRefCell<Vec<JS<Attr>>>, attrs: DOMRefCell<Vec<JS<Attr>>>,
id_attribute: DOMRefCell<Option<Atom>>, id_attribute: DOMRefCell<Option<Atom>>,
#[ignore_heap_size_of = "Arc"]
style_attribute: DOMRefCell<Option<Arc<PropertyDeclarationBlock>>>, style_attribute: DOMRefCell<Option<Arc<PropertyDeclarationBlock>>>,
attr_list: MutNullableHeap<JS<NamedNodeMap>>, attr_list: MutNullableHeap<JS<NamedNodeMap>>,
class_list: MutNullableHeap<JS<DOMTokenList>>, class_list: MutNullableHeap<JS<DOMTokenList>>,

View file

@ -47,6 +47,7 @@ struct ImageRequest {
state: State, state: State,
parsed_url: Option<Url>, parsed_url: Option<Url>,
source_url: Option<DOMString>, source_url: Option<DOMString>,
#[ignore_heap_size_of = "Arc"]
image: Option<Arc<Image>>, image: Option<Arc<Image>>,
metadata: Option<ImageMetadata>, metadata: Option<ImageMetadata>,
} }

View file

@ -52,6 +52,7 @@ no_jsmanaged_fields!(Stylesheet);
pub struct HTMLLinkElement { pub struct HTMLLinkElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
rel_list: MutNullableHeap<JS<DOMTokenList>>, rel_list: MutNullableHeap<JS<DOMTokenList>>,
#[ignore_heap_size_of = "Arc"]
stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>, stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>,
/// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts /// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts

View file

@ -27,6 +27,7 @@ use style::viewport::ViewportRule;
#[dom_struct] #[dom_struct]
pub struct HTMLMetaElement { pub struct HTMLMetaElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
#[ignore_heap_size_of = "Arc"]
stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>, stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>,
} }

View file

@ -24,6 +24,7 @@ use string_cache::Atom;
#[dom_struct] #[dom_struct]
pub struct HTMLObjectElement { pub struct HTMLObjectElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
#[ignore_heap_size_of = "Arc"]
image: DOMRefCell<Option<Arc<Image>>>, image: DOMRefCell<Option<Arc<Image>>>,
} }

View file

@ -24,6 +24,7 @@ use style::stylesheets::{Stylesheet, Origin};
#[dom_struct] #[dom_struct]
pub struct HTMLStyleElement { pub struct HTMLStyleElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
#[ignore_heap_size_of = "Arc"]
stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>, stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>,
} }

View file

@ -83,6 +83,7 @@ pub struct WorkerGlobalScope {
worker_id: WorkerId, worker_id: WorkerId,
pipeline_id: PipelineId, pipeline_id: PipelineId,
worker_url: Url, worker_url: Url,
#[ignore_heap_size_of = "Arc"]
closing: Option<Arc<AtomicBool>>, closing: Option<Arc<AtomicBool>>,
#[ignore_heap_size_of = "Defined in js"] #[ignore_heap_size_of = "Defined in js"]
runtime: Runtime, runtime: Runtime,