Add eStyleUnit_None so we don't have to use eStyleUnit_Null as a real value for max-width and max-height. b=379741 r+sr=bzbarsky
This commit is contained in:
Родитель
78aa8b18a3
Коммит
55574120dc
|
@ -1500,7 +1500,7 @@ nsLayoutUtils::ComputeWidthDependentValue(
|
|||
if (eStyleUnit_Percent == aCoord.GetUnit()) {
|
||||
return NSToCoordFloor(aContainingBlockWidth * aCoord.GetPercentValue());
|
||||
}
|
||||
NS_ASSERTION(aCoord.GetUnit() == eStyleUnit_Null ||
|
||||
NS_ASSERTION(aCoord.GetUnit() == eStyleUnit_None ||
|
||||
aCoord.GetUnit() == eStyleUnit_Auto,
|
||||
"unexpected width value");
|
||||
return 0;
|
||||
|
@ -1594,7 +1594,7 @@ nsLayoutUtils::ComputeHeightDependentValue(
|
|||
return NSToCoordFloor(aContainingBlockHeight * aCoord.GetPercentValue());
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(aCoord.GetUnit() == eStyleUnit_Null ||
|
||||
NS_ASSERTION(aCoord.GetUnit() == eStyleUnit_None ||
|
||||
aCoord.GetUnit() == eStyleUnit_Auto,
|
||||
"unexpected height value");
|
||||
return 0;
|
||||
|
@ -1605,7 +1605,7 @@ IsAutoHeight(const nsStyleCoord &aCoord, nscoord aCBHeight)
|
|||
{
|
||||
nsStyleUnit unit = aCoord.GetUnit();
|
||||
return unit == eStyleUnit_Auto || // only for 'height'
|
||||
unit == eStyleUnit_Null || // only for 'max-height'
|
||||
unit == eStyleUnit_None || // only for 'max-height'
|
||||
(unit == eStyleUnit_Percent &&
|
||||
aCBHeight == NS_AUTOHEIGHT);
|
||||
}
|
||||
|
@ -1650,7 +1650,7 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
|||
NS_ASSERTION(width >= 0, "negative result from ComputeWidthValue");
|
||||
}
|
||||
|
||||
if (stylePos->mMaxWidth.GetUnit() != eStyleUnit_Null) {
|
||||
if (stylePos->mMaxWidth.GetUnit() != eStyleUnit_None) {
|
||||
maxWidth = nsLayoutUtils::ComputeWidthValue(aRenderingContext,
|
||||
aFrame, aCBSize.width, boxSizingAdjust.width,
|
||||
boxSizingToMarginEdgeWidth, stylePos->mMaxWidth);
|
||||
|
|
|
@ -192,7 +192,7 @@ static inline PRBool IsFixedMarginSize(nsStyleUnit aUnit) {
|
|||
aUnit == eStyleUnit_Chars;
|
||||
}
|
||||
static inline PRBool IsFixedMaxSize(nsStyleUnit aUnit) {
|
||||
return aUnit == eStyleUnit_Null || aUnit == eStyleUnit_Coord ||
|
||||
return aUnit == eStyleUnit_None || aUnit == eStyleUnit_Coord ||
|
||||
aUnit == eStyleUnit_Chars;
|
||||
}
|
||||
static inline PRBool IsFixedOffset(nsStyleUnit aUnit) {
|
||||
|
@ -213,7 +213,7 @@ static inline PRBool IsFixedWidth(const nsStyleCoord& aCoord)
|
|||
|
||||
static inline PRBool IsFixedMaxWidth(const nsStyleCoord& aCoord)
|
||||
{
|
||||
return aCoord.GetUnit() == eStyleUnit_Null ||
|
||||
return aCoord.GetUnit() == eStyleUnit_None ||
|
||||
IsFixedWidth(aCoord);
|
||||
}
|
||||
|
||||
|
|
|
@ -3104,7 +3104,7 @@ IsAutoHeight(const nsStyleCoord &aCoord, nscoord aCBHeight)
|
|||
{
|
||||
nsStyleUnit unit = aCoord.GetUnit();
|
||||
return unit == eStyleUnit_Auto || // only for 'height'
|
||||
unit == eStyleUnit_Null || // only for 'max-height'
|
||||
unit == eStyleUnit_None || // only for 'max-height'
|
||||
(unit == eStyleUnit_Percent &&
|
||||
aCBHeight == NS_AUTOHEIGHT);
|
||||
}
|
||||
|
@ -3139,7 +3139,7 @@ nsFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
|
|||
stylePos->mWidth);
|
||||
}
|
||||
|
||||
if (stylePos->mMaxWidth.GetUnit() != eStyleUnit_Null) {
|
||||
if (stylePos->mMaxWidth.GetUnit() != eStyleUnit_None) {
|
||||
nscoord maxWidth =
|
||||
nsLayoutUtils::ComputeWidthValue(aRenderingContext, this,
|
||||
aCBSize.width, boxSizingAdjust.width, boxSizingToMarginEdgeWidth,
|
||||
|
|
|
@ -2135,7 +2135,7 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
|||
mStylePosition->mBoxSizing,
|
||||
mStylePosition->mMinWidth);
|
||||
|
||||
if (eStyleUnit_Null == mStylePosition->mMaxWidth.GetUnit()) {
|
||||
if (eStyleUnit_None == mStylePosition->mMaxWidth.GetUnit()) {
|
||||
// Specified value of 'none'
|
||||
mComputedMaxWidth = NS_UNCONSTRAINEDSIZE; // no limit
|
||||
} else {
|
||||
|
@ -2160,7 +2160,7 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
|||
mStylePosition->mMinHeight, mComputedMinHeight);
|
||||
}
|
||||
nsStyleUnit maxHeightUnit = mStylePosition->mMaxHeight.GetUnit();
|
||||
if (eStyleUnit_Null == maxHeightUnit) {
|
||||
if (eStyleUnit_None == maxHeightUnit) {
|
||||
// Specified value of 'none'
|
||||
mComputedMaxHeight = NS_UNCONSTRAINEDSIZE; // no limit
|
||||
} else {
|
||||
|
|
|
@ -2767,7 +2767,7 @@ nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue* aValue,
|
|||
break;
|
||||
}
|
||||
|
||||
case eStyleUnit_Null:
|
||||
case eStyleUnit_None:
|
||||
aValue->SetIdent(nsGkAtoms::none);
|
||||
break;
|
||||
|
||||
|
|
|
@ -242,6 +242,7 @@ nscoord CalcLength(const nsCSSValue& aValue,
|
|||
#define SETCOORD_LENGTH 0x20 // L
|
||||
#define SETCOORD_INTEGER 0x40 // I
|
||||
#define SETCOORD_ENUMERATED 0x80 // E
|
||||
#define SETCOORD_NONE 0x100 // O
|
||||
|
||||
#define SETCOORD_LP (SETCOORD_LENGTH | SETCOORD_PERCENT)
|
||||
#define SETCOORD_LH (SETCOORD_LENGTH | SETCOORD_INHERIT)
|
||||
|
@ -251,6 +252,8 @@ nscoord CalcLength(const nsCSSValue& aValue,
|
|||
#define SETCOORD_LPAH (SETCOORD_LP | SETCOORD_AH)
|
||||
#define SETCOORD_LPEH (SETCOORD_LP | SETCOORD_ENUMERATED | SETCOORD_INHERIT)
|
||||
#define SETCOORD_LPAEH (SETCOORD_LPAH | SETCOORD_ENUMERATED)
|
||||
#define SETCOORD_LPOH (SETCOORD_LPH | SETCOORD_NONE)
|
||||
#define SETCOORD_LPOEH (SETCOORD_LPOH | SETCOORD_ENUMERATED)
|
||||
#define SETCOORD_LE (SETCOORD_LENGTH | SETCOORD_ENUMERATED)
|
||||
#define SETCOORD_LEH (SETCOORD_LE | SETCOORD_INHERIT)
|
||||
#define SETCOORD_IA (SETCOORD_INTEGER | SETCOORD_AUTO)
|
||||
|
@ -299,6 +302,10 @@ static PRBool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord,
|
|||
(aValue.GetUnit() == eCSSUnit_Normal)) {
|
||||
aCoord.SetNormalValue();
|
||||
}
|
||||
else if (((aMask & SETCOORD_NONE) != 0) &&
|
||||
(aValue.GetUnit() == eCSSUnit_None)) {
|
||||
aCoord.SetNoneValue();
|
||||
}
|
||||
else if (((aMask & SETCOORD_FACTOR) != 0) &&
|
||||
(aValue.GetUnit() == eCSSUnit_Number)) {
|
||||
aCoord.SetFactorValue(aValue.GetFloatValue());
|
||||
|
@ -3591,23 +3598,15 @@ nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct,
|
|||
SETCOORD_LPAEH, aContext, mPresContext, inherited);
|
||||
SetCoord(posData.mMinWidth, pos->mMinWidth, parentPos->mMinWidth,
|
||||
SETCOORD_LPEH, aContext, mPresContext, inherited);
|
||||
if (! SetCoord(posData.mMaxWidth, pos->mMaxWidth, parentPos->mMaxWidth,
|
||||
SETCOORD_LPEH, aContext, mPresContext, inherited)) {
|
||||
if (eCSSUnit_None == posData.mMaxWidth.GetUnit()) {
|
||||
pos->mMaxWidth.Reset();
|
||||
}
|
||||
}
|
||||
SetCoord(posData.mMaxWidth, pos->mMaxWidth, parentPos->mMaxWidth,
|
||||
SETCOORD_LPOEH, aContext, mPresContext, inherited);
|
||||
|
||||
SetCoord(posData.mHeight, pos->mHeight, parentPos->mHeight,
|
||||
SETCOORD_LPAH, aContext, mPresContext, inherited);
|
||||
SetCoord(posData.mMinHeight, pos->mMinHeight, parentPos->mMinHeight,
|
||||
SETCOORD_LPH, aContext, mPresContext, inherited);
|
||||
if (! SetCoord(posData.mMaxHeight, pos->mMaxHeight, parentPos->mMaxHeight,
|
||||
SETCOORD_LPH, aContext, mPresContext, inherited)) {
|
||||
if (eCSSUnit_None == posData.mMaxHeight.GetUnit()) {
|
||||
pos->mMaxHeight.Reset();
|
||||
}
|
||||
}
|
||||
SetCoord(posData.mMaxHeight, pos->mMaxHeight, parentPos->mMaxHeight,
|
||||
SETCOORD_LPOH, aContext, mPresContext, inherited);
|
||||
|
||||
// box-sizing: enum, inherit
|
||||
if (eCSSUnit_Enumerated == posData.mBoxSizing.GetUnit()) {
|
||||
|
|
|
@ -177,6 +177,12 @@ void nsStyleCoord::SetAutoValue(void)
|
|||
mValue.mInt = 0;
|
||||
}
|
||||
|
||||
void nsStyleCoord::SetNoneValue(void)
|
||||
{
|
||||
mUnit = eStyleUnit_None;
|
||||
mValue.mInt = 0;
|
||||
}
|
||||
|
||||
void nsStyleCoord::SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit)
|
||||
{
|
||||
mUnit = aUnit;
|
||||
|
@ -208,6 +214,7 @@ void nsStyleCoord::AppendToString(nsString& aBuffer) const
|
|||
case eStyleUnit_Factor: aBuffer.AppendLiteral("f"); break;
|
||||
case eStyleUnit_Normal: aBuffer.AppendLiteral("Normal"); break;
|
||||
case eStyleUnit_Auto: aBuffer.AppendLiteral("Auto"); break;
|
||||
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;
|
||||
|
|
|
@ -50,6 +50,7 @@ enum nsStyleUnit {
|
|||
eStyleUnit_Null = 0, // (no value) value is not specified
|
||||
eStyleUnit_Normal = 1, // (no value)
|
||||
eStyleUnit_Auto = 2, // (no value)
|
||||
eStyleUnit_None = 3, // (no value)
|
||||
eStyleUnit_Percent = 10, // (float) 1.0 == 100%
|
||||
eStyleUnit_Factor = 11, // (float) a multiplier
|
||||
eStyleUnit_Coord = 20, // (nscoord) value is twips
|
||||
|
@ -97,6 +98,7 @@ public:
|
|||
void SetFactorValue(float aValue);
|
||||
void SetNormalValue(void);
|
||||
void SetAutoValue(void);
|
||||
void SetNoneValue(void);
|
||||
void SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit);
|
||||
|
||||
void AppendToString(nsString& aBuffer) const;
|
||||
|
|
|
@ -864,10 +864,10 @@ nsStylePosition::nsStylePosition(void)
|
|||
mOffset.SetBottom(autoCoord);
|
||||
mWidth.SetAutoValue();
|
||||
mMinWidth.SetCoordValue(0);
|
||||
mMaxWidth.Reset();
|
||||
mMaxWidth.SetNoneValue();
|
||||
mHeight.SetAutoValue();
|
||||
mMinHeight.SetCoordValue(0);
|
||||
mMaxHeight.Reset();
|
||||
mMaxHeight.SetNoneValue();
|
||||
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
|
||||
mZIndex.SetAutoValue();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче