mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #13459 - servo:no-arc-heapsize, r=emilio
Use parking_lot::RwLock for PropertyDeclarationBlock <!-- Please describe your changes on the following line: --> As discussed in https://bugzilla.mozilla.org/show_bug.cgi?id=1305141 Closes #13176 --- Original PR title: Stop relying on `impl<T: HeapSizeOf> HeapSizeOf for Arc<T>` https://github.com/servo/heapsize/issues/37#issuecomment-249861171 This builds on top of that. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13459) <!-- Reviewable:end -->
This commit is contained in:
commit
aea9545e16
46 changed files with 313 additions and 265 deletions
|
@ -113,7 +113,7 @@ use script_traits::UntrustedNodeAddress;
|
|||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::boxed::FnBox;
|
||||
use std::cell::Cell;
|
||||
use std::cell::{Cell, Ref, RefMut};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::default::Default;
|
||||
|
@ -125,7 +125,6 @@ use std::time::{Duration, Instant};
|
|||
use string_cache::{Atom, QualName};
|
||||
use style::attr::AttrValue;
|
||||
use style::context::ReflowGoal;
|
||||
use style::refcell::{Ref, RefMut};
|
||||
use style::selector_impl::ElementSnapshot;
|
||||
use style::str::{split_html_space_chars, str_join};
|
||||
use style::stylesheets::Stylesheet;
|
||||
|
@ -146,6 +145,14 @@ enum ParserBlockedByScript {
|
|||
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
|
||||
#[dom_struct]
|
||||
pub struct Document {
|
||||
|
@ -174,7 +181,7 @@ pub struct Document {
|
|||
anchors: MutNullableHeap<JS<HTMLCollection>>,
|
||||
applets: MutNullableHeap<JS<HTMLCollection>>,
|
||||
/// 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.
|
||||
stylesheets_changed_since_reflow: Cell<bool>,
|
||||
ready_state: Cell<DocumentReadyState>,
|
||||
|
@ -1879,13 +1886,16 @@ impl Document {
|
|||
node.get_stylesheet()
|
||||
} else {
|
||||
None
|
||||
}.map(|stylesheet| (JS::from_ref(&*node), stylesheet))
|
||||
}.map(|stylesheet| StylesheetInDocument {
|
||||
node: JS::from_ref(&*node),
|
||||
stylesheet: stylesheet
|
||||
})
|
||||
})
|
||||
.collect());
|
||||
};
|
||||
}
|
||||
self.stylesheets.borrow().as_ref().unwrap().iter()
|
||||
.map(|&(_, ref stylesheet)| stylesheet.clone())
|
||||
.map(|s| s.stylesheet.clone())
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue