nsHTMLValue value; aAttributes->GetAttribute(nsHTMLAtoms::border, value); if (((value.GetUnit() == eHTMLUnit_Pixel) && (value.GetPixelValue() > 0)) || (value.GetUnit() == eHTMLUnit_Empty)) { if (aData->mMarginData->mBorderWidth->mLeft.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mLeft.SetFloatValue(1.0f, eCSSUnit_Pixel); if (aData->mMarginData->mBorderWidth->mRight.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mRight.SetFloatValue(1.0f, eCSSUnit_Pixel); if (aData->mMarginData->mBorderWidth->mTop.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mTop.SetFloatValue(1.0f, eCSSUnit_Pixel); if (aData->mMarginData->mBorderWidth->mBottom.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mBottom.SetFloatValue(1.0f, eCSSUnit_Pixel);  PRUint8 borderStyle = (eCompatibility_NavQuirks == mode) ? NS_STYLE_BORDER_STYLE_BG_INSET : NS_STYLE_BORDER_STYLE_INSET;
if (NS_STYLE_BORDER_SEPARATE == tableStyle->mBorderCollapse) {   nsHTMLValue value; aAttributes->GetAttribute(nsHTMLAtoms::border, value); if (((value.GetUnit() == eHTMLUnit_Pixel) && (value.GetPixelValue() > 0)) || (value.GetUnit() == eHTMLUnit_Empty)) { if (aData->mMarginData->mBorderWidth->mLeft.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mLeft.SetFloatValue(1.0f, eCSSUnit_Pixel); if (aData->mMarginData->mBorderWidth->mRight.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mRight.SetFloatValue(1.0f, eCSSUnit_Pixel); if (aData->mMarginData->mBorderWidth->mTop.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mTop.SetFloatValue(1.0f, eCSSUnit_Pixel); if (aData->mMarginData->mBorderWidth->mBottom.GetUnit() == eCSSUnit_Null) aData->mMarginData->mBorderWidth->mBottom.SetFloatValue(1.0f, eCSSUnit_Pixel);  PRUint8 borderStyle = (eCompatibility_NavQuirks == mode) ? NS_STYLE_BORDER_STYLE_BG_INSET : NS_STYLE_BORDER_STYLE_INSET;
MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes,                      nsRuleData* aData){  if (!aData)    return;  if (!aAttributes)    return;  nsCompatibility mode;  aData->mPresContext->GetCompatibilityMode(&mode);  if (aData->mSID == eStyleStruct_TableBorder && aData->mTableData) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);    if (readDisplay && readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {      // cellspacing       nsHTMLValue value;      aAttributes->GetAttribute(nsHTMLAtoms::cellspacing, value);      if (value.GetUnit() == eHTMLUnit_Pixel) {        if (aData->mTableData->mBorderSpacingX.GetUnit() == eCSSUnit_Null)          aData->mTableData->mBorderSpacingX.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);        if (aData->mTableData->mBorderSpacingY.GetUnit() == eCSSUnit_Null)          aData->mTableData->mBorderSpacingY.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);      }      else if ((value.GetUnit() == eHTMLUnit_Percent) && (eCompatibility_NavQuirks == mode)) {        // in quirks mode, treat a % cellspacing value a pixel value.        if (aData->mTableData->mBorderSpacingX.GetUnit() == eCSSUnit_Null)          aData->mTableData->mBorderSpacingX.SetFloatValue(100.0f * value.GetPercentValue(), eCSSUnit_Pixel);        if (aData->mTableData->mBorderSpacingY.GetUnit() == eCSSUnit_Null)          aData->mTableData->mBorderSpacingY.SetFloatValue(100.0f * value.GetPercentValue(), eCSSUnit_Pixel);      }    }  }  if (aData->mSID == eStyleStruct_Table && aData->mTableData) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);    if (readDisplay && readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {      MapTableBorderInto(aAttributes, aData, 0);      nsHTMLValue value;      // layout      if (aData->mTableData->mLayout.GetUnit() == eCSSUnit_Null) {        aAttributes->GetAttribute(nsHTMLAtoms::layout, value);        if (value.GetUnit() == eHTMLUnit_Enumerated)          aData->mTableData->mLayout.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);      }            // cols      aAttributes->GetAttribute(nsHTMLAtoms::cols, value);      if (value.GetUnit() != eHTMLUnit_Null) {        if (value.GetUnit() == eHTMLUnit_Integer)           aData->mTableData->mCols.SetIntValue(value.GetIntValue(), eCSSUnit_Integer);        else // COLS had no value, so it refers to all columns          aData->mTableData->mCols.SetIntValue(NS_STYLE_TABLE_COLS_ALL, eCSSUnit_Enumerated);      }      // rules      aAttributes->GetAttribute(nsHTMLAtoms::rules, value);      if (value.GetUnit() == eHTMLUnit_Enumerated)        aData->mTableData->mRules.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);    }  }  else if (aData->mSID == eStyleStruct_Margin && aData->mMarginData) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);      if (readDisplay && readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {      // align; Check for enumerated type (it may be another type if      // illegal)      nsHTMLValue value;      aAttributes->GetAttribute(nsHTMLAtoms::align, value);      if (value.GetUnit() == eHTMLUnit_Enumerated) {        if ((NS_STYLE_TEXT_ALIGN_CENTER == value.GetIntValue()) ||            (NS_STYLE_TEXT_ALIGN_MOZ_CENTER == value.GetIntValue())) {          nsCSSRect* margin = aData->mMarginData->mMargin;          if (margin->mLeft.GetUnit() == eCSSUnit_Null)            margin->mLeft.SetAutoValue();          if (margin->mRight.GetUnit() == eCSSUnit_Null)            margin->mRight.SetAutoValue();        }      }      // hspace is mapped into left and right margin,       // vspace is mapped into top and bottom margins      // - *** Quirks Mode only ***      if (eCompatibility_NavQuirks == mode) {        aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);        if (value.GetUnit() == eHTMLUnit_Pixel) {          nsCSSRect* margin = aData->mMarginData->mMargin;          if (margin->mLeft.GetUnit() == eCSSUnit_Null)            margin->mLeft.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);           if (margin->mRight.GetUnit() == eCSSUnit_Null)            margin->mRight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);        }        aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);        if (value.GetUnit() == eHTMLUnit_Pixel) {          nsCSSRect* margin = aData->mMarginData->mMargin;          if (margin->mTop.GetUnit() == eCSSUnit_Null)            margin->mTop.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);           if (margin->mBottom.GetUnit() == eCSSUnit_Null)            margin->mBottom.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);         }      }    }  }  else if (aData->mSID == eStyleStruct_Padding && aData->mMarginData) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);      if (readDisplay &&        (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL)) {      nsHTMLValue value;      aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value);      if (value.GetUnit() == eHTMLUnit_Pixel || value.GetUnit() == eHTMLUnit_Percent) {        // We have cellpadding.  This will override our padding values if we don't        // have any set.        nsCSSValue padVal;        if (value.GetUnit() == eHTMLUnit_Pixel)          padVal.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);        else {          // when we support % cellpadding in standard mode, uncomment the following          float pctVal = value.GetPercentValue();          //if (eCompatibility_NavQuirks == mode) {            // in quirks mode treat a pct cellpadding value as a pixel value            padVal.SetFloatValue(100.0f * pctVal, eCSSUnit_Pixel);          //}          //else {          //  padVal.SetPercentValue(pctVal);          //}        }        if (aData->mMarginData->mPadding->mLeft.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mPadding->mLeft = padVal;        if (aData->mMarginData->mPadding->mRight.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mPadding->mRight = padVal;        if (aData->mMarginData->mPadding->mTop.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mPadding->mTop = padVal;        if (aData->mMarginData->mPadding->mBottom.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mPadding->mBottom = padVal;      }    }  }  else if (aData->mPositionData) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);      if (readDisplay &&        (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL)) {      nsHTMLValue value;      // width: value      if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {        aAttributes->GetAttribute(nsHTMLAtoms::width, value);        if (value.GetUnit() == eHTMLUnit_Pixel)           aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);        else if (value.GetUnit() == eHTMLUnit_Percent)          aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());      }      // height: value      if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {        aAttributes->GetAttribute(nsHTMLAtoms::height, value);        if (value.GetUnit() == eHTMLUnit_Pixel)           aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);        else if (value.GetUnit() == eHTMLUnit_Percent)          aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());       }    }  }  else if (aData->mSID == eStyleStruct_Visibility) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);      if (readDisplay &&        (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL))      nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);  }  else if (aData->mSID == eStyleStruct_Border && aData->mMarginData) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);      if (readDisplay &&        (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL)) {      // set the cell's border from the table      nsHTMLValue value;      aAttributes->GetAttribute(nsHTMLAtoms::border, value);      if (((value.GetUnit() == eHTMLUnit_Pixel) &&           (value.GetPixelValue() > 0)) ||          (value.GetUnit() == eHTMLUnit_Empty)) {        if (aData->mMarginData->mBorderWidth->mLeft.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderWidth->mLeft.SetFloatValue(1.0f, eCSSUnit_Pixel);        if (aData->mMarginData->mBorderWidth->mRight.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderWidth->mRight.SetFloatValue(1.0f, eCSSUnit_Pixel);        if (aData->mMarginData->mBorderWidth->mTop.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderWidth->mTop.SetFloatValue(1.0f, eCSSUnit_Pixel);        if (aData->mMarginData->mBorderWidth->mBottom.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderWidth->mBottom.SetFloatValue(1.0f, eCSSUnit_Pixel);        PRUint8 borderStyle = (eCompatibility_NavQuirks == mode)                               ? NS_STYLE_BORDER_STYLE_BG_INSET : NS_STYLE_BORDER_STYLE_INSET;          // BG_INSET results in a border color based on background colors          // used for NavQuirks only...        if (aData->mMarginData->mBorderStyle->mLeft.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderStyle->mLeft.SetIntValue(borderStyle, eCSSUnit_Enumerated);        if (aData->mMarginData->mBorderStyle->mRight.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderStyle->mRight.SetIntValue(borderStyle, eCSSUnit_Enumerated);        if (aData->mMarginData->mBorderStyle->mTop.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderStyle->mTop.SetIntValue(borderStyle, eCSSUnit_Enumerated);        if (aData->mMarginData->mBorderStyle->mBottom.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderStyle->mBottom.SetIntValue(borderStyle, eCSSUnit_Enumerated);      }    }    else {      // default border style is the Nav4.6 extension which uses the      // background color as the basis of the outset border. If the      // table has a transparent background then it finds the closest      // ancestor that has a non-transparent      // background. NS_STYLE_BORDER_OUTSET uses the border color of      // the table and if that is not set, then it uses the color.      PRUint8 borderStyle = (eCompatibility_NavQuirks == mode)                             ? NS_STYLE_BORDER_STYLE_BG_OUTSET :                              NS_STYLE_BORDER_STYLE_OUTSET;      // bordercolor      nsHTMLValue value;      aAttributes->GetAttribute(nsHTMLAtoms::bordercolor, value);      if ((eHTMLUnit_Color == value.GetUnit()) ||          (eHTMLUnit_ColorName == value.GetUnit())) {        nscolor color = value.GetColorValue();        if (aData->mMarginData->mBorderColor->mLeft.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderColor->mLeft.SetColorValue(color);        if (aData->mMarginData->mBorderColor->mRight.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderColor->mRight.SetColorValue(color);        if (aData->mMarginData->mBorderColor->mTop.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderColor->mTop.SetColorValue(color);        if (aData->mMarginData->mBorderColor->mBottom.GetUnit() == eCSSUnit_Null)          aData->mMarginData->mBorderColor->mBottom.SetColorValue(color);        borderStyle = NS_STYLE_BORDER_STYLE_OUTSET; // use css outset      }      // border and frame      MapTableBorderInto(aAttributes, aData, borderStyle);    }  }  if (aData->mSID == eStyleStruct_Background) {    const nsStyleDisplay* readDisplay = (nsStyleDisplay*)                  aData->mStyleContext->GetStyleData(eStyleStruct_Display);      if (readDisplay &&        (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL))      nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);  }}