зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1083134 - Part 2: Add function that can return which physical box property shorthand a given logical longhand is related to. r=dbaron
This commit is contained in:
Родитель
d973e286a1
Коммит
f9ddcc8210
|
@ -51,6 +51,11 @@
|
|||
keyword table member of class nsCSSProps, for use in
|
||||
nsCSSProps::LookupPropertyValue.
|
||||
|
||||
-. 'boxshorthand_' [used only for CSS_PROP_LOGICAL] is the id of
|
||||
the shorthand property that sets the four sides of the box for which
|
||||
this is a logical property. For example, this would be 'border_color'
|
||||
for 'border-block-start-color'.
|
||||
|
||||
-. 'stylestruct_' [used only for CSS_PROP and CSS_PROP_LOGICAL, not
|
||||
CSS_PROP_*] gives the name of the style struct. Can be used to make
|
||||
nsStyle##stylestruct_ and eStyleStruct_##stylestruct_
|
||||
|
@ -169,12 +174,12 @@
|
|||
|
||||
#ifndef CSS_PROP_LOGICAL
|
||||
#ifdef CSS_PROP_LIST_INCLUDE_LOGICAL
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, struct_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, struct_, stylestructoffset_, animtype_)
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, boxshorthand_, struct_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, struct_, stylestructoffset_, animtype_)
|
||||
#else
|
||||
#ifndef CSS_PROP_LIST_EXCLUDE_LOGICAL
|
||||
#error Must define exactly one of CSS_PROP_LOGICAL, CSS_PROP_LIST_EXCLUDE_LOGICAL and CSS_PROP_LIST_INCLUDE_LOGICAL when capturing properties using CSS_PROP.
|
||||
#endif
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, struct_, stylestructoffset_, animtype_) /* nothing */
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, boxshorthand_, struct_, stylestructoffset_, animtype_) /* nothing */
|
||||
#endif
|
||||
#define DEFINED_CSS_PROP_LOGICAL
|
||||
#endif
|
||||
|
@ -291,7 +296,7 @@
|
|||
#define DEFINED_CSS_PROP_BACKENDONLY
|
||||
#endif
|
||||
#ifndef CSS_PROP_LOGICAL
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, struct_, stylestructoffset_, animtype_) /* nothing */
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, boxshorthand_, struct_, stylestructoffset_, animtype_) /* nothing */
|
||||
#define DEFINED_CSS_PROP_LOGICAL
|
||||
#endif
|
||||
|
||||
|
@ -823,6 +828,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HCK,
|
||||
kBorderColorKTable,
|
||||
border_color,
|
||||
Border,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -837,6 +843,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HK,
|
||||
kBorderStyleKTable,
|
||||
border_style,
|
||||
Border,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -853,6 +860,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HKL | VARIANT_CALC,
|
||||
kBorderWidthKTable,
|
||||
border_width,
|
||||
Border,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -872,6 +880,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HCK,
|
||||
kBorderColorKTable,
|
||||
border_color,
|
||||
Border,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -885,6 +894,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HK,
|
||||
kBorderStyleKTable,
|
||||
border_style,
|
||||
Border,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -900,6 +910,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HKL | VARIANT_CALC,
|
||||
kBorderWidthKTable,
|
||||
border_width,
|
||||
Border,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -2113,6 +2124,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_AHLP | VARIANT_CALC,
|
||||
nullptr,
|
||||
margin,
|
||||
Margin,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -2128,6 +2140,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_AHLP | VARIANT_CALC,
|
||||
nullptr,
|
||||
margin,
|
||||
Margin,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -2456,6 +2469,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HLP | VARIANT_CALC,
|
||||
nullptr,
|
||||
padding,
|
||||
Padding,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
@ -2474,6 +2488,7 @@ CSS_PROP_LOGICAL(
|
|||
"",
|
||||
VARIANT_HLP | VARIANT_CALC,
|
||||
nullptr,
|
||||
padding,
|
||||
Padding,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
|
|
|
@ -2538,6 +2538,39 @@ nsCSSProps::kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shortha
|
|||
};
|
||||
|
||||
|
||||
// Mapping of logical longhand properties to the shorthand that sets the four
|
||||
// corresponding physical properties. The format is pairs of values,
|
||||
// where the first is the logical longhand property and the second is the
|
||||
// shorthand, stored in a flat array (like KTableValue arrays).
|
||||
static const nsCSSProperty gBoxShorthandTable[] = {
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, \
|
||||
kwtable_, boxshorthand_, stylestruct_, \
|
||||
stylestructoffset_, animtype_) \
|
||||
eCSSProperty_##id_, eCSSProperty_##boxshorthand_,
|
||||
#include "nsCSSPropList.h"
|
||||
#undef CSS_PROP_LOGICAL
|
||||
};
|
||||
|
||||
/* static */ nsCSSProperty
|
||||
nsCSSProps::BoxShorthandFor(nsCSSProperty aProperty)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(0 <= aProperty &&
|
||||
aProperty < eCSSProperty_COUNT_no_shorthands,
|
||||
"out of range");
|
||||
NS_ABORT_IF_FALSE(nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_LOGICAL),
|
||||
"aProperty must be a logical longhand property");
|
||||
|
||||
for (size_t i = 0; i < ArrayLength(gBoxShorthandTable); i += 2) {
|
||||
if (gBoxShorthandTable[i] == aProperty) {
|
||||
return gBoxShorthandTable[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
NS_ABORT_IF_FALSE(false, "missing gBoxShorthandTable entry");
|
||||
return eCSSProperty_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
#define ENUM_DATA_FOR_PROPERTY(name_, id_, method_, flags_, pref_, \
|
||||
parsevariant_, kwtable_, stylestructoffset_, \
|
||||
animtype_) \
|
||||
|
@ -2730,8 +2763,8 @@ nsCSSProps::gPropertyIndexInStruct[eCSSProperty_COUNT_no_shorthands] = {
|
|||
parsevariant_, kwtable_) \
|
||||
size_t(-1),
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, \
|
||||
kwtable_, stylestruct_, stylestructoffset_, \
|
||||
animtype_) \
|
||||
kwtable_, boxshorthand_, stylestruct_, \
|
||||
stylestructoffset_, animtype_) \
|
||||
size_t(-1),
|
||||
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
|
||||
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
|
||||
|
@ -2778,8 +2811,8 @@ nsCSSProps::gPropertyEnabled[eCSSProperty_COUNT_with_aliases] = {
|
|||
"only properties defined with CSS_PROP_LOGICAL can use " \
|
||||
"the CSS_PROPERTY_LOGICAL_END_EDGE flag");
|
||||
#define CSS_PROP_LOGICAL(name_, id_, method_, flags_, pref_, parsevariant_, \
|
||||
kwtable_, stylestruct_, stylestructoffset_, \
|
||||
animtype_) \
|
||||
kwtable_, boxshorthand_, stylestruct_, \
|
||||
stylestructoffset_, animtype_) \
|
||||
static_assert((flags_) & CSS_PROPERTY_LOGICAL, \
|
||||
"properties defined with CSS_PROP_LOGICAL must also use " \
|
||||
"the CSS_PROPERTY_LOGICAL flag"); \
|
||||
|
|
|
@ -471,6 +471,19 @@ public:
|
|||
return gPropertyIndexInStruct[aProperty];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shorthand property which sets the four physical box side
|
||||
* properties for which the argument is one of the corresponding logical
|
||||
* box properties. For example, given eCSSProperty_margin_block_start,
|
||||
* returns eCSSProperty_margin.
|
||||
*
|
||||
* (Note that the running time of this function is proportional to the
|
||||
* number of logical longhand properties that exist. If we start
|
||||
* getting too many of these properties, we should make gBoxShorthandTable
|
||||
* be a simple array of eCSSProperty_COUNT length.)
|
||||
*/
|
||||
static nsCSSProperty BoxShorthandFor(nsCSSProperty aProperty);
|
||||
|
||||
private:
|
||||
static bool gPropertyEnabled[eCSSProperty_COUNT_with_aliases];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче