зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465628 part 1 - Use a static table for property preferences. r=emilio
MozReview-Commit-ID: 7tCdZyAlZc0 --HG-- extra : rebase_source : 80ae9bb4199efa3c7948004d329e617b1f14f154
This commit is contained in:
Родитель
fd0bad6980
Коммит
f9e0542b4d
|
@ -33,9 +33,9 @@ def generate(output, dataFile):
|
|||
|
||||
""")
|
||||
|
||||
properties = runpy.run_path(dataFile)["data"]
|
||||
raw_properties = runpy.run_path(dataFile)["data"]
|
||||
properties = [PropertyWrapper(i, p)
|
||||
for i, p in enumerate(properties)
|
||||
for i, p in enumerate(raw_properties)
|
||||
if p.type() != "alias"]
|
||||
|
||||
# Generate kIDLNameTable
|
||||
|
@ -58,6 +58,20 @@ def generate(output, dataFile):
|
|||
output.write(" {},\n".format(position))
|
||||
output.write("};\n\n")
|
||||
|
||||
# Generate preferences table
|
||||
output.write("const nsCSSProps::PropertyPref "
|
||||
"nsCSSProps::kPropertyPrefTable[] = {\n")
|
||||
for p in raw_properties:
|
||||
if not p.pref:
|
||||
continue
|
||||
if p.type() != "alias":
|
||||
prop_id = "eCSSProperty_" + p.id
|
||||
else:
|
||||
prop_id = "eCSSPropertyAlias_" + p.alias_id
|
||||
output.write(" {{ {}, \"{}\" }},\n".format(prop_id, p.pref))
|
||||
output.write(" { eCSSProperty_UNKNOWN, nullptr },\n")
|
||||
output.write("};\n\n")
|
||||
|
||||
# Generate shorthand subprop tables
|
||||
names = []
|
||||
for p in properties:
|
||||
|
|
|
@ -123,25 +123,11 @@ nsCSSProps::AddRefTable(void)
|
|||
static bool prefObserversInited = false;
|
||||
if (!prefObserversInited) {
|
||||
prefObserversInited = true;
|
||||
|
||||
#define OBSERVE_PROP(pref_, id_) \
|
||||
if (pref_[0]) { \
|
||||
Preferences::AddBoolVarCache(&gPropertyEnabled[id_], \
|
||||
pref_); \
|
||||
}
|
||||
|
||||
#define CSS_PROP_LONGHAND(name_, id_, method_, flags_, pref_) \
|
||||
OBSERVE_PROP(pref_, eCSSProperty_##id_)
|
||||
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) \
|
||||
OBSERVE_PROP(pref_, eCSSProperty_##id_)
|
||||
#define CSS_PROP_ALIAS(name_, aliasid_, id_, method_, pref_) \
|
||||
OBSERVE_PROP(pref_, eCSSPropertyAlias_##aliasid_)
|
||||
#include "mozilla/ServoCSSPropList.h"
|
||||
#undef CSS_PROP_ALIAS
|
||||
#undef CSS_PROP_SHORTHAND
|
||||
#undef CSS_PROP_LONGHAND
|
||||
|
||||
#undef OBSERVE_PROP
|
||||
for (const PropertyPref* pref = kPropertyPrefTable;
|
||||
pref->mPropID != eCSSProperty_UNKNOWN; pref++) {
|
||||
bool* enabled = &gPropertyEnabled[pref->mPropID];
|
||||
Preferences::AddBoolVarCache(enabled, pref->mPref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,6 +247,12 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
struct PropertyPref
|
||||
{
|
||||
nsCSSPropertyID mPropID;
|
||||
const char* mPref;
|
||||
};
|
||||
static const PropertyPref kPropertyPrefTable[];
|
||||
|
||||
// Storing the enabledstate_ value in an nsCSSPropertyID variable is a small hack
|
||||
// to avoid needing a separate variable declaration for its real type
|
||||
|
|
Загрузка…
Ссылка в новой задаче