mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-04 22:37:29 +09:00
moebius#90: CSS - implement text-justify property
This commit is contained in:
parent
5677db4b6e
commit
1f262f0d2b
26 changed files with 312 additions and 9 deletions
|
|
@ -238,6 +238,7 @@ CSS_KEY(disc, disc)
|
|||
CSS_KEY(disclosure-closed, disclosure_closed)
|
||||
CSS_KEY(disclosure-open, disclosure_open)
|
||||
CSS_KEY(discretionary-ligatures, discretionary_ligatures)
|
||||
CSS_KEY(distribute, distribute)
|
||||
CSS_KEY(dot, dot)
|
||||
CSS_KEY(dotted, dotted)
|
||||
CSS_KEY(double, double)
|
||||
|
|
@ -333,7 +334,8 @@ CSS_KEY(inline-start, inline_start)
|
|||
CSS_KEY(inline-table, inline_table)
|
||||
CSS_KEY(inset, inset)
|
||||
CSS_KEY(inside, inside)
|
||||
// CSS_KEY(inter-character, inter_character) // TODO see bug 1055672
|
||||
CSS_KEY(inter-character, inter_character)
|
||||
CSS_KEY(inter-word, inter_word)
|
||||
CSS_KEY(interpolatematrix, interpolatematrix)
|
||||
CSS_KEY(intersect, intersect)
|
||||
CSS_KEY(isolate, isolate)
|
||||
|
|
|
|||
|
|
@ -4027,6 +4027,17 @@ CSS_PROP_TEXT(
|
|||
nullptr,
|
||||
offsetof(nsStyleText, mTextIndent),
|
||||
eStyleAnimType_Coord)
|
||||
CSS_PROP_TEXT(
|
||||
text-justify,
|
||||
text_justify,
|
||||
TextJustify,
|
||||
CSS_PROPERTY_PARSE_VALUE |
|
||||
CSS_PROPERTY_APPLIES_TO_PLACEHOLDER,
|
||||
"layout.css.text-justify.enabled",
|
||||
VARIANT_HK,
|
||||
kTextJustifyKTable,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_Discrete)
|
||||
CSS_PROP_VISIBILITY(
|
||||
text-orientation,
|
||||
text_orientation,
|
||||
|
|
|
|||
|
|
@ -2035,6 +2035,17 @@ KTableEntry nsCSSProps::kTextAlignLastKTable[] = {
|
|||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kTextJustifyKTable[] = {
|
||||
{ eCSSKeyword_none, StyleTextJustify::None },
|
||||
{ eCSSKeyword_auto, StyleTextJustify::Auto },
|
||||
{ eCSSKeyword_inter_word, StyleTextJustify::InterWord },
|
||||
{ eCSSKeyword_inter_character, StyleTextJustify::InterCharacter },
|
||||
// For legacy reasons, UAs must also support the keyword "distribute" with
|
||||
// the exact same meaning and behavior as "inter-character".
|
||||
{ eCSSKeyword_distribute, StyleTextJustify::InterCharacter },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kTextCombineUprightKTable[] = {
|
||||
{ eCSSKeyword_none, NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE },
|
||||
{ eCSSKeyword_all, NS_STYLE_TEXT_COMBINE_UPRIGHT_ALL },
|
||||
|
|
|
|||
|
|
@ -869,6 +869,7 @@ public:
|
|||
static const KTableEntry kTextEmphasisPositionKTable[];
|
||||
static const KTableEntry kTextEmphasisStyleFillKTable[];
|
||||
static const KTableEntry kTextEmphasisStyleShapeKTable[];
|
||||
static const KTableEntry kTextJustifyKTable[];
|
||||
static const KTableEntry kTextOrientationKTable[];
|
||||
static const KTableEntry kTextOverflowKTable[];
|
||||
static const KTableEntry kTextTransformKTable[];
|
||||
|
|
|
|||
|
|
@ -3874,6 +3874,16 @@ nsComputedDOMStyle::DoGetTextIndent()
|
|||
return val.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::DoGetTextJustify()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
val->SetIdent(
|
||||
nsCSSProps::ValueToKeywordEnum(StyleText()->mTextJustify,
|
||||
nsCSSProps::kTextJustifyKTable));
|
||||
return val.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::DoGetTextOrientation()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -421,6 +421,7 @@ private:
|
|||
already_AddRefed<CSSValue> DoGetTextEmphasisPosition();
|
||||
already_AddRefed<CSSValue> DoGetTextEmphasisStyle();
|
||||
already_AddRefed<CSSValue> DoGetTextIndent();
|
||||
already_AddRefed<CSSValue> DoGetTextJustify();
|
||||
already_AddRefed<CSSValue> DoGetTextOrientation();
|
||||
already_AddRefed<CSSValue> DoGetTextOverflow();
|
||||
already_AddRefed<CSSValue> DoGetTextTransform();
|
||||
|
|
|
|||
|
|
@ -239,6 +239,7 @@ COMPUTED_STYLE_PROP(text_emphasis_color, TextEmphasisColor)
|
|||
COMPUTED_STYLE_PROP(text_emphasis_position, TextEmphasisPosition)
|
||||
COMPUTED_STYLE_PROP(text_emphasis_style, TextEmphasisStyle)
|
||||
COMPUTED_STYLE_PROP(text_indent, TextIndent)
|
||||
COMPUTED_STYLE_PROP(text_justify, TextJustify)
|
||||
COMPUTED_STYLE_PROP(text_orientation, TextOrientation)
|
||||
COMPUTED_STYLE_PROP(text_overflow, TextOverflow)
|
||||
COMPUTED_STYLE_PROP(text_shadow, TextShadow)
|
||||
|
|
|
|||
|
|
@ -1414,6 +1414,7 @@ struct SetEnumValueHelper
|
|||
DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleFloat, None, InlineEnd)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleTextJustify, None, InterCharacter)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None, SelectMenu)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleUserInput, None, Auto)
|
||||
|
|
@ -4783,6 +4784,12 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
|
|||
SETCOORD_UNSET_INHERIT,
|
||||
aContext, mPresContext, conditions);
|
||||
|
||||
// text-justify: enum, inherit, initial
|
||||
SetValue(*aRuleData->ValueForTextJustify(), text->mTextJustify, conditions,
|
||||
SETVAL_ENUMERATED | SETVAL_UNSET_INHERIT,
|
||||
parentText->mTextJustify,
|
||||
StyleTextJustify::Auto);
|
||||
|
||||
// text-transform: enum, inherit, initial
|
||||
SetValue(*aRuleData->ValueForTextTransform(), text->mTextTransform, conditions,
|
||||
SETVAL_ENUMERATED | SETVAL_UNSET_INHERIT,
|
||||
|
|
|
|||
|
|
@ -185,6 +185,14 @@ enum class StyleShapeSourceType : uint8_t {
|
|||
Box,
|
||||
};
|
||||
|
||||
// text-justify
|
||||
enum class StyleTextJustify : uint8_t {
|
||||
None,
|
||||
Auto,
|
||||
InterWord,
|
||||
InterCharacter,
|
||||
};
|
||||
|
||||
// user-focus
|
||||
enum class StyleUserFocus : uint8_t {
|
||||
None,
|
||||
|
|
|
|||
|
|
@ -3788,6 +3788,7 @@ nsStyleText::nsStyleText(StyleStructContext aContext)
|
|||
, mTextAlignLast(NS_STYLE_TEXT_ALIGN_AUTO)
|
||||
, mTextAlignTrue(false)
|
||||
, mTextAlignLastTrue(false)
|
||||
, mTextJustify(StyleTextJustify::Auto)
|
||||
, mTextTransform(NS_STYLE_TEXT_TRANSFORM_NONE)
|
||||
, mWhiteSpace(NS_STYLE_WHITESPACE_NORMAL)
|
||||
, mWordBreak(NS_STYLE_WORDBREAK_NORMAL)
|
||||
|
|
@ -3824,6 +3825,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|||
, mTextAlignLast(aSource.mTextAlignLast)
|
||||
, mTextAlignTrue(false)
|
||||
, mTextAlignLastTrue(false)
|
||||
, mTextJustify(aSource.mTextJustify)
|
||||
, mTextTransform(aSource.mTextTransform)
|
||||
, mWhiteSpace(aSource.mWhiteSpace)
|
||||
, mWordBreak(aSource.mWordBreak)
|
||||
|
|
@ -3885,6 +3887,7 @@ nsStyleText::CalcDifference(const nsStyleText& aNewData) const
|
|||
(mTextSizeAdjust != aNewData.mTextSizeAdjust) ||
|
||||
(mLetterSpacing != aNewData.mLetterSpacing) ||
|
||||
(mLineHeight != aNewData.mLineHeight) ||
|
||||
(mTextJustify != aNewData.mTextJustify) ||
|
||||
(mTextIndent != aNewData.mTextIndent) ||
|
||||
(mWordSpacing != aNewData.mWordSpacing) ||
|
||||
(mTabSize != aNewData.mTabSize)) {
|
||||
|
|
|
|||
|
|
@ -2071,6 +2071,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText
|
|||
uint8_t mTextAlignLast; // [inherited] see nsStyleConsts.h
|
||||
bool mTextAlignTrue : 1; // [inherited] see nsStyleConsts.h
|
||||
bool mTextAlignLastTrue : 1; // [inherited] see nsStyleConsts.h
|
||||
mozilla::StyleTextJustify mTextJustify; // [inherited]
|
||||
uint8_t mTextTransform; // [inherited] see nsStyleConsts.h
|
||||
uint8_t mWhiteSpace; // [inherited] see nsStyleConsts.h
|
||||
uint8_t mWordBreak; // [inherited] see nsStyleConsts.h
|
||||
|
|
|
|||
|
|
@ -5694,6 +5694,17 @@ if (IsCSSPropertyPrefEnabled("layout.css.text-combine-upright.enabled")) {
|
|||
}
|
||||
}
|
||||
|
||||
if (IsCSSPropertyPrefEnabled("layout.css.text-justify.enabled")) {
|
||||
gCSSProperties["text-justify"] = {
|
||||
domProp: "textJustify",
|
||||
inherited: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "auto" ],
|
||||
other_values: [ "none", "inter-word", "inter-character", "distribute" ],
|
||||
invalid_values: []
|
||||
};
|
||||
}
|
||||
|
||||
if (IsCSSPropertyPrefEnabled("svg.paint-order.enabled")) {
|
||||
gCSSProperties["paint-order"] = {
|
||||
domProp: "paintOrder",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue