Bug 1448526 part 2 - Make nsStyleStructList.h not generated. r=emilio

nsStyleStructList.h was initially made generated in bug 873368 to avoid
manually maintaining boilerplate for if-dispatch, while the if-dispatch
was replaced by jump table in bug 1171842, so the boilerplate went away.

However, in bug 1122781 (before bug 1171842), boilerplate for dependency
check, so it still needs to be generated.

The dependency table is removed in the previous patch, so we no longer
have any boilerplate in the style struct list, and thus it doesn't need
to be generated anymore.

MozReview-Commit-ID: GkbJZ98ojbE

--HG--
extra : rebase_source : a148b97c051bb6c88846cf6ba617c4edef70ca24
extra : source : f1c7d19cde195fb90ac2627d16ed69d020de01b9
This commit is contained in:
Xidorn Quan 2018-03-26 20:09:17 +11:00
parent 9d334f6911
commit 051a0fc278
16 changed files with 178 additions and 287 deletions

View File

@ -512,7 +512,7 @@ CollectWindowReports(nsGlobalWindowInner *aWindow,
// This is the Servo style structs.
size_t servoStyleSundriesSize = 0;
#define STYLE_STRUCT(name_, cb_) \
#define STYLE_STRUCT(name_) \
{ \
size_t size = windowSizes.mServoStyleSizes.NS_STYLE_SIZES_FIELD(name_); \
if (size < STYLE_SUNDRIES_THRESHOLD) { \
@ -737,7 +737,7 @@ nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
"This is the sum of all windows' 'layout/frames/' numbers.");
size_t servoStyleTotal = 0;
#define STYLE_STRUCT(name_, cb_) \
#define STYLE_STRUCT(name_) \
servoStyleTotal += \
windowTotalSizes.mServoStyleSizes.NS_STYLE_SIZES_FIELD(name_);
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES

View File

@ -52,7 +52,7 @@ struct nsStyleSizes
{
nsStyleSizes()
:
#define STYLE_STRUCT(name_, cb_) \
#define STYLE_STRUCT(name_) \
NS_STYLE_SIZES_FIELD(name_)(0),
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
#include "nsStyleStructList.h"
@ -64,7 +64,7 @@ struct nsStyleSizes
void addToTabSizes(nsTabSizes* aSizes) const
{
#define STYLE_STRUCT(name_, cb_) \
#define STYLE_STRUCT(name_) \
aSizes->add(nsTabSizes::Style, NS_STYLE_SIZES_FIELD(name_));
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
#include "nsStyleStructList.h"
@ -76,7 +76,7 @@ struct nsStyleSizes
{
size_t total = 0;
#define STYLE_STRUCT(name_, cb_) \
#define STYLE_STRUCT(name_) \
total += NS_STYLE_SIZES_FIELD(name_);
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
#include "nsStyleStructList.h"
@ -86,7 +86,7 @@ struct nsStyleSizes
return total;
}
#define STYLE_STRUCT(name_, cb_) \
#define STYLE_STRUCT(name_) \
size_t NS_STYLE_SIZES_FIELD(name_);
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
#include "nsStyleStructList.h"

View File

@ -832,19 +832,18 @@ public:
* Callers can use Style*WithOptionalParam if they're in a function that
* accepts an *optional* pointer the style struct.
*/
#define STYLE_STRUCT(name_, checkdata_cb_) \
const nsStyle##name_ * Style##name_ () const MOZ_NONNULL_RETURN { \
NS_ASSERTION(mComputedStyle, "No style found!"); \
return mComputedStyle->Style##name_ (); \
} \
const nsStyle##name_ * Style##name_##WithOptionalParam( \
const nsStyle##name_ * aStyleStruct) const \
MOZ_NONNULL_RETURN { \
if (aStyleStruct) { \
MOZ_ASSERT(aStyleStruct == Style##name_()); \
return aStyleStruct; \
} \
return Style##name_(); \
#define STYLE_STRUCT(name_) \
const nsStyle##name_ * Style##name_ () const MOZ_NONNULL_RETURN { \
NS_ASSERTION(mComputedStyle, "No style found!"); \
return mComputedStyle->Style##name_ (); \
} \
const nsStyle##name_ * Style##name_##WithOptionalParam( \
const nsStyle##name_ * aStyleStruct) const MOZ_NONNULL_RETURN { \
if (aStyleStruct) { \
MOZ_ASSERT(aStyleStruct == Style##name_()); \
return aStyleStruct; \
} \
return Style##name_(); \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT

View File

@ -50,14 +50,14 @@ namespace mozilla {
// in nsStyleStructList.h, since when we set up the IDs, we include
// the inherited and reset structs spearately from nsStyleStructList.h
enum DebugStyleStruct {
#define STYLE_STRUCT(name, checkdata_cb) eDebugStyleStruct_##name,
#define STYLE_STRUCT(name) eDebugStyleStruct_##name,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
};
#define STYLE_STRUCT(name, checkdata_cb) \
#define STYLE_STRUCT(name) \
static_assert(static_cast<int>(eDebugStyleStruct_##name) == \
static_cast<int>(eStyleStruct_##name), \
static_cast<int>(eStyleStruct_##name), \
"Style struct IDs are not declared in order?");
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -194,10 +194,10 @@ ComputedStyle::CalcStyleDifference(ComputedStyle* aNewContext,
#ifdef DEBUG
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
#define STYLE_STRUCT(name_, callback_) \
MOZ_ASSERT(!!(structsFound & NS_STYLE_INHERIT_BIT(name_)) == \
(PEEK(name_) != nullptr), \
"PeekStyleData results must not change in the middle of " \
#define STYLE_STRUCT(name_) \
MOZ_ASSERT(!!(structsFound & NS_STYLE_INHERIT_BIT(name_)) == \
(PEEK(name_) != nullptr), \
"PeekStyleData results must not change in the middle of " \
"difference calculation.");
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -406,8 +406,8 @@ ComputedStyle::CombineVisitedColors(nscolor *aColors, bool aLinkIsVisited)
ComputedStyle::StructName(nsStyleStructID aSID)
{
switch (aSID) {
#define STYLE_STRUCT(name_, checkdata_cb) \
case eStyleStruct_##name_: \
#define STYLE_STRUCT(name_) \
case eStyleStruct_##name_: \
return #name_;
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -421,8 +421,8 @@ ComputedStyle::LookupStruct(const nsACString& aName, nsStyleStructID& aResult)
{
if (false)
;
#define STYLE_STRUCT(name_, checkdata_cb_) \
else if (aName.EqualsLiteral(#name_)) \
#define STYLE_STRUCT(name_) \
else if (aName.EqualsLiteral(#name_)) \
aResult = eStyleStruct_##name_;
#include "nsStyleStructList.h"
#undef STYLE_STRUCT

View File

@ -253,7 +253,7 @@ public:
* const nsStyleBorder* StyleBorder();
* const nsStyleColor* StyleColor();
*/
#define STYLE_STRUCT(name_, checkdata_cb_) \
#define STYLE_STRUCT(name_) \
inline const nsStyle##name_ * Style##name_() MOZ_NONNULL_RETURN;
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -265,7 +265,7 @@ public:
* this style struct. Use with care.
*/
#define STYLE_STRUCT(name_, checkdata_cb_) \
#define STYLE_STRUCT(name_) \
inline const nsStyle##name_ * ThreadsafeStyle##name_();
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -278,7 +278,7 @@ public:
*
* Perhaps this shouldn't be a public ComputedStyle API.
*/
#define STYLE_STRUCT(name_, checkdata_cb_) \
#define STYLE_STRUCT(name_) \
inline const nsStyle##name_ * PeekStyle##name_();
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -380,11 +380,11 @@ protected:
CachedInheritingStyles mCachedInheritingStyles;
// Helper functions for GetStyle* and PeekStyle*
#define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \
template<bool aComputeData> \
#define STYLE_STRUCT_INHERITED(name_) \
template<bool aComputeData> \
const nsStyle##name_ * DoGetStyle##name_();
#define STYLE_STRUCT_RESET(name_, checkdata_cb_) \
template<bool aComputeData> \
#define STYLE_STRUCT_RESET(name_) \
template<bool aComputeData> \
const nsStyle##name_ * DoGetStyle##name_();
#include "nsStyleStructList.h"

View File

@ -21,61 +21,61 @@
namespace mozilla {
#define STYLE_STRUCT(name_, checkdata_cb_) \
const nsStyle##name_ * \
ComputedStyle::Style##name_() { \
return DoGetStyle##name_<true>(); \
} \
const nsStyle##name_ * \
ComputedStyle::ThreadsafeStyle##name_() { \
if (mozilla::ServoStyleSet::IsInServoTraversal()) { \
return ComputedData()->GetStyle##name_(); \
} \
return Style##name_(); \
} \
const nsStyle##name_ * ComputedStyle::PeekStyle##name_() { \
return DoGetStyle##name_<false>(); \
#define STYLE_STRUCT(name_) \
const nsStyle##name_ * \
ComputedStyle::Style##name_() { \
return DoGetStyle##name_<true>(); \
} \
const nsStyle##name_ * \
ComputedStyle::ThreadsafeStyle##name_() { \
if (mozilla::ServoStyleSet::IsInServoTraversal()) { \
return ComputedData()->GetStyle##name_(); \
} \
return Style##name_(); \
} \
const nsStyle##name_ * ComputedStyle::PeekStyle##name_() { \
return DoGetStyle##name_<false>(); \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
// Helper functions for GetStyle* and PeekStyle*
#define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \
template<bool aComputeData> \
#define STYLE_STRUCT_INHERITED(name_) \
template<bool aComputeData> \
const nsStyle##name_ * ComputedStyle::DoGetStyle##name_() { \
const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_)); \
if (!aComputeData && needToCompute) { \
return nullptr; \
} \
\
const nsStyle##name_* data = ComputedData()->GetStyle##name_(); \
\
/* perform any remaining main thread work on the struct */ \
if (needToCompute) { \
MOZ_ASSERT(NS_IsMainThread()); \
MOZ_ASSERT(!mozilla::ServoStyleSet::IsInServoTraversal()); \
const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext(), nullptr); \
/* the ComputedStyle owns the struct */ \
AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \
} \
return data; \
const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_)); \
if (!aComputeData && needToCompute) { \
return nullptr; \
} \
\
const nsStyle##name_* data = ComputedData()->GetStyle##name_(); \
\
/* perform any remaining main thread work on the struct */ \
if (needToCompute) { \
MOZ_ASSERT(NS_IsMainThread()); \
MOZ_ASSERT(!mozilla::ServoStyleSet::IsInServoTraversal()); \
const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext(), nullptr); \
/* the ComputedStyle owns the struct */ \
AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \
} \
return data; \
}
#define STYLE_STRUCT_RESET(name_, checkdata_cb_) \
template<bool aComputeData> \
const nsStyle##name_ * ComputedStyle::DoGetStyle##name_() { \
const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_)); \
if (!aComputeData && needToCompute) { \
return nullptr; \
} \
const nsStyle##name_* data = ComputedData()->GetStyle##name_(); \
/* perform any remaining main thread work on the struct */ \
if (needToCompute) { \
const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext(), nullptr); \
/* the ComputedStyle owns the struct */ \
AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \
} \
return data; \
#define STYLE_STRUCT_RESET(name_) \
template<bool aComputeData> \
const nsStyle##name_ * ComputedStyle::DoGetStyle##name_() { \
const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_)); \
if (!aComputeData && needToCompute) { \
return nullptr; \
} \
const nsStyle##name_* data = ComputedData()->GetStyle##name_(); \
/* perform any remaining main thread work on the struct */ \
if (needToCompute) { \
const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext(), nullptr); \
/* the ComputedStyle owns the struct */ \
AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \
} \
return data; \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_RESET
@ -96,7 +96,7 @@ ComputedStyle::ResolveSameStructsAs(const ComputedStyle* aOther)
uint64_t otherBits = aOther->mBits & NS_STYLE_INHERIT_MASK;
uint64_t newBits = otherBits & ~ourBits & NS_STYLE_INHERIT_MASK;
#define STYLE_STRUCT(name_, checkdata_cb) \
#define STYLE_STRUCT(name_) \
if (nsStyle##name_::kHasFinishStyle && \
(newBits & NS_STYLE_INHERIT_BIT(name_))) { \
const nsStyle##name_* data = ComputedData()->GetStyle##name_(); \

View File

@ -220,7 +220,7 @@ ServoComputedData::AddSizeOfExcludingThis(nsWindowSizes& aSizes) const
// to measure it with a function that can handle an interior pointer. We use
// ServoStyleStructsEnclosingMallocSizeOf to clearly identify in DMD's
// output the memory measured here.
#define STYLE_STRUCT(name_, cb_) \
#define STYLE_STRUCT(name_) \
static_assert(alignof(nsStyle##name_) <= sizeof(size_t), \
"alignment will break AddSizeOfExcludingThis()"); \
const void* p##name_ = GetStyle##name_(); \
@ -2630,7 +2630,7 @@ NS_IMPL_FFI_REFCOUNTING(nsCSSCounterStyleRule, CSSCounterStyleRule);
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
#define STYLE_STRUCT(name, checkdata_cb) \
#define STYLE_STRUCT(name) \
\
void \
Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \

View File

@ -82,12 +82,12 @@ const bool GECKO_IS_NIGHTLY = false;
#endif
namespace mozilla {
#define STYLE_STRUCT(name_, checkdata_cb_) struct Gecko##name_ {nsStyle##name_ gecko;};
#define STYLE_STRUCT(name_) struct Gecko##name_ {nsStyle##name_ gecko;};
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
}
#define STYLE_STRUCT(name_, checkdata_cb_) \
#define STYLE_STRUCT(name_) \
const nsStyle##name_* ServoComputedData::GetStyle##name_() const { return &name_.mPtr->gecko; }
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
#include "nsStyleStructList.h"
@ -657,12 +657,12 @@ void Gecko_AddPropertyToSet(nsCSSPropertyIDSetBorrowedMut, nsCSSPropertyID);
int32_t Gecko_RegisterNamespace(nsAtom* ns);
// Style-struct management.
#define STYLE_STRUCT(name, checkdata_cb) \
void Gecko_Construct_Default_nsStyle##name( \
nsStyle##name* ptr, \
RawGeckoPresContextBorrowed pres_context); \
void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
const nsStyle##name* other); \
#define STYLE_STRUCT(name) \
void Gecko_Construct_Default_nsStyle##name( \
nsStyle##name* ptr, \
RawGeckoPresContextBorrowed pres_context); \
void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
const nsStyle##name* other); \
void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
#include "nsStyleStructList.h"
#undef STYLE_STRUCT

View File

@ -9,7 +9,7 @@
#include "mozilla/TypedEnumBits.h"
#define STYLE_STRUCT(name_, checkdata_cb_) struct nsStyle##name_;
#define STYLE_STRUCT(name_) struct nsStyle##name_;
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -163,7 +163,7 @@ struct ServoComputedValueFlags {
uint16_t mFlags;
};
#define STYLE_STRUCT(name_, checkdata_cb_) struct Gecko##name_;
#define STYLE_STRUCT(name_) struct Gecko##name_;
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
@ -216,7 +216,7 @@ public:
// Constructs via memcpy. Will not move out of aValue.
explicit ServoComputedData(const ServoComputedDataForgotten aValue);
#define STYLE_STRUCT(name_, checkdata_cb_) \
#define STYLE_STRUCT(name_) \
mozilla::ServoRawOffsetArc<mozilla::Gecko##name_> name_; \
inline const nsStyle##name_* GetStyle##name_() const;
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES

View File

@ -1,169 +0,0 @@
#!/usr/bin/env python
# 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/.
# This script generates nsStyleStructList.h, which contains macro invocations
# that can be used for three things:
#
# 1. To generate code for each inherited style struct.
# 2. To generate code for each reset style struct.
# 3. To generate the dependency of each style struct.
from __future__ import print_function
import math
NORMAL_DEP = ["Variables"]
COLOR_DEP = ["Color"]
LENGTH_DEP = ["Font", "Visibility"]
# List of style structs and their corresponding Check callback functions,
# if any.
STYLE_STRUCTS = [("INHERITED",) + x for x in [
# Inherited style structs.
("Font", "CheckFontCallback", NORMAL_DEP + ["Visibility"]),
("Color", "CheckColorCallback", NORMAL_DEP),
("List", "nullptr", NORMAL_DEP + LENGTH_DEP),
("Text", "CheckTextCallback", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("Visibility", "nullptr", NORMAL_DEP),
("UserInterface", "nullptr", NORMAL_DEP),
("TableBorder", "nullptr", NORMAL_DEP + LENGTH_DEP),
("SVG", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("Variables", "CheckVariablesCallback",[]),
]] + [("RESET",) + x for x in [
# Reset style structs.
("Background", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("Position", "nullptr", NORMAL_DEP + LENGTH_DEP),
("TextReset", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("Display", "nullptr", NORMAL_DEP + LENGTH_DEP),
("Content", "nullptr", NORMAL_DEP + LENGTH_DEP),
("UIReset", "nullptr", NORMAL_DEP + LENGTH_DEP),
("Table", "nullptr", NORMAL_DEP),
("Margin", "nullptr", NORMAL_DEP + LENGTH_DEP),
("Padding", "nullptr", NORMAL_DEP + LENGTH_DEP),
("Border", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("Outline", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("XUL", "nullptr", NORMAL_DEP),
("SVGReset", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("Column", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
("Effects", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP),
]]
# ---- Generate nsStyleStructList.h ----
count = len(STYLE_STRUCTS)
# Check for problems with style struct dependencies
resolved_items = []
# This whole loop tries to sort the style structs in topological order
# according to the dependencies. A topological order exists iff there
# are no cyclic dependencies between the style structs. It resolves one
# struct each iteration, and append the resolved one to |resolved_items|.
for i in range(count):
# This inner loop picks one style struct which does not have
# unsolved dependencies. If nothing can be picked, then we
# must have some cyclic dependencies.
for j in range(count):
_, name, _, dependencies = STYLE_STRUCTS[j]
if name in resolved_items:
continue
# Check whether all dependencies of this item have been placed
for dep in dependencies:
if dep not in resolved_items:
break
else:
resolved_items.append(name)
break
else:
import sys
print("ERROR: Cannot resolve style struct dependencies", file=sys.stderr)
print("Resolved items:", " ".join(resolved_items), file=sys.stderr)
unsolved_items = [name for _, name, _, _ in STYLE_STRUCTS
if name not in resolved_items]
print("There exist cyclic dependencies between " +
"the following structs:", " ".join(unsolved_items), file=sys.stderr)
exit(1)
def printEntry(header, i):
if STYLE_STRUCTS[i][1] == "Variables":
print("#ifndef STYLE_STRUCT_LIST_IGNORE_VARIABLES", file=header)
print("STYLE_STRUCT_%s(%s, %s)" % STYLE_STRUCTS[i][:3], file=header)
for dep in STYLE_STRUCTS[i][3]:
print("STYLE_STRUCT_DEP(%s)" % (dep,), file=header)
print("STYLE_STRUCT_END()", file=header)
if STYLE_STRUCTS[i][1] == "Variables":
print("#endif", file=header)
HEADER = """/* THIS FILE IS AUTOGENERATED BY generate-stylestructlist.py - DO NOT EDIT */
// IWYU pragma: private, include "nsStyleStructFwd.h"
/*
* list of structs that contain the data provided by ComputedStyle, the
* internal API for computed style data for an element
*/
/*
* This file is intended to be used by different parts of the code, with
* the STYLE_STRUCT macro (or the STYLE_STRUCT_INHERITED and
* STYLE_STRUCT_RESET pair of macros) defined in different ways.
*/
#ifndef STYLE_STRUCT_INHERITED
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \\
STYLE_STRUCT(name, checkdata_cb)
#define UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifndef STYLE_STRUCT_RESET
#define STYLE_STRUCT_RESET(name, checkdata_cb) \\
STYLE_STRUCT(name, checkdata_cb)
#define UNDEF_STYLE_STRUCT_RESET
#endif
#ifndef STYLE_STRUCT_DEP
#define STYLE_STRUCT_DEP(dep)
#define UNDEF_STYLE_STRUCT_DEP
#endif
#ifndef STYLE_STRUCT_END
#define STYLE_STRUCT_END()
#define UNDEF_STYLE_STRUCT_END
#endif
// The inherited structs are listed before the Reset structs.
// nsStyleStructID assumes this is the case, and callers other than
// nsStyleStructFwd.h that want the structs in id-order just define
// STYLE_STRUCT rather than including the file twice.
"""
FOOTER = """
#ifdef UNDEF_STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_INHERITED
#undef UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifdef UNDEF_STYLE_STRUCT_RESET
#undef STYLE_STRUCT_RESET
#undef UNDEF_STYLE_STRUCT_RESET
#endif
#ifdef UNDEF_STYLE_STRUCT_DEP
#undef STYLE_STRUCT_DEP
#undef UNDEF_STYLE_STRUCT_DEP
#endif
#ifdef UNDEF_STYLE_STRUCT_END
#undef STYLE_STRUCT_END
#undef UNDEF_STYLE_STRUCT_END
#endif
"""
def main(header):
print(HEADER, file=header)
for i in range(count):
printEntry(header, i)
print(FOOTER, file=header)

View File

@ -23,7 +23,6 @@ DIRS += ['xbl-marquee']
TEST_DIRS += ['test']
EXPORTS += [
'!nsStyleStructList.h',
'AnimationCommon.h',
'CounterStyleManager.h',
'nsAnimationManager.h',
@ -62,6 +61,7 @@ EXPORTS += [
'nsStyleStruct.h',
'nsStyleStructFwd.h',
'nsStyleStructInlines.h',
'nsStyleStructList.h',
'nsStyleTransformMatrix.h',
'nsStyleUtil.h',
'nsTimingFunction.h',
@ -280,13 +280,6 @@ CONTENT_ACCESSIBLE_FILES += [
'TopLevelVideoDocument.css',
]
GENERATED_FILES += [
'nsStyleStructList.h',
]
style_struct_list = GENERATED_FILES['nsStyleStructList.h']
style_struct_list.script = 'generate-stylestructlist.py'
if CONFIG['COMPILE_ENVIRONMENT']:
GENERATED_FILES += [
'nsCSSPropsGenerated.inc',

View File

@ -3287,8 +3287,7 @@ enum EffectsCheckCounter {
/* static */ const size_t
nsCSSProps::gPropertyCountInStruct[nsStyleStructID_Length] = {
#define STYLE_STRUCT(name, checkdata_cb) \
ePropertyCount_for_##name,
#define STYLE_STRUCT(name) ePropertyCount_for_##name,
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
};

View File

@ -176,9 +176,9 @@ private:
nsIPresShell* aPresShell,
StyleType aStyleType);
#define STYLE_STRUCT(name_, checkdata_cb_) \
const nsStyle##name_ * Style##name_() { \
return mComputedStyle->Style##name_(); \
#define STYLE_STRUCT(name_) \
const nsStyle##name_ * Style##name_() { \
return mComputedStyle->Style##name_(); \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT

View File

@ -57,7 +57,7 @@ static_assert((((1 << nsStyleStructID_Length) - 1) &
// are allocated by Servo side with Arc, the total size doesn't exceed
// 512 bytes, which minimizes allocator slop.
static constexpr size_t kStyleStructSizeLimit = 504;
#define STYLE_STRUCT(name_, checkdata_cb_) \
#define STYLE_STRUCT(name_) \
static_assert(sizeof(nsStyle##name_) <= kStyleStructSizeLimit, \
"nsStyle" #name_ " became larger than the size limit");
#include "nsStyleStructList.h"

View File

@ -29,9 +29,8 @@ nsStyleStructID_Inherited_Start = 0,
// a dummy value so the value after it is the same as ..._Inherited_Start
nsStyleStructID_DUMMY1 = nsStyleStructID_Inherited_Start - 1,
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
eStyleStruct_##name,
#define STYLE_STRUCT_RESET(name, checkdata_cb)
#define STYLE_STRUCT_INHERITED(name) eStyleStruct_##name,
#define STYLE_STRUCT_RESET(name)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET
@ -40,9 +39,8 @@ nsStyleStructID_Reset_Start,
// a dummy value so the value after it is the same as ..._Reset_Start
nsStyleStructID_DUMMY2 = nsStyleStructID_Reset_Start - 1,
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
eStyleStruct_##name,
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
#define STYLE_STRUCT_RESET(name) eStyleStruct_##name,
#define STYLE_STRUCT_INHERITED(name)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_RESET

View File

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
// IWYU pragma: private, include "nsStyleStructFwd.h"
/*
* list of structs that contain the data provided by ComputedStyle, the
* internal API for computed style data for an element
*/
/*
* This file is intended to be used by different parts of the code, with
* the STYLE_STRUCT macro (or the STYLE_STRUCT_INHERITED and
* STYLE_STRUCT_RESET pair of macros) defined in different ways.
*/
#ifndef STYLE_STRUCT_INHERITED
#define STYLE_STRUCT_INHERITED(name) STYLE_STRUCT(name)
#define UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifndef STYLE_STRUCT_RESET
#define STYLE_STRUCT_RESET(name) STYLE_STRUCT(name)
#define UNDEF_STYLE_STRUCT_RESET
#endif
// The inherited structs are listed before the Reset structs.
// nsStyleStructID assumes this is the case, and callers other than
// nsStyleStructFwd.h that want the structs in id-order just define
// STYLE_STRUCT rather than including the file twice.
STYLE_STRUCT_INHERITED(Font)
STYLE_STRUCT_INHERITED(Color)
STYLE_STRUCT_INHERITED(List)
STYLE_STRUCT_INHERITED(Text)
STYLE_STRUCT_INHERITED(Visibility)
STYLE_STRUCT_INHERITED(UserInterface)
STYLE_STRUCT_INHERITED(TableBorder)
STYLE_STRUCT_INHERITED(SVG)
#ifndef STYLE_STRUCT_LIST_IGNORE_VARIABLES
STYLE_STRUCT_INHERITED(Variables)
#endif
STYLE_STRUCT_RESET(Background)
STYLE_STRUCT_RESET(Position)
STYLE_STRUCT_RESET(TextReset)
STYLE_STRUCT_RESET(Display)
STYLE_STRUCT_RESET(Content)
STYLE_STRUCT_RESET(UIReset)
STYLE_STRUCT_RESET(Table)
STYLE_STRUCT_RESET(Margin)
STYLE_STRUCT_RESET(Padding)
STYLE_STRUCT_RESET(Border)
STYLE_STRUCT_RESET(Outline)
STYLE_STRUCT_RESET(XUL)
STYLE_STRUCT_RESET(SVGReset)
STYLE_STRUCT_RESET(Column)
STYLE_STRUCT_RESET(Effects)
#ifdef UNDEF_STYLE_STRUCT_INHERITED
#undef STYLE_STRUCT_INHERITED
#undef UNDEF_STYLE_STRUCT_INHERITED
#endif
#ifdef UNDEF_STYLE_STRUCT_RESET
#undef STYLE_STRUCT_RESET
#undef UNDEF_STYLE_STRUCT_RESET
#endif