зеркало из https://github.com/mozilla/gecko-dev.git
Backing out bug 647885 due to mochitest oranges. a=backout
This commit is contained in:
Родитель
b3085cf596
Коммит
ed147e5327
|
@ -1265,7 +1265,7 @@ nsComputedDOMStyle::DoGetBackgroundColor()
|
|||
|
||||
|
||||
static void
|
||||
SetValueToCalc(const nsStyleCoord::Calc *aCalc, nsROCSSPrimitiveValue *aValue)
|
||||
SetValueToCalc(nsStyleCoord::Calc *aCalc, nsROCSSPrimitiveValue *aValue)
|
||||
{
|
||||
nsRefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue();
|
||||
nsAutoString tmp, result;
|
||||
|
@ -1524,24 +1524,28 @@ nsComputedDOMStyle::DoGetBackgroundPosition()
|
|||
|
||||
const nsStyleBackground::Position &pos = bg->mLayers[i].mPosition;
|
||||
|
||||
if (!pos.mXPosition.mHasPercent) {
|
||||
NS_ABORT_IF_FALSE(pos.mXPosition.mPercent == 0.0f,
|
||||
"Shouldn't have mPercent!");
|
||||
valX->SetAppUnits(pos.mXPosition.mLength);
|
||||
} else if (pos.mXPosition.mLength == 0) {
|
||||
if (pos.mXPosition.mLength == 0) {
|
||||
valX->SetPercent(pos.mXPosition.mPercent);
|
||||
} else if (pos.mXPosition.mPercent == 0.0f) {
|
||||
valX->SetAppUnits(pos.mXPosition.mLength);
|
||||
} else {
|
||||
SetValueToCalc(&pos.mXPosition, valX);
|
||||
nsStyleCoord::Calc calc;
|
||||
calc.mPercent = pos.mXPosition.mPercent;
|
||||
calc.mLength = pos.mXPosition.mLength;
|
||||
calc.mHasPercent = PR_TRUE;
|
||||
SetValueToCalc(&calc, valX);
|
||||
}
|
||||
|
||||
if (!pos.mYPosition.mHasPercent) {
|
||||
NS_ABORT_IF_FALSE(pos.mYPosition.mPercent == 0.0f,
|
||||
"Shouldn't have mPercent!");
|
||||
valY->SetAppUnits(pos.mYPosition.mLength);
|
||||
} else if (pos.mYPosition.mLength == 0) {
|
||||
if (pos.mYPosition.mLength == 0) {
|
||||
valY->SetPercent(pos.mYPosition.mPercent);
|
||||
} else if (pos.mYPosition.mPercent == 0.0f) {
|
||||
valY->SetAppUnits(pos.mYPosition.mLength);
|
||||
} else {
|
||||
SetValueToCalc(&pos.mYPosition, valY);
|
||||
nsStyleCoord::Calc calc;
|
||||
calc.mPercent = pos.mYPosition.mPercent;
|
||||
calc.mLength = pos.mYPosition.mLength;
|
||||
calc.mHasPercent = PR_TRUE;
|
||||
SetValueToCalc(&calc, valY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1594,18 +1598,20 @@ nsComputedDOMStyle::DoGetMozBackgroundSize()
|
|||
NS_ABORT_IF_FALSE(size.mWidthType ==
|
||||
nsStyleBackground::Size::eLengthPercentage,
|
||||
"bad mWidthType");
|
||||
if (!size.mWidth.mHasPercent &&
|
||||
if (size.mWidth.mLength == 0 &&
|
||||
// negative values must have come from calc()
|
||||
size.mWidth.mLength >= 0) {
|
||||
NS_ABORT_IF_FALSE(size.mWidth.mPercent == 0.0f,
|
||||
"Shouldn't have mPercent");
|
||||
valX->SetAppUnits(size.mWidth.mLength);
|
||||
} else if (size.mWidth.mLength == 0 &&
|
||||
// negative values must have come from calc()
|
||||
size.mWidth.mPercent >= 0.0f) {
|
||||
size.mWidth.mPercent > 0.0f) {
|
||||
valX->SetPercent(size.mWidth.mPercent);
|
||||
} else if (size.mWidth.mPercent == 0.0f &&
|
||||
// negative values must have come from calc()
|
||||
size.mWidth.mLength > 0) {
|
||||
valX->SetAppUnits(size.mWidth.mLength);
|
||||
} else {
|
||||
SetValueToCalc(&size.mWidth, valX);
|
||||
nsStyleCoord::Calc calc;
|
||||
calc.mPercent = size.mWidth.mPercent;
|
||||
calc.mLength = size.mWidth.mLength;
|
||||
calc.mHasPercent = PR_TRUE;
|
||||
SetValueToCalc(&calc, valX);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1615,18 +1621,20 @@ nsComputedDOMStyle::DoGetMozBackgroundSize()
|
|||
NS_ABORT_IF_FALSE(size.mHeightType ==
|
||||
nsStyleBackground::Size::eLengthPercentage,
|
||||
"bad mHeightType");
|
||||
if (!size.mHeight.mHasPercent &&
|
||||
if (size.mHeight.mLength == 0 &&
|
||||
// negative values must have come from calc()
|
||||
size.mHeight.mLength >= 0) {
|
||||
NS_ABORT_IF_FALSE(size.mHeight.mPercent == 0.0f,
|
||||
"Shouldn't have mPercent");
|
||||
valY->SetAppUnits(size.mHeight.mLength);
|
||||
} else if (size.mHeight.mLength == 0 &&
|
||||
// negative values must have come from calc()
|
||||
size.mHeight.mPercent >= 0.0f) {
|
||||
size.mHeight.mPercent > 0.0f) {
|
||||
valY->SetPercent(size.mHeight.mPercent);
|
||||
} else if (size.mHeight.mPercent == 0.0f &&
|
||||
// negative values must have come from calc()
|
||||
size.mHeight.mLength > 0) {
|
||||
valY->SetAppUnits(size.mHeight.mLength);
|
||||
} else {
|
||||
SetValueToCalc(&size.mHeight, valY);
|
||||
nsStyleCoord::Calc calc;
|
||||
calc.mPercent = size.mHeight.mPercent;
|
||||
calc.mLength = size.mHeight.mLength;
|
||||
calc.mHasPercent = PR_TRUE;
|
||||
SetValueToCalc(&calc, valY);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -4652,14 +4652,12 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleBackground::Position>
|
|||
if (eCSSUnit_Percent == specified.GetUnit()) {
|
||||
(position.*(axis->result)).mLength = 0;
|
||||
(position.*(axis->result)).mPercent = specified.GetPercentValue();
|
||||
(position.*(axis->result)).mHasPercent = PR_TRUE;
|
||||
}
|
||||
else if (specified.IsLengthUnit()) {
|
||||
(position.*(axis->result)).mLength =
|
||||
CalcLength(specified, aStyleContext, aStyleContext->PresContext(),
|
||||
aCanStoreInRuleTree);
|
||||
(position.*(axis->result)).mPercent = 0.0f;
|
||||
(position.*(axis->result)).mHasPercent = PR_FALSE;
|
||||
}
|
||||
else if (specified.IsCalcUnit()) {
|
||||
LengthPercentPairCalcOps ops(aStyleContext,
|
||||
|
@ -4668,13 +4666,11 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleBackground::Position>
|
|||
nsRuleNode::ComputedCalc vals = ComputeCalc(specified, ops);
|
||||
(position.*(axis->result)).mLength = vals.mLength;
|
||||
(position.*(axis->result)).mPercent = vals.mPercent;
|
||||
(position.*(axis->result)).mHasPercent = ops.mHasPercent;
|
||||
}
|
||||
else if (eCSSUnit_Enumerated == specified.GetUnit()) {
|
||||
(position.*(axis->result)).mLength = 0;
|
||||
(position.*(axis->result)).mPercent =
|
||||
GetFloatFromBoxPosition(specified.GetIntValue());
|
||||
(position.*(axis->result)).mHasPercent = PR_TRUE;
|
||||
} else {
|
||||
NS_NOTREACHED("unexpected unit");
|
||||
}
|
||||
|
@ -4746,7 +4742,6 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleBackground::Size>
|
|||
else if (eCSSUnit_Percent == specified.GetUnit()) {
|
||||
(size.*(axis->result)).mLength = 0;
|
||||
(size.*(axis->result)).mPercent = specified.GetPercentValue();
|
||||
(size.*(axis->result)).mHasPercent = PR_TRUE;
|
||||
size.*(axis->type) = nsStyleBackground::Size::eLengthPercentage;
|
||||
}
|
||||
else if (specified.IsLengthUnit()) {
|
||||
|
@ -4754,7 +4749,6 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleBackground::Size>
|
|||
CalcLength(specified, aStyleContext, aStyleContext->PresContext(),
|
||||
aCanStoreInRuleTree);
|
||||
(size.*(axis->result)).mPercent = 0.0f;
|
||||
(size.*(axis->result)).mHasPercent = PR_FALSE;
|
||||
size.*(axis->type) = nsStyleBackground::Size::eLengthPercentage;
|
||||
} else {
|
||||
NS_ABORT_IF_FALSE(specified.IsCalcUnit(), "unexpected unit");
|
||||
|
@ -4764,7 +4758,6 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleBackground::Size>
|
|||
nsRuleNode::ComputedCalc vals = ComputeCalc(specified, ops);
|
||||
(size.*(axis->result)).mLength = vals.mLength;
|
||||
(size.*(axis->result)).mPercent = vals.mPercent;
|
||||
(size.*(axis->result)).mHasPercent = ops.mHasPercent;
|
||||
size.*(axis->type) = nsStyleBackground::Size::eLengthPercentage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1822,13 +1822,10 @@ PRBool nsStyleBackground::IsTransparent() const
|
|||
void
|
||||
nsStyleBackground::Position::SetInitialValues()
|
||||
{
|
||||
// Initial value is "0% 0%"
|
||||
mXPosition.mPercent = 0.0f;
|
||||
mXPosition.mLength = 0;
|
||||
mXPosition.mHasPercent = PR_TRUE;
|
||||
mYPosition.mPercent = 0.0f;
|
||||
mYPosition.mLength = 0;
|
||||
mYPosition.mHasPercent = PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -351,7 +351,17 @@ struct nsStyleBackground {
|
|||
struct Position;
|
||||
friend struct Position;
|
||||
struct Position {
|
||||
typedef nsStyleCoord::Calc PositionCoord;
|
||||
struct PositionCoord {
|
||||
// A 'background-position' can be a linear combination of length
|
||||
// and percent (thanks to calc(), which can combine them).
|
||||
nscoord mLength;
|
||||
float mPercent;
|
||||
|
||||
bool operator==(const PositionCoord& aOther) const
|
||||
{ return mLength == aOther.mLength && mPercent == aOther.mPercent; }
|
||||
bool operator!=(const PositionCoord& aOther) const
|
||||
{ return !(*this == aOther); }
|
||||
};
|
||||
PositionCoord mXPosition, mYPosition;
|
||||
|
||||
// Initialize nothing
|
||||
|
@ -378,7 +388,17 @@ struct nsStyleBackground {
|
|||
struct Size;
|
||||
friend struct Size;
|
||||
struct Size {
|
||||
typedef nsStyleCoord::Calc Dimension;
|
||||
struct Dimension {
|
||||
// A 'background-size' can be a linear combination of length
|
||||
// and percent (thanks to calc(), which can combine them).
|
||||
nscoord mLength;
|
||||
float mPercent;
|
||||
|
||||
bool operator==(const Dimension& aOther) const
|
||||
{ return mLength == aOther.mLength && mPercent == aOther.mPercent; }
|
||||
bool operator!=(const Dimension& aOther) const
|
||||
{ return !(*this == aOther); }
|
||||
};
|
||||
Dimension mWidth, mHeight;
|
||||
|
||||
// Except for eLengthPercentage, Dimension types which might change
|
||||
|
|
|
@ -115,74 +115,6 @@ var noframe_container = document.getElementById("content");
|
|||
p.parentNode.removeChild(p);
|
||||
})();
|
||||
|
||||
(function test_bug_647885_1() {
|
||||
// Test that various background-position styles round-trip correctly
|
||||
var backgroundPositions = [
|
||||
[ "0 0", "0px 0px", "unitless 0" ],
|
||||
[ "0px 0px", "0px 0px", "0 with units" ],
|
||||
[ "0% 0%", "0% 0%", "0%" ],
|
||||
[ "-moz-calc(0px) 0", "0px 0px", "0 calc with units x" ],
|
||||
[ "0 -moz-calc(0px)", "0px 0px", "0 calc with units y" ],
|
||||
[ "-moz-calc(3px - 3px) 0", "0px 0px", "computed 0 calc with units x" ],
|
||||
[ "0 -moz-calc(3px - 3px)", "0px 0px", "computed 0 calc with units y" ],
|
||||
[ "-moz-calc(0%) 0", "0% 0px", "0% calc x"],
|
||||
[ "0 -moz-calc(0%)", "0px 0%", "0% calc y"],
|
||||
[ "-moz-calc(3px + 2% - 2%) 0", "-moz-calc(3px + 0%) 0px",
|
||||
"computed 0% calc x"],
|
||||
[ "0 -moz-calc(3px + 2% - 2%)", "0px -moz-calc(3px + 0%)",
|
||||
"computed 0% calc y"],
|
||||
[ "-moz-calc(3px - 5px) -moz-calc(6px - 7px)", "-2px -1px",
|
||||
"negative pixel width"],
|
||||
[ "", "0% 0%", "initial value" ],
|
||||
];
|
||||
|
||||
var p = document.createElement("p");
|
||||
var cs = getComputedStyle(p, "");
|
||||
frame_container.appendChild(p);
|
||||
|
||||
for (var i = 0; i < backgroundPositions.length; ++i) {
|
||||
var test = backgroundPositions[i];
|
||||
p.style.backgroundPosition = test[0];
|
||||
is(cs.backgroundPosition, test[1], "computed value of " + test[2] + " background-position");
|
||||
}
|
||||
|
||||
p.parentNode.removeChild(p);
|
||||
})();
|
||||
|
||||
(function test_bug_647885_2() {
|
||||
// Test that various background-size styles round-trip correctly
|
||||
var backgroundSizes = [
|
||||
[ "0 0", "0px 0px", "unitless 0" ],
|
||||
[ "0px 0px", "0px 0px", "0 with units" ],
|
||||
[ "0% 0%", "0% 0%", "0%" ],
|
||||
[ "-moz-calc(0px) 0", "0px 0px", "0 calc with units horizontal" ],
|
||||
[ "0 -moz-calc(0px)", "0px 0px", "0 calc with units vertical" ],
|
||||
[ "-moz-calc(3px - 3px) 0", "0px 0px", "computed 0 calc with units horizontal" ],
|
||||
[ "0 -moz-calc(3px - 3px)", "0px 0px", "computed 0 calc with units vertical" ],
|
||||
[ "-moz-calc(0%) 0", "0% 0px", "0% calc horizontal"],
|
||||
[ "0 -moz-calc(0%)", "0px 0%", "0% calc vertical"],
|
||||
[ "-moz-calc(3px + 2% - 2%) 0", "-moz-calc(3px + 0%) 0px",
|
||||
"computed 0% calc horizontal"],
|
||||
[ "0 -moz-calc(3px + 2% - 2%)", "0px -moz-calc(3px + 0%)",
|
||||
"computed 0% calc vertical"],
|
||||
[ "-moz-calc(3px - 5px) -moz-calc(6px - 9px)",
|
||||
"-moz-calc(-2px) -moz-calc(-3px)", "negative pixel width" ],
|
||||
[ "", "auto auto", "initial value" ],
|
||||
];
|
||||
|
||||
var p = document.createElement("p");
|
||||
var cs = getComputedStyle(p, "");
|
||||
frame_container.appendChild(p);
|
||||
|
||||
for (var i = 0; i < backgroundSizes.length; ++i) {
|
||||
var test = backgroundSizes[i];
|
||||
p.style.backgroundSize = test[0];
|
||||
is(cs.backgroundSize, test[1], "computed value of " + test[2] + " background-size");
|
||||
}
|
||||
|
||||
p.parentNode.removeChild(p);
|
||||
})();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче