Bug 1055676 part 1 - Parse and compute ruby-align property. r=heycam

This commit is contained in:
Xidorn Quan 2015-02-17 18:01:49 +13:00
parent e5f09dac11
commit 2c07f7ae12
11 changed files with 57 additions and 0 deletions

View File

@ -3030,6 +3030,16 @@ CSS_PROP_POSITION(
nullptr,
offsetof(nsStylePosition, mOffset),
eStyleAnimType_Sides_Right)
CSS_PROP_TEXT(
ruby-align,
ruby_align,
RubyAlign,
CSS_PROPERTY_PARSE_VALUE,
"layout.css.ruby.enabled",
VARIANT_HK,
kRubyAlignKTable,
offsetof(nsStyleText, mRubyAlign),
eStyleAnimType_EnumU8)
CSS_PROP_TEXT(
ruby-position,
ruby_position,

View File

@ -1623,6 +1623,14 @@ const KTableValue nsCSSProps::kResizeKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
const KTableValue nsCSSProps::kRubyAlignKTable[] = {
eCSSKeyword_start, NS_STYLE_RUBY_ALIGN_START,
eCSSKeyword_center, NS_STYLE_RUBY_ALIGN_CENTER,
eCSSKeyword_space_between, NS_STYLE_RUBY_ALIGN_SPACE_BETWEEN,
eCSSKeyword_space_around, NS_STYLE_RUBY_ALIGN_SPACE_AROUND,
eCSSKeyword_UNKNOWN, -1
};
const KTableValue nsCSSProps::kRubyPositionKTable[] = {
eCSSKeyword_over, NS_STYLE_RUBY_POSITION_OVER,
eCSSKeyword_under, NS_STYLE_RUBY_POSITION_UNDER,

View File

@ -667,6 +667,7 @@ public:
static const KTableValue kRadialGradientSizeKTable[];
static const KTableValue kRadialGradientLegacySizeKTable[];
static const KTableValue kResizeKTable[];
static const KTableValue kRubyAlignKTable[];
static const KTableValue kRubyPositionKTable[];
static const KTableValue kScrollBehaviorKTable[];
static const KTableValue kSpeakKTable[];

View File

@ -3081,6 +3081,15 @@ nsComputedDOMStyle::DoGetLineHeight()
return val;
}
CSSValue*
nsComputedDOMStyle::DoGetRubyAlign()
{
nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
val->SetIdent(nsCSSProps::ValueToKeywordEnum(
StyleText()->mRubyAlign, nsCSSProps::kRubyAlignKTable));
return val;
}
CSSValue*
nsComputedDOMStyle::DoGetRubyPosition()
{

View File

@ -374,6 +374,7 @@ private:
/* Text Properties */
mozilla::dom::CSSValue* DoGetLineHeight();
mozilla::dom::CSSValue* DoGetRubyAlign();
mozilla::dom::CSSValue* DoGetRubyPosition();
mozilla::dom::CSSValue* DoGetTextAlign();
mozilla::dom::CSSValue* DoGetTextAlignLast();

View File

@ -197,6 +197,7 @@ COMPUTED_STYLE_PROP(position, Position)
COMPUTED_STYLE_PROP(quotes, Quotes)
COMPUTED_STYLE_PROP(resize, Resize)
COMPUTED_STYLE_PROP(right, Right)
COMPUTED_STYLE_PROP(ruby_align, RubyAlign)
COMPUTED_STYLE_PROP(ruby_position, RubyPosition)
COMPUTED_STYLE_PROP(scroll_behavior, ScrollBehavior)
//// COMPUTED_STYLE_PROP(size, Size)

View File

@ -4304,6 +4304,13 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
parentText->mHyphens,
NS_STYLE_HYPHENS_MANUAL, 0, 0, 0, 0);
// ruby-align: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForRubyAlign(),
text->mRubyAlign, canStoreInRuleTree,
SETDSC_ENUMERATED | SETDSC_UNSET_INHERIT,
parentText->mRubyAlign,
NS_STYLE_RUBY_ALIGN_SPACE_AROUND, 0, 0, 0, 0);
// ruby-position: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForRubyPosition(),
text->mRubyPosition, canStoreInRuleTree,

View File

@ -840,6 +840,12 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_HYPHENS_MANUAL 1
#define NS_STYLE_HYPHENS_AUTO 2
// 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
// ruby-position, see nsStyleText
#define NS_STYLE_RUBY_POSITION_OVER 0
#define NS_STYLE_RUBY_POSITION_UNDER 1

View File

@ -3351,6 +3351,7 @@ nsStyleText::nsStyleText(void)
mWordBreak = NS_STYLE_WORDBREAK_NORMAL;
mWordWrap = NS_STYLE_WORDWRAP_NORMAL;
mHyphens = NS_STYLE_HYPHENS_MANUAL;
mRubyAlign = NS_STYLE_RUBY_ALIGN_SPACE_AROUND;
mRubyPosition = NS_STYLE_RUBY_POSITION_OVER;
mTextSizeAdjust = NS_STYLE_TEXT_SIZE_ADJUST_AUTO;
mTextCombineUpright = NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE;
@ -3375,6 +3376,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
mWordBreak(aSource.mWordBreak),
mWordWrap(aSource.mWordWrap),
mHyphens(aSource.mHyphens),
mRubyAlign(aSource.mRubyAlign),
mRubyPosition(aSource.mRubyPosition),
mTextSizeAdjust(aSource.mTextSizeAdjust),
mTextCombineUpright(aSource.mTextCombineUpright),
@ -3416,6 +3418,7 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
(mWordBreak != aOther.mWordBreak) ||
(mWordWrap != aOther.mWordWrap) ||
(mHyphens != aOther.mHyphens) ||
(mRubyAlign != aOther.mRubyAlign) ||
(mRubyPosition != aOther.mRubyPosition) ||
(mTextSizeAdjust != aOther.mTextSizeAdjust) ||
(mLetterSpacing != aOther.mLetterSpacing) ||

View File

@ -1596,6 +1596,7 @@ struct nsStyleText {
uint8_t mWordBreak; // [inherited] see nsStyleConsts.h
uint8_t mWordWrap; // [inherited] see nsStyleConsts.h
uint8_t mHyphens; // [inherited] see nsStyleConsts.h
uint8_t mRubyAlign; // [inherited] see nsStyleConsts.h
uint8_t mRubyPosition; // [inherited] see nsStyleConsts.h
uint8_t mTextSizeAdjust; // [inherited] see nsStyleConsts.h
uint8_t mTextCombineUpright; // [inherited] see nsStyleConsts.h

View File

@ -5702,6 +5702,16 @@ if (SpecialPowers.getBoolPref("layout.css.ruby.enabled")) {
"ruby-base-container",
"ruby-text",
"ruby-text-container");
gCSSProperties["ruby-align"] = {
domProp: "rubyAlign",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "space-around" ],
other_values: [ "start", "center", "space-between" ],
invalid_values: [
"end", "1", "10px", "50%", "start center"
]
};
gCSSProperties["ruby-position"] = {
domProp: "rubyPosition",
inherited: true,