Make getComputedStyle remove the extra default font that we add to the end of the font-family list so it returns the original computed value. b=94078 r=hyatt sr=jst

This commit is contained in:
dbaron%fas.harvard.edu 2001-09-07 02:28:10 +00:00
parent 0c252bde5d
commit 06944cc30e
4 changed files with 52 additions and 4 deletions

View File

@ -845,7 +845,31 @@ nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame,
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
if(font) {
val->SetString(font->mFont.name);
nsCOMPtr<nsIPresShell> presShell=do_QueryReferent(mPresShellWeak);
NS_ASSERTION(presShell, "pres shell is required");
nsCOMPtr<nsIPresContext> presContext;
presShell->GetPresContext(getter_AddRefs(presContext));
NS_ASSERTION(presContext, "pres context is required");
if (font->mFlags & NS_STYLE_FONT_USE_FIXED) {
const nsString& fontName = font->mFixedFont.name;
const nsFont& defaultFont = presContext->GetDefaultFixedFontDeprecated();
PRInt32 lendiff = fontName.Length() - defaultFont.name.Length();
if (lendiff > 0) {
val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma
} else {
val->SetString(fontName);
}
} else {
const nsString& fontName = font->mFont.name;
const nsFont& defaultFont = presContext->GetDefaultFontDeprecated();
PRInt32 lendiff = fontName.Length() - defaultFont.name.Length();
if (lendiff > 0) {
val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma
} else {
val->SetString(fontName);
}
}
}
else {
val->SetString("");

View File

@ -58,7 +58,7 @@ public:
mType = CSS_STRING;
}
void SetString(const nsString& aString)
void SetString(const nsAString& aString)
{
mString.Assign(aString);
mType = CSS_STRING;

View File

@ -845,7 +845,31 @@ nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame,
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
if(font) {
val->SetString(font->mFont.name);
nsCOMPtr<nsIPresShell> presShell=do_QueryReferent(mPresShellWeak);
NS_ASSERTION(presShell, "pres shell is required");
nsCOMPtr<nsIPresContext> presContext;
presShell->GetPresContext(getter_AddRefs(presContext));
NS_ASSERTION(presContext, "pres context is required");
if (font->mFlags & NS_STYLE_FONT_USE_FIXED) {
const nsString& fontName = font->mFixedFont.name;
const nsFont& defaultFont = presContext->GetDefaultFixedFontDeprecated();
PRInt32 lendiff = fontName.Length() - defaultFont.name.Length();
if (lendiff > 0) {
val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma
} else {
val->SetString(fontName);
}
} else {
const nsString& fontName = font->mFont.name;
const nsFont& defaultFont = presContext->GetDefaultFontDeprecated();
PRInt32 lendiff = fontName.Length() - defaultFont.name.Length();
if (lendiff > 0) {
val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma
} else {
val->SetString(fontName);
}
}
}
else {
val->SetString("");

View File

@ -58,7 +58,7 @@ public:
mType = CSS_STRING;
}
void SetString(const nsString& aString)
void SetString(const nsAString& aString)
{
mString.Assign(aString);
mType = CSS_STRING;