mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 968923 - part 3d - record use counter information from the CSS parser; r=dbaron
This commit is contained in:
parent
b624d96ae9
commit
2cb5b9b157
@ -18,12 +18,18 @@
|
||||
//
|
||||
// method <IDL interface name>.<IDL operation name>
|
||||
// attribute <IDL interface name>.<IDL attribute name>
|
||||
// property <CSS property name>
|
||||
// property <CSS property method name>
|
||||
//
|
||||
// The |CSS property method name| should be identical to the |method|
|
||||
// argument to CSS_PROP and related macros. The method name is
|
||||
// identical to the name of the property, except that all hyphens are
|
||||
// removed and CamelCase naming is used. See nsCSSPropList.h for
|
||||
// further details.
|
||||
//
|
||||
// To actually cause use counters to be incremented, DOM methods
|
||||
// and attributes must have a [UseCounter] extended attribute in
|
||||
// the Web IDL file, and CSS properties must be declared with
|
||||
// the CSS_PROPERTY_HAS_USE_COUNTER flag in nsCSSPropList.h.
|
||||
// the Web IDL file. CSS properties require no special treatment
|
||||
// beyond being listed below.
|
||||
//
|
||||
// You might reasonably ask why we have this file and we require
|
||||
// annotating things with [UseCounter] in the relevant WebIDL file as
|
||||
|
@ -45,7 +45,7 @@ def generate_list(f, counters):
|
||||
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.replace('-', '_')), file=f)
|
||||
print('USE_COUNTER_CSS_PROPERTY(%s, %s)' % (prop, prop), file=f)
|
||||
|
||||
print_optional_macro_undeclare('USE_COUNTER_DOM_METHOD')
|
||||
print_optional_macro_undeclare('USE_COUNTER_DOM_ATTRIBUTE')
|
||||
@ -55,19 +55,20 @@ def generate_property_map(f, counters):
|
||||
print(AUTOGENERATED_WARNING_COMMENT, file=f)
|
||||
print('''
|
||||
enum {
|
||||
// XXX is this the right define?
|
||||
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
|
||||
#define CSS_PROP_LIST_INCLUDE_LOGICAL
|
||||
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \\
|
||||
kwtable_, stylestruct_, stylestructoffset_, animtype_) \\
|
||||
USE_COUNTER_FOR_CSS_PROPERTY_##id_ = eUseCounter_UNKNOWN,
|
||||
USE_COUNTER_FOR_CSS_PROPERTY_##method_ = eUseCounter_UNKNOWN,
|
||||
#include "nsCSSPropList.h"
|
||||
#undef CSS_PROP
|
||||
#undef CSS_PROP_LIST_INCLUDE_LOGICAL
|
||||
#undef CSS_PROP_PUBLIC_OR_PRIVATE
|
||||
};
|
||||
''', file=f)
|
||||
for counter in counters:
|
||||
if counter['type'] == 'property':
|
||||
prop = counter['property_name'].replace('-', '_')
|
||||
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):
|
||||
|
@ -41,7 +41,7 @@ def read_conf(conf_filename):
|
||||
'interface_name': interface_name,
|
||||
'attribute_name': attribute_name }
|
||||
continue
|
||||
m = re.match(r'property ([a-z0-9-]+)$', line)
|
||||
m = re.match(r'property ([A-Za-z0-9]+)$', line)
|
||||
if m:
|
||||
property_name = m.group(1)
|
||||
yield { 'type': 'property',
|
||||
|
@ -1183,9 +1183,18 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(aMappedAttrName),
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (propertyID != eCSSProperty_UNKNOWN) {
|
||||
bool changed; // outparam for ParseProperty. (ignored)
|
||||
bool changed = false; // outparam for ParseProperty.
|
||||
mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI,
|
||||
mElement->NodePrincipal(), mDecl, &changed, false, true);
|
||||
if (changed) {
|
||||
// The normal reporting of use counters by the nsCSSParser won't happen
|
||||
// since it doesn't have a sheet.
|
||||
MOZ_ASSERT(!nsCSSProps::IsShorthand(propertyID));
|
||||
UseCounter useCounter = nsCSSProps::UseCounterFor(propertyID);
|
||||
if (useCounter != eUseCounter_UNKNOWN) {
|
||||
mElement->OwnerDoc()->SetDocumentAndPageUseCounter(useCounter);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(aMappedAttrName == nsGkAtoms::lang,
|
||||
|
@ -614,12 +614,14 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
|
||||
bool aIsImportant,
|
||||
bool aOverrideImportant,
|
||||
bool aMustCallValueAppended,
|
||||
css::Declaration* aDeclaration)
|
||||
css::Declaration* aDeclaration,
|
||||
nsIDocument* aSheetDocument)
|
||||
{
|
||||
if (!nsCSSProps::IsShorthand(aPropID)) {
|
||||
return DoTransferFromBlock(aFromBlock, aPropID,
|
||||
aIsImportant, aOverrideImportant,
|
||||
aMustCallValueAppended, aDeclaration);
|
||||
aMustCallValueAppended, aDeclaration,
|
||||
aSheetDocument);
|
||||
}
|
||||
|
||||
// We can pass eIgnoreEnabledState (here, and in ClearProperty above) rather
|
||||
@ -631,7 +633,8 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
|
||||
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, aEnabledState) {
|
||||
changed |= DoTransferFromBlock(aFromBlock, *p,
|
||||
aIsImportant, aOverrideImportant,
|
||||
aMustCallValueAppended, aDeclaration);
|
||||
aMustCallValueAppended, aDeclaration,
|
||||
aSheetDocument);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
@ -642,7 +645,8 @@ nsCSSExpandedDataBlock::DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
|
||||
bool aIsImportant,
|
||||
bool aOverrideImportant,
|
||||
bool aMustCallValueAppended,
|
||||
css::Declaration* aDeclaration)
|
||||
css::Declaration* aDeclaration,
|
||||
nsIDocument* aSheetDocument)
|
||||
{
|
||||
bool changed = false;
|
||||
MOZ_ASSERT(aFromBlock.HasPropertyBit(aPropID), "oops");
|
||||
@ -670,6 +674,13 @@ nsCSSExpandedDataBlock::DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
|
||||
aDeclaration->ValueAppended(aPropID);
|
||||
}
|
||||
|
||||
if (aSheetDocument) {
|
||||
UseCounter useCounter = nsCSSProps::UseCounterFor(aPropID);
|
||||
if (useCounter != eUseCounter_UNKNOWN) {
|
||||
aSheetDocument->SetDocumentAndPageUseCounter(useCounter);
|
||||
}
|
||||
}
|
||||
|
||||
SetPropertyBit(aPropID);
|
||||
aFromBlock.ClearPropertyBit(aPropID);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
struct nsRuleData;
|
||||
class nsCSSExpandedDataBlock;
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
namespace css {
|
||||
@ -249,6 +250,8 @@ public:
|
||||
* Returns true if something changed, false otherwise. Calls
|
||||
* |ValueAppended| on |aDeclaration| if the property was not
|
||||
* previously set, or in any case if |aMustCallValueAppended| is true.
|
||||
* Calls |SetDocumentAndPageUseCounter| on |aSheetDocument| if it is
|
||||
* non-null and |aPropID| has a use counter.
|
||||
*/
|
||||
bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
|
||||
nsCSSProperty aPropID,
|
||||
@ -256,7 +259,8 @@ public:
|
||||
bool aIsImportant,
|
||||
bool aOverrideImportant,
|
||||
bool aMustCallValueAppended,
|
||||
mozilla::css::Declaration* aDeclaration);
|
||||
mozilla::css::Declaration* aDeclaration,
|
||||
nsIDocument* aSheetDocument);
|
||||
|
||||
/**
|
||||
* Copies the values for aPropID into the specified aRuleData object.
|
||||
@ -290,7 +294,8 @@ private:
|
||||
bool aIsImportant,
|
||||
bool aOverrideImportant,
|
||||
bool aMustCallValueAppended,
|
||||
mozilla::css::Declaration* aDeclaration);
|
||||
mozilla::css::Declaration* aDeclaration,
|
||||
nsIDocument* aSheetDocument);
|
||||
|
||||
#ifdef DEBUG
|
||||
void DoAssertInitialState();
|
||||
|
@ -115,6 +115,8 @@ public:
|
||||
|
||||
nsresult SetStyleSheet(CSSStyleSheet* aSheet);
|
||||
|
||||
nsIDocument* GetDocument();
|
||||
|
||||
nsresult SetQuirkMode(bool aQuirkMode);
|
||||
|
||||
nsresult SetChildLoader(mozilla::css::Loader* aChildLoader);
|
||||
@ -1371,6 +1373,15 @@ CSSParserImpl::SetStyleSheet(CSSStyleSheet* aSheet)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
CSSParserImpl::GetDocument()
|
||||
{
|
||||
if (!mSheet) {
|
||||
return nullptr;
|
||||
}
|
||||
return mSheet->GetDocument();
|
||||
}
|
||||
|
||||
nsresult
|
||||
CSSParserImpl::SetQuirkMode(bool aQuirkMode)
|
||||
{
|
||||
@ -1717,7 +1728,8 @@ CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
|
||||
aDeclaration->ExpandTo(&mData);
|
||||
*aChanged = mData.TransferFromBlock(mTempData, aPropID,
|
||||
PropertyEnabledState(), aIsImportant,
|
||||
true, false, aDeclaration);
|
||||
true, false, aDeclaration,
|
||||
GetDocument());
|
||||
aDeclaration->CompressFrom(&mData);
|
||||
}
|
||||
CLEAR_ERROR();
|
||||
@ -6977,7 +6989,7 @@ CSSParserImpl::ParseDeclaration(css::Declaration* aDeclaration,
|
||||
PropertyEnabledState(),
|
||||
status == ePriority_Important,
|
||||
false, aMustCallValueAppended,
|
||||
aDeclaration);
|
||||
aDeclaration, GetDocument());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -2936,6 +2936,21 @@ nsCSSProps::gPropertyEnabled[eCSSProperty_COUNT_with_aliases] = {
|
||||
#undef CSS_PROP_ALIAS
|
||||
};
|
||||
|
||||
#include "../../dom/base/PropertyUseCounterMap.inc"
|
||||
|
||||
/* static */ const UseCounter
|
||||
nsCSSProps::gPropertyUseCounter[eCSSProperty_COUNT_no_shorthands] = {
|
||||
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
|
||||
#define CSS_PROP_LIST_INCLUDE_LOGICAL
|
||||
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
|
||||
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
|
||||
static_cast<UseCounter>(USE_COUNTER_FOR_CSS_PROPERTY_##method_),
|
||||
#include "nsCSSPropList.h"
|
||||
#undef CSS_PROP
|
||||
#undef CSS_PROP_LIST_INCLUDE_LOGICAL
|
||||
#undef CSS_PROP_PUBLIC_OR_PRIVATE
|
||||
};
|
||||
|
||||
// Check that all logical property flags are used appropriately.
|
||||
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
|
||||
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsCSSProperty.h"
|
||||
#include "nsStyleStructFwd.h"
|
||||
#include "nsCSSKeywords.h"
|
||||
#include "mozilla/UseCounter.h"
|
||||
|
||||
// Length of the "--" prefix on custom names (such as custom property names,
|
||||
// and, in the future, custom media query names).
|
||||
@ -516,6 +517,20 @@ public:
|
||||
return gPropertyEnabled[aProperty];
|
||||
}
|
||||
|
||||
private:
|
||||
// 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(nsCSSProperty aProperty) {
|
||||
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands,
|
||||
"out of range");
|
||||
return gPropertyUseCounter[aProperty];
|
||||
}
|
||||
|
||||
static bool IsEnabled(nsCSSProperty aProperty, EnabledState aEnabled)
|
||||
{
|
||||
if (IsEnabled(aProperty)) {
|
||||
|
Loading…
Reference in New Issue
Block a user