if (NS_SUCCEEDED(GetWidth(&width)) && width) { nsAutoString widthStr; widthStr.AppendInt(width); aValue.Append(widthStr); aValue.Append(NS_LITERAL_STRING("px"));
nsIFrame* frame = nsnull; if (imageFrame) { imageFrame->QueryInterface(NS_GET_IID(nsIFrame), (void**)&frame); NS_WARN_IF_FALSE(frame,"Should not happen - image frame is not frame"); }  if (NS_SUCCEEDED(rv) && frame) { nsSize size; frame->GetSize(size);  nsCOMPtr<nsIPresContext> context; rv = GetPresContext(this, getter_AddRefs(context));  if (NS_SUCCEEDED(rv) && context) { float t2p; context->GetTwipsToPixels(&t2p);  *aWidth = NSTwipsToIntPixels(size.width, t2p); } } else { nsHTMLValue value; rv = GetHTMLAttribute(nsHTMLAtoms::width, value);  if (rv == NS_CONTENT_ATTR_HAS_VALUE) { *aWidth = value.GetPixelValue();
nsHTMLImageElement::GetWidth(nsAWritableString& aValue){  nsresult rv = nsGenericHTMLLeafElement::GetAttribute(kNameSpaceID_None,                                                       nsHTMLAtoms::width,                                                       aValue);  if (rv == NS_CONTENT_ATTR_NOT_THERE) {    PRInt32 width = 0;    aValue.Truncate();     // A zero width most likely means that the image is not loaded yet.    if (NS_SUCCEEDED(GetWidth(&width)) && width) {      nsAutoString widthStr;      widthStr.AppendInt(width);      aValue.Append(widthStr);      aValue.Append(NS_LITERAL_STRING("px"));    }  }  return NS_OK;}