Bug 1578661 - Report counted unknown properties as well. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D44717

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-09-18 15:15:15 +00:00
parent ae4a64b9cc
commit 4ce6b69adf
10 changed files with 77 additions and 2 deletions

View File

@ -14450,10 +14450,14 @@ bool Document::InlineScriptAllowedByCSP() {
}
// Some use-counter sanity-checking.
static_assert(size_t(eUseCounter_Count) -
static_assert(size_t(eUseCounter_EndCSSProperties) -
size_t(eUseCounter_FirstCSSProperty) ==
size_t(eCSSProperty_COUNT_with_aliases),
"");
static_assert(size_t(eUseCounter_Count) -
size_t(eUseCounter_FirstCountedUnknownProperty) ==
size_t(CountedUnknownProperty::Count),
"");
static_assert(size_t(eUseCounter_Count) * 2 ==
size_t(Telemetry::HistogramUseCounterCount),
"");
@ -14488,6 +14492,13 @@ void Document::SetCssUseCounterBits() {
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));
}
}
}

View File

@ -47,6 +47,14 @@ enum UseCounter : int16_t {
#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

@ -69,6 +69,12 @@ add_task(async function() {
"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

View File

@ -4,6 +4,8 @@
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... -->

View File

@ -0,0 +1,20 @@
# 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,6 +285,7 @@ servo_props.inputs = [
if CONFIG['COMPILE_ENVIRONMENT']:
GENERATED_FILES += [
'CompositorAnimatableProperties.h',
'CountedUnknownProperties.h',
'nsComputedDOMStyleGenerated.inc',
'nsCSSPropsGenerated.inc',
'ServoStyleConsts.h',
@ -292,6 +293,7 @@ if CONFIG['COMPILE_ENVIRONMENT']:
EXPORTS.mozilla += [
'!CompositorAnimatableProperties.h',
'!CountedUnknownProperties.h',
'!ServoStyleConsts.h',
]
@ -301,6 +303,12 @@ 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,4 +76,15 @@ 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

@ -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, Hash, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, PartialEq)]
#[repr(u8)]
pub enum CountedUnknownProperty {
% for prop in data.counted_unknown_properties:

View File

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

View File

@ -6561,6 +6561,14 @@ pub unsafe extern "C" fn Servo_IsPropertyIdRecordedInUseCounter(
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,