diff options
author | Moonchild <moonchild@palemoon.org> | 2020-05-27 02:05:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-27 02:05:35 +0200 |
commit | 5fcc364e3ee68c3bc8fc59acf7d54e6252375f75 (patch) | |
tree | 453f417beaf887198c706ce13b3d1b0c1434dfc0 | |
parent | 725e2b731f98b07837ea9315b923f43009dbe792 (diff) | |
parent | 5d89ac37959d6f074e2a7e5a88991039d50ee9c3 (diff) | |
download | uxp-5fcc364e3ee68c3bc8fc59acf7d54e6252375f75.tar.gz |
Merge pull request #1568 from MoonchildProductions/1564
Split off nsIdentifierMapEntry in its own header
-rw-r--r-- | dom/base/ShadowRoot.cpp | 2 | ||||
-rw-r--r-- | dom/base/ShadowRoot.h | 3 | ||||
-rwxr-xr-x | dom/base/moz.build | 1 | ||||
-rw-r--r-- | dom/base/nsDocument.h | 146 | ||||
-rw-r--r-- | dom/base/nsIdentifierMapEntry.h | 170 | ||||
-rw-r--r-- | dom/bindings/SimpleGlobalObject.cpp | 1 | ||||
-rw-r--r-- | dom/ipc/ContentChild.cpp | 1 | ||||
-rw-r--r-- | dom/worklet/WorkletGlobalScope.cpp | 1 | ||||
-rw-r--r-- | editor/libeditor/CSSEditUtils.cpp | 3 | ||||
-rw-r--r-- | editor/libeditor/HTMLAnonymousNodeEditor.cpp | 3 | ||||
-rw-r--r-- | editor/libeditor/HTMLEditUtils.h | 4 | ||||
-rw-r--r-- | layout/style/Loader.cpp | 1 |
12 files changed, 190 insertions, 146 deletions
diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index c4e56f3fbe..2383c951a6 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -15,7 +15,9 @@ #include "nsIStyleSheetLinkingElement.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLSlotElement.h" +#include "mozilla/dom/StyleSheetList.h" #include "nsXBLPrototypeBinding.h" +#include "mozilla/BasicEvents.h" #include "mozilla/EventDispatcher.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h index a24c8138e0..21c6e1733d 100644 --- a/dom/base/ShadowRoot.h +++ b/dom/base/ShadowRoot.h @@ -12,8 +12,9 @@ #include "nsCOMPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsIContentInlines.h" +#include "nsIdentifierMapEntry.h" #include "nsTHashtable.h" -#include "nsDocument.h" +#include "nsXBLBinding.h" class nsIAtom; class nsIContent; diff --git a/dom/base/moz.build b/dom/base/moz.build index 5acb49d4ea..ab0f0e0abc 100755 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -86,6 +86,7 @@ EXPORTS += [ 'nsIContentInlines.h', 'nsIContentIterator.h', 'nsIContentSerializer.h', + 'nsIdentifierMapEntry.h', 'nsIDocument.h', 'nsIDocumentInlines.h', 'nsIDocumentObserver.h', diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 6520d905d1..6baf40270a 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: diff --git a/dom/base/nsIdentifierMapEntry.h b/dom/base/nsIdentifierMapEntry.h new file mode 100644 index 0000000000..fce506cef3 --- /dev/null +++ b/dom/base/nsIdentifierMapEntry.h @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +/* + * Base class for all our document implementations. + */ + +#ifndef nsIdentifierMapEntry_h +#define nsIdentifierMapEntry_h + +#include "PLDHashTable.h" + +#include "mozilla/MemoryReporting.h" +#include "mozilla/Move.h" +#include "mozilla/dom/Element.h" +#include "mozilla/net/ReferrerPolicy.h" + +#include "nsCOMArray.h" +#include "nsCOMPtr.h" +#include "nsContentList.h" +#include "nsIAtom.h" +#include "nsIDocument.h" +#include "nsTArray.h" +#include "nsTHashtable.h" + +class nsIContent; + +/** + * 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; +}; + +#endif // #ifndef nsIdentifierMapEntry_h diff --git a/dom/bindings/SimpleGlobalObject.cpp b/dom/bindings/SimpleGlobalObject.cpp index 88710f7d95..34e204dc79 100644 --- a/dom/bindings/SimpleGlobalObject.cpp +++ b/dom/bindings/SimpleGlobalObject.cpp @@ -13,6 +13,7 @@ #include "nsNullPrincipal.h" #include "nsThreadUtils.h" #include "nsContentUtils.h" +#include "nsWrapperCacheInlines.h" #include "xpcprivate.h" diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 6b914372b0..69f7a3ba2b 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -67,6 +67,7 @@ #include "mozInlineSpellChecker.h" #include "nsDocShell.h" #include "nsIConsoleListener.h" +#include "nsIContentViewer.h" #include "nsICycleCollectorListener.h" #include "nsIIdlePeriod.h" #include "nsIDragService.h" diff --git a/dom/worklet/WorkletGlobalScope.cpp b/dom/worklet/WorkletGlobalScope.cpp index 8c05a0abe3..430e12b766 100644 --- a/dom/worklet/WorkletGlobalScope.cpp +++ b/dom/worklet/WorkletGlobalScope.cpp @@ -8,6 +8,7 @@ #include "mozilla/dom/WorkletGlobalScopeBinding.h" #include "mozilla/dom/Console.h" #include "nsContentUtils.h" +#include "nsWrapperCacheInlines.h" namespace mozilla { namespace dom { diff --git a/editor/libeditor/CSSEditUtils.cpp b/editor/libeditor/CSSEditUtils.cpp index d8146ca654..dd15a8730a 100644 --- a/editor/libeditor/CSSEditUtils.cpp +++ b/editor/libeditor/CSSEditUtils.cpp @@ -17,6 +17,9 @@ #include "nsCOMPtr.h" #include "nsColor.h" #include "nsComputedDOMStyle.h" +#ifdef DEBUG +#include "nsDocument.h" +#endif #include "nsDebug.h" #include "nsDependentSubstring.h" #include "nsError.h" diff --git a/editor/libeditor/HTMLAnonymousNodeEditor.cpp b/editor/libeditor/HTMLAnonymousNodeEditor.cpp index 48f20fd040..798f5c330f 100644 --- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp +++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp @@ -11,6 +11,9 @@ #include "nsCOMPtr.h" #include "nsComputedDOMStyle.h" #include "nsDebug.h" +#ifdef DEBUG +#include "nsDocument.h" +#endif #include "nsError.h" #include "nsGkAtoms.h" #include "nsIAtom.h" diff --git a/editor/libeditor/HTMLEditUtils.h b/editor/libeditor/HTMLEditUtils.h index 4bbb6fdf3c..95d3c0375b 100644 --- a/editor/libeditor/HTMLEditUtils.h +++ b/editor/libeditor/HTMLEditUtils.h @@ -7,6 +7,10 @@ #define HTMLEditUtils_h #include <stdint.h> +#ifdef DEBUG +// Used by various files for debug logging; included here to reduce duplication +#include "nsDocument.h" +#endif class nsIDOMNode; class nsINode; diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 9894ce8f45..68a7be21ed 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -50,6 +50,7 @@ #include "nsGkAtoms.h" #include "nsIThreadInternal.h" #include "nsINetworkPredictor.h" +#include "nsITimedChannel.h" #include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/URL.h" #include "mozilla/AsyncEventDispatcher.h" |