Bug 1600483 : convert NS_STYLE_RUBY_ALIGN_* to an enum class in nsStyleConsts.h r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D55380

--HG--
extra : moz-landing-system : lando
This commit is contained in:
jeffin143 2019-12-01 13:08:49 +00:00
parent 6e53ecda96
commit 0ed9c7c846
7 changed files with 17 additions and 13 deletions

View File

@ -1659,7 +1659,7 @@ void nsBidiPresUtils::RepositionRubyContentFrame(
aFrame->GetSize(), aBorderPadding.IStart(aFrameWM));
isize += aBorderPadding.IEnd(aFrameWM);
if (aFrame->StyleText()->mRubyAlign == NS_STYLE_RUBY_ALIGN_START) {
if (aFrame->StyleText()->mRubyAlign == StyleRubyAlign::Start) {
return;
}
nscoord residualISize = aFrame->ISize(aFrameWM) - isize;

View File

@ -2658,7 +2658,7 @@ struct nsLineLayout::JustificationComputationState {
};
static bool IsRubyAlignSpaceAround(nsIFrame* aRubyBase) {
return aRubyBase->StyleText()->mRubyAlign == NS_STYLE_RUBY_ALIGN_SPACE_AROUND;
return aRubyBase->StyleText()->mRubyAlign == StyleRubyAlign::SpaceAround;
}
/**
@ -2940,14 +2940,14 @@ void nsLineLayout::ExpandRubyBox(PerFrameData* aFrame, nscoord aReservedISize,
WritingMode lineWM = mRootSpan->mWritingMode;
auto rubyAlign = aFrame->mFrame->StyleText()->mRubyAlign;
switch (rubyAlign) {
case NS_STYLE_RUBY_ALIGN_START:
case StyleRubyAlign::Start:
// do nothing for start
break;
case NS_STYLE_RUBY_ALIGN_SPACE_BETWEEN:
case NS_STYLE_RUBY_ALIGN_SPACE_AROUND: {
case StyleRubyAlign::SpaceBetween:
case StyleRubyAlign::SpaceAround: {
int32_t opportunities = aFrame->mJustificationInfo.mInnerOpportunities;
int32_t gaps = opportunities * 2;
if (rubyAlign == NS_STYLE_RUBY_ALIGN_SPACE_AROUND) {
if (rubyAlign == StyleRubyAlign::SpaceAround) {
// Each expandable ruby box with ruby-align space-around has a
// gap at each of its sides. For rb/rbc, see comment in
// AssignInterframeJustificationGaps; for rt/rtc, see comment
@ -2963,7 +2963,7 @@ void nsLineLayout::ExpandRubyBox(PerFrameData* aFrame, nscoord aReservedISize,
// fall-through to center per spec.
MOZ_FALLTHROUGH;
}
case NS_STYLE_RUBY_ALIGN_CENTER:
case StyleRubyAlign::Center:
// Indent all children by half of the reserved inline size.
for (PerFrameData* child = aFrame->mSpan->mFirstFrame; child;
child = child->mNext) {

View File

@ -101,6 +101,7 @@ rusty-enums = [
"mozilla::StyleUserInput",
"mozilla::StyleBoxDirection",
"mozilla::StyleTextJustify",
"mozilla::StyleRubyAlign",
"mozilla::StyleHyphens",
"mozilla::StyleShapeSourceType",
"mozilla::StyleBasicShapeType",

View File

@ -654,10 +654,12 @@ enum class StyleWhiteSpace : uint8_t {
};
// ruby-align, see nsStyleText
#define NS_STYLE_RUBY_ALIGN_START 0
#define NS_STYLE_RUBY_ALIGN_CENTER 1
#define NS_STYLE_RUBY_ALIGN_SPACE_BETWEEN 2
#define NS_STYLE_RUBY_ALIGN_SPACE_AROUND 3
enum class StyleRubyAlign : uint8_t {
Start,
Center,
SpaceBetween,
SpaceAround,
};
// ruby-position, see nsStyleText
#define NS_STYLE_RUBY_POSITION_OVER 0

View File

@ -3408,7 +3408,7 @@ nsStyleText::nsStyleText(const Document& aDocument)
mTextJustify(StyleTextJustify::Auto),
mWhiteSpace(StyleWhiteSpace::Normal),
mHyphens(StyleHyphens::Manual),
mRubyAlign(NS_STYLE_RUBY_ALIGN_SPACE_AROUND),
mRubyAlign(StyleRubyAlign::SpaceAround),
mRubyPosition(NS_STYLE_RUBY_POSITION_OVER),
mTextSizeAdjust(NS_STYLE_TEXT_SIZE_ADJUST_AUTO),
mTextCombineUpright(NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE),

View File

@ -1146,7 +1146,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText {
public:
mozilla::StyleHyphens mHyphens;
uint8_t mRubyAlign; // NS_STYLE_RUBY_ALIGN_*
mozilla::StyleRubyAlign mRubyAlign;
uint8_t mRubyPosition; // NS_STYLE_RUBY_POSITION_*
uint8_t mTextSizeAdjust; // NS_STYLE_TEXT_SIZE_ADJUST_*
uint8_t mTextCombineUpright; // NS_STYLE_TEXT_COMBINE_UPRIGHT_*

View File

@ -333,6 +333,7 @@ ${helpers.single_keyword(
"space-around start center space-between",
engines="gecko",
animation_value_type="discrete",
gecko_enum_prefix="StyleRubyAlign",
spec="https://drafts.csswg.org/css-ruby/#ruby-align-property",
)}