зеркало из https://github.com/mozilla/pjs.git
Delete nsLayoutUtils::GetAbsoluteCoord(); fold logic into callers and simplify. (Bug 437335) r+sr=dbaron
This commit is contained in:
Родитель
2cf6d4a1cd
Коммит
d8e5c0aeb0
|
@ -1493,9 +1493,17 @@ static nscoord AddPercents(nsLayoutUtils::IntrinsicWidthType aType,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PRBool GetAbsoluteCoord(const nsStyleCoord& aStyle, nscoord& aResult)
|
||||||
|
{
|
||||||
|
if (eStyleUnit_Coord != aStyle.GetUnit())
|
||||||
|
return PR_FALSE;
|
||||||
|
|
||||||
|
aResult = aStyle.GetCoordValue();
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
GetPercentHeight(const nsStyleCoord& aStyle,
|
GetPercentHeight(const nsStyleCoord& aStyle,
|
||||||
nsIRenderingContext* aRenderingContext,
|
|
||||||
nsIFrame* aFrame,
|
nsIFrame* aFrame,
|
||||||
nscoord& aResult)
|
nscoord& aResult)
|
||||||
{
|
{
|
||||||
|
@ -1513,9 +1521,8 @@ GetPercentHeight(const nsStyleCoord& aStyle,
|
||||||
|
|
||||||
const nsStylePosition *pos = f->GetStylePosition();
|
const nsStylePosition *pos = f->GetStylePosition();
|
||||||
nscoord h;
|
nscoord h;
|
||||||
if (!nsLayoutUtils::
|
if (!GetAbsoluteCoord(pos->mHeight, h) &&
|
||||||
GetAbsoluteCoord(pos->mHeight, aRenderingContext, f, h) &&
|
!GetPercentHeight(pos->mHeight, f, h)) {
|
||||||
!GetPercentHeight(pos->mHeight, aRenderingContext, f, h)) {
|
|
||||||
NS_ASSERTION(pos->mHeight.GetUnit() == eStyleUnit_Auto ||
|
NS_ASSERTION(pos->mHeight.GetUnit() == eStyleUnit_Auto ||
|
||||||
pos->mHeight.GetUnit() == eStyleUnit_Percent,
|
pos->mHeight.GetUnit() == eStyleUnit_Percent,
|
||||||
"unknown height unit");
|
"unknown height unit");
|
||||||
|
@ -1528,9 +1535,8 @@ GetPercentHeight(const nsStyleCoord& aStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord maxh;
|
nscoord maxh;
|
||||||
if (nsLayoutUtils::
|
if (GetAbsoluteCoord(pos->mMaxHeight, maxh) ||
|
||||||
GetAbsoluteCoord(pos->mMaxHeight, aRenderingContext, f, maxh) ||
|
GetPercentHeight(pos->mMaxHeight, f, maxh)) {
|
||||||
GetPercentHeight(pos->mMaxHeight, aRenderingContext, f, maxh)) {
|
|
||||||
if (maxh < h)
|
if (maxh < h)
|
||||||
h = maxh;
|
h = maxh;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1540,9 +1546,8 @@ GetPercentHeight(const nsStyleCoord& aStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord minh;
|
nscoord minh;
|
||||||
if (nsLayoutUtils::
|
if (GetAbsoluteCoord(pos->mMinHeight, minh) ||
|
||||||
GetAbsoluteCoord(pos->mMinHeight, aRenderingContext, f, minh) ||
|
GetPercentHeight(pos->mMinHeight, f, minh)) {
|
||||||
GetPercentHeight(pos->mMinHeight, aRenderingContext, f, minh)) {
|
|
||||||
if (minh > h)
|
if (minh > h)
|
||||||
h = minh;
|
h = minh;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1686,21 +1691,21 @@ nsLayoutUtils::IntrinsicForContainer(nsIRenderingContext *aRenderingContext,
|
||||||
if (ratio.height != 0) {
|
if (ratio.height != 0) {
|
||||||
|
|
||||||
nscoord h;
|
nscoord h;
|
||||||
if (GetAbsoluteCoord(styleHeight, aRenderingContext, aFrame, h) ||
|
if (GetAbsoluteCoord(styleHeight, h) ||
|
||||||
GetPercentHeight(styleHeight, aRenderingContext, aFrame, h)) {
|
GetPercentHeight(styleHeight, aFrame, h)) {
|
||||||
result =
|
result =
|
||||||
NSToCoordRound(h * (float(ratio.width) / float(ratio.height)));
|
NSToCoordRound(h * (float(ratio.width) / float(ratio.height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetAbsoluteCoord(styleMaxHeight, aRenderingContext, aFrame, h) ||
|
if (GetAbsoluteCoord(styleMaxHeight, h) ||
|
||||||
GetPercentHeight(styleMaxHeight, aRenderingContext, aFrame, h)) {
|
GetPercentHeight(styleMaxHeight, aFrame, h)) {
|
||||||
h = NSToCoordRound(h * (float(ratio.width) / float(ratio.height)));
|
h = NSToCoordRound(h * (float(ratio.width) / float(ratio.height)));
|
||||||
if (h < result)
|
if (h < result)
|
||||||
result = h;
|
result = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetAbsoluteCoord(styleMinHeight, aRenderingContext, aFrame, h) ||
|
if (GetAbsoluteCoord(styleMinHeight, h) ||
|
||||||
GetPercentHeight(styleMinHeight, aRenderingContext, aFrame, h)) {
|
GetPercentHeight(styleMinHeight, aFrame, h)) {
|
||||||
h = NSToCoordRound(h * (float(ratio.width) / float(ratio.height)));
|
h = NSToCoordRound(h * (float(ratio.width) / float(ratio.height)));
|
||||||
if (h > result)
|
if (h > result)
|
||||||
result = h;
|
result = h;
|
||||||
|
@ -1755,7 +1760,7 @@ nsLayoutUtils::IntrinsicForContainer(nsIRenderingContext *aRenderingContext,
|
||||||
pctTotal += pctOutsideWidth;
|
pctTotal += pctOutsideWidth;
|
||||||
|
|
||||||
nscoord w;
|
nscoord w;
|
||||||
if (GetAbsoluteCoord(styleWidth, aRenderingContext, aFrame, w) ||
|
if (GetAbsoluteCoord(styleWidth, w) ||
|
||||||
GetIntrinsicCoord(styleWidth, aRenderingContext, aFrame,
|
GetIntrinsicCoord(styleWidth, aRenderingContext, aFrame,
|
||||||
PROP_WIDTH, w)) {
|
PROP_WIDTH, w)) {
|
||||||
result = AddPercents(aType, w + coordOutsideWidth, pctOutsideWidth);
|
result = AddPercents(aType, w + coordOutsideWidth, pctOutsideWidth);
|
||||||
|
@ -1770,7 +1775,7 @@ nsLayoutUtils::IntrinsicForContainer(nsIRenderingContext *aRenderingContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord maxw;
|
nscoord maxw;
|
||||||
if (GetAbsoluteCoord(styleMaxWidth, aRenderingContext, aFrame, maxw) ||
|
if (GetAbsoluteCoord(styleMaxWidth, maxw) ||
|
||||||
GetIntrinsicCoord(styleMaxWidth, aRenderingContext, aFrame,
|
GetIntrinsicCoord(styleMaxWidth, aRenderingContext, aFrame,
|
||||||
PROP_MAX_WIDTH, maxw)) {
|
PROP_MAX_WIDTH, maxw)) {
|
||||||
maxw = AddPercents(aType, maxw + coordOutsideWidth, pctOutsideWidth);
|
maxw = AddPercents(aType, maxw + coordOutsideWidth, pctOutsideWidth);
|
||||||
|
@ -1779,7 +1784,7 @@ nsLayoutUtils::IntrinsicForContainer(nsIRenderingContext *aRenderingContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord minw;
|
nscoord minw;
|
||||||
if (GetAbsoluteCoord(styleMinWidth, aRenderingContext, aFrame, minw) ||
|
if (GetAbsoluteCoord(styleMinWidth, minw) ||
|
||||||
GetIntrinsicCoord(styleMinWidth, aRenderingContext, aFrame,
|
GetIntrinsicCoord(styleMinWidth, aRenderingContext, aFrame,
|
||||||
PROP_MIN_WIDTH, minw)) {
|
PROP_MIN_WIDTH, minw)) {
|
||||||
minw = AddPercents(aType, minw + coordOutsideWidth, pctOutsideWidth);
|
minw = AddPercents(aType, minw + coordOutsideWidth, pctOutsideWidth);
|
||||||
|
@ -1822,19 +1827,15 @@ nsLayoutUtils::IntrinsicForContainer(nsIRenderingContext *aRenderingContext,
|
||||||
|
|
||||||
/* static */ nscoord
|
/* static */ nscoord
|
||||||
nsLayoutUtils::ComputeWidthDependentValue(
|
nsLayoutUtils::ComputeWidthDependentValue(
|
||||||
nsIRenderingContext* aRenderingContext,
|
|
||||||
nsIFrame* aFrame,
|
|
||||||
nscoord aContainingBlockWidth,
|
nscoord aContainingBlockWidth,
|
||||||
const nsStyleCoord& aCoord)
|
const nsStyleCoord& aCoord)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aFrame, "non-null frame expected");
|
|
||||||
NS_PRECONDITION(aRenderingContext, "non-null rendering context expected");
|
|
||||||
NS_PRECONDITION(aContainingBlockWidth != NS_UNCONSTRAINEDSIZE,
|
NS_PRECONDITION(aContainingBlockWidth != NS_UNCONSTRAINEDSIZE,
|
||||||
"unconstrained widths no longer supported");
|
"unconstrained widths no longer supported");
|
||||||
|
|
||||||
nscoord result;
|
nscoord result;
|
||||||
if (GetAbsoluteCoord(aCoord, aRenderingContext, aFrame, result)) {
|
if (eStyleUnit_Coord == aCoord.GetUnit()) {
|
||||||
return result;
|
return aCoord.GetCoordValue();
|
||||||
}
|
}
|
||||||
if (eStyleUnit_Percent == aCoord.GetUnit()) {
|
if (eStyleUnit_Percent == aCoord.GetUnit()) {
|
||||||
return NSToCoordFloor(aContainingBlockWidth * aCoord.GetPercentValue());
|
return NSToCoordFloor(aContainingBlockWidth * aCoord.GetPercentValue());
|
||||||
|
@ -1862,7 +1863,8 @@ nsLayoutUtils::ComputeWidthValue(
|
||||||
"width less than zero");
|
"width less than zero");
|
||||||
|
|
||||||
nscoord result;
|
nscoord result;
|
||||||
if (GetAbsoluteCoord(aCoord, aRenderingContext, aFrame, result)) {
|
if (eStyleUnit_Coord == aCoord.GetUnit()) {
|
||||||
|
result = aCoord.GetCoordValue();
|
||||||
NS_ASSERTION(result >= 0, "width less than zero");
|
NS_ASSERTION(result >= 0, "width less than zero");
|
||||||
result -= aContentEdgeToBoxSizing;
|
result -= aContentEdgeToBoxSizing;
|
||||||
} else if (eStyleUnit_Percent == aCoord.GetUnit()) {
|
} else if (eStyleUnit_Percent == aCoord.GetUnit()) {
|
||||||
|
@ -1906,17 +1908,12 @@ nsLayoutUtils::ComputeWidthValue(
|
||||||
|
|
||||||
/* static */ nscoord
|
/* static */ nscoord
|
||||||
nsLayoutUtils::ComputeHeightDependentValue(
|
nsLayoutUtils::ComputeHeightDependentValue(
|
||||||
nsIRenderingContext* aRenderingContext,
|
|
||||||
nsIFrame* aFrame,
|
|
||||||
nscoord aContainingBlockHeight,
|
nscoord aContainingBlockHeight,
|
||||||
const nsStyleCoord& aCoord)
|
const nsStyleCoord& aCoord)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aFrame, "non-null frame expected");
|
|
||||||
NS_PRECONDITION(aRenderingContext, "non-null rendering context expected");
|
|
||||||
|
|
||||||
nscoord result;
|
nscoord result;
|
||||||
if (GetAbsoluteCoord(aCoord, aRenderingContext, aFrame, result)) {
|
if (eStyleUnit_Coord == aCoord.GetUnit()) {
|
||||||
return result;
|
return aCoord.GetCoordValue();
|
||||||
}
|
}
|
||||||
if (eStyleUnit_Percent == aCoord.GetUnit()) {
|
if (eStyleUnit_Percent == aCoord.GetUnit()) {
|
||||||
// XXXldb Some callers explicitly check aContainingBlockHeight
|
// XXXldb Some callers explicitly check aContainingBlockHeight
|
||||||
|
@ -2005,16 +2002,16 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
||||||
NS_ASSERTION(minWidth >= 0, "negative result from ComputeWidthValue");
|
NS_ASSERTION(minWidth >= 0, "negative result from ComputeWidthValue");
|
||||||
|
|
||||||
if (!isAutoHeight) {
|
if (!isAutoHeight) {
|
||||||
height = nsLayoutUtils::ComputeHeightDependentValue(aRenderingContext,
|
height = nsLayoutUtils::
|
||||||
aFrame, aCBSize.height, stylePos->mHeight) -
|
ComputeHeightDependentValue(aCBSize.height, stylePos->mHeight) -
|
||||||
boxSizingAdjust.height;
|
boxSizingAdjust.height;
|
||||||
if (height < 0)
|
if (height < 0)
|
||||||
height = 0;
|
height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsAutoHeight(stylePos->mMaxHeight, aCBSize.height)) {
|
if (!IsAutoHeight(stylePos->mMaxHeight, aCBSize.height)) {
|
||||||
maxHeight = nsLayoutUtils::ComputeHeightDependentValue(aRenderingContext,
|
maxHeight = nsLayoutUtils::
|
||||||
aFrame, aCBSize.height, stylePos->mMaxHeight) -
|
ComputeHeightDependentValue(aCBSize.height, stylePos->mMaxHeight) -
|
||||||
boxSizingAdjust.height;
|
boxSizingAdjust.height;
|
||||||
if (maxHeight < 0)
|
if (maxHeight < 0)
|
||||||
maxHeight = 0;
|
maxHeight = 0;
|
||||||
|
@ -2023,8 +2020,8 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsAutoHeight(stylePos->mMinHeight, aCBSize.height)) {
|
if (!IsAutoHeight(stylePos->mMinHeight, aCBSize.height)) {
|
||||||
minHeight = nsLayoutUtils::ComputeHeightDependentValue(aRenderingContext,
|
minHeight = nsLayoutUtils::
|
||||||
aFrame, aCBSize.height, stylePos->mMinHeight) -
|
ComputeHeightDependentValue(aCBSize.height, stylePos->mMinHeight) -
|
||||||
boxSizingAdjust.height;
|
boxSizingAdjust.height;
|
||||||
if (minHeight < 0)
|
if (minHeight < 0)
|
||||||
minHeight = 0;
|
minHeight = 0;
|
||||||
|
@ -2055,9 +2052,8 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
||||||
(aIntrinsicSize.height.GetUnit() == eStyleUnit_Percent &&
|
(aIntrinsicSize.height.GetUnit() == eStyleUnit_Percent &&
|
||||||
aCBSize.height != NS_AUTOHEIGHT)) {
|
aCBSize.height != NS_AUTOHEIGHT)) {
|
||||||
hasIntrinsicHeight = PR_TRUE;
|
hasIntrinsicHeight = PR_TRUE;
|
||||||
intrinsicHeight = nsLayoutUtils::ComputeHeightDependentValue(
|
intrinsicHeight = nsLayoutUtils::
|
||||||
aRenderingContext, aFrame, aCBSize.height,
|
ComputeHeightDependentValue(aCBSize.height, aIntrinsicSize.height);
|
||||||
aIntrinsicSize.height);
|
|
||||||
if (intrinsicHeight < 0)
|
if (intrinsicHeight < 0)
|
||||||
intrinsicHeight = 0;
|
intrinsicHeight = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -582,40 +582,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static PRBool IsViewportScrollbarFrame(nsIFrame* aFrame);
|
static PRBool IsViewportScrollbarFrame(nsIFrame* aFrame);
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the value of aStyle as an nscoord if it can be determined without
|
|
||||||
* reference to ancestors or children (e.g. is not a percentage width)
|
|
||||||
* @param aStyle the style coord
|
|
||||||
* @param aRenderingContext the rendering context to use for font measurement
|
|
||||||
* @param aFrame the frame whose style context should be used for font information
|
|
||||||
* @param aResult the nscoord value of the style coord
|
|
||||||
* @return TRUE if the unit is eStyleUnit_Coord
|
|
||||||
*/
|
|
||||||
static PRBool GetAbsoluteCoord(const nsStyleCoord& aStyle,
|
|
||||||
nsIRenderingContext* aRenderingContext,
|
|
||||||
nsIFrame* aFrame,
|
|
||||||
nscoord& aResult)
|
|
||||||
{
|
|
||||||
return GetAbsoluteCoord(aStyle, aRenderingContext,
|
|
||||||
aFrame->GetStyleContext(), aResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as above but doesn't need a frame
|
|
||||||
*/
|
|
||||||
static PRBool GetAbsoluteCoord(const nsStyleCoord& aStyle,
|
|
||||||
nsIRenderingContext* aRenderingContext,
|
|
||||||
nsStyleContext* aStyleContext,
|
|
||||||
nscoord& aResult)
|
|
||||||
{
|
|
||||||
nsStyleUnit unit = aStyle.GetUnit();
|
|
||||||
if (eStyleUnit_Coord == unit) {
|
|
||||||
aResult = aStyle.GetCoordValue();
|
|
||||||
return PR_TRUE;
|
|
||||||
}
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the contribution of aFrame to its containing block's intrinsic
|
* Get the contribution of aFrame to its containing block's intrinsic
|
||||||
* width. This considers the child's intrinsic width, its 'width',
|
* width. This considers the child's intrinsic width, its 'width',
|
||||||
|
@ -632,8 +598,6 @@ public:
|
||||||
* containing block width.
|
* containing block width.
|
||||||
*/
|
*/
|
||||||
static nscoord ComputeWidthDependentValue(
|
static nscoord ComputeWidthDependentValue(
|
||||||
nsIRenderingContext* aRenderingContext,
|
|
||||||
nsIFrame* aFrame,
|
|
||||||
nscoord aContainingBlockWidth,
|
nscoord aContainingBlockWidth,
|
||||||
const nsStyleCoord& aCoord);
|
const nsStyleCoord& aCoord);
|
||||||
|
|
||||||
|
@ -667,8 +631,6 @@ public:
|
||||||
* containing block height.
|
* containing block height.
|
||||||
*/
|
*/
|
||||||
static nscoord ComputeHeightDependentValue(
|
static nscoord ComputeHeightDependentValue(
|
||||||
nsIRenderingContext* aRenderingContext,
|
|
||||||
nsIFrame* aFrame,
|
|
||||||
nscoord aContainingBlockHeight,
|
nscoord aContainingBlockHeight,
|
||||||
const nsStyleCoord& aCoord);
|
const nsStyleCoord& aCoord);
|
||||||
|
|
||||||
|
|
|
@ -1310,8 +1310,7 @@ nsTextControlFrame::CalcIntrinsicSize(nsIRenderingContext* aRenderingContext,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
aRenderingContext->SetFont(fontMet);
|
aRenderingContext->SetFont(fontMet);
|
||||||
|
|
||||||
lineHeight = nsHTMLReflowState::CalcLineHeight(aRenderingContext,
|
lineHeight = nsHTMLReflowState::CalcLineHeight(this);
|
||||||
this);
|
|
||||||
fontMet->GetAveCharWidth(charWidth);
|
fontMet->GetAveCharWidth(charWidth);
|
||||||
fontMet->GetMaxAdvance(charMaxAdvance);
|
fontMet->GetMaxAdvance(charMaxAdvance);
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,7 @@ BRFrame::Reflow(nsPresContext* aPresContext,
|
||||||
nscoord ascent, descent;
|
nscoord ascent, descent;
|
||||||
fm->GetMaxAscent(ascent);
|
fm->GetMaxAscent(ascent);
|
||||||
fm->GetMaxDescent(descent);
|
fm->GetMaxDescent(descent);
|
||||||
nscoord logicalHeight =
|
nscoord logicalHeight = aReflowState.CalcLineHeight(this);
|
||||||
aReflowState.CalcLineHeight(aReflowState.rendContext, this);
|
|
||||||
nscoord leading = logicalHeight - ascent - descent;
|
nscoord leading = logicalHeight - ascent - descent;
|
||||||
aMetrics.height = logicalHeight;
|
aMetrics.height = logicalHeight;
|
||||||
aMetrics.ascent = ascent + (leading/2);
|
aMetrics.ascent = ascent + (leading/2);
|
||||||
|
|
|
@ -139,8 +139,7 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
|
||||||
mPrevChild = nsnull;
|
mPrevChild = nsnull;
|
||||||
mCurrentLine = aFrame->end_lines();
|
mCurrentLine = aFrame->end_lines();
|
||||||
|
|
||||||
mMinLineHeight = nsHTMLReflowState::CalcLineHeight(aReflowState.rendContext,
|
mMinLineHeight = nsHTMLReflowState::CalcLineHeight(aReflowState.frame);
|
||||||
aReflowState.frame);
|
|
||||||
|
|
||||||
// Calculate mOutsideBulletX
|
// Calculate mOutsideBulletX
|
||||||
GetAvailableSpace();
|
GetAvailableSpace();
|
||||||
|
|
|
@ -229,15 +229,12 @@ GetAvailableContentHeight(const nsHTMLReflowState& aReflowState)
|
||||||
|
|
||||||
static nscoord
|
static nscoord
|
||||||
GetColumnGap(nsColumnSetFrame* aFrame,
|
GetColumnGap(nsColumnSetFrame* aFrame,
|
||||||
const nsStyleColumn* aColStyle,
|
const nsStyleColumn* aColStyle)
|
||||||
nsIRenderingContext* aRenderingContext)
|
|
||||||
{
|
{
|
||||||
nscoord colGap;
|
|
||||||
if (eStyleUnit_Normal == aColStyle->mColumnGap.GetUnit())
|
if (eStyleUnit_Normal == aColStyle->mColumnGap.GetUnit())
|
||||||
return aFrame->GetStyleFont()->mFont.size;
|
return aFrame->GetStyleFont()->mFont.size;
|
||||||
else if (nsLayoutUtils::GetAbsoluteCoord(aColStyle->mColumnGap,
|
if (eStyleUnit_Coord == aColStyle->mColumnGap.GetUnit()) {
|
||||||
aRenderingContext,
|
nscoord colGap = aColStyle->mColumnGap.GetCoordValue();
|
||||||
aFrame, colGap)) {
|
|
||||||
NS_ASSERTION(colGap >= 0, "negative column gap");
|
NS_ASSERTION(colGap >= 0, "negative column gap");
|
||||||
return colGap;
|
return colGap;
|
||||||
}
|
}
|
||||||
|
@ -259,13 +256,12 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
|
||||||
colHeight = aReflowState.ComputedHeight();
|
colHeight = aReflowState.ComputedHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord colGap = GetColumnGap(this, colStyle, aReflowState.rendContext);
|
nscoord colGap = GetColumnGap(this, colStyle);
|
||||||
PRInt32 numColumns = colStyle->mColumnCount;
|
PRInt32 numColumns = colStyle->mColumnCount;
|
||||||
|
|
||||||
nscoord colWidth;
|
nscoord colWidth;
|
||||||
if (nsLayoutUtils::GetAbsoluteCoord(colStyle->mColumnWidth,
|
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
||||||
aReflowState.rendContext,
|
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
||||||
this, colWidth)) {
|
|
||||||
NS_ASSERTION(colWidth >= 0, "negative column width");
|
NS_ASSERTION(colWidth >= 0, "negative column width");
|
||||||
// Reduce column count if necessary to make columns fit in the
|
// Reduce column count if necessary to make columns fit in the
|
||||||
// available width. Compute max number of columns that fit in
|
// available width. Compute max number of columns that fit in
|
||||||
|
@ -371,16 +367,17 @@ nsColumnSetFrame::GetMinWidth(nsIRenderingContext *aRenderingContext) {
|
||||||
}
|
}
|
||||||
const nsStyleColumn* colStyle = GetStyleColumn();
|
const nsStyleColumn* colStyle = GetStyleColumn();
|
||||||
nscoord colWidth;
|
nscoord colWidth;
|
||||||
if (nsLayoutUtils::GetAbsoluteCoord(colStyle->mColumnWidth,
|
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
||||||
aRenderingContext, this, colWidth)) {
|
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
||||||
// As available width reduces to zero, we reduce our number of columns to one,
|
// As available width reduces to zero, we reduce our number of columns
|
||||||
// and don't enforce the column width, so just return the min of the
|
// to one, and don't enforce the column width, so just return the min
|
||||||
// child's min-width with any specified column width.
|
// of the child's min-width with any specified column width.
|
||||||
width = PR_MIN(width, colWidth);
|
width = PR_MIN(width, colWidth);
|
||||||
} else {
|
} else {
|
||||||
NS_ASSERTION(colStyle->mColumnCount > 0, "column-count and column-width can't both be auto");
|
NS_ASSERTION(colStyle->mColumnCount > 0,
|
||||||
// As available width reduces to zero, we still have mColumnCount columns, so
|
"column-count and column-width can't both be auto");
|
||||||
// multiply the child's min-width by the number of columns.
|
// As available width reduces to zero, we still have mColumnCount columns,
|
||||||
|
// so multiply the child's min-width by the number of columns.
|
||||||
colWidth = width;
|
colWidth = width;
|
||||||
width *= colStyle->mColumnCount;
|
width *= colStyle->mColumnCount;
|
||||||
// The multiplication above can make 'width' negative (integer overflow),
|
// The multiplication above can make 'width' negative (integer overflow),
|
||||||
|
@ -394,22 +391,21 @@ nsColumnSetFrame::GetMinWidth(nsIRenderingContext *aRenderingContext) {
|
||||||
|
|
||||||
nscoord
|
nscoord
|
||||||
nsColumnSetFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext) {
|
nsColumnSetFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext) {
|
||||||
// Our preferred width is our desired column width, if specified, otherwise the
|
// Our preferred width is our desired column width, if specified, otherwise
|
||||||
// child's preferred width, times the number of columns, plus the width of any
|
// the child's preferred width, times the number of columns, plus the width
|
||||||
// required column gaps
|
// of any required column gaps
|
||||||
// XXX what about forced column breaks here?
|
// XXX what about forced column breaks here?
|
||||||
const nsStyleColumn* colStyle = GetStyleColumn();
|
const nsStyleColumn* colStyle = GetStyleColumn();
|
||||||
nscoord colGap = GetColumnGap(this, colStyle, aRenderingContext);
|
nscoord colGap = GetColumnGap(this, colStyle);
|
||||||
|
|
||||||
nscoord colWidth;
|
nscoord colWidth;
|
||||||
if (!nsLayoutUtils::GetAbsoluteCoord(colStyle->mColumnWidth,
|
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
||||||
aRenderingContext, this, colWidth)) {
|
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
||||||
if (mFrames.FirstChild()) {
|
} else if (mFrames.FirstChild()) {
|
||||||
colWidth = mFrames.FirstChild()->GetPrefWidth(aRenderingContext);
|
colWidth = mFrames.FirstChild()->GetPrefWidth(aRenderingContext);
|
||||||
} else {
|
} else {
|
||||||
colWidth = 0;
|
colWidth = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PRInt32 numColumns = colStyle->mColumnCount;
|
PRInt32 numColumns = colStyle->mColumnCount;
|
||||||
if (numColumns <= 0) {
|
if (numColumns <= 0) {
|
||||||
|
|
|
@ -3086,16 +3086,16 @@ nsFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
|
||||||
|
|
||||||
if (!IsAutoHeight(stylePos->mHeight, aCBSize.height)) {
|
if (!IsAutoHeight(stylePos->mHeight, aCBSize.height)) {
|
||||||
result.height =
|
result.height =
|
||||||
nsLayoutUtils::ComputeHeightDependentValue(aRenderingContext, this,
|
nsLayoutUtils::ComputeHeightDependentValue(aCBSize.height,
|
||||||
aCBSize.height, stylePos->mHeight) -
|
stylePos->mHeight) -
|
||||||
boxSizingAdjust.height;
|
boxSizingAdjust.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.height != NS_UNCONSTRAINEDSIZE) {
|
if (result.height != NS_UNCONSTRAINEDSIZE) {
|
||||||
if (!IsAutoHeight(stylePos->mMaxHeight, aCBSize.height)) {
|
if (!IsAutoHeight(stylePos->mMaxHeight, aCBSize.height)) {
|
||||||
nscoord maxHeight =
|
nscoord maxHeight =
|
||||||
nsLayoutUtils::ComputeHeightDependentValue(aRenderingContext, this,
|
nsLayoutUtils::ComputeHeightDependentValue(aCBSize.height,
|
||||||
aCBSize.height, stylePos->mMaxHeight) -
|
stylePos->mMaxHeight) -
|
||||||
boxSizingAdjust.height;
|
boxSizingAdjust.height;
|
||||||
if (maxHeight < result.height)
|
if (maxHeight < result.height)
|
||||||
result.height = maxHeight;
|
result.height = maxHeight;
|
||||||
|
@ -3103,8 +3103,8 @@ nsFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
|
||||||
|
|
||||||
if (!IsAutoHeight(stylePos->mMinHeight, aCBSize.height)) {
|
if (!IsAutoHeight(stylePos->mMinHeight, aCBSize.height)) {
|
||||||
nscoord minHeight =
|
nscoord minHeight =
|
||||||
nsLayoutUtils::ComputeHeightDependentValue(aRenderingContext, this,
|
nsLayoutUtils::ComputeHeightDependentValue(aCBSize.height,
|
||||||
aCBSize.height, stylePos->mMinHeight) -
|
stylePos->mMinHeight) -
|
||||||
boxSizingAdjust.height;
|
boxSizingAdjust.height;
|
||||||
if (minHeight > result.height)
|
if (minHeight > result.height)
|
||||||
result.height = minHeight;
|
result.height = minHeight;
|
||||||
|
|
|
@ -178,16 +178,6 @@ nsHTMLReflowState::nsHTMLReflowState(nsPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
|
||||||
nsCSSOffsetState::ComputeWidthDependentValue(nscoord aContainingBlockWidth,
|
|
||||||
const nsStyleCoord& aCoord,
|
|
||||||
nscoord& aResult)
|
|
||||||
{
|
|
||||||
aResult = nsLayoutUtils::ComputeWidthDependentValue(rendContext, frame,
|
|
||||||
aContainingBlockWidth,
|
|
||||||
aCoord);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline nscoord
|
inline nscoord
|
||||||
nsCSSOffsetState::ComputeWidthValue(nscoord aContainingBlockWidth,
|
nsCSSOffsetState::ComputeWidthValue(nscoord aContainingBlockWidth,
|
||||||
nscoord aContentEdgeToBoxSizing,
|
nscoord aContentEdgeToBoxSizing,
|
||||||
|
@ -222,16 +212,6 @@ nsCSSOffsetState::ComputeWidthValue(nscoord aContainingBlockWidth,
|
||||||
outside, aCoord);
|
outside, aCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
|
||||||
nsCSSOffsetState::ComputeHeightDependentValue(nscoord aContainingBlockHeight,
|
|
||||||
const nsStyleCoord& aCoord,
|
|
||||||
nscoord& aResult)
|
|
||||||
{
|
|
||||||
aResult = nsLayoutUtils::ComputeHeightDependentValue(rendContext, frame,
|
|
||||||
aContainingBlockHeight,
|
|
||||||
aCoord);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHTMLReflowState::SetComputedWidth(nscoord aComputedWidth)
|
nsHTMLReflowState::SetComputedWidth(nscoord aComputedWidth)
|
||||||
{
|
{
|
||||||
|
@ -635,9 +615,9 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
||||||
mComputedOffsets.left = mComputedOffsets.right = 0;
|
mComputedOffsets.left = mComputedOffsets.right = 0;
|
||||||
} else {
|
} else {
|
||||||
// 'Right' isn't 'auto' so compute its value
|
// 'Right' isn't 'auto' so compute its value
|
||||||
|
mComputedOffsets.right = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
mStylePosition->mOffset.GetRight(),
|
mStylePosition->mOffset.GetRight());
|
||||||
mComputedOffsets.right);
|
|
||||||
|
|
||||||
// Computed value for 'left' is minus the value of 'right'
|
// Computed value for 'left' is minus the value of 'right'
|
||||||
mComputedOffsets.left = -mComputedOffsets.right;
|
mComputedOffsets.left = -mComputedOffsets.right;
|
||||||
|
@ -647,9 +627,9 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
||||||
NS_ASSERTION(rightIsAuto, "unexpected specified constraint");
|
NS_ASSERTION(rightIsAuto, "unexpected specified constraint");
|
||||||
|
|
||||||
// 'Left' isn't 'auto' so compute its value
|
// 'Left' isn't 'auto' so compute its value
|
||||||
|
mComputedOffsets.left = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
mStylePosition->mOffset.GetLeft(),
|
mStylePosition->mOffset.GetLeft());
|
||||||
mComputedOffsets.left);
|
|
||||||
|
|
||||||
// Computed value for 'right' is minus the value of 'left'
|
// Computed value for 'right' is minus the value of 'left'
|
||||||
mComputedOffsets.right = -mComputedOffsets.left;
|
mComputedOffsets.right = -mComputedOffsets.left;
|
||||||
|
@ -683,9 +663,9 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
||||||
mComputedOffsets.top = mComputedOffsets.bottom = 0;
|
mComputedOffsets.top = mComputedOffsets.bottom = 0;
|
||||||
} else {
|
} else {
|
||||||
// 'Bottom' isn't 'auto' so compute its value
|
// 'Bottom' isn't 'auto' so compute its value
|
||||||
|
mComputedOffsets.bottom = nsLayoutUtils::
|
||||||
ComputeHeightDependentValue(aContainingBlockHeight,
|
ComputeHeightDependentValue(aContainingBlockHeight,
|
||||||
mStylePosition->mOffset.GetBottom(),
|
mStylePosition->mOffset.GetBottom());
|
||||||
mComputedOffsets.bottom);
|
|
||||||
|
|
||||||
// Computed value for 'top' is minus the value of 'bottom'
|
// Computed value for 'top' is minus the value of 'bottom'
|
||||||
mComputedOffsets.top = -mComputedOffsets.bottom;
|
mComputedOffsets.top = -mComputedOffsets.bottom;
|
||||||
|
@ -695,9 +675,9 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
||||||
NS_ASSERTION(bottomIsAuto, "unexpected specified constraint");
|
NS_ASSERTION(bottomIsAuto, "unexpected specified constraint");
|
||||||
|
|
||||||
// 'Top' isn't 'auto' so compute its value
|
// 'Top' isn't 'auto' so compute its value
|
||||||
|
mComputedOffsets.top = nsLayoutUtils::
|
||||||
ComputeHeightDependentValue(aContainingBlockHeight,
|
ComputeHeightDependentValue(aContainingBlockHeight,
|
||||||
mStylePosition->mOffset.GetTop(),
|
mStylePosition->mOffset.GetTop());
|
||||||
mComputedOffsets.top);
|
|
||||||
|
|
||||||
// Computed value for 'bottom' is minus the value of 'top'
|
// Computed value for 'bottom' is minus the value of 'top'
|
||||||
mComputedOffsets.bottom = -mComputedOffsets.top;
|
mComputedOffsets.bottom = -mComputedOffsets.top;
|
||||||
|
@ -817,12 +797,12 @@ nsHTMLReflowState::CalculateHorizBorderPaddingMargin(
|
||||||
// See if the style system can provide us the padding directly
|
// See if the style system can provide us the padding directly
|
||||||
if (!mStylePadding->GetPadding(padding)) {
|
if (!mStylePadding->GetPadding(padding)) {
|
||||||
// We have to compute the left and right values
|
// We have to compute the left and right values
|
||||||
|
padding.left = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
mStylePadding->mPadding.GetLeft(),
|
mStylePadding->mPadding.GetLeft());
|
||||||
padding.left);
|
padding.right = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
mStylePadding->mPadding.GetRight(),
|
mStylePadding->mPadding.GetRight());
|
||||||
padding.right);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if the style system can provide us the margin directly
|
// See if the style system can provide us the margin directly
|
||||||
|
@ -832,17 +812,17 @@ nsHTMLReflowState::CalculateHorizBorderPaddingMargin(
|
||||||
// XXX FIXME (or does CalculateBlockSideMargins do this?)
|
// XXX FIXME (or does CalculateBlockSideMargins do this?)
|
||||||
margin.left = 0; // just ignore
|
margin.left = 0; // just ignore
|
||||||
} else {
|
} else {
|
||||||
|
margin.left = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
mStyleMargin->mMargin.GetLeft(),
|
mStyleMargin->mMargin.GetLeft());
|
||||||
margin.left);
|
|
||||||
}
|
}
|
||||||
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit()) {
|
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit()) {
|
||||||
// XXX FIXME (or does CalculateBlockSideMargins do this?)
|
// XXX FIXME (or does CalculateBlockSideMargins do this?)
|
||||||
margin.right = 0; // just ignore
|
margin.right = 0; // just ignore
|
||||||
} else {
|
} else {
|
||||||
|
margin.right = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
mStyleMargin->mMargin.GetRight(),
|
mStyleMargin->mMargin.GetRight());
|
||||||
margin.right);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,17 +1136,17 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
||||||
mComputedOffsets.left = 0;
|
mComputedOffsets.left = 0;
|
||||||
leftIsAuto = PR_TRUE;
|
leftIsAuto = PR_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
mComputedOffsets.left = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(containingBlockWidth,
|
ComputeWidthDependentValue(containingBlockWidth,
|
||||||
mStylePosition->mOffset.GetLeft(),
|
mStylePosition->mOffset.GetLeft());
|
||||||
mComputedOffsets.left);
|
|
||||||
}
|
}
|
||||||
if (eStyleUnit_Auto == mStylePosition->mOffset.GetRightUnit()) {
|
if (eStyleUnit_Auto == mStylePosition->mOffset.GetRightUnit()) {
|
||||||
mComputedOffsets.right = 0;
|
mComputedOffsets.right = 0;
|
||||||
rightIsAuto = PR_TRUE;
|
rightIsAuto = PR_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
mComputedOffsets.right = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(containingBlockWidth,
|
ComputeWidthDependentValue(containingBlockWidth,
|
||||||
mStylePosition->mOffset.GetRight(),
|
mStylePosition->mOffset.GetRight());
|
||||||
mComputedOffsets.right);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the horizontal component of the hypothetical box in the cases
|
// Use the horizontal component of the hypothetical box in the cases
|
||||||
|
@ -1193,17 +1173,17 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
||||||
mComputedOffsets.top = 0;
|
mComputedOffsets.top = 0;
|
||||||
topIsAuto = PR_TRUE;
|
topIsAuto = PR_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
mComputedOffsets.top = nsLayoutUtils::
|
||||||
ComputeHeightDependentValue(containingBlockHeight,
|
ComputeHeightDependentValue(containingBlockHeight,
|
||||||
mStylePosition->mOffset.GetTop(),
|
mStylePosition->mOffset.GetTop());
|
||||||
mComputedOffsets.top);
|
|
||||||
}
|
}
|
||||||
if (eStyleUnit_Auto == mStylePosition->mOffset.GetBottomUnit()) {
|
if (eStyleUnit_Auto == mStylePosition->mOffset.GetBottomUnit()) {
|
||||||
mComputedOffsets.bottom = 0;
|
mComputedOffsets.bottom = 0;
|
||||||
bottomIsAuto = PR_TRUE;
|
bottomIsAuto = PR_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
mComputedOffsets.bottom = nsLayoutUtils::
|
||||||
ComputeHeightDependentValue(containingBlockHeight,
|
ComputeHeightDependentValue(containingBlockHeight,
|
||||||
mStylePosition->mOffset.GetBottom(),
|
mStylePosition->mOffset.GetBottom());
|
||||||
mComputedOffsets.bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topIsAuto && bottomIsAuto) {
|
if (topIsAuto && bottomIsAuto) {
|
||||||
|
@ -1802,9 +1782,9 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
|
||||||
} else {
|
} else {
|
||||||
NS_ASSERTION(heightUnit == mStylePosition->mHeight.GetUnit(),
|
NS_ASSERTION(heightUnit == mStylePosition->mHeight.GetUnit(),
|
||||||
"unexpected height unit change");
|
"unexpected height unit change");
|
||||||
|
mComputedHeight = nsLayoutUtils::
|
||||||
ComputeHeightDependentValue(aContainingBlockHeight,
|
ComputeHeightDependentValue(aContainingBlockHeight,
|
||||||
mStylePosition->mHeight,
|
mStylePosition->mHeight);
|
||||||
mComputedHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't apply to table elements
|
// Doesn't apply to table elements
|
||||||
|
@ -2050,43 +2030,35 @@ GetNormalLineHeight(nsIFontMetrics* aFontMetrics)
|
||||||
return normalLineHeight;
|
return normalLineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need only one of aRenderingContext and aDeviceContext
|
|
||||||
static nscoord
|
static nscoord
|
||||||
ComputeLineHeight(nsIRenderingContext* aRenderingContext,
|
ComputeLineHeight(nsStyleContext* aStyleContext)
|
||||||
nsStyleContext* aStyleContext)
|
|
||||||
{
|
{
|
||||||
nscoord lineHeight;
|
|
||||||
|
|
||||||
const nsStyleCoord& lhCoord = aStyleContext->GetStyleText()->mLineHeight;
|
const nsStyleCoord& lhCoord = aStyleContext->GetStyleText()->mLineHeight;
|
||||||
|
|
||||||
if (!nsLayoutUtils::GetAbsoluteCoord(lhCoord, aRenderingContext,
|
if (lhCoord.GetUnit() == eStyleUnit_Coord)
|
||||||
aStyleContext, lineHeight)) {
|
return lhCoord.GetCoordValue();
|
||||||
const nsStyleFont* font = aStyleContext->GetStyleFont();
|
|
||||||
if (lhCoord.GetUnit() == eStyleUnit_Factor) {
|
if (lhCoord.GetUnit() == eStyleUnit_Factor)
|
||||||
// For factor units the computed value of the line-height property
|
// For factor units the computed value of the line-height property
|
||||||
// is found by multiplying the factor by the font's computed size
|
// is found by multiplying the factor by the font's computed size
|
||||||
// (adjusted for min-size prefs and text zoom).
|
// (adjusted for min-size prefs and text zoom).
|
||||||
float factor = lhCoord.GetFactorValue();
|
return NSToCoordRound(lhCoord.GetFactorValue() *
|
||||||
lineHeight = NSToCoordRound(factor * font->mFont.size);
|
aStyleContext->GetStyleFont()->mFont.size);
|
||||||
} else {
|
|
||||||
|
|
||||||
NS_ASSERTION(eStyleUnit_Normal == lhCoord.GetUnit(), "bad unit");
|
NS_ASSERTION(eStyleUnit_Normal == lhCoord.GetUnit(), "bad unit");
|
||||||
nsCOMPtr<nsIFontMetrics> fm;
|
nsCOMPtr<nsIFontMetrics> fm;
|
||||||
nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext,
|
nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext,
|
||||||
getter_AddRefs(fm));
|
getter_AddRefs(fm));
|
||||||
lineHeight = GetNormalLineHeight(fm);
|
return GetNormalLineHeight(fm);
|
||||||
}
|
|
||||||
}
|
|
||||||
return lineHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord
|
nscoord
|
||||||
nsHTMLReflowState::CalcLineHeight(nsIRenderingContext* aRenderingContext,
|
nsHTMLReflowState::CalcLineHeight(nsStyleContext* aStyleContext)
|
||||||
nsStyleContext* aStyleContext)
|
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aRenderingContext, "Must have a rendering context");
|
|
||||||
NS_PRECONDITION(aStyleContext, "Must have a style context");
|
NS_PRECONDITION(aStyleContext, "Must have a style context");
|
||||||
|
|
||||||
nscoord lineHeight = ComputeLineHeight(aRenderingContext, aStyleContext);
|
nscoord lineHeight = ComputeLineHeight(aStyleContext);
|
||||||
|
|
||||||
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
|
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
|
||||||
|
|
||||||
|
@ -2122,24 +2094,24 @@ nsCSSOffsetState::ComputeMargin(nscoord aContainingBlockWidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
mComputedMargin.left = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
styleMargin->mMargin.GetLeft(),
|
styleMargin->mMargin.GetLeft());
|
||||||
mComputedMargin.left);
|
mComputedMargin.right = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
styleMargin->mMargin.GetRight(),
|
styleMargin->mMargin.GetRight());
|
||||||
mComputedMargin.right);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// According to the CSS2 spec, margin percentages are
|
// According to the CSS2 spec, margin percentages are
|
||||||
// calculated with respect to the *width* of the containing
|
// calculated with respect to the *width* of the containing
|
||||||
// block, even for margin-top and margin-bottom.
|
// block, even for margin-top and margin-bottom.
|
||||||
// XXX This isn't true for page boxes, if we implement them.
|
// XXX This isn't true for page boxes, if we implement them.
|
||||||
|
mComputedMargin.top = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
styleMargin->mMargin.GetTop(),
|
styleMargin->mMargin.GetTop());
|
||||||
mComputedMargin.top);
|
mComputedMargin.bottom = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
styleMargin->mMargin.GetBottom(),
|
styleMargin->mMargin.GetBottom());
|
||||||
mComputedMargin.bottom);
|
|
||||||
|
|
||||||
// XXX We need to include 'auto' horizontal margins in this too!
|
// XXX We need to include 'auto' horizontal margins in this too!
|
||||||
// ... but if we did that, we'd need to fix nsFrame::GetUsedMargin
|
// ... but if we did that, we'd need to fix nsFrame::GetUsedMargin
|
||||||
|
@ -2158,21 +2130,21 @@ nsCSSOffsetState::ComputePadding(nscoord aContainingBlockWidth)
|
||||||
const nsStylePadding *stylePadding = frame->GetStylePadding();
|
const nsStylePadding *stylePadding = frame->GetStylePadding();
|
||||||
if (!stylePadding->GetPadding(mComputedPadding)) {
|
if (!stylePadding->GetPadding(mComputedPadding)) {
|
||||||
// We have to compute the value
|
// We have to compute the value
|
||||||
|
mComputedPadding.left = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
stylePadding->mPadding.GetLeft(),
|
stylePadding->mPadding.GetLeft());
|
||||||
mComputedPadding.left);
|
mComputedPadding.right = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
stylePadding->mPadding.GetRight(),
|
stylePadding->mPadding.GetRight());
|
||||||
mComputedPadding.right);
|
|
||||||
|
|
||||||
// According to the CSS2 spec, percentages are calculated with respect to
|
// According to the CSS2 spec, percentages are calculated with respect to
|
||||||
// containing block width for padding-top and padding-bottom
|
// containing block width for padding-top and padding-bottom
|
||||||
|
mComputedPadding.top = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
stylePadding->mPadding.GetTop(),
|
stylePadding->mPadding.GetTop());
|
||||||
mComputedPadding.top);
|
mComputedPadding.bottom = nsLayoutUtils::
|
||||||
ComputeWidthDependentValue(aContainingBlockWidth,
|
ComputeWidthDependentValue(aContainingBlockWidth,
|
||||||
stylePadding->mPadding.GetBottom(),
|
stylePadding->mPadding.GetBottom());
|
||||||
mComputedPadding.bottom);
|
|
||||||
|
|
||||||
frame->SetProperty(nsGkAtoms::usedPaddingProperty,
|
frame->SetProperty(nsGkAtoms::usedPaddingProperty,
|
||||||
new nsMargin(mComputedPadding),
|
new nsMargin(mComputedPadding),
|
||||||
|
@ -2241,8 +2213,9 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
||||||
(eStyleUnit_Percent == mStylePosition->mMinHeight.GetUnit())) {
|
(eStyleUnit_Percent == mStylePosition->mMinHeight.GetUnit())) {
|
||||||
mComputedMinHeight = 0;
|
mComputedMinHeight = 0;
|
||||||
} else {
|
} else {
|
||||||
|
mComputedMinHeight = nsLayoutUtils::
|
||||||
ComputeHeightDependentValue(aContainingBlockHeight,
|
ComputeHeightDependentValue(aContainingBlockHeight,
|
||||||
mStylePosition->mMinHeight, mComputedMinHeight);
|
mStylePosition->mMinHeight);
|
||||||
}
|
}
|
||||||
nsStyleUnit maxHeightUnit = mStylePosition->mMaxHeight.GetUnit();
|
nsStyleUnit maxHeightUnit = mStylePosition->mMaxHeight.GetUnit();
|
||||||
if (eStyleUnit_None == maxHeightUnit) {
|
if (eStyleUnit_None == maxHeightUnit) {
|
||||||
|
@ -2255,8 +2228,9 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
||||||
(eStyleUnit_Percent == maxHeightUnit)) {
|
(eStyleUnit_Percent == maxHeightUnit)) {
|
||||||
mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;
|
mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;
|
||||||
} else {
|
} else {
|
||||||
|
mComputedMaxHeight = nsLayoutUtils::
|
||||||
ComputeHeightDependentValue(aContainingBlockHeight,
|
ComputeHeightDependentValue(aContainingBlockHeight,
|
||||||
mStylePosition->mMaxHeight, mComputedMaxHeight);
|
mStylePosition->mMaxHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,15 +194,6 @@ protected:
|
||||||
const nsMargin *aBorder = nsnull,
|
const nsMargin *aBorder = nsnull,
|
||||||
const nsMargin *aPadding = nsnull);
|
const nsMargin *aPadding = nsnull);
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert nsStyleCoord to nscoord when percentages depend on the
|
|
||||||
* containing block width.
|
|
||||||
*/
|
|
||||||
// XXX Make aResult a return value
|
|
||||||
inline void ComputeWidthDependentValue(nscoord aContainingBlockWidth,
|
|
||||||
const nsStyleCoord& aCoord,
|
|
||||||
nscoord& aResult);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert nsStyleCoord to nscoord when percentages depend on the
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
||||||
* containing block width, and enumerated values are for width,
|
* containing block width, and enumerated values are for width,
|
||||||
|
@ -217,15 +208,6 @@ protected:
|
||||||
nscoord ComputeWidthValue(nscoord aContainingBlockWidth,
|
nscoord ComputeWidthValue(nscoord aContainingBlockWidth,
|
||||||
PRUint8 aBoxSizing,
|
PRUint8 aBoxSizing,
|
||||||
const nsStyleCoord& aCoord);
|
const nsStyleCoord& aCoord);
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert nsStyleCoord to nscoord when percentages depend on the
|
|
||||||
* containing block height.
|
|
||||||
*/
|
|
||||||
// XXX Make aResult a return value
|
|
||||||
inline void ComputeHeightDependentValue(nscoord aContainingBlockHeight,
|
|
||||||
const nsStyleCoord& aCoord,
|
|
||||||
nscoord& aResult);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -422,17 +404,15 @@ public:
|
||||||
* Calculate the raw line-height property for the given frame. The return
|
* Calculate the raw line-height property for the given frame. The return
|
||||||
* value will be >= 0.
|
* value will be >= 0.
|
||||||
*/
|
*/
|
||||||
static nscoord CalcLineHeight(nsIRenderingContext* aRenderingContext,
|
static nscoord CalcLineHeight(nsIFrame* aFrame)
|
||||||
nsIFrame* aFrame)
|
|
||||||
{
|
{
|
||||||
return CalcLineHeight(aRenderingContext, aFrame->GetStyleContext());
|
return CalcLineHeight(aFrame->GetStyleContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as above, but doesn't need a frame.
|
* Same as above, but doesn't need a frame.
|
||||||
*/
|
*/
|
||||||
static nscoord CalcLineHeight(nsIRenderingContext* aRenderingContext,
|
static nscoord CalcLineHeight(nsStyleContext* aStyleContext);
|
||||||
nsStyleContext* aStyleContext);
|
|
||||||
|
|
||||||
|
|
||||||
void ComputeContainingBlockRectangle(nsPresContext* aPresContext,
|
void ComputeContainingBlockRectangle(nsPresContext* aPresContext,
|
||||||
|
|
|
@ -1666,7 +1666,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
||||||
// Compute the logical height for this span. The logical height
|
// Compute the logical height for this span. The logical height
|
||||||
// is based on the line-height value, not the font-size. Also
|
// is based on the line-height value, not the font-size. Also
|
||||||
// compute the top leading.
|
// compute the top leading.
|
||||||
nscoord logicalHeight = nsHTMLReflowState::CalcLineHeight(rc, spanFrame);
|
nscoord logicalHeight = nsHTMLReflowState::CalcLineHeight(spanFrame);
|
||||||
nscoord contentHeight = spanFramePFD->mBounds.height -
|
nscoord contentHeight = spanFramePFD->mBounds.height -
|
||||||
spanFramePFD->mBorderPadding.top - spanFramePFD->mBorderPadding.bottom;
|
spanFramePFD->mBorderPadding.top - spanFramePFD->mBorderPadding.bottom;
|
||||||
|
|
||||||
|
@ -1912,7 +1912,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
||||||
case eStyleUnit_Percent:
|
case eStyleUnit_Percent:
|
||||||
// Similar to a length value (eStyleUnit_Coord) except that the
|
// Similar to a length value (eStyleUnit_Coord) except that the
|
||||||
// percentage is a function of the elements line-height value.
|
// percentage is a function of the elements line-height value.
|
||||||
elementLineHeight = nsHTMLReflowState::CalcLineHeight(rc, frame);
|
elementLineHeight = nsHTMLReflowState::CalcLineHeight(frame);
|
||||||
percentOffset = nscoord(
|
percentOffset = nscoord(
|
||||||
textStyle->mVerticalAlign.GetPercentValue() * elementLineHeight
|
textStyle->mVerticalAlign.GetPercentValue() * elementLineHeight
|
||||||
);
|
);
|
||||||
|
|
|
@ -2955,19 +2955,7 @@ nsComputedDOMStyle::GetPaddingWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
|
||||||
PRBool
|
PRBool
|
||||||
nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord)
|
nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord)
|
||||||
{
|
{
|
||||||
// Get a rendering context
|
aCoord = nsHTMLReflowState::CalcLineHeight(mStyleContextHolder);
|
||||||
nsCOMPtr<nsIRenderingContext> cx;
|
|
||||||
nsIFrame* frame = mPresShell->FrameManager()->GetRootFrame();
|
|
||||||
if (frame) {
|
|
||||||
mPresShell->CreateRenderingContext(frame, getter_AddRefs(cx));
|
|
||||||
}
|
|
||||||
if (!cx) {
|
|
||||||
// Give up
|
|
||||||
aCoord = 0;
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
aCoord = nsHTMLReflowState::CalcLineHeight(cx, mStyleContextHolder);
|
|
||||||
|
|
||||||
// CalcLineHeight uses font->mFont.size, but we want to use
|
// CalcLineHeight uses font->mFont.size, but we want to use
|
||||||
// font->mSize as the font size. Adjust for that. Also adjust for
|
// font->mSize as the font size. Adjust for that. Also adjust for
|
||||||
|
|
|
@ -664,20 +664,20 @@ nsIFrame::Redraw(nsBoxLayoutState& aState,
|
||||||
PRBool
|
PRBool
|
||||||
nsIBox::AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
nsIBox::AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
||||||
{
|
{
|
||||||
PRBool heightSet = PR_FALSE;
|
PRBool widthSet = PR_FALSE, heightSet = PR_FALSE;
|
||||||
|
|
||||||
// add in the css min, max, pref
|
// add in the css min, max, pref
|
||||||
const nsStylePosition* position = aBox->GetStylePosition();
|
const nsStylePosition* position = aBox->GetStylePosition();
|
||||||
|
|
||||||
// see if the width or height was specifically set
|
// see if the width or height was specifically set
|
||||||
PRBool widthSet =
|
|
||||||
nsLayoutUtils::GetAbsoluteCoord(position->mWidth,
|
|
||||||
aState.GetRenderingContext(),
|
|
||||||
aBox, aSize.width);
|
|
||||||
// XXX Handle eStyleUnit_Enumerated?
|
// XXX Handle eStyleUnit_Enumerated?
|
||||||
// (Handling the eStyleUnit_Enumerated types requires
|
// (Handling the eStyleUnit_Enumerated types requires
|
||||||
// GetPrefSize/GetMinSize methods that don't consider
|
// GetPrefSize/GetMinSize methods that don't consider
|
||||||
// (min-/max-/)(width/height) properties.
|
// (min-/max-/)(width/height) properties.)
|
||||||
|
if (position->mWidth.GetUnit() == eStyleUnit_Coord) {
|
||||||
|
aSize.width = position->mWidth.GetCoordValue();
|
||||||
|
widthSet = PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (position->mHeight.GetUnit() == eStyleUnit_Coord) {
|
if (position->mHeight.GetUnit() == eStyleUnit_Coord) {
|
||||||
aSize.height = position->mHeight.GetCoordValue();
|
aSize.height = position->mHeight.GetCoordValue();
|
||||||
|
@ -750,10 +750,8 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
||||||
|
|
||||||
// same for min size. Unfortunately min size is always set to 0. So for now
|
// same for min size. Unfortunately min size is always set to 0. So for now
|
||||||
// we will assume 0 means not set.
|
// we will assume 0 means not set.
|
||||||
nscoord min;
|
if (position->mMinWidth.GetUnit() == eStyleUnit_Coord) {
|
||||||
if (nsLayoutUtils::GetAbsoluteCoord(position->mMinWidth,
|
nscoord min = position->mMinWidth.GetCoordValue();
|
||||||
aState.GetRenderingContext(),
|
|
||||||
aBox, min)) {
|
|
||||||
if (min && (!widthSet || (min > aSize.width && canOverride))) {
|
if (min && (!widthSet || (min > aSize.width && canOverride))) {
|
||||||
aSize.width = min;
|
aSize.width = min;
|
||||||
widthSet = PR_TRUE;
|
widthSet = PR_TRUE;
|
||||||
|
@ -819,24 +817,24 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
||||||
PRBool
|
PRBool
|
||||||
nsIBox::AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
nsIBox::AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
||||||
{
|
{
|
||||||
PRBool heightSet = PR_FALSE;
|
PRBool widthSet = PR_FALSE, heightSet = PR_FALSE;
|
||||||
|
|
||||||
// add in the css min, max, pref
|
// add in the css min, max, pref
|
||||||
const nsStylePosition* position = aBox->GetStylePosition();
|
const nsStylePosition* position = aBox->GetStylePosition();
|
||||||
|
|
||||||
// and max
|
// and max
|
||||||
PRBool widthSet =
|
// see if the width or height was specifically set
|
||||||
nsLayoutUtils::GetAbsoluteCoord(position->mMaxWidth,
|
|
||||||
aState.GetRenderingContext(),
|
|
||||||
aBox, aSize.width);
|
|
||||||
// XXX Handle eStyleUnit_Enumerated?
|
// XXX Handle eStyleUnit_Enumerated?
|
||||||
// (Handling the eStyleUnit_Enumerated types requires
|
// (Handling the eStyleUnit_Enumerated types requires
|
||||||
// GetPrefSize/GetMinSize methods that don't consider
|
// GetPrefSize/GetMinSize methods that don't consider
|
||||||
// (min-/max-/)(width/height) properties.
|
// (min-/max-/)(width/height) properties.)
|
||||||
|
if (position->mMaxWidth.GetUnit() == eStyleUnit_Coord) {
|
||||||
|
aSize.width = position->mMaxWidth.GetCoordValue();
|
||||||
|
widthSet = PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (position->mMaxHeight.GetUnit() == eStyleUnit_Coord) {
|
if (position->mMaxHeight.GetUnit() == eStyleUnit_Coord) {
|
||||||
nscoord max = position->mMaxHeight.GetCoordValue();
|
aSize.height = position->mMaxHeight.GetCoordValue();
|
||||||
aSize.height = max;
|
|
||||||
heightSet = PR_TRUE;
|
heightSet = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче