PRBool colorIsSet = aAttributes->GetAttribute(nsHTMLAtoms::color, colorValue) != NS_CONTENT_ATTR_NOT_THERE && colorValue.GetColorValue(color);
PRBool colorIsSet = colorValue && colorValue->GetColorValue(color);
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,                      nsRuleData* aData){  nsHTMLValue value;  PRBool noshade = PR_FALSE;  nsHTMLValue colorValue;  nscolor color;  PRBool colorIsSet = aAttributes->GetAttribute(nsHTMLAtoms::color, colorValue) !=                      NS_CONTENT_ATTR_NOT_THERE &&                      colorValue.GetColorValue(color);  if (aData->mSID == eStyleStruct_Position ||      aData->mSID == eStyleStruct_Border) {    if (colorIsSet) {      noshade = PR_TRUE;    } else {      noshade = !!aAttributes->GetAttr(nsHTMLAtoms::noshade);    }  }  if (aData->mSID == eStyleStruct_Margin) {    // align: enum    aAttributes->GetAttribute(nsHTMLAtoms::align, value);    if (eHTMLUnit_Enumerated == value.GetUnit()) {      // Map align attribute into auto side margins      nsCSSRect& margin = aData->mMarginData->mMargin;      switch (value.GetIntValue()) {      case NS_STYLE_TEXT_ALIGN_LEFT:        if (margin.mLeft.GetUnit() == eCSSUnit_Null)          margin.mLeft.SetFloatValue(0.0f, eCSSUnit_Pixel);        if (margin.mRight.GetUnit() == eCSSUnit_Null)          margin.mRight.SetAutoValue();        break;      case NS_STYLE_TEXT_ALIGN_RIGHT:        if (margin.mLeft.GetUnit() == eCSSUnit_Null)          margin.mLeft.SetAutoValue();        if (margin.mRight.GetUnit() == eCSSUnit_Null)          margin.mRight.SetFloatValue(0.0f, eCSSUnit_Pixel);        break;      case NS_STYLE_TEXT_ALIGN_CENTER:        if (margin.mLeft.GetUnit() == eCSSUnit_Null)          margin.mLeft.SetAutoValue();        if (margin.mRight.GetUnit() == eCSSUnit_Null)          margin.mRight.SetAutoValue();        break;      }    }  }  else if (aData->mSID == eStyleStruct_Position) {    // width: integer, percent    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());      }    }    if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {      // size: integer      if (noshade) {        // noshade case: size is set using the border        aData->mPositionData->mHeight.SetAutoValue();      } else {        // normal case        // the height includes the top and bottom borders that are initially 1px.        // for size=1, html.css has a special case rule that makes this work by        // removing all but the top border.        aAttributes->GetAttribute(nsHTMLAtoms::size, value);        if (value.GetUnit() == eHTMLUnit_Integer) {          aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);        } // else use default value from html.css      }    }  }  else if (aData->mSID == eStyleStruct_Border && noshade) { // if not noshade, border styles are dealt with by html.css    // size: integer    // if a size is set, use half of it per side, otherwise, use 1px per side    float sizePerSide;    PRBool allSides = PR_TRUE;    aAttributes->GetAttribute(nsHTMLAtoms::size, value);    if (value.GetUnit() == eHTMLUnit_Integer) {      sizePerSide = (float)value.GetIntValue() / 2.0f;      if (sizePerSide < 1.0f) {        // XXX When the pixel bug is fixed, all the special casing for        // subpixel borders should be removed.        // In the meantime, this makes http://www.microsoft.com/ look right.        sizePerSide = 1.0f;        allSides = PR_FALSE;      }    } else {      sizePerSide = 1.0f; // default to a 2px high line    }    nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;    if (borderWidth.mTop.GetUnit() == eCSSUnit_Null) {      borderWidth.mTop.SetFloatValue(sizePerSide, eCSSUnit_Pixel);    }    if (allSides) {      if (borderWidth.mRight.GetUnit() == eCSSUnit_Null) {        borderWidth.mRight.SetFloatValue(sizePerSide, eCSSUnit_Pixel);      }      if (borderWidth.mBottom.GetUnit() == eCSSUnit_Null) {        borderWidth.mBottom.SetFloatValue(sizePerSide, eCSSUnit_Pixel);      }      if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null) {        borderWidth.mLeft.SetFloatValue(sizePerSide, eCSSUnit_Pixel);      }    }    // if a color is set, set the border-style to 'solid' so that the    // 'color' property takes effect, otherwise, use '-moz-bg-solid'.    // (we got the color attribute earlier)    PRInt32 style = colorIsSet ? NS_STYLE_BORDER_STYLE_SOLID :                                 NS_STYLE_BORDER_STYLE_BG_SOLID;    nsCSSRect& borderStyle = aData->mMarginData->mBorderStyle;    if (borderStyle.mTop.GetUnit() == eCSSUnit_Null) {      borderStyle.mTop.SetIntValue(style, eCSSUnit_Enumerated);    }    if (allSides) {      if (borderStyle.mRight.GetUnit() == eCSSUnit_Null) {        borderStyle.mRight.SetIntValue(style, eCSSUnit_Enumerated);      }      if (borderStyle.mBottom.GetUnit() == eCSSUnit_Null) {        borderStyle.mBottom.SetIntValue(style, eCSSUnit_Enumerated);      }      if (borderStyle.mLeft.GetUnit() == eCSSUnit_Null) {        borderStyle.mLeft.SetIntValue(style, eCSSUnit_Enumerated);      }      // If it would be noticeable, set the border radius to      // 100% on all corners      nsCSSRect& borderRadius = aData->mMarginData->mBorderRadius;      if (borderRadius.mTop.GetUnit() == eCSSUnit_Null) {        borderRadius.mTop.SetPercentValue(1.0f);      }      if (borderRadius.mRight.GetUnit() == eCSSUnit_Null) {        borderRadius.mRight.SetPercentValue(1.0f);      }      if (borderRadius.mBottom.GetUnit() == eCSSUnit_Null) {        borderRadius.mBottom.SetPercentValue(1.0f);      }      if (borderRadius.mLeft.GetUnit() == eCSSUnit_Null) {        borderRadius.mLeft.SetPercentValue(1.0f);      }    }  }  else if (aData->mSID == eStyleStruct_Color) {    // color: a color    // (we got the color attribute earlier)    if (colorIsSet &&        aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {      aData->mColorData->mColor.SetColorValue(color);    }  }  nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);}