hack->margin.right = (nscoord)ourMargin->mMargin->mRight.GetFloatValue();
spacing->mMargin.right = (nscoord)ourMargin->mMargin->mRight.GetFloatValue();
void CSSStyleRuleImpl::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext){  if (nsnull != mDeclaration) {    nsStyleFont*  font = (nsStyleFont*)aContext->GetData(kStyleFontSID);    nsCSSFont*  ourFont;    if (NS_OK == mDeclaration->GetData(kCSSFontSID, (nsCSSStruct**)&ourFont)) {      if (nsnull != ourFont) {        nsStyleFont* parentFont = font;        nsIStyleContext* parentContext = aContext->GetParent();        if (nsnull != parentContext) {          parentFont = (nsStyleFont*)parentContext->GetData(kStyleFontSID);        }        // font-family: string list        if (ourFont->mFamily.GetUnit() == eCSSUnit_String) {          nsAutoString familyList;          ourFont->mFamily.GetStringValue(familyList);          // XXX meeds font support to determine usable fonts          // parse up the CSS string & remove the quotes          // XXX only does first until we can tell what are installed fonts          nsAutoString family;          PRInt32 index = familyList.Find(PRUnichar(','));          if (-1 < index) {            familyList.Left(family, index);          }          else {            family.Append(familyList);          }          family.StripChars("\"");          family.StripWhitespace();          font->mFont.name = family;        }        // font-style: enum        if (ourFont->mStyle.GetUnit() == eCSSUnit_Enumerated) {          font->mFont.style = ourFont->mStyle.GetIntValue();        }        // font-variant: enum        if (ourFont->mVariant.GetUnit() == eCSSUnit_Enumerated) {          font->mFont.variant = ourFont->mVariant.GetIntValue();        }        // font-weight: abs, enum        if (ourFont->mWeight.GetUnit() == eCSSUnit_Absolute) {          font->mFont.style = ourFont->mWeight.GetIntValue();        }        else if (ourFont->mWeight.GetUnit() == eCSSUnit_Enumerated) {          PRInt32 value = ourFont->mWeight.GetIntValue();          switch (value) {            case NS_STYLE_FONT_WEIGHT_NORMAL:            case NS_STYLE_FONT_WEIGHT_BOLD:              font->mFont.weight = value;              break;            case NS_STYLE_FONT_WEIGHT_BOLDER:            case NS_STYLE_FONT_WEIGHT_LIGHTER:              font->mFont.weight = (parentFont->mFont.weight + value);              break;          }        }        // font-size: enum, length, percent        if (ourFont->mSize.GetUnit() == eCSSUnit_Enumerated) {          static float kFontScale[7] = {            0.5f,                 // xx-small            0.666667f,            // x-small            0.833333f,            // small            1.0f,                 // medium            1.5f,                 // large            1.5f * 1.5f,          // x-large            1.5f * 1.5f * 1.5f,   // xx-large          };          PRInt32 value = ourFont->mSize.GetIntValue();          const nsFont& normal = aPresContext->GetDefaultFont();  // use normal font or body font??          if ((NS_STYLE_FONT_SIZE_XXSMALL <= value) &&               (value <= NS_STYLE_FONT_SIZE_XXLARGE)) {            font->mFont.size = (nscoord)((float)normal.size * kFontScale[value]);          }          else if (NS_STYLE_FONT_SIZE_LARGER == value) {            PRInt32 index;            for (index = NS_STYLE_FONT_SIZE_XXSMALL;                 index < NS_STYLE_FONT_SIZE_XXLARGE; index++)              if (parentFont->mFont.size < (nscoord)((float)normal.size * kFontScale[index]))                break;            font->mFont.size = (nscoord)((float)normal.size * kFontScale[index]);          }          else if (NS_STYLE_FONT_SIZE_SMALLER == value) {            PRInt32 index;            for (index = NS_STYLE_FONT_SIZE_XXLARGE;                 index > NS_STYLE_FONT_SIZE_XXSMALL; index--)              if (parentFont->mFont.size > (nscoord)((float)normal.size * kFontScale[index]))                break;            font->mFont.size = (nscoord)((float)normal.size * kFontScale[index]);          }        }        else if (ourFont->mSize.IsLengthUnit()) {          font->mFont.size = CalcLength(ourFont->mSize, parentFont, aPresContext);        }        else if (ourFont->mSize.GetUnit() == eCSSUnit_Percent) {          font->mFont.size = (nscoord)((float)(parentFont->mFont.size) * ourFont->mSize.GetFloatValue());        }        NS_IF_RELEASE(parentContext);      }    }    nsCSSText*  ourText;    if (NS_OK == mDeclaration->GetData(kCSSTextSID, (nsCSSStruct**)&ourText)) {      if (nsnull != ourText) {        // text-decoration: enum, absolute (bit field)        if (ourText->mDecoration.GetUnit() == eCSSUnit_Enumerated) {          font->mFont.decorations = ourText->mDecoration.GetIntValue();        }        else if (ourText->mDecoration.GetUnit() == eCSSUnit_Absolute) {          font->mFont.decorations = ourText->mDecoration.GetIntValue();        }      }    }    nsCSSColor*  ourColor;    if (NS_OK == mDeclaration->GetData(kCSSColorSID, (nsCSSStruct**)&ourColor)) {      if (nsnull != ourColor) {        nsStyleColor* color = (nsStyleColor*)aContext->GetData(kStyleColorSID);        // color: color        if (ourColor->mColor.GetUnit() == eCSSUnit_Color) {          color->mColor = ourColor->mColor.GetColorValue();        }        // background-color: color, enum (flags)        if (ourColor->mBackColor.GetUnit() == eCSSUnit_Color) {          color->mBackgroundColor = ourColor->mBackColor.GetColorValue();          color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;        }        else if (ourColor->mBackColor.GetUnit() == eCSSUnit_Enumerated) {          color->mBackgroundFlags |= NS_STYLE_BG_COLOR_TRANSPARENT;        }        // background-image: string, enum (flags)        if (ourColor->mBackImage.GetUnit() == eCSSUnit_String) {          ourColor->mBackImage.GetStringValue(color->mBackgroundImage);          color->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE;        }        else if (ourColor->mBackImage.GetUnit() == eCSSUnit_Enumerated) {          color->mBackgroundFlags |= NS_STYLE_BG_IMAGE_NONE;        }        // background-repeat: enum        if (ourColor->mBackRepeat.GetUnit() == eCSSUnit_Enumerated) {          color->mBackgroundRepeat = ourColor->mBackRepeat.GetIntValue();        }        // background-attachment: enum        if (ourColor->mBackAttachment.GetUnit() == eCSSUnit_Enumerated) {          color->mBackgroundAttachment = ourColor->mBackAttachment.GetIntValue();        }        // background-position: length, percent (flags)        if (ourColor->mBackPositionX.GetUnit() == eCSSUnit_Percent) {          color->mBackgroundXPosition = (nscoord)(TWIPS_CONST_FLOAT * ourColor->mBackPositionX.GetFloatValue());          color->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PCT;          color->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;        }        else if (ourColor->mBackPositionX.IsLengthUnit()) {          color->mBackgroundXPosition = CalcLength(ourColor->mBackPositionX,                                                   font, aPresContext);          color->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_LENGTH;          color->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_PCT;        }        if (ourColor->mBackPositionY.GetUnit() == eCSSUnit_Percent) {          color->mBackgroundYPosition = (nscoord)(TWIPS_CONST_FLOAT * ourColor->mBackPositionY.GetFloatValue());          color->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PCT;          color->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;        }        else if (ourColor->mBackPositionY.IsLengthUnit()) {          color->mBackgroundYPosition = CalcLength(ourColor->mBackPositionY,                                                   font, aPresContext);          color->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_LENGTH;          color->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_PCT;        }  // XXX: NYI        nsCSSValue mBackFilter;      }    }    nsCSSMargin*  ourMargin;    if (NS_OK == mDeclaration->GetData(kCSSMarginSID, (nsCSSStruct**)&ourMargin)) {      if (nsnull != ourMargin) {        nsStyleMolecule* hack = (nsStyleMolecule*)aContext->GetData(kStyleMoleculeSID);        // margin        if (nsnull != ourMargin->mMargin) {          if (ourMargin->mMargin->mLeft.IsLengthUnit()) {            hack->margin.left = CalcLength(ourMargin->mMargin->mLeft, font, aPresContext);          } else if (ourMargin->mMargin->mLeft.GetUnit() != eCSSUnit_Null) {            hack->margin.left = (nscoord)ourMargin->mMargin->mLeft.GetFloatValue();          }          if (ourMargin->mMargin->mTop.IsLengthUnit()) {            hack->margin.top = CalcLength(ourMargin->mMargin->mTop, font, aPresContext);          } else if (ourMargin->mMargin->mTop.GetUnit() != eCSSUnit_Null) {            hack->margin.top = (nscoord)ourMargin->mMargin->mTop.GetFloatValue();          }          if (ourMargin->mMargin->mRight.IsLengthUnit()) {            hack->margin.right = CalcLength(ourMargin->mMargin->mRight, font, aPresContext);          } else if (ourMargin->mMargin->mRight.GetUnit() != eCSSUnit_Null) {            hack->margin.right = (nscoord)ourMargin->mMargin->mRight.GetFloatValue();          }          if (ourMargin->mMargin->mBottom.IsLengthUnit()) {            hack->margin.bottom = CalcLength(ourMargin->mMargin->mBottom, font, aPresContext);          } else if (ourMargin->mMargin->mBottom.GetUnit() != eCSSUnit_Null) {            hack->margin.bottom = (nscoord)ourMargin->mMargin->mBottom.GetFloatValue();          }        }      }    }    nsCSSList* ourList;    if (NS_OK == mDeclaration->GetData(kCSSListSID, (nsCSSStruct**)&ourList)) {      if (nsnull != ourList) {        nsStyleList* list = (nsStyleList*)aContext->GetData(kStyleListSID);        // list-style-type: enum        if (ourList->mType.GetUnit() == eCSSUnit_Enumerated) {          list->mListStyleType = ourList->mType.GetIntValue();        }        // list-style-image: string        if (ourList->mImage.GetUnit() == eCSSUnit_String) {          ourList->mImage.GetStringValue(list->mListStyleImage);        }        else if (ourList->mImage.GetUnit() == eCSSUnit_Enumerated) {  // handle "none"          list->mListStyleImage = "";        }        // list-style-position: enum        if (ourList->mPosition.GetUnit() == eCSSUnit_Enumerated) {          list->mListStyleType = ourList->mPosition.GetIntValue();        }      }    }  }}