mirror of
https://github.com/servo/servo.git
synced 2025-08-23 06:15:35 +01:00
Auto merge of #19696 - upsuper:rule-cache-opt, r=emilio
Skip rule node which contains only inherited properties for rule cache This is one possible fix for [bug 1427681](https://bugzilla.mozilla.org/show_bug.cgi?id=1427681) which tries to skip some rule nodes when using rule cache. Try push for correctness: https://treeherder.mozilla.org/#/jobs?repo=try&revision=74e3941e2cfc5fba4bce839f2518af8a5a8b7411 It doesn't really show much memory saving on awsy. It only shows several KB save on fresh start memory. But since conceptually it's simple, I guess it's worth taking. <!-- 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/19696) <!-- Reviewable:end -->
This commit is contained in:
commit
6131371cc2
6 changed files with 75 additions and 7 deletions
|
@ -283,6 +283,12 @@ impl PropertyDeclarationBlock {
|
|||
self.longhands.contains(id)
|
||||
}
|
||||
|
||||
/// Returns whether this block contains any reset longhand.
|
||||
#[inline]
|
||||
pub fn contains_any_reset(&self) -> bool {
|
||||
self.longhands.contains_any_reset()
|
||||
}
|
||||
|
||||
/// Get a declaration for a given property.
|
||||
///
|
||||
/// NOTE: This is linear time.
|
||||
|
|
|
@ -309,6 +309,16 @@ impl LonghandIdSet {
|
|||
true
|
||||
}
|
||||
|
||||
/// Returns whether this set contains any longhand that `other` also contains.
|
||||
pub fn contains_any(&self, other: &Self) -> bool {
|
||||
for (self_cell, other_cell) in self.storage.iter().zip(other.storage.iter()) {
|
||||
if (*self_cell & *other_cell) != 0 {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Create an empty set
|
||||
#[inline]
|
||||
pub fn new() -> LonghandIdSet {
|
||||
|
@ -322,6 +332,13 @@ impl LonghandIdSet {
|
|||
(self.storage[bit / 32] & (1 << (bit % 32))) != 0
|
||||
}
|
||||
|
||||
/// Return whether this set contains any reset longhand.
|
||||
#[inline]
|
||||
pub fn contains_any_reset(&self) -> bool {
|
||||
${static_longhand_id_set("RESET", lambda p: not p.style_struct.inherited)}
|
||||
self.contains_any(&RESET)
|
||||
}
|
||||
|
||||
/// Add the given property to the set
|
||||
#[inline]
|
||||
pub fn insert(&mut self, id: LonghandId) {
|
||||
|
@ -3157,6 +3174,7 @@ pub fn cascade(
|
|||
device,
|
||||
pseudo,
|
||||
rule_node,
|
||||
guards,
|
||||
iter_declarations,
|
||||
parent_style,
|
||||
parent_style_ignoring_first_line,
|
||||
|
@ -3176,6 +3194,7 @@ pub fn apply_declarations<'a, F, I>(
|
|||
device: &Device,
|
||||
pseudo: Option<<&PseudoElement>,
|
||||
rules: &StrongRuleNode,
|
||||
guards: &StylesheetGuards,
|
||||
iter_declarations: F,
|
||||
parent_style: Option<<&ComputedValues>,
|
||||
parent_style_ignoring_first_line: Option<<&ComputedValues>,
|
||||
|
@ -3478,7 +3497,7 @@ where
|
|||
% endif
|
||||
}
|
||||
|
||||
if let Some(style) = rule_cache.and_then(|c| c.find(&context.builder)) {
|
||||
if let Some(style) = rule_cache.and_then(|c| c.find(guards, &context.builder)) {
|
||||
context.builder.copy_reset_from(style);
|
||||
apply_reset = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue