style: Update layer ordering to follow the spec

The bitfield approach worked when the layer order was in pre-order, but
the spec was changed to make it work like post-order and I don't think
there's a way to keep it working like that, so keep the layer order in a
separate data structure that we look up when going from Rule to
ApplicableDeclarationBlock.

This is just a vector index operation so hopefully shouldn't be too bad.

This patch intentionally regresses @keyframe handling to some extent,
since we need a bit more complicated approach and it seemed worth
implementing in a separate patch.

Depends on D129380

Differential Revision: https://phabricator.services.mozilla.com/D129381
This commit is contained in:
Emilio Cobos Álvarez 2023-05-27 17:36:01 +02:00 committed by Oriol Brufau
parent 5f2a29659f
commit 1b2ef21c8c
6 changed files with 190 additions and 164 deletions

View file

@ -88,13 +88,19 @@ impl ApplicableDeclarationBlock {
source: StyleSource::from_declarations(declarations),
bits: ApplicableDeclarationBits::new(0, level),
specificity: 0,
layer_order: LayerOrder::first(),
layer_order: LayerOrder::root(),
}
}
/// Constructs an applicable declaration block from the given components
/// Constructs an applicable declaration block from the given components.
#[inline]
pub fn new(source: StyleSource, source_order: u32, level: CascadeLevel, specificity: u32, layer_order: LayerOrder) -> Self {
pub fn new(
source: StyleSource,
source_order: u32,
level: CascadeLevel,
specificity: u32,
layer_order: LayerOrder,
) -> Self {
ApplicableDeclarationBlock {
source,
bits: ApplicableDeclarationBits::new(source_order, level),