2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Base class for all our document implementations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsDocument_h___
|
|
|
|
#define nsDocument_h___
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsWeakPtr.h"
|
|
|
|
#include "nsVoidArray.h"
|
2009-03-20 01:15:35 -07:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsHashSets.h"
|
|
|
|
#include "nsIDOMXMLDocument.h"
|
|
|
|
#include "nsIDOM3Document.h"
|
|
|
|
#include "nsIDOMDocumentView.h"
|
|
|
|
#include "nsIDOMDocumentXBL.h"
|
|
|
|
#include "nsIDOMNSDocument.h"
|
|
|
|
#include "nsIDOMNSDocumentStyle.h"
|
|
|
|
#include "nsIDOMDocumentRange.h"
|
|
|
|
#include "nsIDOMDocumentTraversal.h"
|
|
|
|
#include "nsStubDocumentObserver.h"
|
|
|
|
#include "nsIDOM3EventTarget.h"
|
|
|
|
#include "nsIDOMNSEventTarget.h"
|
|
|
|
#include "nsIDOMStyleSheetList.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIEventListenerManager.h"
|
|
|
|
#include "nsIDOM3Node.h"
|
2008-07-21 17:55:52 -07:00
|
|
|
#include "nsIDOMNodeSelector.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIParser.h"
|
|
|
|
#include "nsBindingManager.h"
|
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsIDOMDocumentEvent.h"
|
|
|
|
#include "nsIDOM3DocumentEvent.h"
|
|
|
|
#include "nsHashtable.h"
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsIBoxObject.h"
|
|
|
|
#include "nsPIBoxObject.h"
|
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsScriptLoader.h"
|
|
|
|
#include "nsIRadioGroupContainer.h"
|
|
|
|
#include "nsIScriptEventManager.h"
|
|
|
|
#include "nsILayoutHistoryState.h"
|
|
|
|
#include "nsIRequest.h"
|
|
|
|
#include "nsILoadGroup.h"
|
|
|
|
#include "nsTObserverArray.h"
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsIChannel.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2008-06-22 16:12:40 -07:00
|
|
|
#include "nsContentList.h"
|
2008-08-17 19:10:28 -07:00
|
|
|
#include "nsGkAtoms.h"
|
2008-08-26 16:09:02 -07:00
|
|
|
#include "nsIApplicationCache.h"
|
|
|
|
#include "nsIApplicationCacheContainer.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsStyleSet.h"
|
|
|
|
#include "pldhash.h"
|
|
|
|
#include "nsAttrAndChildArray.h"
|
|
|
|
#include "nsDOMAttributeMap.h"
|
2008-07-19 08:11:37 -07:00
|
|
|
#include "nsContentUtils.h"
|
2008-08-17 19:10:28 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2008-10-04 13:00:09 -07:00
|
|
|
#include "nsIDocumentViewer.h"
|
2009-06-14 11:06:22 -07:00
|
|
|
#include "nsIDOMXPathNSResolver.h"
|
2008-10-04 13:00:09 -07:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2008-11-24 10:32:04 -08:00
|
|
|
#include "nsILoadContext.h"
|
|
|
|
#include "nsIProgressEventSink.h"
|
|
|
|
#include "nsISecurityEventSink.h"
|
|
|
|
#include "nsIChannelEventSink.h"
|
2009-07-07 22:23:20 -07:00
|
|
|
#include "imgIRequest.h"
|
2009-10-18 09:39:52 -07:00
|
|
|
#include "nsIDOMDOMImplementation.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
|
|
|
|
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
|
|
|
|
#define XML_DECLARATION_BITS_STANDALONE_EXISTS (1 << 2)
|
|
|
|
#define XML_DECLARATION_BITS_STANDALONE_YES (1 << 3)
|
|
|
|
|
|
|
|
|
|
|
|
class nsIEventListenerManager;
|
|
|
|
class nsDOMStyleSheetList;
|
|
|
|
class nsDOMStyleSheetSetList;
|
|
|
|
class nsIOutputStream;
|
|
|
|
class nsDocument;
|
|
|
|
class nsIDTD;
|
|
|
|
class nsIRadioVisitor;
|
|
|
|
class nsIFormControl;
|
|
|
|
struct nsRadioGroupStruct;
|
|
|
|
class nsOnloadBlocker;
|
|
|
|
class nsUnblockOnloadEvent;
|
|
|
|
class nsChildContentList;
|
2010-04-19 08:41:39 -07:00
|
|
|
class nsXMLEventsManager;
|
|
|
|
class nsHTMLStyleSheet;
|
|
|
|
class nsHTMLCSSStyleSheet;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-06-22 16:12:40 -07:00
|
|
|
/**
|
|
|
|
* Right now our identifier map entries contain information for 'name'
|
|
|
|
* and 'id' mappings of a given string. This is so that
|
|
|
|
* nsHTMLDocument::ResolveName only has to do one hash lookup instead
|
|
|
|
* of two. It's not clear whether this still matters for performance.
|
|
|
|
*
|
|
|
|
* We also store the document.all result list here. This is mainly so that
|
|
|
|
* when all elements with the given ID are removed and we remove
|
|
|
|
* the ID's nsIdentifierMapEntry, the document.all result is released too.
|
|
|
|
* Perhaps the document.all results should have their own hashtable
|
|
|
|
* in nsHTMLDocument.
|
|
|
|
*/
|
2010-06-21 19:59:37 -07:00
|
|
|
class nsIdentifierMapEntry : public nsStringHashKey
|
2008-06-22 16:12:40 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-05-14 10:04:51 -07:00
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2010-06-21 19:59:37 -07:00
|
|
|
nsIdentifierMapEntry(const nsAString& aKey) :
|
|
|
|
nsStringHashKey(&aKey), mNameContentList(nsnull)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
nsIdentifierMapEntry(const nsAString *aKey) :
|
|
|
|
nsStringHashKey(aKey), mNameContentList(nsnull)
|
2008-06-22 16:12:40 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
nsIdentifierMapEntry(const nsIdentifierMapEntry& aOther) :
|
2010-06-21 19:59:37 -07:00
|
|
|
nsStringHashKey(&aOther.GetKey())
|
2008-06-22 16:12:40 -07:00
|
|
|
{
|
|
|
|
NS_ERROR("Should never be called");
|
|
|
|
}
|
|
|
|
~nsIdentifierMapEntry();
|
|
|
|
|
|
|
|
void SetInvalidName();
|
|
|
|
PRBool IsInvalidName();
|
2010-05-14 10:04:51 -07:00
|
|
|
void AddNameElement(Element* aElement);
|
|
|
|
void RemoveNameElement(Element* aElement);
|
2008-06-22 16:12:40 -07:00
|
|
|
PRBool HasNameContentList() {
|
|
|
|
return mNameContentList != nsnull;
|
|
|
|
}
|
2010-08-13 06:35:36 -07:00
|
|
|
PRBool IsEmpty();
|
2008-06-22 16:12:40 -07:00
|
|
|
nsBaseContentList* GetNameContentList() {
|
|
|
|
return mNameContentList;
|
|
|
|
}
|
|
|
|
nsresult CreateNameContentList();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the element if we know the element associated with this
|
|
|
|
* id. Otherwise returns null.
|
|
|
|
*/
|
2010-05-14 10:04:51 -07:00
|
|
|
Element* GetIdElement();
|
2010-08-13 06:35:36 -07:00
|
|
|
/**
|
|
|
|
* If this entry has a non-null image element set (using SetImageElement),
|
|
|
|
* the image element will be returned, otherwise the same as GetIdElement().
|
|
|
|
*/
|
|
|
|
Element* GetImageIdElement();
|
2009-03-23 07:04:40 -07:00
|
|
|
/**
|
|
|
|
* Append all the elements with this id to aElements
|
|
|
|
*/
|
2008-06-22 18:48:05 -07:00
|
|
|
void AppendAllIdContent(nsCOMArray<nsIContent>* aElements);
|
2008-06-24 18:55:01 -07:00
|
|
|
/**
|
|
|
|
* This can fire ID change callbacks.
|
|
|
|
* @return true if the content could be added, false if we failed due
|
|
|
|
* to OOM.
|
|
|
|
*/
|
2010-05-14 10:04:51 -07:00
|
|
|
PRBool AddIdElement(Element* aElement);
|
2008-06-22 18:48:05 -07:00
|
|
|
/**
|
2008-06-24 18:55:01 -07:00
|
|
|
* This can fire ID change callbacks.
|
2008-06-22 18:48:05 -07:00
|
|
|
*/
|
2010-08-13 06:35:36 -07:00
|
|
|
void RemoveIdElement(Element* aElement);
|
|
|
|
/**
|
|
|
|
* Set the image element override for this ID. This will be returned by
|
|
|
|
* GetIdElement(PR_TRUE) if non-null.
|
|
|
|
*/
|
|
|
|
void SetImageElement(Element* aElement);
|
2008-06-22 16:12:40 -07:00
|
|
|
|
2008-06-24 18:55:01 -07:00
|
|
|
PRBool HasContentChangeCallback() { return mChangeCallbacks != nsnull; }
|
2010-08-13 06:35:36 -07:00
|
|
|
void AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
|
|
|
|
void* aData, PRBool aForImage);
|
|
|
|
void RemoveContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
|
|
|
|
void* aData, PRBool aForImage);
|
2008-06-24 18:55:01 -07:00
|
|
|
|
2008-06-22 16:12:40 -07:00
|
|
|
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
|
|
|
|
|
|
|
|
void SetDocAllList(nsContentList* aContentList) { mDocAllList = aContentList; }
|
|
|
|
nsContentList* GetDocAllList() { return mDocAllList; }
|
|
|
|
|
2008-06-24 18:55:01 -07:00
|
|
|
struct ChangeCallback {
|
|
|
|
nsIDocument::IDTargetObserver mCallback;
|
|
|
|
void* mData;
|
2010-08-13 06:35:36 -07:00
|
|
|
PRBool mForImage;
|
2008-06-24 18:55:01 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ChangeCallbackEntry : public PLDHashEntryHdr {
|
|
|
|
typedef const ChangeCallback KeyType;
|
|
|
|
typedef const ChangeCallback* KeyTypePointer;
|
|
|
|
|
|
|
|
ChangeCallbackEntry(const ChangeCallback* key) :
|
|
|
|
mKey(*key) { }
|
|
|
|
ChangeCallbackEntry(const ChangeCallbackEntry& toCopy) :
|
|
|
|
mKey(toCopy.mKey) { }
|
|
|
|
|
|
|
|
KeyType GetKey() const { return mKey; }
|
|
|
|
PRBool KeyEquals(KeyTypePointer aKey) const {
|
|
|
|
return aKey->mCallback == mKey.mCallback &&
|
2010-08-13 06:35:36 -07:00
|
|
|
aKey->mData == mKey.mData &&
|
|
|
|
aKey->mForImage == mKey.mForImage;
|
2008-06-24 18:55:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
|
|
|
|
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
|
|
|
{
|
2008-10-12 10:26:58 -07:00
|
|
|
return (NS_PTR_TO_INT32(aKey->mCallback) >> 2) ^
|
|
|
|
(NS_PTR_TO_INT32(aKey->mData));
|
2008-06-24 18:55:01 -07:00
|
|
|
}
|
|
|
|
enum { ALLOW_MEMMOVE = PR_TRUE };
|
|
|
|
|
|
|
|
ChangeCallback mKey;
|
|
|
|
};
|
|
|
|
|
2008-06-22 16:12:40 -07:00
|
|
|
private:
|
2010-08-13 06:35:36 -07:00
|
|
|
void FireChangeCallbacks(Element* aOldElement, Element* aNewElement,
|
|
|
|
PRBool aImageOnly = PR_FALSE);
|
2008-06-24 18:55:01 -07:00
|
|
|
|
2010-04-30 06:12:05 -07:00
|
|
|
// empty if there are no elementswith this ID.
|
2010-09-01 15:48:24 -07:00
|
|
|
// The elements are stored as weak pointers.
|
2008-06-22 16:12:40 -07:00
|
|
|
nsSmallVoidArray mIdContentList;
|
2010-04-30 06:12:05 -07:00
|
|
|
// NAME_NOT_VALID if this id cannot be used as a 'name'. Otherwise
|
|
|
|
// stores Elements.
|
2008-06-22 16:12:40 -07:00
|
|
|
nsBaseContentList *mNameContentList;
|
|
|
|
nsRefPtr<nsContentList> mDocAllList;
|
2008-06-24 18:55:01 -07:00
|
|
|
nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks;
|
2010-09-03 15:40:10 -07:00
|
|
|
nsRefPtr<Element> mImageElement;
|
2008-06-22 16:12:40 -07:00
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsDocHeaderData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsDocHeaderData(nsIAtom* aField, const nsAString& aData)
|
|
|
|
: mField(aField), mData(aData), mNext(nsnull)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsDocHeaderData(void)
|
|
|
|
{
|
|
|
|
delete mNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAtom> mField;
|
|
|
|
nsString mData;
|
|
|
|
nsDocHeaderData* mNext;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsDOMStyleSheetList : public nsIDOMStyleSheetList,
|
|
|
|
public nsStubDocumentObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsDOMStyleSheetList(nsIDocument *aDocument);
|
|
|
|
virtual ~nsDOMStyleSheetList();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_DECL_NSIDOMSTYLESHEETLIST
|
|
|
|
|
|
|
|
// nsIDocumentObserver
|
2010-10-20 00:41:05 -07:00
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED
|
|
|
|
|
|
|
|
// nsIMutationObserver
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-22 07:31:14 -07:00
|
|
|
nsIStyleSheet* GetItemAt(PRUint32 aIndex);
|
|
|
|
|
|
|
|
static nsDOMStyleSheetList* FromSupports(nsISupports* aSupports)
|
|
|
|
{
|
|
|
|
nsIDOMStyleSheetList* list = static_cast<nsIDOMStyleSheetList*>(aSupports);
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMStyleSheetList> list_qi = do_QueryInterface(aSupports);
|
|
|
|
|
|
|
|
// If this assertion fires the QI implementation for the object in
|
|
|
|
// question doesn't use the nsIDOMStyleSheetList pointer as the
|
|
|
|
// nsISupports pointer. That must be fixed, or we'll crash...
|
|
|
|
NS_ASSERTION(list_qi == list, "Uh, fix QI!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return static_cast<nsDOMStyleSheetList*>(list);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
PRInt32 mLength;
|
|
|
|
nsIDocument* mDocument;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsOnloadBlocker : public nsIRequest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsOnloadBlocker() {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIREQUEST
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsOnloadBlocker() {}
|
|
|
|
};
|
|
|
|
|
2008-10-04 13:00:09 -07:00
|
|
|
class nsExternalResourceMap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef nsIDocument::ExternalResourceLoad ExternalResourceLoad;
|
|
|
|
nsExternalResourceMap();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request an external resource document. This does exactly what
|
|
|
|
* nsIDocument::RequestExternalResource is documented to do.
|
|
|
|
*/
|
|
|
|
nsIDocument* RequestResource(nsIURI* aURI,
|
|
|
|
nsINode* aRequestingNode,
|
|
|
|
nsDocument* aDisplayDocument,
|
|
|
|
ExternalResourceLoad** aPendingLoad);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumerate the resource documents. See
|
|
|
|
* nsIDocument::EnumerateExternalResources.
|
|
|
|
*/
|
|
|
|
void EnumerateResources(nsIDocument::nsSubDocEnumFunc aCallback, void* aData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Traverse ourselves for cycle-collection
|
|
|
|
*/
|
|
|
|
void Traverse(nsCycleCollectionTraversalCallback* aCallback) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shut ourselves down (used for cycle-collection unlink), as well
|
|
|
|
* as for document destruction.
|
|
|
|
*/
|
|
|
|
void Shutdown()
|
|
|
|
{
|
|
|
|
mPendingLoads.Clear();
|
|
|
|
mMap.Clear();
|
|
|
|
mHaveShutDown = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool HaveShutDown() const
|
|
|
|
{
|
|
|
|
return mHaveShutDown;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Needs to be public so we can traverse them sanely
|
|
|
|
struct ExternalResource
|
|
|
|
{
|
|
|
|
~ExternalResource();
|
|
|
|
nsCOMPtr<nsIDocument> mDocument;
|
|
|
|
nsCOMPtr<nsIContentViewer> mViewer;
|
|
|
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
|
|
|
};
|
|
|
|
|
2010-08-11 14:05:26 -07:00
|
|
|
// Hide all our viewers
|
|
|
|
void HideViewers();
|
|
|
|
|
|
|
|
// Show all our viewers
|
|
|
|
void ShowViewers();
|
|
|
|
|
2008-10-04 13:00:09 -07:00
|
|
|
protected:
|
|
|
|
class PendingLoad : public ExternalResourceLoad,
|
|
|
|
public nsIStreamListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PendingLoad(nsDocument* aDisplayDocument) :
|
|
|
|
mDisplayDocument(aDisplayDocument)
|
|
|
|
{}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start aURI loading. This will perform the necessary security checks and
|
|
|
|
* so forth.
|
|
|
|
*/
|
|
|
|
nsresult StartLoad(nsIURI* aURI, nsINode* aRequestingNode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up an nsIDocumentViewer based on aRequest. This is guaranteed to
|
|
|
|
* put null in *aViewer and *aLoadGroup on all failures.
|
|
|
|
*/
|
|
|
|
nsresult SetupViewer(nsIRequest* aRequest, nsIDocumentViewer** aViewer,
|
|
|
|
nsILoadGroup** aLoadGroup);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<nsDocument> mDisplayDocument;
|
|
|
|
nsCOMPtr<nsIStreamListener> mTargetListener;
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
};
|
|
|
|
friend class PendingLoad;
|
|
|
|
|
|
|
|
class LoadgroupCallbacks : public nsIInterfaceRequestor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LoadgroupCallbacks(nsIInterfaceRequestor* aOtherCallbacks)
|
|
|
|
: mCallbacks(aOtherCallbacks)
|
|
|
|
{}
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
private:
|
2008-11-24 10:32:04 -08:00
|
|
|
// The only reason it's safe to hold a strong ref here without leaking is
|
|
|
|
// that the notificationCallbacks on a loadgroup aren't the docshell itself
|
|
|
|
// but a shim that holds a weak reference to the docshell.
|
2008-10-04 13:00:09 -07:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
2008-11-24 10:32:04 -08:00
|
|
|
|
|
|
|
// Use shims for interfaces that docshell implements directly so that we
|
|
|
|
// don't hand out references to the docshell. The shims should all allow
|
|
|
|
// getInterface back on us, but other than that each one should only
|
|
|
|
// implement one interface.
|
|
|
|
|
|
|
|
// XXXbz I wish we could just derive the _allcaps thing from _i
|
|
|
|
#define DECL_SHIM(_i, _allcaps) \
|
|
|
|
class _i##Shim : public nsIInterfaceRequestor, \
|
|
|
|
public _i \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
_i##Shim(nsIInterfaceRequestor* aIfreq, _i* aRealPtr) \
|
|
|
|
: mIfReq(aIfreq), mRealPtr(aRealPtr) \
|
|
|
|
{ \
|
|
|
|
NS_ASSERTION(mIfReq, "Expected non-null here"); \
|
|
|
|
NS_ASSERTION(mRealPtr, "Expected non-null here"); \
|
|
|
|
} \
|
|
|
|
NS_DECL_ISUPPORTS \
|
|
|
|
NS_FORWARD_NSIINTERFACEREQUESTOR(mIfReq->); \
|
|
|
|
NS_FORWARD_##_allcaps(mRealPtr->); \
|
|
|
|
private: \
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> mIfReq; \
|
|
|
|
nsCOMPtr<_i> mRealPtr; \
|
|
|
|
};
|
|
|
|
|
|
|
|
DECL_SHIM(nsILoadContext, NSILOADCONTEXT)
|
|
|
|
DECL_SHIM(nsIProgressEventSink, NSIPROGRESSEVENTSINK)
|
|
|
|
DECL_SHIM(nsIChannelEventSink, NSICHANNELEVENTSINK)
|
|
|
|
DECL_SHIM(nsISecurityEventSink, NSISECURITYEVENTSINK)
|
|
|
|
DECL_SHIM(nsIApplicationCacheContainer, NSIAPPLICATIONCACHECONTAINER)
|
|
|
|
#undef DECL_SHIM
|
2008-10-04 13:00:09 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an ExternalResource for aURI. aViewer and aLoadGroup might be null
|
|
|
|
* when this is called if the URI didn't result in an XML document. This
|
|
|
|
* function makes sure to remove the pending load for aURI, if any, from our
|
|
|
|
* hashtable, and to notify its observers, if any.
|
|
|
|
*/
|
|
|
|
nsresult AddExternalResource(nsIURI* aURI, nsIDocumentViewer* aViewer,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsIDocument* aDisplayDocument);
|
|
|
|
|
|
|
|
nsClassHashtable<nsURIHashKey, ExternalResource> mMap;
|
|
|
|
nsRefPtrHashtable<nsURIHashKey, PendingLoad> mPendingLoads;
|
|
|
|
PRPackedBool mHaveShutDown;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Base class for our document implementations.
|
|
|
|
//
|
|
|
|
// Note that this class *implements* nsIDOMXMLDocument, but it's not
|
|
|
|
// really an nsIDOMXMLDocument. The reason for implementing
|
|
|
|
// nsIDOMXMLDocument on this class is to avoid having to duplicate all
|
|
|
|
// its inherited methods on document classes that *are*
|
|
|
|
// nsIDOMXMLDocument's. nsDocument's QI should *not* claim to support
|
|
|
|
// nsIDOMXMLDocument unless someone writes a real implementation of
|
|
|
|
// the interface.
|
|
|
|
class nsDocument : public nsIDocument,
|
|
|
|
public nsIDOMXMLDocument, // inherits nsIDOMDocument
|
|
|
|
public nsIDOMNSDocument,
|
|
|
|
public nsIDOMDocumentEvent,
|
|
|
|
public nsIDOM3DocumentEvent,
|
|
|
|
public nsIDOMNSDocumentStyle,
|
|
|
|
public nsIDOMDocumentView,
|
|
|
|
public nsIDOMDocumentRange,
|
|
|
|
public nsIDOMDocumentTraversal,
|
|
|
|
public nsIDOMDocumentXBL,
|
|
|
|
public nsIDOM3Document,
|
|
|
|
public nsSupportsWeakReference,
|
2007-05-14 02:11:38 -07:00
|
|
|
public nsIDOMEventTarget,
|
2007-03-22 10:30:00 -07:00
|
|
|
public nsIDOM3EventTarget,
|
|
|
|
public nsIDOMNSEventTarget,
|
|
|
|
public nsIScriptObjectPrincipal,
|
2011-02-25 10:12:47 -08:00
|
|
|
public nsIRadioGroupContainer_MOZILLA_2_0_BRANCH,
|
2008-08-26 16:09:02 -07:00
|
|
|
public nsIApplicationCacheContainer,
|
2011-03-25 08:03:33 -07:00
|
|
|
public nsStubMutationObserver
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-06-23 02:31:35 -07:00
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
2010-01-18 16:54:29 -08:00
|
|
|
using nsINode::GetScriptTypeID;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void Reset(nsIChannel *aChannel, nsILoadGroup *aLoadGroup);
|
|
|
|
virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
|
|
|
nsIPrincipal* aPrincipal);
|
|
|
|
|
|
|
|
// StartDocumentLoad is pure virtual so that subclasses must override it.
|
|
|
|
// The nsDocument StartDocumentLoad does some setup, but does NOT set
|
|
|
|
// *aDocListener; this is the job of subclasses.
|
|
|
|
virtual nsresult StartDocumentLoad(const char* aCommand,
|
|
|
|
nsIChannel* aChannel,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsISupports* aContainer,
|
|
|
|
nsIStreamListener **aDocListener,
|
|
|
|
PRBool aReset = PR_TRUE,
|
|
|
|
nsIContentSink* aContentSink = nsnull) = 0;
|
|
|
|
|
|
|
|
virtual void StopDocumentLoad();
|
|
|
|
|
2008-08-17 19:10:28 -07:00
|
|
|
virtual void NotifyPossibleTitleChange(PRBool aBoundTitleElement);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void SetDocumentURI(nsIURI* aURI);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the principal responsible for this document.
|
|
|
|
*/
|
|
|
|
virtual void SetPrincipal(nsIPrincipal *aPrincipal);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Content-Type of this document.
|
|
|
|
*/
|
|
|
|
// NS_IMETHOD GetContentType(nsAString& aContentType);
|
|
|
|
// Already declared in nsIDOMNSDocument
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Content-Type of this document.
|
|
|
|
*/
|
|
|
|
virtual void SetContentType(const nsAString& aContentType);
|
|
|
|
|
|
|
|
virtual nsresult SetBaseURI(nsIURI* aURI);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get/Set the base target of a link in a document.
|
|
|
|
*/
|
2010-04-23 09:10:07 -07:00
|
|
|
virtual void GetBaseTarget(nsAString &aBaseTarget);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a standard name for the document's character set. This will
|
|
|
|
* trigger a startDocumentLoad if necessary to answer the question.
|
|
|
|
*/
|
|
|
|
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an observer that gets notified whenever the charset changes.
|
|
|
|
*/
|
|
|
|
virtual nsresult AddCharSetObserver(nsIObserver* aObserver);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a charset observer.
|
|
|
|
*/
|
|
|
|
virtual void RemoveCharSetObserver(nsIObserver* aObserver);
|
|
|
|
|
2010-05-14 10:04:51 -07:00
|
|
|
virtual Element* AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
|
2010-08-13 06:35:36 -07:00
|
|
|
void* aData, PRBool aForImage);
|
|
|
|
virtual void RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
|
|
|
|
void* aData, PRBool aForImage);
|
2008-06-24 18:55:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Access HTTP header data (this may also get set from other sources, like
|
|
|
|
* HTML META tags).
|
|
|
|
*/
|
|
|
|
virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const;
|
|
|
|
virtual void SetHeaderData(nsIAtom* aheaderField,
|
|
|
|
const nsAString& aData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new presentation shell that will use aContext for
|
2009-01-23 01:02:09 -08:00
|
|
|
* its presentation context (presentation context's <b>must not</b> be
|
2007-03-22 10:30:00 -07:00
|
|
|
* shared among multiple presentation shell's).
|
|
|
|
*/
|
|
|
|
virtual nsresult CreateShell(nsPresContext* aContext,
|
|
|
|
nsIViewManager* aViewManager,
|
|
|
|
nsStyleSet* aStyleSet,
|
|
|
|
nsIPresShell** aInstancePtrResult);
|
2010-08-11 14:05:26 -07:00
|
|
|
virtual void DeleteShell();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual nsresult SetSubDocumentFor(nsIContent *aContent,
|
|
|
|
nsIDocument* aSubDoc);
|
|
|
|
virtual nsIDocument* GetSubDocumentFor(nsIContent *aContent) const;
|
|
|
|
virtual nsIContent* FindContentForSubDocument(nsIDocument *aDocument) const;
|
2010-05-14 10:04:51 -07:00
|
|
|
virtual Element* GetRootElementInternal() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the style sheets owned by this document.
|
|
|
|
* These are ordered, highest priority last
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetNumberOfStyleSheets() const;
|
|
|
|
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) const;
|
|
|
|
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const;
|
|
|
|
virtual void AddStyleSheet(nsIStyleSheet* aSheet);
|
|
|
|
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
|
|
|
|
|
|
|
|
virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
|
|
|
nsCOMArray<nsIStyleSheet>& aNewSheets);
|
|
|
|
virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
|
|
|
|
virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
|
|
|
|
|
|
|
|
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
|
|
|
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
|
|
|
PRBool aApplicable);
|
|
|
|
|
|
|
|
virtual PRInt32 GetNumberOfCatalogStyleSheets() const;
|
|
|
|
virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const;
|
|
|
|
virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet);
|
|
|
|
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI);
|
|
|
|
|
|
|
|
virtual nsIChannel* GetChannel() const {
|
|
|
|
return mChannel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get this document's attribute stylesheet. May return null if
|
|
|
|
* there isn't one.
|
|
|
|
*/
|
|
|
|
virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const {
|
|
|
|
return mAttrStyleSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get this document's inline style sheet. May return null if there
|
|
|
|
* isn't one
|
|
|
|
*/
|
2009-12-31 07:56:33 -08:00
|
|
|
virtual nsHTMLCSSStyleSheet* GetInlineStyleSheet() const {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mStyleAttrStyleSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the object from which a document can get a script context.
|
|
|
|
* This is the context within which all scripts (during document
|
|
|
|
* creation and during event handling) will run.
|
|
|
|
*/
|
|
|
|
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const;
|
|
|
|
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
|
|
|
|
|
2007-10-01 03:02:32 -07:00
|
|
|
virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsIScriptGlobalObject* GetScopeObject();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the script loader for this document
|
|
|
|
*/
|
2007-05-30 13:43:41 -07:00
|
|
|
virtual nsScriptLoader* ScriptLoader();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-03 18:09:20 -07:00
|
|
|
/**
|
|
|
|
* Add/Remove an element to the document's id and name hashes
|
|
|
|
*/
|
2010-08-13 06:35:36 -07:00
|
|
|
virtual void AddToIdTable(Element* aElement, nsIAtom* aId);
|
|
|
|
virtual void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
|
|
|
|
virtual void AddToNameTable(Element* aElement, nsIAtom* aName);
|
|
|
|
virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName);
|
2010-06-03 18:09:20 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Add a new observer of document change notifications. Whenever
|
|
|
|
* content is changed, appended, inserted or removed the observers are
|
|
|
|
* informed.
|
|
|
|
*/
|
|
|
|
virtual void AddObserver(nsIDocumentObserver* aObserver);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an observer of document change notifications. This will
|
|
|
|
* return false if the observer cannot be found.
|
|
|
|
*/
|
|
|
|
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
|
|
|
|
|
|
|
|
// Observation hooks used to propagate notifications to document
|
|
|
|
// observers.
|
|
|
|
virtual void BeginUpdate(nsUpdateType aUpdateType);
|
|
|
|
virtual void EndUpdate(nsUpdateType aUpdateType);
|
|
|
|
virtual void BeginLoad();
|
|
|
|
virtual void EndLoad();
|
2009-01-09 09:12:09 -08:00
|
|
|
|
|
|
|
virtual void SetReadyStateInternal(ReadyState rs);
|
2009-06-26 10:16:50 -07:00
|
|
|
virtual ReadyState GetReadyStateEnum();
|
2009-01-09 09:12:09 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void ContentStatesChanged(nsIContent* aContent1,
|
|
|
|
nsIContent* aContent2,
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aStateMask);
|
|
|
|
virtual void DocumentStatesChanged(nsEventStates aStateMask);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aOldStyleRule,
|
|
|
|
nsIStyleRule* aNewStyleRule);
|
|
|
|
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule);
|
|
|
|
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule);
|
|
|
|
|
|
|
|
virtual void FlushPendingNotifications(mozFlushType aType);
|
2010-04-10 11:03:40 -07:00
|
|
|
virtual void FlushExternalResources(mozFlushType aType);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsIScriptEventManager* GetScriptEventManager();
|
|
|
|
virtual void SetXMLDeclaration(const PRUnichar *aVersion,
|
|
|
|
const PRUnichar *aEncoding,
|
|
|
|
const PRInt32 aStandalone);
|
|
|
|
virtual void GetXMLDeclaration(nsAString& aVersion,
|
|
|
|
nsAString& aEncoding,
|
|
|
|
nsAString& Standalone);
|
|
|
|
virtual PRBool IsScriptEnabled();
|
|
|
|
|
2009-02-26 14:05:42 -08:00
|
|
|
virtual void OnPageShow(PRBool aPersisted, nsIDOMEventTarget* aDispatchStartTarget);
|
|
|
|
virtual void OnPageHide(PRBool aPersisted, nsIDOMEventTarget* aDispatchStartTarget);
|
2007-03-24 05:18:02 -07:00
|
|
|
|
|
|
|
virtual void WillDispatchMutationEvent(nsINode* aTarget);
|
|
|
|
virtual void MutationEventDispatched(nsINode* aTarget);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsINode
|
|
|
|
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
|
|
|
virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
|
2008-12-03 06:02:03 -08:00
|
|
|
virtual nsIContent * const * GetChildArray(PRUint32* aChildCount) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
|
|
|
virtual PRUint32 GetChildCount() const;
|
|
|
|
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
|
|
|
PRBool aNotify);
|
|
|
|
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
2009-06-28 15:44:22 -07:00
|
|
|
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
|
|
|
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
|
|
|
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsEventStatus* aEventStatus);
|
2009-06-23 04:23:52 -07:00
|
|
|
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
|
2007-05-14 02:11:38 -07:00
|
|
|
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
|
|
|
|
const nsIID& aIID);
|
|
|
|
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
|
|
|
|
const nsIID& aIID);
|
|
|
|
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
2009-04-24 02:18:37 -07:00
|
|
|
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv)
|
2008-07-19 08:11:37 -07:00
|
|
|
{
|
2009-04-24 02:18:37 -07:00
|
|
|
return nsContentUtils::GetContextForEventHandlers(this, aRv);
|
2008-07-19 08:11:37 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2010-04-19 08:40:17 -07:00
|
|
|
virtual PRBool IsEqualNode(nsINode* aOther);
|
2010-04-19 08:41:33 -07:00
|
|
|
virtual void GetTextContent(nsAString &aTextContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIRadioGroupContainer
|
|
|
|
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
|
|
|
|
nsIRadioVisitor* aVisitor,
|
|
|
|
PRBool aFlushContent);
|
|
|
|
NS_IMETHOD SetCurrentRadioButton(const nsAString& aName,
|
|
|
|
nsIDOMHTMLInputElement* aRadio);
|
|
|
|
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
|
|
|
nsIDOMHTMLInputElement** aRadio);
|
|
|
|
NS_IMETHOD GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
|
|
|
|
PRInt32 *aPositionIndex,
|
|
|
|
PRInt32 *aItemsInGroup);
|
|
|
|
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
|
|
|
const PRBool aPrevious,
|
|
|
|
nsIDOMHTMLInputElement* aFocusedRadio,
|
|
|
|
nsIDOMHTMLInputElement** aRadioOut);
|
|
|
|
NS_IMETHOD AddToRadioGroup(const nsAString& aName,
|
|
|
|
nsIFormControl* aRadio);
|
|
|
|
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
|
|
|
|
nsIFormControl* aRadio);
|
2011-02-25 10:12:47 -08:00
|
|
|
virtual PRUint32 GetRequiredRadioCount(const nsAString& aName) const;
|
|
|
|
virtual void RadioRequiredChanged(const nsAString& aName,
|
|
|
|
nsIFormControl* aRadio);
|
2011-02-25 10:16:04 -08:00
|
|
|
virtual bool GetValueMissingState(const nsAString& aName) const;
|
|
|
|
virtual void SetValueMissingState(const nsAString& aName, bool aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// for radio group
|
|
|
|
nsresult GetRadioGroup(const nsAString& aName,
|
|
|
|
nsRadioGroupStruct **aRadioGroup);
|
|
|
|
|
|
|
|
// nsIDOMNode
|
|
|
|
NS_DECL_NSIDOMNODE
|
|
|
|
|
|
|
|
// nsIDOMDocument
|
|
|
|
NS_DECL_NSIDOMDOCUMENT
|
|
|
|
|
|
|
|
// nsIDOM3Document
|
|
|
|
NS_DECL_NSIDOM3DOCUMENT
|
|
|
|
|
|
|
|
// nsIDOMXMLDocument
|
|
|
|
NS_DECL_NSIDOMXMLDOCUMENT
|
|
|
|
|
|
|
|
// nsIDOMNSDocument
|
|
|
|
NS_DECL_NSIDOMNSDOCUMENT
|
|
|
|
|
|
|
|
// nsIDOMDocumentEvent
|
|
|
|
NS_DECL_NSIDOMDOCUMENTEVENT
|
|
|
|
|
|
|
|
// nsIDOM3DocumentEvent
|
|
|
|
NS_DECL_NSIDOM3DOCUMENTEVENT
|
|
|
|
|
|
|
|
// nsIDOMDocumentStyle
|
|
|
|
NS_DECL_NSIDOMDOCUMENTSTYLE
|
|
|
|
|
|
|
|
// nsIDOMNSDocumentStyle
|
|
|
|
NS_DECL_NSIDOMNSDOCUMENTSTYLE
|
|
|
|
|
|
|
|
// nsIDOMDocumentView
|
|
|
|
NS_DECL_NSIDOMDOCUMENTVIEW
|
|
|
|
|
|
|
|
// nsIDOMDocumentRange
|
|
|
|
NS_DECL_NSIDOMDOCUMENTRANGE
|
|
|
|
|
|
|
|
// nsIDOMDocumentTraversal
|
|
|
|
NS_DECL_NSIDOMDOCUMENTTRAVERSAL
|
|
|
|
|
|
|
|
// nsIDOMDocumentXBL
|
|
|
|
NS_DECL_NSIDOMDOCUMENTXBL
|
|
|
|
|
|
|
|
// nsIDOMEventTarget
|
|
|
|
NS_DECL_NSIDOMEVENTTARGET
|
|
|
|
|
|
|
|
// nsIDOM3EventTarget
|
|
|
|
NS_DECL_NSIDOM3EVENTTARGET
|
|
|
|
|
|
|
|
// nsIDOMNSEventTarget
|
|
|
|
NS_DECL_NSIDOMNSEVENTTARGET
|
|
|
|
|
|
|
|
// nsIScriptObjectPrincipal
|
|
|
|
virtual nsIPrincipal* GetPrincipal();
|
|
|
|
|
2008-08-26 16:09:02 -07:00
|
|
|
// nsIApplicationCacheContainer
|
|
|
|
NS_DECL_NSIAPPLICATIONCACHECONTAINER
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsresult Init();
|
|
|
|
|
|
|
|
virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement);
|
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
virtual nsresult CreateElem(const nsAString& aName, nsIAtom *aPrefix,
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 aNamespaceID,
|
|
|
|
PRBool aDocumentDefaultType,
|
|
|
|
nsIContent **aResult);
|
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
nsresult CreateElement(const nsAString& aTagName,
|
|
|
|
nsIContent** aReturn);
|
2010-11-30 10:18:14 -08:00
|
|
|
nsresult CreateElementNS(const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aQualifiedName,
|
|
|
|
nsIContent** aReturn);
|
2010-07-23 02:49:57 -07:00
|
|
|
|
|
|
|
nsresult CreateTextNode(const nsAString& aData, nsIContent** aReturn);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) Sanitize();
|
|
|
|
|
|
|
|
virtual NS_HIDDEN_(void) EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
|
|
|
|
void *aData);
|
|
|
|
|
|
|
|
virtual NS_HIDDEN_(PRBool) CanSavePresentation(nsIRequest *aNewRequest);
|
|
|
|
virtual NS_HIDDEN_(void) Destroy();
|
2008-04-18 03:02:03 -07:00
|
|
|
virtual NS_HIDDEN_(void) RemovedFromDocShell();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(already_AddRefed<nsILayoutHistoryState>) GetLayoutHistoryState() const;
|
|
|
|
|
|
|
|
virtual NS_HIDDEN_(void) BlockOnload();
|
|
|
|
virtual NS_HIDDEN_(void) UnblockOnload(PRBool aFireSync);
|
|
|
|
|
2010-02-24 08:37:03 -08:00
|
|
|
virtual NS_HIDDEN_(void) AddStyleRelevantLink(mozilla::dom::Link* aLink);
|
|
|
|
virtual NS_HIDDEN_(void) ForgetLink(mozilla::dom::Link* aLink);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_HIDDEN_(void) ClearBoxObjectFor(nsIContent* aContent);
|
2009-03-29 17:44:48 -07:00
|
|
|
NS_IMETHOD GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual NS_HIDDEN_(nsresult) GetXBLChildNodesFor(nsIContent* aContent,
|
|
|
|
nsIDOMNodeList** aResult);
|
|
|
|
virtual NS_HIDDEN_(nsresult) GetContentListFor(nsIContent* aContent,
|
|
|
|
nsIDOMNodeList** aResult);
|
2008-11-04 19:58:22 -08:00
|
|
|
|
2010-04-03 04:34:24 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) ElementFromPointHelper(float aX, float aY,
|
2008-11-04 19:58:22 -08:00
|
|
|
PRBool aIgnoreRootScrollFrame,
|
|
|
|
PRBool aFlushLayout,
|
|
|
|
nsIDOMElement** aReturn);
|
|
|
|
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) NodesFromRectHelper(float aX, float aY,
|
|
|
|
float aTopSize, float aRightSize,
|
|
|
|
float aBottomSize, float aLeftSize,
|
|
|
|
PRBool aIgnoreRootScrollFrame,
|
|
|
|
PRBool aFlushLayout,
|
|
|
|
nsIDOMNodeList** aReturn);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(void) FlushSkinBindings();
|
2008-03-21 04:44:09 -07:00
|
|
|
|
|
|
|
virtual NS_HIDDEN_(nsresult) InitializeFrameLoader(nsFrameLoader* aLoader);
|
2008-02-26 06:47:51 -08:00
|
|
|
virtual NS_HIDDEN_(nsresult) FinalizeFrameLoader(nsFrameLoader* aLoader);
|
2008-04-24 03:33:22 -07:00
|
|
|
virtual NS_HIDDEN_(void) TryCancelFrameLoaderInitialization(nsIDocShell* aShell);
|
2008-04-29 00:18:55 -07:00
|
|
|
virtual NS_HIDDEN_(PRBool) FrameLoaderScheduledToBeFinalized(nsIDocShell* aShell);
|
2008-10-04 13:00:09 -07:00
|
|
|
virtual NS_HIDDEN_(nsIDocument*)
|
|
|
|
RequestExternalResource(nsIURI* aURI,
|
|
|
|
nsINode* aRequestingNode,
|
|
|
|
ExternalResourceLoad** aPendingLoad);
|
|
|
|
virtual NS_HIDDEN_(void)
|
|
|
|
EnumerateExternalResources(nsSubDocEnumFunc aCallback, void* aData);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-02 23:51:09 -08:00
|
|
|
nsTArray<nsCString> mFileDataUris;
|
|
|
|
|
2009-01-14 20:38:07 -08:00
|
|
|
#ifdef MOZ_SMIL
|
2010-03-02 23:09:51 -08:00
|
|
|
// Returns our (lazily-initialized) animation controller.
|
|
|
|
// If HasAnimationController is true, this is guaranteed to return non-null.
|
2009-01-14 20:38:07 -08:00
|
|
|
nsSMILAnimationController* GetAnimationController();
|
|
|
|
#endif // MOZ_SMIL
|
|
|
|
|
2010-11-06 12:13:01 -07:00
|
|
|
void SetImagesNeedAnimating(PRBool aAnimating);
|
|
|
|
|
2009-03-03 12:11:14 -08:00
|
|
|
virtual void SuppressEventHandling(PRUint32 aIncrease);
|
|
|
|
|
|
|
|
virtual void UnsuppressEventHandlingAndFireEvents(PRBool aFireEvents);
|
|
|
|
|
|
|
|
void DecreaseEventSuppression() { --mEventsSuppressed; }
|
|
|
|
|
2009-05-12 13:20:42 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDocument,
|
|
|
|
nsIDocument)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-08-17 19:10:28 -07:00
|
|
|
void DoNotifyPossibleTitleChange();
|
|
|
|
|
2008-10-04 13:00:09 -07:00
|
|
|
nsExternalResourceMap& ExternalResourceMap()
|
|
|
|
{
|
|
|
|
return mExternalResourceMap;
|
|
|
|
}
|
|
|
|
|
2008-09-18 04:15:47 -07:00
|
|
|
void SetLoadedAsData(PRBool aLoadedAsData) { mLoadedAsData = aLoadedAsData; }
|
|
|
|
|
|
|
|
nsresult CloneDocHelper(nsDocument* clone) const;
|
|
|
|
|
2009-01-31 04:53:01 -08:00
|
|
|
void MaybeInitializeFinalizeFrameLoaders();
|
|
|
|
|
|
|
|
void MaybeEndOutermostXBLUpdate();
|
2009-07-07 22:23:20 -07:00
|
|
|
|
|
|
|
virtual void MaybePreLoadImage(nsIURI* uri);
|
2009-10-29 18:48:38 -07:00
|
|
|
|
2010-03-02 13:00:39 -08:00
|
|
|
virtual void PreloadStyle(nsIURI* uri, const nsAString& charset);
|
|
|
|
|
|
|
|
virtual nsresult LoadChromeSheetSync(nsIURI* uri, PRBool isAgentSheet,
|
2010-05-11 13:41:47 -07:00
|
|
|
nsCSSStyleSheet** sheet);
|
2010-03-02 13:00:39 -08:00
|
|
|
|
2009-10-29 18:48:38 -07:00
|
|
|
virtual nsISupports* GetCurrentContentSink();
|
|
|
|
|
2010-10-20 04:26:32 -07:00
|
|
|
virtual nsEventStates GetDocumentState();
|
2010-03-17 10:10:57 -07:00
|
|
|
|
2010-09-15 15:52:49 -07:00
|
|
|
virtual void RegisterFileDataUri(const nsACString& aUri);
|
|
|
|
virtual void UnregisterFileDataUri(const nsACString& aUri);
|
2010-03-02 23:51:09 -08:00
|
|
|
|
2010-04-27 02:48:52 -07:00
|
|
|
// Only BlockOnload should call this!
|
|
|
|
void AsyncBlockOnload();
|
|
|
|
|
2010-05-11 17:30:40 -07:00
|
|
|
virtual void SetScrollToRef(nsIURI *aDocumentURI);
|
|
|
|
virtual void ScrollToRef();
|
|
|
|
virtual void ResetScrolledToRefAlready();
|
|
|
|
virtual void SetChangeScrollPosWhenScrollingToRef(PRBool aValue);
|
|
|
|
|
2010-04-19 08:41:38 -07:00
|
|
|
already_AddRefed<nsContentList>
|
2010-11-23 11:10:56 -08:00
|
|
|
GetElementsByTagName(const nsAString& aTagName) {
|
|
|
|
return NS_GetContentList(this, kNameSpaceID_Unknown, aTagName);
|
|
|
|
}
|
2010-04-19 08:41:38 -07:00
|
|
|
already_AddRefed<nsContentList>
|
|
|
|
GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aLocalName);
|
|
|
|
|
2010-08-13 06:35:36 -07:00
|
|
|
virtual Element *GetElementById(const nsAString& aElementId);
|
|
|
|
|
|
|
|
virtual Element *LookupImageElement(const nsAString& aElementId);
|
2010-04-19 08:41:38 -07:00
|
|
|
|
2010-08-03 17:40:29 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) AddImage(imgIRequest* aImage);
|
|
|
|
virtual NS_HIDDEN_(nsresult) RemoveImage(imgIRequest* aImage);
|
|
|
|
virtual NS_HIDDEN_(nsresult) SetImageLockingState(PRBool aLocked);
|
|
|
|
|
2011-03-25 08:03:33 -07:00
|
|
|
virtual nsresult GetMozCurrentStateObject(nsIVariant** aResult);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2009-09-10 06:23:40 -07:00
|
|
|
friend class nsNodeUtils;
|
2008-06-22 16:12:40 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Check that aId is not empty and log a message to the console
|
|
|
|
* service if it is.
|
|
|
|
* @returns PR_TRUE if aId looks correct, PR_FALSE otherwise.
|
|
|
|
*/
|
2010-12-20 08:21:58 -08:00
|
|
|
inline PRBool CheckGetElementByIdArg(const nsAString& aId)
|
2010-06-21 19:59:37 -07:00
|
|
|
{
|
|
|
|
if (aId.IsEmpty()) {
|
|
|
|
ReportEmptyGetElementByIdArg();
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2010-12-20 08:21:58 -08:00
|
|
|
void ReportEmptyGetElementByIdArg();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-23 15:08:41 -08:00
|
|
|
void DispatchContentLoadedEvents();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void RetrieveRelevantHeaders(nsIChannel *aChannel);
|
|
|
|
|
|
|
|
static PRBool TryChannelCharset(nsIChannel *aChannel,
|
|
|
|
PRInt32& aCharsetSource,
|
|
|
|
nsACString& aCharset);
|
2009-09-25 09:50:26 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Call this before the document does something that will unbind all content.
|
2010-06-03 18:09:20 -07:00
|
|
|
// That will stop us from doing a lot of work as each element is removed.
|
|
|
|
void DestroyElementMaps();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-25 09:50:26 -07:00
|
|
|
// Refreshes the hrefs of all the links in the document.
|
|
|
|
void RefreshLinkHrefs();
|
|
|
|
|
|
|
|
nsIContent* GetFirstBaseNodeWithHref();
|
|
|
|
nsresult SetFirstBaseNodeWithHref(nsIContent *node);
|
|
|
|
|
2008-08-17 19:10:28 -07:00
|
|
|
// Get the first <title> element with the given IsNodeOfType type, or
|
|
|
|
// return null if there isn't one
|
|
|
|
nsIContent* GetTitleContent(PRUint32 aNodeType);
|
|
|
|
// Find the first "title" element in the given IsNodeOfType type and
|
|
|
|
// append the concatenation of its text node children to aTitle. Do
|
|
|
|
// nothing if there is no such element.
|
|
|
|
void GetTitleFromElement(PRUint32 aNodeType, nsAString& aTitle);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult doCreateShell(nsPresContext* aContext,
|
|
|
|
nsIViewManager* aViewManager, nsStyleSet* aStyleSet,
|
|
|
|
nsCompatibility aCompatMode,
|
|
|
|
nsIPresShell** aInstancePtrResult);
|
|
|
|
|
|
|
|
nsresult ResetStylesheetsToURI(nsIURI* aURI);
|
|
|
|
void FillStyleSet(nsStyleSet* aStyleSet);
|
|
|
|
|
|
|
|
// Return whether all the presshells for this document are safe to flush
|
|
|
|
PRBool IsSafeToFlush() const;
|
|
|
|
|
|
|
|
virtual PRInt32 GetDefaultNamespaceID() const
|
|
|
|
{
|
|
|
|
return kNameSpaceID_None;
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-24 06:33:02 -07:00
|
|
|
void DispatchPageTransition(nsPIDOMEventTarget* aDispatchTarget,
|
|
|
|
const nsAString& aType,
|
|
|
|
PRBool aPersisted);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-25 20:52:52 -07:00
|
|
|
virtual nsPIDOMWindow *GetWindowInternal() const;
|
2010-04-16 02:05:25 -07:00
|
|
|
virtual nsPIDOMWindow *GetInnerWindowInternal();
|
2010-05-26 07:36:47 -07:00
|
|
|
virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const;
|
2010-08-19 16:12:46 -07:00
|
|
|
virtual PRBool InternalAllowXULXBL();
|
2010-04-16 02:05:25 -07:00
|
|
|
|
2010-07-21 08:33:31 -07:00
|
|
|
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
|
|
|
|
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \
|
|
|
|
func_, params_);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void VerifyRootContentState();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsDocument(const char* aContentType);
|
|
|
|
virtual ~nsDocument();
|
|
|
|
|
2010-01-18 01:07:08 -08:00
|
|
|
void EnsureOnloadBlocker();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCString mReferrer;
|
|
|
|
nsString mLastModified;
|
|
|
|
|
2009-03-20 01:15:35 -07:00
|
|
|
nsTArray<nsIObserver*> mCharSetObservers;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
PLDHashTable *mSubDocuments;
|
|
|
|
|
|
|
|
// Array of owning references to all children
|
|
|
|
nsAttrAndChildArray mChildren;
|
|
|
|
|
|
|
|
// Pointer to our parser if we're currently in the process of being
|
|
|
|
// parsed into.
|
|
|
|
nsCOMPtr<nsIParser> mParser;
|
|
|
|
|
2007-09-20 19:41:08 -07:00
|
|
|
// Weak reference to our sink for in case we no longer have a parser. This
|
|
|
|
// will allow us to flush out any pending stuff from the sink even if
|
|
|
|
// EndLoad() has already happened.
|
|
|
|
nsWeakPtr mWeakSink;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMArray<nsIStyleSheet> mStyleSheets;
|
|
|
|
nsCOMArray<nsIStyleSheet> mCatalogSheets;
|
|
|
|
|
|
|
|
// Array of observers
|
2007-12-19 23:30:04 -08:00
|
|
|
nsTObserverArray<nsIDocumentObserver*> mObservers;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-10-01 03:02:32 -07:00
|
|
|
// If document is created for example using
|
|
|
|
// document.implementation.createDocument(...), mScriptObject points to
|
|
|
|
// the script global object of the original document.
|
|
|
|
nsWeakPtr mScriptObject;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Weak reference to the scope object (aka the script global object)
|
|
|
|
// that, unlike mScriptGlobalObject, is never unset once set. This
|
|
|
|
// is a weak reference to avoid leaks due to circular references.
|
|
|
|
nsWeakPtr mScopeObject;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEventListenerManager> mListenerManager;
|
|
|
|
nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
|
|
|
|
nsRefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
|
|
|
|
nsRefPtr<nsScriptLoader> mScriptLoader;
|
|
|
|
nsDocHeaderData* mHeaderData;
|
2008-06-22 16:12:40 -07:00
|
|
|
/* mIdentifierMap works as follows for IDs:
|
|
|
|
* 1) Attribute changes affect the table immediately (removing and adding
|
|
|
|
* entries as needed).
|
|
|
|
* 2) Removals from the DOM affect the table immediately
|
2009-03-23 07:04:40 -07:00
|
|
|
* 3) Additions to the DOM always update existing entries for names, and add
|
|
|
|
* new ones for IDs.
|
2008-06-22 16:12:40 -07:00
|
|
|
*/
|
|
|
|
nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-27 11:17:32 -07:00
|
|
|
nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// True if the document has been detached from its content viewer.
|
|
|
|
PRPackedBool mIsGoingAway:1;
|
|
|
|
// True if the document is being destroyed.
|
|
|
|
PRPackedBool mInDestructor:1;
|
2009-08-25 10:15:55 -07:00
|
|
|
|
2008-08-17 19:10:28 -07:00
|
|
|
// True if this document has ever had an HTML or SVG <title> element
|
|
|
|
// bound to it
|
|
|
|
PRPackedBool mMayHaveTitleElement:1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-14 12:45:07 -08:00
|
|
|
PRPackedBool mHasWarnedAboutBoxObjects:1;
|
|
|
|
|
2008-04-18 01:58:06 -07:00
|
|
|
PRPackedBool mDelayFrameLoaderInitialization:1;
|
|
|
|
|
2009-01-23 15:08:41 -08:00
|
|
|
PRPackedBool mSynchronousDOMContentLoaded:1;
|
|
|
|
|
2008-08-06 13:59:37 -07:00
|
|
|
// If true, we have an input encoding. If this is false, then the
|
|
|
|
// document was created entirely in memory
|
|
|
|
PRPackedBool mHaveInputEncoding:1;
|
|
|
|
|
2009-01-31 04:53:01 -08:00
|
|
|
PRPackedBool mInXBLUpdate:1;
|
|
|
|
|
2010-01-06 09:20:50 -08:00
|
|
|
// This flag is only set in nsXMLDocument, for e.g. documents used in XBL. We
|
|
|
|
// don't want animations to play in such documents, so we need to store the
|
|
|
|
// flag here so that we can check it in nsDocument::GetAnimationController.
|
|
|
|
PRPackedBool mLoadedAsInteractiveData:1;
|
|
|
|
|
2010-08-03 17:40:29 -07:00
|
|
|
// Whether we're currently holding a lock on all of our images.
|
|
|
|
PRPackedBool mLockingImages:1;
|
|
|
|
|
2010-09-07 17:33:02 -07:00
|
|
|
// Whether we currently require our images to animate
|
|
|
|
PRPackedBool mAnimatingImages:1;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
PRUint8 mXMLDeclarationBits;
|
|
|
|
|
|
|
|
PRUint8 mDefaultElementType;
|
|
|
|
|
2008-02-14 12:45:07 -08:00
|
|
|
nsInterfaceHashtable<nsVoidPtrHashKey, nsPIBoxObject> *mBoxObjectTable;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// The channel that got passed to StartDocumentLoad(), if any
|
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
|
|
|
nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet;
|
2009-12-31 07:56:33 -08:00
|
|
|
nsRefPtr<nsHTMLCSSStyleSheet> mStyleAttrStyleSheet;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRefPtr<nsXMLEventsManager> mXMLEventsManager;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptEventManager> mScriptEventManager;
|
|
|
|
|
2007-10-26 03:30:44 -07:00
|
|
|
// Our update nesting level
|
|
|
|
PRUint32 mUpdateNestLevel;
|
|
|
|
|
2008-08-26 16:09:02 -07:00
|
|
|
// The application cache that this document is associated with, if
|
|
|
|
// any. This can change during the lifetime of the document.
|
|
|
|
nsCOMPtr<nsIApplicationCache> mApplicationCache;
|
|
|
|
|
2009-09-25 09:50:26 -07:00
|
|
|
nsCOMPtr<nsIContent> mFirstBaseNodeWithHref;
|
|
|
|
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates mDocumentState;
|
|
|
|
nsEventStates mGotDocumentState;
|
2010-03-17 10:10:57 -07:00
|
|
|
|
2008-02-21 12:39:20 -08:00
|
|
|
private:
|
2007-03-22 10:30:00 -07:00
|
|
|
friend class nsUnblockOnloadEvent;
|
|
|
|
|
|
|
|
void PostUnblockOnloadEvent();
|
|
|
|
void DoUnblockOnload();
|
|
|
|
|
2010-07-21 08:51:09 -07:00
|
|
|
nsresult CheckFrameOptions();
|
2010-01-22 13:38:21 -08:00
|
|
|
nsresult InitCSP();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* See if aDocument is a child of this. If so, return the frame element in
|
|
|
|
* this document that holds currentDoc (or an ancestor).
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIDOMElement>
|
|
|
|
CheckAncestryAndGetFrame(nsIDocument* aDocument) const;
|
|
|
|
|
|
|
|
// Just like EnableStyleSheetsForSet, but doesn't check whether
|
|
|
|
// aSheetSet is null and allows the caller to control whether to set
|
|
|
|
// aSheetSet as the preferred set in the CSSLoader.
|
|
|
|
void EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
|
|
|
|
PRBool aUpdateCSSLoader);
|
|
|
|
|
2011-03-25 18:05:56 -07:00
|
|
|
// Revoke any pending notifications due to mozRequestAnimationFrame calls
|
|
|
|
void RevokeAnimationFrameNotifications();
|
|
|
|
// Reschedule any notifications we need to handle mozRequestAnimationFrame
|
|
|
|
void RescheduleAnimationFrameNotifications();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// These are not implemented and not supported.
|
|
|
|
nsDocument(const nsDocument& aOther);
|
|
|
|
nsDocument& operator=(const nsDocument& aOther);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mXPathEvaluatorTearoff;
|
|
|
|
|
|
|
|
// The layout history state that should be used by nodes in this
|
|
|
|
// document. We only actually store a pointer to it when:
|
|
|
|
// 1) We have no script global object.
|
|
|
|
// 2) We haven't had Destroy() called on us yet.
|
|
|
|
nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
|
|
|
|
|
2010-04-27 02:48:52 -07:00
|
|
|
// Currently active onload blockers
|
2007-03-22 10:30:00 -07:00
|
|
|
PRUint32 mOnloadBlockCount;
|
2010-04-27 02:48:52 -07:00
|
|
|
// Onload blockers which haven't been activated yet
|
|
|
|
PRUint32 mAsyncOnloadBlockCount;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIRequest> mOnloadBlocker;
|
2009-01-09 09:12:09 -08:00
|
|
|
ReadyState mReadyState;
|
2010-02-24 08:37:02 -08:00
|
|
|
|
2010-02-24 08:37:03 -08:00
|
|
|
// A hashtable of styled links keyed by address pointer.
|
|
|
|
nsTHashtable<nsPtrHashKey<mozilla::dom::Link> > mStyledLinks;
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Indicates whether mStyledLinks was cleared or not. This is used to track
|
|
|
|
// state so we can provide useful assertions to consumers of ForgetLink and
|
|
|
|
// AddStyleRelevantLink.
|
|
|
|
bool mStyledLinksCleared;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Member to store out last-selected stylesheet set.
|
|
|
|
nsString mLastStyleSheetSet;
|
2008-02-26 06:47:51 -08:00
|
|
|
|
2008-03-21 04:44:09 -07:00
|
|
|
nsTArray<nsRefPtr<nsFrameLoader> > mInitializableFrameLoaders;
|
2008-02-26 06:47:51 -08:00
|
|
|
nsTArray<nsRefPtr<nsFrameLoader> > mFinalizableFrameLoaders;
|
2009-01-31 04:53:01 -08:00
|
|
|
nsRefPtr<nsRunnableMethod<nsDocument> > mFrameLoaderRunner;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-20 10:22:04 -07:00
|
|
|
nsRevocableEventPtr<nsRunnableMethod<nsDocument, void, false> >
|
2009-05-06 13:46:01 -07:00
|
|
|
mPendingTitleChangeEvent;
|
2008-10-04 13:00:09 -07:00
|
|
|
|
|
|
|
nsExternalResourceMap mExternalResourceMap;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2009-07-07 22:23:20 -07:00
|
|
|
// All images in process of being preloaded
|
|
|
|
nsCOMArray<imgIRequest> mPreloadingImages;
|
|
|
|
|
2009-10-18 09:39:52 -07:00
|
|
|
nsCOMPtr<nsIDOMDOMImplementation> mDOMImplementation;
|
|
|
|
|
2010-05-11 17:30:40 -07:00
|
|
|
nsCString mScrollToRef;
|
|
|
|
PRUint8 mScrolledToRefAlready : 1;
|
|
|
|
PRUint8 mChangeScrollPosWhenScrollingToRef : 1;
|
|
|
|
|
2010-08-03 17:40:29 -07:00
|
|
|
// Tracking for images in the document.
|
|
|
|
nsDataHashtable< nsPtrHashKey<imgIRequest>, PRUint32> mImageTracker;
|
|
|
|
|
2009-07-25 04:27:42 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
protected:
|
|
|
|
PRBool mWillReparent;
|
|
|
|
#endif
|
2008-08-17 19:10:28 -07:00
|
|
|
};
|
2008-08-16 04:27:40 -07:00
|
|
|
|
2008-11-03 02:31:47 -08:00
|
|
|
#define NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
|
|
|
|
NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocument, nsDocument) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNSDocument, nsDocument) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentEvent, nsDocument) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentView, nsDocument) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentTraversal, \
|
|
|
|
nsDocument) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMEventTarget, nsDocument) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument) \
|
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOM3Document, nsDocument)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* nsDocument_h___ */
|