Merge mozilla-central to autoland.

This commit is contained in:
Mihai Alexandru Michis 2019-09-18 14:47:25 +03:00
commit 7bed28e9e2
23 changed files with 118 additions and 262 deletions

View File

@ -14420,7 +14420,6 @@ void Document::PropagateUseCounters(Document* aParentDocument) {
return;
}
SetCssUseCounterBits();
contentParent->mChildDocumentUseCounters |= mUseCounters;
contentParent->mChildDocumentUseCounters |= mChildDocumentUseCounters;
}
@ -14449,61 +14448,6 @@ bool Document::InlineScriptAllowedByCSP() {
return allowsInlineScript;
}
// Some use-counter sanity-checking.
static_assert(size_t(eUseCounter_EndCSSProperties) -
size_t(eUseCounter_FirstCSSProperty) ==
size_t(eCSSProperty_COUNT_with_aliases),
"We should have the right amount of CSS property use counters");
static_assert(size_t(eUseCounter_Count) -
size_t(eUseCounter_FirstCountedUnknownProperty) ==
size_t(CountedUnknownProperty::Count),
"We should have the right amount of counted unknown properties"
" use counters");
static_assert(size_t(eUseCounter_Count) * 2 ==
size_t(Telemetry::HistogramUseCounterCount),
"There should be two histograms (document and page)"
" for each use counter");
#define ASSERT_CSS_COUNTER(id_, method_) \
static_assert(size_t(eUseCounter_property_##method_) - \
size_t(eUseCounter_FirstCSSProperty) == \
size_t(id_), \
"Order for CSS counters and CSS property id should match");
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
#define CSS_PROP_LONGHAND(name_, id_, method_, ...) \
ASSERT_CSS_COUNTER(eCSSProperty_##id_, method_)
#define CSS_PROP_SHORTHAND(name_, id_, method_, ...) \
ASSERT_CSS_COUNTER(eCSSProperty_##id_, method_)
#define CSS_PROP_ALIAS(name_, aliasid_, id_, method_, ...) \
ASSERT_CSS_COUNTER(eCSSPropertyAlias_##aliasid_, method_)
#include "mozilla/ServoCSSPropList.h"
#undef CSS_PROP_ALIAS
#undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LONGHAND
#undef CSS_PROP_PUBLIC_OR_PRIVATE
#undef ASSERT_CSS_COUNTER
void Document::SetCssUseCounterBits() {
if (!mStyleUseCounters) {
return;
}
for (size_t i = 0; i < eCSSProperty_COUNT_with_aliases; ++i) {
auto id = nsCSSPropertyID(i);
if (Servo_IsPropertyIdRecordedInUseCounter(mStyleUseCounters.get(), id)) {
SetUseCounter(nsCSSProps::UseCounterFor(id));
}
}
for (size_t i = 0; i < size_t(CountedUnknownProperty::Count); ++i) {
if (Servo_IsUnknownPropertyRecordedInUseCounter(
mStyleUseCounters.get(), CountedUnknownProperty(i))) {
SetUseCounter(UseCounter(eUseCounter_FirstCountedUnknownProperty + i));
}
}
}
void Document::PropagateUseCountersToPage() {
if (mDisplayDocument) {
// If we are a resource document, we won't have a docshell and so we won't
@ -14541,7 +14485,6 @@ void Document::ReportUseCounters() {
}
mReportedUseCounters = true;
SetCssUseCounterBits();
// Call ReportUseCounters in all our outstanding subdocuments and resources
// and such. This needs to be here so that all our sub documents propagate our

View File

@ -4039,10 +4039,6 @@ class Document : public nsINode,
private:
void InitializeLocalization(nsTArray<nsString>& aResourceIds);
// Takes the bits from mStyleUseCounters if appropriate, and sets them in
// mUseCounters.
void SetCssUseCounterBits();
// Returns true if there is any valid value in the viewport meta tag.
bool ParseWidthAndHeightInMetaViewport(const nsAString& aWidthString,
const nsAString& aHeightString,

View File

@ -17,44 +17,18 @@ enum UseCounter : int16_t {
#define USE_COUNTER_DOM_ATTRIBUTE(interface_, name_) \
eUseCounter_##interface_##_##name_##_getter, \
eUseCounter_##interface_##_##name_##_setter,
#define USE_COUNTER_CSS_PROPERTY(name_, id_) eUseCounter_property_##id_,
#define USE_COUNTER_CUSTOM(name_, desc_) eUseCounter_custom_##name_,
#include "mozilla/dom/UseCounterList.h"
#undef USE_COUNTER_DOM_METHOD
#undef USE_COUNTER_DOM_ATTRIBUTE
#undef USE_COUNTER_CSS_PROPERTY
#undef USE_COUNTER_CUSTOM
#define DEPRECATED_OPERATION(op_) eUseCounter_##op_,
#include "nsDeprecatedOperationList.h"
#undef DEPRECATED_OPERATION
eUseCounter_FirstCSSProperty,
__reset_hack = eUseCounter_FirstCSSProperty - 1,
// Need an extra level of macro nesting to force expansion of method_
// params before they get pasted.
#define CSS_PROP_USE_COUNTER(method_) eUseCounter_property_##method_,
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
#define CSS_PROP_LONGHAND(name_, id_, method_, ...) \
CSS_PROP_USE_COUNTER(method_)
#define CSS_PROP_SHORTHAND(name_, id_, method_, ...) \
CSS_PROP_USE_COUNTER(method_)
#define CSS_PROP_ALIAS(name_, aliasid_, id_, method_, ...) \
CSS_PROP_USE_COUNTER(method_)
#include "mozilla/ServoCSSPropList.h"
#undef CSS_PROP_ALIAS
#undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LONGHAND
#undef CSS_PROP_PUBLIC_OR_PRIVATE
#undef CSS_PROP_USE_COUNTER
eUseCounter_EndCSSProperties,
eUseCounter_FirstCountedUnknownProperty = eUseCounter_EndCSSProperties,
__reset_hack_2 = eUseCounter_FirstCountedUnknownProperty - 1,
#define COUNTED_UNKNOWN_PROPERTY(name_, method_) eUseCounter_unknown_property_##method_,
#include "mozilla/CountedUnknownProperties.h"
#undef COUNTED_UNKNOWN_PROPERTY
eUseCounter_Count
};

View File

@ -16,8 +16,12 @@
//
// method <IDL interface name>.<IDL operation name>
// attribute <IDL interface name>.<IDL attribute name>
// property <CSS property method name>
// custom <any valid identifier> <description>
//
// The |CSS property method name| should be CamelCase form of the property
// name with -moz- and -x- prefix removed.
//
// The <description> for custom counters will be appended to "When a document "
// or "When a page ", so phrase it appropriately. For instance, "constructs a
// Foo object" or "calls Document.bar('some value')". It may contain any
@ -25,17 +29,21 @@
//
// To actually cause use counters to be incremented, DOM methods
// and attributes must have a [UseCounter] extended attribute in
// the Web IDL file.
// Custom counters are incremented when
// the Web IDL file. CSS properties require no special treatment
// beyond being listed below. Custom counters are incremented when
// SetUseCounter(eUseCounter_custom_MyName) is called on a Document object.
//
// You might reasonably ask why we have this file and we require
// annotating things with [UseCounter] in the relevant WebIDL file as
// well. Generating things from bindings codegen and ensuring all the
// dependencies were correct would have been rather difficult.
// dependencies were correct would have been rather difficult, and
// annotating the WebIDL files does nothing for identifying CSS
// property usage, which we would also like to track.
method SVGSVGElement.getElementById
attribute SVGSVGElement.currentScale
property Fill
property FillOpacity
attribute XMLDocument.async
// Push API

View File

@ -36,6 +36,7 @@ def generate_list(f, counters):
print_optional_macro_declare('USE_COUNTER_DOM_METHOD')
print_optional_macro_declare('USE_COUNTER_DOM_ATTRIBUTE')
print_optional_macro_declare('USE_COUNTER_CSS_PROPERTY')
print_optional_macro_declare('USE_COUNTER_CUSTOM')
for counter in counters:
@ -43,14 +44,44 @@ def generate_list(f, counters):
print('USE_COUNTER_DOM_METHOD(%s, %s)' % (counter['interface_name'], counter['method_name']), file=f)
elif counter['type'] == 'attribute':
print('USE_COUNTER_DOM_ATTRIBUTE(%s, %s)' % (counter['interface_name'], counter['attribute_name']), file=f)
elif counter['type'] == 'property':
prop = counter['property_name']
print('USE_COUNTER_CSS_PROPERTY(%s, %s)' % (prop, prop), file=f)
elif counter['type'] == 'custom':
desc = counter['desc'].replace('\\', r'\\').replace('"', r'\"')
print('USE_COUNTER_CUSTOM(%s, "%s")' % (counter['name'], desc), file=f)
print_optional_macro_undeclare('USE_COUNTER_DOM_METHOD')
print_optional_macro_undeclare('USE_COUNTER_DOM_ATTRIBUTE')
print_optional_macro_undeclare('USE_COUNTER_CSS_PROPERTY')
print_optional_macro_undeclare('USE_COUNTER_CUSTOM')
def generate_property_map(f, counters):
print(AUTOGENERATED_WARNING_COMMENT, file=f)
print('''
enum {
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
// Need an extra level of macro nesting to force expansion of method_
// params before they get pasted.
#define CSS_PROP_USE_COUNTER(method_) \\
USE_COUNTER_FOR_CSS_PROPERTY_##method_ = eUseCounter_UNKNOWN,
#define CSS_PROP_LONGHAND(name_, id_, method_, ...) \\
CSS_PROP_USE_COUNTER(method_)
#include "mozilla/ServoCSSPropList.h"
#undef CSS_PROP_LONGHAND
#undef CSS_PROP_USE_COUNTER
#undef CSS_PROP_PUBLIC_OR_PRIVATE
};
''', file=f)
for counter in counters:
if counter['type'] == 'property':
prop = counter['property_name']
print('#define USE_COUNTER_FOR_CSS_PROPERTY_%s eUseCounter_property_%s' % (prop, prop), file=f)
def use_counter_list(output_header, conf_filename):
counters = usecounters.read_conf(conf_filename)
generate_list(output_header, counters)
def property_map(output_map, conf_filename):
counters = usecounters.read_conf(conf_filename)
generate_property_map(output_map, counters)

View File

@ -540,9 +540,14 @@ if CONFIG['MOZ_X11']:
CXXFLAGS += CONFIG['TK_CFLAGS']
GENERATED_FILES += [
'PropertyUseCounterMap.inc',
'UseCounterList.h',
]
countermap = GENERATED_FILES['PropertyUseCounterMap.inc']
countermap.script = 'gen-usecounters.py:property_map'
countermap.inputs = ['UseCounters.conf']
counterlist = GENERATED_FILES['UseCounterList.h']
counterlist.script = 'gen-usecounters.py:use_counter_list'
counterlist.inputs = ['UseCounters.conf']

View File

@ -24,7 +24,6 @@ support-files =
file_messagemanager_unload.html
file_pluginAudio.html
file_use_counter_outer.html
file_use_counter_style.html
file_use_counter_svg_getElementById.svg
file_use_counter_svg_currentScale.svg
file_use_counter_svg_fill_pattern_definition.svg

View File

@ -51,30 +51,6 @@ add_task(async function() {
"SVGSVGELEMENT_CURRENTSCALE_setter"
);
// Check for longhands.
await check_use_counter_iframe(
"file_use_counter_style.html",
"CSS_PROPERTY_BackgroundImage"
);
// Check for shorthands.
await check_use_counter_iframe(
"file_use_counter_style.html",
"CSS_PROPERTY_Padding"
);
// Check for aliases.
await check_use_counter_iframe(
"file_use_counter_style.html",
"CSS_PROPERTY_MozTransform"
);
// Check for counted unknown properties.
await check_use_counter_iframe(
"file_use_counter_style.html",
"CSS_PROPERTY_WebkitPaddingStart"
);
// Check that even loads from the imglib cache update use counters. The
// images should still be there, because we just loaded them in the last
// set of tests. But we won't get updated counts for the document
@ -100,18 +76,18 @@ add_task(async function() {
// check for properties here.
await check_use_counter_img(
"file_use_counter_svg_getElementById.svg",
"CSS_PROPERTY_Fill"
"PROPERTY_FILL"
);
await check_use_counter_img(
"file_use_counter_svg_currentScale.svg",
"CSS_PROPERTY_Fill"
"PROPERTY_FILL"
);
// Check that use counters are incremented by directly loading SVGs
// that reference patterns defined in another SVG file.
await check_use_counter_direct(
"file_use_counter_svg_fill_pattern.svg",
"CSS_PROPERTY_FillOpacity",
"PROPERTY_FILLOPACITY",
/*xfail=*/ true
);
@ -119,9 +95,8 @@ add_task(async function() {
// that reference patterns defined in the same file or in data: URLs.
await check_use_counter_direct(
"file_use_counter_svg_fill_pattern_internal.svg",
"CSS_PROPERTY_FillOpacity"
"PROPERTY_FILLOPACITY"
);
// data: URLs don't correctly propagate to their referring document yet.
//yield check_use_counter_direct("file_use_counter_svg_fill_pattern_data.svg",
// "PROPERTY_FILL_OPACITY");

View File

@ -1,12 +0,0 @@
<!doctype html>
<style>
div {
background-image: none;
padding: 10px;
-moz-transform: scale(10);
/* Just a property we're unlikely to implement */
-webkit-padding-start: 58.5;
}
</style>
<!-- We currently count even if we don't match it, but well just in case we change that... -->
<div></div>

View File

@ -32,6 +32,12 @@ def read_conf(conf_filename):
'interface_name': interface_name,
'attribute_name': attribute_name }
continue
m = re.match(r'property ([A-Za-z0-9]+)$', line)
if m:
property_name = m.group(1)
yield { 'type': 'property',
'property_name': property_name }
continue
m = re.match(r'custom ([A-Za-z0-9_]+) (.*)$', line)
if m:
name, desc = m.groups()
@ -65,6 +71,9 @@ def generate_histograms(filename):
counter_name = attr.replace('.', '_').upper()
append_counters('%s_getter' % counter_name, 'got %s' % attr)
append_counters('%s_setter' % counter_name, 'set %s' % attr)
elif counter['type'] == 'property':
prop = counter['property_name']
append_counters('PROPERTY_%s' % prop.replace('-', '_').upper(), "used the '%s' property" % prop)
elif counter['type'] == 'custom':
append_counters(counter['name'].upper(), counter['desc'])

View File

@ -1127,13 +1127,23 @@ void MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName,
ParsingMode::AllowUnitlessLength,
mElement->OwnerDoc()->GetCompatibilityMode(), mLoader, {});
// TODO(emilio): If we want to record these from CSSOM more generally, we
// can pass the document use counters down the FFI call. For now manually
// count them for compat with the old code, which is used for testing.
if (changed) {
UseCounter useCounter = nsCSSProps::UseCounterFor(propertyID);
MOZ_ASSERT(useCounter != eUseCounter_UNKNOWN);
mElement->OwnerDoc()->SetUseCounter(useCounter);
// The normal reporting of use counters by the nsCSSParser won't happen
// since it doesn't have a sheet.
if (nsCSSProps::IsShorthand(propertyID)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, propertyID,
CSSEnabledState::ForAllContent) {
UseCounter useCounter = nsCSSProps::UseCounterFor(*subprop);
if (useCounter != eUseCounter_UNKNOWN) {
mElement->OwnerDoc()->SetUseCounter(useCounter);
}
}
} else {
UseCounter useCounter = nsCSSProps::UseCounterFor(propertyID);
if (useCounter != eUseCounter_UNKNOWN) {
mElement->OwnerDoc()->SetUseCounter(useCounter);
}
}
}
return;
}

View File

@ -1,20 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import re
import runpy
import string
def to_camel_case(ident):
return re.sub("(^|_|-)([a-z0-9])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
def generate(output, prop_file):
properties = runpy.run_path(prop_file)["COUNTED_UNKNOWN_PROPERTIES"]
output.write("/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n")
for prop in properties:
output.write("COUNTED_UNKNOWN_PROPERTY({}, {})\n".format(prop, to_camel_case(prop)))

View File

@ -285,7 +285,6 @@ servo_props.inputs = [
if CONFIG['COMPILE_ENVIRONMENT']:
GENERATED_FILES += [
'CompositorAnimatableProperties.h',
'CountedUnknownProperties.h',
'nsComputedDOMStyleGenerated.inc',
'nsCSSPropsGenerated.inc',
'ServoStyleConsts.h',
@ -293,7 +292,6 @@ if CONFIG['COMPILE_ENVIRONMENT']:
EXPORTS.mozilla += [
'!CompositorAnimatableProperties.h',
'!CountedUnknownProperties.h',
'!ServoStyleConsts.h',
]
@ -303,12 +301,6 @@ if CONFIG['COMPILE_ENVIRONMENT']:
'!ServoCSSPropList.py',
]
counted_unknown = GENERATED_FILES['CountedUnknownProperties.h']
counted_unknown.script = 'GenerateCountedUnknownProperties.py:generate'
counted_unknown.inputs = [
'/servo/components/style/properties/counted_unknown_properties.py',
]
computed = GENERATED_FILES['nsComputedDOMStyleGenerated.inc']
computed.script = 'GenerateComputedDOMStyleGenerated.py:generate'
computed.inputs = [

View File

@ -76,15 +76,4 @@ enum nsCSSCounterDesc {
eCSSCounterDesc_COUNT
};
namespace mozilla {
enum class CountedUnknownProperty : uint8_t {
#define COUNTED_UNKNOWN_PROPERTY(name_, method_) method_,
#include "mozilla/CountedUnknownProperties.h"
#undef COUNTED_UNKNOWN_PROPERTY
Count,
};
} // namespace mozilla
#endif /* nsCSSPropertyID_h___ */

View File

@ -337,4 +337,21 @@ bool nsCSSProps::gPropertyEnabled[eCSSProperty_COUNT_with_aliases] = {
#undef IS_ENABLED_BY_DEFAULT
};
#include "../../dom/base/PropertyUseCounterMap.inc"
/* static */ const UseCounter
nsCSSProps::gPropertyUseCounter[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
// Need an extra level of macro nesting to force expansion of method_
// params before they get pasted.
#define CSS_PROP_USE_COUNTER(method_) \
static_cast<UseCounter>(USE_COUNTER_FOR_CSS_PROPERTY_##method_),
#define CSS_PROP_LONGHAND(name_, id_, method_, ...) \
CSS_PROP_USE_COUNTER(method_)
#include "mozilla/ServoCSSPropList.h"
#undef CSS_PROP_LONGHAND
#undef CSS_PROP_USE_COUNTER
#undef CSS_PROP_PUBLIC_OR_PRIVATE
};
#include "nsCSSPropsGenerated.inc"

View File

@ -20,9 +20,9 @@
#include "nsCSSPropertyID.h"
#include "nsStyleStructFwd.h"
#include "nsCSSKeywords.h"
#include "mozilla/UseCounter.h"
#include "mozilla/CSSEnabledState.h"
#include "mozilla/CSSPropFlags.h"
#include "mozilla/UseCounter.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/Preferences.h"
#include "nsXULAppAPI.h"
@ -111,14 +111,6 @@ class nsCSSProps {
// Same but for @font-face descriptors
static nsCSSFontDesc LookupFontDesc(const nsAString& aProperty);
// The relevant invariants are asserted in Document.cpp
static mozilla::UseCounter UseCounterFor(nsCSSPropertyID aProperty) {
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_with_aliases,
"out of range");
return mozilla::UseCounter(size_t(mozilla::eUseCounter_FirstCSSProperty) +
size_t(aProperty));
}
// Given a property enum, get the string value
//
// This string is static.
@ -247,7 +239,18 @@ class nsCSSProps {
return gPropertyEnabled[aProperty];
}
// A table for the use counter associated with each CSS property. If a
// property does not have a use counter defined in UseCounters.conf, then
// its associated entry is |eUseCounter_UNKNOWN|.
static const mozilla::UseCounter
gPropertyUseCounter[eCSSProperty_COUNT_no_shorthands];
public:
static mozilla::UseCounter UseCounterFor(nsCSSPropertyID aProperty) {
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands,
"out of range");
return gPropertyUseCounter[aProperty];
}
static bool IsEnabled(nsCSSPropertyID aProperty, EnabledState aEnabled) {
if (IsEnabled(aProperty)) {

View File

@ -1793,7 +1793,7 @@ impl ToCss for PropertyId {
}
/// The counted unknown property list which is used for css use counters.
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[repr(u8)]
pub enum CountedUnknownProperty {
% for prop in data.counted_unknown_properties:

View File

@ -195,7 +195,6 @@ renaming_overrides_prefixing = true
"nsTArray" = "nsTArray"
"nsPresContext" = "nsPresContext"
"ComputedTiming" = "ComputedTiming"
"CountedUnknownProperty" = "CountedUnknownProperty"
"RefPtr" = "RefPtr"
"nsCSSPropertyID" = "nsCSSPropertyID"
"nsCSSPropertyIDSet" = "nsCSSPropertyIDSet"

View File

@ -6552,23 +6552,6 @@ pub unsafe extern "C" fn Servo_UseCounters_Merge(
doc_counters.merge(sheet_counters)
}
#[no_mangle]
pub unsafe extern "C" fn Servo_IsPropertyIdRecordedInUseCounter(
use_counters: &UseCounters,
id: nsCSSPropertyID,
) -> bool {
let id = NonCustomPropertyId::from_nscsspropertyid(id).unwrap();
use_counters.non_custom_properties.recorded(id)
}
#[no_mangle]
pub unsafe extern "C" fn Servo_IsUnknownPropertyRecordedInUseCounter(
use_counters: &UseCounters,
p: CountedUnknownProperty,
) -> bool {
use_counters.counted_unknown_properties.recorded(p)
}
#[no_mangle]
pub unsafe extern "C" fn Servo_IsCssPropertyRecordedInUseCounter(
use_counters: &UseCounters,

View File

@ -6,7 +6,7 @@ from __future__ import print_function
from mozparsers.shared_telemetry_utils import ParserError
from perfecthash import PerfectHash
PHFSIZE = 1024
PHFSIZE = 512
from mozparsers import parse_histograms
import sys

View File

@ -8,7 +8,6 @@ import json
import math
import os
import re
import runpy
import sys
import atexit
import shared_telemetry_utils as utils
@ -732,52 +731,9 @@ def from_nsDeprecatedOperationList(filename, strict_type_checks):
return histograms
def to_camel_case(property_name):
return re.sub("(^|_|-)([a-z0-9])",
lambda m: m.group(2).upper(),
property_name.strip("_").strip("-"))
def add_css_property_counters(histograms, property_name):
def add_counter(context):
name = 'USE_COUNTER2_CSS_PROPERTY_%s_%s' % (to_camel_case(property_name), context.upper())
histograms[name] = {
'expires_in_version': 'never',
'kind': 'boolean',
'description': 'Whether a %s used the CSS property %s' % (context, property_name)
}
add_counter('document')
add_counter('page')
def from_ServoCSSPropList(filename, strict_type_checks):
histograms = collections.OrderedDict()
properties = runpy.run_path(filename)["data"]
for prop in properties:
add_css_property_counters(histograms, prop.name)
return histograms
def from_counted_unknown_properties(filename, strict_type_checks):
histograms = collections.OrderedDict()
properties = runpy.run_path(filename)["COUNTED_UNKNOWN_PROPERTIES"]
# NOTE(emilio): Unlike ServoCSSProperties, `prop` here is just the property
# name.
#
# We use the same naming as CSS properties so that we don't get
# discontinuity when we implement or prototype them.
for prop in properties:
add_css_property_counters(histograms, prop)
return histograms
FILENAME_PARSERS = [
(lambda x: from_json if x.endswith('.json') else None),
(lambda x: from_nsDeprecatedOperationList if x == 'nsDeprecatedOperationList.h' else None),
(lambda x: from_ServoCSSPropList if x == 'ServoCSSPropList.py' else None),
(lambda x: from_counted_unknown_properties if x == 'counted_unknown_properties.py' else None),
]
# Similarly to the dance above with buildconfig, usecounters may not be

View File

@ -36,14 +36,9 @@ parameter must have the same value of the deprecation note added to the *IDL* fi
See this `changeset <https://hg.mozilla.org/mozilla-central/rev/e30a357b25f1>`_ for a sample
deprecated operation.
CSS Properties
~~~~~~~~~~~~~~
Use counters for CSS properties are generated for every property Gecko supports automatically, and are counted via StyleUseCounters (`Rust code <https://searchfox.org/mozilla-central/rev/7ed8e2d3d1d7a1464ba42763a33fd2e60efcaedc/servo/components/style/use_counters/mod.rs>`_, `C++ code <https://searchfox.org/mozilla-central/rev/7ed8e2d3d1d7a1464ba42763a33fd2e60efcaedc/dom/base/Document.h#5077>`_).
The UseCounters registry
------------------------
Use counters for WebIDL methods/attributes are registered in the `UseCounters.conf <https://dxr.mozilla.org/mozilla-central/source/dom/base/UseCounters.conf>`_ file. The format of this file is very strict. Each line can be:
Use counters for WebIDL methods/attributes and CSS properties are registered in the `UseCounters.conf <https://dxr.mozilla.org/mozilla-central/source/dom/base/UseCounters.conf>`_ file. The format of this file is very strict. Each line can be:
1. a blank line
2. a comment, which is a line that begins with ``//``
@ -51,17 +46,22 @@ Use counters for WebIDL methods/attributes are registered in the `UseCounters.co
* ``method <IDL interface name>.<IDL operation name>``
* ``attribute <IDL interface name>.<IDL attribute name>``
* ``property <CSS property method name>``
* ``custom <any valid identifier> <description>``
CSS properties
~~~~~~~~~~~~~~
The CSS property method name should be identical to the ``method`` argument of ``CSS_PROP()`` and related macros. The only differences are that all hyphens are removed and CamelCase naming is used. See `ServoCSSPropList.h <https://searchfox.org/mozilla-central/source/__GENERATED__/layout/style/ServoCSSPropList.h>`_ for further details.
Custom use counters
~~~~~~~~~~~~~~~~~~~
The <description> for custom counters will be appended to "When a document " or "When a page ", so phrase it appropriately. For instance, "constructs a Foo object" or "calls Document.bar('some value')". It may contain any character (including whitespace). Custom counters are incremented when SetUseCounter(eUseCounter_custom_MyName) is called on a Document object.
The <description> for custom counters will be appended to "When a document " or "When a page ", so phrase it appropriately. For instance, "constructs a Foo object" or "calls Document.bar('some value')". It may contain any character (including whitespace). Custom counters are incremented when SetDocumentAndPageUseCounter(eUseCounter_custom_MyName) is called on an ns(I)Document object.
WebIDL methods and attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Additionally to having a new entry added to the `UseCounters.conf <https://dxr.mozilla.org/mozilla-central/source/dom/base/UseCounters.conf>`_ file, WebIDL methods and attributes must have a ``[UseCounter]`` extended attribute in the Web IDL file in order for the counters to be incremented.
Both additions are required because generating things from bindings codegen and ensuring all the dependencies are correct would have been rather difficult.
Both additions are required because generating things from bindings codegen and ensuring all the dependencies are correct would have been rather difficult, and annotating the WebIDL files does nothing for identifying CSS property usage, which we would also like to track.
The processor script
====================
@ -78,6 +78,7 @@ gen-usecounters.py
------------------
This script is called by the build system to generate:
- the ``PropertyUseCounterMap.inc`` C++ header for the CSS properties;
- the ``UseCounterList.h`` header for the WebIDL, out of the definition files.
Interpreting the data

View File

@ -157,8 +157,6 @@ histogram_files = [
'Histograms.json',
'/dom/base/UseCounters.conf',
'/dom/base/nsDeprecatedOperationList.h',
'!/layout/style/ServoCSSPropList.py',
'/servo/components/style/properties/counted_unknown_properties.py',
]
if CONFIG['MOZ_TELEMETRY_EXTRA_HISTOGRAM_FILES']:
histogram_files.extend(CONFIG['MOZ_TELEMETRY_EXTRA_HISTOGRAM_FILES'])