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:
@@ -845,7 +845,31 @@ nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame,
|
|||||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||||
|
|
||||||
if(font) {
|
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 {
|
else {
|
||||||
val->SetString("");
|
val->SetString("");
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
mType = CSS_STRING;
|
mType = CSS_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetString(const nsString& aString)
|
void SetString(const nsAString& aString)
|
||||||
{
|
{
|
||||||
mString.Assign(aString);
|
mString.Assign(aString);
|
||||||
mType = CSS_STRING;
|
mType = CSS_STRING;
|
||||||
|
|||||||
@@ -845,7 +845,31 @@ nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame,
|
|||||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||||
|
|
||||||
if(font) {
|
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 {
|
else {
|
||||||
val->SetString("");
|
val->SetString("");
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
mType = CSS_STRING;
|
mType = CSS_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetString(const nsString& aString)
|
void SetString(const nsAString& aString)
|
||||||
{
|
{
|
||||||
mString.Assign(aString);
|
mString.Assign(aString);
|
||||||
mType = CSS_STRING;
|
mType = CSS_STRING;
|
||||||
|
|||||||
Reference in New Issue
Block a user