Bug 1297982 - Replace NS_STYLE_BOX_ALIGN_* with enum class; r=xidorn

MozReview-Commit-ID: EO8hXmXooft

--HG--
extra : rebase_source : ef1e01a373964d5cb7207f87e14e85a9a1dab7fd
This commit is contained in:
Ravi Shankar 2016-08-26 12:39:19 +05:30
Родитель 9c0325a862
Коммит ca8ee9dc38
7 изменённых файлов: 31 добавлений и 28 удалений

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

@ -124,15 +124,15 @@ ConvertLegacyStyleToAlignItems(const nsStyleXUL* aStyleXUL)
{
// -[moz|webkit]-box-align corresponds to modern "align-items"
switch (aStyleXUL->mBoxAlign) {
case NS_STYLE_BOX_ALIGN_STRETCH:
case StyleBoxAlign::Stretch:
return NS_STYLE_ALIGN_STRETCH;
case NS_STYLE_BOX_ALIGN_START:
case StyleBoxAlign::Start:
return NS_STYLE_ALIGN_FLEX_START;
case NS_STYLE_BOX_ALIGN_CENTER:
case StyleBoxAlign::Center:
return NS_STYLE_ALIGN_CENTER;
case NS_STYLE_BOX_ALIGN_BASELINE:
case StyleBoxAlign::Baseline:
return NS_STYLE_ALIGN_BASELINE;
case NS_STYLE_BOX_ALIGN_END:
case StyleBoxAlign::End:
return NS_STYLE_ALIGN_FLEX_END;
}

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

@ -2242,11 +2242,11 @@ const KTableEntry nsCSSProps::kWritingModeKTable[] = {
// Specific keyword tables for XUL.properties
const KTableEntry nsCSSProps::kBoxAlignKTable[] = {
{ eCSSKeyword_stretch, NS_STYLE_BOX_ALIGN_STRETCH },
{ eCSSKeyword_start, NS_STYLE_BOX_ALIGN_START },
{ eCSSKeyword_center, NS_STYLE_BOX_ALIGN_CENTER },
{ eCSSKeyword_baseline, NS_STYLE_BOX_ALIGN_BASELINE },
{ eCSSKeyword_end, NS_STYLE_BOX_ALIGN_END },
{ eCSSKeyword_stretch, StyleBoxAlign::Stretch },
{ eCSSKeyword_start, StyleBoxAlign::Start },
{ eCSSKeyword_center, StyleBoxAlign::Center },
{ eCSSKeyword_baseline, StyleBoxAlign::Baseline },
{ eCSSKeyword_end, StyleBoxAlign::End },
{ eCSSKeyword_UNKNOWN, -1 }
};

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

@ -1334,6 +1334,7 @@ struct SetEnumValueHelper
aField = static_cast<type_>(value); \
}
DEFINE_ENUM_CLASS_SETTER(StyleBoxAlign, Stretch, End)
DEFINE_ENUM_CLASS_SETTER(StyleBoxSizing, Content, Border)
DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd)
DEFINE_ENUM_CLASS_SETTER(StyleFloat, None_, InlineEnd)
@ -9090,7 +9091,7 @@ nsRuleNode::ComputeXULData(void* aStartStruct,
xul->mBoxAlign, conditions,
SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
parentXUL->mBoxAlign,
NS_STYLE_BOX_ALIGN_STRETCH);
StyleBoxAlign::Stretch);
// box-direction: enum, inherit, initial
SetValue(*aRuleData->ValueForBoxDirection(),

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

@ -62,6 +62,15 @@ enum class StyleBasicShapeType : uint8_t {
Inset,
};
// box-align
enum class StyleBoxAlign : uint8_t {
Stretch,
Start,
Center,
Baseline,
End,
};
// box-sizing
enum class StyleBoxSizing : uint8_t {
Content,
@ -168,13 +177,6 @@ enum class StyleUserSelect : uint8_t {
#define NS_STYLE_WINDOW_DRAGGING_DRAG 1
#define NS_STYLE_WINDOW_DRAGGING_NO_DRAG 2
// box-align
#define NS_STYLE_BOX_ALIGN_STRETCH 0
#define NS_STYLE_BOX_ALIGN_START 1
#define NS_STYLE_BOX_ALIGN_CENTER 2
#define NS_STYLE_BOX_ALIGN_BASELINE 3
#define NS_STYLE_BOX_ALIGN_END 4
// box-pack
#define NS_STYLE_BOX_PACK_START 0
#define NS_STYLE_BOX_PACK_CENTER 1

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

@ -828,7 +828,7 @@ nsStyleList::sNoneQuotes;
nsStyleXUL::nsStyleXUL(StyleStructContext aContext)
: mBoxFlex(0.0f)
, mBoxOrdinal(1)
, mBoxAlign(NS_STYLE_BOX_ALIGN_STRETCH)
, mBoxAlign(StyleBoxAlign::Stretch)
, mBoxDirection(NS_STYLE_BOX_DIRECTION_NORMAL)
, mBoxOrient(NS_STYLE_BOX_ORIENT_HORIZONTAL)
, mBoxPack(NS_STYLE_BOX_PACK_START)

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

@ -3429,7 +3429,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleXUL
float mBoxFlex; // [reset] see nsStyleConsts.h
uint32_t mBoxOrdinal; // [reset] see nsStyleConsts.h
uint8_t mBoxAlign; // [reset] see nsStyleConsts.h
mozilla::StyleBoxAlign mBoxAlign; // [reset]
uint8_t mBoxDirection; // [reset] see nsStyleConsts.h
uint8_t mBoxOrient; // [reset] see nsStyleConsts.h
uint8_t mBoxPack; // [reset] see nsStyleConsts.h

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

@ -353,13 +353,13 @@ nsBoxFrame::GetInitialHAlignment(nsBoxFrame::Halignment& aHalign)
}
else {
switch (boxInfo->mBoxAlign) {
case NS_STYLE_BOX_ALIGN_START:
case StyleBoxAlign::Start:
aHalign = nsBoxFrame::hAlign_Left;
return true;
case NS_STYLE_BOX_ALIGN_CENTER:
case StyleBoxAlign::Center:
aHalign = nsBoxFrame::hAlign_Center;
return true;
case NS_STYLE_BOX_ALIGN_END:
case StyleBoxAlign::End:
aHalign = nsBoxFrame::hAlign_Right;
return true;
default: // Nonsensical value. Just bail.
@ -413,16 +413,16 @@ nsBoxFrame::GetInitialVAlignment(nsBoxFrame::Valignment& aValign)
const nsStyleXUL* boxInfo = StyleXUL();
if (IsXULHorizontal()) {
switch (boxInfo->mBoxAlign) {
case NS_STYLE_BOX_ALIGN_START:
case StyleBoxAlign::Start:
aValign = nsBoxFrame::vAlign_Top;
return true;
case NS_STYLE_BOX_ALIGN_CENTER:
case StyleBoxAlign::Center:
aValign = nsBoxFrame::vAlign_Middle;
return true;
case NS_STYLE_BOX_ALIGN_BASELINE:
case StyleBoxAlign::Baseline:
aValign = nsBoxFrame::vAlign_BaseLine;
return true;
case NS_STYLE_BOX_ALIGN_END:
case StyleBoxAlign::End:
aValign = nsBoxFrame::vAlign_Bottom;
return true;
default: // Nonsensical value. Just bail.
@ -547,7 +547,7 @@ nsBoxFrame::GetInitialAutoStretch(bool& aStretch)
// Check the CSS box-align property.
const nsStyleXUL* boxInfo = StyleXUL();
aStretch = (boxInfo->mBoxAlign == NS_STYLE_BOX_ALIGN_STRETCH);
aStretch = (boxInfo->mBoxAlign == StyleBoxAlign::Stretch);
return true;
}