summaryrefslogtreecommitdiffstats
path: root/dom/base/nsDocument.h
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/nsDocument.h')
-rw-r--r--dom/base/nsDocument.h146
1 files changed, 1 insertions, 145 deletions
diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
index 6520d905d..6baf40270 100644
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -19,6 +19,7 @@
#include "nsWeakReference.h"
#include "nsWeakPtr.h"
#include "nsTArray.h"
+#include "nsIdentifierMapEntry.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentXBL.h"
#include "nsStubDocumentObserver.h"
@@ -130,151 +131,6 @@ public:
} // namespace dom
} // namespace mozilla
-/**
- * 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.
- */
-class nsIdentifierMapEntry : public nsStringHashKey
-{
-public:
- typedef mozilla::dom::Element Element;
- typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
-
- explicit nsIdentifierMapEntry(const nsAString& aKey) :
- nsStringHashKey(&aKey), mNameContentList(nullptr)
- {
- }
- explicit nsIdentifierMapEntry(const nsAString* aKey) :
- nsStringHashKey(aKey), mNameContentList(nullptr)
- {
- }
- nsIdentifierMapEntry(const nsIdentifierMapEntry& aOther) :
- nsStringHashKey(&aOther.GetKey())
- {
- NS_ERROR("Should never be called");
- }
- ~nsIdentifierMapEntry();
-
- void AddNameElement(nsINode* aDocument, Element* aElement);
- void RemoveNameElement(Element* aElement);
- bool IsEmpty();
- nsBaseContentList* GetNameContentList() {
- return mNameContentList;
- }
- bool HasNameElement() const {
- return mNameContentList && mNameContentList->Length() != 0;
- }
-
- /**
- * Returns the element if we know the element associated with this
- * id. Otherwise returns null.
- */
- Element* GetIdElement();
- /**
- * Returns the list of all elements associated with this id.
- */
- const nsTArray<Element*>& GetIdElements() const {
- return mIdContentList;
- }
- /**
- * 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();
- /**
- * Append all the elements with this id to aElements
- */
- void AppendAllIdContent(nsCOMArray<nsIContent>* aElements);
- /**
- * This can fire ID change callbacks.
- * @return true if the content could be added, false if we failed due
- * to OOM.
- */
- bool AddIdElement(Element* aElement);
- /**
- * This can fire ID change callbacks.
- */
- void RemoveIdElement(Element* aElement);
- /**
- * Set the image element override for this ID. This will be returned by
- * GetIdElement(true) if non-null.
- */
- void SetImageElement(Element* aElement);
- bool HasIdElementExposedAsHTMLDocumentProperty();
-
- bool HasContentChangeCallback() { return mChangeCallbacks != nullptr; }
- void AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
- void* aData, bool aForImage);
- void RemoveContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
- void* aData, bool aForImage);
-
- /**
- * Remove all elements and notify change listeners.
- */
- void ClearAndNotify();
-
- void Traverse(nsCycleCollectionTraversalCallback* aCallback);
-
- struct ChangeCallback {
- nsIDocument::IDTargetObserver mCallback;
- void* mData;
- bool mForImage;
- };
-
- struct ChangeCallbackEntry : public PLDHashEntryHdr {
- typedef const ChangeCallback KeyType;
- typedef const ChangeCallback* KeyTypePointer;
-
- explicit ChangeCallbackEntry(const ChangeCallback* aKey) :
- mKey(*aKey) { }
- ChangeCallbackEntry(const ChangeCallbackEntry& toCopy) :
- mKey(toCopy.mKey) { }
-
- KeyType GetKey() const { return mKey; }
- bool KeyEquals(KeyTypePointer aKey) const {
- return aKey->mCallback == mKey.mCallback &&
- aKey->mData == mKey.mData &&
- aKey->mForImage == mKey.mForImage;
- }
-
- static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
- static PLDHashNumber HashKey(KeyTypePointer aKey)
- {
- return mozilla::HashGeneric(aKey->mCallback, aKey->mData);
- }
- enum { ALLOW_MEMMOVE = true };
-
- ChangeCallback mKey;
- };
-
- size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
-
-private:
- void FireChangeCallbacks(Element* aOldElement, Element* aNewElement,
- bool aImageOnly = false);
-
- // empty if there are no elements with this ID.
- // The elements are stored as weak pointers.
- nsTArray<Element*> mIdContentList;
- RefPtr<nsBaseContentList> mNameContentList;
- nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks;
- RefPtr<Element> mImageElement;
-};
-
-namespace mozilla {
-namespace dom {
-
-} // namespace dom
-} // namespace mozilla
-
class nsDocHeaderData
{
public: