From 9b980e2f491293b921b3feec7bce4965e410890c Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Fri, 5 Jun 2020 00:39:50 +0000 Subject: [PATCH] style: Add telemetry for -moz-appearance usage. Differential Revision: https://phabricator.services.mozilla.com/D77637 --- components/style/properties/declaration_block.rs | 15 +++++++++++++++ components/style/properties/longhands/box.mako.rs | 15 +++++++++++++++ components/style/properties/properties.mako.rs | 3 ++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 75d05836972..2bb7a8c7442 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -348,6 +348,21 @@ impl PropertyDeclarationBlock { .find(|(declaration, _)| declaration.id() == property) } + /// Get a declaration for a given property with the specified importance. + #[inline] + pub fn get_at_importance( + &self, + property: PropertyDeclarationId, + importance: Importance, + ) -> Option<&PropertyDeclaration> { + let (declaration, i) = self.get(property)?; + if i == importance { + Some(declaration) + } else { + None + } + } + /// Tries to serialize a given shorthand from the declarations in this /// block. pub fn shorthand_to_css( diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs index 53aaf453d92..943bd0f27ff 100644 --- a/components/style/properties/longhands/box.mako.rs +++ b/components/style/properties/longhands/box.mako.rs @@ -627,6 +627,21 @@ ${helpers.predefined_type( gecko_ffi_name="mAppearance", )} +// A UA-sheet only property that is always set to the same value as +// -moz-appearance. Used to record telemetry for when author sheets +// override the value of -moz-appearance; see +// nsIFrame::RecordAppearanceTelemetry. +${helpers.predefined_type( + "-moz-default-appearance", + "Appearance", + "computed::Appearance::None", + engines="gecko", + animation_value_type="none", + spec="Internal (not web-exposed)", + enabled_in="ua", + gecko_ffi_name="mDefaultAppearance", +)} + ${helpers.single_keyword( "-moz-orient", "inline block horizontal vertical", diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 12904fe1ca4..e0e0fe4cb03 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2111,7 +2111,8 @@ impl PropertyId { pub struct WideKeywordDeclaration { #[css(skip)] id: LonghandId, - keyword: CSSWideKeyword, + /// The CSS-wide keyword. + pub keyword: CSSWideKeyword, } /// An unparsed declaration that contains `var()` functions.