Add support for -moz-text-size-adjust CSS property. (Bug 627842, patch 1) r=bzbarsky

This property is analogous to the -webkit-text-size-adjust property (and
*maybe* also the -ms-text-size-adjust property).  It allows pages to opt
out of text size adjustments performed on mobile devices by specifying
-moz-text-size-adjust: none.
This commit is contained in:
L. David Baron 2011-11-23 18:48:23 -08:00
Родитель c27a07ee01
Коммит b20ea773ca
9 изменённых файлов: 58 добавлений и 1 удалений

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

@ -51,7 +51,7 @@
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[builtinclass, scriptable, uuid(519ae4fa-0fee-4aaa-bcb9-34b503236801)]
[builtinclass, scriptable, uuid(0a6fc4c6-a62a-4f52-9ab6-3d398b958843)]
interface nsIDOMCSS2Properties : nsISupports
{
attribute DOMString background;
@ -764,4 +764,7 @@ interface nsIDOMCSS2Properties : nsISupports
attribute DOMString MozAnimation;
// raises(DOMException) on setting
attribute DOMString MozTextSizeAdjust;
// raises(DOMException) on setting
};

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

@ -713,6 +713,10 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_HYPHENS_MANUAL 1
#define NS_STYLE_HYPHENS_AUTO 2
// See nsStyleText
#define NS_STYLE_TEXT_SIZE_ADJUST_NONE 0
#define NS_STYLE_TEXT_SIZE_ADJUST_AUTO 1
// See nsStyleText
#define NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT 0

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

@ -2235,6 +2235,15 @@ CSS_PROP_TEXT(
nsnull,
offsetof(nsStyleText, mTextShadow),
eStyleAnimType_Shadow)
CSS_PROP_TEXT(
-moz-text-size-adjust,
text_size_adjust,
CSS_PROP_DOMPROP_PREFIXED(TextSizeAdjust),
CSS_PROPERTY_PARSE_VALUE,
VARIANT_AUTO | VARIANT_NONE | VARIANT_INHERIT,
nsnull,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_TEXT(
text-transform,
text_transform,

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

@ -2643,6 +2643,24 @@ nsComputedDOMStyle::DoGetHyphens()
return val;
}
nsIDOMCSSValue*
nsComputedDOMStyle::DoGetTextSizeAdjust()
{
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
switch (GetStyleText()->mTextSizeAdjust) {
default:
NS_NOTREACHED("unexpected value");
// fall through
case NS_STYLE_TEXT_SIZE_ADJUST_AUTO:
val->SetIdent(eCSSKeyword_auto);
break;
case NS_STYLE_TEXT_SIZE_ADJUST_NONE:
val->SetIdent(eCSSKeyword_none);
break;
}
return val;
}
nsIDOMCSSValue*
nsComputedDOMStyle::DoGetPointerEvents()
{
@ -4579,6 +4597,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
COMPUTED_STYLE_MAP_ENTRY(text_decoration_color, MozTextDecorationColor),
COMPUTED_STYLE_MAP_ENTRY(text_decoration_line, MozTextDecorationLine),
COMPUTED_STYLE_MAP_ENTRY(text_decoration_style, MozTextDecorationStyle),
COMPUTED_STYLE_MAP_ENTRY(text_size_adjust, TextSizeAdjust),
COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_transform, MozTransform),
COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_transform_origin, MozTransformOrigin),
COMPUTED_STYLE_MAP_ENTRY(transform_style, MozTransformStyle),

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

@ -322,6 +322,7 @@ private:
nsIDOMCSSValue* DoGetWordWrap();
nsIDOMCSSValue* DoGetHyphens();
nsIDOMCSSValue* DoGetMozTabSize();
nsIDOMCSSValue* DoGetTextSizeAdjust();
/* Visibility properties */
nsIDOMCSSValue* DoGetOpacity();

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

@ -3398,6 +3398,15 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
SETDSC_ENUMERATED, parentText->mHyphens,
NS_STYLE_HYPHENS_MANUAL, 0, 0, 0, 0);
// text-size-adjust: none, auto, inherit, initial
SetDiscrete(*aRuleData->ValueForTextSizeAdjust(), text->mTextSizeAdjust,
canStoreInRuleTree, SETDSC_NONE | SETDSC_AUTO,
parentText->mTextSizeAdjust,
NS_STYLE_TEXT_SIZE_ADJUST_AUTO, // initial value
NS_STYLE_TEXT_SIZE_ADJUST_AUTO, // auto value
NS_STYLE_TEXT_SIZE_ADJUST_NONE, // none value
0, 0);
COMPUTE_END_INHERITED(Text, text)
}

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

@ -2800,6 +2800,7 @@ nsStyleText::nsStyleText(void)
mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
mWordWrap = NS_STYLE_WORDWRAP_NORMAL;
mHyphens = NS_STYLE_HYPHENS_MANUAL;
mTextSizeAdjust = NS_STYLE_TEXT_SIZE_ADJUST_AUTO;
mLetterSpacing.SetNormalValue();
mLineHeight.SetNormalValue();
@ -2816,6 +2817,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
mWhiteSpace(aSource.mWhiteSpace),
mWordWrap(aSource.mWordWrap),
mHyphens(aSource.mHyphens),
mTextSizeAdjust(aSource.mTextSizeAdjust),
mTabSize(aSource.mTabSize),
mLetterSpacing(aSource.mLetterSpacing),
mLineHeight(aSource.mLineHeight),
@ -2843,6 +2845,7 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
(mWhiteSpace != aOther.mWhiteSpace) ||
(mWordWrap != aOther.mWordWrap) ||
(mHyphens != aOther.mHyphens) ||
(mTextSizeAdjust != aOther.mTextSizeAdjust) ||
(mLetterSpacing != aOther.mLetterSpacing) ||
(mLineHeight != aOther.mLineHeight) ||
(mTextIndent != aOther.mTextIndent) ||

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

@ -1280,6 +1280,7 @@ struct nsStyleText {
PRUint8 mWhiteSpace; // [inherited] see nsStyleConsts.h
PRUint8 mWordWrap; // [inherited] see nsStyleConsts.h
PRUint8 mHyphens; // [inherited] see nsStyleConsts.h
PRUint8 mTextSizeAdjust; // [inherited] see nsStyleConsts.h
PRInt32 mTabSize; // [inherited] see nsStyleConsts.h
nsStyleCoord mLetterSpacing; // [inherited] coord, normal

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

@ -925,6 +925,14 @@ var gCSSProperties = {
other_values: [ "0", "3", "99", "12000" ],
invalid_values: [ "-1", "-808", "3.0", "17.5" ]
},
"-moz-text-size-adjust": {
domProp: "MozTextSizeAdjust",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "auto" ],
other_values: [ "none" ],
invalid_values: [ "-5%", "0", "100", "0%", "50%", "100%", "220.3%" ]
},
"-moz-transform": {
domProp: "MozTransform",
inherited: false,