Better API for used padding/border/margin: remove deprecated Calc*For on nsStyleStructs and add GetUsed* to nsIFrame. b=332922 r+sr=roc
git-svn-id: svn://10.0.0.236/trunk@216965 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d9604b2cd3
commit
866a194991
@ -1399,6 +1399,8 @@ GK_ATOM(overflowPlaceholdersProperty, "OverflowPlaceholdersProperty") // nsFram
|
||||
GK_ATOM(rowUnpaginatedHeightProperty, "RowUnpaginatedHeightProperty") // nscoord*
|
||||
GK_ATOM(spaceManagerProperty, "SpaceManagerProperty") // the space manager for a block
|
||||
GK_ATOM(tableBCProperty, "TableBCProperty") // table border collapsing info (e.g. damage area, table border widths)
|
||||
GK_ATOM(usedMarginProperty, "UsedMarginProperty") // nsMargin*
|
||||
GK_ATOM(usedPaddingProperty, "UsedPaddingProperty") // nsMargin*
|
||||
GK_ATOM(viewProperty, "ViewProperty")
|
||||
|
||||
// Languages for lang-specific transforms
|
||||
|
||||
@ -1150,11 +1150,7 @@ const nsSize
|
||||
nsGenericHTMLElement::GetClientAreaSize(nsIFrame *aFrame)
|
||||
{
|
||||
nsRect rect = aFrame->GetRect();
|
||||
|
||||
const nsStyleBorder* border = aFrame->GetStyleBorder();
|
||||
|
||||
nsMargin border_size;
|
||||
border->CalcBorderFor(aFrame, border_size);
|
||||
nsMargin border_size = aFrame->GetUsedBorder();
|
||||
|
||||
rect.Deflate(border_size);
|
||||
|
||||
|
||||
@ -348,8 +348,7 @@ nsHTMLImageElement::GetWidthHeight()
|
||||
// mComputedSize.....
|
||||
size = frame->GetSize();
|
||||
|
||||
nsMargin margin;
|
||||
frame->CalcBorderPadding(margin);
|
||||
nsMargin margin = frame->GetUsedBorderAndPadding();
|
||||
|
||||
size.height -= margin.top + margin.bottom;
|
||||
size.width -= margin.left + margin.right;
|
||||
|
||||
@ -1705,7 +1705,7 @@ void nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
|
||||
if (aHardBorderSize > 0) {
|
||||
border.SizeTo(aHardBorderSize, aHardBorderSize, aHardBorderSize, aHardBorderSize);
|
||||
} else {
|
||||
aBorderStyle.CalcBorderFor(aForFrame, border);
|
||||
border = aBorderStyle.GetBorder();
|
||||
}
|
||||
if ((0 == border.left) && (0 == border.right) &&
|
||||
(0 == border.top) && (0 == border.bottom)) {
|
||||
@ -3007,9 +3007,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
|
||||
// XXXldb What about SkipSides?
|
||||
bgOriginArea.Deflate(aBorder.GetBorder());
|
||||
if (aColor.mBackgroundOrigin != NS_STYLE_BG_ORIGIN_PADDING) {
|
||||
nsMargin padding;
|
||||
// XXX CalcPaddingFor is deprecated, but we need it for percentage padding
|
||||
aPadding.CalcPaddingFor(aForFrame, padding);
|
||||
nsMargin padding = aForFrame->GetUsedPadding();
|
||||
// XXXldb What about SkipSides?
|
||||
bgOriginArea.Deflate(padding);
|
||||
NS_ASSERTION(aColor.mBackgroundOrigin == NS_STYLE_BG_ORIGIN_CONTENT,
|
||||
@ -3530,7 +3528,7 @@ nsCSSRendering::PaintRoundedBorder(nsPresContext* aPresContext,
|
||||
|
||||
NS_ASSERTION((aIsOutline && aOutlineStyle) || (!aIsOutline && aBorderStyle), "null params not allowed");
|
||||
if (!aIsOutline) {
|
||||
aBorderStyle->CalcBorderFor(aForFrame, border);
|
||||
border = aBorderStyle->GetBorder();
|
||||
if ((0 == border.left) && (0 == border.right) &&
|
||||
(0 == border.top) && (0 == border.bottom)) {
|
||||
return;
|
||||
|
||||
@ -216,8 +216,7 @@ nsGfxCheckboxControlFrame::PaintCheckBox(nsIRenderingContext& aRenderingContext,
|
||||
{
|
||||
// REVIEW: moved the mAppearance test out so we avoid constructing
|
||||
// a display item if it's not needed
|
||||
nsMargin borderPadding(0,0,0,0);
|
||||
CalcBorderPadding(borderPadding);
|
||||
nsMargin borderPadding = GetUsedBorderAndPadding();
|
||||
|
||||
nsRect checkRect(aPt, mRect.Size());
|
||||
checkRect.Deflate(borderPadding);
|
||||
|
||||
@ -229,10 +229,7 @@ nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
// but the real problem is the FirstChild (the AreaFrame)
|
||||
// isn't being constrained properly
|
||||
// Bug #17474
|
||||
const nsStyleBorder* borderStyle = GetStyleBorder();
|
||||
nsMargin border;
|
||||
border.SizeTo(0, 0, 0, 0);
|
||||
borderStyle->CalcBorderFor(this, border);
|
||||
nsMargin border = GetStyleBorder()->GetBorder();
|
||||
nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
|
||||
rect.Deflate(border);
|
||||
|
||||
|
||||
@ -685,20 +685,55 @@ NS_IMETHODIMP nsFrame::DidSetStyleContext()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFrame::CalcBorderPadding(nsMargin& aBorderPadding) const {
|
||||
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
|
||||
if (mStyleContext) {
|
||||
nsStyleBorderPadding bpad;
|
||||
mStyleContext->GetBorderPaddingFor(bpad);
|
||||
if (!bpad.GetBorderPadding(aBorderPadding)) {
|
||||
const nsStylePadding* paddingStyle = GetStylePadding();
|
||||
paddingStyle->CalcPaddingFor(this, aBorderPadding);
|
||||
const nsStyleBorder* borderStyle = GetStyleBorder();
|
||||
aBorderPadding += borderStyle->GetBorder();
|
||||
/* virtual */ nsMargin
|
||||
nsIFrame::GetUsedMargin() const
|
||||
{
|
||||
NS_ASSERTION(!(GetStateBits() &
|
||||
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) ||
|
||||
(GetStateBits() & NS_FRAME_IN_REFLOW),
|
||||
"cannot call on a dirty frame not currently being reflowed");
|
||||
|
||||
nsMargin margin(0, 0, 0, 0);
|
||||
if (!GetStyleMargin()->GetMargin(margin)) {
|
||||
nsMargin *m = NS_STATIC_CAST(nsMargin*,
|
||||
GetProperty(nsLayoutAtoms::usedMarginProperty));
|
||||
NS_ASSERTION(m, "used margin property missing (out of memory?)");
|
||||
if (m) {
|
||||
margin = *m;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return margin;
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsIFrame::GetUsedBorder() const
|
||||
{
|
||||
NS_ASSERTION(!(GetStateBits() &
|
||||
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) ||
|
||||
(GetStateBits() & NS_FRAME_IN_REFLOW),
|
||||
"cannot call on a dirty frame not currently being reflowed");
|
||||
|
||||
return GetStyleBorder()->GetBorder();
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsIFrame::GetUsedPadding() const
|
||||
{
|
||||
NS_ASSERTION(!(GetStateBits() &
|
||||
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) ||
|
||||
(GetStateBits() & NS_FRAME_IN_REFLOW),
|
||||
"cannot call on a dirty frame not currently being reflowed");
|
||||
|
||||
nsMargin padding(0, 0, 0, 0);
|
||||
if (!GetStylePadding()->GetPadding(padding)) {
|
||||
nsMargin *p = NS_STATIC_CAST(nsMargin*,
|
||||
GetProperty(nsLayoutAtoms::usedPaddingProperty));
|
||||
NS_ASSERTION(p, "used padding property missing (out of memory?)");
|
||||
if (p) {
|
||||
padding = *p;
|
||||
}
|
||||
}
|
||||
return padding;
|
||||
}
|
||||
|
||||
nsStyleContext*
|
||||
|
||||
@ -177,7 +177,6 @@ public:
|
||||
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
|
||||
nsIFrame* aOldFrame);
|
||||
virtual void Destroy();
|
||||
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const;
|
||||
virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const;
|
||||
virtual void SetAdditionalStyleContext(PRInt32 aIndex,
|
||||
nsStyleContext* aStyleContext);
|
||||
|
||||
@ -205,9 +205,8 @@ nsHTMLContainerFrame::PaintTextDecorationLine(
|
||||
nscoord aAscent,
|
||||
nscoord aSize)
|
||||
{
|
||||
nsMargin bp;
|
||||
NS_ASSERTION(!aLine, "Should not have passed a linebox to a non-block frame");
|
||||
CalcBorderPadding(bp);
|
||||
nsMargin bp = GetUsedBorderAndPadding();
|
||||
PRIntn skip = GetSkipSides();
|
||||
NS_FOR_CSS_SIDES(side) {
|
||||
if (skip & (1 << side)) {
|
||||
|
||||
@ -1887,6 +1887,15 @@ nsHTMLReflowState::CalcLineHeight(nsPresContext* aPresContext,
|
||||
return lineHeight;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyMarginFunc(void* aFrame,
|
||||
nsIAtom* aPropertyName,
|
||||
void* aPropertyValue,
|
||||
void* aDtorData)
|
||||
{
|
||||
delete NS_STATIC_CAST(nsMargin*, aPropertyValue);
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSOffsetState::ComputeMargin(nscoord aContainingBlockWidth)
|
||||
{
|
||||
@ -1937,6 +1946,11 @@ nsCSSOffsetState::ComputeMargin(nscoord aContainingBlockWidth)
|
||||
styleMargin->mMargin.GetBottomUnit(),
|
||||
styleMargin->mMargin.GetBottom(bottom),
|
||||
mComputedMargin.bottom);
|
||||
|
||||
// XXX We need to include 'auto' horizontal margins in this too!
|
||||
frame->SetProperty(nsLayoutAtoms::usedMarginProperty,
|
||||
new nsMargin(mComputedMargin),
|
||||
DestroyMarginFunc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1968,8 +1982,13 @@ nsCSSOffsetState::ComputePadding(nscoord aContainingBlockWidth)
|
||||
stylePadding->mPadding.GetBottomUnit(),
|
||||
stylePadding->mPadding.GetBottom(bottom),
|
||||
mComputedPadding.bottom);
|
||||
|
||||
frame->SetProperty(nsLayoutAtoms::usedPaddingProperty,
|
||||
new nsMargin(mComputedPadding),
|
||||
DestroyMarginFunc);
|
||||
}
|
||||
// a table row/col group, row/col doesn't have padding
|
||||
// XXXldb Neither do border-collapse tables.
|
||||
nsIAtom* frameType = frame->GetType();
|
||||
if (nsLayoutAtoms::tableRowGroupFrame == frameType ||
|
||||
nsLayoutAtoms::tableColGroupFrame == frameType ||
|
||||
|
||||
@ -622,10 +622,6 @@ public:
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
// Utility function: more convenient than 2 calls to GetStyleData to get border and padding
|
||||
|
||||
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const = 0;
|
||||
|
||||
/**
|
||||
* These methods are to access any additional style contexts that
|
||||
* the frame may be holding. These are contexts that are children
|
||||
@ -670,6 +666,38 @@ public:
|
||||
: GetPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the distance between the border edge of the frame and the
|
||||
* margin edge of the frame. Can only be called after Reflow for the
|
||||
* frame has at least *started*.
|
||||
*
|
||||
* This doesn't include any margin collapsing that may have occurred.
|
||||
*/
|
||||
virtual nsMargin GetUsedMargin() const;
|
||||
|
||||
/**
|
||||
* Return the distance between the border edge of the frame (which is
|
||||
* its rect) and the padding edge of the frame. Can only be called
|
||||
* after Reflow for the frame has at least *started*.
|
||||
*
|
||||
* Note that this differs from GetStyleBorder()->GetBorder() in that
|
||||
* this describes region of the frame's box, and
|
||||
* GetStyleBorder()->GetBorder() describes a border. They differ only
|
||||
* for tables, particularly border-collapse tables.
|
||||
*/
|
||||
virtual nsMargin GetUsedBorder() const;
|
||||
|
||||
/**
|
||||
* Return the distance between the padding edge of the frame and the
|
||||
* content edge of the frame. Can only be called after Reflow for the
|
||||
* frame has at least *started*.
|
||||
*/
|
||||
virtual nsMargin GetUsedPadding() const;
|
||||
|
||||
nsMargin GetUsedBorderAndPadding() const {
|
||||
return GetUsedBorder() + GetUsedPadding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to iterate the list of additional child list names. Returns the atom
|
||||
* name for the additional child list at the specified 0-based index, or a
|
||||
|
||||
@ -2066,8 +2066,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
|
||||
if (!frame)
|
||||
return NS_OK;
|
||||
|
||||
nsMargin borderPadding(0, 0, 0, 0);
|
||||
frame->CalcBorderPadding(borderPadding);
|
||||
nsMargin borderPadding = frame->GetUsedBorderAndPadding();
|
||||
nsRect rect(frame->GetRect());
|
||||
rect.Deflate(borderPadding);
|
||||
adjSize = rect.Size();
|
||||
|
||||
@ -2739,16 +2739,10 @@ nsComputedDOMStyle::GetHeight(nsIFrame *aFrame,
|
||||
}
|
||||
|
||||
if (calcHeight) {
|
||||
nsMargin padding;
|
||||
nsMargin border;
|
||||
nsMargin bp = aFrame->GetUsedBorderAndPadding();
|
||||
nsSize size = aFrame->GetSize();
|
||||
const nsStylePadding* paddingData = aFrame->GetStylePadding();
|
||||
paddingData->CalcPaddingFor(aFrame, padding);
|
||||
const nsStyleBorder* borderData = aFrame->GetStyleBorder();
|
||||
borderData->CalcBorderFor(aFrame, border);
|
||||
|
||||
val->SetTwips(size.height - padding.top - padding.bottom -
|
||||
border.top - border.bottom);
|
||||
val->SetTwips(size.height - bp.TopBottom());
|
||||
} else {
|
||||
// Just return the value in the style context
|
||||
const nsStylePosition* positionData = nsnull;
|
||||
@ -2801,14 +2795,8 @@ nsComputedDOMStyle::GetWidth(nsIFrame *aFrame,
|
||||
|
||||
if (calcWidth) {
|
||||
nsSize size = aFrame->GetSize();
|
||||
nsMargin padding;
|
||||
nsMargin border;
|
||||
const nsStylePadding *paddingData = aFrame->GetStylePadding();
|
||||
paddingData->CalcPaddingFor(aFrame, padding);
|
||||
const nsStyleBorder *borderData = aFrame->GetStyleBorder();
|
||||
borderData->CalcBorderFor(aFrame, border);
|
||||
val->SetTwips(size.width - padding.left - padding.right -
|
||||
border.left - border.right);
|
||||
nsMargin bp = aFrame->GetUsedBorderAndPadding();
|
||||
val->SetTwips(size.width - bp.LeftRight());
|
||||
} else {
|
||||
// Just return the value in the style context
|
||||
const nsStylePosition *positionData = nsnull;
|
||||
@ -3200,19 +3188,14 @@ nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIFrame* aFrame,
|
||||
case eStyleUnit_Percent:
|
||||
container = GetContainingBlockFor(aFrame);
|
||||
if (container) {
|
||||
nsMargin border;
|
||||
nsMargin padding;
|
||||
container->GetStyleBorder()->CalcBorderFor(container, border);
|
||||
container->GetStylePadding()->CalcPaddingFor(container, padding);
|
||||
nsMargin bp = container->GetUsedBorderAndPadding();
|
||||
nsSize size = container->GetSize();
|
||||
if (aSide == NS_SIDE_LEFT || aSide == NS_SIDE_RIGHT) {
|
||||
val->SetTwips(sign * coord.GetPercentValue() *
|
||||
(size.width - border.left - border.right -
|
||||
padding.left - padding.right));
|
||||
(size.width - bp.LeftRight()));
|
||||
} else {
|
||||
val->SetTwips(sign * coord.GetPercentValue() *
|
||||
(size.height - border.top - border.bottom -
|
||||
padding.top - padding.bottom));
|
||||
(size.height - bp.TopBottom()));
|
||||
}
|
||||
} else {
|
||||
// XXX no containing block.
|
||||
@ -3333,26 +3316,19 @@ nsComputedDOMStyle::GetPaddingWidthFor(PRUint8 aSide, nsIFrame *aFrame,
|
||||
nscoord
|
||||
nsComputedDOMStyle::GetPaddingWidthCoordFor(PRUint8 aSide, nsIFrame* aFrame)
|
||||
{
|
||||
const nsStylePadding* paddingData = nsnull;
|
||||
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingData,
|
||||
aFrame);
|
||||
|
||||
if (paddingData) {
|
||||
nsMargin padding;
|
||||
paddingData->CalcPaddingFor(aFrame, padding);
|
||||
switch(aSide) {
|
||||
case NS_SIDE_TOP :
|
||||
return padding.top;
|
||||
case NS_SIDE_BOTTOM :
|
||||
return padding.bottom;
|
||||
case NS_SIDE_LEFT :
|
||||
return padding.left;
|
||||
case NS_SIDE_RIGHT :
|
||||
return padding.right;
|
||||
default:
|
||||
NS_ERROR("Invalid side");
|
||||
break;
|
||||
}
|
||||
nsMargin padding = aFrame->GetUsedPadding();
|
||||
switch(aSide) {
|
||||
case NS_SIDE_TOP :
|
||||
return padding.top;
|
||||
case NS_SIDE_BOTTOM :
|
||||
return padding.bottom;
|
||||
case NS_SIDE_LEFT :
|
||||
return padding.left;
|
||||
case NS_SIDE_RIGHT :
|
||||
return padding.right;
|
||||
default:
|
||||
NS_ERROR("Invalid side");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -3361,28 +3337,11 @@ nsComputedDOMStyle::GetPaddingWidthCoordFor(PRUint8 aSide, nsIFrame* aFrame)
|
||||
nscoord
|
||||
nsComputedDOMStyle::GetBorderWidthCoordFor(PRUint8 aSide, nsIFrame *aFrame)
|
||||
{
|
||||
nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
|
||||
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
const nsStyleBorder* borderData = nsnull;
|
||||
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderData, aFrame);
|
||||
|
||||
if (borderData) {
|
||||
nsMargin border;
|
||||
borderData->CalcBorderFor(aFrame, border);
|
||||
switch(aSide) {
|
||||
case NS_SIDE_TOP :
|
||||
return border.top;
|
||||
case NS_SIDE_BOTTOM :
|
||||
return border.bottom;
|
||||
case NS_SIDE_LEFT :
|
||||
return border.left;
|
||||
case NS_SIDE_RIGHT :
|
||||
return border.right;
|
||||
default:
|
||||
NS_ERROR("Invalid side");
|
||||
break;
|
||||
}
|
||||
return borderData->GetBorderWidth(aSide);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -3529,9 +3488,7 @@ nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide, nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border, aFrame);
|
||||
|
||||
if (border) {
|
||||
nscoord width;
|
||||
border->CalcBorderFor(aFrame, aSide, width);
|
||||
val->SetTwips(width);
|
||||
val->SetTwips(border->GetBorderWidth(aSide));
|
||||
}
|
||||
|
||||
return CallQueryInterface(val, aValue);
|
||||
@ -3594,24 +3551,19 @@ nsComputedDOMStyle::GetMarginWidthFor(PRUint8 aSide, nsIFrame *aFrame,
|
||||
nscoord
|
||||
nsComputedDOMStyle::GetMarginWidthCoordFor(PRUint8 aSide, nsIFrame *aFrame)
|
||||
{
|
||||
const nsStyleMargin* marginData = nsnull;
|
||||
GetStyleData(eStyleStruct_Margin, (const nsStyleStruct*&)marginData, aFrame);
|
||||
if (marginData) {
|
||||
nsMargin margin;
|
||||
marginData->CalcMarginFor(aFrame, margin);
|
||||
switch(aSide) {
|
||||
case NS_SIDE_TOP :
|
||||
return margin.top;
|
||||
case NS_SIDE_BOTTOM :
|
||||
return margin.bottom;
|
||||
case NS_SIDE_LEFT :
|
||||
return margin.left;
|
||||
case NS_SIDE_RIGHT :
|
||||
return margin.right;
|
||||
default:
|
||||
NS_ERROR("Invalid side");
|
||||
break;
|
||||
}
|
||||
nsMargin margin = aFrame->GetUsedMargin();
|
||||
switch(aSide) {
|
||||
case NS_SIDE_TOP :
|
||||
return margin.top;
|
||||
case NS_SIDE_BOTTOM :
|
||||
return margin.bottom;
|
||||
case NS_SIDE_LEFT :
|
||||
return margin.left;
|
||||
case NS_SIDE_RIGHT :
|
||||
return margin.right;
|
||||
default:
|
||||
NS_ERROR("Invalid side");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -69,80 +69,6 @@ inline PRBool IsFixedUnit(nsStyleUnit aUnit, PRBool aEnumOK)
|
||||
(aEnumOK && (aUnit == eStyleUnit_Enumerated)));
|
||||
}
|
||||
|
||||
// XXX this is here to support deprecated calc spacing methods only
|
||||
// XXXldb Probably shouldn't be inline.
|
||||
inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
|
||||
PRUint8 aSpacing, PRUint8 aSide)
|
||||
{
|
||||
nscoord result = 0;
|
||||
|
||||
switch (aCoord.GetUnit()) {
|
||||
case eStyleUnit_Auto:
|
||||
// Auto margins are handled by layout
|
||||
break;
|
||||
|
||||
case eStyleUnit_Percent:
|
||||
{
|
||||
nscoord baseWidth = 0;
|
||||
nsIFrame* frame = aFrame ?
|
||||
nsHTMLReflowState::GetContainingBlockFor(aFrame) : nsnull;
|
||||
if (frame) {
|
||||
baseWidth = frame->GetSize().width;
|
||||
// subtract border of containing block
|
||||
nsMargin border;
|
||||
frame->GetStyleBorder()->CalcBorderFor(frame, border);
|
||||
baseWidth -= (border.left + border.right);
|
||||
// if aFrame is not absolutely positioned, subtract
|
||||
// padding of containing block
|
||||
const nsStyleDisplay* displayData = aFrame->GetStyleDisplay();
|
||||
if (displayData->mPosition != NS_STYLE_POSITION_ABSOLUTE &&
|
||||
displayData->mPosition != NS_STYLE_POSITION_FIXED) {
|
||||
nsMargin padding;
|
||||
frame->GetStylePadding()->CalcPaddingFor(frame, padding);
|
||||
baseWidth -= (padding.left + padding.right);
|
||||
}
|
||||
}
|
||||
result = (nscoord)((float)baseWidth * aCoord.GetPercentValue());
|
||||
}
|
||||
break;
|
||||
|
||||
case eStyleUnit_Coord:
|
||||
result = aCoord.GetCoordValue();
|
||||
break;
|
||||
|
||||
case eStyleUnit_Enumerated:
|
||||
case eStyleUnit_Null:
|
||||
case eStyleUnit_Normal:
|
||||
case eStyleUnit_Integer:
|
||||
case eStyleUnit_Proportional:
|
||||
default:
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
if ((NS_SPACING_PADDING == aSpacing) || (NS_SPACING_BORDER == aSpacing)) {
|
||||
if (result < 0) {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// XXXldb Probably shouldn't be inline.
|
||||
inline void CalcSidesFor(const nsIFrame* aFrame, const nsStyleSides& aSides,
|
||||
PRUint8 aSpacing, nsMargin& aResult)
|
||||
{
|
||||
nsStyleCoord coord;
|
||||
|
||||
aResult.left = CalcSideFor(aFrame, aSides.GetLeft(coord), aSpacing,
|
||||
NS_SIDE_LEFT);
|
||||
aResult.top = CalcSideFor(aFrame, aSides.GetTop(coord), aSpacing,
|
||||
NS_SIDE_TOP);
|
||||
aResult.right = CalcSideFor(aFrame, aSides.GetRight(coord), aSpacing,
|
||||
NS_SIDE_RIGHT);
|
||||
aResult.bottom = CalcSideFor(aFrame, aSides.GetBottom(coord), aSpacing,
|
||||
NS_SIDE_BOTTOM);
|
||||
}
|
||||
|
||||
static PRBool EqualURIs(nsIURI *aURI1, nsIURI *aURI2)
|
||||
{
|
||||
PRBool eq;
|
||||
@ -351,16 +277,6 @@ nsChangeHint nsStyleMargin::MaxDifference()
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsStyleMargin::CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const
|
||||
{
|
||||
if (mHasCachedMargin) {
|
||||
aMargin = mCachedMargin;
|
||||
} else {
|
||||
CalcSidesFor(aFrame, mMargin, NS_SPACING_MARGIN, aMargin);
|
||||
}
|
||||
}
|
||||
|
||||
nsStylePadding::nsStylePadding() {
|
||||
mPadding.Reset();
|
||||
mHasCachedPadding = PR_FALSE;
|
||||
@ -415,16 +331,6 @@ nsChangeHint nsStylePadding::MaxDifference()
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsStylePadding::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const
|
||||
{
|
||||
if (mHasCachedPadding) {
|
||||
aPadding = mCachedPadding;
|
||||
} else {
|
||||
CalcSidesFor(aFrame, mPadding, NS_SPACING_PADDING, aPadding);
|
||||
}
|
||||
}
|
||||
|
||||
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
|
||||
: mComputedBorder(0, 0, 0, 0)
|
||||
{
|
||||
|
||||
@ -236,9 +236,6 @@ struct nsStyleMargin: public nsStyleStruct {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// XXX this is a deprecated method
|
||||
void CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const;
|
||||
|
||||
protected:
|
||||
PRPackedBool mHasCachedMargin;
|
||||
nsMargin mCachedMargin;
|
||||
@ -270,9 +267,6 @@ struct nsStylePadding: public nsStyleStruct {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// XXX this is a deprecated method
|
||||
void CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const;
|
||||
|
||||
protected:
|
||||
PRPackedBool mHasCachedPadding;
|
||||
nsMargin mCachedPadding;
|
||||
@ -461,16 +455,6 @@ struct nsStyleBorder: public nsStyleStruct {
|
||||
mBorderStyle[aSide] |= BORDER_COLOR_FOREGROUND;
|
||||
}
|
||||
|
||||
// XXX these are deprecated methods
|
||||
void CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
|
||||
{
|
||||
aBorder = GetBorder();
|
||||
}
|
||||
void CalcBorderFor(const nsIFrame* aFrame, PRUint8 aSide,
|
||||
nscoord& aWidth) const {
|
||||
aWidth = GetBorderWidth(aSide);
|
||||
}
|
||||
|
||||
protected:
|
||||
// mComputedBorder holds the CSS2.1 computed border-width values. In
|
||||
// particular, these widths take into account the border-style for the
|
||||
|
||||
@ -251,6 +251,11 @@ void nsTableCellFrame::SetColIndex(PRInt32 aColIndex)
|
||||
mColIndex = aColIndex;
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableCellFrame::GetUsedMargin() const
|
||||
{
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
//ASSURE DIFFERENT COLORS for selection
|
||||
inline nscolor EnsureDifferentColors(nscolor colorA, nscolor colorB)
|
||||
@ -1020,6 +1025,14 @@ nsBCTableCellFrame::GetType() const
|
||||
return nsLayoutAtoms::bcTableCellFrame;
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsBCTableCellFrame::GetUsedBorder() const
|
||||
{
|
||||
nsMargin result;
|
||||
GetBorderWidth(GetPresContext()->PixelsToTwips(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHODIMP
|
||||
nsBCTableCellFrame::GetFrameName(nsAString& aResult) const
|
||||
|
||||
@ -87,7 +87,6 @@ public:
|
||||
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
|
||||
#endif
|
||||
|
||||
|
||||
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType);
|
||||
@ -107,6 +106,8 @@ public:
|
||||
return GetFirstChild(nsnull)->GetContentInsertionFrame();
|
||||
}
|
||||
|
||||
virtual nsMargin GetUsedMargin() const;
|
||||
|
||||
virtual void NotifyPercentHeight(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
virtual PRBool NeedsToObserve(const nsHTMLReflowState& aReflowState);
|
||||
@ -324,6 +325,8 @@ public:
|
||||
|
||||
virtual nsIAtom* GetType() const;
|
||||
|
||||
virtual nsMargin GetUsedBorder() const;
|
||||
|
||||
// Get the *inner half of the border only*, in twips.
|
||||
virtual nsMargin* GetBorderWidth(float aPixelsToTwips,
|
||||
nsMargin& aBorder) const;
|
||||
|
||||
@ -2494,6 +2494,24 @@ nsTableFrame::RemoveFrame(nsIAtom* aListName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableFrame::GetUsedBorder() const
|
||||
{
|
||||
if (!IsBorderCollapse())
|
||||
return nsHTMLContainerFrame::GetUsedBorder();
|
||||
|
||||
return GetIncludedOuterBCBorder();
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableFrame::GetUsedPadding() const
|
||||
{
|
||||
if (!IsBorderCollapse())
|
||||
return nsHTMLContainerFrame::GetUsedPadding();
|
||||
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
static void
|
||||
DivideBCBorderSize(nscoord aPixelSize,
|
||||
nscoord& aSmallHalf,
|
||||
@ -4469,7 +4487,7 @@ GetColorAndStyle(const nsIFrame* aFrame,
|
||||
aSide = NS_SIDE_RIGHT;
|
||||
}
|
||||
}
|
||||
styleData->CalcBorderFor(aFrame, aSide, width);
|
||||
width = styleData->GetBorderWidth(aSide);
|
||||
aWidth = NSToCoordRound(aTwipsToPixels * (float)width);
|
||||
}
|
||||
|
||||
|
||||
@ -149,6 +149,9 @@ public:
|
||||
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
|
||||
nsIFrame* aOldFrame);
|
||||
|
||||
virtual nsMargin GetUsedBorder() const;
|
||||
virtual nsMargin GetUsedPadding() const;
|
||||
|
||||
// Get the offset from the border box to the area where the row groups fit
|
||||
nsMargin GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const;
|
||||
|
||||
|
||||
@ -278,6 +278,24 @@ nsTableRowFrame::RemoveFrame(nsIAtom* aListName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableRowFrame::GetUsedMargin() const
|
||||
{
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableRowFrame::GetUsedBorder() const
|
||||
{
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableRowFrame::GetUsedPadding() const
|
||||
{
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
nscoord
|
||||
GetHeightOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame,
|
||||
nsTableFrame& aTableFrame)
|
||||
|
||||
@ -83,6 +83,10 @@ public:
|
||||
*/
|
||||
friend nsIFrame* NS_NewTableRowFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
||||
|
||||
virtual nsMargin GetUsedMargin() const;
|
||||
virtual nsMargin GetUsedBorder() const;
|
||||
virtual nsMargin GetUsedPadding() const;
|
||||
|
||||
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsDisplayListSet& aLists);
|
||||
|
||||
@ -1430,6 +1430,24 @@ nsTableRowGroupFrame::RemoveFrame(nsIAtom* aListName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableRowGroupFrame::GetUsedMargin() const
|
||||
{
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableRowGroupFrame::GetUsedBorder() const
|
||||
{
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
nsTableRowGroupFrame::GetUsedPadding() const
|
||||
{
|
||||
return nsMargin(0,0,0,0);
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsTableRowGroupFrame::GetHeightBasis(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
|
||||
@ -123,6 +123,10 @@ public:
|
||||
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
|
||||
nsIFrame* aOldFrame);
|
||||
|
||||
virtual nsMargin GetUsedMargin() const;
|
||||
virtual nsMargin GetUsedBorder() const;
|
||||
virtual nsMargin GetUsedPadding() const;
|
||||
|
||||
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsDisplayListSet& aLists);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user