From 015d412b9844c9d838979c3df781fc7353c7f499 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Tue, 3 Sep 2002 23:55:48 +0000 Subject: [PATCH] Minimum font-size wasn't working if no font props was specified, b=163785, r=dbaron, sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@128778 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsRuleNode.cpp | 43 +++++++++++++++++-------- mozilla/layout/style/nsRuleNode.cpp | 43 +++++++++++++++++-------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 5edd6fc7ff3..bf3413af08c 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -1631,6 +1631,25 @@ ZoomFont(nsIPresContext* aPresContext, nscoord aInSize) return nscoord(aInSize * textZoom); } +static PRBool +IsChrome(nsIPresContext* aPresContext) +{ + PRBool isChrome = PR_FALSE; + nsCOMPtr container; + nsresult result = aPresContext->GetContainer(getter_AddRefs(container)); + if (NS_SUCCEEDED(result) && container) { + nsCOMPtr docShell(do_QueryInterface(container, &result)); + if (NS_SUCCEEDED(result) && docShell) { + PRInt32 docShellType; + result = docShell->GetItemType(&docShellType); + if (NS_SUCCEEDED(result)) { + isChrome = nsIDocShellTreeItem::typeChrome == docShellType; + } + } + } + return isChrome; +} + const nsStyleStruct* nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext) { @@ -1640,8 +1659,15 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte const nsFont* defaultFont; mPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, &defaultFont); nsStyleFont* fontData = new (mPresContext) nsStyleFont(*defaultFont); - fontData->mSize = fontData->mFont.size = - ZoomFont(mPresContext, fontData->mFont.size); + fontData->mSize = ZoomFont(mPresContext, fontData->mFont.size); + if (!IsChrome(mPresContext)) { + nscoord minimumFontSize = 0; + mPresContext->GetCachedIntPref(kPresContext_MinimumFontSize, minimumFontSize); + fontData->mFont.size = PR_MAX(fontData->mSize, minimumFontSize); + } + else { + fontData->mFont.size = fontData->mSize; + } aContext->SetStyle(eStyleStruct_Font, fontData); return fontData; } @@ -2216,18 +2242,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat // document fonts (overriding the useDocumentFonts flag), or to // determine if we have to override the minimum font-size constraint. if (!useDocumentFonts || minimumFontSize > 0) { - nsCOMPtr container; - nsresult result = mPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { - nsCOMPtr docShell(do_QueryInterface(container, &result)); - if (NS_SUCCEEDED(result) && docShell) { - PRInt32 docShellType; - result = docShell->GetItemType(&docShellType); - if (NS_SUCCEEDED(result)) { - chromeOverride = nsIDocShellTreeItem::typeChrome == docShellType; - } - } - } + chromeOverride = IsChrome(mPresContext); } // If we don't have to use document fonts, then we are only entitled diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 5edd6fc7ff3..bf3413af08c 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -1631,6 +1631,25 @@ ZoomFont(nsIPresContext* aPresContext, nscoord aInSize) return nscoord(aInSize * textZoom); } +static PRBool +IsChrome(nsIPresContext* aPresContext) +{ + PRBool isChrome = PR_FALSE; + nsCOMPtr container; + nsresult result = aPresContext->GetContainer(getter_AddRefs(container)); + if (NS_SUCCEEDED(result) && container) { + nsCOMPtr docShell(do_QueryInterface(container, &result)); + if (NS_SUCCEEDED(result) && docShell) { + PRInt32 docShellType; + result = docShell->GetItemType(&docShellType); + if (NS_SUCCEEDED(result)) { + isChrome = nsIDocShellTreeItem::typeChrome == docShellType; + } + } + } + return isChrome; +} + const nsStyleStruct* nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext) { @@ -1640,8 +1659,15 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte const nsFont* defaultFont; mPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, &defaultFont); nsStyleFont* fontData = new (mPresContext) nsStyleFont(*defaultFont); - fontData->mSize = fontData->mFont.size = - ZoomFont(mPresContext, fontData->mFont.size); + fontData->mSize = ZoomFont(mPresContext, fontData->mFont.size); + if (!IsChrome(mPresContext)) { + nscoord minimumFontSize = 0; + mPresContext->GetCachedIntPref(kPresContext_MinimumFontSize, minimumFontSize); + fontData->mFont.size = PR_MAX(fontData->mSize, minimumFontSize); + } + else { + fontData->mFont.size = fontData->mSize; + } aContext->SetStyle(eStyleStruct_Font, fontData); return fontData; } @@ -2216,18 +2242,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat // document fonts (overriding the useDocumentFonts flag), or to // determine if we have to override the minimum font-size constraint. if (!useDocumentFonts || minimumFontSize > 0) { - nsCOMPtr container; - nsresult result = mPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { - nsCOMPtr docShell(do_QueryInterface(container, &result)); - if (NS_SUCCEEDED(result) && docShell) { - PRInt32 docShellType; - result = docShell->GetItemType(&docShellType); - if (NS_SUCCEEDED(result)) { - chromeOverride = nsIDocShellTreeItem::typeChrome == docShellType; - } - } - } + chromeOverride = IsChrome(mPresContext); } // If we don't have to use document fonts, then we are only entitled