зеркало из https://github.com/mozilla/pjs.git
189533, background-position has low accuracy. Specifically, it was not allowing fractional percentages.
r+sr=dbaron
This commit is contained in:
Родитель
3e987a87ce
Коммит
6134063f7b
|
@ -3275,18 +3275,18 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct,
|
||||||
|
|
||||||
// background-position: enum, length, percent (flags), inherit
|
// background-position: enum, length, percent (flags), inherit
|
||||||
if (eCSSUnit_Percent == colorData.mBackPositionX.GetUnit()) {
|
if (eCSSUnit_Percent == colorData.mBackPositionX.GetUnit()) {
|
||||||
bg->mBackgroundXPosition = (nscoord)(100.0f * colorData.mBackPositionX.GetPercentValue());
|
bg->mBackgroundXPosition.mFloat = colorData.mBackPositionX.GetPercentValue();
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
else if (colorData.mBackPositionX.IsLengthUnit()) {
|
else if (colorData.mBackPositionX.IsLengthUnit()) {
|
||||||
bg->mBackgroundXPosition = CalcLength(colorData.mBackPositionX, nsnull,
|
bg->mBackgroundXPosition.mCoord = CalcLength(colorData.mBackPositionX, nsnull,
|
||||||
aContext, mPresContext, inherited);
|
aContext, mPresContext, inherited);
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_LENGTH;
|
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_LENGTH;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_PERCENT;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_PERCENT;
|
||||||
}
|
}
|
||||||
else if (eCSSUnit_Enumerated == colorData.mBackPositionX.GetUnit()) {
|
else if (eCSSUnit_Enumerated == colorData.mBackPositionX.GetUnit()) {
|
||||||
bg->mBackgroundXPosition = (nscoord)colorData.mBackPositionX.GetIntValue();
|
bg->mBackgroundXPosition.mFloat = (float)colorData.mBackPositionX.GetIntValue() / 100.0f;
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
|
@ -3298,18 +3298,18 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eCSSUnit_Percent == colorData.mBackPositionY.GetUnit()) {
|
if (eCSSUnit_Percent == colorData.mBackPositionY.GetUnit()) {
|
||||||
bg->mBackgroundYPosition = (nscoord)(100.0f * colorData.mBackPositionY.GetPercentValue());
|
bg->mBackgroundYPosition.mFloat = colorData.mBackPositionY.GetPercentValue();
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
else if (colorData.mBackPositionY.IsLengthUnit()) {
|
else if (colorData.mBackPositionY.IsLengthUnit()) {
|
||||||
bg->mBackgroundYPosition = CalcLength(colorData.mBackPositionY, nsnull,
|
bg->mBackgroundYPosition.mCoord = CalcLength(colorData.mBackPositionY, nsnull,
|
||||||
aContext, mPresContext, inherited);
|
aContext, mPresContext, inherited);
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_LENGTH;
|
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_LENGTH;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_PERCENT;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||||
}
|
}
|
||||||
else if (eCSSUnit_Enumerated == colorData.mBackPositionY.GetUnit()) {
|
else if (eCSSUnit_Enumerated == colorData.mBackPositionY.GetUnit()) {
|
||||||
bg->mBackgroundYPosition = (nscoord)colorData.mBackPositionY.GetIntValue();
|
bg->mBackgroundYPosition.mFloat = (float)colorData.mBackPositionY.GetIntValue() / 100.0f;
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -939,8 +939,8 @@ void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out,
|
||||||
(int)bg->mBackgroundFlags,
|
(int)bg->mBackgroundFlags,
|
||||||
(int)bg->mBackgroundRepeat,
|
(int)bg->mBackgroundRepeat,
|
||||||
(long)bg->mBackgroundColor,
|
(long)bg->mBackgroundColor,
|
||||||
(long)bg->mBackgroundXPosition,
|
(long)bg->mBackgroundXPosition.mCoord, // potentially lossy on some platforms
|
||||||
(long)bg->mBackgroundYPosition,
|
(long)bg->mBackgroundYPosition.mCoord, // potentially lossy on some platforms
|
||||||
NS_ConvertUCS2toUTF8(bg->mBackgroundImage).get());
|
NS_ConvertUCS2toUTF8(bg->mBackgroundImage).get());
|
||||||
|
|
||||||
// SPACING (ie. margin, padding, border, outline)
|
// SPACING (ie. margin, padding, border, outline)
|
||||||
|
|
|
@ -168,9 +168,15 @@ struct nsStyleBackground : public nsStyleStruct {
|
||||||
PRUint8 mBackgroundOrigin : 3; // [reset] See nsStyleConsts.h
|
PRUint8 mBackgroundOrigin : 3; // [reset] See nsStyleConsts.h
|
||||||
PRUint8 mBackgroundRepeat : 4; // [reset] See nsStyleConsts.h
|
PRUint8 mBackgroundRepeat : 4; // [reset] See nsStyleConsts.h
|
||||||
|
|
||||||
|
// Note: a member of this union is valid IFF the appropriate bit flag
|
||||||
|
// is set in mBackgroundFlags.
|
||||||
|
union {
|
||||||
|
nscoord mCoord;
|
||||||
|
float mFloat;
|
||||||
|
} mBackgroundXPosition, // [reset]
|
||||||
|
mBackgroundYPosition; // [reset]
|
||||||
|
|
||||||
nscolor mBackgroundColor; // [reset]
|
nscolor mBackgroundColor; // [reset]
|
||||||
nscoord mBackgroundXPosition; // [reset]
|
|
||||||
nscoord mBackgroundYPosition; // [reset]
|
|
||||||
nsString mBackgroundImage; // [reset] absolute url string
|
nsString mBackgroundImage; // [reset] absolute url string
|
||||||
|
|
||||||
PRBool IsTransparent() const
|
PRBool IsTransparent() const
|
||||||
|
@ -179,11 +185,6 @@ struct nsStyleBackground : public nsStyleStruct {
|
||||||
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE)) ==
|
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE)) ==
|
||||||
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);
|
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool IsPositioned() const
|
|
||||||
{
|
|
||||||
return mBackgroundXPosition != 0 || mBackgroundYPosition != 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BORDER_COLOR_DEFINED 0x80
|
#define BORDER_COLOR_DEFINED 0x80
|
||||||
|
|
|
@ -974,9 +974,7 @@ nsStyleBackground::nsStyleBackground(nsIPresContext* aPresContext)
|
||||||
mBackgroundClip(NS_STYLE_BG_CLIP_BORDER),
|
mBackgroundClip(NS_STYLE_BG_CLIP_BORDER),
|
||||||
mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS),
|
mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS),
|
||||||
mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING),
|
mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING),
|
||||||
mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY),
|
mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY)
|
||||||
mBackgroundXPosition(0),
|
|
||||||
mBackgroundYPosition(0)
|
|
||||||
{
|
{
|
||||||
aPresContext->GetDefaultBackgroundColor(&mBackgroundColor);
|
aPresContext->GetDefaultBackgroundColor(&mBackgroundColor);
|
||||||
}
|
}
|
||||||
|
@ -988,9 +986,9 @@ nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
||||||
mBackgroundInlinePolicy(aSource.mBackgroundInlinePolicy),
|
mBackgroundInlinePolicy(aSource.mBackgroundInlinePolicy),
|
||||||
mBackgroundOrigin(aSource.mBackgroundOrigin),
|
mBackgroundOrigin(aSource.mBackgroundOrigin),
|
||||||
mBackgroundRepeat(aSource.mBackgroundRepeat),
|
mBackgroundRepeat(aSource.mBackgroundRepeat),
|
||||||
mBackgroundColor(aSource.mBackgroundColor),
|
|
||||||
mBackgroundXPosition(aSource.mBackgroundXPosition),
|
mBackgroundXPosition(aSource.mBackgroundXPosition),
|
||||||
mBackgroundYPosition(aSource.mBackgroundYPosition),
|
mBackgroundYPosition(aSource.mBackgroundYPosition),
|
||||||
|
mBackgroundColor(aSource.mBackgroundColor),
|
||||||
mBackgroundImage(aSource.mBackgroundImage)
|
mBackgroundImage(aSource.mBackgroundImage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1007,12 +1005,18 @@ nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther)
|
||||||
(mBackgroundFlags == aOther.mBackgroundFlags) &&
|
(mBackgroundFlags == aOther.mBackgroundFlags) &&
|
||||||
(mBackgroundRepeat == aOther.mBackgroundRepeat) &&
|
(mBackgroundRepeat == aOther.mBackgroundRepeat) &&
|
||||||
(mBackgroundColor == aOther.mBackgroundColor) &&
|
(mBackgroundColor == aOther.mBackgroundColor) &&
|
||||||
(mBackgroundXPosition == aOther.mBackgroundXPosition) &&
|
|
||||||
(mBackgroundYPosition == aOther.mBackgroundYPosition) &&
|
|
||||||
(mBackgroundClip == aOther.mBackgroundClip) &&
|
(mBackgroundClip == aOther.mBackgroundClip) &&
|
||||||
(mBackgroundInlinePolicy == aOther.mBackgroundInlinePolicy) &&
|
(mBackgroundInlinePolicy == aOther.mBackgroundInlinePolicy) &&
|
||||||
(mBackgroundOrigin == aOther.mBackgroundOrigin) &&
|
(mBackgroundOrigin == aOther.mBackgroundOrigin) &&
|
||||||
(mBackgroundImage == aOther.mBackgroundImage))
|
(mBackgroundImage == aOther.mBackgroundImage) &&
|
||||||
|
((!(mBackgroundFlags & NS_STYLE_BG_X_POSITION_PERCENT) ||
|
||||||
|
(mBackgroundXPosition.mFloat == aOther.mBackgroundXPosition.mFloat)) &&
|
||||||
|
(!(mBackgroundFlags & NS_STYLE_BG_X_POSITION_LENGTH) ||
|
||||||
|
(mBackgroundXPosition.mCoord == aOther.mBackgroundXPosition.mCoord))) &&
|
||||||
|
((!(mBackgroundFlags & NS_STYLE_BG_Y_POSITION_PERCENT) ||
|
||||||
|
(mBackgroundYPosition.mFloat == aOther.mBackgroundYPosition.mFloat)) &&
|
||||||
|
(!(mBackgroundFlags & NS_STYLE_BG_Y_POSITION_LENGTH) ||
|
||||||
|
(mBackgroundYPosition.mCoord == aOther.mBackgroundYPosition.mCoord))))
|
||||||
return NS_STYLE_HINT_NONE;
|
return NS_STYLE_HINT_NONE;
|
||||||
return NS_STYLE_HINT_VISUAL;
|
return NS_STYLE_HINT_VISUAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2397,14 +2397,16 @@ ComputeBackgroundAnchorPoint(const nsStyleBackground& aColor,
|
||||||
{
|
{
|
||||||
nscoord x;
|
nscoord x;
|
||||||
if (NS_STYLE_BG_X_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
if (NS_STYLE_BG_X_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
||||||
x = aColor.mBackgroundXPosition;
|
x = aColor.mBackgroundXPosition.mCoord;
|
||||||
|
}
|
||||||
|
else if (NS_STYLE_BG_X_POSITION_PERCENT & aColor.mBackgroundFlags) {
|
||||||
|
PRFloat64 percent = PRFloat64(aColor.mBackgroundXPosition.mFloat);
|
||||||
|
nscoord tilePos = nscoord(percent * PRFloat64(aTileWidth));
|
||||||
|
nscoord boxPos = nscoord(percent * PRFloat64(aOriginBounds.width));
|
||||||
|
x = boxPos - tilePos;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nscoord t = aColor.mBackgroundXPosition;
|
x = 0;
|
||||||
float pct = float(t) / 100.0f;
|
|
||||||
nscoord tilePos = nscoord(pct * aTileWidth);
|
|
||||||
nscoord boxPos = nscoord(pct * aOriginBounds.width);
|
|
||||||
x = boxPos - tilePos;
|
|
||||||
}
|
}
|
||||||
x += aOriginBounds.x - aClipBounds.x;
|
x += aOriginBounds.x - aClipBounds.x;
|
||||||
if (NS_STYLE_BG_REPEAT_X & aColor.mBackgroundRepeat) {
|
if (NS_STYLE_BG_REPEAT_X & aColor.mBackgroundRepeat) {
|
||||||
|
@ -2434,14 +2436,16 @@ ComputeBackgroundAnchorPoint(const nsStyleBackground& aColor,
|
||||||
|
|
||||||
nscoord y;
|
nscoord y;
|
||||||
if (NS_STYLE_BG_Y_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
if (NS_STYLE_BG_Y_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
||||||
y = aColor.mBackgroundYPosition;
|
y = aColor.mBackgroundYPosition.mCoord;
|
||||||
|
}
|
||||||
|
else if (NS_STYLE_BG_Y_POSITION_PERCENT & aColor.mBackgroundFlags){
|
||||||
|
PRFloat64 percent = PRFloat64(aColor.mBackgroundYPosition.mFloat);
|
||||||
|
nscoord tilePos = nscoord(percent * PRFloat64(aTileHeight));
|
||||||
|
nscoord boxPos = nscoord(percent * PRFloat64(aOriginBounds.height));
|
||||||
|
y = boxPos - tilePos;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nscoord t = aColor.mBackgroundYPosition;
|
y = 0;
|
||||||
float pct = float(t) / 100.0f;
|
|
||||||
nscoord tilePos = nscoord(pct * aTileHeight);
|
|
||||||
nscoord boxPos = nscoord(pct * aOriginBounds.height);
|
|
||||||
y = boxPos - tilePos;
|
|
||||||
}
|
}
|
||||||
y += aOriginBounds.y - aClipBounds.y;
|
y += aOriginBounds.y - aClipBounds.y;
|
||||||
if (NS_STYLE_BG_REPEAT_Y & aColor.mBackgroundRepeat) {
|
if (NS_STYLE_BG_REPEAT_Y & aColor.mBackgroundRepeat) {
|
||||||
|
|
|
@ -2397,14 +2397,16 @@ ComputeBackgroundAnchorPoint(const nsStyleBackground& aColor,
|
||||||
{
|
{
|
||||||
nscoord x;
|
nscoord x;
|
||||||
if (NS_STYLE_BG_X_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
if (NS_STYLE_BG_X_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
||||||
x = aColor.mBackgroundXPosition;
|
x = aColor.mBackgroundXPosition.mCoord;
|
||||||
|
}
|
||||||
|
else if (NS_STYLE_BG_X_POSITION_PERCENT & aColor.mBackgroundFlags) {
|
||||||
|
PRFloat64 percent = PRFloat64(aColor.mBackgroundXPosition.mFloat);
|
||||||
|
nscoord tilePos = nscoord(percent * PRFloat64(aTileWidth));
|
||||||
|
nscoord boxPos = nscoord(percent * PRFloat64(aOriginBounds.width));
|
||||||
|
x = boxPos - tilePos;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nscoord t = aColor.mBackgroundXPosition;
|
x = 0;
|
||||||
float pct = float(t) / 100.0f;
|
|
||||||
nscoord tilePos = nscoord(pct * aTileWidth);
|
|
||||||
nscoord boxPos = nscoord(pct * aOriginBounds.width);
|
|
||||||
x = boxPos - tilePos;
|
|
||||||
}
|
}
|
||||||
x += aOriginBounds.x - aClipBounds.x;
|
x += aOriginBounds.x - aClipBounds.x;
|
||||||
if (NS_STYLE_BG_REPEAT_X & aColor.mBackgroundRepeat) {
|
if (NS_STYLE_BG_REPEAT_X & aColor.mBackgroundRepeat) {
|
||||||
|
@ -2434,14 +2436,16 @@ ComputeBackgroundAnchorPoint(const nsStyleBackground& aColor,
|
||||||
|
|
||||||
nscoord y;
|
nscoord y;
|
||||||
if (NS_STYLE_BG_Y_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
if (NS_STYLE_BG_Y_POSITION_LENGTH & aColor.mBackgroundFlags) {
|
||||||
y = aColor.mBackgroundYPosition;
|
y = aColor.mBackgroundYPosition.mCoord;
|
||||||
|
}
|
||||||
|
else if (NS_STYLE_BG_Y_POSITION_PERCENT & aColor.mBackgroundFlags){
|
||||||
|
PRFloat64 percent = PRFloat64(aColor.mBackgroundYPosition.mFloat);
|
||||||
|
nscoord tilePos = nscoord(percent * PRFloat64(aTileHeight));
|
||||||
|
nscoord boxPos = nscoord(percent * PRFloat64(aOriginBounds.height));
|
||||||
|
y = boxPos - tilePos;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nscoord t = aColor.mBackgroundYPosition;
|
y = 0;
|
||||||
float pct = float(t) / 100.0f;
|
|
||||||
nscoord tilePos = nscoord(pct * aTileHeight);
|
|
||||||
nscoord boxPos = nscoord(pct * aOriginBounds.height);
|
|
||||||
y = boxPos - tilePos;
|
|
||||||
}
|
}
|
||||||
y += aOriginBounds.y - aClipBounds.y;
|
y += aOriginBounds.y - aClipBounds.y;
|
||||||
if (NS_STYLE_BG_REPEAT_Y & aColor.mBackgroundRepeat) {
|
if (NS_STYLE_BG_REPEAT_Y & aColor.mBackgroundRepeat) {
|
||||||
|
|
|
@ -3275,18 +3275,18 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct,
|
||||||
|
|
||||||
// background-position: enum, length, percent (flags), inherit
|
// background-position: enum, length, percent (flags), inherit
|
||||||
if (eCSSUnit_Percent == colorData.mBackPositionX.GetUnit()) {
|
if (eCSSUnit_Percent == colorData.mBackPositionX.GetUnit()) {
|
||||||
bg->mBackgroundXPosition = (nscoord)(100.0f * colorData.mBackPositionX.GetPercentValue());
|
bg->mBackgroundXPosition.mFloat = colorData.mBackPositionX.GetPercentValue();
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
else if (colorData.mBackPositionX.IsLengthUnit()) {
|
else if (colorData.mBackPositionX.IsLengthUnit()) {
|
||||||
bg->mBackgroundXPosition = CalcLength(colorData.mBackPositionX, nsnull,
|
bg->mBackgroundXPosition.mCoord = CalcLength(colorData.mBackPositionX, nsnull,
|
||||||
aContext, mPresContext, inherited);
|
aContext, mPresContext, inherited);
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_LENGTH;
|
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_LENGTH;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_PERCENT;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_PERCENT;
|
||||||
}
|
}
|
||||||
else if (eCSSUnit_Enumerated == colorData.mBackPositionX.GetUnit()) {
|
else if (eCSSUnit_Enumerated == colorData.mBackPositionX.GetUnit()) {
|
||||||
bg->mBackgroundXPosition = (nscoord)colorData.mBackPositionX.GetIntValue();
|
bg->mBackgroundXPosition.mFloat = (float)colorData.mBackPositionX.GetIntValue() / 100.0f;
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
|
@ -3298,18 +3298,18 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eCSSUnit_Percent == colorData.mBackPositionY.GetUnit()) {
|
if (eCSSUnit_Percent == colorData.mBackPositionY.GetUnit()) {
|
||||||
bg->mBackgroundYPosition = (nscoord)(100.0f * colorData.mBackPositionY.GetPercentValue());
|
bg->mBackgroundYPosition.mFloat = colorData.mBackPositionY.GetPercentValue();
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
else if (colorData.mBackPositionY.IsLengthUnit()) {
|
else if (colorData.mBackPositionY.IsLengthUnit()) {
|
||||||
bg->mBackgroundYPosition = CalcLength(colorData.mBackPositionY, nsnull,
|
bg->mBackgroundYPosition.mCoord = CalcLength(colorData.mBackPositionY, nsnull,
|
||||||
aContext, mPresContext, inherited);
|
aContext, mPresContext, inherited);
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_LENGTH;
|
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_LENGTH;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_PERCENT;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||||
}
|
}
|
||||||
else if (eCSSUnit_Enumerated == colorData.mBackPositionY.GetUnit()) {
|
else if (eCSSUnit_Enumerated == colorData.mBackPositionY.GetUnit()) {
|
||||||
bg->mBackgroundYPosition = (nscoord)colorData.mBackPositionY.GetIntValue();
|
bg->mBackgroundYPosition.mFloat = (float)colorData.mBackPositionY.GetIntValue() / 100.0f;
|
||||||
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
bg->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
||||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
bg->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -939,8 +939,8 @@ void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out,
|
||||||
(int)bg->mBackgroundFlags,
|
(int)bg->mBackgroundFlags,
|
||||||
(int)bg->mBackgroundRepeat,
|
(int)bg->mBackgroundRepeat,
|
||||||
(long)bg->mBackgroundColor,
|
(long)bg->mBackgroundColor,
|
||||||
(long)bg->mBackgroundXPosition,
|
(long)bg->mBackgroundXPosition.mCoord, // potentially lossy on some platforms
|
||||||
(long)bg->mBackgroundYPosition,
|
(long)bg->mBackgroundYPosition.mCoord, // potentially lossy on some platforms
|
||||||
NS_ConvertUCS2toUTF8(bg->mBackgroundImage).get());
|
NS_ConvertUCS2toUTF8(bg->mBackgroundImage).get());
|
||||||
|
|
||||||
// SPACING (ie. margin, padding, border, outline)
|
// SPACING (ie. margin, padding, border, outline)
|
||||||
|
|
|
@ -974,9 +974,7 @@ nsStyleBackground::nsStyleBackground(nsIPresContext* aPresContext)
|
||||||
mBackgroundClip(NS_STYLE_BG_CLIP_BORDER),
|
mBackgroundClip(NS_STYLE_BG_CLIP_BORDER),
|
||||||
mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS),
|
mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS),
|
||||||
mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING),
|
mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING),
|
||||||
mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY),
|
mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY)
|
||||||
mBackgroundXPosition(0),
|
|
||||||
mBackgroundYPosition(0)
|
|
||||||
{
|
{
|
||||||
aPresContext->GetDefaultBackgroundColor(&mBackgroundColor);
|
aPresContext->GetDefaultBackgroundColor(&mBackgroundColor);
|
||||||
}
|
}
|
||||||
|
@ -988,9 +986,9 @@ nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
||||||
mBackgroundInlinePolicy(aSource.mBackgroundInlinePolicy),
|
mBackgroundInlinePolicy(aSource.mBackgroundInlinePolicy),
|
||||||
mBackgroundOrigin(aSource.mBackgroundOrigin),
|
mBackgroundOrigin(aSource.mBackgroundOrigin),
|
||||||
mBackgroundRepeat(aSource.mBackgroundRepeat),
|
mBackgroundRepeat(aSource.mBackgroundRepeat),
|
||||||
mBackgroundColor(aSource.mBackgroundColor),
|
|
||||||
mBackgroundXPosition(aSource.mBackgroundXPosition),
|
mBackgroundXPosition(aSource.mBackgroundXPosition),
|
||||||
mBackgroundYPosition(aSource.mBackgroundYPosition),
|
mBackgroundYPosition(aSource.mBackgroundYPosition),
|
||||||
|
mBackgroundColor(aSource.mBackgroundColor),
|
||||||
mBackgroundImage(aSource.mBackgroundImage)
|
mBackgroundImage(aSource.mBackgroundImage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1007,12 +1005,18 @@ nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther)
|
||||||
(mBackgroundFlags == aOther.mBackgroundFlags) &&
|
(mBackgroundFlags == aOther.mBackgroundFlags) &&
|
||||||
(mBackgroundRepeat == aOther.mBackgroundRepeat) &&
|
(mBackgroundRepeat == aOther.mBackgroundRepeat) &&
|
||||||
(mBackgroundColor == aOther.mBackgroundColor) &&
|
(mBackgroundColor == aOther.mBackgroundColor) &&
|
||||||
(mBackgroundXPosition == aOther.mBackgroundXPosition) &&
|
|
||||||
(mBackgroundYPosition == aOther.mBackgroundYPosition) &&
|
|
||||||
(mBackgroundClip == aOther.mBackgroundClip) &&
|
(mBackgroundClip == aOther.mBackgroundClip) &&
|
||||||
(mBackgroundInlinePolicy == aOther.mBackgroundInlinePolicy) &&
|
(mBackgroundInlinePolicy == aOther.mBackgroundInlinePolicy) &&
|
||||||
(mBackgroundOrigin == aOther.mBackgroundOrigin) &&
|
(mBackgroundOrigin == aOther.mBackgroundOrigin) &&
|
||||||
(mBackgroundImage == aOther.mBackgroundImage))
|
(mBackgroundImage == aOther.mBackgroundImage) &&
|
||||||
|
((!(mBackgroundFlags & NS_STYLE_BG_X_POSITION_PERCENT) ||
|
||||||
|
(mBackgroundXPosition.mFloat == aOther.mBackgroundXPosition.mFloat)) &&
|
||||||
|
(!(mBackgroundFlags & NS_STYLE_BG_X_POSITION_LENGTH) ||
|
||||||
|
(mBackgroundXPosition.mCoord == aOther.mBackgroundXPosition.mCoord))) &&
|
||||||
|
((!(mBackgroundFlags & NS_STYLE_BG_Y_POSITION_PERCENT) ||
|
||||||
|
(mBackgroundYPosition.mFloat == aOther.mBackgroundYPosition.mFloat)) &&
|
||||||
|
(!(mBackgroundFlags & NS_STYLE_BG_Y_POSITION_LENGTH) ||
|
||||||
|
(mBackgroundYPosition.mCoord == aOther.mBackgroundYPosition.mCoord))))
|
||||||
return NS_STYLE_HINT_NONE;
|
return NS_STYLE_HINT_NONE;
|
||||||
return NS_STYLE_HINT_VISUAL;
|
return NS_STYLE_HINT_VISUAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,9 +168,15 @@ struct nsStyleBackground : public nsStyleStruct {
|
||||||
PRUint8 mBackgroundOrigin : 3; // [reset] See nsStyleConsts.h
|
PRUint8 mBackgroundOrigin : 3; // [reset] See nsStyleConsts.h
|
||||||
PRUint8 mBackgroundRepeat : 4; // [reset] See nsStyleConsts.h
|
PRUint8 mBackgroundRepeat : 4; // [reset] See nsStyleConsts.h
|
||||||
|
|
||||||
|
// Note: a member of this union is valid IFF the appropriate bit flag
|
||||||
|
// is set in mBackgroundFlags.
|
||||||
|
union {
|
||||||
|
nscoord mCoord;
|
||||||
|
float mFloat;
|
||||||
|
} mBackgroundXPosition, // [reset]
|
||||||
|
mBackgroundYPosition; // [reset]
|
||||||
|
|
||||||
nscolor mBackgroundColor; // [reset]
|
nscolor mBackgroundColor; // [reset]
|
||||||
nscoord mBackgroundXPosition; // [reset]
|
|
||||||
nscoord mBackgroundYPosition; // [reset]
|
|
||||||
nsString mBackgroundImage; // [reset] absolute url string
|
nsString mBackgroundImage; // [reset] absolute url string
|
||||||
|
|
||||||
PRBool IsTransparent() const
|
PRBool IsTransparent() const
|
||||||
|
@ -179,11 +185,6 @@ struct nsStyleBackground : public nsStyleStruct {
|
||||||
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE)) ==
|
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE)) ==
|
||||||
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);
|
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool IsPositioned() const
|
|
||||||
{
|
|
||||||
return mBackgroundXPosition != 0 || mBackgroundYPosition != 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BORDER_COLOR_DEFINED 0x80
|
#define BORDER_COLOR_DEFINED 0x80
|
||||||
|
|
Загрузка…
Ссылка в новой задаче