const nsStylePadding* padding=nsnull; GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)padding, aFrame);  if(padding) { nsStyleCoord coord; switch(aSide) { case NS_SIDE_TOP: padding->mPadding.GetTop(coord); break; case NS_SIDE_BOTTOM : padding->mPadding.GetBottom(coord); break; case NS_SIDE_LEFT : padding->mPadding.GetLeft(coord); break; case NS_SIDE_RIGHT : padding->mPadding.GetRight(coord); break; default: NS_WARNING("double check the side"); break; }  switch(coord.GetUnit()) { case eStyleUnit_Coord: val->SetTwips(coord.GetCoordValue()); break; case eStyleUnit_Percent: { nsIFrame* parent=nsnull; aFrame->GetParent(&parent); if(parent) { nsRect rect; parent->GetRect(rect); val->SetTwips(nscoord(coord.GetPercentValue() * rect.width)); break; } } default: NS_WARNING("double check the unit"); break; } }
nscoord width = GetPaddingWidthCoordFor(aSide, aFrame); val->SetTwips(width);
nsComputedDOMStyle::GetPaddingWidthFor(PRUint8 aSide,                                       nsIFrame *aFrame,                                       nsIDOMCSSPrimitiveValue*& aValue){  nsROCSSPrimitiveValue* val=GetROCSSPrimitiveValue();  NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);  const nsStylePadding* padding=nsnull;  GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)padding, aFrame);  if(padding) {     nsStyleCoord coord;     switch(aSide) {       case NS_SIDE_TOP:         padding->mPadding.GetTop(coord); break;       case NS_SIDE_BOTTOM :         padding->mPadding.GetBottom(coord); break;       case NS_SIDE_LEFT :         padding->mPadding.GetLeft(coord); break;       case NS_SIDE_RIGHT :         padding->mPadding.GetRight(coord); break;       default:         NS_WARNING("double check the side");         break;     }     switch(coord.GetUnit()) {       case eStyleUnit_Coord:         val->SetTwips(coord.GetCoordValue()); break;       case eStyleUnit_Percent:         {            nsIFrame* parent=nsnull;            aFrame->GetParent(&parent);            if(parent) {              nsRect rect;              parent->GetRect(rect);              val->SetTwips(nscoord(coord.GetPercentValue() * rect.width));              break; // intentionally breaking here...            }         }       default:         NS_WARNING("double check the unit");         break;     }  }  return val->QueryInterface(NS_GET_IID(nsIDOMCSSPrimitiveValue),                             (void **)&aValue);}