Bug 1507308 - Serialize mask using servo. r=jwatt

text-decoration is dealt with in D130018.

Remove the test that checks that we don't serialize mask with various
non-default properties since now we serialize it correctly.

Remove mask from another test, because with this patch we start
serializing the url like the mask-image shorthand, which would
also fail this test.

Making serialization consistent with the longhand makes sense IMO. There's
https://github.com/w3c/csswg-drafts/issues/3195 to make image serialization and
non-image URL serialization consistent. Will try to fix that in the coming
days. After that we can re-add mask/mask-image to that test.

Differential Revision: https://phabricator.services.mozilla.com/D130095
This commit is contained in:
Emilio Cobos Álvarez 2021-11-08 14:29:52 +00:00
parent 2125a049e6
commit 7eb98ff300
4 changed files with 1 additions and 126 deletions

View File

@ -99,8 +99,7 @@ LONGHANDS_NOT_SERIALIZED_WITH_SERVO = [
def serialized_by_servo(prop):
if prop.type() == "shorthand":
# FIXME: Need to figure out what to do with relative mask urls.
return prop.name != "mask"
return True
# Keywords are all fine, except -moz-osx-font-smoothing, which does
# resistfingerprinting stuff.
if prop.keyword and prop.name != "-moz-osx-font-smoothing":

View File

@ -2441,32 +2441,6 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::GetTransformValue(
return MatrixToCSSValue(matrix);
}
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetMask() {
const nsStyleSVGReset* svg = StyleSVGReset();
const nsStyleImageLayers::Layer& firstLayer = svg->mMask.mLayers[0];
// Mask is now a shorthand, but it used to be a longhand, so that we
// need to support computed style for the cases where it used to be
// a longhand.
if (svg->mMask.mImageCount > 1 ||
firstLayer.mClip != StyleGeometryBox::BorderBox ||
firstLayer.mOrigin != StyleGeometryBox::BorderBox ||
firstLayer.mComposite != StyleMaskComposite::Add ||
firstLayer.mMaskMode != StyleMaskMode::MatchSource ||
firstLayer.mPosition != Position::FromPercentage(0.0f) ||
!firstLayer.mRepeat.IsInitialValue() ||
!firstLayer.mSize.IsInitialValue() ||
!(firstLayer.mImage.IsNone() || firstLayer.mImage.IsUrl())) {
return nullptr;
}
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueToURLValue(firstLayer.mImage.GetImageRequestURLValue(), val);
return val.forget();
}
already_AddRefed<CSSValue> nsComputedDOMStyle::DummyGetter() {
MOZ_CRASH("DummyGetter is not supposed to be invoked");
}

View File

@ -240,9 +240,6 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
already_AddRefed<CSSValue> DoGetImageLayerPosition(
const nsStyleImageLayers& aLayers);
/* Mask properties */
already_AddRefed<CSSValue> DoGetMask();
/* Padding properties */
already_AddRefed<CSSValue> DoGetPaddingTop();
already_AddRefed<CSSValue> DoGetPaddingBottom();

View File

@ -220,99 +220,6 @@ var noframe_container = document.getElementById("content");
p.remove();
})();
(function test_bug_1235015() {
// "masks" object contains non-initial mask longhand values.
var emptyMasks = {
// More then one <mask-reference>, or any mask-image value other then
// <mask-source>,
"mask-image": [
"url(#mask1), url(#mask2)",
"linear-gradient(red, yellow)",
"-moz-element(#test)"
],
// any mask-clip value other than "border-box".
"mask-clip": [
"content-box", "padding-box", "margin-box", "fill-box", "stroke-box",
"view-box", "no-clip"
],
// any mask-origin value other than "border-box".
"mask-origin": [
"content-box", "padding-box", "margin-box", "fill-box", "stroke-box",
"view-box"
],
// any mask-composite value other than "add".
"mask-composite": [
"subtract", "intersect", "exclude"
],
// any mask-mode value other than "match-source".
"mask-mode": [
"alpha", "luminance"
],
// any mask-position value other then "0%" "top" "left"
// "center center".
"mask-position": [
"0%", "center", "right", "bottom", "50%", "100%"
],
// any mask-repeat value other then "repeat" "repeat repeat".
"mask-repeat": [
"repeat-x", "repeat-y", "no-repeat", "space", "round"
],
// any mask-size value other then "auto" "auto auto".
"mask-size": [
"10px", "100%", "cover", "contain", "auto 5px"
],
};
// "masks" object contains initial mask longhand values.
var nonEmptyMasks = {
"mask-image": [
"url(#mask1)", "none"
],
"mask-clip": [
"border-box"
],
"mask-origin": [
"border-box"
],
"mask-composite": [
"add"
],
"mask-mode": [
"match-source"
],
"mask-position": [
"0% 0%", "left top"
],
"mask-repeat": [
"repeat", "repeat repeat"
],
"mask-size": [
"auto", "auto auto"
],
};
var p = document.createElement("p");
var cs = getComputedStyle(p, "");
frame_container.appendChild(p);
for (var prop in emptyMasks) {
var subProp = emptyMasks[prop];
for (var i = 0; i < subProp.length; i++) {
p.style.mask = subProp[i];
is(cs.mask, "", "computed value of " + subProp[i] + " mask");
}
}
for (var prop in nonEmptyMasks) {
var subProp = nonEmptyMasks[prop];
for (var i = 0; i < subProp.length; i++) {
p.style.mask = subProp[i];
isnot(cs.mask, "", "computed value of " + subProp[i] + " mask");
}
}
p.remove();
})();
(function test_bug_1363349_linear() {
const specPrefix = "-webkit-gradient(linear, ";
const specSuffix = ", from(blue), to(lime))";
@ -512,7 +419,6 @@ var noframe_container = document.getElementById("content");
})();
(function test_bug_1293164() {
var p = document.createElement("p");
var cs = getComputedStyle(p, "");
frame_container.appendChild(p);
@ -524,7 +430,6 @@ var noframe_container = document.getElementById("content");
var resolvedNonLocalURL = "url(\"" + docPath + "foo.svg#foo\")";
var testStyles = [
"mask",
"markerStart",
"markerMid",
"markerEnd",