mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Condense box property four side shorthands in value getters, just as in serialization. (Bug 376075) r+sr=bzbarsky
This commit is contained in:
parent
fd19b3e628
commit
5eb3c08c33
@ -636,14 +636,40 @@ nsCSSDeclaration::GetValue(nsCSSProperty aProperty,
|
||||
nsCSSProps::kTypeTable[subprops[2]] == eCSSType_Value &&
|
||||
nsCSSProps::kTypeTable[subprops[3]] == eCSSType_Value,
|
||||
"type mismatch");
|
||||
if (!AppendValueToString(subprops[0], aValue) ||
|
||||
!(aValue.Append(PRUnichar(' ')),
|
||||
AppendValueToString(subprops[1], aValue)) ||
|
||||
!(aValue.Append(PRUnichar(' ')),
|
||||
AppendValueToString(subprops[2], aValue)) ||
|
||||
!(aValue.Append(PRUnichar(' ')),
|
||||
AppendValueToString(subprops[3], aValue))) {
|
||||
aValue.Truncate();
|
||||
NS_ASSERTION(nsCSSProps::GetStringValue(subprops[0]).Find("-top") !=
|
||||
kNotFound, "first subprop must be top");
|
||||
NS_ASSERTION(nsCSSProps::GetStringValue(subprops[1]).Find("-right") !=
|
||||
kNotFound, "second subprop must be right");
|
||||
NS_ASSERTION(nsCSSProps::GetStringValue(subprops[2]).Find("-bottom") !=
|
||||
kNotFound, "third subprop must be bottom");
|
||||
NS_ASSERTION(nsCSSProps::GetStringValue(subprops[3]).Find("-left") !=
|
||||
kNotFound, "fourth subprop must be left");
|
||||
const nsCSSValue &topValue =
|
||||
*static_cast<const nsCSSValue*>(data->StorageFor(subprops[0]));
|
||||
const nsCSSValue &rightValue =
|
||||
*static_cast<const nsCSSValue*>(data->StorageFor(subprops[1]));
|
||||
const nsCSSValue &bottomValue =
|
||||
*static_cast<const nsCSSValue*>(data->StorageFor(subprops[2]));
|
||||
const nsCSSValue &leftValue =
|
||||
*static_cast<const nsCSSValue*>(data->StorageFor(subprops[3]));
|
||||
PRBool haveValue;
|
||||
haveValue = AppendCSSValueToString(subprops[0], topValue, aValue);
|
||||
NS_ASSERTION(haveValue, "should have bailed before");
|
||||
if (topValue != rightValue || topValue != leftValue ||
|
||||
topValue != bottomValue) {
|
||||
aValue.Append(PRUnichar(' '));
|
||||
haveValue = AppendCSSValueToString(subprops[1], rightValue, aValue);
|
||||
NS_ASSERTION(haveValue, "should have bailed before");
|
||||
if (topValue != bottomValue || rightValue != leftValue) {
|
||||
aValue.Append(PRUnichar(' '));
|
||||
haveValue = AppendCSSValueToString(subprops[2], bottomValue, aValue);
|
||||
NS_ASSERTION(haveValue, "should have bailed before");
|
||||
if (rightValue != leftValue) {
|
||||
aValue.Append(PRUnichar(' '));
|
||||
haveValue = AppendCSSValueToString(subprops[3], leftValue, aValue);
|
||||
NS_ASSERTION(haveValue, "should have bailed before");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -861,7 +887,7 @@ nsCSSDeclaration::GetValue(nsCSSProperty aProperty,
|
||||
GetValueOrImportantValue(eCSSProperty_overflow_x, xValue);
|
||||
GetValueOrImportantValue(eCSSProperty_overflow_y, yValue);
|
||||
if (xValue == yValue)
|
||||
AppendValueToString(eCSSProperty_overflow_x, aValue);
|
||||
AppendCSSValueToString(eCSSProperty_overflow_x, xValue, aValue);
|
||||
break;
|
||||
}
|
||||
case eCSSProperty_pause: {
|
||||
|
@ -64,6 +64,37 @@ ok(e.style.cssText == "border-right: medium solid;" ||
|
||||
e.style.cssText == "border-right: solid medium;",
|
||||
"implied default color omitted serializing declaration");
|
||||
|
||||
// Test that we shorten box properties to the shortest possible.
|
||||
e.setAttribute("style", "margin: 7px");
|
||||
is(e.style.margin, "7px", "should condense to shortest possible");
|
||||
is(e.style.cssText, "margin: 7px;", "should condense to shortest possible");
|
||||
e.setAttribute("style", "padding: 7px 7px 7px");
|
||||
is(e.style.padding, "7px", "should condense to shortest possible");
|
||||
is(e.style.cssText, "padding: 7px;", "should condense to shortest possible");
|
||||
e.setAttribute("style", "border-width: 7px 7px 7px 7px");
|
||||
is(e.style.borderWidth, "7px", "should condense to shortest possible");
|
||||
is(e.style.cssText, "border-width: 7px;", "should condense to shortest possible");
|
||||
e.setAttribute("style", "margin: 7px 7px 7px 6px");
|
||||
is(e.style.margin, "7px 7px 7px 6px", "should not condense");
|
||||
is(e.style.cssText, "margin: 7px 7px 7px 6px;", "should not condense");
|
||||
e.setAttribute("style", "border-style: solid dotted none dotted");
|
||||
is(e.style.borderStyle, "solid dotted none", "should condense");
|
||||
is(e.style.cssText, "border-style: solid dotted none;", "should condense");
|
||||
e.setAttribute("style", "border-color: green blue");
|
||||
is(e.style.borderColor, "green blue", "should condense");
|
||||
is(e.style.cssText, "border-color: green blue;", "should condense");
|
||||
e.setAttribute("style", "border-color: green blue green");
|
||||
is(e.style.borderColor, "green blue", "should condense");
|
||||
is(e.style.cssText, "border-color: green blue;", "should condense");
|
||||
e.setAttribute("style", "border-color: green blue green blue");
|
||||
is(e.style.borderColor, "green blue", "should condense");
|
||||
is(e.style.cssText, "border-color: green blue;", "should condense");
|
||||
e.setAttribute("style", "border-color: currentColor currentColor currentcolor CURRENTcolor");
|
||||
is(e.style.borderColor, "currentcolor", "should condense to canonical case");
|
||||
is(e.style.cssText, "border-color: currentcolor;", "should condense to canonical case");
|
||||
e.setAttribute("style", "border-style: ridge none none none");
|
||||
is(e.style.borderStyle, "ridge none none", "should condense");
|
||||
is(e.style.cssText, "border-style: ridge none none;", "should condense");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -76,11 +76,6 @@ var gBadCompute = {
|
||||
"-moz-box-ordinal-group": [ "-1", "-1000" ],
|
||||
};
|
||||
|
||||
var gShortenableValues = {
|
||||
"border-color": [ "currentColor currentColor currentcolor CURRENTcolor" ],
|
||||
"border-style": [ "none none none none", "groove none none none", "none none double none" ],
|
||||
};
|
||||
|
||||
function xfail_accepted(property, value)
|
||||
{
|
||||
if (property in gNotAccepted &&
|
||||
@ -109,15 +104,6 @@ function xfail_ser_val(property, value)
|
||||
if (property in gShorthandsWithoutCondensingSerialize)
|
||||
return true;
|
||||
|
||||
// We condense multiple values in the serialization, but not in the
|
||||
// value getter.
|
||||
if (property.match(/^(border-(color|style|width)|margin|padding)$/) &&
|
||||
value.split(" ").length != 4)
|
||||
return true;
|
||||
if (property in gShortenableValues &&
|
||||
gShortenableValues[property].indexOf(value) != -1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user