Bug 1247777 - Part1: parse and compute -webkit-text-fill-color property. r=heycam

--HG--
extra : commitid : 3L1KflCYhR3
This commit is contained in:
Jeremy Chen 2016-03-25 15:54:49 +08:00
Родитель fb9390dfa5
Коммит 4134ed5760
12 изменённых файлов: 96 добавлений и 2 удалений

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

@ -3284,6 +3284,14 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty,
break;
}
case eCSSProperty__webkit_text_fill_color: {
auto styleText = static_cast<const nsStyleText*>(styleStruct);
nscolor color = styleText->mWebkitTextFillColorForeground ?
aStyleContext->StyleColor()->mColor : styleText->mWebkitTextFillColor;
aComputedValue.SetColorValue(color);
break;
}
case eCSSProperty_border_spacing: {
const nsStyleTableBorder *styleTableBorder =
static_cast<const nsStyleTableBorder*>(styleStruct);

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

@ -3328,6 +3328,19 @@ CSS_PROP_TEXT(
nullptr,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_TEXT(
-webkit-text-fill-color,
_webkit_text_fill_color,
WebkitTextFillColor,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_APPLIES_TO_PLACEHOLDER |
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED,
"layout.css.prefixes.webkit",
VARIANT_HC,
nullptr,
offsetof(nsStyleText, mWebkitTextFillColor),
eStyleAnimType_Custom)
CSS_PROP_TEXT(
text-indent,
text_indent,

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

@ -3914,6 +3914,17 @@ nsComputedDOMStyle::DoGetTextSizeAdjust()
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetWebkitTextFillColor()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
const nsStyleText* text = StyleText();
nscolor color = text->mWebkitTextFillColorForeground ?
StyleColor()->mColor : text->mWebkitTextFillColor;
SetToRGBAColor(val, color);
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetPointerEvents()
{

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

@ -425,6 +425,7 @@ private:
already_AddRefed<CSSValue> DoGetHyphens();
already_AddRefed<CSSValue> DoGetTabSize();
already_AddRefed<CSSValue> DoGetTextSizeAdjust();
already_AddRefed<CSSValue> DoGetWebkitTextFillColor();
/* Visibility properties */
already_AddRefed<CSSValue> DoGetOpacity();

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

@ -297,6 +297,12 @@ COMPUTED_STYLE_PROP(user_select, UserSelect)
COMPUTED_STYLE_PROP(_moz_window_dragging, WindowDragging)
COMPUTED_STYLE_PROP(_moz_window_shadow, WindowShadow)
/* ********************************** *\
* Implementations of -webkit- styles *
\* ********************************** */
COMPUTED_STYLE_PROP(_webkit_text_fill_color, WebkitTextFillColor)
/* ***************************** *\
* Implementations of SVG styles *
\* ***************************** */

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

@ -4711,6 +4711,27 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
MOZ_ASSERT_UNREACHABLE("Unknown value unit type");
}
// -webkit-text-fill-color: color, string, inherit, initial
const nsCSSValue*
webkitTextFillColorValue = aRuleData->ValueForWebkitTextFillColor();
if (webkitTextFillColorValue->GetUnit() == eCSSUnit_Null) {
// We don't want to change anything in this case.
} else if (webkitTextFillColorValue->GetUnit() == eCSSUnit_Inherit ||
webkitTextFillColorValue->GetUnit() == eCSSUnit_Unset) {
conditions.SetUncacheable();
text->mWebkitTextFillColorForeground = parentText->mWebkitTextFillColorForeground;
text->mWebkitTextFillColor = parentText->mWebkitTextFillColor;
} else if ((webkitTextFillColorValue->GetUnit() == eCSSUnit_EnumColor &&
webkitTextFillColorValue->GetIntValue() == NS_COLOR_CURRENTCOLOR) ||
webkitTextFillColorValue->GetUnit() == eCSSUnit_Initial) {
text->mWebkitTextFillColorForeground = true;
text->mWebkitTextFillColor = mPresContext->DefaultColor();
} else {
text->mWebkitTextFillColorForeground = false;
SetColor(*webkitTextFillColorValue, 0, mPresContext, aContext,
text->mWebkitTextFillColor, conditions);
}
// -moz-control-character-visibility: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForControlCharacterVisibility(),
text->mControlCharacterVisibility,

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

@ -1091,7 +1091,10 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
const nsStyleText* otherVisText = otherVis->StyleText();
if (thisVisText->mTextEmphasisColorForeground !=
otherVisText->mTextEmphasisColorForeground ||
thisVisText->mTextEmphasisColor != otherVisText->mTextEmphasisColor) {
thisVisText->mTextEmphasisColor != otherVisText->mTextEmphasisColor ||
thisVisText->mWebkitTextFillColorForeground !=
otherVisText->mWebkitTextFillColorForeground ||
thisVisText->mWebkitTextFillColor != otherVisText->mWebkitTextFillColor) {
change = true;
}
}
@ -1313,6 +1316,7 @@ nsStyleContext::GetVisitedDependentColor(nsCSSProperty aProperty)
aProperty == eCSSProperty__moz_column_rule_color ||
aProperty == eCSSProperty_text_decoration_color ||
aProperty == eCSSProperty_text_emphasis_color ||
aProperty == eCSSProperty__webkit_text_fill_color ||
aProperty == eCSSProperty_fill ||
aProperty == eCSSProperty_stroke,
"we need to add to nsStyleContext::CalcStyleDifference");

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

@ -3633,6 +3633,7 @@ nsStyleText::nsStyleText(nsPresContext* aPresContext)
mTextAlignTrue = false;
mTextAlignLastTrue = false;
mTextEmphasisColorForeground = true;
mWebkitTextFillColorForeground = true;
mTextTransform = NS_STYLE_TEXT_TRANSFORM_NONE;
mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
mWordBreak = NS_STYLE_WORDBREAK_NORMAL;
@ -3649,6 +3650,7 @@ nsStyleText::nsStyleText(nsPresContext* aPresContext)
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT_ZH :
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT;
mTextEmphasisColor = aPresContext->DefaultColor();
mWebkitTextFillColor = aPresContext->DefaultColor();
mControlCharacterVisibility = nsCSSParser::ControlCharVisibilityDefault();
mWordSpacing.SetCoordValue(0);
@ -3666,6 +3668,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
mTextAlignTrue(false),
mTextAlignLastTrue(false),
mTextEmphasisColorForeground(aSource.mTextEmphasisColorForeground),
mWebkitTextFillColorForeground(aSource.mWebkitTextFillColorForeground),
mTextTransform(aSource.mTextTransform),
mWhiteSpace(aSource.mWhiteSpace),
mWordBreak(aSource.mWordBreak),
@ -3680,6 +3683,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
mTextEmphasisStyle(aSource.mTextEmphasisStyle),
mTabSize(aSource.mTabSize),
mTextEmphasisColor(aSource.mTextEmphasisColor),
mWebkitTextFillColor(aSource.mWebkitTextFillColor),
mWordSpacing(aSource.mWordSpacing),
mLetterSpacing(aSource.mLetterSpacing),
mLineHeight(aSource.mLineHeight),
@ -3749,7 +3753,9 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
"If the text-emphasis-color are both foreground color, "
"mTextEmphasisColor should also be identical");
if (mTextEmphasisColorForeground != aOther.mTextEmphasisColorForeground ||
mTextEmphasisColor != aOther.mTextEmphasisColor) {
mTextEmphasisColor != aOther.mTextEmphasisColor ||
mWebkitTextFillColorForeground != aOther.mWebkitTextFillColorForeground ||
mWebkitTextFillColor != aOther.mWebkitTextFillColor) {
return nsChangeHint_SchedulePaint |
nsChangeHint_RepaintFrame;
}

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

