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