LCOV - code coverage report
Current view: directory - dom/base - nsPIDOMWindow.h (source / functions) Found Hit Coverage
Test: app.info Lines: 100 0 0.0 %
Date: 2012-06-02 Functions: 27 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim: set ts=2 sw=2 et tw=80: */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is mozilla.org code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : 
      40                 : #ifndef nsPIDOMWindow_h__
      41                 : #define nsPIDOMWindow_h__
      42                 : 
      43                 : #include "nsIDOMWindow.h"
      44                 : 
      45                 : #include "nsIDOMLocation.h"
      46                 : #include "nsIDOMXULCommandDispatcher.h"
      47                 : #include "nsIDOMElement.h"
      48                 : #include "nsIDOMEventTarget.h"
      49                 : #include "nsIDOMDocument.h"
      50                 : #include "nsCOMPtr.h"
      51                 : #include "nsEvent.h"
      52                 : #include "nsIURI.h"
      53                 : 
      54                 : #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed"
      55                 : #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen"
      56                 : #define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed"
      57                 : 
      58                 : class nsIPrincipal;
      59                 : 
      60                 : // Popup control state enum. The values in this enum must go from most
      61                 : // permissive to least permissive so that it's safe to push state in
      62                 : // all situations. Pushing popup state onto the stack never makes the
      63                 : // current popup state less permissive (see
      64                 : // nsGlobalWindow::PushPopupControlState()).
      65                 : enum PopupControlState {
      66                 :   openAllowed = 0,  // open that window without worries
      67                 :   openControlled,   // it's a popup, but allow it
      68                 :   openAbused,       // it's a popup. disallow it, but allow domain override.
      69                 :   openOverridden    // disallow window open
      70                 : };
      71                 : 
      72                 : class nsIDocShell;
      73                 : class nsIContent;
      74                 : class nsIDocument;
      75                 : class nsIScriptTimeoutHandler;
      76                 : struct nsTimeout;
      77                 : template <class> class nsScriptObjectHolder;
      78                 : class nsXBLPrototypeHandler;
      79                 : class nsIArray;
      80                 : class nsPIWindowRoot;
      81                 : 
      82                 : #define NS_PIDOMWINDOW_IID \
      83                 : { 0x9aef58e9, 0x5225, 0x4e58, \
      84                 :   { 0x9a, 0xfb, 0xe6, 0x63, 0x97, 0x1d, 0x86, 0x88 } }
      85                 : 
      86                 : class nsPIDOMWindow : public nsIDOMWindowInternal
      87                 : {
      88                 : public:
      89                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOW_IID)
      90                 : 
      91                 :   virtual nsPIDOMWindow* GetPrivateRoot() = 0;
      92                 : 
      93                 :   virtual void ActivateOrDeactivate(bool aActivate) = 0;
      94                 : 
      95                 :   // this is called GetTopWindowRoot to avoid conflicts with nsIDOMWindow::GetWindowRoot
      96                 :   virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() = 0;
      97                 : 
      98               0 :   virtual void SetActive(bool aActive)
      99                 :   {
     100               0 :     NS_PRECONDITION(IsOuterWindow(),
     101                 :                     "active state is only maintained on outer windows");
     102               0 :     mIsActive = aActive;
     103               0 :   }
     104                 : 
     105                 :   bool IsActive()
     106                 :   {
     107                 :     NS_PRECONDITION(IsOuterWindow(),
     108                 :                     "active state is only maintained on outer windows");
     109                 :     return mIsActive;
     110                 :   }
     111                 : 
     112               0 :   virtual void SetIsBackground(bool aIsBackground)
     113                 :   {
     114               0 :     NS_PRECONDITION(IsOuterWindow(),
     115                 :                     "background state is only maintained on outer windows");
     116               0 :     mIsBackground = aIsBackground;
     117               0 :   }
     118                 : 
     119               0 :   bool IsBackground()
     120                 :   {
     121               0 :     NS_PRECONDITION(IsOuterWindow(),
     122                 :                     "background state is only maintained on outer windows");
     123               0 :     return mIsBackground;
     124                 :   }
     125                 : 
     126               0 :   nsIDOMEventTarget* GetChromeEventHandler() const
     127                 :   {
     128               0 :     return mChromeEventHandler;
     129                 :   }
     130                 : 
     131                 :   virtual void SetChromeEventHandler(nsIDOMEventTarget* aChromeEventHandler) = 0;
     132                 : 
     133               0 :   nsIDOMEventTarget* GetParentTarget()
     134                 :   {
     135               0 :     if (!mParentTarget) {
     136               0 :       UpdateParentTarget();
     137                 :     }
     138               0 :     return mParentTarget;
     139                 :   }
     140                 : 
     141                 :   bool HasMutationListeners(PRUint32 aMutationEventType) const
     142                 :   {
     143                 :     const nsPIDOMWindow *win;
     144                 : 
     145                 :     if (IsOuterWindow()) {
     146                 :       win = GetCurrentInnerWindow();
     147                 : 
     148                 :       if (!win) {
     149                 :         NS_ERROR("No current inner window available!");
     150                 : 
     151                 :         return false;
     152                 :       }
     153                 :     } else {
     154                 :       if (!mOuterWindow) {
     155                 :         NS_ERROR("HasMutationListeners() called on orphan inner window!");
     156                 : 
     157                 :         return false;
     158                 :       }
     159                 : 
     160                 :       win = this;
     161                 :     }
     162                 : 
     163                 :     return (win->mMutationBits & aMutationEventType) != 0;
     164                 :   }
     165                 : 
     166               0 :   void SetMutationListeners(PRUint32 aType)
     167                 :   {
     168                 :     nsPIDOMWindow *win;
     169                 : 
     170               0 :     if (IsOuterWindow()) {
     171               0 :       win = GetCurrentInnerWindow();
     172                 : 
     173               0 :       if (!win) {
     174               0 :         NS_ERROR("No inner window available to set mutation bits on!");
     175                 : 
     176               0 :         return;
     177                 :       }
     178                 :     } else {
     179               0 :       if (!mOuterWindow) {
     180               0 :         NS_ERROR("HasMutationListeners() called on orphan inner window!");
     181                 : 
     182               0 :         return;
     183                 :       }
     184                 : 
     185               0 :       win = this;
     186                 :     }
     187                 : 
     188               0 :     win->mMutationBits |= aType;
     189                 :   }
     190                 : 
     191               0 :   virtual void MaybeUpdateTouchState() {}
     192               0 :   virtual void UpdateTouchState() {}
     193                 : 
     194                 :   // GetExtantDocument provides a backdoor to the DOM GetDocument accessor
     195               0 :   nsIDOMDocument* GetExtantDocument() const
     196                 :   {
     197               0 :     return mDocument;
     198                 :   }
     199                 : 
     200                 :   // Internal getter/setter for the frame element, this version of the
     201                 :   // getter crosses chrome boundaries whereas the public scriptable
     202                 :   // one doesn't for security reasons.
     203               0 :   nsIDOMElement* GetFrameElementInternal() const
     204                 :   {
     205               0 :     if (mOuterWindow) {
     206               0 :       return mOuterWindow->GetFrameElementInternal();
     207                 :     }
     208                 : 
     209               0 :     NS_ASSERTION(!IsInnerWindow(),
     210                 :                  "GetFrameElementInternal() called on orphan inner window");
     211                 : 
     212               0 :     return mFrameElement;
     213                 :   }
     214                 : 
     215                 :   void SetFrameElementInternal(nsIDOMElement *aFrameElement)
     216                 :   {
     217                 :     if (IsOuterWindow()) {
     218                 :       mFrameElement = aFrameElement;
     219                 : 
     220                 :       return;
     221                 :     }
     222                 : 
     223                 :     if (!mOuterWindow) {
     224                 :       NS_ERROR("frameElement set on inner window with no outer!");
     225                 : 
     226                 :       return;
     227                 :     }
     228                 : 
     229                 :     mOuterWindow->SetFrameElementInternal(aFrameElement);
     230                 :   }
     231                 : 
     232                 :   bool IsLoadingOrRunningTimeout() const
     233                 :   {
     234                 :     const nsPIDOMWindow *win = GetCurrentInnerWindow();
     235                 : 
     236                 :     if (!win) {
     237                 :       win = this;
     238                 :     }
     239                 : 
     240                 :     return !win->mIsDocumentLoaded || win->mRunningTimeout;
     241                 :   }
     242                 : 
     243                 :   // Check whether a document is currently loading
     244                 :   bool IsLoading() const
     245                 :   {
     246                 :     const nsPIDOMWindow *win;
     247                 : 
     248                 :     if (IsOuterWindow()) {
     249                 :       win = GetCurrentInnerWindow();
     250                 : 
     251                 :       if (!win) {
     252                 :         NS_ERROR("No current inner window available!");
     253                 : 
     254                 :         return false;
     255                 :       }
     256                 :     } else {
     257                 :       if (!mOuterWindow) {
     258                 :         NS_ERROR("IsLoading() called on orphan inner window!");
     259                 : 
     260                 :         return false;
     261                 :       }
     262                 : 
     263                 :       win = this;
     264                 :     }
     265                 : 
     266                 :     return !win->mIsDocumentLoaded;
     267                 :   }
     268                 : 
     269               0 :   bool IsHandlingResizeEvent() const
     270                 :   {
     271                 :     const nsPIDOMWindow *win;
     272                 : 
     273               0 :     if (IsOuterWindow()) {
     274               0 :       win = GetCurrentInnerWindow();
     275                 : 
     276               0 :       if (!win) {
     277               0 :         NS_ERROR("No current inner window available!");
     278                 : 
     279               0 :         return false;
     280                 :       }
     281                 :     } else {
     282               0 :       if (!mOuterWindow) {
     283               0 :         NS_ERROR("IsHandlingResizeEvent() called on orphan inner window!");
     284                 : 
     285               0 :         return false;
     286                 :       }
     287                 : 
     288               0 :       win = this;
     289                 :     }
     290                 : 
     291               0 :     return win->mIsHandlingResizeEvent;
     292                 :   }
     293                 : 
     294                 :   // Tell this window who opened it.  This only has an effect if there is
     295                 :   // either no document currently in the window or if the document is the
     296                 :   // original document this window came with (an about:blank document either
     297                 :   // preloaded into it when it was created, or created by
     298                 :   // CreateAboutBlankContentViewer()).
     299                 :   virtual void SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal) = 0;
     300                 :   // Ask this window who opened it.
     301                 :   virtual nsIPrincipal* GetOpenerScriptPrincipal() = 0;
     302                 : 
     303                 :   virtual PopupControlState PushPopupControlState(PopupControlState aState,
     304                 :                                                   bool aForce) const = 0;
     305                 :   virtual void PopPopupControlState(PopupControlState state) const = 0;
     306                 :   virtual PopupControlState GetPopupControlState() const = 0;
     307                 : 
     308                 :   // Returns an object containing the window's state.  This also suspends
     309                 :   // all running timeouts in the window.
     310                 :   virtual nsresult SaveWindowState(nsISupports **aState) = 0;
     311                 : 
     312                 :   // Restore the window state from aState.
     313                 :   virtual nsresult RestoreWindowState(nsISupports *aState) = 0;
     314                 : 
     315                 :   // Suspend timeouts in this window and in child windows.
     316                 :   virtual void SuspendTimeouts(PRUint32 aIncrease = 1,
     317                 :                                bool aFreezeChildren = true) = 0;
     318                 : 
     319                 :   // Resume suspended timeouts in this window and in child windows.
     320                 :   virtual nsresult ResumeTimeouts(bool aThawChildren = true) = 0;
     321                 : 
     322                 :   virtual PRUint32 TimeoutSuspendCount() = 0;
     323                 : 
     324                 :   // Fire any DOM notification events related to things that happened while
     325                 :   // the window was frozen.
     326                 :   virtual nsresult FireDelayedDOMEvents() = 0;
     327                 : 
     328                 :   virtual bool IsFrozen() const = 0;
     329                 : 
     330                 :   // Add a timeout to this window.
     331                 :   virtual nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
     332                 :                                         PRInt32 interval,
     333                 :                                         bool aIsInterval, PRInt32 *aReturn) = 0;
     334                 : 
     335                 :   // Clear a timeout from this window.
     336                 :   virtual nsresult ClearTimeoutOrInterval(PRInt32 aTimerID) = 0;
     337                 : 
     338               0 :   nsPIDOMWindow *GetOuterWindow()
     339                 :   {
     340               0 :     return mIsInnerWindow ? mOuterWindow.get() : this;
     341                 :   }
     342                 : 
     343               0 :   nsPIDOMWindow *GetCurrentInnerWindow() const
     344                 :   {
     345               0 :     return mInnerWindow;
     346                 :   }
     347                 : 
     348               0 :   nsPIDOMWindow *EnsureInnerWindow()
     349                 :   {
     350               0 :     NS_ASSERTION(IsOuterWindow(), "EnsureInnerWindow called on inner window");
     351                 :     // GetDocument forces inner window creation if there isn't one already
     352               0 :     nsCOMPtr<nsIDOMDocument> doc;
     353               0 :     GetDocument(getter_AddRefs(doc));
     354               0 :     return GetCurrentInnerWindow();
     355                 :   }
     356                 : 
     357               0 :   bool IsInnerWindow() const
     358                 :   {
     359               0 :     return mIsInnerWindow;
     360                 :   }
     361                 : 
     362               0 :   bool IsOuterWindow() const
     363                 :   {
     364               0 :     return !IsInnerWindow();
     365                 :   }
     366                 : 
     367                 :   virtual bool WouldReuseInnerWindow(nsIDocument *aNewDocument) = 0;
     368                 : 
     369                 :   /**
     370                 :    * Get the docshell in this window.
     371                 :    */
     372               0 :   nsIDocShell *GetDocShell()
     373                 :   {
     374               0 :     if (mOuterWindow) {
     375               0 :       return mOuterWindow->mDocShell;
     376                 :     }
     377                 : 
     378               0 :     return mDocShell;
     379                 :   }
     380                 : 
     381                 :   /**
     382                 :    * Set or unset the docshell in the window.
     383                 :    */
     384                 :   virtual void SetDocShell(nsIDocShell *aDocShell) = 0;
     385                 : 
     386                 :   /**
     387                 :    * Set a new document in the window. Calling this method will in
     388                 :    * most cases create a new inner window. If this method is called on
     389                 :    * an inner window the call will be forewarded to the outer window,
     390                 :    * if the inner window is not the current inner window an
     391                 :    * NS_ERROR_NOT_AVAILABLE error code will be returned. This may be
     392                 :    * called with a pointer to the current document, in that case the
     393                 :    * document remains unchanged, but a new inner window will be
     394                 :    * created.
     395                 :    */
     396                 :   virtual nsresult SetNewDocument(nsIDocument *aDocument,
     397                 :                                   nsISupports *aState,
     398                 :                                   bool aForceReuseInnerWindow) = 0;
     399                 : 
     400                 :   /**
     401                 :    * Set the opener window.  aOriginalOpener is true if and only if this is the
     402                 :    * original opener for the window.  That is, it can only be true at most once
     403                 :    * during the life cycle of a window, and then only the first time
     404                 :    * SetOpenerWindow is called.  It might never be true, of course, if the
     405                 :    * window does not have an opener when it's created.
     406                 :    */
     407                 :   virtual void SetOpenerWindow(nsIDOMWindow* aOpener,
     408                 :                                bool aOriginalOpener) = 0;
     409                 : 
     410                 :   virtual void EnsureSizeUpToDate() = 0;
     411                 : 
     412                 :   /**
     413                 :    * Callback for notifying a window about a modal dialog being
     414                 :    * opened/closed with the window as a parent.
     415                 :    */
     416                 :   virtual nsIDOMWindow *EnterModalState() = 0;
     417                 :   virtual void LeaveModalState(nsIDOMWindow *) = 0;
     418                 : 
     419                 :   virtual bool CanClose() = 0;
     420                 :   virtual nsresult ForceClose() = 0;
     421                 : 
     422                 :   bool IsModalContentWindow() const
     423                 :   {
     424                 :     return mIsModalContentWindow;
     425                 :   }
     426                 : 
     427                 :   /**
     428                 :    * Call this to indicate that some node (this window, its document,
     429                 :    * or content in that document) has a paint event listener.
     430                 :    */
     431               0 :   void SetHasPaintEventListeners()
     432                 :   {
     433               0 :     mMayHavePaintEventListener = true;
     434               0 :   }
     435                 : 
     436                 :   /**
     437                 :    * Call this to check whether some node (this window, its document,
     438                 :    * or content in that document) has a paint event listener.
     439                 :    */
     440                 :   bool HasPaintEventListeners()
     441                 :   {
     442                 :     return mMayHavePaintEventListener;
     443                 :   }
     444                 :   
     445                 :   /**
     446                 :    * Call this to indicate that some node (this window, its document,
     447                 :    * or content in that document) has a touch event listener.
     448                 :    */
     449               0 :   void SetHasTouchEventListeners()
     450                 :   {
     451               0 :     mMayHaveTouchEventListener = true;
     452               0 :     MaybeUpdateTouchState();
     453               0 :   }
     454                 : 
     455                 :   bool HasTouchEventListeners()
     456                 :   {
     457                 :     return mMayHaveTouchEventListener;
     458                 :   }
     459                 : 
     460                 :   /**
     461                 :    * Moves the top-level window into fullscreen mode if aIsFullScreen is true,
     462                 :    * otherwise exits fullscreen. If aRequireTrust is true, this method only
     463                 :    * changes window state in a context trusted for write.
     464                 :    */
     465                 :   virtual nsresult SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust) = 0;
     466                 : 
     467                 :   /**
     468                 :    * Call this to indicate that some node (this window, its document,
     469                 :    * or content in that document) has a "MozAudioAvailable" event listener.
     470                 :    */
     471                 :   virtual void SetHasAudioAvailableEventListeners() = 0;
     472                 : 
     473                 :   /**
     474                 :    * Call this to check whether some node (this window, its document,
     475                 :    * or content in that document) has a mouseenter/leave event listener.
     476                 :    */
     477                 :   bool HasMouseEnterLeaveEventListeners()
     478                 :   {
     479                 :     return mMayHaveMouseEnterLeaveEventListener;
     480                 :   }
     481                 : 
     482                 :   /**
     483                 :    * Call this to indicate that some node (this window, its document,
     484                 :    * or content in that document) has a mouseenter/leave event listener.
     485                 :    */
     486               0 :   void SetHasMouseEnterLeaveEventListeners()
     487                 :   {
     488               0 :     mMayHaveMouseEnterLeaveEventListener = true;
     489               0 :   }  
     490                 : 
     491                 :   /**
     492                 :    * Initialize window.java and window.Packages.
     493                 :    */
     494                 :   virtual void InitJavaProperties() = 0;
     495                 : 
     496                 :   virtual JSObject* GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey) = 0;
     497                 :   virtual void CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
     498                 :                                         nsScriptObjectHolder<JSObject>& aHandler) = 0;
     499                 : 
     500                 :   /*
     501                 :    * Get and set the currently focused element within the document. If
     502                 :    * aNeedsFocus is true, then set mNeedsFocus to true to indicate that a
     503                 :    * document focus event is needed.
     504                 :    *
     505                 :    * DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER
     506                 :    * INSTEAD.
     507                 :    */
     508               0 :   nsIContent* GetFocusedNode()
     509                 :   {
     510               0 :     if (IsOuterWindow()) {
     511               0 :       return mInnerWindow ? mInnerWindow->mFocusedNode.get() : nsnull;
     512                 :     }
     513               0 :     return mFocusedNode;
     514                 :   }
     515                 :   virtual void SetFocusedNode(nsIContent* aNode,
     516                 :                               PRUint32 aFocusMethod = 0,
     517                 :                               bool aNeedsFocus = false) = 0;
     518                 : 
     519                 :   /**
     520                 :    * Retrieves the method that was used to focus the current node.
     521                 :    */
     522                 :   virtual PRUint32 GetFocusMethod() = 0;
     523                 : 
     524                 :   /*
     525                 :    * Tells the window that it now has focus or has lost focus, based on the
     526                 :    * state of aFocus. If this method returns true, then the document loaded
     527                 :    * in the window has never received a focus event and expects to receive
     528                 :    * one. If false is returned, the document has received a focus event before
     529                 :    * and should only receive one if the window is being focused.
     530                 :    *
     531                 :    * aFocusMethod may be set to one of the focus method constants in
     532                 :    * nsIFocusManager to indicate how focus was set.
     533                 :    */
     534                 :   virtual bool TakeFocus(bool aFocus, PRUint32 aFocusMethod) = 0;
     535                 : 
     536                 :   /**
     537                 :    * Indicates that the window may now accept a document focus event. This
     538                 :    * should be called once a document has been loaded into the window.
     539                 :    */
     540                 :   virtual void SetReadyForFocus() = 0;
     541                 : 
     542                 :   /**
     543                 :    * Whether the focused content within the window should show a focus ring.
     544                 :    */
     545                 :   virtual bool ShouldShowFocusRing() = 0;
     546                 : 
     547                 :   /**
     548                 :    * Set the keyboard indicator state for accelerators and focus rings.
     549                 :    */
     550                 :   virtual void SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
     551                 :                                      UIStateChangeType aShowFocusRings) = 0;
     552                 : 
     553                 :   /**
     554                 :    * Get the keyboard indicator state for accelerators and focus rings.
     555                 :    */
     556                 :   virtual void GetKeyboardIndicators(bool* aShowAccelerators,
     557                 :                                      bool* aShowFocusRings) = 0;
     558                 : 
     559                 :   /**
     560                 :    * Indicates that the page in the window has been hidden. This is used to
     561                 :    * reset the focus state.
     562                 :    */
     563                 :   virtual void PageHidden() = 0;
     564                 : 
     565                 :   /**
     566                 :    * Instructs this window to asynchronously dispatch a hashchange event.  This
     567                 :    * method must be called on an inner window.
     568                 :    */
     569                 :   virtual nsresult DispatchAsyncHashchange(nsIURI *aOldURI,
     570                 :                                            nsIURI *aNewURI) = 0;
     571                 : 
     572                 :   /**
     573                 :    * Instructs this window to synchronously dispatch a popState event.
     574                 :    */
     575                 :   virtual nsresult DispatchSyncPopState() = 0;
     576                 : 
     577                 :   /**
     578                 :    * Tell this window that there is an observer for orientation changes
     579                 :    */
     580                 :   virtual void SetHasOrientationEventListener() = 0;
     581                 : 
     582                 :   /**
     583                 :    * Tell this window that we remove an orientation listener
     584                 :    */
     585                 :   virtual void RemoveOrientationEventListener() = 0;
     586                 : 
     587                 :   /**
     588                 :    * Set a arguments for this window. This will be set on the window
     589                 :    * right away (if there's an existing document) and it will also be
     590                 :    * installed on the window when the next document is loaded. Each
     591                 :    * language impl is responsible for converting to an array of args
     592                 :    * as appropriate for that language.
     593                 :    */
     594                 :   virtual nsresult SetArguments(nsIArray *aArguments, nsIPrincipal *aOrigin) = 0;
     595                 : 
     596                 :   /**
     597                 :    * NOTE! This function *will* be called on multiple threads so the
     598                 :    * implementation must not do any AddRef/Release or other actions that will
     599                 :    * mutate internal state.
     600                 :    */
     601                 :   virtual PRUint32 GetSerial() = 0;
     602                 : 
     603                 :   /**
     604                 :    * Return the window id of this window
     605                 :    */
     606               0 :   PRUint64 WindowID() const { return mWindowID; }
     607                 : 
     608                 :   /**
     609                 :    * Dispatch a custom event with name aEventName targeted at this window.
     610                 :    * Returns whether the default action should be performed.
     611                 :    */
     612                 :   virtual bool DispatchCustomEvent(const char *aEventName) = 0;
     613                 : 
     614                 : protected:
     615                 :   // The nsPIDOMWindow constructor. The aOuterWindow argument should
     616                 :   // be null if and only if the created window itself is an outer
     617                 :   // window. In all other cases aOuterWindow should be the outer
     618                 :   // window for the inner window that is being created.
     619                 :   nsPIDOMWindow(nsPIDOMWindow *aOuterWindow);
     620                 : 
     621                 :   ~nsPIDOMWindow();
     622                 : 
     623               0 :   void SetChromeEventHandlerInternal(nsIDOMEventTarget* aChromeEventHandler) {
     624               0 :     mChromeEventHandler = aChromeEventHandler;
     625                 :     // mParentTarget will be set when the next event is dispatched.
     626               0 :     mParentTarget = nsnull;
     627               0 :   }
     628                 : 
     629                 :   virtual void UpdateParentTarget() = 0;
     630                 : 
     631                 :   // These two variables are special in that they're set to the same
     632                 :   // value on both the outer window and the current inner window. Make
     633                 :   // sure you keep them in sync!
     634                 :   nsCOMPtr<nsIDOMEventTarget> mChromeEventHandler; // strong
     635                 :   nsCOMPtr<nsIDOMDocument> mDocument; // strong
     636                 : 
     637                 :   nsCOMPtr<nsIDOMEventTarget> mParentTarget; // strong
     638                 : 
     639                 :   // These members are only used on outer windows.
     640                 :   nsCOMPtr<nsIDOMElement> mFrameElement;
     641                 :   nsIDocShell           *mDocShell;  // Weak Reference
     642                 : 
     643                 :   PRUint32               mModalStateDepth;
     644                 : 
     645                 :   // These variables are only used on inner windows.
     646                 :   nsTimeout             *mRunningTimeout;
     647                 : 
     648                 :   PRUint32               mMutationBits;
     649                 : 
     650                 :   bool                   mIsDocumentLoaded;
     651                 :   bool                   mIsHandlingResizeEvent;
     652                 :   bool                   mIsInnerWindow;
     653                 :   bool                   mMayHavePaintEventListener;
     654                 :   bool                   mMayHaveTouchEventListener;
     655                 :   bool                   mMayHaveMouseEnterLeaveEventListener;
     656                 : 
     657                 :   // This variable is used on both inner and outer windows (and they
     658                 :   // should match).
     659                 :   bool                   mIsModalContentWindow;
     660                 : 
     661                 :   // Tracks activation state that's used for :-moz-window-inactive.
     662                 :   // Only used on outer windows.
     663                 :   bool                   mIsActive;
     664                 : 
     665                 :   // Tracks whether our docshell is active.  If it is, mIsBackground
     666                 :   // is false.  Too bad we have so many different concepts of
     667                 :   // "active".  Only used on outer windows.
     668                 :   bool                   mIsBackground;
     669                 : 
     670                 :   // And these are the references between inner and outer windows.
     671                 :   nsPIDOMWindow         *mInnerWindow;
     672                 :   nsCOMPtr<nsPIDOMWindow> mOuterWindow;
     673                 : 
     674                 :   // the element within the document that is currently focused when this
     675                 :   // window is active
     676                 :   nsCOMPtr<nsIContent> mFocusedNode;
     677                 : 
     678                 :   // A unique (as long as our 64-bit counter doesn't roll over) id for
     679                 :   // this window.
     680                 :   PRUint64 mWindowID;
     681                 : 
     682                 :   // This is only used by the inner window. Set to true once we've sent
     683                 :   // the (chrome|content)-document-global-created notification.
     684                 :   bool mHasNotifiedGlobalCreated;
     685                 : };
     686                 : 
     687                 : 
     688                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindow, NS_PIDOMWINDOW_IID)
     689                 : 
     690                 : #ifdef _IMPL_NS_LAYOUT
     691                 : PopupControlState
     692                 : PushPopupControlState(PopupControlState aState, bool aForce);
     693                 : 
     694                 : void
     695                 : PopPopupControlState(PopupControlState aState);
     696                 : 
     697                 : #define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherInternal
     698                 : #else
     699                 : #define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherExternal
     700                 : #endif
     701                 : 
     702                 : // Helper class that helps with pushing and popping popup control
     703                 : // state. Note that this class looks different from within code that's
     704                 : // part of the layout library than it does in code outside the layout
     705                 : // library.  We give the two object layouts different names so the symbols
     706                 : // don't conflict, but code should always use the name
     707                 : // |nsAutoPopupStatePusher|.
     708                 : class NS_AUTO_POPUP_STATE_PUSHER
     709                 : {
     710                 : public:
     711                 : #ifdef _IMPL_NS_LAYOUT
     712               0 :   NS_AUTO_POPUP_STATE_PUSHER(PopupControlState aState, bool aForce = false)
     713               0 :     : mOldState(::PushPopupControlState(aState, aForce))
     714                 :   {
     715               0 :   }
     716                 : 
     717               0 :   ~NS_AUTO_POPUP_STATE_PUSHER()
     718                 :   {
     719               0 :     PopPopupControlState(mOldState);
     720               0 :   }
     721                 : #else
     722               0 :   NS_AUTO_POPUP_STATE_PUSHER(nsPIDOMWindow *aWindow, PopupControlState aState)
     723               0 :     : mWindow(aWindow), mOldState(openAbused)
     724                 :   {
     725               0 :     if (aWindow) {
     726               0 :       mOldState = aWindow->PushPopupControlState(aState, false);
     727                 :     }
     728               0 :   }
     729                 : 
     730               0 :   ~NS_AUTO_POPUP_STATE_PUSHER()
     731               0 :   {
     732               0 :     if (mWindow) {
     733               0 :       mWindow->PopPopupControlState(mOldState);
     734                 :     }
     735               0 :   }
     736                 : #endif
     737                 : 
     738                 : protected:
     739                 : #ifndef _IMPL_NS_LAYOUT
     740                 :   nsCOMPtr<nsPIDOMWindow> mWindow;
     741                 : #endif
     742                 :   PopupControlState mOldState;
     743                 : 
     744                 : private:
     745                 :   // Hide so that this class can only be stack-allocated
     746                 :   static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nsnull; }
     747                 :   static void operator delete(void* /*memory*/) {}
     748                 : };
     749                 : 
     750                 : #define nsAutoPopupStatePusher NS_AUTO_POPUP_STATE_PUSHER
     751                 : 
     752                 : #endif // nsPIDOMWindow_h__

Generated by: LCOV version 1.7