@ -1872,6 +1872,7 @@ struct nsStyleText
bool mTextAlignTrue : 1; // [inherited] see nsStyleConsts.h
bool mTextAlignLastTrue : 1; // [inherited] see nsStyleConsts.h
bool mTextEmphasisColorForeground : 1;// [inherited] whether text-emphasis-color is currentColor
bool mWebkitTextFillColorForeground : 1; // [inherited] whether -webkit-text-fill-color is currentColor
uint8_t mTextTransform; // [inherited] see nsStyleConsts.h
uint8_t mWhiteSpace; // [inherited] see nsStyleConsts.h
uint8_t mWordBreak; // [inherited] see nsStyleConsts.h
@ -1886,6 +1887,7 @@ struct nsStyleText
uint8_t mTextEmphasisStyle; // [inherited] see nsStyleConsts.h
int32_t mTabSize; // [inherited] see nsStyleConsts.h
nscolor mTextEmphasisColor; // [inherited]
nscolor mWebkitTextFillColor; // [inherited]
nsStyleCoord mWordSpacing; // [inherited] coord, percent, calc
nsStyleCoord mLetterSpacing; // [inherited] coord, normal

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

@ -7013,6 +7013,15 @@ if (IsCSSPropertyPrefEnabled("layout.css.prefixes.webkit")) {
alias_for: "filter",
subproperties: [ "filter" ],
};
gCSSProperties["-webkit-text-fill-color"] = {
domProp: "webkitTextFillColor",
inherited: true,
type: CSS_TYPE_LONGHAND,
prerequisites: { "color": "black" },
initial_values: [ "currentColor", "black", "#000", "#000000", "rgb(0,0,0)" ],
other_values: [ "red", "rgba(255,255,255,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000", "ff00ff", "rgb(255,xxx,255)" ]
};
gCSSProperties["-webkit-text-size-adjust"] = {
domProp: "webkitTextSizeAdjust",
inherited: true,

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

@ -23,6 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=531585
text-decoration-color: black; /* don't derive from color */
outline-color: black; /* don't derive from color */
text-emphasis-color: black; /* don't derive from color */
-webkit-text-fill-color: black; /* don't derive from color */
}
#four {
@ -75,6 +76,7 @@ var got_one_target_borderleft = false;
var got_one_target_columnrule = false;
var got_one_target_textdecorationcolor = false;
var got_one_target_textemphasiscolor = false;
var got_one_target_webkittextfillcolor = false;
var got_one_target_outlinecolor = false;
var got_two_target = false;
var got_three_top = false;
@ -198,6 +200,12 @@ $("one").addEventListener("transitionend",
got_one_target_textemphasiscolor = true;
event.stopPropagation();
break;
case "-webkit-text-fill-color":
ok(!got_one_target_webkittextfillcolor,
"transitionend on one on target (-webkit-text-fill-color)");
got_one_target_webkittextfillcolor = true;
event.stopPropagation();
break;
case "outline-color":
ok(!got_one_target_outlinecolor,
"transitionend on one on target (outline-color)");
@ -226,6 +234,9 @@ started_test(); // text-decoration-color on #one
if (SpecialPowers.getBoolPref("layout.css.text-emphasis.enabled")) {
started_test(); // text-emphasis-color on #one
}
if (SpecialPowers.getBoolPref("layout.css.prefixes.webkit")) {
started_test(); // -webkit-text-fill-color on #one
}
started_test(); // outline-color on #one
$("one").style.color = "lime";

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

@ -257,6 +257,8 @@ var supported_properties = {
test_length_clamped, test_percent_clamped ],
"word-spacing": [ test_length_transition, test_length_unclamped ],
"z-index": [ test_integer_transition, test_pos_integer_or_auto_transition ],
"-webkit-text-fill-color": [ test_color_transition,
test_border_color_transition ]
};
if (SupportsMaskShorthand()) {