mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Fix regression of background-position serialization. b=258080 r+sr=bzbarsky
This commit is contained in:
parent
f792615997
commit
028b212457
@ -230,6 +230,14 @@
|
||||
#define NS_STYLE_BG_ORIGIN_PADDING 1
|
||||
#define NS_STYLE_BG_ORIGIN_CONTENT 2
|
||||
|
||||
// See nsStyleBackground
|
||||
// The parser code depends on |ing these values together.
|
||||
#define NS_STYLE_BG_POSITION_CENTER (1<<0)
|
||||
#define NS_STYLE_BG_POSITION_TOP (1<<1)
|
||||
#define NS_STYLE_BG_POSITION_BOTTOM (1<<2)
|
||||
#define NS_STYLE_BG_POSITION_LEFT (1<<3)
|
||||
#define NS_STYLE_BG_POSITION_RIGHT (1<<4)
|
||||
|
||||
// See nsStyleBackground
|
||||
#define NS_STYLE_BG_REPEAT_OFF 0x00
|
||||
#define NS_STYLE_BG_REPEAT_X 0x01
|
||||
|
@ -4344,26 +4344,14 @@ PRBool CSSParserImpl::ParseProperty(nsresult& aErrorCode,
|
||||
}
|
||||
|
||||
// Bits used in determining which background position info we have
|
||||
#define BG_CENTER 0x01
|
||||
#define BG_TOP 0x02
|
||||
#define BG_BOTTOM 0x04
|
||||
#define BG_LEFT 0x08
|
||||
#define BG_RIGHT 0x10
|
||||
#define BG_CENTER NS_STYLE_BG_POSITION_CENTER
|
||||
#define BG_TOP NS_STYLE_BG_POSITION_TOP
|
||||
#define BG_BOTTOM NS_STYLE_BG_POSITION_BOTTOM
|
||||
#define BG_LEFT NS_STYLE_BG_POSITION_LEFT
|
||||
#define BG_RIGHT NS_STYLE_BG_POSITION_RIGHT
|
||||
#define BG_CTB (BG_CENTER | BG_TOP | BG_BOTTOM)
|
||||
#define BG_CLR (BG_CENTER | BG_LEFT | BG_RIGHT)
|
||||
|
||||
// Note: Don't change this table unless you update
|
||||
// parseBackgroundPosition!
|
||||
|
||||
static const PRInt32 kBackgroundXYPositionKTable[] = {
|
||||
eCSSKeyword_center, BG_CENTER,
|
||||
eCSSKeyword_top, BG_TOP,
|
||||
eCSSKeyword_bottom, BG_BOTTOM,
|
||||
eCSSKeyword_left, BG_LEFT,
|
||||
eCSSKeyword_right, BG_RIGHT,
|
||||
-1,
|
||||
};
|
||||
|
||||
PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode,
|
||||
nsCSSValue& aValue,
|
||||
nsCSSProperty aPropID)
|
||||
@ -4828,25 +4816,25 @@ PRBool CSSParserImpl::ParseAzimuth(nsresult& aErrorCode, nsCSSValue& aValue)
|
||||
static nsCSSValue
|
||||
BackgroundPositionMaskToCSSValue(PRInt32 aMask, PRBool isX)
|
||||
{
|
||||
PRInt32 pct = 50;
|
||||
PRInt32 val = NS_STYLE_BG_POSITION_CENTER;
|
||||
if (isX) {
|
||||
if (aMask & BG_LEFT) {
|
||||
pct = 0;
|
||||
val = NS_STYLE_BG_POSITION_LEFT;
|
||||
}
|
||||
else if (aMask & BG_RIGHT) {
|
||||
pct = 100;
|
||||
val = NS_STYLE_BG_POSITION_RIGHT;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (aMask & BG_TOP) {
|
||||
pct = 0;
|
||||
val = NS_STYLE_BG_POSITION_TOP;
|
||||
}
|
||||
else if (aMask & BG_BOTTOM) {
|
||||
pct = 100;
|
||||
val = NS_STYLE_BG_POSITION_BOTTOM;
|
||||
}
|
||||
}
|
||||
|
||||
return nsCSSValue(pct, eCSSUnit_Enumerated);
|
||||
return nsCSSValue(val, eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
PRBool CSSParserImpl::ParseBackground(nsresult& aErrorCode)
|
||||
@ -4956,7 +4944,7 @@ PRBool CSSParserImpl::ParseBackground(nsresult& aErrorCode)
|
||||
return PR_FALSE;
|
||||
}
|
||||
} else if (nsCSSProps::FindKeyword(keyword,
|
||||
kBackgroundXYPositionKTable, dummy)) {
|
||||
nsCSSProps::kBackgroundPositionKTable, dummy)) {
|
||||
if (havePosition)
|
||||
return PR_FALSE;
|
||||
havePosition = PR_TRUE;
|
||||
@ -5030,7 +5018,7 @@ PRBool CSSParserImpl::ParseBackgroundPositionValues(nsresult& aErrorCode)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (ParseEnum(aErrorCode, yValue, kBackgroundXYPositionKTable)) {
|
||||
if (ParseEnum(aErrorCode, yValue, nsCSSProps::kBackgroundPositionKTable)) {
|
||||
PRInt32 yVal = yValue.GetIntValue();
|
||||
if (!(yVal & BG_CTB)) {
|
||||
// The second keyword can only be 'center', 'top', or 'bottom'
|
||||
@ -5053,10 +5041,10 @@ PRBool CSSParserImpl::ParseBackgroundPositionValues(nsresult& aErrorCode)
|
||||
// any duplicate keywords other than center. We try to get two
|
||||
// keywords but it's okay if there is only one.
|
||||
PRInt32 mask = 0;
|
||||
if (ParseEnum(aErrorCode, xValue, kBackgroundXYPositionKTable)) {
|
||||
if (ParseEnum(aErrorCode, xValue, nsCSSProps::kBackgroundPositionKTable)) {
|
||||
PRInt32 bit = xValue.GetIntValue();
|
||||
mask |= bit;
|
||||
if (ParseEnum(aErrorCode, xValue, kBackgroundXYPositionKTable)) {
|
||||
if (ParseEnum(aErrorCode, xValue, nsCSSProps::kBackgroundPositionKTable)) {
|
||||
bit = xValue.GetIntValue();
|
||||
if (mask & (bit & ~BG_CENTER)) {
|
||||
// Only the 'center' keyword can be duplicated.
|
||||
|
@ -277,7 +277,7 @@ CSS_PROP_BACKGROUND(background-color, background_color, BackgroundColor, Color,
|
||||
CSS_PROP_BACKGROUND(background-image, background_image, BackgroundImage, Color, mBackImage, eCSSType_Value, nsnull)
|
||||
CSS_PROP_BACKGROUND(-moz-background-inline-policy, _moz_background_inline_policy, MozBackgroundInlinePolicy, Color, mBackInlinePolicy, eCSSType_Value, kBackgroundInlinePolicyKTable)
|
||||
CSS_PROP_BACKGROUND(-moz-background-origin, _moz_background_origin, MozBackgroundOrigin, Color, mBackOrigin, eCSSType_Value, kBackgroundOriginKTable)
|
||||
CSS_PROP_BACKGROUND(background-position, background_position, BackgroundPosition, Color, mBackPosition, eCSSType_ValuePair, nsnull)
|
||||
CSS_PROP_BACKGROUND(background-position, background_position, BackgroundPosition, Color, mBackPosition, eCSSType_ValuePair, kBackgroundPositionKTable)
|
||||
CSS_PROP_BACKGROUND(background-repeat, background_repeat, BackgroundRepeat, Color, mBackRepeat, eCSSType_Value, kBackgroundRepeatKTable)
|
||||
CSS_PROP_DISPLAY(-moz-binding, binding, MozBinding, Display, mBinding, eCSSType_Value, nsnull) // XXX bug 3935
|
||||
CSS_PROP_SHORTHAND(border, border, Border)
|
||||
|
@ -306,6 +306,18 @@ const PRInt32 nsCSSProps::kBackgroundOriginKTable[] = {
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
// Note: Don't change this table unless you update
|
||||
// parseBackgroundPosition!
|
||||
|
||||
const PRInt32 nsCSSProps::kBackgroundPositionKTable[] = {
|
||||
eCSSKeyword_center, NS_STYLE_BG_POSITION_CENTER,
|
||||
eCSSKeyword_top, NS_STYLE_BG_POSITION_TOP,
|
||||
eCSSKeyword_bottom, NS_STYLE_BG_POSITION_BOTTOM,
|
||||
eCSSKeyword_left, NS_STYLE_BG_POSITION_LEFT,
|
||||
eCSSKeyword_right, NS_STYLE_BG_POSITION_RIGHT,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kBackgroundRepeatKTable[] = {
|
||||
eCSSKeyword_no_repeat, NS_STYLE_BG_REPEAT_OFF,
|
||||
eCSSKeyword_repeat, NS_STYLE_BG_REPEAT_XY,
|
||||
@ -314,20 +326,6 @@ const PRInt32 nsCSSProps::kBackgroundRepeatKTable[] = {
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kBackgroundXPositionKTable[] = {
|
||||
eCSSKeyword_left, 0,
|
||||
eCSSKeyword_center, 50,
|
||||
eCSSKeyword_right, 100,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kBackgroundYPositionKTable[] = {
|
||||
eCSSKeyword_top, 0,
|
||||
eCSSKeyword_center, 50,
|
||||
eCSSKeyword_bottom, 100,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kBorderCollapseKTable[] = {
|
||||
eCSSKeyword_collapse, NS_STYLE_BORDER_COLLAPSE,
|
||||
eCSSKeyword_separate, NS_STYLE_BORDER_SEPARATE,
|
||||
|
@ -118,9 +118,8 @@ public:
|
||||
static const PRInt32 kBackgroundColorKTable[];
|
||||
static const PRInt32 kBackgroundInlinePolicyKTable[];
|
||||
static const PRInt32 kBackgroundOriginKTable[];
|
||||
static const PRInt32 kBackgroundPositionKTable[];
|
||||
static const PRInt32 kBackgroundRepeatKTable[];
|
||||
static const PRInt32 kBackgroundXPositionKTable[];
|
||||
static const PRInt32 kBackgroundYPositionKTable[];
|
||||
static const PRInt32 kBorderCollapseKTable[];
|
||||
static const PRInt32 kBorderColorKTable[];
|
||||
static const PRInt32 kBorderStyleKTable[];
|
||||
|
@ -3101,7 +3101,20 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct,
|
||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_PERCENT;
|
||||
}
|
||||
else if (eCSSUnit_Enumerated == colorData.mBackPosition.mXValue.GetUnit()) {
|
||||
bg->mBackgroundXPosition.mFloat = (float)colorData.mBackPosition.mXValue.GetIntValue() / 100.0f;
|
||||
switch (colorData.mBackPosition.mXValue.GetIntValue()) {
|
||||
case NS_STYLE_BG_POSITION_LEFT:
|
||||
bg->mBackgroundXPosition.mFloat = 0.0f;
|
||||
break;
|
||||
case NS_STYLE_BG_POSITION_RIGHT:
|
||||
bg->mBackgroundXPosition.mFloat = 1.0f;
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("unexpected value");
|
||||
// fall through
|
||||
case NS_STYLE_BG_POSITION_CENTER:
|
||||
bg->mBackgroundXPosition.mFloat = 0.5f;
|
||||
break;
|
||||
}
|
||||
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
||||
}
|
||||
@ -3124,7 +3137,20 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct,
|
||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||
}
|
||||
else if (eCSSUnit_Enumerated == colorData.mBackPosition.mYValue.GetUnit()) {
|
||||
bg->mBackgroundYPosition.mFloat = (float)colorData.mBackPosition.mYValue.GetIntValue() / 100.0f;
|
||||
switch (colorData.mBackPosition.mYValue.GetIntValue()) {
|
||||
case NS_STYLE_BG_POSITION_TOP:
|
||||
bg->mBackgroundYPosition.mFloat = 0.0f;
|
||||
break;
|
||||
case NS_STYLE_BG_POSITION_BOTTOM:
|
||||
bg->mBackgroundYPosition.mFloat = 1.0f;
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("unexpected value");
|
||||
// fall through
|
||||
case NS_STYLE_BG_POSITION_CENTER:
|
||||
bg->mBackgroundYPosition.mFloat = 0.5f;
|
||||
break;
|
||||
}
|
||||
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
||||
}
|
||||
|
@ -154,11 +154,6 @@ function xfail_idparseser(property, value)
|
||||
if (property == "cue" && value == "none")
|
||||
return true;
|
||||
|
||||
// Can't serialize keywords for background-position (bug 258080)
|
||||
if ((property == "background-position" || property == "background") &&
|
||||
value.match(/(top|bottom|center|right|left)/))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -181,11 +176,6 @@ function xfail_idsersplitparse_compute(property, subprop, value, step1subcomp)
|
||||
|
||||
function xfail_idparsesplitser(property, value)
|
||||
{
|
||||
// Can't serialize keywords for background-position (bug 258080)
|
||||
if (property == "background" &&
|
||||
value.match(/(top|bottom|center|right|left)/))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user