Bug 1507305 - Use Servo to serialize most of the already-exposed shorthands. r=heycam

Skip mask and text-decoration for now since there's a single test-case failing
for each that seem worth fixing in a different bug:

 * For mask, there's the case of setting mask: url(foo.svg#bar), which we test
   we serialize absolutely. But given we're uncomputing it we don't serialize
   the resolved URL. Chrome doesn't either so we could just change the test, but
   even if we decided to do it we probably should do it in a separate bug.

 * For text-decoration, we need to resolve the value, when it's an interpolation
   between currentcolor and other color. Right now that returns the empty string
   which is not great:

     https://searchfox.org/mozilla-central/rev/d850d799a0009f851b5535580e0a8b4bb2c591d7/servo/components/style/values/specified/color.rs#194

   So I need to come up with something. Probably we need to implement the "hard"
   version of the serialization code that doesn't reuse the animation machinery.

   Definitely a separate bug though.

While at it, also serialize all <position> longhands with Servo, so that I can
clean up the tests.

Differential Revision: https://phabricator.services.mozilla.com/D11948

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2018-11-15 04:10:08 +00:00
Родитель f3bce5b4dd
Коммит 0112d2ebe1
5 изменённых файлов: 21 добавлений и 142 удалений

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

@ -105,6 +105,7 @@ SERIALIZED_PREDEFINED_TYPES = [
"OffsetPath",
"Opacity",
"OverflowWrap",
"Position",
"Quotes",
"Resize",
"Rotate",
@ -126,9 +127,11 @@ def serialized_by_servo(prop):
# If the property requires layout information, no such luck.
if "GETCS_NEEDS_LAYOUT_FLUSH" in prop.flags:
return False
# No shorthands yet.
if prop.type() == "shorthand":
return False
# FIXME: Need to serialize a value interpolated with currentcolor
# properly to be able to use text-decoration, and figure out what to do
# with relative mask urls.
return prop.name != "text-decoration" and prop.name != "mask"
# Keywords are all fine, except -moz-osx-font-smoothing, which does
# resistfingerprinting stuff.
if prop.keyword and prop.name != "-moz-osx-font-smoothing":
@ -161,8 +164,8 @@ def flags(prop):
result.append("CanAnimateOnCompositor")
if exposed_on_getcs(prop):
result.append("ExposedOnGetCS")
if serialized_by_servo(prop):
result.append("SerializedByServo")
if serialized_by_servo(prop):
result.append("SerializedByServo")
if prop.type() == "longhand" and prop.logical:
result.append("IsLogical")
return ", ".join('"{}"'.format(flag) for flag in result)

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

@ -1343,37 +1343,6 @@ nsComputedDOMStyle::DoGetOsxFontSmoothing()
return val.forget();
}
// return a value *only* for valid longhand values from CSS 2.1, either
// normal or small-caps only
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetFontVariant()
{
const nsFont& f = StyleFont()->mFont;
// if any of the other font-variant subproperties other than
// font-variant-caps are not normal then can't calculate a computed value
if (f.variantAlternates || f.variantEastAsian || f.variantLigatures ||
f.variantNumeric || f.variantPosition) {
return nullptr;
}
nsCSSKeyword keyword;
switch (f.variantCaps) {
case 0:
keyword = eCSSKeyword_normal;
break;
case NS_FONT_VARIANT_CAPS_SMALLCAPS:
keyword = eCSSKeyword_small_caps;
break;
default:
return nullptr;
}
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(keyword);
return val.forget();
}
static void
SetValueToCalc(const nsStyleCoord::CalcValue* aCalc,
nsROCSSPrimitiveValue* aValue)
@ -1480,13 +1449,6 @@ nsComputedDOMStyle::SetValueToURLValue(const css::URLValue* aURL,
aValue->SetString(url);
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetBackgroundPosition()
{
const nsStyleImageLayers& layers = StyleBackground()->mImage;
return DoGetImageLayerPosition(layers);
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetGridTemplateAreas()
{
@ -2210,34 +2172,6 @@ nsComputedDOMStyle::DoGetScrollSnapPointsY()
return GetScrollSnapPoints(StyleDisplay()->mScrollSnapPointsY);
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetScrollSnapDestination()
{
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
SetValueToPosition(StyleDisplay()->mScrollSnapDestination, valueList);
return valueList.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetScrollSnapCoordinate()
{
const nsStyleDisplay* sd = StyleDisplay();
if (sd->mScrollSnapCoordinate.IsEmpty()) {
// Having no snap coordinates is interpreted as "none"
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(eCSSKeyword_none);
return val.forget();
} else {
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(true);
for (size_t i = 0, i_end = sd->mScrollSnapCoordinate.Length(); i < i_end; ++i) {
RefPtr<nsDOMCSSValueList> itemList = GetROCSSValueList(false);
SetValueToPosition(sd->mScrollSnapCoordinate[i], itemList);
valueList->AppendCSSValue(itemList.forget());
}
return valueList.forget();
}
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetScrollbarColor()
{
@ -2980,29 +2914,6 @@ nsComputedDOMStyle::DoGetWillChange()
return valueList.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetOverflow()
{
const nsStyleDisplay* display = StyleDisplay();
RefPtr<nsROCSSPrimitiveValue> overflowX = new nsROCSSPrimitiveValue;
overflowX->SetIdent(
nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
nsCSSProps::kOverflowKTable));
if (display->mOverflowX == display->mOverflowY) {
return overflowX.forget();
}
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
valueList->AppendCSSValue(overflowX.forget());
RefPtr<nsROCSSPrimitiveValue> overflowY= new nsROCSSPrimitiveValue;
overflowY->SetIdent(
nsCSSProps::ValueToKeywordEnum(display->mOverflowY,
nsCSSProps::kOverflowKTable));
valueList->AppendCSSValue(overflowY.forget());
return valueList.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetOverflowY()
{
@ -3210,14 +3121,6 @@ nsComputedDOMStyle::DoGetMinWidth()
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetObjectPosition()
{
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
SetValueToPosition(StylePosition()->mObjectPosition, valueList);
return valueList.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetLeft()
{
@ -4239,13 +4142,6 @@ nsComputedDOMStyle::DoGetMask()
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetMaskPosition()
{
const nsStyleImageLayers& layers = StyleSVGReset()->mMask;
return DoGetImageLayerPosition(layers);
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetPaintOrder()
{

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

@ -248,7 +248,6 @@ private:
already_AddRefed<CSSValue> DoGetMaxWidth();
already_AddRefed<CSSValue> DoGetMinHeight();
already_AddRefed<CSSValue> DoGetMinWidth();
already_AddRefed<CSSValue> DoGetObjectPosition();
already_AddRefed<CSSValue> DoGetLeft();
already_AddRefed<CSSValue> DoGetTop();
already_AddRefed<CSSValue> DoGetRight();
@ -259,7 +258,6 @@ private:
/* Font properties */
already_AddRefed<CSSValue> DoGetOsxFontSmoothing();
already_AddRefed<CSSValue> DoGetFontVariant();
/* Grid properties */
already_AddRefed<CSSValue> DoGetGridAutoFlow();
@ -276,12 +274,8 @@ private:
/* StyleImageLayer properties */
already_AddRefed<CSSValue> DoGetImageLayerPosition(const nsStyleImageLayers& aLayers);
/* Background properties */
already_AddRefed<CSSValue> DoGetBackgroundPosition();
/* Mask properties */
already_AddRefed<CSSValue> DoGetMask();
already_AddRefed<CSSValue> DoGetMaskPosition();
/* Padding properties */
already_AddRefed<CSSValue> DoGetPaddingTop();
@ -315,8 +309,6 @@ private:
/* Box Shadow */
already_AddRefed<CSSValue> DoGetBoxShadow();
/* Window Shadow */
/* Margin Properties */
already_AddRefed<CSSValue> DoGetMarginTopWidth();
already_AddRefed<CSSValue> DoGetMarginBottomWidth();
@ -350,16 +342,11 @@ private:
already_AddRefed<CSSValue> DoGetTabSize();
already_AddRefed<CSSValue> DoGetWebkitTextStrokeWidth();
/* Visibility properties */
/* Direction properties */
/* Display properties */
already_AddRefed<CSSValue> DoGetBinding();
already_AddRefed<CSSValue> DoGetDisplay();
already_AddRefed<CSSValue> DoGetContain();
already_AddRefed<CSSValue> DoGetWillChange();
already_AddRefed<CSSValue> DoGetOverflow();
already_AddRefed<CSSValue> DoGetOverflowY();
already_AddRefed<CSSValue> DoGetOverflowClipBoxBlock();
already_AddRefed<CSSValue> DoGetOverflowClipBoxInline();
@ -374,8 +361,6 @@ private:
already_AddRefed<CSSValue> DoGetScrollSnapTypeY();
already_AddRefed<CSSValue> DoGetScrollSnapPointsX();
already_AddRefed<CSSValue> DoGetScrollSnapPointsY();
already_AddRefed<CSSValue> DoGetScrollSnapDestination();
already_AddRefed<CSSValue> DoGetScrollSnapCoordinate();
already_AddRefed<CSSValue> DoGetScrollbarColor();
/* User interface properties */

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

@ -144,9 +144,9 @@ var noframe_container = document.getElementById("content");
[ "0 calc(3px - 3px)", "0px 0px", "computed 0 calc with units y" ],
[ "calc(0%) 0", "0% 0px", "0% calc x"],
[ "0 calc(0%)", "0px 0%", "0% calc y"],
[ "calc(3px + 2% - 2%) 0", "calc(3px + 0%) 0px",
[ "calc(3px + 2% - 2%) 0", "calc(0% + 3px) 0px",
"computed 0% calc x"],
[ "0 calc(3px + 2% - 2%)", "0px calc(3px + 0%)",
[ "0 calc(3px + 2% - 2%)", "0px calc(0% + 3px)",
"computed 0% calc y"],
[ "calc(3px - 5px) calc(6px - 7px)", "-2px -1px",
"negative pixel width"],

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

@ -2489,11 +2489,11 @@ function test_background_position_transition(prop) {
// values.
div.style.setProperty("transition-property", "none", "");
div.style.setProperty(prop, "right 20px bottom 30%", "");
is(cs.getPropertyValue(prop), "calc(-20px + 100%) 70%",
is(cs.getPropertyValue(prop), "calc(100% - 20px) 70%",
"property " + prop + ": computed value before transition");
div.style.setProperty("transition-property", prop, "");
div.style.setProperty(prop, "calc(40px + 20%) calc(12px + 30%)", "");
is(cs.getPropertyValue(prop), "calc(-5px + 80%) calc(3px + 60%)",
is(cs.getPropertyValue(prop), "calc(80% - 5px) calc(60% + 3px)",
"property " + prop + ": interpolation of edge keywords w/ offsets & calc");
if (doesPropHaveDistanceComputation) {
check_distance(prop, "right 20px bottom 30%",
@ -2632,8 +2632,6 @@ function test_background_position_size_common(prop, doesPropTakeListValues,
check_distance(prop, "10px 40px", "20px 30px", "50px 0");
}
const serializesCalcAccordingToTheSpec = prop == "mask-size" || prop == "background-size";
// Test interpolation that computes to to calc() (transition from % to px)
div.style.setProperty("transition-property", "none", "");
div.style.setProperty(prop, "20% 40%", "");
@ -2642,7 +2640,7 @@ function test_background_position_size_common(prop, doesPropTakeListValues,
div.style.setProperty("transition-property", prop, "");
div.style.setProperty(prop, "12px 20px", "");
is(cs.getPropertyValue(prop),
serializesCalcAccordingToTheSpec ? "calc(15% + 3px) calc(30% + 5px)" : "calc(3px + 15%) calc(5px + 30%)",
"calc(15% + 3px) calc(30% + 5px)",
"property " + prop + ": interpolation that computes to calc()");
if (doesPropHaveDistanceComputation) {
check_distance(prop, "20% 40%",
@ -2658,7 +2656,7 @@ function test_background_position_size_common(prop, doesPropTakeListValues,
div.style.setProperty("transition-property", prop, "");
div.style.setProperty(prop, "20% 40%", "");
is(cs.getPropertyValue(prop),
serializesCalcAccordingToTheSpec ? "calc(5% + 9px) calc(10% + 15px)" : "calc(9px + 5%) calc(15px + 10%)",
"calc(5% + 9px) calc(10% + 15px)",
"property " + prop + ": interpolation that computes to calc()");
if (doesPropHaveDistanceComputation) {
check_distance(prop, "12px 20px",
@ -2669,11 +2667,11 @@ function test_background_position_size_common(prop, doesPropTakeListValues,
// Test interpolation between calc() and non-calc()
div.style.setProperty("transition-property", "none", "");
div.style.setProperty(prop, "calc(40px + 10%) 16px", "");
is(cs.getPropertyValue(prop), serializesCalcAccordingToTheSpec ? "calc(10% + 40px) 16px" : "calc(40px + 10%) 16px",
is(cs.getPropertyValue(prop), "calc(10% + 40px) 16px",
"property " + prop + ": computed value before transition");
div.style.setProperty("transition-property", prop, "");
div.style.setProperty(prop, "30% calc(8px + 60%)", "");
is(cs.getPropertyValue(prop), serializesCalcAccordingToTheSpec ? "calc(15% + 30px) calc(15% + 14px)" : "calc(30px + 15%) calc(14px + 15%)",
is(cs.getPropertyValue(prop), "calc(15% + 30px) calc(15% + 14px)",
"property " + prop + ": interpolation between calc() and non-calc()");
if (doesPropHaveDistanceComputation) {
check_distance(prop, "calc(40px + 10%) 16px",
@ -2715,9 +2713,8 @@ function test_background_position_size_common(prop, doesPropTakeListValues,
"property " + prop + ": computed value before transition");
div.style.setProperty("transition-property", prop, "");
div.style.setProperty(prop, "12px 20px, 40% 16%", "");
is(cs.getPropertyValue(prop), serializesCalcAccordingToTheSpec
? "calc(15% + 3px) calc(30% + 5px), calc(10% + 6px) calc(4% + 9px)"
: "calc(3px + 15%) calc(5px + 30%), calc(6px + 10%) calc(9px + 4%)",
is(cs.getPropertyValue(prop),
"calc(15% + 3px) calc(30% + 5px), calc(10% + 6px) calc(4% + 9px)",
"property " + prop + ": interpolation that computes to calc()");
if (doesPropHaveDistanceComputation) {
check_distance(prop, "20% 40%, 8px 12px",
@ -2726,15 +2723,13 @@ function test_background_position_size_common(prop, doesPropTakeListValues,
}
div.style.setProperty("transition-property", "none", "");
div.style.setProperty(prop, "calc(20% + 40px) calc(40px + 40%), 8px 12%, calc(20px + 12%) calc(24px + 8%)", "");
is(cs.getPropertyValue(prop), serializesCalcAccordingToTheSpec
? "calc(20% + 40px) calc(40% + 40px), 8px 12%, calc(12% + 20px) calc(8% + 24px)"
: "calc(40px + 20%) calc(40px + 40%), 8px 12%, calc(20px + 12%) calc(24px + 8%)",
is(cs.getPropertyValue(prop),
"calc(20% + 40px) calc(40% + 40px), 8px 12%, calc(12% + 20px) calc(8% + 24px)",
"property " + prop + ": computed value before transition");
div.style.setProperty("transition-property", prop, "");
div.style.setProperty(prop, "12px 20%, calc(20%) calc(16px + 60%), calc(8px + 20%) calc(40px + 16%)", "");
is(cs.getPropertyValue(prop), serializesCalcAccordingToTheSpec
? "calc(15% + 33px) calc(35% + 30px), calc(5% + 6px) calc(24% + 4px), calc(14% + 17px) calc(10% + 28px)"
: "calc(33px + 15%) calc(30px + 35%), calc(6px + 5%) calc(4px + 24%), calc(17px + 14%) calc(28px + 10%)",
is(cs.getPropertyValue(prop),
"calc(15% + 33px) calc(35% + 30px), calc(5% + 6px) calc(24% + 4px), calc(14% + 17px) calc(10% + 28px)",
"property " + prop + ": interpolation that computes to calc()");
if (doesPropHaveDistanceComputation) {
check_distance(prop, "calc(20% + 40px) calc(40px + 40%), 8px 12%, calc(20px + 12%) calc(24px + 8%)",