зеркало из https://github.com/mozilla/gecko-dev.git
Bug 708901 - Migrate to nsTHashSet in dom/base. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D108593
This commit is contained in:
Родитель
8118f95d0d
Коммит
4803e61816
|
@ -325,13 +325,13 @@ CustomElementRegistry::RunCustomElementCreationCallback::Run() {
|
|||
MOZ_ASSERT(!mRegistry->mElementCreationCallbacks.GetWeak(mAtom),
|
||||
"Callback should be removed.");
|
||||
|
||||
mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> elements;
|
||||
mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> elements;
|
||||
mRegistry->mElementCreationCallbacksUpgradeCandidatesMap.Remove(mAtom,
|
||||
&elements);
|
||||
MOZ_ASSERT(elements, "There should be a list");
|
||||
|
||||
for (auto iter = elements->ConstIter(); !iter.Done(); iter.Next()) {
|
||||
nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey());
|
||||
for (const auto& key : *elements) {
|
||||
nsCOMPtr<Element> elem = do_QueryReferent(key);
|
||||
if (!elem) {
|
||||
continue;
|
||||
}
|
||||
|
@ -409,10 +409,10 @@ void CustomElementRegistry::RegisterUnresolvedElement(Element* aElement,
|
|||
return;
|
||||
}
|
||||
|
||||
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* unresolved =
|
||||
nsTHashSet<RefPtr<nsIWeakReference>>* unresolved =
|
||||
mCandidatesMap.GetOrInsertNew(typeName);
|
||||
nsWeakPtr elem = do_GetWeakReference(aElement);
|
||||
unresolved->PutEntry(elem);
|
||||
unresolved->Insert(elem);
|
||||
}
|
||||
|
||||
void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement,
|
||||
|
@ -431,10 +431,10 @@ void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement,
|
|||
}
|
||||
#endif
|
||||
|
||||
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* candidates = nullptr;
|
||||
nsTHashSet<RefPtr<nsIWeakReference>>* candidates = nullptr;
|
||||
if (mCandidatesMap.Get(aTypeName, &candidates)) {
|
||||
MOZ_ASSERT(candidates);
|
||||
candidates->RemoveEntry(weak);
|
||||
candidates->Remove(weak);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -549,7 +549,7 @@ namespace {
|
|||
|
||||
class CandidateFinder {
|
||||
public:
|
||||
CandidateFinder(nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates,
|
||||
CandidateFinder(nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates,
|
||||
Document* aDoc);
|
||||
nsTArray<nsCOMPtr<Element>> OrderedCandidates();
|
||||
|
||||
|
@ -559,12 +559,11 @@ class CandidateFinder {
|
|||
};
|
||||
|
||||
CandidateFinder::CandidateFinder(
|
||||
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates,
|
||||
Document* aDoc)
|
||||
nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates, Document* aDoc)
|
||||
: mDoc(aDoc), mCandidates(aCandidates.Count()) {
|
||||
MOZ_ASSERT(mDoc);
|
||||
for (auto iter = aCandidates.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey());
|
||||
for (const auto& candidate : aCandidates) {
|
||||
nsCOMPtr<Element> elem = do_QueryReferent(candidate);
|
||||
if (!elem) {
|
||||
continue;
|
||||
}
|
||||
|
@ -613,8 +612,7 @@ void CustomElementRegistry::UpgradeCandidates(
|
|||
return;
|
||||
}
|
||||
|
||||
mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>>
|
||||
candidates;
|
||||
mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> candidates;
|
||||
if (mCandidatesMap.Remove(aKey, &candidates)) {
|
||||
MOZ_ASSERT(candidates);
|
||||
CustomElementReactionsStack* reactionsStack =
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsTHashSet.h"
|
||||
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
|
@ -474,7 +475,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
|
|||
typeName = aElement->NodeInfo()->NameAtom();
|
||||
}
|
||||
|
||||
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* elements =
|
||||
nsTHashSet<RefPtr<nsIWeakReference>>* elements =
|
||||
mElementCreationCallbacksUpgradeCandidatesMap.Get(typeName);
|
||||
|
||||
// If there isn't a table, there won't be a definition added by the
|
||||
|
@ -484,7 +485,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
|
|||
}
|
||||
|
||||
nsWeakPtr elem = do_GetWeakReference(aElement);
|
||||
elements->PutEntry(elem);
|
||||
elements->Insert(elem);
|
||||
}
|
||||
|
||||
void TraceDefinitions(JSTracer* aTrc);
|
||||
|
@ -511,7 +512,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
|
|||
CustomElementCreationCallback>
|
||||
ElementCreationCallbackMap;
|
||||
typedef nsClassHashtable<nsRefPtrHashKey<nsAtom>,
|
||||
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>>
|
||||
nsTHashSet<RefPtr<nsIWeakReference>>>
|
||||
CandidateMap;
|
||||
typedef JS::GCHashMap<JS::Heap<JSObject*>, RefPtr<nsAtom>,
|
||||
js::MovableCellHasher<JS::Heap<JSObject*>>,
|
||||
|
|
|
@ -377,7 +377,7 @@ nsresult DocGroup::QueueIframePostMessages(
|
|||
MOZ_ASSERT(mIframePostMessageQueue);
|
||||
MOZ_ASSERT(mIframePostMessageQueue->IsPaused());
|
||||
|
||||
mIframesUsedPostMessageQueue.PutEntry(aWindowId);
|
||||
mIframesUsedPostMessageQueue.Insert(aWindowId);
|
||||
|
||||
mIframePostMessageQueue->Dispatch(std::move(aRunnable), NS_DISPATCH_NORMAL);
|
||||
return NS_OK;
|
||||
|
@ -387,7 +387,7 @@ nsresult DocGroup::QueueIframePostMessages(
|
|||
|
||||
void DocGroup::TryFlushIframePostMessages(uint64_t aWindowId) {
|
||||
if (DocGroup::TryToLoadIframesInBackground()) {
|
||||
mIframesUsedPostMessageQueue.RemoveEntry(aWindowId);
|
||||
mIframesUsedPostMessageQueue.Remove(aWindowId);
|
||||
if (mIframePostMessageQueue && mIframesUsedPostMessageQueue.IsEmpty()) {
|
||||
MOZ_ASSERT(mIframePostMessageQueue->IsPaused());
|
||||
nsresult rv = mIframePostMessageQueue->SetIsPaused(true);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "nsISupportsImpl.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsTHashSet.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/dom/BrowsingContextGroup.h"
|
||||
|
@ -141,7 +141,7 @@ class DocGroup final {
|
|||
RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
|
||||
RefPtr<BrowsingContextGroup> mBrowsingContextGroup;
|
||||
RefPtr<mozilla::ThrottledEventQueue> mIframePostMessageQueue;
|
||||
nsTHashtable<nsUint64HashKey> mIframesUsedPostMessageQueue;
|
||||
nsTHashSet<uint64_t> mIframesUsedPostMessageQueue;
|
||||
nsCOMPtr<nsISerialEventTarget> mEventTarget;
|
||||
|
||||
// non-null if the JS execution for this docgroup is regulated with regards
|
||||
|
|
|
@ -4090,7 +4090,7 @@ AbstractThread* Document::AbstractMainThreadFor(
|
|||
void Document::NoteScriptTrackingStatus(const nsACString& aURL,
|
||||
bool aIsTracking) {
|
||||
if (aIsTracking) {
|
||||
mTrackingScripts.PutEntry(aURL);
|
||||
mTrackingScripts.Insert(aURL);
|
||||
} else {
|
||||
MOZ_ASSERT(!mTrackingScripts.Contains(aURL));
|
||||
}
|
||||
|
@ -8334,9 +8334,7 @@ already_AddRefed<Attr> Document::CreateAttributeNS(
|
|||
}
|
||||
|
||||
void Document::ResolveScheduledSVGPresAttrs() {
|
||||
for (auto iter = mLazySVGPresElements.ConstIter(); !iter.Done();
|
||||
iter.Next()) {
|
||||
SVGElement* svg = iter.Get()->GetKey();
|
||||
for (SVGElement* svg : mLazySVGPresElements) {
|
||||
svg->UpdateContentDeclarationBlock();
|
||||
}
|
||||
mLazySVGPresElements.Clear();
|
||||
|
@ -11618,10 +11616,7 @@ void Document::RefreshLinkHrefs() {
|
|||
// Get a list of all links we know about. We will reset them, which will
|
||||
// remove them from the document, so we need a copy of what is in the
|
||||
// hashtable.
|
||||
LinkArray linksToNotify(mStyledLinks.Count());
|
||||
for (auto iter = mStyledLinks.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
linksToNotify.AppendElement(iter.Get()->GetKey());
|
||||
}
|
||||
const LinkArray linksToNotify = ToArray(mStyledLinks);
|
||||
|
||||
// Reset all of our styled links.
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
@ -12563,21 +12558,16 @@ void Document::ScrollToRef() {
|
|||
|
||||
void Document::RegisterActivityObserver(nsISupports* aSupports) {
|
||||
if (!mActivityObservers) {
|
||||
mActivityObservers = MakeUnique<nsTHashtable<nsPtrHashKey<nsISupports>>>();
|
||||
mActivityObservers = MakeUnique<nsTHashSet<nsISupports*>>();
|
||||
}
|
||||
mActivityObservers->PutEntry(aSupports);
|
||||
mActivityObservers->Insert(aSupports);
|
||||
}
|
||||
|
||||
bool Document::UnregisterActivityObserver(nsISupports* aSupports) {
|
||||
if (!mActivityObservers) {
|
||||
return false;
|
||||
}
|
||||
nsPtrHashKey<nsISupports>* entry = mActivityObservers->GetEntry(aSupports);
|
||||
if (!entry) {
|
||||
return false;
|
||||
}
|
||||
mActivityObservers->RemoveEntry(entry);
|
||||
return true;
|
||||
return mActivityObservers->EnsureRemoved(aSupports);
|
||||
}
|
||||
|
||||
void Document::EnumerateActivityObservers(
|
||||
|
@ -12586,12 +12576,9 @@ void Document::EnumerateActivityObservers(
|
|||
return;
|
||||
}
|
||||
|
||||
nsTArray<nsCOMPtr<nsISupports>> observers(mActivityObservers->Count());
|
||||
for (auto iter = mActivityObservers->ConstIter(); !iter.Done(); iter.Next()) {
|
||||
observers.AppendElement(iter.Get()->GetKey());
|
||||
}
|
||||
|
||||
for (auto& observer : observers) {
|
||||
const auto keyArray =
|
||||
ToTArray<nsTArray<nsCOMPtr<nsISupports>>>(*mActivityObservers);
|
||||
for (auto& observer : keyArray) {
|
||||
aEnumerator(observer.get());
|
||||
}
|
||||
}
|
||||
|
@ -13032,10 +13019,7 @@ mozilla::dom::ImageTracker* Document::ImageTracker() {
|
|||
}
|
||||
|
||||
void Document::GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) {
|
||||
aPlugins.SetCapacity(aPlugins.Length() + mPlugins.Count());
|
||||
for (auto iter = mPlugins.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
aPlugins.AppendElement(iter.Get()->GetKey());
|
||||
}
|
||||
aPlugins.AppendElements(ToArray(mPlugins));
|
||||
auto recurse = [&aPlugins](Document& aSubDoc) {
|
||||
aSubDoc.GetPlugins(aPlugins);
|
||||
return CallState::Continue;
|
||||
|
@ -13052,7 +13036,7 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate(
|
|||
return;
|
||||
}
|
||||
|
||||
mSVGUseElementsNeedingShadowTreeUpdate.PutEntry(&aUseElement);
|
||||
mSVGUseElementsNeedingShadowTreeUpdate.Insert(&aUseElement);
|
||||
|
||||
if (PresShell* presShell = GetPresShell()) {
|
||||
presShell->EnsureStyleFlush();
|
||||
|
@ -13061,22 +13045,13 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate(
|
|||
|
||||
void Document::DoUpdateSVGUseElementShadowTrees() {
|
||||
MOZ_ASSERT(!mSVGUseElementsNeedingShadowTreeUpdate.IsEmpty());
|
||||
nsTArray<RefPtr<SVGUseElement>> useElementsToUpdate;
|
||||
|
||||
do {
|
||||
useElementsToUpdate.Clear();
|
||||
useElementsToUpdate.SetCapacity(
|
||||
mSVGUseElementsNeedingShadowTreeUpdate.Count());
|
||||
const auto useElementsToUpdate = ToTArray<nsTArray<RefPtr<SVGUseElement>>>(
|
||||
mSVGUseElementsNeedingShadowTreeUpdate);
|
||||
mSVGUseElementsNeedingShadowTreeUpdate.Clear();
|
||||
|
||||
{
|
||||
for (auto iter = mSVGUseElementsNeedingShadowTreeUpdate.ConstIter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
useElementsToUpdate.AppendElement(iter.Get()->GetKey());
|
||||
}
|
||||
mSVGUseElementsNeedingShadowTreeUpdate.Clear();
|
||||
}
|
||||
|
||||
for (auto& useElement : useElementsToUpdate) {
|
||||
for (const auto& useElement : useElementsToUpdate) {
|
||||
if (MOZ_UNLIKELY(!useElement->IsInComposedDoc())) {
|
||||
// The element was in another <use> shadow tree which we processed
|
||||
// already and also needed an update, and is removed from the document
|
||||
|
@ -13090,8 +13065,7 @@ void Document::DoUpdateSVGUseElementShadowTrees() {
|
|||
}
|
||||
|
||||
void Document::NotifyMediaFeatureValuesChanged() {
|
||||
for (auto iter = mResponsiveContent.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
RefPtr<HTMLImageElement> imageElement = iter.Get()->GetKey();
|
||||
for (RefPtr<HTMLImageElement> imageElement : mResponsiveContent) {
|
||||
imageElement->MediaFeatureValuesChanged();
|
||||
}
|
||||
}
|
||||
|
@ -15469,11 +15443,8 @@ void Document::UpdateIntersectionObservations(TimeStamp aNowTime) {
|
|||
}
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<DOMIntersectionObserver>> observers(
|
||||
mIntersectionObservers.Count());
|
||||
for (auto& observer : mIntersectionObservers) {
|
||||
observers.AppendElement(observer.GetKey());
|
||||
}
|
||||
const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>(
|
||||
mIntersectionObservers);
|
||||
for (const auto& observer : observers) {
|
||||
if (observer) {
|
||||
observer->Update(this, time);
|
||||
|
@ -15493,22 +15464,12 @@ void Document::ScheduleIntersectionObserverNotification() {
|
|||
}
|
||||
|
||||
void Document::NotifyIntersectionObservers() {
|
||||
nsTArray<RefPtr<DOMIntersectionObserver>> observers(
|
||||
mIntersectionObservers.Count());
|
||||
for (auto iter = mIntersectionObservers.ConstIter(); !iter.Done();
|
||||
iter.Next()) {
|
||||
DOMIntersectionObserver* observer = iter.Get()->GetKey();
|
||||
observers.AppendElement(observer);
|
||||
}
|
||||
const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>(
|
||||
mIntersectionObservers);
|
||||
for (const auto& observer : observers) {
|
||||
if (observer) {
|
||||
// MOZ_KnownLive because 'observers' is guaranteed to
|
||||
// keep it alive.
|
||||
//
|
||||
// Even with https://bugzilla.mozilla.org/show_bug.cgi?id=1620312 fixed
|
||||
// this might need to stay, because 'observers' is not const, so it's not
|
||||
// obvious how to prove via static analysis that it won't change and
|
||||
// release us.
|
||||
// MOZ_KnownLive because the 'observers' array guarantees to keep it
|
||||
// alive.
|
||||
MOZ_KnownLive(observer)->Notify();
|
||||
}
|
||||
}
|
||||
|
@ -16985,8 +16946,8 @@ void Document::DoCacheAllKnownLangPrefs() {
|
|||
data->GetFontPrefsForLang(nsGkAtoms::x_math);
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1362599#c12
|
||||
data->GetFontPrefsForLang(nsGkAtoms::Unicode);
|
||||
for (auto iter = mLanguagesUsed.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
data->GetFontPrefsForLang(iter.Get()->GetKey());
|
||||
for (const auto& key : mLanguagesUsed) {
|
||||
data->GetFontPrefsForLang(key);
|
||||
}
|
||||
mMayNeedFontPrefsUpdate = false;
|
||||
}
|
||||
|
@ -17287,10 +17248,7 @@ bool Document::ShouldIncludeInTelemetry(bool aAllowExtensionURIs) {
|
|||
|
||||
void Document::GetConnectedShadowRoots(
|
||||
nsTArray<RefPtr<ShadowRoot>>& aOut) const {
|
||||
aOut.SetCapacity(mComposedShadowRoots.Count());
|
||||
for (const auto& entry : mComposedShadowRoots) {
|
||||
aOut.AppendElement(entry.GetKey());
|
||||
}
|
||||
AppendToArray(aOut, mComposedShadowRoots);
|
||||
}
|
||||
|
||||
bool Document::HasPictureInPictureChildElement() const {
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsTHashSet.h"
|
||||
#include "nsTLiteralString.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
@ -1369,13 +1369,13 @@ class Document : public nsINode,
|
|||
* is removed.
|
||||
*/
|
||||
void ScheduleSVGForPresAttrEvaluation(SVGElement* aSVG) {
|
||||
mLazySVGPresElements.PutEntry(aSVG);
|
||||
mLazySVGPresElements.Insert(aSVG);
|
||||
}
|
||||
|
||||
// Unschedule an element scheduled by ScheduleFrameRequestCallback (e.g. for
|
||||
// when it is destroyed)
|
||||
void UnscheduleSVGForPresAttrEvaluation(SVGElement* aSVG) {
|
||||
mLazySVGPresElements.RemoveEntry(aSVG);
|
||||
mLazySVGPresElements.Remove(aSVG);
|
||||
}
|
||||
|
||||
// Resolve all SVG pres attrs scheduled in ScheduleSVGForPresAttrEvaluation
|
||||
|
@ -2431,11 +2431,11 @@ class Document : public nsINode,
|
|||
void AddStyleRelevantLink(Link* aLink) {
|
||||
NS_ASSERTION(aLink, "Passing in a null link. Expect crashes RSN!");
|
||||
#ifdef DEBUG
|
||||
nsPtrHashKey<Link>* entry = mStyledLinks.GetEntry(aLink);
|
||||
NS_ASSERTION(!entry, "Document already knows about this Link!");
|
||||
NS_ASSERTION(!mStyledLinks.Contains(aLink),
|
||||
"Document already knows about this Link!");
|
||||
mStyledLinksCleared = false;
|
||||
#endif
|
||||
mStyledLinks.PutEntry(aLink);
|
||||
mStyledLinks.Insert(aLink);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2447,11 +2447,11 @@ class Document : public nsINode,
|
|||
void ForgetLink(Link* aLink) {
|
||||
NS_ASSERTION(aLink, "Passing in a null link. Expect crashes RSN!");
|
||||
#ifdef DEBUG
|
||||
nsPtrHashKey<Link>* entry = mStyledLinks.GetEntry(aLink);
|
||||
NS_ASSERTION(entry || mStyledLinksCleared,
|
||||
bool linkContained = mStyledLinks.Contains(aLink);
|
||||
NS_ASSERTION(linkContained || mStyledLinksCleared,
|
||||
"Document knows nothing about this Link!");
|
||||
#endif
|
||||
mStyledLinks.RemoveEntry(aLink);
|
||||
mStyledLinks.Remove(aLink);
|
||||
}
|
||||
|
||||
// Refreshes the hrefs of all the links in the document.
|
||||
|
@ -3100,14 +3100,14 @@ class Document : public nsINode,
|
|||
// added to the tree.
|
||||
void AddPlugin(nsIObjectLoadingContent* aPlugin) {
|
||||
MOZ_ASSERT(aPlugin);
|
||||
mPlugins.PutEntry(aPlugin);
|
||||
mPlugins.Insert(aPlugin);
|
||||
}
|
||||
|
||||
// RemovePlugin removes a plugin-related element to mPlugins when the
|
||||
// element is removed from the tree.
|
||||
void RemovePlugin(nsIObjectLoadingContent* aPlugin) {
|
||||
MOZ_ASSERT(aPlugin);
|
||||
mPlugins.RemoveEntry(aPlugin);
|
||||
mPlugins.Remove(aPlugin);
|
||||
}
|
||||
|
||||
// GetPlugins returns the plugin-related elements from
|
||||
|
@ -3118,33 +3118,33 @@ class Document : public nsINode,
|
|||
// added to the tree.
|
||||
void AddResponsiveContent(HTMLImageElement* aContent) {
|
||||
MOZ_ASSERT(aContent);
|
||||
mResponsiveContent.PutEntry(aContent);
|
||||
mResponsiveContent.Insert(aContent);
|
||||
}
|
||||
|
||||
// Removes an element from mResponsiveContent when the element is
|
||||
// removed from the tree.
|
||||
void RemoveResponsiveContent(HTMLImageElement* aContent) {
|
||||
MOZ_ASSERT(aContent);
|
||||
mResponsiveContent.RemoveEntry(aContent);
|
||||
mResponsiveContent.Remove(aContent);
|
||||
}
|
||||
|
||||
void ScheduleSVGUseElementShadowTreeUpdate(SVGUseElement&);
|
||||
void UnscheduleSVGUseElementShadowTreeUpdate(SVGUseElement& aElement) {
|
||||
mSVGUseElementsNeedingShadowTreeUpdate.RemoveEntry(&aElement);
|
||||
mSVGUseElementsNeedingShadowTreeUpdate.Remove(&aElement);
|
||||
}
|
||||
|
||||
bool SVGUseElementNeedsShadowTreeUpdate(SVGUseElement& aElement) const {
|
||||
return mSVGUseElementsNeedingShadowTreeUpdate.GetEntry(&aElement);
|
||||
return mSVGUseElementsNeedingShadowTreeUpdate.Contains(&aElement);
|
||||
}
|
||||
|
||||
using ShadowRootSet = nsTHashtable<nsPtrHashKey<ShadowRoot>>;
|
||||
using ShadowRootSet = nsTHashSet<ShadowRoot*>;
|
||||
|
||||
void AddComposedDocShadowRoot(ShadowRoot& aShadowRoot) {
|
||||
mComposedShadowRoots.PutEntry(&aShadowRoot);
|
||||
mComposedShadowRoots.Insert(&aShadowRoot);
|
||||
}
|
||||
|
||||
void RemoveComposedDocShadowRoot(ShadowRoot& aShadowRoot) {
|
||||
mComposedShadowRoots.RemoveEntry(&aShadowRoot);
|
||||
mComposedShadowRoots.Remove(&aShadowRoot);
|
||||
}
|
||||
|
||||
// If you're considering using this, you probably want to use
|
||||
|
@ -3710,11 +3710,11 @@ class Document : public nsINode,
|
|||
void AddIntersectionObserver(DOMIntersectionObserver* aObserver) {
|
||||
MOZ_ASSERT(!mIntersectionObservers.Contains(aObserver),
|
||||
"Intersection observer already in the list");
|
||||
mIntersectionObservers.PutEntry(aObserver);
|
||||
mIntersectionObservers.Insert(aObserver);
|
||||
}
|
||||
|
||||
void RemoveIntersectionObserver(DOMIntersectionObserver* aObserver) {
|
||||
mIntersectionObservers.RemoveEntry(aObserver);
|
||||
mIntersectionObservers.Remove(aObserver);
|
||||
}
|
||||
|
||||
bool HasIntersectionObservers() const {
|
||||
|
@ -4414,7 +4414,7 @@ class Document : public nsINode,
|
|||
// See ShadowRoot::Bind and ShadowRoot::Unbind.
|
||||
ShadowRootSet mComposedShadowRoots;
|
||||
|
||||
using SVGUseElementSet = nsTHashtable<nsPtrHashKey<SVGUseElement>>;
|
||||
using SVGUseElementSet = nsTHashSet<SVGUseElement*>;
|
||||
|
||||
// The set of <svg:use> elements that need a shadow tree reclone because the
|
||||
// tree they map to has changed.
|
||||
|
@ -4426,10 +4426,10 @@ class Document : public nsINode,
|
|||
//
|
||||
// These are non-owning pointers, the elements are responsible for removing
|
||||
// themselves when they go away.
|
||||
UniquePtr<nsTHashtable<nsPtrHashKey<nsISupports>>> mActivityObservers;
|
||||
UniquePtr<nsTHashSet<nsISupports*>> mActivityObservers;
|
||||
|
||||
// A hashtable of styled links keyed by address pointer.
|
||||
nsTHashtable<nsPtrHashKey<Link>> mStyledLinks;
|
||||
nsTHashSet<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
|
||||
|
@ -5029,7 +5029,7 @@ class Document : public nsINode,
|
|||
// The set of all the tracking script URLs. URLs are added to this set by
|
||||
// calling NoteScriptTrackingStatus(). Currently we assume that a URL not
|
||||
// existing in the set means the corresponding script isn't a tracking script.
|
||||
nsTHashtable<nsCStringHashKey> mTrackingScripts;
|
||||
nsTHashSet<nsCString> mTrackingScripts;
|
||||
|
||||
// Pointer to our parser if we're currently in the process of being
|
||||
// parsed into.
|
||||
|
@ -5095,7 +5095,7 @@ class Document : public nsINode,
|
|||
nsWeakPtr mScopeObject;
|
||||
|
||||
// Array of intersection observers
|
||||
nsTHashtable<nsPtrHashKey<DOMIntersectionObserver>> mIntersectionObservers;
|
||||
nsTHashSet<DOMIntersectionObserver*> mIntersectionObservers;
|
||||
|
||||
RefPtr<DOMIntersectionObserver> mLazyLoadImageObserver;
|
||||
// Used to measure how effective the lazyload thresholds are.
|
||||
|
@ -5113,10 +5113,10 @@ class Document : public nsINode,
|
|||
RefPtr<nsContentList> mImageMaps;
|
||||
|
||||
// A set of responsive images keyed by address pointer.
|
||||
nsTHashtable<nsPtrHashKey<HTMLImageElement>> mResponsiveContent;
|
||||
nsTHashSet<HTMLImageElement*> mResponsiveContent;
|
||||
|
||||
// Tracking for plugins in the document.
|
||||
nsTHashtable<nsPtrHashKey<nsIObjectLoadingContent>> mPlugins;
|
||||
nsTHashSet<nsIObjectLoadingContent*> mPlugins;
|
||||
|
||||
RefPtr<DocumentTimeline> mDocumentTimeline;
|
||||
LinkedList<DocumentTimeline> mTimelines;
|
||||
|
@ -5182,9 +5182,9 @@ class Document : public nsINode,
|
|||
// We lazily calculate declaration blocks for SVG elements with mapped
|
||||
// attributes in Servo mode. This list contains all elements which need lazy
|
||||
// resolution.
|
||||
nsTHashtable<nsPtrHashKey<SVGElement>> mLazySVGPresElements;
|
||||
nsTHashSet<SVGElement*> mLazySVGPresElements;
|
||||
|
||||
nsTHashtable<nsRefPtrHashKey<nsAtom>> mLanguagesUsed;
|
||||
nsTHashSet<RefPtr<nsAtom>> mLanguagesUsed;
|
||||
|
||||
// TODO(emilio): Is this hot enough to warrant to be cached?
|
||||
RefPtr<nsAtom> mLanguageFromCharset;
|
||||
|
|
|
@ -142,7 +142,7 @@ void DocumentOrShadowRoot::SetAdoptedStyleSheets(
|
|||
break;
|
||||
}
|
||||
++commonPrefix;
|
||||
set.PutEntry(mAdoptedStyleSheets[i]);
|
||||
set.Insert(mAdoptedStyleSheets[i]);
|
||||
}
|
||||
|
||||
// Try to truncate the sheets to a common prefix.
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "nsClassHashtable.h"
|
||||
#include "nsContentListDeclarations.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsTHashSet.h"
|
||||
|
||||
class nsContentList;
|
||||
class nsCycleCollectionTraversalCallback;
|
||||
|
@ -254,7 +255,7 @@ class DocumentOrShadowRoot {
|
|||
nsCycleCollectionTraversalCallback&);
|
||||
void UnlinkStyleSheets(nsTArray<RefPtr<StyleSheet>>&);
|
||||
|
||||
using StyleSheetSet = nsTHashtable<nsPtrHashKey<const StyleSheet>>;
|
||||
using StyleSheetSet = nsTHashSet<const StyleSheet*>;
|
||||
void RemoveSheetFromStylesIfApplicable(StyleSheet&);
|
||||
void ClearAdoptedStyleSheets();
|
||||
|
||||
|
|
|
@ -1302,15 +1302,13 @@ nsINode* FindOptimizableSubtreeRoot(nsINode* aNode) {
|
|||
return aNode;
|
||||
}
|
||||
|
||||
StaticAutoPtr<nsTHashtable<nsPtrHashKey<nsINode>>> gCCBlackMarkedNodes;
|
||||
StaticAutoPtr<nsTHashSet<nsINode*>> gCCBlackMarkedNodes;
|
||||
|
||||
static void ClearBlackMarkedNodes() {
|
||||
if (!gCCBlackMarkedNodes) {
|
||||
return;
|
||||
}
|
||||
for (auto iter = gCCBlackMarkedNodes->ConstIter(); !iter.Done();
|
||||
iter.Next()) {
|
||||
nsINode* n = iter.Get()->GetKey();
|
||||
for (nsINode* n : *gCCBlackMarkedNodes) {
|
||||
n->SetCCMarkedRoot(false);
|
||||
n->SetInCCBlackTree(false);
|
||||
}
|
||||
|
@ -1322,7 +1320,7 @@ void FragmentOrElement::RemoveBlackMarkedNode(nsINode* aNode) {
|
|||
if (!gCCBlackMarkedNodes) {
|
||||
return;
|
||||
}
|
||||
gCCBlackMarkedNodes->RemoveEntry(aNode);
|
||||
gCCBlackMarkedNodes->Remove(aNode);
|
||||
}
|
||||
|
||||
static bool IsCertainlyAliveNode(nsINode* aNode, Document* aDoc) {
|
||||
|
@ -1368,7 +1366,7 @@ bool FragmentOrElement::CanSkipInCC(nsINode* aNode) {
|
|||
}
|
||||
|
||||
if (!gCCBlackMarkedNodes) {
|
||||
gCCBlackMarkedNodes = new nsTHashtable<nsPtrHashKey<nsINode>>(1020);
|
||||
gCCBlackMarkedNodes = new nsTHashSet<nsINode*>(1020);
|
||||
}
|
||||
|
||||
// nodesToUnpurple contains nodes which will be removed
|
||||
|
@ -1412,7 +1410,7 @@ bool FragmentOrElement::CanSkipInCC(nsINode* aNode) {
|
|||
|
||||
root->SetCCMarkedRoot(true);
|
||||
root->SetInCCBlackTree(foundLiveWrapper);
|
||||
gCCBlackMarkedNodes->PutEntry(root);
|
||||
gCCBlackMarkedNodes->Insert(root);
|
||||
|
||||
if (!foundLiveWrapper) {
|
||||
return false;
|
||||
|
@ -1427,7 +1425,7 @@ bool FragmentOrElement::CanSkipInCC(nsINode* aNode) {
|
|||
for (uint32_t i = 0; i < grayNodes.Length(); ++i) {
|
||||
nsINode* node = grayNodes[i];
|
||||
node->SetInCCBlackTree(true);
|
||||
gCCBlackMarkedNodes->PutEntry(node);
|
||||
gCCBlackMarkedNodes->Insert(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1721,8 +1719,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement)
|
|||
static_cast<IntersectionObserverList*>(
|
||||
elem->GetProperty(nsGkAtoms::intersectionobserverlist));
|
||||
if (observers) {
|
||||
for (const auto& entry : *observers) {
|
||||
DOMIntersectionObserver* observer = entry.GetKey();
|
||||
for (DOMIntersectionObserver* observer : observers->Keys()) {
|
||||
cb.NoteXPCOMChild(observer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1442,7 +1442,7 @@ nsDOMWindowUtils::GetTranslationNodes(nsINode* aRoot,
|
|||
return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;
|
||||
}
|
||||
|
||||
nsTHashtable<nsPtrHashKey<nsIContent>> translationNodesHash(500);
|
||||
nsTHashSet<nsIContent*> translationNodesHash(500);
|
||||
RefPtr<nsTranslationNodeList> list = new nsTranslationNodeList;
|
||||
|
||||
uint32_t limit = 15000;
|
||||
|
@ -1469,7 +1469,7 @@ nsDOMWindowUtils::GetTranslationNodes(nsINode* aRoot,
|
|||
for (nsIContent* child = content->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsText() && child->GetAsText()->HasTextForTranslation()) {
|
||||
translationNodesHash.PutEntry(content);
|
||||
translationNodesHash.Insert(content);
|
||||
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
bool isTranslationRoot = frame && frame->IsBlockFrameOrSubclass();
|
||||
|
@ -3280,7 +3280,7 @@ nsDOMWindowUtils::IsPartOfOpaqueLayer(Element* aElement, bool* aResult) {
|
|||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::NumberOfAssignedPaintedLayers(
|
||||
const nsTArray<RefPtr<Element>>& aElements, uint32_t* aResult) {
|
||||
nsTHashtable<nsPtrHashKey<PaintedLayer>> layers;
|
||||
nsTHashSet<PaintedLayer*> layers;
|
||||
for (Element* element : aElements) {
|
||||
nsIFrame* frame = element->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
|
@ -3293,7 +3293,7 @@ nsDOMWindowUtils::NumberOfAssignedPaintedLayers(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
layers.PutEntry(layer);
|
||||
layers.Insert(layer);
|
||||
}
|
||||
|
||||
*aResult = layers.Count();
|
||||
|
|
|
@ -322,7 +322,7 @@ bool nsINode::IsSelected(const uint32_t aStartOffset,
|
|||
"Selection is for sure not selected.");
|
||||
|
||||
// Collect the selection objects for potential ranges.
|
||||
nsTHashtable<nsPtrHashKey<Selection>> ancestorSelections;
|
||||
nsTHashSet<Selection*> ancestorSelections;
|
||||
Selection* prevSelection = nullptr;
|
||||
for (; n; n = GetClosestCommonInclusiveAncestorForRangeInSelection(
|
||||
n->GetParentNode())) {
|
||||
|
@ -339,7 +339,7 @@ bool nsINode::IsSelected(const uint32_t aStartOffset,
|
|||
Selection* selection = range->GetSelection();
|
||||
if (prevSelection != selection) {
|
||||
prevSelection = selection;
|
||||
ancestorSelections.PutEntry(selection);
|
||||
ancestorSelections.Insert(selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,8 +347,7 @@ bool nsINode::IsSelected(const uint32_t aStartOffset,
|
|||
|
||||
nsContentUtils::ComparePointsCache cache;
|
||||
IsItemInRangeComparator comparator{*this, aStartOffset, aEndOffset, &cache};
|
||||
for (auto iter = ancestorSelections.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
Selection* selection = iter.Get()->GetKey();
|
||||
for (Selection* selection : ancestorSelections) {
|
||||
// Binary search the sorted ranges in this selection.
|
||||
// (Selection::GetRangeAt returns its ranges ordered).
|
||||
size_t low = 0;
|
||||
|
@ -1828,19 +1827,18 @@ ConvertNodesOrStringsIntoNode(const Sequence<OwningNodeOrString>& aNodes,
|
|||
return fragment.forget();
|
||||
}
|
||||
|
||||
static void InsertNodesIntoHashset(
|
||||
const Sequence<OwningNodeOrString>& aNodes,
|
||||
nsTHashtable<nsPtrHashKey<nsINode>>& aHashset) {
|
||||
static void InsertNodesIntoHashset(const Sequence<OwningNodeOrString>& aNodes,
|
||||
nsTHashSet<nsINode*>& aHashset) {
|
||||
for (const auto& node : aNodes) {
|
||||
if (node.IsNode()) {
|
||||
aHashset.PutEntry(node.GetAsNode());
|
||||
aHashset.Insert(node.GetAsNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static nsINode* FindViablePreviousSibling(
|
||||
const nsINode& aNode, const Sequence<OwningNodeOrString>& aNodes) {
|
||||
nsTHashtable<nsPtrHashKey<nsINode>> nodeSet(16);
|
||||
nsTHashSet<nsINode*> nodeSet(16);
|
||||
InsertNodesIntoHashset(aNodes, nodeSet);
|
||||
|
||||
nsINode* viablePreviousSibling = nullptr;
|
||||
|
@ -1857,7 +1855,7 @@ static nsINode* FindViablePreviousSibling(
|
|||
|
||||
static nsINode* FindViableNextSibling(
|
||||
const nsINode& aNode, const Sequence<OwningNodeOrString>& aNodes) {
|
||||
nsTHashtable<nsPtrHashKey<nsINode>> nodeSet(16);
|
||||
nsTHashSet<nsINode*> nodeSet(16);
|
||||
InsertNodesIntoHashset(aNodes, nodeSet);
|
||||
|
||||
nsINode* viableNextSibling = nullptr;
|
||||
|
|
|
@ -351,8 +351,6 @@ class nsRange final : public mozilla::dom::AbstractRange,
|
|||
*/
|
||||
MOZ_CAN_RUN_SCRIPT void NotifySelectionListenersAfterRangeSet();
|
||||
|
||||
typedef nsTHashtable<nsPtrHashKey<nsRange>> RangeHashTable;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor
|
||||
|
|
|
@ -1492,37 +1492,37 @@ void nsTreeSanitizer::InitializeStatics() {
|
|||
|
||||
sElementsHTML = new AtomsTable(ArrayLength(kElementsHTML));
|
||||
for (uint32_t i = 0; kElementsHTML[i]; i++) {
|
||||
sElementsHTML->PutEntry(kElementsHTML[i]);
|
||||
sElementsHTML->Insert(kElementsHTML[i]);
|
||||
}
|
||||
|
||||
sAttributesHTML = new AtomsTable(ArrayLength(kAttributesHTML));
|
||||
for (uint32_t i = 0; kAttributesHTML[i]; i++) {
|
||||
sAttributesHTML->PutEntry(kAttributesHTML[i]);
|
||||
sAttributesHTML->Insert(kAttributesHTML[i]);
|
||||
}
|
||||
|
||||
sPresAttributesHTML = new AtomsTable(ArrayLength(kPresAttributesHTML));
|
||||
for (uint32_t i = 0; kPresAttributesHTML[i]; i++) {
|
||||
sPresAttributesHTML->PutEntry(kPresAttributesHTML[i]);
|
||||
sPresAttributesHTML->Insert(kPresAttributesHTML[i]);
|
||||
}
|
||||
|
||||
sElementsSVG = new AtomsTable(ArrayLength(kElementsSVG));
|
||||
for (uint32_t i = 0; kElementsSVG[i]; i++) {
|
||||
sElementsSVG->PutEntry(kElementsSVG[i]);
|
||||
sElementsSVG->Insert(kElementsSVG[i]);
|
||||
}
|
||||
|
||||
sAttributesSVG = new AtomsTable(ArrayLength(kAttributesSVG));
|
||||
for (uint32_t i = 0; kAttributesSVG[i]; i++) {
|
||||
sAttributesSVG->PutEntry(kAttributesSVG[i]);
|
||||
sAttributesSVG->Insert(kAttributesSVG[i]);
|
||||
}
|
||||
|
||||
sElementsMathML = new AtomsTable(ArrayLength(kElementsMathML));
|
||||
for (uint32_t i = 0; kElementsMathML[i]; i++) {
|
||||
sElementsMathML->PutEntry(kElementsMathML[i]);
|
||||
sElementsMathML->Insert(kElementsMathML[i]);
|
||||
}
|
||||
|
||||
sAttributesMathML = new AtomsTable(ArrayLength(kAttributesMathML));
|
||||
for (uint32_t i = 0; kAttributesMathML[i]; i++) {
|
||||
sAttributesMathML->PutEntry(kAttributesMathML[i]);
|
||||
sAttributesMathML->Insert(kAttributesMathML[i]);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "nsAtom.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsTHashSet.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsINode;
|
||||
|
@ -102,10 +102,10 @@ class MOZ_STACK_CLASS nsTreeSanitizer {
|
|||
/**
|
||||
* We have various tables of static atoms for elements and attributes.
|
||||
*/
|
||||
class AtomsTable : public nsTHashtable<nsPtrHashKey<const nsStaticAtom>> {
|
||||
class AtomsTable : public nsTHashSet<const nsStaticAtom*> {
|
||||
public:
|
||||
explicit AtomsTable(uint32_t aLength)
|
||||
: nsTHashtable<nsPtrHashKey<const nsStaticAtom>>(aLength) {}
|
||||
: nsTHashSet<const nsStaticAtom*>(aLength) {}
|
||||
|
||||
bool Contains(nsAtom* aAtom) {
|
||||
// Because this table only contains static atoms, if aAtom isn't
|
||||
|
|
|
@ -207,7 +207,7 @@ static void ReportCount(const nsCString& aBasePath, const char* aPathTail,
|
|||
|
||||
static void CollectWindowReports(nsGlobalWindowInner* aWindow,
|
||||
nsWindowSizes* aWindowTotalSizes,
|
||||
nsTHashtable<nsUint64HashKey>* aGhostWindowIDs,
|
||||
nsTHashSet<uint64_t>* aGhostWindowIDs,
|
||||
WindowPaths* aWindowPaths,
|
||||
WindowPaths* aTopWindowPaths,
|
||||
nsIHandleReportCallback* aHandleReport,
|
||||
|
@ -502,19 +502,13 @@ nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
windows.AppendElement(entry.GetData());
|
||||
}
|
||||
|
||||
// Get the IDs of all the "ghost" windows, and call aHandleReport->Callback()
|
||||
// for each one.
|
||||
nsTHashtable<nsUint64HashKey> ghostWindows;
|
||||
// Get the IDs of all the "ghost" windows, and call
|
||||
// aHandleReport->Callback() for each one.
|
||||
nsTHashSet<uint64_t> ghostWindows;
|
||||
CheckForGhostWindows(&ghostWindows);
|
||||
for (auto iter = ghostWindows.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
nsGlobalWindowInner::InnerWindowByIdTable* windowsById =
|
||||
nsGlobalWindowInner::GetWindowsTable();
|
||||
if (!windowsById) {
|
||||
NS_WARNING("Couldn't get window-by-id hashtable?");
|
||||
continue;
|
||||
}
|
||||
|
||||
nsGlobalWindowInner* window = windowsById->Get(iter.Get()->GetKey());
|
||||
for (const auto& key : ghostWindows) {
|
||||
nsGlobalWindowInner* window = windowsById->Get(key);
|
||||
if (!window) {
|
||||
NS_WARNING("Could not look up window?");
|
||||
continue;
|
||||
|
@ -787,7 +781,7 @@ void nsWindowMemoryReporter::ObserveAfterMinimizeMemoryUsage() {
|
|||
* all ghost windows we found.
|
||||
*/
|
||||
void nsWindowMemoryReporter::CheckForGhostWindows(
|
||||
nsTHashtable<nsUint64HashKey>* aOutGhostIDs /* = nullptr */) {
|
||||
nsTHashSet<uint64_t>* aOutGhostIDs /* = nullptr */) {
|
||||
nsGlobalWindowInner::InnerWindowByIdTable* windowsById =
|
||||
nsGlobalWindowInner::GetWindowsTable();
|
||||
if (!windowsById) {
|
||||
|
@ -798,8 +792,7 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
|
|||
mLastCheckForGhostWindows = TimeStamp::NowLoRes();
|
||||
KillCheckTimer();
|
||||
|
||||
nsTHashtable<nsPtrHashKey<BrowsingContextGroup>>
|
||||
nonDetachedBrowsingContextGroups;
|
||||
nsTHashSet<BrowsingContextGroup*> nonDetachedBrowsingContextGroups;
|
||||
|
||||
// Populate nonDetachedBrowsingContextGroups.
|
||||
for (const auto& entry : *windowsById) {
|
||||
|
@ -813,8 +806,7 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
|
|||
continue;
|
||||
}
|
||||
|
||||
nonDetachedBrowsingContextGroups.PutEntry(
|
||||
window->GetBrowsingContextGroup());
|
||||
nonDetachedBrowsingContextGroups.Insert(window->GetBrowsingContextGroup());
|
||||
}
|
||||
|
||||
// Update mDetachedWindows and write the ghost window IDs into aOutGhostIDs,
|
||||
|
@ -852,7 +844,7 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
|
|||
BrowsingContextGroup* browsingContextGroup =
|
||||
window->GetBrowsingContextGroup();
|
||||
if (browsingContextGroup &&
|
||||
nonDetachedBrowsingContextGroups.GetEntry(browsingContextGroup)) {
|
||||
nonDetachedBrowsingContextGroups.Contains(browsingContextGroup)) {
|
||||
// This window is in the same browsing context group as a non-detached
|
||||
// window, so reset its clock.
|
||||
timeStamp = TimeStamp();
|
||||
|
@ -867,7 +859,7 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
|
|||
// that is not null.
|
||||
mGhostWindowCount++;
|
||||
if (aOutGhostIDs && window) {
|
||||
aOutGhostIDs->PutEntry(window->WindowID());
|
||||
aOutGhostIDs->Insert(window->WindowID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -910,16 +902,16 @@ void nsWindowMemoryReporter::UnlinkGhostWindows() {
|
|||
}
|
||||
|
||||
// Get the IDs of all the "ghost" windows, and unlink them all.
|
||||
nsTHashtable<nsUint64HashKey> ghostWindows;
|
||||
nsTHashSet<uint64_t> ghostWindows;
|
||||
sWindowReporter->CheckForGhostWindows(&ghostWindows);
|
||||
for (auto iter = ghostWindows.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
for (const auto& key : ghostWindows) {
|
||||
nsGlobalWindowInner::InnerWindowByIdTable* windowsById =
|
||||
nsGlobalWindowInner::GetWindowsTable();
|
||||
if (!windowsById) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RefPtr<nsGlobalWindowInner> window = windowsById->Get(iter.Get()->GetKey());
|
||||
RefPtr<nsGlobalWindowInner> window = windowsById->Get(key);
|
||||
if (window) {
|
||||
window->RiskyUnlink();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsTHashMap.h"
|
||||
#include "nsTHashSet.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
|
@ -132,8 +133,7 @@ class nsWindowMemoryReporter final : public nsIMemoryReporter,
|
|||
* This is called asynchronously after we observe a DOM window being detached
|
||||
* from its docshell, and also right before we generate a memory report.
|
||||
*/
|
||||
void CheckForGhostWindows(
|
||||
nsTHashtable<nsUint64HashKey>* aOutGhostIDs = nullptr);
|
||||
void CheckForGhostWindows(nsTHashSet<uint64_t>* aOutGhostIDs = nullptr);
|
||||
|
||||
/**
|
||||
* Eventually do a check for ghost windows, if we haven't done one recently
|
||||
|
|
|
@ -280,8 +280,7 @@ nsresult nsWindowRoot::GetControllerForCommand(const char* aCommand,
|
|||
}
|
||||
|
||||
void nsWindowRoot::GetEnabledDisabledCommandsForControllers(
|
||||
nsIControllers* aControllers,
|
||||
nsTHashtable<nsCStringHashKey>& aCommandsHandled,
|
||||
nsIControllers* aControllers, nsTHashSet<nsCString>& aCommandsHandled,
|
||||
nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands) {
|
||||
uint32_t controllerCount;
|
||||
|
@ -322,7 +321,7 @@ void nsWindowRoot::GetEnabledDisabledCommandsForControllers(
|
|||
void nsWindowRoot::GetEnabledDisabledCommands(
|
||||
nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands) {
|
||||
nsTHashtable<nsCStringHashKey> commandsHandled;
|
||||
nsTHashSet<nsCString> commandsHandled;
|
||||
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
GetControllers(false, getter_AddRefs(controllers));
|
||||
|
@ -367,20 +366,20 @@ JSObject* nsWindowRoot::WrapObject(JSContext* aCx,
|
|||
|
||||
void nsWindowRoot::AddBrowser(nsIRemoteTab* aBrowser) {
|
||||
nsWeakPtr weakBrowser = do_GetWeakReference(aBrowser);
|
||||
mWeakBrowsers.PutEntry(weakBrowser);
|
||||
mWeakBrowsers.Insert(weakBrowser);
|
||||
}
|
||||
|
||||
void nsWindowRoot::RemoveBrowser(nsIRemoteTab* aBrowser) {
|
||||
nsWeakPtr weakBrowser = do_GetWeakReference(aBrowser);
|
||||
mWeakBrowsers.RemoveEntry(weakBrowser);
|
||||
mWeakBrowsers.Remove(weakBrowser);
|
||||
}
|
||||
|
||||
void nsWindowRoot::EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) {
|
||||
// Collect strong references to all browsers in a separate array in
|
||||
// case aEnumFunc alters mWeakBrowsers.
|
||||
nsTArray<nsCOMPtr<nsIRemoteTab>> remoteTabs;
|
||||
for (auto iter = mWeakBrowsers.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
nsCOMPtr<nsIRemoteTab> remoteTab(do_QueryReferent(iter.Get()->GetKey()));
|
||||
for (const auto& key : mWeakBrowsers) {
|
||||
nsCOMPtr<nsIRemoteTab> remoteTab(do_QueryReferent(key));
|
||||
if (remoteTab) {
|
||||
remoteTabs.AppendElement(remoteTab);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class nsIGlobalObject;
|
|||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsPIWindowRoot.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsTHashSet.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
class nsWindowRoot final : public nsPIWindowRoot {
|
||||
|
@ -77,8 +77,7 @@ class nsWindowRoot final : public nsPIWindowRoot {
|
|||
virtual ~nsWindowRoot();
|
||||
|
||||
void GetEnabledDisabledCommandsForControllers(
|
||||
nsIControllers* aControllers,
|
||||
nsTHashtable<nsCStringHashKey>& aCommandsHandled,
|
||||
nsIControllers* aControllers, nsTHashSet<nsCString>& aCommandsHandled,
|
||||
nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands);
|
||||
|
||||
|
@ -95,7 +94,7 @@ class nsWindowRoot final : public nsPIWindowRoot {
|
|||
|
||||
// The BrowserParents that are currently registered with this top-level
|
||||
// window.
|
||||
typedef nsTHashtable<nsRefPtrHashKey<nsIWeakReference>> WeakBrowserTable;
|
||||
typedef nsTHashSet<RefPtr<nsIWeakReference>> WeakBrowserTable;
|
||||
WeakBrowserTable mWeakBrowsers;
|
||||
};
|
||||
|
||||
|
|
|
@ -130,8 +130,7 @@ nsPresContext* ServoStyleSet::GetPresContext() {
|
|||
template <typename Functor>
|
||||
static void EnumerateShadowRoots(const Document& aDoc, const Functor& aCb) {
|
||||
const Document::ShadowRootSet& shadowRoots = aDoc.ComposedShadowRoots();
|
||||
for (auto iter = shadowRoots.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
ShadowRoot* root = iter.Get()->GetKey();
|
||||
for (ShadowRoot* root : shadowRoots) {
|
||||
MOZ_ASSERT(root);
|
||||
MOZ_DIAGNOSTIC_ASSERT(root->IsInComposedDoc());
|
||||
aCb(*root);
|
||||
|
|
Загрузка…
Ссылка в новой задаче