Use even fewer bits for source order and shrink ApplicableDeclarationsBlock by another word.

MozReview-Commit-ID: 7B1i1g0HLTj
This commit is contained in:
Bobby Holley 2017-06-10 13:54:13 -07:00
parent 3afab1400a
commit 0caad2ffdc
4 changed files with 96 additions and 18 deletions

View file

@ -12,6 +12,7 @@ use properties::{AnimationRules, Importance, LonghandIdSet, PropertyDeclarationB
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use smallvec::SmallVec;
use std::io::{self, Write};
use std::mem;
use std::ptr;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use stylearc::{Arc, NonZeroPtrMut};
@ -229,7 +230,7 @@ impl RuleTree {
guards: &StylesheetGuards)
-> StrongRuleNode
{
let rules = applicable_declarations.drain().map(|d| (d.source, d.level));
let rules = applicable_declarations.drain().map(|d| d.source_and_level());
let rule_node = self.insert_ordered_rules_with_important(rules, guards);
rule_node
}
@ -425,10 +426,18 @@ pub enum CascadeLevel {
/// User-agent important rules.
UAImportant,
/// Transitions
///
/// NB: If this changes from being last, change from_byte below.
Transitions,
}
impl CascadeLevel {
/// Converts a raw byte to a CascadeLevel.
pub unsafe fn from_byte(byte: u8) -> Self {
debug_assert!(byte <= CascadeLevel::Transitions as u8);
mem::transmute(byte)
}
/// Select a lock guard for this level
pub fn guard<'a>(&self, guards: &'a StylesheetGuards<'a>) -> &'a SharedRwLockReadGuard<'a> {
match *self {