diff --git a/layout/style/nsStyleStructFwd.h b/layout/style/nsStyleStructFwd.h index 9d32c08c6e97..b6e93d2f28fc 100644 --- a/layout/style/nsStyleStructFwd.h +++ b/layout/style/nsStyleStructFwd.h @@ -50,15 +50,42 @@ enum nsStyleStructID { * * The C++ standard, section 7.2, guarantees that enums begin with 0 and * increase by 1. + * + * We separate the IDs of Reset and Inherited structs so that we can use + * the IDs as indices (offset by nsStyleStructID_*_Start) into arrays of + * one type or the other. */ -#define STYLE_STRUCT(name, checkdata_cb, ctor_args) eStyleStruct_##name, +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, ctor_args) \ + eStyleStruct_##name, +#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) #include "nsStyleStructList.h" -#undef STYLE_STRUCT +#undef STYLE_STRUCT_INHERITED +#undef STYLE_STRUCT_RESET + +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, ctor_args) \ + eStyleStruct_##name, +#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) +#include "nsStyleStructList.h" +#undef STYLE_STRUCT_INHERITED +#undef STYLE_STRUCT_RESET // one past the end; length of 0-based list nsStyleStructID_Length, +nsStyleStructID_Inherited_Count = + nsStyleStructID_Reset_Start - nsStyleStructID_Inherited_Start, +nsStyleStructID_Reset_Count = + nsStyleStructID_Length - nsStyleStructID_Reset_Start, + // An ID used for properties that are not in style structs. This is // used only in some users of nsStyleStructID, such as // nsCSSProps::kSIDTable, including some that store SIDs in a bitfield, diff --git a/layout/style/nsStyleStructList.h b/layout/style/nsStyleStructList.h index 45f5fae8bd72..cb5be533e584 100644 --- a/layout/style/nsStyleStructList.h +++ b/layout/style/nsStyleStructList.h @@ -66,6 +66,11 @@ #define STYLE_STRUCT_TEST_CODE(c) #endif +// The inherited structs must be 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_TEST_CODE(if (STYLE_STRUCT_TEST < 8) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 4) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 2) {) @@ -76,23 +81,23 @@ STYLE_STRUCT_INHERITED(Color, CheckColorCallback, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 2) {) -STYLE_STRUCT_RESET(Background, nsnull, ()) - STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_INHERITED(List, nsnull, ()) + STYLE_STRUCT_TEST_CODE( } else {) +STYLE_STRUCT_INHERITED(Text, CheckTextCallback, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 6) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 4) {) -STYLE_STRUCT_RESET(Position, nsnull, ()) +STYLE_STRUCT_INHERITED(Visibility, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_INHERITED(Text, CheckTextCallback, ()) +STYLE_STRUCT_INHERITED(Quotes, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 6) {) -STYLE_STRUCT_RESET(TextReset, nsnull, ()) +STYLE_STRUCT_INHERITED(UserInterface, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_RESET(Display, nsnull, ()) +STYLE_STRUCT_INHERITED(TableBorder, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) @@ -100,49 +105,49 @@ STYLE_STRUCT_RESET(Display, nsnull, ()) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 12) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 10) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 8) {) -STYLE_STRUCT_INHERITED(Visibility, nsnull, (SSARG_PRESCONTEXT)) +STYLE_STRUCT_INHERITED(SVG, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_RESET(Content, nsnull, ()) +STYLE_STRUCT_RESET(Background, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 10) {) -STYLE_STRUCT_INHERITED(Quotes, nsnull, ()) +STYLE_STRUCT_RESET(Position, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_INHERITED(UserInterface, nsnull, ()) +STYLE_STRUCT_RESET(TextReset, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 14) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 12) {) -STYLE_STRUCT_RESET(UIReset, nsnull, ()) +STYLE_STRUCT_RESET(Display, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_RESET(Table, nsnull, ()) +STYLE_STRUCT_RESET(Content, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 14) {) -STYLE_STRUCT_INHERITED(TableBorder, nsnull, (SSARG_PRESCONTEXT)) +STYLE_STRUCT_RESET(UIReset, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_RESET(Margin, nsnull, ()) +STYLE_STRUCT_RESET(Table, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE(} else if (STYLE_STRUCT_TEST < 20) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 18) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 16) {) -STYLE_STRUCT_RESET(Padding, nsnull, ()) +STYLE_STRUCT_RESET(Margin, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_RESET(Border, nsnull, (SSARG_PRESCONTEXT)) +STYLE_STRUCT_RESET(Padding, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 18) {) -STYLE_STRUCT_RESET(Outline, nsnull, (SSARG_PRESCONTEXT)) +STYLE_STRUCT_RESET(Border, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( } else {) -STYLE_STRUCT_RESET(XUL, nsnull, ()) +STYLE_STRUCT_RESET(Outline, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE(} else if (STYLE_STRUCT_TEST < 22) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 20) {) -STYLE_STRUCT_INHERITED(SVG, nsnull, ()) +STYLE_STRUCT_RESET(XUL, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_RESET(SVGReset,nsnull, ()) STYLE_STRUCT_TEST_CODE( })