mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
Auto merge of #16802 - emilio:slim-down-slc, r=bholley
style: Slim down SharedStyleContext, and do various other cleanups around the style crate. This slims down SharedStyleContext, in preparation for a few things. First, I would like to eventually move the stylist to the document in Servo, in order for it to hold the StyleSheetSet. Also, this gets rid of a fair amount of overhead while creating it in stylo. Fixes bug 1363245. <!-- 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/16802) <!-- Reviewable:end -->
This commit is contained in:
commit
eeb1ee9723
11 changed files with 171 additions and 141 deletions
|
@ -296,13 +296,15 @@ impl Stylist {
|
|||
/// This method resets all the style data each time the stylesheets change
|
||||
/// (which is indicated by the `stylesheets_changed` parameter), or the
|
||||
/// device is dirty, which means we need to re-evaluate media queries.
|
||||
pub fn rebuild<'a>(&mut self,
|
||||
doc_stylesheets: &[Arc<Stylesheet>],
|
||||
guards: &StylesheetGuards,
|
||||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||
stylesheets_changed: bool,
|
||||
author_style_disabled: bool,
|
||||
extra_data: &mut ExtraStyleData<'a>) -> bool {
|
||||
pub fn rebuild<'a, 'b, I>(&mut self,
|
||||
doc_stylesheets: I,
|
||||
guards: &StylesheetGuards,
|
||||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||
stylesheets_changed: bool,
|
||||
author_style_disabled: bool,
|
||||
extra_data: &mut ExtraStyleData<'a>) -> bool
|
||||
where I: Iterator<Item = &'b Arc<Stylesheet>> + Clone,
|
||||
{
|
||||
debug_assert!(!self.is_cleared || self.is_device_dirty);
|
||||
|
||||
self.is_cleared = false;
|
||||
|
@ -315,7 +317,7 @@ impl Stylist {
|
|||
|
||||
let cascaded_rule = ViewportRule {
|
||||
declarations: viewport::Cascade::from_stylesheets(
|
||||
doc_stylesheets, guards.author, &self.device
|
||||
doc_stylesheets.clone(), guards.author, &self.device
|
||||
).finish(),
|
||||
};
|
||||
|
||||
|
@ -345,7 +347,7 @@ impl Stylist {
|
|||
}
|
||||
|
||||
// Only use author stylesheets if author styles are enabled.
|
||||
let sheets_to_add = doc_stylesheets.iter().filter(|s| {
|
||||
let sheets_to_add = doc_stylesheets.filter(|s| {
|
||||
!author_style_disabled || s.origin != Origin::Author
|
||||
});
|
||||
|
||||
|
@ -366,13 +368,15 @@ impl Stylist {
|
|||
|
||||
/// clear the stylist and then rebuild it. Chances are, you want to use
|
||||
/// either clear() or rebuild(), with the latter done lazily, instead.
|
||||
pub fn update<'a>(&mut self,
|
||||
doc_stylesheets: &[Arc<Stylesheet>],
|
||||
guards: &StylesheetGuards,
|
||||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||
stylesheets_changed: bool,
|
||||
author_style_disabled: bool,
|
||||
extra_data: &mut ExtraStyleData<'a>) -> bool {
|
||||
pub fn update<'a, 'b, I>(&mut self,
|
||||
doc_stylesheets: I,
|
||||
guards: &StylesheetGuards,
|
||||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||
stylesheets_changed: bool,
|
||||
author_style_disabled: bool,
|
||||
extra_data: &mut ExtraStyleData<'a>) -> bool
|
||||
where I: Iterator<Item = &'b Arc<Stylesheet>> + Clone,
|
||||
{
|
||||
debug_assert!(!self.is_cleared || self.is_device_dirty);
|
||||
|
||||
// We have to do a dirtiness check before clearing, because if
|
||||
|
@ -385,7 +389,9 @@ impl Stylist {
|
|||
author_style_disabled, extra_data)
|
||||
}
|
||||
|
||||
fn add_stylesheet<'a>(&mut self, stylesheet: &Stylesheet, guard: &SharedRwLockReadGuard,
|
||||
fn add_stylesheet<'a>(&mut self,
|
||||
stylesheet: &Stylesheet,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
extra_data: &mut ExtraStyleData<'a>) {
|
||||
if stylesheet.disabled() || !stylesheet.is_effective_for_device(&self.device, guard) {
|
||||
return;
|
||||
|
@ -711,10 +717,12 @@ impl Stylist {
|
|||
/// FIXME(emilio): The semantics of the device for Servo and Gecko are
|
||||
/// different enough we may want to unify them.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn set_device(&mut self, mut device: Device, guard: &SharedRwLockReadGuard,
|
||||
pub fn set_device(&mut self,
|
||||
mut device: Device,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
stylesheets: &[Arc<Stylesheet>]) {
|
||||
let cascaded_rule = ViewportRule {
|
||||
declarations: viewport::Cascade::from_stylesheets(stylesheets, guard, &device).finish(),
|
||||
declarations: viewport::Cascade::from_stylesheets(stylesheets.iter(), guard, &device).finish(),
|
||||
};
|
||||
|
||||
self.viewport_constraints =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue