mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Rejigger serialization of a declaration block to not look at the shorthands length.
This is because I'm going to make shorthands() and longhands() return an iterator, so that we account for prefs properly (https://bugzilla.mozilla.org/show_bug.cgi?id=1438234).
This commit is contained in:
parent
c676b52448
commit
e46f910b66
2 changed files with 18 additions and 14 deletions
|
@ -426,7 +426,7 @@ impl PropertyDeclarationBlock {
|
|||
let all_shorthand_len = match drain.all_shorthand {
|
||||
AllShorthand::NotSet => 0,
|
||||
AllShorthand::CSSWideKeyword(_) |
|
||||
AllShorthand::WithVariables(_) => ShorthandId::All.longhands().len()
|
||||
AllShorthand::WithVariables(_) => shorthands::ALL_SHORTHAND_MAX_LEN,
|
||||
};
|
||||
let push_calls_count =
|
||||
drain.declarations.len() + all_shorthand_len;
|
||||
|
@ -784,8 +784,6 @@ impl PropertyDeclarationBlock {
|
|||
|
||||
// Step 3.3.2
|
||||
for &shorthand in declaration.shorthands() {
|
||||
let properties = shorthand.longhands();
|
||||
|
||||
// Substep 2 & 3
|
||||
let mut current_longhands = SmallVec::<[_; 10]>::new();
|
||||
let mut important_count = 0;
|
||||
|
@ -811,21 +809,24 @@ impl PropertyDeclarationBlock {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for (longhand, importance) in self.declaration_importance_iter() {
|
||||
if longhand.id().is_longhand_of(shorthand) {
|
||||
current_longhands.push(longhand);
|
||||
if importance.important() {
|
||||
important_count += 1;
|
||||
let mut contains_all_longhands = true;
|
||||
for &longhand in shorthand.longhands() {
|
||||
match self.get(PropertyDeclarationId::Longhand(longhand)) {
|
||||
Some((declaration, importance)) => {
|
||||
current_longhands.push(declaration);
|
||||
if importance.important() {
|
||||
important_count += 1;
|
||||
}
|
||||
}
|
||||
None => {
|
||||
contains_all_longhands = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Substep 1:
|
||||
//
|
||||
// Assuming that the PropertyDeclarationBlock contains no
|
||||
// duplicate entries, if the current_longhands length is
|
||||
// equal to the properties length, it means that the
|
||||
// properties that map to shorthand are present in longhands
|
||||
if current_longhands.len() != properties.len() {
|
||||
if !contains_all_longhands {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,6 +193,9 @@ pub mod shorthands {
|
|||
spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand"
|
||||
)
|
||||
%>
|
||||
|
||||
/// The max amount of longhands that the `all` shorthand will ever contain.
|
||||
pub const ALL_SHORTHAND_MAX_LEN: usize = ${len(logical_longhands + other_longhands)};
|
||||
}
|
||||
|
||||
<%
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue