content->GetDocument(*getter_AddRefs(doc));
content->GetDocument(getter_AddRefs(doc));
GetScreenOrigin(nsIDOMElement* aElement){  nsRect* rect = new nsRect(0,0,0,0);  nsSize size;   nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);  nsCOMPtr<nsIDocument> doc;  content->GetDocument(*getter_AddRefs(doc));  if (doc) {    // Get Presentation shell 0    nsCOMPtr<nsIPresShell> presShell;    doc->GetShellAt(0, getter_AddRefs(presShell));        if (presShell) {      nsCOMPtr<nsIPresContext> presContext;      presShell->GetPresContext(getter_AddRefs(presContext));      if (presContext) {        // Get the scale from that Presentation Context        float scale;        presContext->GetTwipsToPixels(&scale);        nsIFrame* frame;        nsresult rv = presShell->GetPrimaryFrameFor(content, &frame);        nsIView* view;        nsPoint offset;        frame->GetOffsetFromView(presContext, offset, &view);        if (view) {          nscoord dummy;          nsCOMPtr<nsIWidget> widget;          rv = view->GetOffsetFromWidget(&dummy, &dummy, *getter_AddRefs(widget));          if (widget) {            nsRect oldBox(0,0,0,0);            widget->WidgetToScreen(oldBox, *rect);          }                    nscoord viewX = 0, viewY = 0;          view->GetPosition(&viewX, &viewY);          rect->x += NSTwipsToIntPixels(offset.x+viewX, scale);          rect->y += NSTwipsToIntPixels(offset.y+viewY, scale);        }                frame->GetSize(size);        rect->width = NSTwipsToIntPixels(size.width, scale);        rect->height = NSTwipsToIntPixels(size.height, scale);      }    }  }    return *rect;}