nsIDocument *document = GetOwnerDoc();
nsHTMLImageElement::GetXY(){  nsPoint point(0, 0);  if (!IsInDoc()) {    return point;  }  nsIDocument *document = GetOwnerDoc();  // Get Presentation shell 0  nsIPresShell *presShell = document->GetShellAt(0);  if (!presShell) {    return point;  }  // Get the Presentation Context from the Shell  nsPresContext *context = presShell->GetPresContext();  if (!context) {    return point;  }  // Flush all pending notifications so that our frames are laid out correctly  document->FlushPendingNotifications(Flush_Layout);  // Get the Frame for this image  nsIFrame* frame = nsnull;  presShell->GetPrimaryFrameFor(this, &frame);  if (!frame) {    return point;  }  nsPoint origin(0, 0);  nsIView* parentView;  nsresult rv = frame->GetOffsetFromView(context, origin, &parentView);  if (NS_FAILED(rv)) {    return point;  }  // Get the scale from that Presentation Context  float scale;  scale = context->TwipsToPixels();  // Convert to pixels using that scale  point.x = NSTwipsToIntPixels(origin.x, scale);  point.y = NSTwipsToIntPixels(origin.y, scale);  return point;}