Bug 1578661 - Fix use counter test. r=boris

By reporting the properties in MappedAttrParser that we used to (the test relies
on counting those), and by adjusting the histogram name to the new thing.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-09-18 12:04:37 +00:00
parent e1882a044c
commit 959c99b520
3 changed files with 22 additions and 4 deletions

View File

@ -76,18 +76,18 @@ add_task(async function() {
// check for properties here.
await check_use_counter_img(
"file_use_counter_svg_getElementById.svg",
"PROPERTY_FILL"
"CSS_PROPERTY_Fill"
);
await check_use_counter_img(
"file_use_counter_svg_currentScale.svg",
"PROPERTY_FILL"
"CSS_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",
"PROPERTY_FILLOPACITY",
"CSS_PROPERTY_FillOpacity",
/*xfail=*/ true
);
@ -95,7 +95,7 @@ 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",
"PROPERTY_FILLOPACITY"
"CSS_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",

View File

@ -1126,6 +1126,15 @@ void MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName,
mDecl->Raw(), propertyID, &value, false, data,
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);
}
return;
}
MOZ_ASSERT(aMappedAttrName == nsGkAtoms::lang,

View File

@ -20,6 +20,7 @@
#include "nsCSSPropertyID.h"
#include "nsStyleStructFwd.h"
#include "nsCSSKeywords.h"
#include "mozilla/UseCounter.h"
#include "mozilla/CSSEnabledState.h"
#include "mozilla/CSSPropFlags.h"
#include "mozilla/EnumTypeTraits.h"
@ -110,6 +111,14 @@ 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.