Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsFormFillController.cpp File Reference
#include "nsFormFillController.h"
#include "nsFormHistory.h"
#include "nsIAutoCompleteResultTypes.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDocShellTreeItem.h"
#include "nsIChromeEventHandler.h"
#include "nsPIDOMWindow.h"
#include "nsIWebNavigation.h"
#include "nsIContentViewer.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMKeyEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIDOMCompositionListener.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIDocument.h"
#include "nsIScriptGlobalObject.h"
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIView.h"
#include "nsIFrame.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsIDOMDocumentEvent.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsPasswordManager.h"
#include "nsIDOMMouseEvent.h"

Go to the source code of this file.

Functions

nsRect GetScreenOrigin (nsIDOMElement *aElement)

Function Documentation

Definition at line 131 of file nsFormFillController.cpp.

{
  nsRect rect(0,0,0,0);
  nsSize size;
 
  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
  nsCOMPtr<nsIDocument> doc = content->GetDocument();

  if (doc) {
    // Get Presentation shell 0
    nsIPresShell* presShell = doc->GetShellAt(0);
    
    if (presShell) {
      nsPresContext* presContext = presShell->GetPresContext();

      if (presContext) {
        // Get the scale from that Presentation Context
        float scale;
        scale = presContext->TwipsToPixels();

        nsIFrame* frame;
        presShell->GetPrimaryFrameFor(content, &frame);
        if (!frame)
          return rect;

        nsIView* view;
        nsPoint offset;
        frame->GetOffsetFromView(offset, &view);
        if (view) {
          nsPoint widgetOffset(0, 0);
          nsIWidget* widget = view->GetNearestWidget(&widgetOffset);
          if (widget) {
            nsRect oldBox(0,0,0,0);
            widget->WidgetToScreen(oldBox, rect);
          }
          
          rect.x += NSTwipsToIntPixels(offset.x+widgetOffset.x, scale);
          rect.y += NSTwipsToIntPixels(offset.y+widgetOffset.y, scale);
        }
        
        size = frame->GetSize();
        rect.width = NSTwipsToIntPixels(size.width, scale);
        rect.height = NSTwipsToIntPixels(size.height, scale);
      }
    }
  }
  
  return rect;
}

Here is the call graph for this function: