diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 05c75d4d97e8..39192c1ae834 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -616,7 +616,6 @@ void BrowsingContext::SetDocShell(nsIDocShell* aDocShell) { } RecomputeCanExecuteScripts(); - ClearCachedValuesOfLocations(); } // This class implements a callback that will return the remote window proxy for @@ -1048,8 +1047,6 @@ void BrowsingContext::PrepareForProcessChange() { mIsInProcess = false; mUserGestureStart = TimeStamp(); - ClearCachedValuesOfLocations(); - // NOTE: For now, clear our nsDocShell reference, as we're primarily in a // different process now. This may need to change in the future with // Cross-Process BFCache. @@ -1416,9 +1413,6 @@ BrowsingContext::~BrowsingContext() { sBrowsingContexts->Remove(Id()); } UnregisterBrowserId(this); - - ClearCachedValuesOfLocations(); - mLocations.clear(); } /* static */ @@ -3759,17 +3753,6 @@ void BrowsingContext::ResetLocationChangeRateLimit() { mLocationChangeRateLimitSpanStart = TimeStamp(); } -void BrowsingContext::LocationCreated(dom::Location* aLocation) { - MOZ_ASSERT(!aLocation->isInList()); - mLocations.insertBack(aLocation); -} - -void BrowsingContext::ClearCachedValuesOfLocations() { - for (dom::Location* loc = mLocations.getFirst(); loc; loc = loc->getNext()) { - loc->ClearCachedValues(); - } -} - } // namespace dom namespace ipc { diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index a4a85f57e492..4c245337b7db 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -68,7 +68,6 @@ class ChildSHistory; class ContentParent; class Element; struct LoadingSessionHistoryInfo; -class Location; template struct Nullable; template @@ -949,9 +948,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache { return GetIsUnderHiddenEmbedderElement(); } - void LocationCreated(dom::Location* aLocation); - void ClearCachedValuesOfLocations(); - protected: virtual ~BrowsingContext(); BrowsingContext(WindowContext* aParentWindow, BrowsingContextGroup* aGroup, @@ -1410,8 +1406,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache { // Used by CheckLocationChangeRateLimit. Do not apply cross-process. uint32_t mLocationChangeRateLimitCount; mozilla::TimeStamp mLocationChangeRateLimitSpanStart; - - mozilla::LinkedList mLocations; }; /** diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 6629a66bbe20..543fa3af44aa 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1550,7 +1550,7 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest, mTitleValidForCurrentURI = false; } - SetCurrentURIInternal(aURI); + mCurrentURI = aURI; #ifdef DEBUG mLastOpenedURI = aURI; @@ -1576,13 +1576,6 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest, return !aFireOnLocationChange; } -void nsDocShell::SetCurrentURIInternal(nsIURI* aURI) { - mCurrentURI = aURI; - if (mBrowsingContext) { - mBrowsingContext->ClearCachedValuesOfLocations(); - } -} - NS_IMETHODIMP nsDocShell::GetCharset(nsACString& aCharset) { aCharset.Truncate(); @@ -4574,7 +4567,7 @@ nsDocShell::Destroy() { nsDocLoader::Destroy(); mParentWidget = nullptr; - SetCurrentURIInternal(nullptr); + mCurrentURI = nullptr; if (mScriptGlobal) { mScriptGlobal->DetachFromDocShell(!mWillChangeProcess); @@ -8189,7 +8182,7 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer, viewer->Close(nullptr); viewer->Destroy(); mContentViewer = nullptr; - SetCurrentURIInternal(nullptr); + mCurrentURI = nullptr; NS_WARNING("ContentViewer Initialization failed"); return NS_ERROR_FAILURE; } diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 21cd7c944b39..0f360bf1f5f2 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -1160,10 +1160,7 @@ class nsDocShell final : public nsDocLoader, const nsAString& aTitle, bool aReplace, nsIURI* aCurrentURI, bool aEqualURIs); - private: - void SetCurrentURIInternal(nsIURI* aURI); - - // data members + private: // data members nsString mTitle; nsCString mOriginalUriString; nsTObserverArray mPrivacyObservers; @@ -1208,7 +1205,6 @@ class nsDocShell final : public nsDocLoader, mozilla::UniquePtr mObserved; // mCurrentURI should be marked immutable on set if possible. - // Change mCurrentURI only through SetCurrentURIInternal method. nsCOMPtr mCurrentURI; nsCOMPtr mReferrerInfo; diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp index c4e26964a86e..6b488991204b 100644 --- a/dom/base/Location.cpp +++ b/dom/base/Location.cpp @@ -42,18 +42,13 @@ namespace mozilla::dom { Location::Location(nsPIDOMWindowInner* aWindow, BrowsingContext* aBrowsingContext) : mInnerWindow(aWindow) { - // aBrowsingContext can be null if it gets called after nsDocShell::Destroy(). + // aBrowsingContext can be null if it gets called after nsDocShell::Destory(). if (aBrowsingContext) { mBrowsingContextId = aBrowsingContext->Id(); - aBrowsingContext->LocationCreated(this); } } -Location::~Location() { - if (isInList()) { - remove(); - } -} +Location::~Location() = default; // QueryInterface implementation for Location NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Location) @@ -651,8 +646,4 @@ JSObject* Location::WrapObject(JSContext* aCx, return Location_Binding::Wrap(aCx, this, aGivenProto); } -void Location::ClearCachedValues() { - Location_Binding::ClearCachedHashValue(this); -} - } // namespace mozilla::dom diff --git a/dom/base/Location.h b/dom/base/Location.h index 448af2d8c19b..5fb92beb0417 100644 --- a/dom/base/Location.h +++ b/dom/base/Location.h @@ -9,7 +9,6 @@ #include "js/TypeDecls.h" #include "mozilla/ErrorResult.h" -#include "mozilla/LinkedList.h" #include "mozilla/dom/BrowsingContext.h" #include "mozilla/dom/LocationBase.h" #include "nsCycleCollectionParticipant.h" @@ -29,8 +28,7 @@ namespace mozilla::dom { class Location final : public nsISupports, public LocationBase, - public nsWrapperCache, - public LinkedListElement { + public nsWrapperCache { public: typedef BrowsingContext::LocationProxy RemoteProxy; @@ -112,8 +110,6 @@ class Location final : public nsISupports, nsresult ToString(nsAString& aString) { return GetHref(aString); } - void ClearCachedValues(); - protected: virtual ~Location(); diff --git a/dom/webidl/Location.webidl b/dom/webidl/Location.webidl index 28bd69bdb7af..5ee62c72fe80 100644 --- a/dom/webidl/Location.webidl +++ b/dom/webidl/Location.webidl @@ -11,9 +11,6 @@ * and create derivative works of this document. */ -// Consider to cache more attributes, if the getters show up badly in -// the performance profiles. - [LegacyUnforgeable, Exposed=Window] interface Location { @@ -33,7 +30,7 @@ interface Location { attribute USVString pathname; [Throws, NeedsSubjectPrincipal] attribute USVString search; - [Throws, NeedsSubjectPrincipal, Cached, Pure] + [Throws, NeedsSubjectPrincipal] attribute USVString hash; [Throws, NeedsSubjectPrincipal]