style: Fix cascade order of !important in Shadow DOM.

No cleaner ideas right now that carrying that counter around... Maybe a custom
type may be cleaner?

This makes ApplicableDeclarationBlock a bit bigger. I could probably try to make
the counter a 4 / 5-bit number or something and pack the counter there in the
SourceOrderAndCascadeLevel somehow...

But doesn't seem really worth the churn, and can be done as a followup in any
case. Let me know if you want to block on that.

Bug: 1454162
Reviewed-by: heycam
MozReview-Commit-ID: 1LdW9S4xA6f
This commit is contained in:
Emilio Cobos Álvarez 2018-04-18 09:56:33 +02:00
parent 78f9672b6c
commit 84d6c13871
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
6 changed files with 133 additions and 44 deletions

View file

@ -5,7 +5,7 @@
//! Applicable declarations management.
use properties::PropertyDeclarationBlock;
use rule_tree::{CascadeLevel, StyleSource};
use rule_tree::{CascadeLevel, ShadowCascadeOrder, StyleSource};
use servo_arc::Arc;
use shared_lock::Locked;
use smallvec::SmallVec;
@ -83,6 +83,8 @@ pub struct ApplicableDeclarationBlock {
order_and_level: SourceOrderAndCascadeLevel,
/// The specificity of the selector this block is represented by.
pub specificity: u32,
/// The order in the tree of trees we carry on.
pub shadow_cascade_order: ShadowCascadeOrder,
}
impl ApplicableDeclarationBlock {
@ -97,16 +99,24 @@ impl ApplicableDeclarationBlock {
source: StyleSource::Declarations(declarations),
order_and_level: SourceOrderAndCascadeLevel::new(0, level),
specificity: 0,
shadow_cascade_order: 0,
}
}
/// Constructs an applicable declaration block from the given components
#[inline]
pub fn new(source: StyleSource, order: u32, level: CascadeLevel, specificity: u32) -> Self {
pub fn new(
source: StyleSource,
order: u32,
level: CascadeLevel,
specificity: u32,
shadow_cascade_order: u32,
) -> Self {
ApplicableDeclarationBlock {
source: source,
source,
order_and_level: SourceOrderAndCascadeLevel::new(order, level),
specificity: specificity,
specificity,
shadow_cascade_order,
}
}
@ -122,11 +132,11 @@ impl ApplicableDeclarationBlock {
self.order_and_level.level()
}
/// Convenience method to consume self and return the source alongside the
/// level.
/// Convenience method to consume self and return the right thing for the
/// rule tree to iterate over.
#[inline]
pub fn order_and_level(self) -> (StyleSource, CascadeLevel) {
pub fn for_rule_tree(self) -> (StyleSource, CascadeLevel, ShadowCascadeOrder) {
let level = self.level();
(self.source, level)
(self.source, level, self.shadow_cascade_order)
}
}