Backed out changeset e37fab919847 (bug 1743150) for causing linux build bustage in layout/style/nsComputedDOMStyle. CLOSED TREE

This commit is contained in:
Sandor Molnar 2021-12-01 13:03:47 +02:00
Родитель 085009fb70
Коммит c0280a84f2
2 изменённых файлов: 33 добавлений и 72 удалений

Просмотреть файл

@ -4,33 +4,21 @@
import runpy
FILE = """/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
def generate(output, dataFile):
output.write(
"""/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
/* processed file that defines entries for nsComputedDOMStyle, designed
to be #included in nsComputedDOMStyle.cpp */
// We use designated initializers for simplicity.
// They're legal in C++20 so it's a matter of time we can remove this.
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc99-designator"
#endif
static constexpr size_t kEntryIndices[eCSSProperty_COUNT] = {{
{indices}
}};
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
static constexpr Entry kEntries[eCSSProperty_COUNT] = {{
{entries}
}};
static constexpr Entry kEntries[] = {
"""
)
def exposed_on_getcs(p):
return "ExposedOnGetCS" in p.flags
def generate(output, dataFile):
def order_key(p):
# Put prefixed properties after normal properties.
# The spec is unclear about this, and Blink doesn't have any sensible
@ -40,8 +28,6 @@ def generate(output, dataFile):
return (order, p.name)
def has_cpp_getter(p):
if not "ExposedOnGetCS" in p.flags:
return False
if "SerializedByServo" in p.flags:
return False
if p.type() == "longhand" and "IsLogical" in p.flags:
@ -57,20 +43,10 @@ def generate(output, dataFile):
return "DummyGetter"
properties = runpy.run_path(dataFile)["data"]
properties = filter(exposed_on_getcs, properties)
entries = []
indices = []
non_aliases = filter(lambda p: p.type() != "alias", properties)
for i, p in enumerate(sorted(non_aliases, key=order_key)):
indices.append("[eCSSProperty_{}] = {}".format(p.id, i))
can_be_exposed = "true" if "ExposedOnGetCS" in p.flags else "false"
entries.append(
"{{ eCSSProperty_{}, {}, &nsComputedDOMStyle::{}}}".format(
p.id, can_be_exposed, getter_entry(p)
)
)
i += 1
TEMPLATE = " {{ eCSSProperty_{}, &nsComputedDOMStyle::{} }},\n"
for p in sorted(properties, key=order_key):
output.write(TEMPLATE.format(p.id, getter_entry(p)))
output.write(
FILE.format(indices=", ".join(indices), entries=",\n ".join(entries))
)
output.write("};\n")

Просмотреть файл

@ -206,24 +206,13 @@ struct ComputedStyleMap {
struct Entry {
// Create a pointer-to-member-function type.
using ComputeMethod = already_AddRefed<CSSValue> (nsComputedDOMStyle::*)();
typedef already_AddRefed<CSSValue> (nsComputedDOMStyle::*ComputeMethod)();
nsCSSPropertyID mProperty;
// Whether the property can ever be exposed in getComputedStyle(). For
// example, @page descriptors implemented as CSS properties or other
// internal properties, would have this flag set to `false`.
bool mCanBeExposed = false;
ComputeMethod mGetter = nullptr;
bool IsEnumerable() const {
return IsEnabled() && !nsCSSProps::IsShorthand(mProperty);
}
ComputeMethod mGetter;
bool IsEnabled() const {
if (!mCanBeExposed ||
!nsCSSProps::IsEnabled(mProperty, CSSEnabledState::ForAllContent)) {
if (!nsCSSProps::IsEnabled(mProperty, CSSEnabledState::ForAllContent)) {
return false;
}
if (nsCSSProps::IsShorthand(mProperty) &&
@ -245,7 +234,7 @@ struct ComputedStyleMap {
*/
uint32_t Length() {
Update();
return mEnumerablePropertyCount;
return mExposedPropertyCount;
}
/**
@ -264,23 +253,21 @@ struct ComputedStyleMap {
* or is currently disabled.
*/
const Entry* FindEntryForProperty(nsCSSPropertyID aPropID) {
if (size_t(aPropID) >= ArrayLength(kEntryIndices)) {
MOZ_ASSERT(aPropID == eCSSProperty_UNKNOWN);
return nullptr;
Update();
for (uint32_t i = 0; i < mExposedPropertyCount; i++) {
const Entry* entry = &kEntries[EntryIndex(i)];
if (entry->mProperty == aPropID) {
return entry;
}
}
MOZ_ASSERT(kEntryIndices[aPropID] < ArrayLength(kEntries));
const auto& entry = kEntries[kEntryIndices[aPropID]];
if (!entry.IsEnabled()) {
return nullptr;
}
return &entry;
return nullptr;
}
/**
* Records that mIndexMap needs updating, due to prefs changing that could
* affect the set of properties exposed on an nsComputedDOMStyle.
*/
void MarkDirty() { mEnumerablePropertyCount = 0; }
void MarkDirty() { mExposedPropertyCount = 0; }
// The member variables are public so that we can use an initializer in
// nsComputedDOMStyle::GetComputedStyleMap. Use the member functions
@ -292,7 +279,7 @@ struct ComputedStyleMap {
* prefs are disabled. A value of 0 indicates that it and mIndexMap are out
* of date.
*/
uint32_t mEnumerablePropertyCount = 0;
uint32_t mExposedPropertyCount;
/**
* A map of indexes on the nsComputedDOMStyle object to indexes into kEntries.
@ -301,13 +288,13 @@ struct ComputedStyleMap {
private:
/**
* Returns whether mEnumerablePropertyCount and mIndexMap are out of date.
* Returns whether mExposedPropertyCount and mIndexMap are out of date.
*/
bool IsDirty() { return mEnumerablePropertyCount == 0; }
bool IsDirty() { return mExposedPropertyCount == 0; }
/**
* Updates mEnumerablePropertyCount and mIndexMap to take into account
* properties whose prefs are currently disabled.
* Updates mExposedPropertyCount and mIndexMap to take into account properties
* whose prefs are currently disabled.
*/
void Update();
@ -315,7 +302,7 @@ struct ComputedStyleMap {
* Maps an nsComputedDOMStyle indexed getter index to an index into kEntries.
*/
uint32_t EntryIndex(uint32_t aIndex) const {
MOZ_ASSERT(aIndex < mEnumerablePropertyCount);
MOZ_ASSERT(aIndex < mExposedPropertyCount);
return mIndexMap[aIndex];
}
};
@ -323,8 +310,6 @@ struct ComputedStyleMap {
constexpr ComputedStyleMap::Entry
ComputedStyleMap::kEntries[ArrayLength(kEntries)];
constexpr size_t ComputedStyleMap::kEntryIndices[ArrayLength(kEntries)];
void ComputedStyleMap::Update() {
if (!IsDirty()) {
return;
@ -332,11 +317,11 @@ void ComputedStyleMap::Update() {
uint32_t index = 0;
for (uint32_t i = 0; i < ArrayLength(kEntries); i++) {
if (kEntries[i].IsEnumerable()) {
if (kEntries[i].IsEnabled()) {
mIndexMap[index++] = i;
}
}
mEnumerablePropertyCount = index;
mExposedPropertyCount = index;
}
nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,