зеркало из https://github.com/mozilla/pjs.git
Back out 0b57ada5d4b2 due to mochitest failures on at least Windows. (Bug 363706)
This commit is contained in:
Родитель
cb5bc9d2a1
Коммит
c53e393693
|
@ -1493,6 +1493,25 @@ static nscoord AddPercents(nsLayoutUtils::IntrinsicWidthType aType,
|
|||
return result;
|
||||
}
|
||||
|
||||
/* static */ PRBool
|
||||
nsLayoutUtils::GetAbsoluteCoord(const nsStyleCoord& aStyle,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsStyleContext* aStyleContext,
|
||||
nscoord& aResult)
|
||||
{
|
||||
nsStyleUnit unit = aStyle.GetUnit();
|
||||
if (eStyleUnit_Coord == unit) {
|
||||
aResult = aStyle.GetCoordValue();
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (eStyleUnit_Chars == unit) {
|
||||
aResult = nsLayoutUtils::CharsToCoord(aStyle, aRenderingContext,
|
||||
aStyleContext);
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
GetPercentHeight(const nsStyleCoord& aStyle,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
|
@ -2632,6 +2651,21 @@ nsLayoutUtils::SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC)
|
|||
aRC->SetFont(font->mFont, visibility->mLangGroup);
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsLayoutUtils::CharsToCoord(const nsStyleCoord& aStyle,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsStyleContext* aStyleContext)
|
||||
{
|
||||
NS_ASSERTION(aStyle.GetUnit() == eStyleUnit_Chars,
|
||||
"Shouldn't have called this");
|
||||
|
||||
SetFontFromStyle(aRenderingContext, aStyleContext);
|
||||
nscoord fontWidth;
|
||||
aRenderingContext->SetTextRunRTL(PR_FALSE);
|
||||
aRenderingContext->GetWidth('M', fontWidth);
|
||||
return aStyle.GetIntValue() * fontWidth;
|
||||
}
|
||||
|
||||
static PRBool NonZeroStyleCoord(const nsStyleCoord& aCoord)
|
||||
{
|
||||
switch (aCoord.GetUnit()) {
|
||||
|
|
|
@ -589,7 +589,7 @@ public:
|
|||
* @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
|
||||
* @return TRUE if the unit is eStyleUnit_Coord or eStyleUnit_Chars
|
||||
*/
|
||||
static PRBool GetAbsoluteCoord(const nsStyleCoord& aStyle,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
|
@ -606,16 +606,7 @@ public:
|
|||
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;
|
||||
}
|
||||
|
||||
nscoord& aResult);
|
||||
/**
|
||||
* Get the contribution of aFrame to its containing block's intrinsic
|
||||
* width. This considers the child's intrinsic width, its 'width',
|
||||
|
@ -770,6 +761,17 @@ public:
|
|||
*/
|
||||
static void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC);
|
||||
|
||||
/**
|
||||
* Convert an eStyleUnit_Chars nsStyleCoord to an nscoord.
|
||||
*
|
||||
* @param aStyle the style coord
|
||||
* @param aRenderingContext the rendering context to use for font measurement
|
||||
* @param aStyleContext the style context to use for font infomation
|
||||
*/
|
||||
static nscoord CharsToCoord(const nsStyleCoord& aStyle,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsStyleContext* aStyleContext);
|
||||
|
||||
/**
|
||||
* Determine if any style coordinate is nonzero
|
||||
* @param aCoord the style sides
|
||||
|
|
|
@ -210,24 +210,26 @@ nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
|
|||
}
|
||||
|
||||
static inline PRBool IsFixedPaddingSize(nsStyleUnit aUnit) {
|
||||
return aUnit == eStyleUnit_Coord;
|
||||
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Chars;
|
||||
}
|
||||
static inline PRBool IsFixedMarginSize(nsStyleUnit aUnit) {
|
||||
return aUnit == eStyleUnit_Coord;
|
||||
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Chars;
|
||||
}
|
||||
static inline PRBool IsFixedMaxSize(nsStyleUnit aUnit) {
|
||||
return aUnit == eStyleUnit_None || aUnit == eStyleUnit_Coord;
|
||||
return aUnit == eStyleUnit_None || aUnit == eStyleUnit_Coord ||
|
||||
aUnit == eStyleUnit_Chars;
|
||||
}
|
||||
static inline PRBool IsFixedOffset(nsStyleUnit aUnit) {
|
||||
return aUnit == eStyleUnit_Coord;
|
||||
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Chars;
|
||||
}
|
||||
static inline PRBool IsFixedHeight(nsStyleUnit aUnit) {
|
||||
return aUnit == eStyleUnit_Coord;
|
||||
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Chars;
|
||||
}
|
||||
|
||||
static inline PRBool IsFixedWidth(const nsStyleCoord& aCoord)
|
||||
{
|
||||
return aCoord.GetUnit() == eStyleUnit_Coord ||
|
||||
aCoord.GetUnit() == eStyleUnit_Chars ||
|
||||
(aCoord.GetUnit() == eStyleUnit_Enumerated &&
|
||||
(aCoord.GetIntValue() == NS_STYLE_WIDTH_MAX_CONTENT ||
|
||||
aCoord.GetIntValue() == NS_STYLE_WIDTH_MIN_CONTENT));
|
||||
|
|
|
@ -2963,6 +2963,11 @@ AddCoord(const nsStyleCoord& aStyle,
|
|||
case eStyleUnit_Percent:
|
||||
*aPercent += aStyle.GetPercentValue();
|
||||
break;
|
||||
case eStyleUnit_Chars: {
|
||||
*aCoord += nsLayoutUtils::CharsToCoord(aStyle, aRenderingContext,
|
||||
aFrame->GetStyleContext());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2771,6 +2771,7 @@ nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIDOMCSSValue** aValue)
|
|||
|
||||
NS_ASSERTION(coord.GetUnit() == eStyleUnit_Coord ||
|
||||
coord.GetUnit() == eStyleUnit_Percent ||
|
||||
coord.GetUnit() == eStyleUnit_Chars ||
|
||||
coord.GetUnit() == eStyleUnit_Auto,
|
||||
"Unexpected unit");
|
||||
|
||||
|
@ -3057,6 +3058,24 @@ nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue* aValue,
|
|||
aTable));
|
||||
break;
|
||||
|
||||
case eStyleUnit_Chars: {
|
||||
// Get a rendering context
|
||||
nsCOMPtr<nsIRenderingContext> cx;
|
||||
nsIFrame* frame = mPresShell->FrameManager()->GetRootFrame();
|
||||
if (frame) {
|
||||
mPresShell->CreateRenderingContext(frame, getter_AddRefs(cx));
|
||||
}
|
||||
if (cx) {
|
||||
nscoord val =
|
||||
nsLayoutUtils::CharsToCoord(aCoord, cx, mStyleContextHolder);
|
||||
aValue->SetAppUnits(PR_MAX(aMinAppUnits, PR_MIN(val, aMaxAppUnits)));
|
||||
} else {
|
||||
// Oh, well. Give up.
|
||||
aValue->SetAppUnits(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case eStyleUnit_None:
|
||||
aValue->SetIdent(nsGkAtoms::none);
|
||||
break;
|
||||
|
@ -3076,6 +3095,21 @@ nsComputedDOMStyle::StyleCoordToNSCoord(const nsStyleCoord& aCoord,
|
|||
switch (aCoord.GetUnit()) {
|
||||
case eStyleUnit_Coord:
|
||||
return aCoord.GetCoordValue();
|
||||
case eStyleUnit_Chars:
|
||||
{
|
||||
// Get a rendering context
|
||||
nsCOMPtr<nsIRenderingContext> cx;
|
||||
nsIFrame* frame = mPresShell->FrameManager()->GetRootFrame();
|
||||
if (frame) {
|
||||
mPresShell->CreateRenderingContext(frame, getter_AddRefs(cx));
|
||||
}
|
||||
if (!cx) {
|
||||
// Return the default value, I guess
|
||||
break;
|
||||
}
|
||||
|
||||
return nsLayoutUtils::CharsToCoord(aCoord, cx, mStyleContextHolder);
|
||||
}
|
||||
case eStyleUnit_Percent:
|
||||
{
|
||||
nscoord percentageBase;
|
||||
|
|
|
@ -320,6 +320,10 @@ static PRBool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord,
|
|||
if (aValue.GetUnit() == eCSSUnit_Null) {
|
||||
result = PR_FALSE;
|
||||
}
|
||||
else if (((aMask & SETCOORD_LENGTH) != 0) &&
|
||||
(aValue.GetUnit() == eCSSUnit_Char)) {
|
||||
aCoord.SetIntValue(NSToIntFloor(aValue.GetFloatValue()), eStyleUnit_Chars);
|
||||
}
|
||||
else if (((aMask & SETCOORD_LENGTH) != 0) &&
|
||||
aValue.IsLengthUnit()) {
|
||||
aCoord.SetCoordValue(CalcLength(aValue, aStyleContext, aPresContext, aInherited));
|
||||
|
@ -3729,8 +3733,15 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
|
|||
// OK to pass bad aParentCoord since we're not passing SETCOORD_INHERIT
|
||||
else if (SetCoord(value, coord, nsStyleCoord(), SETCOORD_LENGTH,
|
||||
aContext, mPresContext, inherited)) {
|
||||
NS_ASSERTION(coord.GetUnit() == eStyleUnit_Coord, "unexpected unit");
|
||||
border->SetBorderWidth(side, coord.GetCoordValue());
|
||||
if (coord.GetUnit() == eStyleUnit_Coord) {
|
||||
border->SetBorderWidth(side, coord.GetCoordValue());
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
NS_ASSERTION(coord.GetUnit() == eStyleUnit_Chars, "unexpected unit");
|
||||
NS_WARNING("Border set in chars; we don't handle that");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (eCSSUnit_Inherit == value.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
|
|
|
@ -129,8 +129,10 @@ void nsStyleCoord::SetCoordValue(nscoord aValue)
|
|||
void nsStyleCoord::SetIntValue(PRInt32 aValue, nsStyleUnit aUnit)
|
||||
{
|
||||
NS_ASSERTION((aUnit == eStyleUnit_Enumerated) ||
|
||||
(aUnit == eStyleUnit_Chars) ||
|
||||
(aUnit == eStyleUnit_Integer), "not an int value");
|
||||
if ((aUnit == eStyleUnit_Enumerated) ||
|
||||
(aUnit == eStyleUnit_Chars) ||
|
||||
(aUnit == eStyleUnit_Integer)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mInt = aValue;
|
||||
|
@ -194,6 +196,7 @@ void nsStyleCoord::AppendToString(nsString& aBuffer) const
|
|||
case eStyleUnit_None: aBuffer.AppendLiteral("None"); break;
|
||||
case eStyleUnit_Enumerated: aBuffer.AppendLiteral("enum"); break;
|
||||
case eStyleUnit_Integer: aBuffer.AppendLiteral("int"); break;
|
||||
case eStyleUnit_Chars: aBuffer.AppendLiteral("chars"); break;
|
||||
}
|
||||
aBuffer.Append(PRUnichar(' '));
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ enum nsStyleUnit {
|
|||
eStyleUnit_Factor = 11, // (float) a multiplier
|
||||
eStyleUnit_Coord = 20, // (nscoord) value is twips
|
||||
eStyleUnit_Integer = 30, // (int) value is simple integer
|
||||
eStyleUnit_Enumerated = 32 // (int) value has enumerated meaning
|
||||
eStyleUnit_Enumerated = 32, // (int) value has enumerated meaning
|
||||
eStyleUnit_Chars = 33 // (int) value is number of characters
|
||||
};
|
||||
|
||||
typedef union {
|
||||
|
@ -196,8 +197,10 @@ inline PRInt32 nsStyleCoord::GetCoordValue(void) const
|
|||
inline PRInt32 nsStyleCoord::GetIntValue(void) const
|
||||
{
|
||||
NS_ASSERTION((mUnit == eStyleUnit_Enumerated) ||
|
||||
(mUnit == eStyleUnit_Chars) ||
|
||||
(mUnit == eStyleUnit_Integer), "not an int value");
|
||||
if ((mUnit == eStyleUnit_Enumerated) ||
|
||||
(mUnit == eStyleUnit_Chars) ||
|
||||
(mUnit == eStyleUnit_Integer)) {
|
||||
return mValue.mInt;
|
||||
}
|
||||
|
|
|
@ -231,6 +231,10 @@ static nscoord CalcCoord(const nsStyleCoord& aCoord,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case eStyleUnit_Chars:
|
||||
// XXX we need a frame and a rendering context to calculate this, bug 281972, bug 282126.
|
||||
NS_NOTYETIMPLEMENTED("CalcCoord: eStyleUnit_Chars");
|
||||
return 0;
|
||||
default:
|
||||
NS_ERROR("bad unit type");
|
||||
break;
|
||||
|
|
|
@ -526,7 +526,7 @@ struct nsStyleOutline {
|
|||
aOffset = NS_ROUND_OFFSET_TO_PIXELS(offset, mTwipsPerPixel);
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
NS_ERROR("GetOutlineOffset: bad unit type");
|
||||
NS_NOTYETIMPLEMENTED("GetOutlineOffset: eStyleUnit_Chars");
|
||||
aOffset = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ GetWidthInfo(nsIRenderingContext *aRenderingContext,
|
|||
// XXXldb Should we consider -moz-box-sizing?
|
||||
|
||||
nsStyleUnit unit = aStylePos->mWidth.GetUnit();
|
||||
if (unit == eStyleUnit_Coord) {
|
||||
if (unit == eStyleUnit_Coord || unit == eStyleUnit_Chars) {
|
||||
hasSpecifiedWidth = PR_TRUE;
|
||||
nscoord w = nsLayoutUtils::ComputeWidthValue(aRenderingContext,
|
||||
aFrame, 0, 0, 0, aStylePos->mWidth);
|
||||
|
@ -171,7 +171,8 @@ GetWidthInfo(nsIRenderingContext *aRenderingContext,
|
|||
unit = maxWidth.GetUnit();
|
||||
// XXX To really implement 'max-width' well, we'd need to store
|
||||
// it separately on the columns.
|
||||
if (unit == eStyleUnit_Coord || unit == eStyleUnit_Enumerated) {
|
||||
if (unit == eStyleUnit_Coord || unit == eStyleUnit_Chars ||
|
||||
unit == eStyleUnit_Enumerated) {
|
||||
nscoord w =
|
||||
nsLayoutUtils::ComputeWidthValue(aRenderingContext, aFrame,
|
||||
0, 0, 0, maxWidth);
|
||||
|
@ -196,7 +197,8 @@ GetWidthInfo(nsIRenderingContext *aRenderingContext,
|
|||
eStyleUnit_Enumerated);
|
||||
}
|
||||
unit = minWidth.GetUnit();
|
||||
if (unit == eStyleUnit_Coord || unit == eStyleUnit_Enumerated) {
|
||||
if (unit == eStyleUnit_Coord || unit == eStyleUnit_Chars ||
|
||||
unit == eStyleUnit_Enumerated) {
|
||||
nscoord w =
|
||||
nsLayoutUtils::ComputeWidthValue(aRenderingContext, aFrame,
|
||||
0, 0, 0, minWidth);
|
||||
|
|
|
@ -98,7 +98,8 @@ FixedTableLayoutStrategy::GetMinWidth(nsIRenderingContext* aRenderingContext)
|
|||
}
|
||||
const nsStyleCoord *styleWidth =
|
||||
&colFrame->GetStylePosition()->mWidth;
|
||||
if (styleWidth->GetUnit() == eStyleUnit_Coord) {
|
||||
if (styleWidth->GetUnit() == eStyleUnit_Coord ||
|
||||
styleWidth->GetUnit() == eStyleUnit_Chars) {
|
||||
result += nsLayoutUtils::ComputeWidthValue(aRenderingContext,
|
||||
colFrame, 0, 0, 0, *styleWidth);
|
||||
} else if (styleWidth->GetUnit() == eStyleUnit_Percent) {
|
||||
|
@ -117,6 +118,7 @@ FixedTableLayoutStrategy::GetMinWidth(nsIRenderingContext* aRenderingContext)
|
|||
if (cellFrame) {
|
||||
styleWidth = &cellFrame->GetStylePosition()->mWidth;
|
||||
if (styleWidth->GetUnit() == eStyleUnit_Coord ||
|
||||
styleWidth->GetUnit() == eStyleUnit_Chars ||
|
||||
(styleWidth->GetUnit() == eStyleUnit_Enumerated &&
|
||||
(styleWidth->GetIntValue() == NS_STYLE_WIDTH_MAX_CONTENT ||
|
||||
styleWidth->GetIntValue() == NS_STYLE_WIDTH_MIN_CONTENT))) {
|
||||
|
@ -214,7 +216,8 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
|
|||
const nsStyleCoord *styleWidth =
|
||||
&colFrame->GetStylePosition()->mWidth;
|
||||
nscoord colWidth;
|
||||
if (styleWidth->GetUnit() == eStyleUnit_Coord) {
|
||||
if (styleWidth->GetUnit() == eStyleUnit_Coord ||
|
||||
styleWidth->GetUnit() == eStyleUnit_Chars) {
|
||||
colWidth = nsLayoutUtils::ComputeWidthValue(
|
||||
aReflowState.rendContext,
|
||||
colFrame, 0, 0, 0, *styleWidth);
|
||||
|
@ -237,6 +240,7 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
|
|||
if (cellFrame) {
|
||||
styleWidth = &cellFrame->GetStylePosition()->mWidth;
|
||||
if (styleWidth->GetUnit() == eStyleUnit_Coord ||
|
||||
styleWidth->GetUnit() == eStyleUnit_Chars ||
|
||||
(styleWidth->GetUnit() == eStyleUnit_Enumerated &&
|
||||
(styleWidth->GetIntValue() == NS_STYLE_WIDTH_MAX_CONTENT ||
|
||||
styleWidth->GetIntValue() == NS_STYLE_WIDTH_MIN_CONTENT))) {
|
||||
|
|
|
@ -683,6 +683,7 @@ nsIBox::AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
|||
aSize.height = position->mHeight.GetCoordValue();
|
||||
heightSet = PR_TRUE;
|
||||
}
|
||||
// XXX Handle eStyleUnit_Chars?
|
||||
|
||||
nsIContent* content = aBox->GetContent();
|
||||
// ignore 'height' and 'width' attributes if the actual element is not XUL
|
||||
|
@ -781,6 +782,7 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
|||
aSize.height = 0;
|
||||
heightSet = PR_TRUE;
|
||||
}
|
||||
// XXX Handle eStyleUnit_Chars?
|
||||
|
||||
nsIContent* content = aBox->GetContent();
|
||||
if (content) {
|
||||
|
@ -839,6 +841,7 @@ nsIBox::AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
|||
aSize.height = max;
|
||||
heightSet = PR_TRUE;
|
||||
}
|
||||
// XXX Handle eStyleUnit_Chars?
|
||||
|
||||
nsIContent* content = aBox->GetContent();
|
||||
if (content) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче