nsRect rect; GetAbsoluteFrameRect(aFrame, rect);  val->SetTwips(rect.width);
if (aFrame) {  nsCOMPtr<nsIDocument> document; mContent->GetDocument(*getter_AddRefs(document));  if (document) { document->FlushPendingNotifications(); }  const nsStyleDisplay* displayData = nsnull; GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)displayData, aFrame); if (displayData && displayData->mDisplay == NS_STYLE_DISPLAY_INLINE) { nsFrameState frameState; aFrame->GetFrameState(&frameState); if (! (frameState & NS_FRAME_REPLACED_ELEMENT)) {  return NS_ERROR_NOT_IMPLEMENTED; } }  nsRect rect; nsMargin padding; nsMargin border; aFrame->GetRect(rect); const nsStylePadding* paddingData=nsnull; GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingData, aFrame); if (paddingData) { paddingData->CalcPaddingFor(aFrame, padding); } const nsStyleBorder* borderData=nsnull; GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderData, aFrame); if (borderData) { borderData->CalcBorderFor(aFrame, border); } val->SetTwips(rect.width - padding.left - padding.right - border.left - border.right); } else {  val->SetTwips(0); }
nsComputedDOMStyle::GetWidth(nsIFrame *aFrame,                             nsIDOMCSSPrimitiveValue*& aValue){  nsROCSSPrimitiveValue* val=GetROCSSPrimitiveValue();  NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);  nsRect rect;  GetAbsoluteFrameRect(aFrame, rect);  val->SetTwips(rect.width);  return val->QueryInterface(NS_GET_IID(nsIDOMCSSPrimitiveValue),                             (void **)&aValue);}