weight = ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);
weight = nsStyleUtil::ConstrainFontWeight((weight / 100) * 100);
MapFontAttributesInto(const nsIHTMLMappedAttributes* aAttributes,                      nsIStyleContext* aContext,                      nsIPresContext* aPresContext){  if (nsnull != aAttributes) {    nsHTMLValue value;    nsStyleFont* font = (nsStyleFont*)      aContext->GetMutableStyleData(eStyleStruct_Font);    const nsStyleFont* parentFont = font;    nsIStyleContext* parentContext = aContext->GetParent();    if (nsnull != parentContext) {      parentFont = (const nsStyleFont*)        parentContext->GetStyleData(eStyleStruct_Font);    }    const nsFont& defaultFont = aPresContext->GetDefaultFontDeprecated();     const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFontDeprecated();     // face: string list    aAttributes->GetAttribute(nsHTMLAtoms::face, value);    if (value.GetUnit() == eHTMLUnit_String) {      nsCOMPtr<nsIDeviceContext> dc;      aPresContext->GetDeviceContext(getter_AddRefs(dc));      if (dc) {        nsAutoString  familyList;        value.GetStringValue(familyList);                  font->mFont.name = familyList;        nsAutoString face;        if (NS_OK == dc->FirstExistingFont(font->mFont, face)) {          if (face.EqualsIgnoreCase("-moz-fixed")) {            font->mFlags |= NS_STYLE_FONT_USE_FIXED;          }          else {            font->mFixedFont.name = familyList;          }        }        else {          font->mFont.name = defaultFont.name;          font->mFixedFont.name= defaultFixedFont.name;        }        font->mFlags |= NS_STYLE_FONT_FACE_EXPLICIT;      }    }    // pointSize: int, enum    aAttributes->GetAttribute(nsHTMLAtoms::pointSize, value);    if (value.GetUnit() == eHTMLUnit_Integer) {      // XXX should probably sanitize value      font->mFont.size = parentFont->mFont.size +        NSIntPointsToTwips(value.GetIntValue());      font->mFixedFont.size = parentFont->mFixedFont.size +        NSIntPointsToTwips(value.GetIntValue());      font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;    }    else if (value.GetUnit() == eHTMLUnit_Enumerated) {      font->mFont.size = NSIntPointsToTwips(value.GetIntValue());      font->mFixedFont.size = NSIntPointsToTwips(value.GetIntValue());      font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;    }    else {      // size: int, enum , NOTE: this does not count as an explicit size      // also this has no effect if font is already explicit (quirk mode)      nsCompatibility mode;      aPresContext->GetCompatibilityMode(&mode);      if ((eCompatibility_Standard == mode) ||           (0 == (font->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT))) {        aAttributes->GetAttribute(nsHTMLAtoms::size, value);        if ((value.GetUnit() == eHTMLUnit_Integer) ||            (value.GetUnit() == eHTMLUnit_Enumerated)) {           PRInt32 size = value.GetIntValue();                  if (value.GetUnit() == eHTMLUnit_Integer) { // int (+/-)            size = 3 + size;  // XXX should be BASEFONT, not three          }          size = ((0 < size) ? ((size < 8) ? size : 7) : 1);           PRInt32 scaler;          aPresContext->GetFontScaler(&scaler);          float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);          font->mFont.size =            nsStyleUtil::CalcFontPointSize(size, (PRInt32)defaultFont.size,                                           scaleFactor);          font->mFixedFont.size =            nsStyleUtil::CalcFontPointSize(size,                                           (PRInt32)defaultFixedFont.size,                                           scaleFactor);        }      }    }    // fontWeight: int, enum    aAttributes->GetAttribute(nsHTMLAtoms::fontWeight, value);    if (value.GetUnit() == eHTMLUnit_Integer) { // +/-      PRInt32 weight = parentFont->mFont.weight + value.GetIntValue();      font->mFont.weight =        ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);      font->mFixedFont.weight =        ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);    }    else if (value.GetUnit() == eHTMLUnit_Enumerated) {      PRInt32 weight = value.GetIntValue();      weight = ((100 < weight) ? ((weight < 700) ? weight : 700) : 100);      font->mFont.weight = weight;      font->mFixedFont.weight = weight;    }    NS_IF_RELEASE(parentContext);  }}