Bug 1248708 - Part1: parse and compute -webkit-text-stroke property. r=heycam

This commit is contained in:
Jeremy Chen
2016-04-23 01:40:39 +08:00
parent 12db17691a
commit 753e4f7268
15 changed files with 222 additions and 5 deletions

View File

@@ -1086,6 +1086,7 @@ protected:
bool ParseScrollSnapPoints(nsCSSValue& aValue, nsCSSProperty aPropID);
bool ParseScrollSnapDestination(nsCSSValue& aValue);
bool ParseScrollSnapCoordinate(nsCSSValue& aValue);
bool ParseWebkitTextStroke();
/**
* Parses a variable value from a custom property declaration.
@@ -10803,6 +10804,37 @@ CSSParserImpl::ParseWebkitGradient(nsCSSValue& aValue)
return true;
}
bool
CSSParserImpl::ParseWebkitTextStroke()
{
static const nsCSSProperty kWebkitTextStrokeIDs[] = {
eCSSProperty__webkit_text_stroke_width,
eCSSProperty__webkit_text_stroke_color
};
const size_t numProps = ArrayLength(kWebkitTextStrokeIDs);
nsCSSValue values[numProps];
int32_t found = ParseChoice(values, kWebkitTextStrokeIDs, numProps);
if (found < 1) {
return false;
}
if (!(found & 1)) { // Provide default -webkit-text-stroke-width
values[0].SetFloatValue(0, eCSSUnit_Pixel);
}
if (!(found & 2)) { // Provide default -webkit-text-stroke-color
values[1].SetIntValue(NS_COLOR_CURRENTCOLOR, eCSSUnit_EnumColor);
}
for (size_t index = 0; index < numProps; ++index) {
AppendValue(kWebkitTextStrokeIDs[index], values[index]);
}
return true;
}
int32_t
CSSParserImpl::ParseChoice(nsCSSValue aValues[],
const nsCSSProperty aPropIDs[], int32_t aNumIDs)
@@ -11576,6 +11608,8 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID)
case eCSSProperty_mask_size:
return ParseImageLayerSize(eCSSProperty_mask_size);
#endif
case eCSSProperty__webkit_text_stroke:
return ParseWebkitTextStroke();
case eCSSProperty_all:
return ParseAll();
default: