Bug 1978217 - Add support for custom style use counters. r=firefox-style-system-reviewers,layout-reviewers,dshin, a=dsmith
In the future if we need to we can hook these up to telemetry (in fact it's not hard, we just need to do that in Document::ReportUseCounters). For now I want to start using them to record whether we might have a data URI. Differential Revision: https://phabricator.services.mozilla.com/D258291
This commit is contained in:
committed by
dsmith@mozilla.com
parent
a3013fe0ae
commit
7a19b92511
@@ -26,7 +26,29 @@ pub struct NonCustomPropertyUseCounters {
|
||||
storage: [Cell<usize>; (property_counts::NON_CUSTOM - 1 + BITS_PER_ENTRY) / BITS_PER_ENTRY],
|
||||
}
|
||||
|
||||
macro_rules! property_use_counters_methods {
|
||||
/// A custom style use counter that we may want to record.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[repr(u32)]
|
||||
pub enum CustomUseCounter {
|
||||
/// Dummy value, used for indexing purposes.
|
||||
Last,
|
||||
}
|
||||
|
||||
impl CustomUseCounter {
|
||||
#[inline]
|
||||
fn bit(self) -> usize {
|
||||
self as usize
|
||||
}
|
||||
}
|
||||
|
||||
/// One bit for each custom use counter.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct CustomUseCounters {
|
||||
storage:
|
||||
[Cell<usize>; ((CustomUseCounter::Last as usize) - 1 + BITS_PER_ENTRY) / BITS_PER_ENTRY],
|
||||
}
|
||||
|
||||
macro_rules! use_counters_methods {
|
||||
($id: ident) => {
|
||||
/// Returns the bucket a given property belongs in, and the bitmask for that
|
||||
/// property.
|
||||
@@ -65,11 +87,15 @@ macro_rules! property_use_counters_methods {
|
||||
}
|
||||
|
||||
impl CountedUnknownPropertyUseCounters {
|
||||
property_use_counters_methods!(CountedUnknownProperty);
|
||||
use_counters_methods!(CountedUnknownProperty);
|
||||
}
|
||||
|
||||
impl NonCustomPropertyUseCounters {
|
||||
property_use_counters_methods!(NonCustomPropertyId);
|
||||
use_counters_methods!(NonCustomPropertyId);
|
||||
}
|
||||
|
||||
impl CustomUseCounters {
|
||||
use_counters_methods!(CustomUseCounter);
|
||||
}
|
||||
|
||||
/// The use-counter data related to a given document we want to store.
|
||||
@@ -80,6 +106,8 @@ pub struct UseCounters {
|
||||
pub non_custom_properties: NonCustomPropertyUseCounters,
|
||||
/// The counters for css properties which we haven't implemented yet.
|
||||
pub counted_unknown_properties: CountedUnknownPropertyUseCounters,
|
||||
/// Custom counters for virtually everything else.
|
||||
pub custom: CustomUseCounters,
|
||||
}
|
||||
|
||||
impl UseCounters {
|
||||
@@ -92,5 +120,6 @@ impl UseCounters {
|
||||
.merge(&other.non_custom_properties);
|
||||
self.counted_unknown_properties
|
||||
.merge(&other.counted_unknown_properties);
|
||||
self.custom.merge(&other.custom);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user