else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {
else if (eCSSUnit_Enumerated == ourBorderColor->mLeft.GetUnit()) {
MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,                          nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,                         nsStyleFont* aFont, nsIPresContext* aPresContext){  nsCSSMargin*  ourMargin;  if (NS_OK == aDeclaration->GetData(kCSSMarginSID, (nsCSSStruct**)&ourMargin)) {    if (nsnull != ourMargin) {      nsStyleMargin* margin = (nsStyleMargin*)aContext->GetMutableStyleData(eStyleStruct_Margin);      nsStylePadding* padding = (nsStylePadding*)aContext->GetMutableStyleData(eStyleStruct_Padding);      nsStyleBorder* border = (nsStyleBorder*)aContext->GetMutableStyleData(eStyleStruct_Border);      nsStyleOutline* outline = (nsStyleOutline*)aContext->GetMutableStyleData(eStyleStruct_Outline);      const nsStyleMargin* parentMargin = margin;      const nsStylePadding* parentPadding = padding;      const nsStyleBorder* parentBorder = border;      const nsStyleOutline* parentOutline = outline;      if (nsnull != aParentContext) {        parentMargin = (const nsStyleMargin*)aParentContext->GetStyleData(eStyleStruct_Margin);        parentPadding = (const nsStylePadding*)aParentContext->GetStyleData(eStyleStruct_Padding);        parentBorder = (const nsStyleBorder*)aParentContext->GetStyleData(eStyleStruct_Border);        parentOutline = (const nsStyleOutline*)aParentContext->GetStyleData(eStyleStruct_Outline);      }      // margin: length, percent, auto, inherit      if (nsnull != ourMargin->mMargin) {        nsStyleCoord  coord;        nsStyleCoord  parentCoord;        parentMargin->mMargin.GetLeft(parentCoord);        if (SetCoord(ourMargin->mMargin->mLeft, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {          margin->mMargin.SetLeft(coord);        }        parentMargin->mMargin.GetTop(parentCoord);        if (SetCoord(ourMargin->mMargin->mTop, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {          margin->mMargin.SetTop(coord);        }        parentMargin->mMargin.GetRight(parentCoord);        if (SetCoord(ourMargin->mMargin->mRight, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {          margin->mMargin.SetRight(coord);        }        parentMargin->mMargin.GetBottom(parentCoord);        if (SetCoord(ourMargin->mMargin->mBottom, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {          margin->mMargin.SetBottom(coord);        }      }      // padding: length, percent, inherit      if (nsnull != ourMargin->mPadding) {        nsStyleCoord  coord;        nsStyleCoord  parentCoord;        parentPadding->mPadding.GetLeft(parentCoord);        if (SetCoord(ourMargin->mPadding->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          padding->mPadding.SetLeft(coord);        }        parentPadding->mPadding.GetTop(parentCoord);        if (SetCoord(ourMargin->mPadding->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          padding->mPadding.SetTop(coord);        }        parentPadding->mPadding.GetRight(parentCoord);        if (SetCoord(ourMargin->mPadding->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          padding->mPadding.SetRight(coord);        }        parentPadding->mPadding.GetBottom(parentCoord);        if (SetCoord(ourMargin->mPadding->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          padding->mPadding.SetBottom(coord);        }      }      // border-size: length, enum, inherit      if (nsnull != ourMargin->mBorderWidth) {        nsStyleCoord  coord;        nsStyleCoord  parentCoord;        if (SetCoord(ourMargin->mBorderWidth->mLeft, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {          border->mBorder.SetLeft(coord);        }        else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mLeft.GetUnit()) {          border->mBorder.SetLeft(parentBorder->mBorder.GetLeft(coord));        }        if (SetCoord(ourMargin->mBorderWidth->mTop, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {          border->mBorder.SetTop(coord);        }        else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mTop.GetUnit()) {          border->mBorder.SetTop(parentBorder->mBorder.GetTop(coord));        }        if (SetCoord(ourMargin->mBorderWidth->mRight, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {          border->mBorder.SetRight(coord);        }        else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mRight.GetUnit()) {          border->mBorder.SetRight(parentBorder->mBorder.GetRight(coord));        }        if (SetCoord(ourMargin->mBorderWidth->mBottom, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {          border->mBorder.SetBottom(coord);        }        else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mBottom.GetUnit()) {          border->mBorder.SetBottom(parentBorder->mBorder.GetBottom(coord));        }      }      // border-style: enum, none, inhert      if (nsnull != ourMargin->mBorderStyle) {        nsCSSRect* ourStyle = ourMargin->mBorderStyle;        if (eCSSUnit_Enumerated == ourStyle->mTop.GetUnit()) {          border->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());        }        else if (eCSSUnit_None == ourStyle->mTop.GetUnit()) {          border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);        }        else if (eCSSUnit_Inherit == ourStyle->mTop.GetUnit()) {          border->SetBorderStyle(NS_SIDE_TOP, parentBorder->GetBorderStyle(NS_SIDE_TOP));        }        if (eCSSUnit_Enumerated == ourStyle->mRight.GetUnit()) {          border->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());        }        else if (eCSSUnit_None == ourStyle->mRight.GetUnit()) {          border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);        }        else if (eCSSUnit_Inherit == ourStyle->mRight.GetUnit()) {          border->SetBorderStyle(NS_SIDE_RIGHT, parentBorder->GetBorderStyle(NS_SIDE_RIGHT));        }        if (eCSSUnit_Enumerated == ourStyle->mBottom.GetUnit()) {          border->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());        }        else if (eCSSUnit_None == ourStyle->mBottom.GetUnit()) {          border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);        }        else if (eCSSUnit_Inherit == ourStyle->mBottom.GetUnit()) {           border->SetBorderStyle(NS_SIDE_BOTTOM, parentBorder->GetBorderStyle(NS_SIDE_BOTTOM));        }        if (eCSSUnit_Enumerated == ourStyle->mLeft.GetUnit()) {          border->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());        }        else if (eCSSUnit_None == ourStyle->mLeft.GetUnit()) {         border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);        }        else if (eCSSUnit_Inherit == ourStyle->mLeft.GetUnit()) {          border->SetBorderStyle(NS_SIDE_LEFT, parentBorder->GetBorderStyle(NS_SIDE_LEFT));        }      }      // border-color: color, string, enum, inherit      if (nsnull != ourMargin->mBorderColor) {        nsCSSRect* ourBorderColor = ourMargin->mBorderColor;        nscolor borderColor;        nscolor unused = NS_RGB(0,0,0);        // top        if (eCSSUnit_Inherit == ourBorderColor->mTop.GetUnit()) {          if (parentBorder->GetBorderColor(NS_SIDE_TOP, borderColor)) {            border->SetBorderColor(NS_SIDE_TOP, borderColor);          }          else {            border->SetBorderTransparent(NS_SIDE_TOP);          }        }        else if (SetColor(ourBorderColor->mTop, unused, aPresContext, borderColor)) {          border->SetBorderColor(NS_SIDE_TOP, borderColor);        }        else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {          switch (ourBorderColor->mTop.GetIntValue()) {            case NS_STYLE_COLOR_TRANSPARENT:              border->SetBorderTransparent(NS_SIDE_TOP);              break;            case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:              const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);              border->SetBorderColor(NS_SIDE_TOP, ourColor->mColor);              break;          }        }        // right        if (eCSSUnit_Inherit == ourBorderColor->mRight.GetUnit()) {          if (parentBorder->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {            border->SetBorderColor(NS_SIDE_RIGHT, borderColor);          }          else {            border->SetBorderTransparent(NS_SIDE_RIGHT);          }        }        else if (SetColor(ourBorderColor->mRight, unused, aPresContext, borderColor)) {          border->SetBorderColor(NS_SIDE_RIGHT, borderColor);        }        else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {          switch (ourBorderColor->mRight.GetIntValue()) {            case NS_STYLE_COLOR_TRANSPARENT:              border->SetBorderTransparent(NS_SIDE_RIGHT);              break;            case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:              const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);              border->SetBorderColor(NS_SIDE_RIGHT, ourColor->mColor);              break;          }        }        // bottom        if (eCSSUnit_Inherit == ourBorderColor->mBottom.GetUnit()) {          if (parentBorder->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {            border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);          }          else {            border->SetBorderTransparent(NS_SIDE_BOTTOM);          }        }        else if (SetColor(ourBorderColor->mBottom, unused, aPresContext, borderColor)) {          border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);        }        else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {          switch (ourBorderColor->mBottom.GetIntValue()) {            case NS_STYLE_COLOR_TRANSPARENT:              border->SetBorderTransparent(NS_SIDE_BOTTOM);              break;            case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:              const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);              border->SetBorderColor(NS_SIDE_BOTTOM, ourColor->mColor);              break;          }        }        // left        if (eCSSUnit_Inherit == ourBorderColor->mLeft.GetUnit()) {          if (parentBorder->GetBorderColor(NS_SIDE_LEFT, borderColor)) {            border->SetBorderColor(NS_SIDE_LEFT, borderColor);          }          else {            border->SetBorderTransparent(NS_SIDE_LEFT);          }        }        else if (SetColor(ourBorderColor->mLeft, unused, aPresContext, borderColor)) {          border->SetBorderColor(NS_SIDE_LEFT, borderColor);        }        else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {          switch (ourBorderColor->mLeft.GetIntValue()) {            case NS_STYLE_COLOR_TRANSPARENT:              border->SetBorderTransparent(NS_SIDE_LEFT);              break;            case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:              const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);              border->SetBorderColor(NS_SIDE_LEFT, ourColor->mColor);              break;          }        }      }      // -moz-border-radius: length, percent, inherit      if (nsnull != ourMargin->mBorderRadius) {        nsStyleCoord  coord;        nsStyleCoord  parentCoord;        parentBorder->mBorderRadius.GetLeft(parentCoord);        if (SetCoord(ourMargin->mBorderRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          border->mBorderRadius.SetLeft(coord);        }        parentBorder->mBorderRadius.GetTop(parentCoord);        if (SetCoord(ourMargin->mBorderRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          border->mBorderRadius.SetTop(coord);        }        parentBorder->mBorderRadius.GetRight(parentCoord);        if (SetCoord(ourMargin->mBorderRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          border->mBorderRadius.SetRight(coord);        }        parentBorder->mBorderRadius.GetBottom(parentCoord);        if (SetCoord(ourMargin->mBorderRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          border->mBorderRadius.SetBottom(coord);        }      }      // -moz-outline-radius: length, percent, inherit      if (nsnull != ourMargin->mOutlineRadius) {        nsStyleCoord  coord;        nsStyleCoord  parentCoord;        parentOutline->mOutlineRadius.GetLeft(parentCoord);        if (SetCoord(ourMargin->mOutlineRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          outline->mOutlineRadius.SetLeft(coord);        }        parentOutline->mOutlineRadius.GetTop(parentCoord);        if (SetCoord(ourMargin->mOutlineRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          outline->mOutlineRadius.SetTop(coord);        }        parentOutline->mOutlineRadius.GetRight(parentCoord);        if (SetCoord(ourMargin->mOutlineRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          outline->mOutlineRadius.SetRight(coord);        }        parentOutline->mOutlineRadius.GetBottom(parentCoord);        if (SetCoord(ourMargin->mOutlineRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {          outline->mOutlineRadius.SetBottom(coord);        }      }      // outline-width: length, enum, inherit      if (! SetCoord(ourMargin->mOutlineWidth, outline->mOutlineWidth, parentOutline->mOutlineWidth,                     SETCOORD_LEH, aFont->mFont, aPresContext)) {      }      // outline-color: color, string, enum, inherit      nscolor outlineColor;      nscolor unused = NS_RGB(0,0,0);      if (eCSSUnit_Inherit == ourMargin->mOutlineColor.GetUnit()) {        if (parentOutline->GetOutlineColor(outlineColor)) {          outline->SetOutlineColor(outlineColor);        }        else {          outline->SetOutlineInvert();        }      }      else if (SetColor(ourMargin->mOutlineColor, unused, aPresContext, outlineColor)) {        outline->SetOutlineColor(outlineColor);      }      else if (eCSSUnit_Enumerated == ourMargin->mOutlineColor.GetUnit()) {        outline->SetOutlineInvert();      }      // outline-style: enum, none, inherit      if (eCSSUnit_Enumerated == ourMargin->mOutlineStyle.GetUnit()) {        outline->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());      }      else if (eCSSUnit_None == ourMargin->mOutlineStyle.GetUnit()) {        outline->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);      }      else if (eCSSUnit_Inherit == ourMargin->mOutlineStyle.GetUnit()) {        outline->SetOutlineStyle(parentOutline->GetOutlineStyle());      }      // float-edge: enum, inherit      if (eCSSUnit_Enumerated == ourMargin->mFloatEdge.GetUnit()) {        border->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();      }      else if (eCSSUnit_Inherit == ourMargin->mFloatEdge.GetUnit()) {        border->mFloatEdge = parentBorder->mFloatEdge;      }    }  }}