Don't allow negative line-heights to make it past the CSS parser. Bug 240900,

r+sr=dbaron
This commit is contained in:
bzbarsky%mit.edu 2004-04-18 20:10:09 +00:00
Родитель ea5ea5c43c
Коммит 3d8d255e66
4 изменённых файлов: 22 добавлений и 44 удалений

Просмотреть файл

@ -5197,7 +5197,9 @@ PRBool CSSParserImpl::ParseFont(nsresult& aErrorCode)
// Get optional "/" line-height
nsCSSValue lineHeight;
if (ExpectSymbol(aErrorCode, '/', PR_TRUE)) {
if (! ParseVariant(aErrorCode, lineHeight, VARIANT_NUMBER | VARIANT_LP | VARIANT_NORMAL, nsnull)) {
if (! ParsePositiveVariant(aErrorCode, lineHeight,
VARIANT_NUMBER | VARIANT_LP | VARIANT_NORMAL,
nsnull)) {
return PR_FALSE;
}
}

Просмотреть файл

@ -2185,27 +2185,14 @@ nsHTMLReflowState::CalcLineHeight(nsIPresContext* aPresContext,
nsIRenderingContext* aRenderingContext,
nsIFrame* aFrame)
{
nscoord lineHeight = -1;
nsStyleContext* sc = aFrame->GetStyleContext();
if (sc) {
lineHeight = ComputeLineHeight(aPresContext, aRenderingContext, sc);
}
if (lineHeight < 0) {
// Negative line-heights are not allowed by the spec. Translate
// them into "normal" when found.
const nsStyleFont* font = sc->GetStyleFont();
if (UseComputedHeight()) {
lineHeight = font->mFont.size;
}
else {
SetFontFromStyle(aRenderingContext, sc);
nsCOMPtr<nsIFontMetrics> fm;
aRenderingContext->GetFontMetrics(*getter_AddRefs(fm));
if (fm) {
lineHeight = GetNormalLineHeight(fm);
}
}
}
NS_ASSERTION(aFrame && aFrame->GetStyleContext(),
"Bogus data passed in to CalcLineHeight");
nscoord lineHeight = ComputeLineHeight(aPresContext, aRenderingContext,
aFrame->GetStyleContext());
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
return lineHeight;
}

Просмотреть файл

@ -2185,27 +2185,14 @@ nsHTMLReflowState::CalcLineHeight(nsIPresContext* aPresContext,
nsIRenderingContext* aRenderingContext,
nsIFrame* aFrame)
{
nscoord lineHeight = -1;
nsStyleContext* sc = aFrame->GetStyleContext();
if (sc) {
lineHeight = ComputeLineHeight(aPresContext, aRenderingContext, sc);
}
if (lineHeight < 0) {
// Negative line-heights are not allowed by the spec. Translate
// them into "normal" when found.
const nsStyleFont* font = sc->GetStyleFont();
if (UseComputedHeight()) {
lineHeight = font->mFont.size;
}
else {
SetFontFromStyle(aRenderingContext, sc);
nsCOMPtr<nsIFontMetrics> fm;
aRenderingContext->GetFontMetrics(*getter_AddRefs(fm));
if (fm) {
lineHeight = GetNormalLineHeight(fm);
}
}
}
NS_ASSERTION(aFrame && aFrame->GetStyleContext(),
"Bogus data passed in to CalcLineHeight");
nscoord lineHeight = ComputeLineHeight(aPresContext, aRenderingContext,
aFrame->GetStyleContext());
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
return lineHeight;
}

Просмотреть файл

@ -5197,7 +5197,9 @@ PRBool CSSParserImpl::ParseFont(nsresult& aErrorCode)
// Get optional "/" line-height
nsCSSValue lineHeight;
if (ExpectSymbol(aErrorCode, '/', PR_TRUE)) {
if (! ParseVariant(aErrorCode, lineHeight, VARIANT_NUMBER | VARIANT_LP | VARIANT_NORMAL, nsnull)) {
if (! ParsePositiveVariant(aErrorCode, lineHeight,
VARIANT_NUMBER | VARIANT_LP | VARIANT_NORMAL,
nsnull)) {
return PR_FALSE;
}
}