2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 "nsIDOMXMLDocument.h"
|
|
|
|
#include "nsIDOMDocumentXBL.h"
|
|
|
|
#include "nsStubDocumentObserver.h"
|
|
|
|
#include "nsIDOMStyleSheetList.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsIContent.h"
|
2011-06-23 19:18:01 -07:00
|
|
|
#include "nsEventListenerManager.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"
|
2012-03-28 22:43:09 -07:00
|
|
|
#include "nsINodeInfo.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#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 "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-08-17 19:10:28 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2011-10-15 00:33:26 -07:00
|
|
|
#include "nsIContentViewer.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"
|
2011-04-26 05:30:17 -07:00
|
|
|
#include "nsIDOMTouchEvent.h"
|
2011-08-24 12:49:25 -07:00
|
|
|
#include "nsIInlineEventHandlers.h"
|
2011-08-11 06:29:50 -07:00
|
|
|
#include "nsDataHashtable.h"
|
2011-09-15 16:47:29 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-06-23 03:39:48 -07:00
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2011-06-23 19:18:01 -07:00
|
|
|
class nsEventListenerManager;
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
2011-06-23 03:39:48 -07:00
|
|
|
class nsDOMNavigationTiming;
|
2012-02-01 13:58:01 -08:00
|
|
|
class nsWindowSizes;
|
2012-03-24 04:34:42 -07:00
|
|
|
class nsHtml5TreeOpExecutor;
|
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) :
|
2012-07-30 07:20:58 -07:00
|
|
|
nsStringHashKey(&aKey), mNameContentList(nullptr)
|
2010-06-21 19:59:37 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
nsIdentifierMapEntry(const nsAString *aKey) :
|
2012-07-30 07:20:58 -07:00
|
|
|
nsStringHashKey(aKey), mNameContentList(nullptr)
|
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();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsInvalidName();
|
2009-06-15 23:32:10 -07:00
|
|
|
void AddNameElement(nsIDocument* aDocument, Element* aElement);
|
2010-05-14 10:04:51 -07:00
|
|
|
void RemoveNameElement(Element* aElement);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsEmpty();
|
2008-06-22 16:12:40 -07:00
|
|
|
nsBaseContentList* GetNameContentList() {
|
|
|
|
return mNameContentList;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
2011-10-31 19:50:50 -07:00
|
|
|
/**
|
|
|
|
* Returns the list of all elements associated with this id.
|
|
|
|
*/
|
|
|
|
const nsSmallVoidArray* GetIdElements() const {
|
|
|
|
return &mIdContentList;
|
|
|
|
}
|
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.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool 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
|
2011-10-17 07:59:28 -07:00
|
|
|
* GetIdElement(true) if non-null.
|
2010-08-13 06:35:36 -07:00
|
|
|
*/
|
|
|
|
void SetImageElement(Element* aElement);
|
2008-06-22 16:12:40 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
bool HasContentChangeCallback() { return mChangeCallbacks != nullptr; }
|
2010-08-13 06:35:36 -07:00
|
|
|
void AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
|
2011-09-28 23:19:26 -07:00
|
|
|
void* aData, bool aForImage);
|
2010-08-13 06:35:36 -07:00
|
|
|
void RemoveContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
|
2011-09-28 23:19:26 -07:00
|
|
|
void* aData, bool 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;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool 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; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool KeyEquals(KeyTypePointer aKey) const {
|
2008-06-24 18:55:01 -07:00
|
|
|
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)
|
|
|
|
{
|
2012-03-12 15:53:18 -07:00
|
|
|
return mozilla::HashGeneric(aKey->mCallback, aKey->mData);
|
2008-06-24 18:55:01 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
enum { ALLOW_MEMMOVE = true };
|
2008-06-24 18:55:01 -07:00
|
|
|
|
|
|
|
ChangeCallback mKey;
|
|
|
|
};
|
|
|
|
|
2012-06-18 09:39:29 -07:00
|
|
|
static size_t SizeOfExcludingThis(nsIdentifierMapEntry* aEntry,
|
|
|
|
nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
void* aArg);
|
|
|
|
|
2008-06-22 16:12:40 -07:00
|
|
|
private:
|
2010-08-13 06:35:36 -07:00
|
|
|
void FireChangeCallbacks(Element* aOldElement, Element* aNewElement,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aImageOnly = false);
|
2008-06-24 18:55:01 -07:00
|
|
|
|
2011-10-31 19:50:50 -07:00
|
|
|
// empty if there are no elements with 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;
|
2011-04-23 00:29:12 -07:00
|
|
|
nsRefPtr<nsBaseContentList> mNameContentList;
|
2008-06-22 16:12:40 -07:00
|
|
|
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)
|
2012-07-30 07:20:58 -07:00
|
|
|
: mField(aField), mData(aData), mNext(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~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;
|
|
|
|
};
|
|
|
|
|
2012-06-18 19:30:09 -07:00
|
|
|
class nsOnloadBlocker MOZ_FINAL : public nsIRequest
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
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();
|
2011-10-17 07:59:28 -07:00
|
|
|
mHaveShutDown = true;
|
2008-10-04 13:00:09 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HaveShutDown() const
|
2008-10-04 13:00:09 -07:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
2011-10-15 00:33:26 -07:00
|
|
|
* Set up an nsIContentViewer based on aRequest. This is guaranteed to
|
2008-10-04 13:00:09 -07:00
|
|
|
* put null in *aViewer and *aLoadGroup on all failures.
|
|
|
|
*/
|
2011-10-15 00:33:26 -07:00
|
|
|
nsresult SetupViewer(nsIRequest* aRequest, nsIContentViewer** aViewer,
|
2008-10-04 13:00:09 -07:00
|
|
|
nsILoadGroup** aLoadGroup);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<nsDocument> mDisplayDocument;
|
|
|
|
nsCOMPtr<nsIStreamListener> mTargetListener;
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
};
|
|
|
|
friend class PendingLoad;
|
|
|
|
|
2012-06-18 19:30:09 -07:00
|
|
|
class LoadgroupCallbacks MOZ_FINAL : public nsIInterfaceRequestor
|
2008-10-04 13:00:09 -07:00
|
|
|
{
|
|
|
|
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) \
|
2012-06-18 19:30:09 -07:00
|
|
|
class _i##Shim MOZ_FINAL : public nsIInterfaceRequestor, \
|
|
|
|
public _i \
|
2008-11-24 10:32:04 -08:00
|
|
|
{ \
|
|
|
|
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 \
|
2012-07-14 21:11:10 -07:00
|
|
|
NS_FORWARD_NSIINTERFACEREQUESTOR(mIfReq->) \
|
|
|
|
NS_FORWARD_##_allcaps(mRealPtr->) \
|
2008-11-24 10:32:04 -08:00
|
|
|
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.
|
|
|
|
*/
|
2011-10-15 00:33:26 -07:00
|
|
|
nsresult AddExternalResource(nsIURI* aURI, nsIContentViewer* aViewer,
|
2008-10-04 13:00:09 -07:00
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsIDocument* aDisplayDocument);
|
|
|
|
|
|
|
|
nsClassHashtable<nsURIHashKey, ExternalResource> mMap;
|
|
|
|
nsRefPtrHashtable<nsURIHashKey, PendingLoad> mPendingLoads;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHaveShutDown;
|
2008-10-04 13:00:09 -07:00
|
|
|
};
|
|
|
|
|
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 nsIDOMDocumentXBL,
|
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsIScriptObjectPrincipal,
|
2011-07-19 02:44:55 -07:00
|
|
|
public nsIRadioGroupContainer,
|
2008-08-26 16:09:02 -07:00
|
|
|
public nsIApplicationCacheContainer,
|
2011-04-26 05:30:17 -07:00
|
|
|
public nsStubMutationObserver,
|
2011-08-24 12:49:25 -07:00
|
|
|
public nsIDOMDocumentTouch,
|
2012-05-08 14:47:20 -07:00
|
|
|
public nsIInlineEventHandlers,
|
|
|
|
public nsIObserver
|
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
|
2012-02-01 13:58:01 -08:00
|
|
|
|
|
|
|
NS_DECL_SIZEOF_EXCLUDING_THIS
|
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,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aReset = true,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIContentSink* aContentSink = nullptr) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual void StopDocumentLoad();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void NotifyPossibleTitleChange(bool aBoundTitleElement);
|
2008-08-17 19:10:28 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void SetDocumentURI(nsIURI* aURI);
|
2011-08-09 05:35:00 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Set the principal responsible for this document.
|
|
|
|
*/
|
|
|
|
virtual void SetPrincipal(nsIPrincipal *aPrincipal);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Content-Type of this document.
|
|
|
|
*/
|
|
|
|
// NS_IMETHOD GetContentType(nsAString& aContentType);
|
2011-05-28 00:43:53 -07:00
|
|
|
// Already declared in nsIDOMDocument
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
2011-09-28 23:19:26 -07:00
|
|
|
void* aData, bool aForImage);
|
2010-08-13 06:35:36 -07:00
|
|
|
virtual void RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
|
2011-09-28 23:19:26 -07:00
|
|
|
void* aData, bool 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
|
|
|
|
2012-08-20 11:34:32 -07:00
|
|
|
virtual nsresult GetAllowPlugins(bool* aAllowPlugins);
|
|
|
|
|
2011-10-29 13:22:19 -07:00
|
|
|
virtual nsresult SetSubDocumentFor(Element* aContent,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDocument* aSubDoc);
|
2011-10-29 13:22:19 -07:00
|
|
|
virtual nsIDocument* GetSubDocumentFor(nsIContent* aContent) const;
|
|
|
|
virtual Element* 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,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aApplicable);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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 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.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool RemoveObserver(nsIDocumentObserver* aObserver);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2011-03-28 20:32:11 -07:00
|
|
|
virtual void ContentStateChanged(nsIContent* aContent,
|
|
|
|
nsEventStates aStateMask);
|
2010-10-20 04:26:32 -07:00
|
|
|
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 void SetXMLDeclaration(const PRUnichar *aVersion,
|
|
|
|
const PRUnichar *aEncoding,
|
|
|
|
const PRInt32 aStandalone);
|
|
|
|
virtual void GetXMLDeclaration(nsAString& aVersion,
|
|
|
|
nsAString& aEncoding,
|
|
|
|
nsAString& Standalone);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsScriptEnabled();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void OnPageShow(bool aPersisted, nsIDOMEventTarget* aDispatchStartTarget);
|
|
|
|
virtual void OnPageHide(bool 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
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsNodeOfType(PRUint32 aFlags) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
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,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNotify);
|
|
|
|
virtual nsresult AppendChildTo(nsIContent* aKid, bool aNotify);
|
2012-03-29 14:09:07 -07:00
|
|
|
virtual void RemoveChildAt(PRUint32 aIndex, bool aNotify);
|
2012-03-28 22:43:09 -07:00
|
|
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIRadioGroupContainer
|
|
|
|
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
|
|
|
|
nsIRadioVisitor* aVisitor,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aFlushContent);
|
2012-08-03 03:38:52 -07:00
|
|
|
virtual void SetCurrentRadioButton(const nsAString& aName,
|
|
|
|
nsIDOMHTMLInputElement* aRadio);
|
|
|
|
virtual nsIDOMHTMLInputElement* GetCurrentRadioButton(const nsAString& aName);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
2011-09-28 23:19:26 -07:00
|
|
|
const bool aPrevious,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMHTMLInputElement* aFocusedRadio,
|
|
|
|
nsIDOMHTMLInputElement** aRadioOut);
|
2012-08-03 03:38:52 -07:00
|
|
|
virtual void AddToRadioGroup(const nsAString& aName,
|
|
|
|
nsIFormControl* aRadio);
|
|
|
|
virtual void 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
|
2012-08-04 00:44:00 -07:00
|
|
|
nsRadioGroupStruct* GetRadioGroup(const nsAString& aName) const;
|
|
|
|
nsRadioGroupStruct* GetOrCreateRadioGroup(const nsAString& aName);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-04 00:44:00 -07:00
|
|
|
private:
|
|
|
|
nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const;
|
|
|
|
|
|
|
|
public:
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIDOMNode
|
|
|
|
NS_DECL_NSIDOMNODE
|
|
|
|
|
|
|
|
// nsIDOMDocument
|
|
|
|
NS_DECL_NSIDOMDOCUMENT
|
|
|
|
|
|
|
|
// nsIDOMXMLDocument
|
|
|
|
NS_DECL_NSIDOMXMLDOCUMENT
|
|
|
|
|
|
|
|
// nsIDOMDocumentXBL
|
|
|
|
NS_DECL_NSIDOMDOCUMENTXBL
|
|
|
|
|
|
|
|
// nsIDOMEventTarget
|
2011-06-23 19:17:59 -07:00
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
2011-06-23 19:18:01 -07:00
|
|
|
virtual nsEventListenerManager*
|
2011-09-28 23:19:26 -07:00
|
|
|
GetListenerManager(bool aCreateIfNotFound);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIScriptObjectPrincipal
|
|
|
|
virtual nsIPrincipal* GetPrincipal();
|
|
|
|
|
2008-08-26 16:09:02 -07:00
|
|
|
// nsIApplicationCacheContainer
|
|
|
|
NS_DECL_NSIAPPLICATIONCACHECONTAINER
|
|
|
|
|
2011-08-24 12:49:25 -07:00
|
|
|
// nsITouchEventReceiver
|
|
|
|
NS_DECL_NSITOUCHEVENTRECEIVER
|
|
|
|
|
2011-04-26 05:30:17 -07:00
|
|
|
// nsIDOMDocumentTouch
|
|
|
|
NS_DECL_NSIDOMDOCUMENTTOUCH
|
|
|
|
|
2011-08-24 12:49:25 -07:00
|
|
|
// nsIInlineEventHandlers
|
|
|
|
NS_DECL_NSIINLINEEVENTHANDLERS
|
|
|
|
|
2012-05-08 14:47:20 -07:00
|
|
|
// nsIObserver
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsresult Init();
|
|
|
|
|
2011-07-03 02:53:41 -07:00
|
|
|
virtual void AddXMLEventsContent(nsIContent * aXMLEventsElement);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
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,
|
|
|
|
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);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(bool) CanSavePresentation(nsIRequest *aNewRequest);
|
2007-03-22 10:30:00 -07:00
|
|
|
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();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(void) UnblockOnload(bool aFireSync);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
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);
|
2012-05-27 21:52:53 -07:00
|
|
|
virtual NS_HIDDEN_(nsIContent*)
|
|
|
|
GetAnonymousElementByAttribute(nsIContent* aElement,
|
|
|
|
nsIAtom* aAttrName,
|
|
|
|
const nsAString& aAttrValue) const;
|
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,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIgnoreRootScrollFrame,
|
|
|
|
bool aFlushLayout,
|
2008-11-04 19:58:22 -08:00
|
|
|
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,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIgnoreRootScrollFrame,
|
|
|
|
bool aFlushLayout,
|
2010-04-07 17:31:26 -07:00
|
|
|
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);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(bool) 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;
|
|
|
|
|
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();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetImagesNeedAnimating(bool aAnimating);
|
2010-11-06 12:13:01 -07:00
|
|
|
|
2009-03-03 12:11:14 -08:00
|
|
|
virtual void SuppressEventHandling(PRUint32 aIncrease);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void UnsuppressEventHandlingAndFireEvents(bool aFireEvents);
|
2009-03-03 12:11:14 -08:00
|
|
|
|
2011-08-07 19:24:28 -07:00
|
|
|
void DecreaseEventSuppression() {
|
|
|
|
--mEventsSuppressed;
|
|
|
|
MaybeRescheduleAnimationFrameNotifications();
|
|
|
|
}
|
2009-03-03 12:11:14 -08:00
|
|
|
|
2012-01-30 12:08:13 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_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;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetLoadedAsData(bool aLoadedAsData) { mLoadedAsData = aLoadedAsData; }
|
2011-11-03 13:39:08 -07:00
|
|
|
void SetLoadedAsInteractiveData(bool aLoadedAsInteractiveData)
|
|
|
|
{
|
|
|
|
mLoadedAsInteractiveData = aLoadedAsInteractiveData;
|
|
|
|
}
|
2008-09-18 04:15:47 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
2011-07-29 11:30:00 -07:00
|
|
|
virtual void MaybePreLoadImage(nsIURI* uri,
|
|
|
|
const nsAString &aCrossOriginAttr);
|
2009-10-29 18:48:38 -07:00
|
|
|
|
2010-03-02 13:00:39 -08:00
|
|
|
virtual void PreloadStyle(nsIURI* uri, const nsAString& charset);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual nsresult LoadChromeSheetSync(nsIURI* uri, bool 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();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue);
|
2010-05-11 17:30:40 -07:00
|
|
|
|
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);
|
2011-10-31 19:50:50 -07:00
|
|
|
virtual const nsSmallVoidArray* GetAllElementsForId(const nsAString& aElementId) const;
|
2010-08-13 06:35:36 -07:00
|
|
|
|
|
|
|
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);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) SetImageLockingState(bool aLocked);
|
2010-08-03 17:40:29 -07:00
|
|
|
|
2012-03-28 08:53:56 -07:00
|
|
|
// AddPlugin adds a plugin-related element to mPlugins when the element is
|
|
|
|
// added to the tree.
|
|
|
|
virtual nsresult AddPlugin(nsIObjectLoadingContent* aPlugin);
|
|
|
|
// RemovePlugin removes a plugin-related element to mPlugins when the
|
|
|
|
// element is removed from the tree.
|
|
|
|
virtual void RemovePlugin(nsIObjectLoadingContent* aPlugin);
|
|
|
|
// GetPlugins returns the plugin-related elements from
|
|
|
|
// the frame and any subframes.
|
|
|
|
virtual void GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins);
|
|
|
|
|
2011-04-24 19:30:54 -07:00
|
|
|
virtual nsresult GetStateObject(nsIVariant** aResult);
|
2011-03-25 08:03:33 -07:00
|
|
|
|
2011-06-23 03:39:48 -07:00
|
|
|
virtual nsDOMNavigationTiming* GetNavigationTiming() const;
|
|
|
|
virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming);
|
|
|
|
|
2011-05-30 03:59:59 -07:00
|
|
|
virtual Element* FindImageMap(const nsAString& aNormalizedMapName);
|
|
|
|
|
2011-11-21 16:34:21 -08:00
|
|
|
virtual void NotifyAudioAvailableListener();
|
|
|
|
|
|
|
|
bool HasAudioAvailableListeners()
|
|
|
|
{
|
|
|
|
return mHasAudioAvailableListener;
|
|
|
|
}
|
|
|
|
|
2011-09-04 13:39:05 -07:00
|
|
|
virtual Element* GetFullScreenElement();
|
2011-11-04 12:05:16 -07:00
|
|
|
virtual void AsyncRequestFullScreen(Element* aElement);
|
2011-12-06 13:59:39 -08:00
|
|
|
virtual void RestorePreviousFullScreenState();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsFullScreenDoc();
|
2012-05-21 13:43:36 -07:00
|
|
|
virtual void SetApprovedForFullscreen(bool aIsApproved);
|
2012-07-30 19:09:31 -07:00
|
|
|
virtual nsresult RemoteFrameFullscreenChanged(nsIDOMElement* aFrameElement,
|
|
|
|
const nsAString& aNewOrigin);
|
|
|
|
|
|
|
|
virtual nsresult RemoteFrameFullscreenReverted();
|
2012-05-21 13:43:36 -07:00
|
|
|
|
2011-12-06 13:59:39 -08:00
|
|
|
static void ExitFullScreen();
|
2011-09-04 13:39:05 -07:00
|
|
|
|
2011-11-04 12:05:16 -07:00
|
|
|
// This is called asynchronously by nsIDocument::AsyncRequestFullScreen()
|
2012-07-30 19:09:31 -07:00
|
|
|
// to move this document into full-screen mode if allowed. aWasCallerChrome
|
2011-11-04 12:05:16 -07:00
|
|
|
// should be true when nsIDocument::AsyncRequestFullScreen() was called
|
2012-07-30 19:09:31 -07:00
|
|
|
// by chrome code. aNotifyOnOriginChange denotes whether we should send a
|
|
|
|
// fullscreen-origin-change notification if requesting fullscreen in this
|
|
|
|
// document causes the origin which is fullscreen to change. We may want to
|
|
|
|
// *not* send this notification if we're calling RequestFullscreen() as part
|
|
|
|
// of a continuation of a request in a subdocument, whereupon the caller will
|
|
|
|
// need to send the notification with the origin of the document which
|
|
|
|
// originally requested fullscreen, not *this* document's origin.
|
|
|
|
void RequestFullScreen(Element* aElement,
|
|
|
|
bool aWasCallerChrome,
|
|
|
|
bool aNotifyOnOriginChange);
|
2011-11-04 12:05:16 -07:00
|
|
|
|
2011-12-06 13:59:39 -08:00
|
|
|
// Removes all elements from the full-screen stack, removing full-scren
|
|
|
|
// styles from the top element in the stack.
|
2012-05-21 13:43:36 -07:00
|
|
|
void CleanupFullscreenState();
|
|
|
|
|
|
|
|
// Add/remove "fullscreen-approved" observer service notification listener.
|
|
|
|
// Chrome sends us a notification when fullscreen is approved for a
|
|
|
|
// document, with the notification subject as the document that was approved.
|
|
|
|
// We maintain this listener while in fullscreen mode.
|
|
|
|
nsresult AddFullscreenApprovedObserver();
|
|
|
|
nsresult RemoveFullscreenApprovedObserver();
|
2011-12-06 13:59:39 -08:00
|
|
|
|
|
|
|
// Pushes aElement onto the full-screen stack, and removes full-screen styles
|
|
|
|
// from the former full-screen stack top, and its ancestors, and applies the
|
|
|
|
// styles to aElement. aElement becomes the new "full-screen element".
|
|
|
|
bool FullScreenStackPush(Element* aElement);
|
|
|
|
|
|
|
|
// Remove the top element from the full-screen stack. Removes the full-screen
|
|
|
|
// styles from the former top element, and applies them to the new top
|
|
|
|
// element, if there is one.
|
|
|
|
void FullScreenStackPop();
|
|
|
|
|
|
|
|
// Returns the top element from the full-screen stack.
|
|
|
|
Element* FullScreenStackTop();
|
|
|
|
|
2012-04-11 14:55:21 -07:00
|
|
|
void RequestPointerLock(Element* aElement);
|
|
|
|
bool ShouldLockPointer(Element* aElement);
|
|
|
|
bool SetPointerLock(Element* aElement, int aCursorStyle);
|
|
|
|
static void UnlockPointer();
|
|
|
|
|
2011-10-11 14:29:12 -07:00
|
|
|
// This method may fire a DOM event; if it does so it will happen
|
|
|
|
// synchronously.
|
|
|
|
void UpdateVisibilityState();
|
|
|
|
// Posts an event to call UpdateVisibilityState
|
|
|
|
virtual void PostVisibilityUpdateEvent();
|
|
|
|
|
2012-02-01 13:58:01 -08:00
|
|
|
virtual void DocSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const;
|
|
|
|
// DocSizeOfIncludingThis is inherited from nsIDocument.
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2012-04-25 06:47:30 -07:00
|
|
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
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
|
|
|
|
2011-11-04 12:05:16 -07:00
|
|
|
// Returns true if a request for DOM full-screen is currently enabled in
|
|
|
|
// this document. This returns true if there are no windowed plugins in this
|
|
|
|
// doc tree, and if the document is visible, and if the api is not
|
|
|
|
// disabled by pref. aIsCallerChrome must contain the return value of
|
|
|
|
// nsContentUtils::IsCallerChrome() from the context we're checking.
|
2011-11-21 13:23:48 -08:00
|
|
|
// If aLogFailure is true, an appropriate warning message is logged to the
|
|
|
|
// console, and a "mozfullscreenerror" event is dispatched to this document.
|
|
|
|
bool IsFullScreenEnabled(bool aIsCallerChrome, bool aLogFailure);
|
2011-11-04 12:05:16 -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.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @returns true if aId looks correct, false otherwise.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
inline bool CheckGetElementByIdArg(const nsAString& aId)
|
2010-06-21 19:59:37 -07:00
|
|
|
{
|
|
|
|
if (aId.IsEmpty()) {
|
|
|
|
ReportEmptyGetElementByIdArg();
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-21 19:59:37 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-06-21 19:59:37 -07:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2012-03-24 04:34:42 -07:00
|
|
|
bool TryChannelCharset(nsIChannel *aChannel,
|
|
|
|
PRInt32& aCharsetSource,
|
|
|
|
nsACString& aCharset,
|
|
|
|
nsHtml5TreeOpExecutor* aExecutor);
|
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);
|
|
|
|
|
2012-04-16 21:03:10 -07:00
|
|
|
inline void
|
|
|
|
SetDocumentDirectionality(mozilla::directionality::Directionality aDir)
|
|
|
|
{
|
|
|
|
mDirectionality = aDir;
|
|
|
|
}
|
|
|
|
|
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
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsSafeToFlush() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-23 19:18:00 -07:00
|
|
|
void DispatchPageTransition(nsIDOMEventTarget* aDispatchTarget,
|
2009-06-24 06:33:02 -07:00
|
|
|
const nsAString& aType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool 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;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool 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;
|
|
|
|
|
2011-10-31 22:11:09 -07:00
|
|
|
// The document which requested (and was granted) full-screen. All ancestors
|
|
|
|
// of this document will also be full-screen.
|
|
|
|
static nsWeakPtr sFullScreenDoc;
|
|
|
|
|
2011-11-04 00:30:09 -07:00
|
|
|
// The root document of the doctree containing the document which requested
|
|
|
|
// full-screen. This root document will also be in full-screen state, as will
|
|
|
|
// all the descendents down to the document which requested full-screen. This
|
|
|
|
// reference allows us to reset full-screen state on all documents when a
|
|
|
|
// document is hidden/navigation occurs.
|
|
|
|
static nsWeakPtr sFullScreenRootDoc;
|
|
|
|
|
2012-05-08 14:47:20 -07:00
|
|
|
// Weak reference to the document which owned the pending pointer lock
|
|
|
|
// element, at the time it requested pointer lock.
|
|
|
|
static nsWeakPtr sPendingPointerLockDoc;
|
|
|
|
|
|
|
|
// Weak reference to the element which requested pointer lock. This request
|
|
|
|
// is "pending", and will be processed once the element's document has had
|
|
|
|
// the "fullscreen" permission granted.
|
|
|
|
static nsWeakPtr sPendingPointerLockElement;
|
|
|
|
|
2011-12-06 13:59:39 -08:00
|
|
|
// Stack of full-screen elements. When we request full-screen we push the
|
|
|
|
// full-screen element onto this stack, and when we cancel full-screen we
|
|
|
|
// pop one off this stack, restoring the previous full-screen state
|
|
|
|
nsTArray<nsWeakPtr> mFullScreenStack;
|
|
|
|
|
2011-06-23 19:18:01 -07:00
|
|
|
nsRefPtr<nsEventListenerManager> mListenerManager;
|
2007-03-22 10:30:00 -07:00
|
|
|
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
|
|
|
|
2011-06-23 03:39:48 -07:00
|
|
|
// Recorded time of change to 'loading' state.
|
|
|
|
mozilla::TimeStamp mLoadingTimeStamp;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// True if the document has been detached from its content viewer.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsGoingAway:1;
|
2007-03-22 10:30:00 -07:00
|
|
|
// True if the document is being destroyed.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool 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
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mMayHaveTitleElement:1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHasWarnedAboutBoxObjects:1;
|
2008-02-14 12:45:07 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDelayFrameLoaderInitialization:1;
|
2008-04-18 01:58:06 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSynchronousDOMContentLoaded:1;
|
2009-01-23 15:08:41 -08:00
|
|
|
|
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
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHaveInputEncoding:1;
|
2008-08-06 13:59:37 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInXBLUpdate:1;
|
2009-01-31 04:53:01 -08:00
|
|
|
|
2010-08-03 17:40:29 -07:00
|
|
|
// Whether we're currently holding a lock on all of our images.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mLockingImages:1;
|
2010-08-03 17:40:29 -07:00
|
|
|
|
2010-09-07 17:33:02 -07:00
|
|
|
// Whether we currently require our images to animate
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAnimatingImages:1;
|
2010-09-07 17:33:02 -07:00
|
|
|
|
2011-11-21 16:34:21 -08:00
|
|
|
// Whether some node in this document has a listener for the
|
|
|
|
// "mozaudioavailable" event.
|
|
|
|
bool mHasAudioAvailableListener:1;
|
|
|
|
|
2011-12-14 20:42:15 -08:00
|
|
|
// Whether we're currently under a FlushPendingNotifications call to
|
|
|
|
// our presshell. This is used to handle flush reentry correctly.
|
|
|
|
bool mInFlush:1;
|
|
|
|
|
2012-03-27 22:17:53 -07:00
|
|
|
// Parser aborted. True if the parser of this document was forcibly
|
|
|
|
// terminated instead of letting it finish at its own pace.
|
|
|
|
bool mParserAborted:1;
|
|
|
|
|
2012-05-21 13:43:36 -07:00
|
|
|
// Whether this document has been approved for fullscreen, either by explicit
|
|
|
|
// approval via the fullscreen-approval UI, or because it received
|
|
|
|
// approval because its document's host already had the "fullscreen"
|
|
|
|
// permission granted when the document requested fullscreen.
|
|
|
|
//
|
|
|
|
// Note if a document's principal doesn't have a host, the permission manager
|
|
|
|
// can't store permissions for it, so we can only manage approval using this
|
|
|
|
// flag.
|
|
|
|
//
|
|
|
|
// Note we must track this separately from the "fullscreen" permission,
|
|
|
|
// so that pending pointer lock requests can determine whether documents
|
|
|
|
// whose principal doesn't have a host (i.e. those which can't store
|
|
|
|
// permissions in the permission manager) have been approved for fullscreen.
|
|
|
|
bool mIsApprovedForFullscreen:1;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
PRUint8 mXMLDeclarationBits;
|
|
|
|
|
2012-03-21 11:07:31 -07:00
|
|
|
nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject> *mBoxObjectTable;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// The channel that got passed to StartDocumentLoad(), if any
|
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
2009-12-31 07:56:33 -08:00
|
|
|
nsRefPtr<nsHTMLCSSStyleSheet> mStyleAttrStyleSheet;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRefPtr<nsXMLEventsManager> mXMLEventsManager;
|
|
|
|
|
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
|
|
|
|
2011-06-23 03:39:48 -07:00
|
|
|
nsRefPtr<nsDOMNavigationTiming> mTiming;
|
2008-02-21 12:39:20 -08:00
|
|
|
private:
|
2007-03-22 10:30:00 -07:00
|
|
|
friend class nsUnblockOnloadEvent;
|
2011-10-11 14:29:12 -07:00
|
|
|
// This needs to stay in sync with the list in GetMozVisibilityState.
|
|
|
|
enum VisibilityState {
|
|
|
|
eHidden = 0,
|
|
|
|
eVisible,
|
|
|
|
eVisibilityStateCount
|
|
|
|
};
|
|
|
|
// Recomputes the visibility state but doesn't set the new value.
|
|
|
|
VisibilityState GetVisibilityState() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void PostUnblockOnloadEvent();
|
|
|
|
void DoUnblockOnload();
|
|
|
|
|
2010-07-21 08:51:09 -07:00
|
|
|
nsresult CheckFrameOptions();
|
2010-01-22 13:38:21 -08:00
|
|
|
nsresult InitCSP();
|
|
|
|
|
2012-05-08 14:47:20 -07:00
|
|
|
// Sets aElement to be the pending pointer lock element. Once this document's
|
|
|
|
// node principal's URI is granted the "fullscreen" permission, the pointer
|
|
|
|
// lock request will be processed. At any one time there can be only one
|
|
|
|
// pending pointer lock request; calling this clears the previous pending
|
|
|
|
// request.
|
|
|
|
static nsresult SetPendingPointerLockRequest(Element* aElement);
|
|
|
|
|
|
|
|
// Clears any pending pointer lock request.
|
|
|
|
static void ClearPendingPointerLockRequest(bool aDispatchErrorEvents);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2012-06-20 18:03:54 -07:00
|
|
|
* Find the (non-anonymous) content in this document for aFrame. It will
|
|
|
|
* be aFrame's content node if that content is in this document and not
|
|
|
|
* anonymous. Otherwise, when aFrame is in a subdocument, we use the frame
|
|
|
|
* element containing the subdocument containing aFrame, and/or find the
|
|
|
|
* nearest non-anonymous ancestor in this document.
|
|
|
|
* Returns null if there is no such element.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-06-10 16:44:50 -07:00
|
|
|
nsIContent* GetContentInThisDocument(nsIFrame* aFrame) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// 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,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUpdateCSSLoader);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-25 18:05:56 -07:00
|
|
|
// Revoke any pending notifications due to mozRequestAnimationFrame calls
|
|
|
|
void RevokeAnimationFrameNotifications();
|
2011-08-07 19:24:28 -07:00
|
|
|
// Reschedule any notifications we need to handle
|
|
|
|
// mozRequestAnimationFrame, if it's OK to do so.
|
|
|
|
void MaybeRescheduleAnimationFrameNotifications();
|
2011-03-25 18:05:56 -07:00
|
|
|
|
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;
|
|
|
|
|
2011-05-30 03:59:59 -07:00
|
|
|
nsRefPtr<nsContentList> mImageMaps;
|
|
|
|
|
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;
|
|
|
|
|
2012-03-28 08:53:56 -07:00
|
|
|
// Tracking for plugins in the document.
|
|
|
|
nsTHashtable< nsPtrHashKey<nsIObjectLoadingContent> > mPlugins;
|
|
|
|
|
2011-10-11 14:29:12 -07:00
|
|
|
VisibilityState mVisibilityState;
|
|
|
|
|
2009-07-25 04:27:42 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
protected:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mWillReparent;
|
2009-07-25 04:27:42 -07:00
|
|
|
#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, nsIDOMEventTarget, nsDocument) \
|
2011-03-26 09:06:27 -07:00
|
|
|
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument)
|
2008-11-03 02:31:47 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* nsDocument_h___ */
|