Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsWindowUtils.cpp File Reference
#include <MacWindows.h>
#include "nsCommandLineServiceMac.h"
#include "nsCOMPtr.h"
#include "nsIBaseWindow.h"
#include "nsIBrowserDOMWindow.h"
#include "nsIContent.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMWindow.h"
#include "nsIDOMChromeWindow.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIServiceManager.h"
#include "nsIWebNavigation.h"
#include "nsIWidget.h"
#include "nsIWindowMediator.h"
#include "nsIURI.h"
#include "nsIXULWindow.h"
#include "nsString.h"
#include "nsNetUtil.h"
#include "nsWindowUtils.h"
#include "nsMacUtils.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsAEUtils.h"

Go to the source code of this file.

Functions

static NS_DEFINE_CID (kWindowMediatorCID, NS_WINDOWMEDIATOR_CID)
static void GetXULWindowFromWindowPtr (WindowPtr inWindowPtr, nsIXULWindow **outXULWindow)
static void GetXULWindowTypeString (nsIXULWindow *inXULWindow, nsString &outWindowType)
static TWindowKind WindowKindFromTypeString (const nsString &inWindowType)
static TWindowKind GetXULWindowKind (nsIXULWindow *inXULWindow)
void GetWindowPortRect (WindowPtr wind, Rect *outRect)
static void LocalToGlobalRect (Rect *r)

Function Documentation

void GetWindowPortRect ( WindowPtr  wind,
Rect *  outRect 
) [inline]

Definition at line 445 of file nsWindowUtils.cpp.

{
#if OPAQUE_TOOLBOX_STRUCTS
    ::GetPortBounds(GetWindowPort(wind), outRect);
#else
       *outRect = wind->portRect;
#endif
}

Here is the caller graph for this function:

static void GetXULWindowFromWindowPtr ( WindowPtr  inWindowPtr,
nsIXULWindow **  outXULWindow 
) [static]

Definition at line 87 of file nsWindowUtils.cpp.

{
       *outXULWindow = NULL;
       
       if (!inWindowPtr)
              ThrowOSErr(paramErr);
       
       nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
       ThrowErrIfNil(windowMediator, paramErr);

       nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
       if (NS_FAILED(windowMediator->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowEnumerator))))
              ThrowOSErr(paramErr);                     // need a better error

       // Find the window
       while (true)
       {
              PRBool more = false;
              windowEnumerator->HasMoreElements(&more);
              if (!more)
                     break;
                     
              nsCOMPtr<nsISupports> nextWindow = nsnull;
              windowEnumerator->GetNext(getter_AddRefs(nextWindow));
              nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(nextWindow));
              if (NULL == baseWindow)
                  continue;
                  
              nsCOMPtr<nsIWidget> widget = nsnull;
              baseWindow->GetMainWidget(getter_AddRefs(widget));
              if (NULL == widget)
                  continue;
              
              WindowRef windowRef = (WindowRef)widget->GetNativeData(NS_NATIVE_DISPLAY);
              if ((WindowPtr)windowRef == inWindowPtr)
              {
                     // !!! There really must be an easier way to do this. JavaScript?
                     nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow));
                     if (!xulWindow)
                            break;
                            
                     NS_ADDREF(*outXULWindow = xulWindow);
                     return;                            
              }             
       }
       
       // if we got here, we didn't find the window
       ThrowOSErr(paramErr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static TWindowKind GetXULWindowKind ( nsIXULWindow inXULWindow) [static]

Definition at line 205 of file nsWindowUtils.cpp.

{
       nsAutoString         windowType;
       GetXULWindowTypeString(inXULWindow, windowType);
       return WindowKindFromTypeString(windowType);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void GetXULWindowTypeString ( nsIXULWindow inXULWindow,
nsString outWindowType 
) [static]

Definition at line 144 of file nsWindowUtils.cpp.

{
       outWindowType.Truncate();

       if (inXULWindow)
       {
              nsCOMPtr<nsIDocShellTreeItem>             contentShell;
              inXULWindow->GetPrimaryContentShell(getter_AddRefs(contentShell));
              nsCOMPtr<nsIWebNavigation>                webNav(do_QueryInterface(contentShell));
              ThrowErrIfNil(webNav, paramErr);

              nsCOMPtr<nsIDOMDocument> domDoc;
              webNav->GetDocument(getter_AddRefs(domDoc));
              if (domDoc)
              {
             nsCOMPtr<nsIDOMElement> element;
             domDoc->GetDocumentElement(getter_AddRefs(element));
             if (element)
               element->GetAttribute(NS_LITERAL_STRING("windowtype"), outWindowType);             
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void LocalToGlobalRect ( Rect *  r) [static]

Definition at line 462 of file nsWindowUtils.cpp.

{
       LocalToGlobal((Point*)&r->top);
       LocalToGlobal((Point*)&r->bottom);
}

Here is the caller graph for this function:

static NS_DEFINE_CID ( kWindowMediatorCID  ,
NS_WINDOWMEDIATOR_CID   
) [static]
static TWindowKind WindowKindFromTypeString ( const nsString inWindowType) [static]

Definition at line 173 of file nsWindowUtils.cpp.

{
       if (inWindowType.IsEmpty())
              return kAnyWindowKind;
              
       if (inWindowType.EqualsLiteral("navigator:browser"))
              return kBrowserWindowKind;

       if (inWindowType.EqualsLiteral("mail:3pane"))
              return kMailWindowKind;

       if (inWindowType.EqualsLiteral("msgcompose"))
              return kMailComposeWindowKind;

       if (inWindowType.EqualsLiteral("mail:addressbook"))
              return kAddressBookWindowKind;

       if (inWindowType.EqualsLiteral("composer:html"))
              return kComposerWindowKind;

       if (inWindowType.EqualsLiteral("composer:text"))
              return kComposerWindowKind;

       return kOtherWindowKind;
}

Here is the caller graph for this function: