LCOV - app.info - content/base/src/nsDocument.h

LCOV - code coverage report
| Current view: | directory - content/base/src - nsDocument.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 82 | 28 | 34.1 %
| Date: | 2012-04-21 | Functions: | 67 | 16 | 23.9 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is mozilla.org code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Netscape Communications Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 :
          38                 : /*
          39                 :  * Base class for all our document implementations.
          40                 :  */
          41                 :
          42                 : #ifndef nsDocument_h___
          43                 : #define nsDocument_h___
          44                 :
          45                 : #include "nsCOMPtr.h"
          46                 : #include "nsAutoPtr.h"
          47                 : #include "nsCRT.h"
          48                 : #include "nsIDocument.h"
          49                 : #include "nsWeakReference.h"
          50                 : #include "nsWeakPtr.h"
          51                 : #include "nsVoidArray.h"
          52                 : #include "nsTArray.h"
          53                 : #include "nsIDOMXMLDocument.h"
          54                 : #include "nsIDOMDocumentXBL.h"
          55                 : #include "nsStubDocumentObserver.h"
          56                 : #include "nsIDOMStyleSheetList.h"
          57                 : #include "nsIScriptGlobalObject.h"
          58                 : #include "nsIDOMEventTarget.h"
          59                 : #include "nsIContent.h"
          60                 : #include "nsEventListenerManager.h"
          61                 : #include "nsIDOMNodeSelector.h"
          62                 : #include "nsIPrincipal.h"
          63                 : #include "nsIParser.h"
          64                 : #include "nsBindingManager.h"
          65                 : #include "nsINodeInfo.h"
          66                 : #include "nsHashtable.h"
          67                 : #include "nsInterfaceHashtable.h"
          68                 : #include "nsIBoxObject.h"
          69                 : #include "nsPIBoxObject.h"
          70                 : #include "nsIScriptObjectPrincipal.h"
          71                 : #include "nsIURI.h"
          72                 : #include "nsScriptLoader.h"
          73                 : #include "nsIRadioGroupContainer.h"
          74                 : #include "nsILayoutHistoryState.h"
          75                 : #include "nsIRequest.h"
          76                 : #include "nsILoadGroup.h"
          77                 : #include "nsTObserverArray.h"
          78                 : #include "nsStubMutationObserver.h"
          79                 : #include "nsIChannel.h"
          80                 : #include "nsCycleCollectionParticipant.h"
          81                 : #include "nsContentList.h"
          82                 : #include "nsGkAtoms.h"
          83                 : #include "nsIApplicationCache.h"
          84                 : #include "nsIApplicationCacheContainer.h"
          85                 : #include "nsStyleSet.h"
          86                 : #include "pldhash.h"
          87                 : #include "nsAttrAndChildArray.h"
          88                 : #include "nsDOMAttributeMap.h"
          89                 : #include "nsThreadUtils.h"
          90                 : #include "nsIContentViewer.h"
          91                 : #include "nsIDOMXPathNSResolver.h"
          92                 : #include "nsIInterfaceRequestor.h"
          93                 : #include "nsILoadContext.h"
          94                 : #include "nsIProgressEventSink.h"
          95                 : #include "nsISecurityEventSink.h"
          96                 : #include "nsIChannelEventSink.h"
          97                 : #include "imgIRequest.h"
          98                 : #include "nsIDOMDOMImplementation.h"
          99                 : #include "nsIDOMTouchEvent.h"
         100                 : #include "nsIInlineEventHandlers.h"
         101                 : #include "nsDataHashtable.h"
         102                 : #include "mozilla/TimeStamp.h"
         103                 :
         104                 : #define XML_DECLARATION_BITS_DECLARATION_EXISTS   (1 << 0)
         105                 : #define XML_DECLARATION_BITS_ENCODING_EXISTS      (1 << 1)
         106                 : #define XML_DECLARATION_BITS_STANDALONE_EXISTS    (1 << 2)
         107                 : #define XML_DECLARATION_BITS_STANDALONE_YES       (1 << 3)
         108                 :
         109                 :
         110                 : class nsEventListenerManager;
         111                 : class nsDOMStyleSheetList;
         112                 : class nsDOMStyleSheetSetList;
         113                 : class nsIOutputStream;
         114                 : class nsDocument;
         115                 : class nsIDTD;
         116                 : class nsIRadioVisitor;
         117                 : class nsIFormControl;
         118                 : struct nsRadioGroupStruct;
         119                 : class nsOnloadBlocker;
         120                 : class nsUnblockOnloadEvent;
         121                 : class nsChildContentList;
         122                 : class nsXMLEventsManager;
         123                 : class nsHTMLStyleSheet;
         124                 : class nsHTMLCSSStyleSheet;
         125                 : class nsDOMNavigationTiming;
         126                 : class nsWindowSizes;
         127                 :
         128                 : /**
         129                 :  * Right now our identifier map entries contain information for 'name'
         130                 :  * and 'id' mappings of a given string. This is so that
         131                 :  * nsHTMLDocument::ResolveName only has to do one hash lookup instead
         132                 :  * of two. It's not clear whether this still matters for performance.
         133                 :  *
         134                 :  * We also store the document.all result list here. This is mainly so that
         135                 :  * when all elements with the given ID are removed and we remove
         136                 :  * the ID's nsIdentifierMapEntry, the document.all result is released too.
         137                 :  * Perhaps the document.all results should have their own hashtable
         138                 :  * in nsHTMLDocument.
         139                 :  */
         140                 : class nsIdentifierMapEntry : public nsStringHashKey
         141                 : {
         142                 : public:
         143                 :   typedef mozilla::dom::Element Element;
         144                 :
         145                 :   nsIdentifierMapEntry(const nsAString& aKey) :
         146                 :     nsStringHashKey(&aKey), mNameContentList(nsnull)
         147                 :   {
         148                 :   }
         149             122 :   nsIdentifierMapEntry(const nsAString *aKey) :
         150             122 :     nsStringHashKey(aKey), mNameContentList(nsnull)
         151                 :   {
         152             122 :   }
         153                 :   nsIdentifierMapEntry(const nsIdentifierMapEntry& aOther) :
         154                 :     nsStringHashKey(&aOther.GetKey())
         155                 :   {
         156                 :     NS_ERROR("Should never be called");
         157                 :   }
         158                 :   ~nsIdentifierMapEntry();
         159                 :
         160                 :   void SetInvalidName();
         161                 :   bool IsInvalidName();
         162                 :   void AddNameElement(nsIDocument* aDocument, Element* aElement);
         163                 :   void RemoveNameElement(Element* aElement);
         164                 :   bool IsEmpty();
         165               0 :   nsBaseContentList* GetNameContentList() {
         166               0 :     return mNameContentList;
         167                 :   }
         168                 :
         169                 :   /**
         170                 :    * Returns the element if we know the element associated with this
         171                 :    * id. Otherwise returns null.
         172                 :    */
         173                 :   Element* GetIdElement();
         174                 :   /**
         175                 :    * Returns the list of all elements associated with this id.
         176                 :    */
         177               0 :   const nsSmallVoidArray* GetIdElements() const {
         178               0 :     return &mIdContentList;
         179                 :   }
         180                 :   /**
         181                 :    * If this entry has a non-null image element set (using SetImageElement),
         182                 :    * the image element will be returned, otherwise the same as GetIdElement().
         183                 :    */
         184                 :   Element* GetImageIdElement();
         185                 :   /**
         186                 :    * Append all the elements with this id to aElements
         187                 :    */
         188                 :   void AppendAllIdContent(nsCOMArray<nsIContent>* aElements);
         189                 :   /**
         190                 :    * This can fire ID change callbacks.
         191                 :    * @return true if the content could be added, false if we failed due
         192                 :    * to OOM.
         193                 :    */
         194                 :   bool AddIdElement(Element* aElement);
         195                 :   /**
         196                 :    * This can fire ID change callbacks.
         197                 :    */
         198                 :   void RemoveIdElement(Element* aElement);
         199                 :   /**
         200                 :    * Set the image element override for this ID. This will be returned by
         201                 :    * GetIdElement(true) if non-null.
         202                 :    */
         203                 :   void SetImageElement(Element* aElement);
         204                 :
         205                 :   bool HasContentChangeCallback() { return mChangeCallbacks != nsnull; }
         206                 :   void AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
         207                 :                                 void* aData, bool aForImage);
         208                 :   void RemoveContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
         209                 :                                 void* aData, bool aForImage);
         210                 :
         211                 :   void Traverse(nsCycleCollectionTraversalCallback* aCallback);
         212                 :
         213               0 :   void SetDocAllList(nsContentList* aContentList) { mDocAllList = aContentList; }
         214               0 :   nsContentList* GetDocAllList() { return mDocAllList; }
         215                 :
         216                 :   struct ChangeCallback {
         217                 :     nsIDocument::IDTargetObserver mCallback;
         218                 :     void* mData;
         219                 :     bool mForImage;
         220                 :   };
         221                 :
         222               0 :   struct ChangeCallbackEntry : public PLDHashEntryHdr {
         223                 :     typedef const ChangeCallback KeyType;
         224                 :     typedef const ChangeCallback* KeyTypePointer;
         225                 :
         226               0 :     ChangeCallbackEntry(const ChangeCallback* key) :
         227               0 :       mKey(*key) { }
         228                 :     ChangeCallbackEntry(const ChangeCallbackEntry& toCopy) :
         229                 :       mKey(toCopy.mKey) { }
         230                 :
         231                 :     KeyType GetKey() const { return mKey; }
         232               0 :     bool KeyEquals(KeyTypePointer aKey) const {
         233                 :       return aKey->mCallback == mKey.mCallback &&
         234                 :              aKey->mData == mKey.mData &&
         235               0 :              aKey->mForImage == mKey.mForImage;
         236                 :     }
         237                 :
         238               0 :     static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
         239               0 :     static PLDHashNumber HashKey(KeyTypePointer aKey)
         240                 :     {
         241               0 :       return mozilla::HashGeneric(aKey->mCallback, aKey->mData);
         242                 :     }
         243                 :     enum { ALLOW_MEMMOVE = true };
         244                 :
         245                 :     ChangeCallback mKey;
         246                 :   };
         247                 :
         248                 : private:
         249                 :   void FireChangeCallbacks(Element* aOldElement, Element* aNewElement,
         250                 :                            bool aImageOnly = false);
         251                 :
         252                 :   // empty if there are no elements with this ID.
         253                 :   // The elements are stored as weak pointers.
         254                 :   nsSmallVoidArray mIdContentList;
         255                 :   nsRefPtr<nsBaseContentList> mNameContentList;
         256                 :   nsRefPtr<nsContentList> mDocAllList;
         257                 :   nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks;
         258                 :   nsRefPtr<Element> mImageElement;
         259                 : };
         260                 :
         261                 : class nsDocHeaderData
         262                 : {
         263                 : public:
         264               4 :   nsDocHeaderData(nsIAtom* aField, const nsAString& aData)
         265               4 :     : mField(aField), mData(aData), mNext(nsnull)
         266                 :   {
         267               4 :   }
         268                 :
         269               4 :   ~nsDocHeaderData(void)
         270               4 :   {
         271               4 :     delete mNext;
         272               4 :   }
         273                 :
         274                 :   nsCOMPtr<nsIAtom> mField;
         275                 :   nsString          mData;
         276                 :   nsDocHeaderData*  mNext;
         277                 : };
         278                 :
         279                 : class nsDOMStyleSheetList : public nsIDOMStyleSheetList,
         280                 :                             public nsStubDocumentObserver
         281                 : {
         282                 : public:
         283                 :   nsDOMStyleSheetList(nsIDocument *aDocument);
         284                 :   virtual ~nsDOMStyleSheetList();
         285                 :
         286                 :   NS_DECL_ISUPPORTS
         287                 :
         288                 :   NS_DECL_NSIDOMSTYLESHEETLIST
         289                 :
         290                 :   // nsIDocumentObserver
         291                 :   NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED
         292                 :   NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED
         293                 :
         294                 :   // nsIMutationObserver
         295                 :   NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
         296                 :
         297                 :   nsIStyleSheet* GetItemAt(PRUint32 aIndex);
         298                 :
         299               0 :   static nsDOMStyleSheetList* FromSupports(nsISupports* aSupports)
         300                 :   {
         301               0 :     nsIDOMStyleSheetList* list = static_cast<nsIDOMStyleSheetList*>(aSupports);
         302                 : #ifdef DEBUG
         303                 :     {
         304               0 :       nsCOMPtr<nsIDOMStyleSheetList> list_qi = do_QueryInterface(aSupports);
         305                 :
         306                 :       // If this assertion fires the QI implementation for the object in
         307                 :       // question doesn't use the nsIDOMStyleSheetList pointer as the
         308                 :       // nsISupports pointer. That must be fixed, or we'll crash...
         309               0 :       NS_ASSERTION(list_qi == list, "Uh, fix QI!");
         310                 :     }
         311                 : #endif
         312               0 :     return static_cast<nsDOMStyleSheetList*>(list);
         313                 :   }
         314                 :
         315                 : protected:
         316                 :   PRInt32       mLength;
         317                 :   nsIDocument*  mDocument;
         318                 : };
         319                 :
         320                 : class nsOnloadBlocker : public nsIRequest
         321                 : {
         322                 : public:
         323            1251 :   nsOnloadBlocker() {}
         324                 :
         325                 :   NS_DECL_ISUPPORTS
         326                 :   NS_DECL_NSIREQUEST
         327                 :
         328                 : private:
         329            1249 :   ~nsOnloadBlocker() {}
         330                 : };
         331                 :
         332                 : class nsExternalResourceMap
         333            1249 : {
         334                 : public:
         335                 :   typedef nsIDocument::ExternalResourceLoad ExternalResourceLoad;
         336                 :   nsExternalResourceMap();
         337                 :
         338                 :   /**
         339                 :    * Request an external resource document.  This does exactly what
         340                 :    * nsIDocument::RequestExternalResource is documented to do.
         341                 :    */
         342                 :   nsIDocument* RequestResource(nsIURI* aURI,
         343                 :                                nsINode* aRequestingNode,
         344                 :                                nsDocument* aDisplayDocument,
         345                 :                                ExternalResourceLoad** aPendingLoad);
         346                 :
         347                 :   /**
         348                 :    * Enumerate the resource documents.  See
         349                 :    * nsIDocument::EnumerateExternalResources.
         350                 :    */
         351                 :   void EnumerateResources(nsIDocument::nsSubDocEnumFunc aCallback, void* aData);
         352                 :
         353                 :   /**
         354                 :    * Traverse ourselves for cycle-collection
         355                 :    */
         356                 :   void Traverse(nsCycleCollectionTraversalCallback* aCallback) const;
         357                 :
         358                 :   /**
         359                 :    * Shut ourselves down (used for cycle-collection unlink), as well
         360                 :    * as for document destruction.
         361                 :    */
         362            1249 :   void Shutdown()
         363                 :   {
         364            1249 :     mPendingLoads.Clear();
         365            1249 :     mMap.Clear();
         366            1249 :     mHaveShutDown = true;
         367            1249 :   }
         368                 :
         369               0 :   bool HaveShutDown() const
         370                 :   {
         371               0 :     return mHaveShutDown;
         372                 :   }
         373                 :
         374                 :   // Needs to be public so we can traverse them sanely
         375                 :   struct ExternalResource
         376               0 :   {
         377                 :     ~ExternalResource();
         378                 :     nsCOMPtr<nsIDocument> mDocument;
         379                 :     nsCOMPtr<nsIContentViewer> mViewer;
         380                 :     nsCOMPtr<nsILoadGroup> mLoadGroup;
         381                 :   };
         382                 :
         383                 :   // Hide all our viewers
         384                 :   void HideViewers();
         385                 :
         386                 :   // Show all our viewers
         387                 :   void ShowViewers();
         388                 :
         389                 : protected:
         390                 :   class PendingLoad : public ExternalResourceLoad,
         391                 :                       public nsIStreamListener
         392               0 :   {
         393                 :   public:
         394               0 :     PendingLoad(nsDocument* aDisplayDocument) :
         395               0 :       mDisplayDocument(aDisplayDocument)
         396               0 :     {}
         397                 :
         398                 :     NS_DECL_ISUPPORTS
         399                 :     NS_DECL_NSISTREAMLISTENER
         400                 :     NS_DECL_NSIREQUESTOBSERVER
         401                 :
         402                 :     /**
         403                 :      * Start aURI loading.  This will perform the necessary security checks and
         404                 :      * so forth.
         405                 :      */
         406                 :     nsresult StartLoad(nsIURI* aURI, nsINode* aRequestingNode);
         407                 :
         408                 :     /**
         409                 :      * Set up an nsIContentViewer based on aRequest.  This is guaranteed to
         410                 :      * put null in *aViewer and *aLoadGroup on all failures.
         411                 :      */
         412                 :     nsresult SetupViewer(nsIRequest* aRequest, nsIContentViewer** aViewer,
         413                 :                          nsILoadGroup** aLoadGroup);
         414                 :
         415                 :   private:
         416                 :     nsRefPtr<nsDocument> mDisplayDocument;
         417                 :     nsCOMPtr<nsIStreamListener> mTargetListener;
         418                 :     nsCOMPtr<nsIURI> mURI;
         419                 :   };
         420                 :   friend class PendingLoad;
         421                 :
         422                 :   class LoadgroupCallbacks : public nsIInterfaceRequestor
         423               0 :   {
         424                 :   public:
         425               0 :     LoadgroupCallbacks(nsIInterfaceRequestor* aOtherCallbacks)
         426               0 :       : mCallbacks(aOtherCallbacks)
         427               0 :     {}
         428                 :     NS_DECL_ISUPPORTS
         429                 :     NS_DECL_NSIINTERFACEREQUESTOR
         430                 :   private:
         431                 :     // The only reason it's safe to hold a strong ref here without leaking is
         432                 :     // that the notificationCallbacks on a loadgroup aren't the docshell itself
         433                 :     // but a shim that holds a weak reference to the docshell.
         434                 :     nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
         435                 :
         436                 :     // Use shims for interfaces that docshell implements directly so that we
         437                 :     // don't hand out references to the docshell.  The shims should all allow
         438                 :     // getInterface back on us, but other than that each one should only
         439                 :     // implement one interface.
         440                 :
         441                 :     // XXXbz I wish we could just derive the _allcaps thing from _i
         442                 : #define DECL_SHIM(_i, _allcaps)                                              \
         443                 :     class _i##Shim : public nsIInterfaceRequestor,                           \
         444                 :                      public _i                                               \
         445                 :     {                                                                        \
         446                 :     public:                                                                  \
         447                 :       _i##Shim(nsIInterfaceRequestor* aIfreq, _i* aRealPtr)                  \
         448                 :         : mIfReq(aIfreq), mRealPtr(aRealPtr)                                 \
         449                 :       {                                                                      \
         450                 :         NS_ASSERTION(mIfReq, "Expected non-null here");                      \
         451                 :         NS_ASSERTION(mRealPtr, "Expected non-null here");                    \
         452                 :       }                                                                      \
         453                 :       NS_DECL_ISUPPORTS                                                      \
         454                 :       NS_FORWARD_NSIINTERFACEREQUESTOR(mIfReq->);                            \
         455                 :       NS_FORWARD_##_allcaps(mRealPtr->);                                     \
         456                 :     private:                                                                 \
         457                 :       nsCOMPtr<nsIInterfaceRequestor> mIfReq;                                \
         458                 :       nsCOMPtr<_i> mRealPtr;                                                 \
         459                 :     };
         460                 :
         461               0 :     DECL_SHIM(nsILoadContext, NSILOADCONTEXT)
         462               0 :     DECL_SHIM(nsIProgressEventSink, NSIPROGRESSEVENTSINK)
         463               0 :     DECL_SHIM(nsIChannelEventSink, NSICHANNELEVENTSINK)
         464               0 :     DECL_SHIM(nsISecurityEventSink, NSISECURITYEVENTSINK)
         465               0 :     DECL_SHIM(nsIApplicationCacheContainer, NSIAPPLICATIONCACHECONTAINER)
         466                 : #undef DECL_SHIM
         467                 :   };
         468                 :
         469                 :   /**
         470                 :    * Add an ExternalResource for aURI.  aViewer and aLoadGroup might be null
         471                 :    * when this is called if the URI didn't result in an XML document.  This
         472                 :    * function makes sure to remove the pending load for aURI, if any, from our
         473                 :    * hashtable, and to notify its observers, if any.
         474                 :    */
         475                 :   nsresult AddExternalResource(nsIURI* aURI, nsIContentViewer* aViewer,
         476                 :                                nsILoadGroup* aLoadGroup,
         477                 :                                nsIDocument* aDisplayDocument);
         478                 :
         479                 :   nsClassHashtable<nsURIHashKey, ExternalResource> mMap;
         480                 :   nsRefPtrHashtable<nsURIHashKey, PendingLoad> mPendingLoads;
         481                 :   bool mHaveShutDown;
         482                 : };
         483                 :
         484                 : // Base class for our document implementations.
         485                 : //
         486                 : // Note that this class *implements* nsIDOMXMLDocument, but it's not
         487                 : // really an nsIDOMXMLDocument. The reason for implementing
         488                 : // nsIDOMXMLDocument on this class is to avoid having to duplicate all
         489                 : // its inherited methods on document classes that *are*
         490                 : // nsIDOMXMLDocument's. nsDocument's QI should *not* claim to support
         491                 : // nsIDOMXMLDocument unless someone writes a real implementation of
         492                 : // the interface.
         493                 : class nsDocument : public nsIDocument,
         494                 :                    public nsIDOMXMLDocument, // inherits nsIDOMDocument
         495                 :                    public nsIDOMDocumentXBL,
         496                 :                    public nsSupportsWeakReference,
         497                 :                    public nsIScriptObjectPrincipal,
         498                 :                    public nsIRadioGroupContainer,
         499                 :                    public nsIApplicationCacheContainer,
         500                 :                    public nsStubMutationObserver,
         501                 :                    public nsIDOMDocumentTouch,
         502                 :                    public nsIInlineEventHandlers
         503                 : {
         504                 : public:
         505                 :   typedef mozilla::dom::Element Element;
         506                 :
         507            1418 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
         508                 :
         509                 :   NS_DECL_SIZEOF_EXCLUDING_THIS
         510                 :
         511                 :   using nsINode::GetScriptTypeID;
         512                 :
         513                 :   virtual void Reset(nsIChannel *aChannel, nsILoadGroup *aLoadGroup);
         514                 :   virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
         515                 :                           nsIPrincipal* aPrincipal);
         516                 :
         517                 :   // StartDocumentLoad is pure virtual so that subclasses must override it.
         518                 :   // The nsDocument StartDocumentLoad does some setup, but does NOT set
         519                 :   // *aDocListener; this is the job of subclasses.
         520                 :   virtual nsresult StartDocumentLoad(const char* aCommand,
         521                 :                                      nsIChannel* aChannel,
         522                 :                                      nsILoadGroup* aLoadGroup,
         523                 :                                      nsISupports* aContainer,
         524                 :                                      nsIStreamListener **aDocListener,
         525                 :                                      bool aReset = true,
         526                 :                                      nsIContentSink* aContentSink = nsnull) = 0;
         527                 :
         528                 :   virtual void StopDocumentLoad();
         529                 :
         530                 :   virtual void NotifyPossibleTitleChange(bool aBoundTitleElement);
         531                 :
         532                 :   virtual void SetDocumentURI(nsIURI* aURI);
         533                 :
         534                 :   /**
         535                 :    * Set the principal responsible for this document.
         536                 :    */
         537                 :   virtual void SetPrincipal(nsIPrincipal *aPrincipal);
         538                 :
         539                 :   /**
         540                 :    * Get the Content-Type of this document.
         541                 :    */
         542                 :   // NS_IMETHOD GetContentType(nsAString& aContentType);
         543                 :   // Already declared in nsIDOMDocument
         544                 :
         545                 :   /**
         546                 :    * Set the Content-Type of this document.
         547                 :    */
         548                 :   virtual void SetContentType(const nsAString& aContentType);
         549                 :
         550                 :   virtual nsresult SetBaseURI(nsIURI* aURI);
         551                 :
         552                 :   /**
         553                 :    * Get/Set the base target of a link in a document.
         554                 :    */
         555                 :   virtual void GetBaseTarget(nsAString &aBaseTarget);
         556                 :
         557                 :   /**
         558                 :    * Return a standard name for the document's character set. This will
         559                 :    * trigger a startDocumentLoad if necessary to answer the question.
         560                 :    */
         561                 :   virtual void SetDocumentCharacterSet(const nsACString& aCharSetID);
         562                 :
         563                 :   /**
         564                 :    * Add an observer that gets notified whenever the charset changes.
         565                 :    */
         566                 :   virtual nsresult AddCharSetObserver(nsIObserver* aObserver);
         567                 :
         568                 :   /**
         569                 :    * Remove a charset observer.
         570                 :    */
         571                 :   virtual void RemoveCharSetObserver(nsIObserver* aObserver);
         572                 :
         573                 :   virtual Element* AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
         574                 :                                        void* aData, bool aForImage);
         575                 :   virtual void RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
         576                 :                                       void* aData, bool aForImage);
         577                 :
         578                 :   /**
         579                 :    * Access HTTP header data (this may also get set from other sources, like
         580                 :    * HTML META tags).
         581                 :    */
         582                 :   virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const;
         583                 :   virtual void SetHeaderData(nsIAtom* aheaderField,
         584                 :                              const nsAString& aData);
         585                 :
         586                 :   /**
         587                 :    * Create a new presentation shell that will use aContext for
         588                 :    * its presentation context (presentation context's <b>must not</b> be
         589                 :    * shared among multiple presentation shell's).
         590                 :    */
         591                 :   virtual nsresult CreateShell(nsPresContext* aContext,
         592                 :                                nsIViewManager* aViewManager,
         593                 :                                nsStyleSet* aStyleSet,
         594                 :                                nsIPresShell** aInstancePtrResult);
         595                 :   virtual void DeleteShell();
         596                 :
         597                 :   virtual nsresult SetSubDocumentFor(Element* aContent,
         598                 :                                      nsIDocument* aSubDoc);
         599                 :   virtual nsIDocument* GetSubDocumentFor(nsIContent* aContent) const;
         600                 :   virtual Element* FindContentForSubDocument(nsIDocument *aDocument) const;
         601                 :   virtual Element* GetRootElementInternal() const;
         602                 :
         603                 :   /**
         604                 :    * Get the style sheets owned by this document.
         605                 :    * These are ordered, highest priority last
         606                 :    */
         607                 :   virtual PRInt32 GetNumberOfStyleSheets() const;
         608                 :   virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) const;
         609                 :   virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const;
         610                 :   virtual void AddStyleSheet(nsIStyleSheet* aSheet);
         611                 :   virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
         612                 :
         613                 :   virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
         614                 :                                  nsCOMArray<nsIStyleSheet>& aNewSheets);
         615                 :   virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
         616                 :   virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
         617                 :
         618                 :   virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
         619                 :   virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
         620                 :                                             bool aApplicable);
         621                 :
         622                 :   virtual PRInt32 GetNumberOfCatalogStyleSheets() const;
         623                 :   virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const;
         624                 :   virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet);
         625                 :   virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI);
         626                 :
         627               0 :   virtual nsIChannel* GetChannel() const {
         628               0 :     return mChannel;
         629                 :   }
         630                 :
         631                 :   /**
         632                 :    * Get this document's attribute stylesheet.  May return null if
         633                 :    * there isn't one.
         634                 :    */
         635             731 :   virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const {
         636             731 :     return mAttrStyleSheet;
         637                 :   }
         638                 :
         639                 :   /**
         640                 :    * Get this document's inline style sheet.  May return null if there
         641                 :    * isn't one
         642                 :    */
         643               0 :   virtual nsHTMLCSSStyleSheet* GetInlineStyleSheet() const {
         644               0 :     return mStyleAttrStyleSheet;
         645                 :   }
         646                 :
         647                 :   /**
         648                 :    * Set the object from which a document can get a script context.
         649                 :    * This is the context within which all scripts (during document
         650                 :    * creation and during event handling) will run.
         651                 :    */
         652                 :   virtual nsIScriptGlobalObject* GetScriptGlobalObject() const;
         653                 :   virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
         654                 :
         655                 :   virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject);
         656                 :
         657                 :   virtual nsIScriptGlobalObject* GetScopeObject();
         658                 :
         659                 :   /**
         660                 :    * Get the script loader for this document
         661                 :    */
         662                 :   virtual nsScriptLoader* ScriptLoader();
         663                 :
         664                 :   /**
         665                 :    * Add/Remove an element to the document's id and name hashes
         666                 :    */
         667                 :   virtual void AddToIdTable(Element* aElement, nsIAtom* aId);
         668                 :   virtual void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
         669                 :   virtual void AddToNameTable(Element* aElement, nsIAtom* aName);
         670                 :   virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName);
         671                 :
         672                 :   /**
         673                 :    * Add a new observer of document change notifications. Whenever
         674                 :    * content is changed, appended, inserted or removed the observers are
         675                 :    * informed.
         676                 :    */
         677                 :   virtual void AddObserver(nsIDocumentObserver* aObserver);
         678                 :
         679                 :   /**
         680                 :    * Remove an observer of document change notifications. This will
         681                 :    * return false if the observer cannot be found.
         682                 :    */
         683                 :   virtual bool RemoveObserver(nsIDocumentObserver* aObserver);
         684                 :
         685                 :   // Observation hooks used to propagate notifications to document
         686                 :   // observers.
         687                 :   virtual void BeginUpdate(nsUpdateType aUpdateType);
         688                 :   virtual void EndUpdate(nsUpdateType aUpdateType);
         689                 :   virtual void BeginLoad();
         690                 :   virtual void EndLoad();
         691                 :
         692                 :   virtual void SetReadyStateInternal(ReadyState rs);
         693                 :   virtual ReadyState GetReadyStateEnum();
         694                 :
         695                 :   virtual void ContentStateChanged(nsIContent* aContent,
         696                 :                                    nsEventStates aStateMask);
         697                 :   virtual void DocumentStatesChanged(nsEventStates aStateMask);
         698                 :
         699                 :   virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
         700                 :                                 nsIStyleRule* aOldStyleRule,
         701                 :                                 nsIStyleRule* aNewStyleRule);
         702                 :   virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
         703                 :                               nsIStyleRule* aStyleRule);
         704                 :   virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
         705                 :                                 nsIStyleRule* aStyleRule);
         706                 :
         707                 :   virtual void FlushPendingNotifications(mozFlushType aType);
         708                 :   virtual void FlushExternalResources(mozFlushType aType);
         709                 :   virtual void SetXMLDeclaration(const PRUnichar *aVersion,
         710                 :                                  const PRUnichar *aEncoding,
         711                 :                                  const PRInt32 aStandalone);
         712                 :   virtual void GetXMLDeclaration(nsAString& aVersion,
         713                 :                                  nsAString& aEncoding,
         714                 :                                  nsAString& Standalone);
         715                 :   virtual bool IsScriptEnabled();
         716                 :
         717                 :   virtual void OnPageShow(bool aPersisted, nsIDOMEventTarget* aDispatchStartTarget);
         718                 :   virtual void OnPageHide(bool aPersisted, nsIDOMEventTarget* aDispatchStartTarget);
         719                 :
         720                 :   virtual void WillDispatchMutationEvent(nsINode* aTarget);
         721                 :   virtual void MutationEventDispatched(nsINode* aTarget);
         722                 :
         723                 :   // nsINode
         724                 :   virtual bool IsNodeOfType(PRUint32 aFlags) const;
         725                 :   virtual PRUint16 NodeType();
         726                 :   virtual void NodeName(nsAString& aNodeName);
         727                 :   virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
         728                 :   virtual nsIContent * const * GetChildArray(PRUint32* aChildCount) const;
         729                 :   virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
         730                 :   virtual PRUint32 GetChildCount() const;
         731                 :   virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
         732                 :                                  bool aNotify);
         733                 :   virtual nsresult AppendChildTo(nsIContent* aKid, bool aNotify);
         734                 :   virtual nsresult RemoveChildAt(PRUint32 aIndex, bool aNotify);
         735               0 :   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
         736                 :   {
         737               0 :     return NS_ERROR_NOT_IMPLEMENTED;
         738                 :   }
         739                 :
         740                 :   // nsIRadioGroupContainer
         741                 :   NS_IMETHOD WalkRadioGroup(const nsAString& aName,
         742                 :                             nsIRadioVisitor* aVisitor,
         743                 :                             bool aFlushContent);
         744                 :   NS_IMETHOD SetCurrentRadioButton(const nsAString& aName,
         745                 :                                    nsIDOMHTMLInputElement* aRadio);
         746                 :   NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
         747                 :                                    nsIDOMHTMLInputElement** aRadio);
         748                 :   NS_IMETHOD GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
         749                 :                                 PRInt32 *aPositionIndex,
         750                 :                                 PRInt32 *aItemsInGroup);
         751                 :   NS_IMETHOD GetNextRadioButton(const nsAString& aName,
         752                 :                                 const bool aPrevious,
         753                 :                                 nsIDOMHTMLInputElement*  aFocusedRadio,
         754                 :                                 nsIDOMHTMLInputElement** aRadioOut);
         755                 :   NS_IMETHOD AddToRadioGroup(const nsAString& aName,
         756                 :                              nsIFormControl* aRadio);
         757                 :   NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
         758                 :                                   nsIFormControl* aRadio);
         759                 :   virtual PRUint32 GetRequiredRadioCount(const nsAString& aName) const;
         760                 :   virtual void RadioRequiredChanged(const nsAString& aName,
         761                 :                                     nsIFormControl* aRadio);
         762                 :   virtual bool GetValueMissingState(const nsAString& aName) const;
         763                 :   virtual void SetValueMissingState(const nsAString& aName, bool aValue);
         764                 :
         765                 :   // for radio group
         766                 :   nsresult GetRadioGroup(const nsAString& aName,
         767                 :                          nsRadioGroupStruct **aRadioGroup);
         768                 :
         769                 :   // nsIDOMNode
         770                 :   NS_DECL_NSIDOMNODE
         771                 :
         772                 :   // nsIDOMDocument
         773                 :   NS_DECL_NSIDOMDOCUMENT
         774                 :
         775                 :   // nsIDOMXMLDocument
         776                 :   NS_DECL_NSIDOMXMLDOCUMENT
         777                 :
         778                 :   // nsIDOMDocumentXBL
         779                 :   NS_DECL_NSIDOMDOCUMENTXBL
         780                 :
         781                 :   // nsIDOMEventTarget
         782                 :   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
         783                 :   virtual nsEventListenerManager*
         784                 :     GetListenerManager(bool aCreateIfNotFound);
         785                 :
         786                 :   // nsIScriptObjectPrincipal
         787                 :   virtual nsIPrincipal* GetPrincipal();
         788                 :
         789                 :   // nsIApplicationCacheContainer
         790                 :   NS_DECL_NSIAPPLICATIONCACHECONTAINER
         791                 :
         792                 :   // nsITouchEventReceiver
         793                 :   NS_DECL_NSITOUCHEVENTRECEIVER
         794                 :
         795                 :   // nsIDOMDocumentTouch
         796                 :   NS_DECL_NSIDOMDOCUMENTTOUCH
         797                 :
         798                 :   // nsIInlineEventHandlers
         799                 :   NS_DECL_NSIINLINEEVENTHANDLERS
         800                 :
         801                 :   virtual nsresult Init();
         802                 :
         803                 :   virtual void AddXMLEventsContent(nsIContent * aXMLEventsElement);
         804                 :
         805                 :   virtual nsresult CreateElem(const nsAString& aName, nsIAtom *aPrefix,
         806                 :                               PRInt32 aNamespaceID,
         807                 :                               nsIContent **aResult);
         808                 :
         809                 :   nsresult CreateElement(const nsAString& aTagName,
         810                 :                          nsIContent** aReturn);
         811                 :   nsresult CreateElementNS(const nsAString& aNamespaceURI,
         812                 :                            const nsAString& aQualifiedName,
         813                 :                            nsIContent** aReturn);
         814                 :
         815                 :   nsresult CreateTextNode(const nsAString& aData, nsIContent** aReturn);
         816                 :
         817                 :   virtual NS_HIDDEN_(nsresult) Sanitize();
         818                 :
         819                 :   virtual NS_HIDDEN_(void) EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
         820                 :                                                  void *aData);
         821                 :
         822                 :   virtual NS_HIDDEN_(bool) CanSavePresentation(nsIRequest *aNewRequest);
         823                 :   virtual NS_HIDDEN_(void) Destroy();
         824                 :   virtual NS_HIDDEN_(void) RemovedFromDocShell();
         825                 :   virtual NS_HIDDEN_(already_AddRefed<nsILayoutHistoryState>) GetLayoutHistoryState() const;
         826                 :
         827                 :   virtual NS_HIDDEN_(void) BlockOnload();
         828                 :   virtual NS_HIDDEN_(void) UnblockOnload(bool aFireSync);
         829                 :
         830                 :   virtual NS_HIDDEN_(void) AddStyleRelevantLink(mozilla::dom::Link* aLink);
         831                 :   virtual NS_HIDDEN_(void) ForgetLink(mozilla::dom::Link* aLink);
         832                 :
         833                 :   NS_HIDDEN_(void) ClearBoxObjectFor(nsIContent* aContent);
         834                 :   NS_IMETHOD GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult);
         835                 :
         836                 :   virtual NS_HIDDEN_(nsresult) GetXBLChildNodesFor(nsIContent* aContent,
         837                 :                                                    nsIDOMNodeList** aResult);
         838                 :   virtual NS_HIDDEN_(nsresult) GetContentListFor(nsIContent* aContent,
         839                 :                                                  nsIDOMNodeList** aResult);
         840                 :
         841                 :   virtual NS_HIDDEN_(nsresult) ElementFromPointHelper(float aX, float aY,
         842                 :                                                       bool aIgnoreRootScrollFrame,
         843                 :                                                       bool aFlushLayout,
         844                 :                                                       nsIDOMElement** aReturn);
         845                 :
         846                 :   virtual NS_HIDDEN_(nsresult) NodesFromRectHelper(float aX, float aY,
         847                 :                                                    float aTopSize, float aRightSize,
         848                 :                                                    float aBottomSize, float aLeftSize,
         849                 :                                                    bool aIgnoreRootScrollFrame,
         850                 :                                                    bool aFlushLayout,
         851                 :                                                    nsIDOMNodeList** aReturn);
         852                 :
         853                 :   virtual NS_HIDDEN_(void) FlushSkinBindings();
         854                 :
         855                 :   virtual NS_HIDDEN_(nsresult) InitializeFrameLoader(nsFrameLoader* aLoader);
         856                 :   virtual NS_HIDDEN_(nsresult) FinalizeFrameLoader(nsFrameLoader* aLoader);
         857                 :   virtual NS_HIDDEN_(void) TryCancelFrameLoaderInitialization(nsIDocShell* aShell);
         858                 :   virtual NS_HIDDEN_(bool) FrameLoaderScheduledToBeFinalized(nsIDocShell* aShell);
         859                 :   virtual NS_HIDDEN_(nsIDocument*)
         860                 :     RequestExternalResource(nsIURI* aURI,
         861                 :                             nsINode* aRequestingNode,
         862                 :                             ExternalResourceLoad** aPendingLoad);
         863                 :   virtual NS_HIDDEN_(void)
         864                 :     EnumerateExternalResources(nsSubDocEnumFunc aCallback, void* aData);
         865                 :
         866                 :   nsTArray<nsCString> mFileDataUris;
         867                 :
         868                 :   // Returns our (lazily-initialized) animation controller.
         869                 :   // If HasAnimationController is true, this is guaranteed to return non-null.
         870                 :   nsSMILAnimationController* GetAnimationController();
         871                 :
         872                 :   void SetImagesNeedAnimating(bool aAnimating);
         873                 :
         874                 :   virtual void SuppressEventHandling(PRUint32 aIncrease);
         875                 :
         876                 :   virtual void UnsuppressEventHandlingAndFireEvents(bool aFireEvents);
         877                 :
         878               0 :   void DecreaseEventSuppression() {
         879               0 :     --mEventsSuppressed;
         880               0 :     MaybeRescheduleAnimationFrameNotifications();
         881               0 :   }
         882                 :
         883          372906 :   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDocument,
         884                 :                                                                    nsIDocument)
         885                 :
         886                 :   void DoNotifyPossibleTitleChange();
         887                 :
         888               0 :   nsExternalResourceMap& ExternalResourceMap()
         889                 :   {
         890               0 :     return mExternalResourceMap;
         891                 :   }
         892                 :
         893            1251 :   void SetLoadedAsData(bool aLoadedAsData) { mLoadedAsData = aLoadedAsData; }
         894               0 :   void SetLoadedAsInteractiveData(bool aLoadedAsInteractiveData)
         895                 :   {
         896               0 :     mLoadedAsInteractiveData = aLoadedAsInteractiveData;
         897               0 :   }
         898                 :
         899                 :   nsresult CloneDocHelper(nsDocument* clone) const;
         900                 :
         901                 :   void MaybeInitializeFinalizeFrameLoaders();
         902                 :
         903                 :   void MaybeEndOutermostXBLUpdate();
         904                 :
         905                 :   virtual void MaybePreLoadImage(nsIURI* uri,
         906                 :                                  const nsAString &aCrossOriginAttr);
         907                 :
         908                 :   virtual void PreloadStyle(nsIURI* uri, const nsAString& charset);
         909                 :
         910                 :   virtual nsresult LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
         911                 :                                        nsCSSStyleSheet** sheet);
         912                 :
         913                 :   virtual nsISupports* GetCurrentContentSink();
         914                 :
         915                 :   virtual nsEventStates GetDocumentState();
         916                 :
         917                 :   virtual void RegisterFileDataUri(const nsACString& aUri);
         918                 :   virtual void UnregisterFileDataUri(const nsACString& aUri);
         919                 :
         920                 :   // Only BlockOnload should call this!
         921                 :   void AsyncBlockOnload();
         922                 :
         923                 :   virtual void SetScrollToRef(nsIURI *aDocumentURI);
         924                 :   virtual void ScrollToRef();
         925                 :   virtual void ResetScrolledToRefAlready();
         926                 :   virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue);
         927                 :
         928                 :   already_AddRefed<nsContentList>
         929              26 :   GetElementsByTagName(const nsAString& aTagName) {
         930              26 :     return NS_GetContentList(this, kNameSpaceID_Unknown, aTagName);
         931                 :   }
         932                 :   already_AddRefed<nsContentList>
         933                 :     GetElementsByTagNameNS(const nsAString& aNamespaceURI,
         934                 :                            const nsAString& aLocalName);
         935                 :
         936                 :   virtual Element *GetElementById(const nsAString& aElementId);
         937                 :   virtual const nsSmallVoidArray* GetAllElementsForId(const nsAString& aElementId) const;
         938                 :
         939                 :   virtual Element *LookupImageElement(const nsAString& aElementId);
         940                 :
         941                 :   virtual NS_HIDDEN_(nsresult) AddImage(imgIRequest* aImage);
         942                 :   virtual NS_HIDDEN_(nsresult) RemoveImage(imgIRequest* aImage);
         943                 :   virtual NS_HIDDEN_(nsresult) SetImageLockingState(bool aLocked);
         944                 :
         945                 :   virtual nsresult GetStateObject(nsIVariant** aResult);
         946                 :
         947                 :   virtual nsDOMNavigationTiming* GetNavigationTiming() const;
         948                 :   virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming);
         949                 :
         950                 :   virtual Element* FindImageMap(const nsAString& aNormalizedMapName);
         951                 :
         952                 :   virtual void NotifyAudioAvailableListener();
         953                 :
         954               0 :   bool HasAudioAvailableListeners()
         955                 :   {
         956               0 :     return mHasAudioAvailableListener;
         957                 :   }
         958                 :
         959                 :   virtual Element* GetFullScreenElement();
         960                 :   virtual void AsyncRequestFullScreen(Element* aElement);
         961                 :   virtual void RestorePreviousFullScreenState();
         962                 :   virtual bool IsFullScreenDoc();
         963                 :   static void ExitFullScreen();
         964                 :
         965                 :   // This is called asynchronously by nsIDocument::AsyncRequestFullScreen()
         966                 :   // to move document into full-screen mode if allowed. aWasCallerChrome
         967                 :   // should be true when nsIDocument::AsyncRequestFullScreen() was called
         968                 :   // by chrome code.
         969                 :   void RequestFullScreen(Element* aElement, bool aWasCallerChrome);
         970                 :
         971                 :   // Removes all elements from the full-screen stack, removing full-scren
         972                 :   // styles from the top element in the stack.
         973                 :   void ClearFullScreenStack();
         974                 :
         975                 :   // Pushes aElement onto the full-screen stack, and removes full-screen styles
         976                 :   // from the former full-screen stack top, and its ancestors, and applies the
         977                 :   // styles to aElement. aElement becomes the new "full-screen element".
         978                 :   bool FullScreenStackPush(Element* aElement);
         979                 :
         980                 :   // Remove the top element from the full-screen stack. Removes the full-screen
         981                 :   // styles from the former top element, and applies them to the new top
         982                 :   // element, if there is one.
         983                 :   void FullScreenStackPop();
         984                 :
         985                 :   // Returns the top element from the full-screen stack.
         986                 :   Element* FullScreenStackTop();
         987                 :
         988                 :   // This method may fire a DOM event; if it does so it will happen
         989                 :   // synchronously.
         990                 :   void UpdateVisibilityState();
         991                 :   // Posts an event to call UpdateVisibilityState
         992                 :   virtual void PostVisibilityUpdateEvent();
         993                 :
         994                 :   virtual void DocSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const;
         995                 :   // DocSizeOfIncludingThis is inherited from nsIDocument.
         996                 :
         997                 : protected:
         998                 :   friend class nsNodeUtils;
         999                 :
        1000                 :   // Returns true if a request for DOM full-screen is currently enabled in
        1001                 :   // this document. This returns true if there are no windowed plugins in this
        1002                 :   // doc tree, and if the document is visible, and if the api is not
        1003                 :   // disabled by pref. aIsCallerChrome must contain the return value of
        1004                 :   // nsContentUtils::IsCallerChrome() from the context we're checking.
        1005                 :   // If aLogFailure is true, an appropriate warning message is logged to the
        1006                 :   // console, and a "mozfullscreenerror" event is dispatched to this document.
        1007                 :   bool IsFullScreenEnabled(bool aIsCallerChrome, bool aLogFailure);
        1008                 :
        1009                 :   /**
        1010                 :    * Check that aId is not empty and log a message to the console
        1011                 :    * service if it is.
        1012                 :    * @returns true if aId looks correct, false otherwise.
        1013                 :    */
        1014              78 :   inline bool CheckGetElementByIdArg(const nsAString& aId)
        1015                 :   {
        1016              78 :     if (aId.IsEmpty()) {
        1017               0 :       ReportEmptyGetElementByIdArg();
        1018               0 :       return false;
        1019                 :     }
        1020              78 :     return true;
        1021                 :   }
        1022                 :
        1023                 :   void ReportEmptyGetElementByIdArg();
        1024                 :
        1025                 :   void DispatchContentLoadedEvents();
        1026                 :
        1027                 :   void RetrieveRelevantHeaders(nsIChannel *aChannel);
        1028                 :
        1029                 :   static bool TryChannelCharset(nsIChannel *aChannel,
        1030                 :                                   PRInt32& aCharsetSource,
        1031                 :                                   nsACString& aCharset);
        1032                 :
        1033                 :   // Call this before the document does something that will unbind all content.
        1034                 :   // That will stop us from doing a lot of work as each element is removed.
        1035                 :   void DestroyElementMaps();
        1036                 :
        1037                 :   // Refreshes the hrefs of all the links in the document.
        1038                 :   void RefreshLinkHrefs();
        1039                 :
        1040                 :   nsIContent* GetFirstBaseNodeWithHref();
        1041                 :   nsresult SetFirstBaseNodeWithHref(nsIContent *node);
        1042                 :
        1043                 :   // Get the first <title> element with the given IsNodeOfType type, or
        1044                 :   // return null if there isn't one
        1045                 :   nsIContent* GetTitleContent(PRUint32 aNodeType);
        1046                 :   // Find the first "title" element in the given IsNodeOfType type and
        1047                 :   // append the concatenation of its text node children to aTitle. Do
        1048                 :   // nothing if there is no such element.
        1049                 :   void GetTitleFromElement(PRUint32 aNodeType, nsAString& aTitle);
        1050                 :
        1051                 :   nsresult doCreateShell(nsPresContext* aContext,
        1052                 :                          nsIViewManager* aViewManager, nsStyleSet* aStyleSet,
        1053                 :                          nsCompatibility aCompatMode,
        1054                 :                          nsIPresShell** aInstancePtrResult);
        1055                 :
        1056                 :   nsresult ResetStylesheetsToURI(nsIURI* aURI);
        1057                 :   void FillStyleSet(nsStyleSet* aStyleSet);
        1058                 :
        1059                 :   // Return whether all the presshells for this document are safe to flush
        1060                 :   bool IsSafeToFlush() const;
        1061                 :
        1062                 :   void DispatchPageTransition(nsIDOMEventTarget* aDispatchTarget,
        1063                 :                               const nsAString& aType,
        1064                 :                               bool aPersisted);
        1065                 :
        1066                 :   virtual nsPIDOMWindow *GetWindowInternal() const;
        1067                 :   virtual nsPIDOMWindow *GetInnerWindowInternal();
        1068                 :   virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const;
        1069                 :   virtual bool InternalAllowXULXBL();
        1070                 :
        1071                 : #define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_)                        \
        1072                 :   NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \
        1073                 :                                            func_, params_);
        1074                 :
        1075                 : #ifdef DEBUG
        1076                 :   void VerifyRootContentState();
        1077                 : #endif
        1078                 :
        1079                 :   nsDocument(const char* aContentType);
        1080                 :   virtual ~nsDocument();
        1081                 :
        1082                 :   void EnsureOnloadBlocker();
        1083                 :
        1084                 :   nsCString mReferrer;
        1085                 :   nsString mLastModified;
        1086                 :
        1087                 :   nsTArray<nsIObserver*> mCharSetObservers;
        1088                 :
        1089                 :   PLDHashTable *mSubDocuments;
        1090                 :
        1091                 :   // Array of owning references to all children
        1092                 :   nsAttrAndChildArray mChildren;
        1093                 :
        1094                 :   // Pointer to our parser if we're currently in the process of being
        1095                 :   // parsed into.
        1096                 :   nsCOMPtr<nsIParser> mParser;
        1097                 :
        1098                 :   // Weak reference to our sink for in case we no longer have a parser.  This
        1099                 :   // will allow us to flush out any pending stuff from the sink even if
        1100                 :   // EndLoad() has already happened.
        1101                 :   nsWeakPtr mWeakSink;
        1102                 :
        1103                 :   nsCOMArray<nsIStyleSheet> mStyleSheets;
        1104                 :   nsCOMArray<nsIStyleSheet> mCatalogSheets;
        1105                 :
        1106                 :   // Array of observers
        1107                 :   nsTObserverArray<nsIDocumentObserver*> mObservers;
        1108                 :
        1109                 :   // If document is created for example using
        1110                 :   // document.implementation.createDocument(...), mScriptObject points to
        1111                 :   // the script global object of the original document.
        1112                 :   nsWeakPtr mScriptObject;
        1113                 :
        1114                 :   // Weak reference to the scope object (aka the script global object)
        1115                 :   // that, unlike mScriptGlobalObject, is never unset once set. This
        1116                 :   // is a weak reference to avoid leaks due to circular references.
        1117                 :   nsWeakPtr mScopeObject;
        1118                 :
        1119                 :   // The document which requested (and was granted) full-screen. All ancestors
        1120                 :   // of this document will also be full-screen.
        1121                 :   static nsWeakPtr sFullScreenDoc;
        1122                 :
        1123                 :   // The root document of the doctree containing the document which requested
        1124                 :   // full-screen. This root document will also be in full-screen state, as will
        1125                 :   // all the descendents down to the document which requested full-screen. This
        1126                 :   // reference allows us to reset full-screen state on all documents when a
        1127                 :   // document is hidden/navigation occurs.
        1128                 :   static nsWeakPtr sFullScreenRootDoc;
        1129                 :
        1130                 :   // Stack of full-screen elements. When we request full-screen we push the
        1131                 :   // full-screen element onto this stack, and when we cancel full-screen we
        1132                 :   // pop one off this stack, restoring the previous full-screen state
        1133                 :   nsTArray<nsWeakPtr> mFullScreenStack;
        1134                 :
        1135                 :   nsRefPtr<nsEventListenerManager> mListenerManager;
        1136                 :   nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
        1137                 :   nsRefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
        1138                 :   nsRefPtr<nsScriptLoader> mScriptLoader;
        1139                 :   nsDocHeaderData* mHeaderData;
        1140                 :   /* mIdentifierMap works as follows for IDs:
        1141                 :    * 1) Attribute changes affect the table immediately (removing and adding
        1142                 :    *    entries as needed).
        1143                 :    * 2) Removals from the DOM affect the table immediately
        1144                 :    * 3) Additions to the DOM always update existing entries for names, and add
        1145                 :    *    new ones for IDs.
        1146                 :    */
        1147                 :   nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
        1148                 :
        1149                 :   nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
        1150                 :
        1151                 :   // Recorded time of change to 'loading' state.
        1152                 :   mozilla::TimeStamp mLoadingTimeStamp;
        1153                 :
        1154                 :   // True if the document has been detached from its content viewer.
        1155                 :   bool mIsGoingAway:1;
        1156                 :   // True if the document is being destroyed.
        1157                 :   bool mInDestructor:1;
        1158                 :
        1159                 :   // True if this document has ever had an HTML or SVG <title> element
        1160                 :   // bound to it
        1161                 :   bool mMayHaveTitleElement:1;
        1162                 :
        1163                 :   bool mHasWarnedAboutBoxObjects:1;
        1164                 :
        1165                 :   bool mDelayFrameLoaderInitialization:1;
        1166                 :
        1167                 :   bool mSynchronousDOMContentLoaded:1;
        1168                 :
        1169                 :   // If true, we have an input encoding.  If this is false, then the
        1170                 :   // document was created entirely in memory
        1171                 :   bool mHaveInputEncoding:1;
        1172                 :
        1173                 :   bool mInXBLUpdate:1;
        1174                 :
        1175                 :   // This flag is only set in nsXMLDocument, for e.g. documents used in XBL. We
        1176                 :   // don't want animations to play in such documents, so we need to store the
        1177                 :   // flag here so that we can check it in nsDocument::GetAnimationController.
        1178                 :   bool mLoadedAsInteractiveData:1;
        1179                 :
        1180                 :   // Whether we're currently holding a lock on all of our images.
        1181                 :   bool mLockingImages:1;
        1182                 :
        1183                 :   // Whether we currently require our images to animate
        1184                 :   bool mAnimatingImages:1;
        1185                 :
        1186                 :   // Whether some node in this document has a listener for the
        1187                 :   // "mozaudioavailable" event.
        1188                 :   bool mHasAudioAvailableListener:1;
        1189                 :
        1190                 :   // Whether we are currently in full-screen mode, as per the DOM API.
        1191                 :   bool mIsFullScreen:1;
        1192                 :
        1193                 :   // Whether we're currently under a FlushPendingNotifications call to
        1194                 :   // our presshell.  This is used to handle flush reentry correctly.
        1195                 :   bool mInFlush:1;
        1196                 :
        1197                 :   // Parser aborted. True if the parser of this document was forcibly
        1198                 :   // terminated instead of letting it finish at its own pace.
        1199                 :   bool mParserAborted:1;
        1200                 :
        1201                 :   PRUint8 mXMLDeclarationBits;
        1202                 :
        1203                 :   nsInterfaceHashtable<nsVoidPtrHashKey, nsPIBoxObject> *mBoxObjectTable;
        1204                 :
        1205                 :   // The channel that got passed to StartDocumentLoad(), if any
        1206                 :   nsCOMPtr<nsIChannel> mChannel;
        1207                 :   nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet;
        1208                 :   nsRefPtr<nsHTMLCSSStyleSheet> mStyleAttrStyleSheet;
        1209                 :   nsRefPtr<nsXMLEventsManager> mXMLEventsManager;
        1210                 :
        1211                 :   // Our update nesting level
        1212                 :   PRUint32 mUpdateNestLevel;
        1213                 :
        1214                 :   // The application cache that this document is associated with, if
        1215                 :   // any.  This can change during the lifetime of the document.
        1216                 :   nsCOMPtr<nsIApplicationCache> mApplicationCache;
        1217                 :
        1218                 :   nsCOMPtr<nsIContent> mFirstBaseNodeWithHref;
        1219                 :
        1220                 :   nsEventStates mDocumentState;
        1221                 :   nsEventStates mGotDocumentState;
        1222                 :
        1223                 :   nsRefPtr<nsDOMNavigationTiming> mTiming;
        1224                 : private:
        1225                 :   friend class nsUnblockOnloadEvent;
        1226                 :   // This needs to stay in sync with the list in GetMozVisibilityState.
        1227                 :   enum VisibilityState {
        1228                 :     eHidden = 0,
        1229                 :     eVisible,
        1230                 :     eVisibilityStateCount
        1231                 :   };
        1232                 :   // Recomputes the visibility state but doesn't set the new value.
        1233                 :   VisibilityState GetVisibilityState() const;
        1234                 :
        1235                 :   void PostUnblockOnloadEvent();
        1236                 :   void DoUnblockOnload();
        1237                 :
        1238                 :   nsresult CheckFrameOptions();
        1239                 :   nsresult InitCSP();
        1240                 :
        1241                 :   /**
        1242                 :    * See if aDocument is a child of this.  If so, return the frame element in
        1243                 :    * this document that holds currentDoc (or an ancestor).
        1244                 :    */
        1245                 :   already_AddRefed<nsIDOMElement>
        1246                 :     CheckAncestryAndGetFrame(nsIDocument* aDocument) const;
        1247                 :
        1248                 :   // Just like EnableStyleSheetsForSet, but doesn't check whether
        1249                 :   // aSheetSet is null and allows the caller to control whether to set
        1250                 :   // aSheetSet as the preferred set in the CSSLoader.
        1251                 :   void EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
        1252                 :                                        bool aUpdateCSSLoader);
        1253                 :
        1254                 :   // Revoke any pending notifications due to mozRequestAnimationFrame calls
        1255                 :   void RevokeAnimationFrameNotifications();
        1256                 :   // Reschedule any notifications we need to handle
        1257                 :   // mozRequestAnimationFrame, if it's OK to do so.
        1258                 :   void MaybeRescheduleAnimationFrameNotifications();
        1259                 :
        1260                 :   // These are not implemented and not supported.
        1261                 :   nsDocument(const nsDocument& aOther);
        1262                 :   nsDocument& operator=(const nsDocument& aOther);
        1263                 :
        1264                 :   nsCOMPtr<nsISupports> mXPathEvaluatorTearoff;
        1265                 :
        1266                 :   // The layout history state that should be used by nodes in this
        1267                 :   // document.  We only actually store a pointer to it when:
        1268                 :   // 1)  We have no script global object.
        1269                 :   // 2)  We haven't had Destroy() called on us yet.
        1270                 :   nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
        1271                 :
        1272                 :   // Currently active onload blockers
        1273                 :   PRUint32 mOnloadBlockCount;
        1274                 :   // Onload blockers which haven't been activated yet
        1275                 :   PRUint32 mAsyncOnloadBlockCount;
        1276                 :   nsCOMPtr<nsIRequest> mOnloadBlocker;
        1277                 :   ReadyState mReadyState;
        1278                 :
        1279                 :   // A hashtable of styled links keyed by address pointer.
        1280                 :   nsTHashtable<nsPtrHashKey<mozilla::dom::Link> > mStyledLinks;
        1281                 : #ifdef DEBUG
        1282                 :   // Indicates whether mStyledLinks was cleared or not.  This is used to track
        1283                 :   // state so we can provide useful assertions to consumers of ForgetLink and
        1284                 :   // AddStyleRelevantLink.
        1285                 :   bool mStyledLinksCleared;
        1286                 : #endif
        1287                 :
        1288                 :   // Member to store out last-selected stylesheet set.
        1289                 :   nsString mLastStyleSheetSet;
        1290                 :
        1291                 :   nsTArray<nsRefPtr<nsFrameLoader> > mInitializableFrameLoaders;
        1292                 :   nsTArray<nsRefPtr<nsFrameLoader> > mFinalizableFrameLoaders;
        1293                 :   nsRefPtr<nsRunnableMethod<nsDocument> > mFrameLoaderRunner;
        1294                 :
        1295                 :   nsRevocableEventPtr<nsRunnableMethod<nsDocument, void, false> >
        1296                 :     mPendingTitleChangeEvent;
        1297                 :
        1298                 :   nsExternalResourceMap mExternalResourceMap;
        1299                 :
        1300                 :   // All images in process of being preloaded
        1301                 :   nsCOMArray<imgIRequest> mPreloadingImages;
        1302                 :
        1303                 :   nsCOMPtr<nsIDOMDOMImplementation> mDOMImplementation;
        1304                 :
        1305                 :   nsRefPtr<nsContentList> mImageMaps;
        1306                 :
        1307                 :   nsCString mScrollToRef;
        1308                 :   PRUint8 mScrolledToRefAlready : 1;
        1309                 :   PRUint8 mChangeScrollPosWhenScrollingToRef : 1;
        1310                 :
        1311                 :   // Tracking for images in the document.
        1312                 :   nsDataHashtable< nsPtrHashKey<imgIRequest>, PRUint32> mImageTracker;
        1313                 :
        1314                 :   VisibilityState mVisibilityState;
        1315                 :
        1316                 : #ifdef DEBUG
        1317                 : protected:
        1318                 :   bool mWillReparent;
        1319                 : #endif
        1320                 : };
        1321                 :
        1322                 : #define NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class)                             \
        1323                 :   NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
        1324                 :   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocument, nsDocument)      \
        1325                 :   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMEventTarget, nsDocument)   \
        1326                 :   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument)
        1327                 :
        1328                 : #endif /* nsDocument_h___ */

Generated by: LCOV version 1.7