aAttributes->GetAttribute(nsHTMLAtoms::height, value); if (value.GetUnit() == eHTMLUnit_Integer) aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel); else if (value.GetUnit() == eHTMLUnit_Percent) aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height); if (value && value->Type() == nsAttrValue::eInteger) aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); else if (value && value->Type() == nsAttrValue::ePercent) aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,                      nsRuleData* aData){  // XXX Bug 211636:  This function is used by a single style rule  // that's used to match two different type of elements -- tables, and  // table cells.  (nsHTMLTableCellElement overrides  // WalkContentStyleRules so that this happens.)  This violates the  // nsIStyleRule contract, since it's the same style rule object doing  // the mapping in two different ways.  It's also incorrect since it's  // testing the display type of the style context rather than checking  // which *element* it's matching (style rules should not stop matching  // when the display type is changed).  nsCompatibility mode = aData->mPresContext->CompatibilityMode();  if (aData->mSID == eStyleStruct_TableBorder) {    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();    if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {      // cellspacing       nsHTMLValue value;      aAttributes->GetAttribute(nsHTMLAtoms::cellspacing, value);      if (value.GetUnit() == eHTMLUnit_Integer) {        if (aData->mTableData->mBorderSpacingX.GetUnit() == eCSSUnit_Null)          aData->mTableData->mBorderSpacingX.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);        if (aData->mTableData->mBorderSpacingY.GetUnit() == eCSSUnit_Null)          aData->mTableData->mBorderSpacingY.SetFloatValue((float)value.GetIntValue(), 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);      }    }  }   else if (aData->mSID == eStyleStruct_Table) {    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();    if (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      if (aAttributes->GetAttribute(nsHTMLAtoms::cols, value) !=          NS_CONTENT_ATTR_NOT_THERE) {        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) {    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();      if (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_Integer) {          nsCSSRect& margin = aData->mMarginData->mMargin;          if (margin.mLeft.GetUnit() == eCSSUnit_Null)            margin.mLeft.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);           if (margin.mRight.GetUnit() == eCSSUnit_Null)            margin.mRight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);        }        aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);        if (value.GetUnit() == eHTMLUnit_Integer) {          nsCSSRect& margin = aData->mMarginData->mMargin;          if (margin.mTop.GetUnit() == eCSSUnit_Null)            margin.mTop.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);           if (margin.mBottom.GetUnit() == eCSSUnit_Null)            margin.mBottom.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);         }      }    }  }  else if (aData->mSID == eStyleStruct_Padding) {    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();      if (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {      nsHTMLValue value;      aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value);      if (value.GetUnit() == eHTMLUnit_Integer || 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_Integer)          padVal.SetFloatValue((float)value.GetIntValue(), 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->mSID == eStyleStruct_Position) {    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();      if (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_Integer)           aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), 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_Integer)           aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);        else if (value.GetUnit() == eHTMLUnit_Percent)          aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());       }    }  }  else if (aData->mSID == eStyleStruct_Visibility) {    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();      if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL)      nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);  }  else if (aData->mSID == eStyleStruct_Border) {    if (!aData->mStyleContext) return;    const nsStyleTableBorder* tableStyle = aData->mStyleContext->GetStyleTableBorder();    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();    if (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {      if (NS_STYLE_BORDER_SEPARATE == tableStyle->mBorderCollapse) {        // Set the cell's border from the table in the separate border model. If there is a border        // on the table, then the mapping to rules=all will take care of borders in the collapsing model.        nsHTMLValue value;        if (aAttributes->GetAttribute(nsHTMLAtoms::border, value) !=            NS_CONTENT_ATTR_NOT_THERE &&            ((value.GetUnit() == eHTMLUnit_Integer &&              value.GetIntValue() > 0) ||             value.IsEmptyString())) {          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;      nscolor color;      if (aAttributes->GetAttribute(nsHTMLAtoms::bordercolor, value) !=          NS_CONTENT_ATTR_NOT_THERE &&          value.GetColorValue(color)) {        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      }      else if (NS_STYLE_BORDER_COLLAPSE == tableStyle->mBorderCollapse) {        // make the color grey        nscolor color = NS_RGB(80, 80, 80);        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);      }      // border and frame      MapTableBorderInto(aAttributes, aData, borderStyle);    }  }  else if (aData->mSID == eStyleStruct_Background) {    const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();      if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL)      nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);  }}