mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Stop refcounting the stylist.
This commit is contained in:
parent
ebd9bf8181
commit
50e0c67e2c
2 changed files with 17 additions and 24 deletions
|
@ -133,7 +133,7 @@ pub struct LayoutThread {
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
|
|
||||||
/// Performs CSS selector matching and style resolution.
|
/// Performs CSS selector matching and style resolution.
|
||||||
stylist: ::StyleArc<Stylist>,
|
stylist: Stylist,
|
||||||
|
|
||||||
/// Is the current reflow of an iframe, as opposed to a root window?
|
/// Is the current reflow of an iframe, as opposed to a root window?
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
|
@ -418,7 +418,7 @@ impl LayoutThread {
|
||||||
let font_cache_receiver =
|
let font_cache_receiver =
|
||||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
|
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
|
||||||
|
|
||||||
let stylist = StyleArc::new(Stylist::new(device));
|
let stylist = Stylist::new(device);
|
||||||
let outstanding_web_fonts_counter = Arc::new(AtomicUsize::new(0));
|
let outstanding_web_fonts_counter = Arc::new(AtomicUsize::new(0));
|
||||||
let ua_stylesheets = &*UA_STYLESHEETS;
|
let ua_stylesheets = &*UA_STYLESHEETS;
|
||||||
let guard = ua_stylesheets.shared_lock.read();
|
let guard = ua_stylesheets.shared_lock.read();
|
||||||
|
@ -679,11 +679,10 @@ impl LayoutThread {
|
||||||
size: display_list.map_or(0, |sc| sc.heap_size_of_children()),
|
size: display_list.map_or(0, |sc| sc.heap_size_of_children()),
|
||||||
});
|
});
|
||||||
|
|
||||||
let stylist = self.stylist.as_ref();
|
|
||||||
reports.push(Report {
|
reports.push(Report {
|
||||||
path: path![formatted_url, "layout-thread", "stylist"],
|
path: path![formatted_url, "layout-thread", "stylist"],
|
||||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||||
size: stylist.heap_size_of_children(),
|
size: self.stylist.heap_size_of_children(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// The LayoutThread has data in Persistent TLS...
|
// The LayoutThread has data in Persistent TLS...
|
||||||
|
@ -780,7 +779,7 @@ impl LayoutThread {
|
||||||
|
|
||||||
/// Sets quirks mode for the document, causing the quirks mode stylesheet to be used.
|
/// Sets quirks mode for the document, causing the quirks mode stylesheet to be used.
|
||||||
fn handle_set_quirks_mode<'a, 'b>(&mut self, quirks_mode: QuirksMode) {
|
fn handle_set_quirks_mode<'a, 'b>(&mut self, quirks_mode: QuirksMode) {
|
||||||
StyleArc::get_mut(&mut self.stylist).unwrap().set_quirks_mode(quirks_mode);
|
self.stylist.set_quirks_mode(quirks_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_get_layout_root<N: LayoutNode>(&self, node: N) -> Option<FlowRef> {
|
fn try_get_layout_root<N: LayoutNode>(&self, node: N) -> Option<FlowRef> {
|
||||||
|
@ -1038,8 +1037,7 @@ impl LayoutThread {
|
||||||
self.document_shared_lock = Some(document_shared_lock.clone());
|
self.document_shared_lock = Some(document_shared_lock.clone());
|
||||||
let author_guard = document_shared_lock.read();
|
let author_guard = document_shared_lock.read();
|
||||||
let device = Device::new(MediaType::Screen, initial_viewport);
|
let device = Device::new(MediaType::Screen, initial_viewport);
|
||||||
StyleArc::get_mut(&mut self.stylist).unwrap()
|
self.stylist.set_device(device, &author_guard, &data.document_stylesheets);
|
||||||
.set_device(device, &author_guard, &data.document_stylesheets);
|
|
||||||
|
|
||||||
self.viewport_size =
|
self.viewport_size =
|
||||||
self.stylist.viewport_constraints().map_or(current_screen_size, |constraints| {
|
self.stylist.viewport_constraints().map_or(current_screen_size, |constraints| {
|
||||||
|
@ -1092,7 +1090,7 @@ impl LayoutThread {
|
||||||
let mut extra_data = ExtraStyleData {
|
let mut extra_data = ExtraStyleData {
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
};
|
};
|
||||||
let needs_dirtying = StyleArc::get_mut(&mut self.stylist).unwrap().update(
|
let needs_dirtying = self.stylist.update(
|
||||||
&data.document_stylesheets,
|
&data.document_stylesheets,
|
||||||
&guards,
|
&guards,
|
||||||
Some(ua_stylesheets),
|
Some(ua_stylesheets),
|
||||||
|
|
|
@ -25,7 +25,7 @@ use stylist::{ExtraStyleData, Stylist};
|
||||||
/// itself.
|
/// itself.
|
||||||
pub struct PerDocumentStyleDataImpl {
|
pub struct PerDocumentStyleDataImpl {
|
||||||
/// Rule processor.
|
/// Rule processor.
|
||||||
pub stylist: Arc<Stylist>,
|
pub stylist: Stylist,
|
||||||
|
|
||||||
/// List of stylesheets, mirrored from Gecko.
|
/// List of stylesheets, mirrored from Gecko.
|
||||||
pub stylesheets: StylesheetSet,
|
pub stylesheets: StylesheetSet,
|
||||||
|
@ -60,7 +60,7 @@ impl PerDocumentStyleData {
|
||||||
let (new_anims_sender, new_anims_receiver) = channel();
|
let (new_anims_sender, new_anims_receiver) = channel();
|
||||||
|
|
||||||
PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
|
PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
|
||||||
stylist: Arc::new(Stylist::new(device)),
|
stylist: Stylist::new(device),
|
||||||
stylesheets: StylesheetSet::new(),
|
stylesheets: StylesheetSet::new(),
|
||||||
new_animations_sender: new_anims_sender,
|
new_animations_sender: new_anims_sender,
|
||||||
new_animations_receiver: new_anims_receiver,
|
new_animations_receiver: new_anims_receiver,
|
||||||
|
@ -86,10 +86,7 @@ impl PerDocumentStyleDataImpl {
|
||||||
///
|
///
|
||||||
/// Implies also a stylesheet flush.
|
/// Implies also a stylesheet flush.
|
||||||
pub fn reset_device(&mut self, guard: &SharedRwLockReadGuard) {
|
pub fn reset_device(&mut self, guard: &SharedRwLockReadGuard) {
|
||||||
{
|
Arc::get_mut(&mut self.stylist.device).unwrap().reset();
|
||||||
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
|
||||||
Arc::get_mut(&mut stylist.device).unwrap().reset();
|
|
||||||
}
|
|
||||||
self.stylesheets.force_dirty();
|
self.stylesheets.force_dirty();
|
||||||
self.flush_stylesheets(guard);
|
self.flush_stylesheets(guard);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +97,6 @@ impl PerDocumentStyleDataImpl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
|
||||||
let mut extra_data = ExtraStyleData {
|
let mut extra_data = ExtraStyleData {
|
||||||
font_faces: &mut self.font_faces,
|
font_faces: &mut self.font_faces,
|
||||||
};
|
};
|
||||||
|
@ -108,13 +104,13 @@ impl PerDocumentStyleDataImpl {
|
||||||
let author_style_disabled = self.stylesheets.author_style_disabled();
|
let author_style_disabled = self.stylesheets.author_style_disabled();
|
||||||
let mut stylesheets = Vec::<Arc<Stylesheet>>::new();
|
let mut stylesheets = Vec::<Arc<Stylesheet>>::new();
|
||||||
self.stylesheets.flush(&mut stylesheets);
|
self.stylesheets.flush(&mut stylesheets);
|
||||||
stylist.clear();
|
self.stylist.clear();
|
||||||
stylist.rebuild(stylesheets.as_slice(),
|
self.stylist.rebuild(stylesheets.as_slice(),
|
||||||
&StylesheetGuards::same(guard),
|
&StylesheetGuards::same(guard),
|
||||||
/* ua_sheets = */ None,
|
/* ua_sheets = */ None,
|
||||||
/* stylesheets_changed = */ true,
|
/* stylesheets_changed = */ true,
|
||||||
author_style_disabled,
|
author_style_disabled,
|
||||||
&mut extra_data);
|
&mut extra_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the default computed values for this document.
|
/// Get the default computed values for this document.
|
||||||
|
@ -125,8 +121,7 @@ impl PerDocumentStyleDataImpl {
|
||||||
/// Clear the stylist. This will be a no-op if the stylist is
|
/// Clear the stylist. This will be a no-op if the stylist is
|
||||||
/// already cleared; the stylist handles that.
|
/// already cleared; the stylist handles that.
|
||||||
pub fn clear_stylist(&mut self) {
|
pub fn clear_stylist(&mut self) {
|
||||||
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
self.stylist.clear();
|
||||||
stylist.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue