mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
Bug 271869. mBorderWidths need not be per-nsStyleBorder/nsStyleOutline, put it in the prescontext instead. r+sr=dbaron
This commit is contained in:
parent
40d0d3cc54
commit
c59dda520c
@ -3352,7 +3352,7 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct,
|
||||
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Border), aHighestNode);
|
||||
}
|
||||
|
||||
border->RecalcData();
|
||||
border->RecalcData(mPresContext);
|
||||
return border;
|
||||
}
|
||||
|
||||
@ -3510,7 +3510,7 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct,
|
||||
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Outline), aHighestNode);
|
||||
}
|
||||
|
||||
outline->RecalcData();
|
||||
outline->RecalcData(mPresContext);
|
||||
return outline;
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ struct nsStyleBorder: public nsStyleStruct {
|
||||
void Destroy(nsPresContext* aContext);
|
||||
|
||||
PRBool IsBorderSideVisible(PRUint8 aSide) const;
|
||||
void RecalcData();
|
||||
void RecalcData(nsPresContext* aContext);
|
||||
nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
|
||||
#ifdef DEBUG
|
||||
static nsChangeHint MaxDifference();
|
||||
@ -467,9 +467,6 @@ protected:
|
||||
PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h
|
||||
nscolor mBorderColor[4]; // [reset] the colors to use for a simple border. not used
|
||||
// if -moz-border-colors is specified
|
||||
|
||||
// XXX remove with deprecated methods
|
||||
nscoord mBorderWidths[3];
|
||||
};
|
||||
|
||||
|
||||
@ -514,7 +511,7 @@ struct nsStyleOutline: public nsStyleStruct {
|
||||
aContext->FreeToShell(sizeof(nsStyleOutline), this);
|
||||
};
|
||||
|
||||
void RecalcData();
|
||||
void RecalcData(nsPresContext* aContext);
|
||||
nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
|
||||
#ifdef DEBUG
|
||||
static nsChangeHint MaxDifference();
|
||||
@ -588,9 +585,6 @@ protected:
|
||||
|
||||
nscolor mOutlineColor; // [reset]
|
||||
|
||||
// XXX remove with deprecated methods
|
||||
nscoord mBorderWidths[3];
|
||||
|
||||
PRPackedBool mHasCachedOutline;
|
||||
PRUint8 mOutlineStyle; // [reset] See nsStyleConsts.h
|
||||
};
|
||||
|
@ -441,15 +441,6 @@ nsStylePadding::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const
|
||||
|
||||
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
|
||||
{
|
||||
// XXX support mBorderWidths until deprecated methods are removed
|
||||
float pixelsToTwips = 20.0f;
|
||||
if (aPresContext) {
|
||||
pixelsToTwips = aPresContext->PixelsToTwips();
|
||||
}
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
||||
|
||||
// spacing values not inherited
|
||||
nsStyleCoord medium(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated);
|
||||
mBorder.SetLeft(medium);
|
||||
@ -513,7 +504,7 @@ PRBool nsStyleBorder::IsBorderSideVisible(PRUint8 aSide) const
|
||||
&& (borderStyle != NS_STYLE_BORDER_STYLE_HIDDEN));
|
||||
}
|
||||
|
||||
void nsStyleBorder::RecalcData()
|
||||
void nsStyleBorder::RecalcData(nsPresContext* aContext)
|
||||
{
|
||||
PRBool allFixed = PR_TRUE;
|
||||
{NS_FOR_CSS_SIDES(side) {
|
||||
@ -525,9 +516,10 @@ void nsStyleBorder::RecalcData()
|
||||
}}
|
||||
if (allFixed) {
|
||||
nsStyleCoord coord;
|
||||
const nscoord* borderWidths = aContext->GetBorderWidthTable();
|
||||
NS_FOR_CSS_SIDES(side) {
|
||||
mCachedBorder.*(gMarginSides[side]) = IsBorderSideVisible(side)
|
||||
? CalcCoord(mBorder.Get(side, coord), mBorderWidths, 3)
|
||||
? CalcCoord(mBorder.Get(side, coord), borderWidths, 3)
|
||||
: 0;
|
||||
}
|
||||
mHasCachedBorder = PR_TRUE;
|
||||
@ -602,7 +594,8 @@ nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
|
||||
if (mHasCachedBorder) {
|
||||
aBorder = mCachedBorder;
|
||||
} else {
|
||||
CalcSidesFor(aFrame, mBorder, NS_SPACING_BORDER, mBorderWidths, 3, aBorder);
|
||||
CalcSidesFor(aFrame, mBorder, NS_SPACING_BORDER,
|
||||
aFrame->GetPresContext()->GetBorderWidthTable(), 3, aBorder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,19 +618,12 @@ nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, PRUint8 aSide, nscoord& aWi
|
||||
default: // NS_SIDE_LEFT
|
||||
coord = mBorder.GetLeft(coord);
|
||||
}
|
||||
aWidth = CalcSideFor(aFrame, coord, NS_SPACING_BORDER, aSide, mBorderWidths, 3);
|
||||
aWidth = CalcSideFor(aFrame, coord, NS_SPACING_BORDER, aSide,
|
||||
aFrame->GetPresContext()->GetBorderWidthTable(), 3);
|
||||
}
|
||||
|
||||
nsStyleOutline::nsStyleOutline(nsPresContext* aPresContext)
|
||||
{
|
||||
// XXX support mBorderWidths until deprecated methods are removed
|
||||
float pixelsToTwips = 20.0f;
|
||||
if (aPresContext)
|
||||
pixelsToTwips = aPresContext->PixelsToTwips();
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
||||
|
||||
// spacing values not inherited
|
||||
mOutlineRadius.Reset();
|
||||
mOutlineOffset.Reset();
|
||||
@ -655,15 +641,16 @@ nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc) {
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleOutline::RecalcData(void)
|
||||
nsStyleOutline::RecalcData(nsPresContext* aContext)
|
||||
{
|
||||
if ((NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle()) ||
|
||||
IsFixedUnit(mOutlineWidth.GetUnit(), PR_TRUE)) {
|
||||
const nscoord* borderWidths = aContext->GetBorderWidthTable();
|
||||
if (NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle())
|
||||
mCachedOutlineWidth = 0;
|
||||
else
|
||||
mCachedOutlineWidth = CalcCoord(mOutlineWidth, mBorderWidths, 3);
|
||||
mCachedOutlineOffset = CalcCoord(mOutlineOffset, mBorderWidths, 3);
|
||||
mCachedOutlineWidth = CalcCoord(mOutlineWidth, borderWidths, 3);
|
||||
mCachedOutlineOffset = CalcCoord(mOutlineOffset, borderWidths, 3);
|
||||
mHasCachedOutline = PR_TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -690,6 +690,11 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
||||
mInitialized = PR_TRUE;
|
||||
#endif
|
||||
|
||||
float pixelsToTwips = PixelsToTwips();
|
||||
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
||||
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
||||
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -595,6 +595,12 @@ public:
|
||||
nsIFrame * aFrame, PRUint32 aColor);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This table maps border-width enums 'thin', 'medium', 'thick'
|
||||
* to actual nscoord values.
|
||||
*/
|
||||
const nscoord* GetBorderWidthTable() { return mBorderWidthTable; }
|
||||
|
||||
protected:
|
||||
NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
|
||||
NS_HIDDEN_(void) GetDocumentColorPreferences();
|
||||
@ -670,6 +676,8 @@ protected:
|
||||
nsFont mDefaultCursiveFont;
|
||||
nsFont mDefaultFantasyFont;
|
||||
|
||||
nscoord mBorderWidthTable[3];
|
||||
|
||||
unsigned mUseDocumentFonts : 1;
|
||||
unsigned mUseDocumentColors : 1;
|
||||
unsigned mUnderlineLinks : 1;
|
||||
|
@ -595,6 +595,12 @@ public:
|
||||
nsIFrame * aFrame, PRUint32 aColor);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This table maps border-width enums 'thin', 'medium', 'thick'
|
||||
* to actual nscoord values.
|
||||
*/
|
||||
const nscoord* GetBorderWidthTable() { return mBorderWidthTable; }
|
||||
|
||||
protected:
|
||||
NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
|
||||
NS_HIDDEN_(void) GetDocumentColorPreferences();
|
||||
@ -670,6 +676,8 @@ protected:
|
||||
nsFont mDefaultCursiveFont;
|
||||
nsFont mDefaultFantasyFont;
|
||||
|
||||
nscoord mBorderWidthTable[3];
|
||||
|
||||
unsigned mUseDocumentFonts : 1;
|
||||
unsigned mUseDocumentColors : 1;
|
||||
unsigned mUnderlineLinks : 1;
|
||||
|
@ -690,6 +690,11 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
||||
mInitialized = PR_TRUE;
|
||||
#endif
|
||||
|
||||
float pixelsToTwips = PixelsToTwips();
|
||||
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
||||
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
||||
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1332,7 @@ nsBCTableCellFrame::PaintUnderlay(nsPresContext& aPresContext,
|
||||
myBorder.mBorder.SetBottom(coord);
|
||||
coord.SetCoordValue(borderWidth.left);
|
||||
myBorder.mBorder.SetLeft(coord);
|
||||
myBorder.RecalcData();
|
||||
myBorder.RecalcData(&aPresContext);
|
||||
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
|
||||
|
@ -213,7 +213,7 @@ TableBackgroundPainter::TableBackgroundData::SetBCBorder(nsMargin& aBorder,
|
||||
mSynthBorder->mBorder.SetBottom(coord);
|
||||
coord.SetCoordValue(aBorder.left);
|
||||
mSynthBorder->mBorder.SetLeft(coord);
|
||||
mSynthBorder->RecalcData();
|
||||
mSynthBorder->RecalcData(aPainter->mPresContext);
|
||||
|
||||
mBorder = mSynthBorder;
|
||||
return NS_OK;
|
||||
@ -242,7 +242,7 @@ TableBackgroundPainter::TableBackgroundPainter(nsTableFrame* aTableFrame,
|
||||
mZeroBorder.mBorder.SetRight(coord);
|
||||
mZeroBorder.mBorder.SetBottom(coord);
|
||||
mZeroBorder.mBorder.SetLeft(coord);
|
||||
mZeroBorder.RecalcData();
|
||||
mZeroBorder.RecalcData(aPresContext);
|
||||
|
||||
mZeroPadding.RecalcData();
|
||||
|
||||
|
@ -3352,7 +3352,7 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct,
|
||||
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Border), aHighestNode);
|
||||
}
|
||||
|
||||
border->RecalcData();
|
||||
border->RecalcData(mPresContext);
|
||||
return border;
|
||||
}
|
||||
|
||||
@ -3510,7 +3510,7 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct,
|
||||
PropagateDependentBit(NS_STYLE_INHERIT_BIT(Outline), aHighestNode);
|
||||
}
|
||||
|
||||
outline->RecalcData();
|
||||
outline->RecalcData(mPresContext);
|
||||
return outline;
|
||||
}
|
||||
|
||||
|
@ -441,15 +441,6 @@ nsStylePadding::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const
|
||||
|
||||
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
|
||||
{
|
||||
// XXX support mBorderWidths until deprecated methods are removed
|
||||
float pixelsToTwips = 20.0f;
|
||||
if (aPresContext) {
|
||||
pixelsToTwips = aPresContext->PixelsToTwips();
|
||||
}
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
||||
|
||||
// spacing values not inherited
|
||||
nsStyleCoord medium(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated);
|
||||
mBorder.SetLeft(medium);
|
||||
@ -513,7 +504,7 @@ PRBool nsStyleBorder::IsBorderSideVisible(PRUint8 aSide) const
|
||||
&& (borderStyle != NS_STYLE_BORDER_STYLE_HIDDEN));
|
||||
}
|
||||
|
||||
void nsStyleBorder::RecalcData()
|
||||
void nsStyleBorder::RecalcData(nsPresContext* aContext)
|
||||
{
|
||||
PRBool allFixed = PR_TRUE;
|
||||
{NS_FOR_CSS_SIDES(side) {
|
||||
@ -525,9 +516,10 @@ void nsStyleBorder::RecalcData()
|
||||
}}
|
||||
if (allFixed) {
|
||||
nsStyleCoord coord;
|
||||
const nscoord* borderWidths = aContext->GetBorderWidthTable();
|
||||
NS_FOR_CSS_SIDES(side) {
|
||||
mCachedBorder.*(gMarginSides[side]) = IsBorderSideVisible(side)
|
||||
? CalcCoord(mBorder.Get(side, coord), mBorderWidths, 3)
|
||||
? CalcCoord(mBorder.Get(side, coord), borderWidths, 3)
|
||||
: 0;
|
||||
}
|
||||
mHasCachedBorder = PR_TRUE;
|
||||
@ -602,7 +594,8 @@ nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
|
||||
if (mHasCachedBorder) {
|
||||
aBorder = mCachedBorder;
|
||||
} else {
|
||||
CalcSidesFor(aFrame, mBorder, NS_SPACING_BORDER, mBorderWidths, 3, aBorder);
|
||||
CalcSidesFor(aFrame, mBorder, NS_SPACING_BORDER,
|
||||
aFrame->GetPresContext()->GetBorderWidthTable(), 3, aBorder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,19 +618,12 @@ nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, PRUint8 aSide, nscoord& aWi
|
||||
default: // NS_SIDE_LEFT
|
||||
coord = mBorder.GetLeft(coord);
|
||||
}
|
||||
aWidth = CalcSideFor(aFrame, coord, NS_SPACING_BORDER, aSide, mBorderWidths, 3);
|
||||
aWidth = CalcSideFor(aFrame, coord, NS_SPACING_BORDER, aSide,
|
||||
aFrame->GetPresContext()->GetBorderWidthTable(), 3);
|
||||
}
|
||||
|
||||
nsStyleOutline::nsStyleOutline(nsPresContext* aPresContext)
|
||||
{
|
||||
// XXX support mBorderWidths until deprecated methods are removed
|
||||
float pixelsToTwips = 20.0f;
|
||||
if (aPresContext)
|
||||
pixelsToTwips = aPresContext->PixelsToTwips();
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
||||
mBorderWidths[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
||||
|
||||
// spacing values not inherited
|
||||
mOutlineRadius.Reset();
|
||||
mOutlineOffset.Reset();
|
||||
@ -655,15 +641,16 @@ nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc) {
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleOutline::RecalcData(void)
|
||||
nsStyleOutline::RecalcData(nsPresContext* aContext)
|
||||
{
|
||||
if ((NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle()) ||
|
||||
IsFixedUnit(mOutlineWidth.GetUnit(), PR_TRUE)) {
|
||||
const nscoord* borderWidths = aContext->GetBorderWidthTable();
|
||||
if (NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle())
|
||||
mCachedOutlineWidth = 0;
|
||||
else
|
||||
mCachedOutlineWidth = CalcCoord(mOutlineWidth, mBorderWidths, 3);
|
||||
mCachedOutlineOffset = CalcCoord(mOutlineOffset, mBorderWidths, 3);
|
||||
mCachedOutlineWidth = CalcCoord(mOutlineWidth, borderWidths, 3);
|
||||
mCachedOutlineOffset = CalcCoord(mOutlineOffset, borderWidths, 3);
|
||||
mHasCachedOutline = PR_TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -341,7 +341,7 @@ struct nsStyleBorder: public nsStyleStruct {
|
||||
void Destroy(nsPresContext* aContext);
|
||||
|
||||
PRBool IsBorderSideVisible(PRUint8 aSide) const;
|
||||
void RecalcData();
|
||||
void RecalcData(nsPresContext* aContext);
|
||||
nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
|
||||
#ifdef DEBUG
|
||||
static nsChangeHint MaxDifference();
|
||||
@ -467,9 +467,6 @@ protected:
|
||||
PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h
|
||||
nscolor mBorderColor[4]; // [reset] the colors to use for a simple border. not used
|
||||
// if -moz-border-colors is specified
|
||||
|
||||
// XXX remove with deprecated methods
|
||||
nscoord mBorderWidths[3];
|
||||
};
|
||||
|
||||
|
||||
@ -514,7 +511,7 @@ struct nsStyleOutline: public nsStyleStruct {
|
||||
aContext->FreeToShell(sizeof(nsStyleOutline), this);
|
||||
};
|
||||
|
||||
void RecalcData();
|
||||
void RecalcData(nsPresContext* aContext);
|
||||
nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
|
||||
#ifdef DEBUG
|
||||
static nsChangeHint MaxDifference();
|
||||
@ -588,9 +585,6 @@ protected:
|
||||
|
||||
nscolor mOutlineColor; // [reset]
|
||||
|
||||
// XXX remove with deprecated methods
|
||||
nscoord mBorderWidths[3];
|
||||
|
||||
PRPackedBool mHasCachedOutline;
|
||||
PRUint8 mOutlineStyle; // [reset] See nsStyleConsts.h
|
||||
};
|
||||
|
@ -1332,7 +1332,7 @@ nsBCTableCellFrame::PaintUnderlay(nsPresContext& aPresContext,
|
||||
myBorder.mBorder.SetBottom(coord);
|
||||
coord.SetCoordValue(borderWidth.left);
|
||||
myBorder.mBorder.SetLeft(coord);
|
||||
myBorder.RecalcData();
|
||||
myBorder.RecalcData(&aPresContext);
|
||||
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
|
||||
|
@ -213,7 +213,7 @@ TableBackgroundPainter::TableBackgroundData::SetBCBorder(nsMargin& aBorder,
|
||||
mSynthBorder->mBorder.SetBottom(coord);
|
||||
coord.SetCoordValue(aBorder.left);
|
||||
mSynthBorder->mBorder.SetLeft(coord);
|
||||
mSynthBorder->RecalcData();
|
||||
mSynthBorder->RecalcData(aPainter->mPresContext);
|
||||
|
||||
mBorder = mSynthBorder;
|
||||
return NS_OK;
|
||||
@ -242,7 +242,7 @@ TableBackgroundPainter::TableBackgroundPainter(nsTableFrame* aTableFrame,
|
||||
mZeroBorder.mBorder.SetRight(coord);
|
||||
mZeroBorder.mBorder.SetBottom(coord);
|
||||
mZeroBorder.mBorder.SetLeft(coord);
|
||||
mZeroBorder.RecalcData();
|
||||
mZeroBorder.RecalcData(aPresContext);
|
||||
|
||||
mZeroPadding.RecalcData();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user