if (font) { nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShellWeak); NS_ASSERTION(presShell, "pres shell is required"); nsPresContext *presContext = presShell->GetPresContext(); NS_ASSERTION(presContext, "pres context is required");  const nsString& fontName = font->mFont.name; PRUint8 generic = font->mFlags & NS_STYLE_FONT_FACE_MASK; if (generic == kGenericFont_NONE && !font->mFont.systemFont) { const nsFont* defaultFont = presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID);  PRInt32 lendiff = fontName.Length() - defaultFont->name.Length(); if (lendiff > 0) { val->SetString(Substring(fontName, 0, lendiff-1)); } else { val->SetString(fontName); } } else { val->SetString(fontName); }
if(font) { val->SetString(font->mFont.name); } else { val->SetString("");
nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame,                                  nsIDOMCSSValue** aValue){  nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();  NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);  const nsStyleFont* font = nsnull;  GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);  if (font) {    nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShellWeak);    NS_ASSERTION(presShell, "pres shell is required");    nsPresContext *presContext = presShell->GetPresContext();    NS_ASSERTION(presContext, "pres context is required");    const nsString& fontName = font->mFont.name;    PRUint8 generic = font->mFlags & NS_STYLE_FONT_FACE_MASK;    if (generic == kGenericFont_NONE && !font->mFont.systemFont) {       const nsFont* defaultFont =        presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID);      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(fontName);    }  }  return CallQueryInterface(val, aValue);}