mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Make the StyleSheetSet::flush API slightly nicer.
MozReview-Commit-ID: LfJxZA9zhaE Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
1c9c0334ba
commit
a98fd5e2b6
2 changed files with 13 additions and 10 deletions
|
@ -180,14 +180,12 @@ where
|
||||||
.any(|(d, _)| d.dirty)
|
.any(|(d, _)| d.dirty)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flush the current set, unmarking it as dirty, and returns an iterator
|
/// Flush the current set, unmarking it as dirty, and returns the damaged
|
||||||
/// over the new stylesheet list.
|
/// origins, and whether any elements were invalidated.
|
||||||
///
|
|
||||||
/// Returns true if any elements were invalidated.
|
|
||||||
pub fn flush<E>(
|
pub fn flush<E>(
|
||||||
&mut self,
|
&mut self,
|
||||||
document_element: Option<E>,
|
document_element: Option<E>,
|
||||||
) -> (StylesheetIterator<S>, OriginSet, bool)
|
) -> (OriginSet, bool)
|
||||||
where
|
where
|
||||||
E: TElement,
|
E: TElement,
|
||||||
{
|
{
|
||||||
|
@ -195,6 +193,7 @@ where
|
||||||
|
|
||||||
let mut origins = OriginSet::empty();
|
let mut origins = OriginSet::empty();
|
||||||
let mut have_invalidations = false;
|
let mut have_invalidations = false;
|
||||||
|
|
||||||
for (data, origin) in self.invalidation_data.iter_mut_origins() {
|
for (data, origin) in self.invalidation_data.iter_mut_origins() {
|
||||||
if data.dirty {
|
if data.dirty {
|
||||||
have_invalidations |= data.invalidations.flush(document_element);
|
have_invalidations |= data.invalidations.flush(document_element);
|
||||||
|
@ -203,7 +202,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(self.iter(), origins, have_invalidations)
|
(origins, have_invalidations)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flush stylesheets, but without running any of the invalidation passes.
|
/// Flush stylesheets, but without running any of the invalidation passes.
|
||||||
|
|
|
@ -490,13 +490,15 @@ impl Stylist {
|
||||||
}
|
}
|
||||||
|
|
||||||
let author_style_disabled = self.stylesheets.author_style_disabled();
|
let author_style_disabled = self.stylesheets.author_style_disabled();
|
||||||
let (doc_stylesheets, origins_to_rebuild, have_invalidations) =
|
let (origins_to_rebuild, have_invalidations) =
|
||||||
self.stylesheets.flush(document_element);
|
self.stylesheets.flush(document_element);
|
||||||
|
|
||||||
if origins_to_rebuild.is_empty() {
|
if origins_to_rebuild.is_empty() {
|
||||||
return have_invalidations;
|
return have_invalidations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let doc_stylesheets = self.stylesheets.iter();
|
||||||
|
|
||||||
self.num_rebuilds += 1;
|
self.num_rebuilds += 1;
|
||||||
|
|
||||||
// Update viewport_constraints regardless of which origins'
|
// Update viewport_constraints regardless of which origins'
|
||||||
|
@ -520,9 +522,11 @@ impl Stylist {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.viewport_constraints =
|
self.viewport_constraints =
|
||||||
ViewportConstraints::maybe_new(&self.device,
|
ViewportConstraints::maybe_new(
|
||||||
&cascaded_rule,
|
&self.device,
|
||||||
self.quirks_mode);
|
&cascaded_rule,
|
||||||
|
self.quirks_mode,
|
||||||
|
);
|
||||||
|
|
||||||
if let Some(ref constraints) = self.viewport_constraints {
|
if let Some(ref constraints) = self.viewport_constraints {
|
||||||
self.device.account_for_viewport_rule(constraints);
|
self.device.account_for_viewport_rule(constraints);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue