Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends
nsXULWindow Class Reference

#include <nsXULWindow.h>

Inheritance diagram for nsXULWindow:
Inheritance graph
[legend]
Collaboration diagram for nsXULWindow:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIXULWINDOW
NS_DECL_NSIBASEWINDOW void 
LockUntilChromeLoad ()
PRBool IsLocked () const
void initWindow (in nativeWindow parentNativeWindow, in nsIWidget parentWidget, in long x, in long y, in long cx, in long cy)
void create ()
void destroy ()
void setPosition (in long x, in long y)
void getPosition (out long x, out long y)
void setSize (in long cx, in long cy, in boolean fRepaint)
void getSize (out long cx, out long cy)
void setPositionAndSize (in long x, in long y, in long cx, in long cy, in boolean fRepaint)
void getPositionAndSize (out long x, out long y, out long cx, out long cy)
void repaint (in boolean force)
 Tell the window to repaint itself.
void setFocus ()
 Give the window focus.
void getInterface (in nsIIDRef uuid,[iid_is(uuid), retval] out nsQIResult result)
 Retrieves the specified interface pointer.
nsIDocShellTreeItem getContentShellById (in wstring ID)
 The content shell specified by the supplied id.
void addChildWindow (in nsIXULWindow aChild)
 Tell this window that it has picked up a child XUL window.
void removeChildWindow (in nsIXULWindow aChild)
 Tell this window that it has lost a child XUL window.
void center (in nsIXULWindow aRelative, in boolean aScreen, in boolean aAlert)
 Move the window to a centered position.
void showModal ()
 Shows the window as a modal window.
nsIXULWindow createNewWindow (in PRInt32 aChromeFlags, in nsIAppShell aAppShell)
 Create a new window.

Public Attributes

attribute nsIWidget parentWidget
attribute nativeWindow parentNativeWindow
attribute boolean visibility
attribute boolean enabled
attribute boolean blurSuppression
 set blurSuppression to true to suppress handling of blur events.
readonly attribute nsIWidget mainWidget
attribute wstring title
readonly attribute nsIDocShell docShell
 The docshell owning the XUL for this window.
attribute boolean intrinsicallySized
 Indicates if this window is instrinsically sized.
readonly attribute
nsIDocShellTreeItem 
primaryContentShell
 The primary content shell.
const unsigned long lowestZ = 0
const unsigned long loweredZ = 4
const unsigned long normalZ = 5
const unsigned long raisedZ = 6
const unsigned long highestZ = 9
attribute unsigned long zLevel
attribute PRUint32 contextFlags
 contextFlags are from nsIWindowCreator2
attribute PRUint32 chromeFlags
attribute nsIXULBrowserWindow XULBrowserWindow

Protected Types

enum  persistentAttributes { PAD_MISC = 0x1, PAD_POSITION = 0x2, PAD_SIZE = 0x4 }

Protected Member Functions

 nsXULWindow ()
virtual ~nsXULWindow ()
NS_IMETHOD EnsureChromeTreeOwner ()
NS_IMETHOD EnsureContentTreeOwner ()
NS_IMETHOD EnsurePrimaryContentTreeOwner ()
NS_IMETHOD EnsurePrompter ()
NS_IMETHOD EnsureAuthPrompter ()
void OnChromeLoaded ()
void StaggerPosition (PRInt32 &aRequestedX, PRInt32 &aRequestedY, PRInt32 aSpecWidth, PRInt32 aSpecHeight)
PRBool LoadPositionFromXUL ()
PRBool LoadSizeFromXUL ()
PRBool LoadMiscPersistentAttributesFromXUL ()
nsresult LoadChromeHidingFromXUL ()
NS_IMETHOD LoadWindowClassFromXUL ()
NS_IMETHOD LoadIconFromXUL ()
NS_IMETHOD SavePersistentAttributes ()
NS_IMETHOD GetWindowDOMWindow (nsIDOMWindowInternal **aDOMWindow)
NS_IMETHOD GetWindowDOMElement (nsIDOMElement **aDOMElement)
NS_IMETHOD GetDOMElementById (char *aID, nsIDOMElement **aDOMElement)
 NS_HIDDEN_ (nsresult) ContentShellAdded(nsIDocShellTreeItem *aContentShell
 NS_HIDDEN_ (nsresult) ContentShellRemoved(nsIDocShellTreeItem *aContentShell)
NS_IMETHOD SizeShellTo (nsIDocShellTreeItem *aShellItem, PRInt32 aCX, PRInt32 aCY)
NS_IMETHOD ExitModalLoop (nsresult aStatus)
NS_IMETHOD CreateNewChromeWindow (PRInt32 aChromeFlags, nsIAppShell *aAppShell, nsIXULWindow **_retval)
NS_IMETHOD CreateNewContentWindow (PRInt32 aChromeFlags, nsIAppShell *aAppShell, nsIXULWindow **_retval)
void EnableParent (PRBool aEnable)
PRBool ConstrainToZLevel (PRBool aImmediate, nsWindowZ *aPlacement, nsIWidget *aReqBelow, nsIWidget **aActualBelow)
void PlaceWindowLayersBehind (PRUint32 aLowLevel, PRUint32 aHighLevel, nsIXULWindow *aBehind)
void SetContentScrollbarVisibility (PRBool aVisible)
PRBool GetContentScrollbarVisibility ()
void PersistentAttributesDirty (PRUint32 aDirtyFlags)
nsresult ApplyChromeFlags ()

Protected Attributes

PRBool aPrimary
PRBool PRBool aTargetable
PRBool PRBool const nsAString & aID
nsChromeTreeOwnermChromeTreeOwner
nsContentTreeOwnermContentTreeOwner
nsContentTreeOwnermPrimaryContentTreeOwner
nsCOMPtr< nsIWidgetmWindow
nsCOMPtr< nsIDocShellmDocShell
nsCOMPtr< nsIDOMWindowInternalmDOMWindow
nsCOMPtr< nsIWeakReferencemParentWindow
nsCOMPtr< nsIPromptmPrompter
nsCOMPtr< nsIAuthPromptmAuthPrompter
nsCOMPtr< nsIXULBrowserWindowmXULBrowserWindow
nsCOMPtr< nsIDocShellTreeItemmPrimaryContentShell
nsVoidArray mContentShells
nsresult mModalStatus
PRPackedBool mContinueModalLoop
PRPackedBool mDebuting
PRPackedBool mChromeLoaded
PRPackedBool mShowAfterLoad
PRPackedBool mIntrinsicallySized
PRPackedBool mCenterAfterLoad
PRPackedBool mIsHiddenWindow
PRPackedBool mLockedUntilChromeLoad
PRUint32 mContextFlags
PRUint32 mBlurSuppressionLevel
PRUint32 mPersistentAttributesDirty
PRUint32 mPersistentAttributesMask
PRUint32 mChromeFlags
nsString mTitle
nsCOMArray< nsIWeakReferencemTargetableShells

Friends

class nsChromeTreeOwner
class nsContentTreeOwner

Detailed Description

Definition at line 80 of file nsXULWindow.h.


Member Enumeration Documentation

Enumerator:
PAD_MISC 
PAD_POSITION 
PAD_SIZE 

Definition at line 101 of file nsXULWindow.h.

                             {
     PAD_MISC =         0x1,
     PAD_POSITION =     0x2,
     PAD_SIZE =         0x4
   };

Constructor & Destructor Documentation

nsXULWindow::nsXULWindow ( ) [protected]
nsXULWindow::~nsXULWindow ( ) [protected, virtual]

Definition at line 132 of file nsXULWindow.cpp.

{
  Destroy();
}

Member Function Documentation

Tell this window that it has picked up a child XUL window.

Parameters:
aChildthe child window being added

Definition at line 2060 of file nsXULWindow.cpp.

{
  nsCOMPtr<nsIDOMElement> window;
  GetWindowDOMElement(getter_AddRefs(window));
  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);

  // menubar has its own special treatment
  mWindow->ShowMenuBar(mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR ? 
                       PR_TRUE : PR_FALSE);

  // Scrollbars have their own special treatment.
  SetContentScrollbarVisibility(mChromeFlags &
                                  nsIWebBrowserChrome::CHROME_SCROLLBARS ?
                                PR_TRUE : PR_FALSE);

  /* the other flags are handled together. we have style rules
     in navigator.css that trigger visibility based on
     the 'chromehidden' attribute of the <window> tag. */
  nsAutoString newvalue;

  if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR))
    newvalue.AppendLiteral("menubar ");

  if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR))
    newvalue.AppendLiteral("toolbar ");

  if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_LOCATIONBAR))
    newvalue.AppendLiteral("location ");

  if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR))
    newvalue.AppendLiteral("directories ");

  if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR))
    newvalue.AppendLiteral("status ");

  if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_EXTRA))
    newvalue.AppendLiteral("extrachrome ");


  // Get the old value, to avoid useless style reflows if we're just
  // setting stuff to the exact same thing.
  nsAutoString oldvalue;
  window->GetAttribute(NS_LITERAL_STRING("chromehidden"), oldvalue);

  if (oldvalue != newvalue)
    window->SetAttribute(NS_LITERAL_STRING("chromehidden"), newvalue);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIXULWindow::center ( in nsIXULWindow  aRelative,
in boolean  aScreen,
in boolean  aAlert 
) [inherited]

Move the window to a centered position.

Parameters:
aRelativethe window relative to which the window is moved. See screen parameter for details. if null, the window is centered relative to the main screen.
aScreenPR_TRUE to center the window relative to the screen containing aRelative. PR_FALSE to center it relative to aRelative itself.
aAlertPR_TRUE to move the window to an alert position, generally centered horizontally and 1/3 down from the top.
PRBool nsXULWindow::ConstrainToZLevel ( PRBool  aImmediate,
nsWindowZ aPlacement,
nsIWidget aReqBelow,
nsIWidget **  aActualBelow 
) [protected]

Definition at line 1881 of file nsXULWindow.cpp.

                                                {

#if 0
  /* Do we have a parent window? This means our z-order is already constrained,
     since we're a dependent window. Our window list isn't hierarchical,
     so we can't properly calculate placement for such a window.
     Should we just abort? */
  nsCOMPtr<nsIBaseWindow> parentWindow = do_QueryReferent(mParentWindow);
  if (parentWindow)
    return PR_FALSE;
#endif

  nsCOMPtr<nsIWindowMediator> mediator(do_GetService(kWindowMediatorCID));
  if(!mediator)
    return PR_FALSE;

  PRBool         altered;
  PRUint32       position,
                 newPosition,
                 zLevel;
  nsIXULWindow  *us = this;

  altered = PR_FALSE;
  mediator->GetZLevel(this, &zLevel);

  // translate from nsGUIEvent to nsIWindowMediator constants
  position = nsIWindowMediator::zLevelTop;
  if (*aPlacement == nsWindowZBottom || zLevel == nsIXULWindow::lowestZ)
    position = nsIWindowMediator::zLevelBottom;
  else if (*aPlacement == nsWindowZRelative)
    position = nsIWindowMediator::zLevelBelow;

  if (NS_SUCCEEDED(mediator->CalculateZPosition(us, position, aReqBelow,
                               &newPosition, aActualBelow, &altered))) {

    /* If we were asked to move to the top but constrained to remain
       below one of our other windows, first move all windows in that
       window's layer and above to the top. This allows the user to
       click a window which can't be topmost and still bring mozilla
       to the foreground. */
    if (altered &&
        (position == nsIWindowMediator::zLevelTop ||
         position == nsIWindowMediator::zLevelBelow && aReqBelow == 0))

      PlaceWindowLayersBehind(zLevel+1, nsIXULWindow::highestZ, 0);

    if (*aPlacement != nsWindowZBottom &&
        position == nsIWindowMediator::zLevelBottom)
      altered = PR_TRUE;
    if (altered || aImmediate) {
      if (newPosition == nsIWindowMediator::zLevelTop)
        *aPlacement = nsWindowZTop;
      else if (newPosition == nsIWindowMediator::zLevelBottom)
        *aPlacement = nsWindowZBottom;
      else
        *aPlacement = nsWindowZRelative;

      if (aImmediate) {
        nsCOMPtr<nsIBaseWindow> ourBase = do_QueryInterface(NS_STATIC_CAST(nsIXULWindow *,this));
        if (ourBase) {
          nsCOMPtr<nsIWidget> ourWidget;
          ourBase->GetMainWidget(getter_AddRefs(ourWidget));
          ourWidget->PlaceBehind(*aPlacement == nsWindowZBottom ?
                                   eZPlacementBottom : eZPlacementBelow,
                                 *aActualBelow, PR_FALSE);
        }
      }
    }

    /* (CalculateZPosition can tell us to be below nothing, because it tries
       not to change something it doesn't recognize. A request to verify
       being below an unrecognized window, then, is treated as a request
       to come to the top (below null) */
    nsCOMPtr<nsIXULWindow> windowAbove;
    if (newPosition == nsIWindowMediator::zLevelBelow && *aActualBelow) {
      void *data;
      (*aActualBelow)->GetClientData(data);
      if (data) {
        windowAbove = NS_REINTERPRET_CAST(nsWebShellWindow*, data);
      }
    }

    mediator->SetZPosition(us, newPosition, windowAbove);
  }

  return altered;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIBaseWindow::create ( ) [inherited]
NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow ( PRInt32  aChromeFlags,
nsIAppShell aAppShell,
nsIXULWindow **  _retval 
) [protected]

Definition at line 1742 of file nsXULWindow.cpp.

{
   NS_TIMELINE_ENTER("nsXULWindow::CreateNewChromeWindow");
   nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
   NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
   
   // Just do a normal create of a window and return.
   //XXXTAB remove this when appshell talks in terms of nsIXULWindow
   nsCOMPtr<nsIXULWindow> parent;
   if(aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
      parent = this;

   nsCOMPtr<nsIXULWindow> newWindow;
   appShell->CreateTopLevelWindow(parent, nsnull, aChromeFlags,
                                  nsIAppShellService::SIZE_TO_CONTENT,
                                  nsIAppShellService::SIZE_TO_CONTENT,
                                  aAppShell, getter_AddRefs(newWindow));

   NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);

   newWindow->SetChromeFlags(aChromeFlags);

   *_retval = newWindow;
   NS_ADDREF(*_retval);
   
   NS_TIMELINE_LEAVE("nsXULWindow::CreateNewChromeWindow done");
   return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsXULWindow::CreateNewContentWindow ( PRInt32  aChromeFlags,
nsIAppShell aAppShell,
nsIXULWindow **  _retval 
) [protected]

Definition at line 1772 of file nsXULWindow.cpp.

{
   NS_TIMELINE_ENTER("nsXULWindow::CreateNewContentWindow");
   nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
   NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);

   nsCOMPtr<nsIXULWindow> parent;
   if(aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
      parent = this;

   // We need to create a new top level window and then enter a nested
   // loop. Eventually the new window will be told that it has loaded,
   // at which time we know it is safe to spin out of the nested loop
   // and allow the opening code to proceed.

   // First push a nested event queue for event processing from netlib
   // onto our UI thread queue stack.
   nsEventQueueStack queuePusher;
   NS_ENSURE_SUCCESS(queuePusher.Success(), NS_ERROR_FAILURE);

   nsCOMPtr<nsIURI> uri;

   nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
   if (prefs) {
     char *urlStr;
     PRBool strAllocated = PR_TRUE;
     nsresult prefres;
     prefres = prefs->CopyCharPref("browser.chromeURL", &urlStr);
     if (NS_SUCCEEDED(prefres) && urlStr[0] == '\0') {
       PL_strfree(urlStr);
       prefres = NS_ERROR_FAILURE;
     }
     if (NS_FAILED(prefres)) {
       urlStr = "chrome://navigator/content/navigator.xul";
       strAllocated = PR_FALSE;
     }

     nsCOMPtr<nsIIOService> service(do_GetService(kIOServiceCID));
     if (service)
       service->NewURI(nsDependentCString(urlStr), nsnull, nsnull, getter_AddRefs(uri));
     if (strAllocated)
       PL_strfree(urlStr);
   }
   NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);

   nsCOMPtr<nsIXULWindow> newWindow;
   appShell->CreateTopLevelWindow(parent, uri,
                                  aChromeFlags, 615, 480, aAppShell,
                                  getter_AddRefs(newWindow));

   NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);

   newWindow->SetChromeFlags(aChromeFlags);

   nsCOMPtr<nsIAppShell> subShell(do_CreateInstance(kAppShellCID));
   NS_ENSURE_TRUE(subShell, NS_ERROR_FAILURE);

   subShell->Create(0, nsnull);
   subShell->Spinup();

   // Specify that we want the window to remain locked until the chrome has loaded.
   nsXULWindow *xulWin = NS_STATIC_CAST(nsXULWindow*,
                                        NS_STATIC_CAST(nsIXULWindow*,
                                                       newWindow));

   xulWin->LockUntilChromeLoad();

   // Push nsnull onto the JSContext stack before we dispatch a native event.
   nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
   if(stack && NS_SUCCEEDED(stack->Push(nsnull)))
      {
      nsresult looprv = NS_OK;
      while(NS_SUCCEEDED(looprv) && xulWin->IsLocked())
         {
         void      *data;
         PRBool    isRealEvent;
    
         looprv = subShell->GetNativeEvent(isRealEvent, data);
         subShell->DispatchNativeEvent(isRealEvent, data);
         }

      JSContext *cx;
      stack->Pop(&cx);
      NS_ASSERTION(cx == nsnull, "JSContextStack mismatch");
      }

   subShell->Spindown();

   *_retval = newWindow;
   NS_ADDREF(*_retval);

   NS_TIMELINE_LEAVE("nsXULWindow::CreateNewContentWindow");
   return NS_OK;
}

Here is the call graph for this function:

nsIXULWindow nsIXULWindow::createNewWindow ( in PRInt32  aChromeFlags,
in nsIAppShell  aAppShell 
) [inherited]

Create a new window.

Parameters:
aChromeFlagssee nsIWebBrowserChrome
Returns:
the newly minted window
void nsIBaseWindow::destroy ( ) [inherited]
void nsXULWindow::EnableParent ( PRBool  aEnable) [protected]

Definition at line 1868 of file nsXULWindow.cpp.

{
  nsCOMPtr<nsIBaseWindow> parentWindow;
  nsCOMPtr<nsIWidget>     parentWidget;

  parentWindow = do_QueryReferent(mParentWindow);
  if (parentWindow)
    parentWindow->GetMainWidget(getter_AddRefs(parentWidget));
  if (parentWidget)
    parentWidget->Enable(aEnable);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 938 of file nsXULWindow.cpp.

Here is the call graph for this function:

Definition at line 881 of file nsXULWindow.cpp.

Here is the call graph for this function:

Definition at line 895 of file nsXULWindow.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 923 of file nsXULWindow.cpp.

Here is the call graph for this function:

Definition at line 1722 of file nsXULWindow.cpp.

Here is the call graph for this function:

Definition at line 2040 of file nsXULWindow.cpp.

                                                  {

  PRBool visible = PR_TRUE;

  nsCOMPtr<nsIDOMWindow> contentWin(do_GetInterface(mPrimaryContentShell));
  if (contentWin) {
    nsCOMPtr<nsIDOMBarProp> scrollbars;
    contentWin->GetScrollbars(getter_AddRefs(scrollbars));
    if (scrollbars)
      scrollbars->GetVisible(&visible);
  }
  return visible;
}

Here is the call graph for this function:

The content shell specified by the supplied id.

Note that this is a docshell tree item and therefore can not be assured of what object it is. It could be an editor, a docshell, or a browser object. Or down the road any other object that supports being a DocShellTreeItem Query accordingly to determine the capabilities.

NS_IMETHODIMP nsXULWindow::GetDOMElementById ( char *  aID,
nsIDOMElement **  aDOMElement 
) [protected]

Definition at line 1580 of file nsXULWindow.cpp.

{
   NS_ENSURE_STATE(mDocShell);
   NS_ENSURE_ARG_POINTER(aDOMElement);

   *aDOMElement = nsnull;

   nsCOMPtr<nsIContentViewer> cv;
   
   mDocShell->GetContentViewer(getter_AddRefs(cv));
   if(!cv)
      return NS_ERROR_FAILURE;

   nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
   if(!docv)   
      return NS_ERROR_FAILURE;

   nsCOMPtr<nsIDocument> doc;
   docv->GetDocument(getter_AddRefs(doc));
   nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc));
   if(!domdoc) 
      return NS_ERROR_FAILURE;
   
   NS_ENSURE_SUCCESS(domdoc->GetElementById(NS_ConvertASCIItoUCS2(aID), aDOMElement), NS_ERROR_FAILURE);

   return NS_OK;
}

Here is the call graph for this function:

void nsIInterfaceRequestor::getInterface ( in nsIIDRef  uuid,
[iid_is(uuid), retval] out nsQIResult  result 
) [inherited]

Retrieves the specified interface pointer.

Parameters:
uuidThe IID of the interface being requested.
result[out] The interface pointer to be filled in if the interface is accessible.
Returns:
NS_OK - interface was successfully returned. NS_NOINTERFACE - interface not accessible. NS_ERROR* - method failure.
void nsIBaseWindow::getPosition ( out long  x,
out long  y 
) [inherited]
void nsIBaseWindow::getPositionAndSize ( out long  x,
out long  y,
out long  cx,
out long  cy 
) [inherited]
void nsIBaseWindow::getSize ( out long  cx,
out long  cy 
) [inherited]

Definition at line 1554 of file nsXULWindow.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1541 of file nsXULWindow.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIBaseWindow::initWindow ( in nativeWindow  parentNativeWindow,
in nsIWidget  parentWidget,
in long  x,
in long  y,
in long  cx,
in long  cy 
) [inherited]
PRBool nsXULWindow::IsLocked ( ) const [inline]

Definition at line 98 of file nsXULWindow.h.

Here is the caller graph for this function:

Definition at line 998 of file nsXULWindow.cpp.

{
  NS_ENSURE_STATE(mWindow);

  // Get <window> element.
  nsCOMPtr<nsIDOMElement> windowElement;
  GetWindowDOMElement(getter_AddRefs(windowElement));
  NS_ENSURE_TRUE(windowElement, NS_ERROR_FAILURE);

  nsAutoString attr;
  nsresult rv = windowElement->GetAttribute(NS_LITERAL_STRING("hidechrome"), attr);

  if (NS_SUCCEEDED(rv) && attr.LowerCaseEqualsLiteral("true")) {
    mWindow->HideWindowChrome(PR_TRUE);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1366 of file nsXULWindow.cpp.

{
    NS_ENSURE_STATE(mWindow);

    // Get <window> element.
    nsCOMPtr<nsIDOMElement> windowElement;
    GetWindowDOMElement(getter_AddRefs(windowElement));
    NS_ENSURE_TRUE(windowElement, NS_ERROR_FAILURE);

    // XXX The following code is being #if 0'd out since it
    // basically does nothing until bug 70974 is fixed.
    // After bug 70974 is fixed, we will also need to implement
    // computed style for that property before this will
    // be of any use.  And even then, it will *still* 
    // do nothing on platforms which don't implement 
    // nsWindow::SetIcon(). See bug 76211 for that.
    // Also see bug 57576 and its dependency tree.
#if 0
    // Get document in which this <window> is contained.
    nsCOMPtr<nsIDOMDocument> document;
    windowElement->GetOwnerDocument(getter_AddRefs(document));
    NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);

    // Get document view.
    nsCOMPtr<nsIDOMDocumentView> docView(do_QueryInterface(document));
    NS_ENSURE_TRUE(docView, NS_ERROR_FAILURE);

    // Get default/abstract view.
    nsCOMPtr<nsIDOMAbstractView> abstractView;
    docView->GetDefaultView(getter_AddRefs(abstractView));
    NS_ENSURE_TRUE(abstractView, NS_ERROR_FAILURE);

    // Get "view CSS."
    nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(abstractView));
    NS_ENSURE_TRUE(viewCSS, NS_ERROR_FAILURE);

    // Next, get CSS style declaration.
    nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
    viewCSS->GetComputedStyle(windowElement, EmptyString(),
                              getter_AddRefs(cssDecl));
    NS_ENSURE_TRUE(cssDecl, NS_ERROR_FAILURE);

    // Whew.  Now get "list-style-image" property value.
    nsAutoString windowIcon;
    windowIcon.AssignLiteral("-moz-window-icon");
    nsAutoString icon;
    cssDecl->GetPropertyValue(windowIcon, icon);
#endif

    nsAutoString id;
    windowElement->GetAttribute(NS_LITERAL_STRING("id"), id);

    if (id.IsEmpty()) {
        id.AssignLiteral("default");
    }

    mWindow->SetIcon(id);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1159 of file nsXULWindow.cpp.

{
  nsresult rv;
  PRBool   gotState = PR_FALSE;
  
  /* There are no misc attributes of interest to the hidden window.
     It's especially important not to try to validate that window's
     size or position, because some platforms (Mac OS X) need to
     make it visible and offscreen. */
  if (mIsHiddenWindow)
    return PR_FALSE;

  nsCOMPtr<nsIDOMElement> windowElement;
  GetWindowDOMElement(getter_AddRefs(windowElement));
  NS_ASSERTION(windowElement, "no xul:window");
  if (!windowElement)
    return PR_FALSE;

  nsAutoString stateString;

  // sizemode
  rv = windowElement->GetAttribute(NS_LITERAL_STRING("sizemode"), stateString);
  if (NS_SUCCEEDED(rv)) {
    PRInt32 sizeMode = nsSizeMode_Normal;
    /* ignore request to minimize, to not confuse novices
    if (stateString.Equals(SIZEMODE_MINIMIZED))
      sizeMode = nsSizeMode_Minimized;
    */
    if (stateString.Equals(SIZEMODE_MAXIMIZED)) {
      /* Honor request to maximize only if the window is sizable.
         An unsizable, unmaximizable, yet maximized window confuses
         Windows OS and is something of a travesty, anyway. */
      if (mChromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
        mIntrinsicallySized = PR_FALSE;
        sizeMode = nsSizeMode_Maximized;
      }
    }
    // the widget had better be able to deal with not becoming visible yet
    mWindow->SetSizeMode(sizeMode);
    gotState = PR_TRUE;
  }

  // zlevel
  rv = windowElement->GetAttribute(NS_LITERAL_STRING("zlevel"), stateString);
  if (NS_SUCCEEDED(rv) && stateString.Length() > 0) {
    PRInt32  errorCode;
    PRUint32 zLevel = stateString.ToInteger(&errorCode);
    if (NS_SUCCEEDED(errorCode) && zLevel >= lowestZ && zLevel <= highestZ)
      SetZLevel(zLevel);
  }

  return gotState;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1017 of file nsXULWindow.cpp.

{
  nsresult rv;
  PRBool   gotPosition = PR_FALSE;
  
  // if we're the hidden window, don't try to validate our size/position. We're
  // special.
  if (mIsHiddenWindow)
    return PR_FALSE;

  nsCOMPtr<nsIDOMElement> windowElement;
  GetWindowDOMElement(getter_AddRefs(windowElement));
  NS_ASSERTION(windowElement, "no xul:window");
  if (!windowElement)
    return PR_FALSE;

  PRInt32 currX = 0;
  PRInt32 currY = 0;
  PRInt32 currWidth = 0;
  PRInt32 currHeight = 0;
  PRInt32 errorCode;
  PRInt32 temp;

  GetPositionAndSize(&currX, &currY, &currWidth, &currHeight);

  // Obtain the position information from the <xul:window> element.
  PRInt32 specX = currX;
  PRInt32 specY = currY;
  nsAutoString posString;

  rv = windowElement->GetAttribute(NS_LITERAL_STRING("screenX"), posString);
  if (NS_SUCCEEDED(rv)) {
    temp = posString.ToInteger(&errorCode);
    if (NS_SUCCEEDED(errorCode)) {
      specX = temp;
      gotPosition = PR_TRUE;
    }
  }
  rv = windowElement->GetAttribute(NS_LITERAL_STRING("screenY"), posString);
  if (NS_SUCCEEDED(rv)) {
    temp = posString.ToInteger(&errorCode);
    if (NS_SUCCEEDED(errorCode)) {
      specY = temp;
      gotPosition = PR_TRUE;
    }
  }
    
  if (gotPosition) {
    // our position will be relative to our parent, if any
    nsCOMPtr<nsIBaseWindow> parent(do_QueryReferent(mParentWindow));
    if (parent) {
      PRInt32 parentX, parentY;
      if (NS_SUCCEEDED(parent->GetPosition(&parentX, &parentY))) {
        specX += parentX;
        specY += parentY;
      }
    } else
      StaggerPosition(specX, specY, currWidth, currHeight);
  }
  mWindow->ConstrainPosition(PR_FALSE, &specX, &specY);
  if (specX != currX || specY != currY)
    SetPosition(specX, specY);

  return gotPosition;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1083 of file nsXULWindow.cpp.

{
  nsresult rv;
  PRBool   gotSize = PR_FALSE;
  
  // if we're the hidden window, don't try to validate our size/position. We're
  // special.
  if (mIsHiddenWindow)
    return PR_FALSE;

  nsCOMPtr<nsIDOMElement> windowElement;
  GetWindowDOMElement(getter_AddRefs(windowElement));
  NS_ASSERTION(windowElement, "no xul:window");
  if (!windowElement)
    return PR_FALSE;

  PRInt32 currWidth = 0;
  PRInt32 currHeight = 0;
  PRInt32 errorCode;
  PRInt32 temp;

  GetSize(&currWidth, &currHeight);

  // Obtain the position and sizing information from the <xul:window> element.
  PRInt32 specWidth = currWidth;
  PRInt32 specHeight = currHeight;
  nsAutoString sizeString;

  rv = windowElement->GetAttribute(NS_LITERAL_STRING("width"), sizeString);
  if (NS_SUCCEEDED(rv)) {
    temp = sizeString.ToInteger(&errorCode);
    if (NS_SUCCEEDED(errorCode) && temp > 0) {
      specWidth = temp > 100 ? temp : 100;
      gotSize = PR_TRUE;
    }
  }
  rv = windowElement->GetAttribute(NS_LITERAL_STRING("height"), sizeString);
  if (NS_SUCCEEDED(rv)) {
    temp = sizeString.ToInteger(&errorCode);
    if (NS_SUCCEEDED(errorCode) && temp > 0) {
      specHeight = temp > 100 ? temp : 100;
      gotSize = PR_TRUE;
    }
  }

  if (gotSize) {
    // constrain to screen size
    nsCOMPtr<nsIDOMWindowInternal> domWindow;
    GetWindowDOMWindow(getter_AddRefs(domWindow));
    if (domWindow) {
      nsCOMPtr<nsIDOMScreen> screen;
      domWindow->GetScreen(getter_AddRefs(screen));
      if (screen) {
        PRInt32 screenWidth;
        PRInt32 screenHeight;
        screen->GetAvailWidth(&screenWidth);
        screen->GetAvailHeight(&screenHeight);
        if (specWidth > screenWidth)
          specWidth = screenWidth;
        if (specHeight > screenHeight)
          specHeight = screenHeight;
      }
    }

    mIntrinsicallySized = PR_FALSE;
    if (specWidth != currWidth || specHeight != currHeight)
      SetSize(specWidth, specHeight, PR_FALSE);
  }

  return gotSize;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1332 of file nsXULWindow.cpp.

{
  if (mWindow->GetWindowClass(nsnull)==NS_ERROR_NOT_IMPLEMENTED)
    return NS_OK;

  nsCOMPtr<nsIDOMElement> docShellElement;
  GetWindowDOMElement(getter_AddRefs(docShellElement));
  NS_ENSURE_TRUE(docShellElement, NS_ERROR_FAILURE);

  nsAutoString windowClass;

  docShellElement->GetAttribute(NS_LITERAL_STRING("windowtype"),
                                windowClass);

  if (!windowClass.IsEmpty())
  {
    PRBool persistPosition;
    PRBool persistSize;
    PRBool persistSizeMode;

    if (NS_SUCCEEDED(
         mContentTreeOwner->
           GetPersistence(&persistPosition, &persistSize, &persistSizeMode)
        ) && !persistPosition && !persistSize && !persistSizeMode)
      windowClass.AppendLiteral("-jsSpamPopupCrap");

    char *windowClass_cstr = ToNewCString(windowClass);
    mWindow->SetWindowClass(windowClass_cstr);
    nsMemory::Free(windowClass_cstr);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_DECL_ISUPPORTS NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIXULWINDOW NS_DECL_NSIBASEWINDOW void nsXULWindow::LockUntilChromeLoad ( ) [inline]

Definition at line 97 of file nsXULWindow.h.

Here is the caller graph for this function:

nsXULWindow::NS_HIDDEN_ ( nsresult  ) [protected]
nsXULWindow::NS_HIDDEN_ ( nsresult  ) [protected]

Definition at line 953 of file nsXULWindow.cpp.

{
  nsresult rv = EnsureContentTreeOwner();

  if (NS_SUCCEEDED(rv)) {
    mChromeLoaded = PR_TRUE;
    ApplyChromeFlags();

    LoadChromeHidingFromXUL();
    LoadWindowClassFromXUL();
    LoadIconFromXUL();
    LoadSizeFromXUL();
    if(mIntrinsicallySized) {
      // (if LoadSizeFromXUL set the size, mIntrinsicallySized will be false)
      nsCOMPtr<nsIContentViewer> cv;
      mDocShell->GetContentViewer(getter_AddRefs(cv));
      nsCOMPtr<nsIMarkupDocumentViewer> markupViewer(do_QueryInterface(cv));
      if(markupViewer)
        markupViewer->SizeToContent();
    }

    PRBool positionSet = PR_TRUE;
    nsCOMPtr<nsIXULWindow> parentWindow(do_QueryReferent(mParentWindow));
#if defined(XP_UNIX) && !defined(XP_MACOSX)
    // don't override WM placement on unix for independent, top-level windows
    // (however, we think the benefits of intelligent dependent window placement
    // trump that override.)
    if (!parentWindow)
      positionSet = PR_FALSE;
#endif
    if (positionSet)
      positionSet = LoadPositionFromXUL();
    LoadMiscPersistentAttributesFromXUL();

    //LoadContentAreas();

    if (mCenterAfterLoad && !positionSet)
      Center(parentWindow, parentWindow ? PR_FALSE : PR_TRUE, PR_FALSE);

    if(mShowAfterLoad)
      SetVisibility(PR_TRUE);
  }
  mPersistentAttributesMask |= PAD_POSITION | PAD_SIZE | PAD_MISC;
}

Here is the call graph for this function:

Definition at line 2055 of file nsXULWindow.cpp.

Here is the caller graph for this function:

void nsXULWindow::PlaceWindowLayersBehind ( PRUint32  aLowLevel,
PRUint32  aHighLevel,
nsIXULWindow aBehind 
) [protected]

Definition at line 1981 of file nsXULWindow.cpp.

                                                                 {

  // step through windows in z-order from top to bottommost window

  nsCOMPtr<nsIWindowMediator> mediator(do_GetService(kWindowMediatorCID));
  if(!mediator)
    return;

  nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
  mediator->GetZOrderXULWindowEnumerator(0, PR_TRUE,
              getter_AddRefs(windowEnumerator));
  if (!windowEnumerator)
    return;

  // each window will be moved behind previousHighWidget, itself
  // a moving target. initialize it.
  nsCOMPtr<nsIWidget> previousHighWidget;
  if (aBehind) {
    nsCOMPtr<nsIBaseWindow> highBase(do_QueryInterface(aBehind));
    if (highBase)
      highBase->GetMainWidget(getter_AddRefs(previousHighWidget));
  }

  // get next lower window
  PRBool more;
  while (windowEnumerator->HasMoreElements(&more), more) {
    PRUint32 nextZ; // z-level of nextWindow
    nsCOMPtr<nsISupports> nextWindow;
    windowEnumerator->GetNext(getter_AddRefs(nextWindow));
    nsCOMPtr<nsIXULWindow> nextXULWindow(do_QueryInterface(nextWindow));
    nextXULWindow->GetZLevel(&nextZ);
    if (nextZ < aLowLevel)
      break; // we've processed all windows through aLowLevel
    
    // move it just below its next higher window
    nsCOMPtr<nsIBaseWindow> nextBase(do_QueryInterface(nextXULWindow));
    if (nextBase) {
      nsCOMPtr<nsIWidget> nextWidget;
      nextBase->GetMainWidget(getter_AddRefs(nextWidget));
      if (nextZ <= aHighLevel)
        nextWidget->PlaceBehind(eZPlacementBelow, previousHighWidget, PR_FALSE);
      previousHighWidget = nextWidget;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tell this window that it has lost a child XUL window.

Parameters:
aChildthe child window being removed
void nsIBaseWindow::repaint ( in boolean  force) [inherited]

Tell the window to repaint itself.

Parameters:
aForce- if true, repaint immediately if false, the window may defer repainting as it sees fit.

Definition at line 1426 of file nsXULWindow.cpp.

{
  // can happen when the persistence timer fires at an inopportune time
  // during window shutdown
  if (!mDocShell)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIDOMElement> docShellElement;
  GetWindowDOMElement(getter_AddRefs(docShellElement));
  if(!docShellElement)
    return NS_ERROR_FAILURE;

  nsAutoString   persistString;
  docShellElement->GetAttribute(PERSIST_ATTRIBUTE, persistString);
  if (persistString.IsEmpty()) { // quick check which sometimes helps
    mPersistentAttributesDirty = 0;
    return NS_OK;
  }

  PRInt32 x, y, cx, cy;
  PRInt32 sizeMode;

  // get our size, position and mode to persist
  NS_ENSURE_SUCCESS(GetPositionAndSize(&x, &y, &cx, &cy), NS_ERROR_FAILURE);
  mWindow->GetSizeMode(&sizeMode);

  // make our position relative to our parent, if any
  nsCOMPtr<nsIBaseWindow> parent(do_QueryReferent(mParentWindow));
  if (parent) {
    PRInt32 parentX, parentY;
    if (NS_SUCCEEDED(parent->GetPosition(&parentX, &parentY))) {
      x -= parentX;
      y -= parentY;
    }
  }

  char                        sizeBuf[10];
  nsAutoString                sizeString;
  nsAutoString                windowElementId;
  nsCOMPtr<nsIDOMXULDocument> ownerXULDoc;

  { // fetch docShellElement's ID and XUL owner document
    nsCOMPtr<nsIDOMDocument> ownerDoc;
    docShellElement->GetOwnerDocument(getter_AddRefs(ownerDoc));
    ownerXULDoc = do_QueryInterface(ownerDoc);
    nsCOMPtr<nsIDOMXULElement> XULElement(do_QueryInterface(docShellElement));
    if (XULElement)
      XULElement->GetId(windowElementId);
  }

  // (only for size elements which are persisted)
  if ((mPersistentAttributesDirty & PAD_POSITION) &&
      sizeMode == nsSizeMode_Normal) {
    if(persistString.Find("screenX") >= 0) {
      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)x);
      sizeString.AssignWithConversion(sizeBuf);
      docShellElement->SetAttribute(SCREENX_ATTRIBUTE, sizeString);
      if (ownerXULDoc) // force persistence in case the value didn't change
        ownerXULDoc->Persist(windowElementId, SCREENX_ATTRIBUTE);
    }
    if(persistString.Find("screenY") >= 0) {
      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)y);
      sizeString.AssignWithConversion(sizeBuf);
      docShellElement->SetAttribute(SCREENY_ATTRIBUTE, sizeString);
      if (ownerXULDoc)
        ownerXULDoc->Persist(windowElementId, SCREENY_ATTRIBUTE);
    }
  }

  if ((mPersistentAttributesDirty & PAD_SIZE) &&
      sizeMode == nsSizeMode_Normal) {
    if(persistString.Find("width") >= 0) {
      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)cx);
      sizeString.AssignWithConversion(sizeBuf);
      docShellElement->SetAttribute(WIDTH_ATTRIBUTE, sizeString);
      if (ownerXULDoc)
        ownerXULDoc->Persist(windowElementId, WIDTH_ATTRIBUTE);
    }
    if(persistString.Find("height") >= 0) {
      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%ld", (long)cy);
      sizeString.AssignWithConversion(sizeBuf);
      docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString);
      if (ownerXULDoc)
        ownerXULDoc->Persist(windowElementId, HEIGHT_ATTRIBUTE);
    }
  }

  if (mPersistentAttributesDirty & PAD_MISC) {
    if (sizeMode != nsSizeMode_Minimized &&
        persistString.Find("sizemode") >= 0) {
      if (sizeMode == nsSizeMode_Maximized)
        sizeString.Assign(SIZEMODE_MAXIMIZED);
      else
        sizeString.Assign(SIZEMODE_NORMAL);
      docShellElement->SetAttribute(MODE_ATTRIBUTE, sizeString);
      if (ownerXULDoc)
        ownerXULDoc->Persist(windowElementId, MODE_ATTRIBUTE);
    }
    if (persistString.Find("zlevel") >= 0) {
      PRUint32 zLevel;
      nsCOMPtr<nsIWindowMediator> mediator(do_GetService(kWindowMediatorCID));
      if (mediator) {
        mediator->GetZLevel(this, &zLevel);
        PR_snprintf(sizeBuf, sizeof(sizeBuf), "%lu", (unsigned long)zLevel);
        sizeString.AssignWithConversion(sizeBuf);
        docShellElement->SetAttribute(ZLEVEL_ATTRIBUTE, sizeString);
        ownerXULDoc->Persist(windowElementId, ZLEVEL_ATTRIBUTE);
      }
    }
  }

  mPersistentAttributesDirty = 0;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2029 of file nsXULWindow.cpp.

                                                               {

  nsCOMPtr<nsIDOMWindow> contentWin(do_GetInterface(mPrimaryContentShell));
  if (contentWin) {
    nsCOMPtr<nsIDOMBarProp> scrollbars;
    contentWin->GetScrollbars(getter_AddRefs(scrollbars));
    if (scrollbars)
      scrollbars->SetVisible(aVisible);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIBaseWindow::setFocus ( ) [inherited]

Give the window focus.

void nsIBaseWindow::setPosition ( in long  x,
in long  y 
) [inherited]
void nsIBaseWindow::setPositionAndSize ( in long  x,
in long  y,
in long  cx,
in long  cy,
in boolean  fRepaint 
) [inherited]
void nsIBaseWindow::setSize ( in long  cx,
in long  cy,
in boolean  fRepaint 
) [inherited]
void nsIXULWindow::showModal ( ) [inherited]

Shows the window as a modal window.

That is, ensures that it is visible and runs a local event loop, exiting only once the window has been closed.

NS_IMETHODIMP nsXULWindow::SizeShellTo ( nsIDocShellTreeItem aShellItem,
PRInt32  aCX,
PRInt32  aCY 
) [protected]

Definition at line 1692 of file nsXULWindow.cpp.

{
   // XXXTAB This is wrong, we should actually reflow based on the passed in'
   // shell.  For now we are hacking and doing delta sizing.  This is bad
   // because it assumes all size we add will go to the shell which probably
   // won't happen.

   nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(aShellItem));
   NS_ENSURE_TRUE(shellAsWin, NS_ERROR_FAILURE);

   PRInt32 width = 0;
   PRInt32 height = 0;
   shellAsWin->GetSize(&width, &height);

   PRInt32 widthDelta = aCX - width;
   PRInt32 heightDelta = aCY - height;

   if(widthDelta || heightDelta)
      {
      PRInt32 winCX = 0;
      PRInt32 winCY = 0;

      GetSize(&winCX, &winCY);
      SetSize(winCX + widthDelta, winCY + heightDelta, PR_TRUE);
      }

   return NS_OK;
}

Here is the call graph for this function:

void nsXULWindow::StaggerPosition ( PRInt32 aRequestedX,
PRInt32 aRequestedY,
PRInt32  aSpecWidth,
PRInt32  aSpecHeight 
) [protected]

Definition at line 1218 of file nsXULWindow.cpp.

{
  const PRInt32 kOffset = 22;
  const PRInt32 kSlop = 4;
  nsresult rv;
  PRBool   keepTrying;
  int      bouncedX = 0, // bounced off vertical edge of screen
           bouncedY = 0; // bounced off horizontal edge

  // look for any other windows of this type
  nsCOMPtr<nsIWindowMediator> wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
  if (!wm)
    return;

  nsCOMPtr<nsIDOMElement> windowElement;
  GetWindowDOMElement(getter_AddRefs(windowElement));
  nsCOMPtr<nsIXULWindow> ourXULWindow(this);

  nsAutoString windowType;
  rv = windowElement->GetAttribute(WINDOWTYPE_ATTRIBUTE, windowType);
  if (NS_FAILED(rv))
    return;

  PRInt32 screenTop = 0,    // it's pointless to initialize these ...
          screenRight = 0,  // ... but to prevent oversalubrious and ...
          screenBottom = 0, // ... underbright compilers from ...
          screenLeft = 0;   // ... issuing warnings.
  PRBool  gotScreen = PR_FALSE;

  { // fetch screen coordinates
    nsCOMPtr<nsIScreenManager> screenMgr(do_GetService(
                                         "@mozilla.org/gfx/screenmanager;1"));
    if (screenMgr) {
      nsCOMPtr<nsIScreen> ourScreen;
      screenMgr->ScreenForRect(aRequestedX, aRequestedY,
                               aSpecWidth, aSpecHeight,
                               getter_AddRefs(ourScreen));
      if (ourScreen) {
        PRInt32 screenWidth, screenHeight;
        ourScreen->GetAvailRect(&screenLeft, &screenTop,
                                &screenWidth, &screenHeight);
        screenBottom = screenTop + screenHeight;
        screenRight = screenLeft + screenWidth;
        gotScreen = PR_TRUE;
      }
    }
  }

  // one full pass through all windows of this type. repeat until
  // no collisions.
  do {
    keepTrying = PR_FALSE;
    nsCOMPtr<nsISimpleEnumerator> windowList;
    wm->GetXULWindowEnumerator(windowType.get(), getter_AddRefs(windowList));

    if (!windowList)
      break;

    // one full pass through all windows of this type. offset and stop
    // on collision.
    do {
      PRBool more;
      PRInt32 listX, listY;
      windowList->HasMoreElements(&more);
      if (!more)
        break;

      nsCOMPtr<nsISupports> supportsWindow;
      windowList->GetNext(getter_AddRefs(supportsWindow));

      nsCOMPtr<nsIXULWindow> listXULWindow(do_QueryInterface(supportsWindow));
      nsCOMPtr<nsIBaseWindow> listBaseWindow(do_QueryInterface(supportsWindow));

      if (listXULWindow != ourXULWindow) {
        listBaseWindow->GetPosition(&listX, &listY);

        if (PR_ABS(listX-aRequestedX) <= kSlop &&
            PR_ABS(listY-aRequestedY) <= kSlop) {
          // collision! offset and start over
          if (bouncedX & 0x1)
            aRequestedX -= kOffset;
          else
            aRequestedX += kOffset;
          aRequestedY += kOffset;

          if (gotScreen) {
            // bounce off left and right edges
            if (!(bouncedX & 0x1) && aRequestedX + aSpecWidth > screenRight) {
              aRequestedX = screenRight - aSpecWidth;
              ++bouncedX;
            }
            if ((bouncedX & 0x1) && aRequestedX < screenLeft) {
              aRequestedX = screenLeft;
              ++bouncedX;
            }
            // hit the bottom and start again at the top
            if (aRequestedY + aSpecHeight > screenBottom) {
              aRequestedY = screenTop;
              ++bouncedY;
            }
          }

          /* loop around again,
             but it's time to give up once we've covered the screen.
             there's a potential infinite loop with lots of windows. */
          keepTrying = bouncedX < 2 || bouncedY == 0;
          break;
        }
      }
    } while(1);
  } while (keepTrying);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsChromeTreeOwner [friend]

Definition at line 85 of file nsXULWindow.h.

friend class nsContentTreeOwner [friend]

Definition at line 86 of file nsXULWindow.h.


Member Data Documentation

PRBool PRBool const nsAString& nsXULWindow::aID [protected]

Definition at line 133 of file nsXULWindow.h.

Definition at line 133 of file nsXULWindow.h.

Definition at line 133 of file nsXULWindow.h.

set blurSuppression to true to suppress handling of blur events.

set it false to re-enable them. query it to determine whether blur events are suppressed. The implementation should allow for blur events to be suppressed multiple times.

Definition at line 205 of file nsIBaseWindow.idl.

Definition at line 131 of file nsIXULWindow.idl.

contextFlags are from nsIWindowCreator2

Definition at line 129 of file nsIXULWindow.idl.

The docshell owning the XUL for this window.

Definition at line 60 of file nsIXULWindow.idl.

Definition at line 198 of file nsIBaseWindow.idl.

const unsigned long nsIXULWindow::highestZ = 9 [inherited]

Definition at line 122 of file nsIXULWindow.idl.

Indicates if this window is instrinsically sized.

Definition at line 65 of file nsIXULWindow.idl.

const unsigned long nsIXULWindow::loweredZ = 4 [inherited]

Definition at line 119 of file nsIXULWindow.idl.

const unsigned long nsIXULWindow::lowestZ = 0 [inherited]

Definition at line 118 of file nsIXULWindow.idl.

Definition at line 212 of file nsIBaseWindow.idl.

Definition at line 162 of file nsXULWindow.h.

Definition at line 176 of file nsXULWindow.h.

Definition at line 172 of file nsXULWindow.h.

Definition at line 179 of file nsXULWindow.h.

Definition at line 169 of file nsXULWindow.h.

Definition at line 154 of file nsXULWindow.h.

Definition at line 165 of file nsXULWindow.h.

Definition at line 155 of file nsXULWindow.h.

Definition at line 175 of file nsXULWindow.h.

Definition at line 167 of file nsXULWindow.h.

Definition at line 168 of file nsXULWindow.h.

Definition at line 158 of file nsXULWindow.h.

Definition at line 159 of file nsXULWindow.h.

Definition at line 171 of file nsXULWindow.h.

Definition at line 173 of file nsXULWindow.h.

Definition at line 174 of file nsXULWindow.h.

Definition at line 166 of file nsXULWindow.h.

Definition at line 160 of file nsXULWindow.h.

Definition at line 177 of file nsXULWindow.h.

Definition at line 178 of file nsXULWindow.h.

Definition at line 164 of file nsXULWindow.h.

Definition at line 156 of file nsXULWindow.h.

Definition at line 161 of file nsXULWindow.h.

Definition at line 170 of file nsXULWindow.h.

Definition at line 182 of file nsXULWindow.h.

Definition at line 180 of file nsXULWindow.h.

Definition at line 157 of file nsXULWindow.h.

Definition at line 163 of file nsXULWindow.h.

const unsigned long nsIXULWindow::normalZ = 5 [inherited]

Definition at line 120 of file nsIXULWindow.idl.

Definition at line 185 of file nsIBaseWindow.idl.

Definition at line 174 of file nsIBaseWindow.idl.

The primary content shell.

Note that this is a docshell tree item and therefore can not be assured of what object it is. It could be an editor, a docshell, or a browser object. Or down the road any other object that supports being a DocShellTreeItem Query accordingly to determine the capabilities.

Definition at line 75 of file nsIXULWindow.idl.

const unsigned long nsIXULWindow::raisedZ = 6 [inherited]

Definition at line 121 of file nsIXULWindow.idl.

attribute wstring nsIBaseWindow::title [inherited]

Definition at line 222 of file nsIBaseWindow.idl.

Definition at line 192 of file nsIBaseWindow.idl.

Definition at line 140 of file nsIXULWindow.idl.

attribute unsigned long nsIXULWindow::zLevel [inherited]

Definition at line 124 of file nsIXULWindow.idl.


The documentation for this class was generated from the following files: