mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1578661 - Remove old CSS use counters. r=boris
We only have two counters enabled, just for testing, and they just count from the SVG mapped attribute code. That's not great, and they mostly complicate the next few patches. Differential Revision: https://phabricator.services.mozilla.com/D44695 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d88a4a0a4b
commit
31755a845c
@ -17,12 +17,10 @@ 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_,
|
||||
|
@ -16,12 +16,8 @@
|
||||
//
|
||||
// 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
|
||||
@ -29,21 +25,17 @@
|
||||
//
|
||||
// To actually cause use counters to be incremented, DOM methods
|
||||
// and attributes must have a [UseCounter] extended attribute in
|
||||
// the Web IDL file. CSS properties require no special treatment
|
||||
// beyond being listed below. Custom counters are incremented when
|
||||
// the Web IDL file.
|
||||
// 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, and
|
||||
// annotating the WebIDL files does nothing for identifying CSS
|
||||
// property usage, which we would also like to track.
|
||||
// dependencies were correct would have been rather difficult.
|
||||
|
||||
method SVGSVGElement.getElementById
|
||||
attribute SVGSVGElement.currentScale
|
||||
property Fill
|
||||
property FillOpacity
|
||||
attribute XMLDocument.async
|
||||
|
||||
// Push API
|
||||
|
@ -36,7 +36,6 @@ 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:
|
||||
@ -44,44 +43,14 @@ 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)
|
||||
|
@ -540,14 +540,9 @@ 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']
|
||||
|
@ -32,12 +32,6 @@ 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()
|
||||
@ -71,9 +65,6 @@ 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'])
|
||||
|
||||
|
@ -1126,25 +1126,6 @@ void MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName,
|
||||
mDecl->Raw(), propertyID, &value, false, data,
|
||||
ParsingMode::AllowUnitlessLength,
|
||||
mElement->OwnerDoc()->GetCompatibilityMode(), mLoader, {});
|
||||
|
||||
if (changed) {
|
||||
// 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;
|
||||
}
|
||||
MOZ_ASSERT(aMappedAttrName == nsGkAtoms::lang,
|
||||
|
@ -337,21 +337,4 @@ 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"
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "nsCSSKeywords.h"
|
||||
#include "mozilla/CSSEnabledState.h"
|
||||
#include "mozilla/CSSPropFlags.h"
|
||||
#include "mozilla/UseCounter.h"
|
||||
#include "mozilla/EnumTypeTraits.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
@ -239,18 +238,7 @@ 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)) {
|
||||
|
@ -38,7 +38,7 @@ deprecated operation.
|
||||
|
||||
The UseCounters registry
|
||||
------------------------
|
||||
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:
|
||||
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:
|
||||
|
||||
1. a blank line
|
||||
2. a comment, which is a line that begins with ``//``
|
||||
@ -46,13 +46,8 @@ Use counters for WebIDL methods/attributes and CSS properties are registered in
|
||||
|
||||
* ``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 SetDocumentAndPageUseCounter(eUseCounter_custom_MyName) is called on an ns(I)Document object.
|
||||
@ -61,7 +56,7 @@ 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, and annotating the WebIDL files does nothing for identifying CSS property usage, which we would also like to track.
|
||||
Both additions are required because generating things from bindings codegen and ensuring all the dependencies are correct would have been rather difficult.
|
||||
|
||||
The processor script
|
||||
====================
|
||||
@ -78,7 +73,6 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user