mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 110567 - Remove nsIDocShell::GetURLSearchParams(), r=smaug
This commit is contained in:
parent
647cbae2ff
commit
689a34864f
@ -193,7 +193,6 @@
|
||||
#include "nsIWidget.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "nsPerformance.h"
|
||||
|
||||
#ifdef MOZ_TOOLKIT_SEARCH
|
||||
@ -2022,24 +2021,6 @@ nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
|
||||
mLSHE->GetIsSubFrame(&isSubFrame);
|
||||
}
|
||||
|
||||
// nsDocShell owns a URLSearchParams that is used by
|
||||
// window.location.searchParams to be in sync with the current location.
|
||||
if (!mURLSearchParams) {
|
||||
mURLSearchParams = new URLSearchParams();
|
||||
}
|
||||
|
||||
nsAutoCString search;
|
||||
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(mCurrentURI));
|
||||
if (url) {
|
||||
nsresult rv = url->GetQuery(search);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to get the query from a nsIURL.");
|
||||
}
|
||||
}
|
||||
|
||||
mURLSearchParams->ParseInput(search, nullptr);
|
||||
|
||||
if (!isSubFrame && !isRoot) {
|
||||
/*
|
||||
* We don't want to send OnLocationChange notifications when
|
||||
@ -5846,11 +5827,6 @@ nsDocShell::Destroy()
|
||||
mParentWidget = nullptr;
|
||||
mCurrentURI = nullptr;
|
||||
|
||||
if (mURLSearchParams) {
|
||||
mURLSearchParams->RemoveObservers();
|
||||
mURLSearchParams = nullptr;
|
||||
}
|
||||
|
||||
if (mScriptGlobal) {
|
||||
mScriptGlobal->DetachFromDocShell();
|
||||
mScriptGlobal = nullptr;
|
||||
@ -13931,12 +13907,6 @@ nsDocShell::GetOpener()
|
||||
return opener;
|
||||
}
|
||||
|
||||
URLSearchParams*
|
||||
nsDocShell::GetURLSearchParams()
|
||||
{
|
||||
return mURLSearchParams;
|
||||
}
|
||||
|
||||
class JavascriptTimelineMarker : public TimelineMarker
|
||||
{
|
||||
public:
|
||||
|
@ -60,7 +60,6 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class EventTarget;
|
||||
class URLSearchParams;
|
||||
}
|
||||
}
|
||||
|
||||
@ -841,9 +840,6 @@ protected:
|
||||
nsCOMPtr<nsIChannel> mFailedChannel;
|
||||
uint32_t mFailedLoadType;
|
||||
|
||||
// window.location.searchParams is updated in sync with this object.
|
||||
nsRefPtr<mozilla::dom::URLSearchParams> mURLSearchParams;
|
||||
|
||||
// Set in DoURILoad when either the LOAD_RELOAD_ALLOW_MIXED_CONTENT flag or
|
||||
// the LOAD_NORMAL_ALLOW_MIXED_CONTENT flag is set.
|
||||
// Checked in nsMixedContentBlocker, to see if the channels match.
|
||||
|
@ -11,13 +11,6 @@
|
||||
#include "js/TypeDecls.h"
|
||||
class nsPresContext;
|
||||
class nsIPresShell;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class URLSearchParams;
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/**
|
||||
@ -26,7 +19,6 @@ class URLSearchParams;
|
||||
|
||||
[ptr] native nsPresContext(nsPresContext);
|
||||
[ptr] native nsIPresShell(nsIPresShell);
|
||||
[ptr] native URLSearchParams(mozilla::dom::URLSearchParams);
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIChannel;
|
||||
@ -54,7 +46,7 @@ interface nsITabParent;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
[scriptable, builtinclass, uuid(696b32a1-3cf1-4909-b501-474b25fc7954)]
|
||||
[scriptable, builtinclass, uuid(b3137b7c-d589-48aa-b89b-e02aa451d42c)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
@ -1031,9 +1023,6 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
[noscript,notxpcom,nostdcall] void setOpener(in nsITabParent aOpener);
|
||||
[noscript,notxpcom,nostdcall] nsITabParent getOpener();
|
||||
|
||||
// URLSearchParams for the window.location is owned by the docShell.
|
||||
[noscript,notxpcom] URLSearchParams getURLSearchParams();
|
||||
|
||||
/**
|
||||
* Notify DocShell when the browser is about to start executing JS, and after
|
||||
* that execution has stopped. This only occurs when the Timeline devtool
|
||||
|
@ -61,7 +61,6 @@ nsLocation::nsLocation(nsPIDOMWindow* aWindow, nsIDocShell *aDocShell)
|
||||
|
||||
nsLocation::~nsLocation()
|
||||
{
|
||||
RemoveURLSearchParams();
|
||||
}
|
||||
|
||||
// QueryInterface implementation for nsLocation
|
||||
@ -74,14 +73,11 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsLocation)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsLocation)
|
||||
tmp->RemoveURLSearchParams();
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInnerWindow);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsLocation)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSearchParams)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInnerWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
@ -1057,119 +1053,3 @@ nsLocation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return LocationBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
URLSearchParams*
|
||||
nsLocation::GetDocShellSearchParams()
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = GetDocShell();
|
||||
if (!docShell) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return docShell->GetURLSearchParams();
|
||||
}
|
||||
|
||||
URLSearchParams*
|
||||
nsLocation::SearchParams()
|
||||
{
|
||||
if (!mSearchParams) {
|
||||
// We must register this object to the URLSearchParams of the docshell in
|
||||
// order to receive updates.
|
||||
nsRefPtr<URLSearchParams> searchParams = GetDocShellSearchParams();
|
||||
if (searchParams) {
|
||||
searchParams->AddObserver(this);
|
||||
}
|
||||
|
||||
mSearchParams = new URLSearchParams();
|
||||
mSearchParams->AddObserver(this);
|
||||
UpdateURLSearchParams();
|
||||
}
|
||||
|
||||
return mSearchParams;
|
||||
}
|
||||
|
||||
void
|
||||
nsLocation::SetSearchParams(URLSearchParams& aSearchParams)
|
||||
{
|
||||
if (mSearchParams) {
|
||||
mSearchParams->RemoveObserver(this);
|
||||
}
|
||||
|
||||
// the observer will be cleared using the cycle collector.
|
||||
mSearchParams = &aSearchParams;
|
||||
mSearchParams->AddObserver(this);
|
||||
|
||||
nsAutoString search;
|
||||
mSearchParams->Serialize(search);
|
||||
SetSearchInternal(search);
|
||||
|
||||
// We don't need to inform the docShell about this new SearchParams because
|
||||
// setting the new value the docShell will refresh its value automatically.
|
||||
}
|
||||
|
||||
void
|
||||
nsLocation::URLSearchParamsUpdated(URLSearchParams* aSearchParams)
|
||||
{
|
||||
MOZ_ASSERT(mSearchParams);
|
||||
|
||||
// This change comes from content.
|
||||
if (aSearchParams == mSearchParams) {
|
||||
nsAutoString search;
|
||||
mSearchParams->Serialize(search);
|
||||
SetSearchInternal(search);
|
||||
return;
|
||||
}
|
||||
|
||||
// This change comes from the docShell.
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsRefPtr<URLSearchParams> searchParams = GetDocShellSearchParams();
|
||||
MOZ_ASSERT(searchParams);
|
||||
MOZ_ASSERT(aSearchParams == searchParams);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsAutoString search;
|
||||
aSearchParams->Serialize(search);
|
||||
mSearchParams->ParseInput(NS_ConvertUTF16toUTF8(search), this);
|
||||
}
|
||||
|
||||
void
|
||||
nsLocation::UpdateURLSearchParams()
|
||||
{
|
||||
if (!mSearchParams) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString search;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetURI(getter_AddRefs(uri));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)) || NS_WARN_IF(!uri)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
||||
if (url) {
|
||||
nsresult rv = url->GetQuery(search);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to get the query from a nsIURL.");
|
||||
}
|
||||
}
|
||||
|
||||
mSearchParams->ParseInput(search, this);
|
||||
}
|
||||
|
||||
void
|
||||
nsLocation::RemoveURLSearchParams()
|
||||
{
|
||||
if (mSearchParams) {
|
||||
mSearchParams->RemoveObserver(this);
|
||||
mSearchParams = nullptr;
|
||||
|
||||
nsRefPtr<URLSearchParams> docShellSearchParams = GetDocShellSearchParams();
|
||||
if (docShellSearchParams) {
|
||||
docShellSearchParams->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
class nsIURI;
|
||||
@ -27,7 +26,6 @@ class nsIDocShellLoadInfo;
|
||||
|
||||
class nsLocation final : public nsIDOMLocation
|
||||
, public nsWrapperCache
|
||||
, public mozilla::dom::URLSearchParamsObserver
|
||||
{
|
||||
typedef mozilla::ErrorResult ErrorResult;
|
||||
|
||||
@ -122,10 +120,6 @@ public:
|
||||
aError = SetSearch(aSeach);
|
||||
}
|
||||
|
||||
mozilla::dom::URLSearchParams* SearchParams();
|
||||
|
||||
void SetSearchParams(mozilla::dom::URLSearchParams& aSearchParams);
|
||||
|
||||
void GetHash(nsAString& aHash, ErrorResult& aError)
|
||||
{
|
||||
aError = GetHash(aHash);
|
||||
@ -144,17 +138,10 @@ public:
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// URLSearchParamsObserver
|
||||
void URLSearchParamsUpdated(mozilla::dom::URLSearchParams* aSearchParams) override;
|
||||
|
||||
protected:
|
||||
virtual ~nsLocation();
|
||||
|
||||
nsresult SetSearchInternal(const nsAString& aSearch);
|
||||
void UpdateURLSearchParams();
|
||||
void RemoveURLSearchParams();
|
||||
|
||||
mozilla::dom::URLSearchParams* GetDocShellSearchParams();
|
||||
|
||||
// In the case of jar: uris, we sometimes want the place the jar was
|
||||
// fetched from as the URI instead of the jar: uri itself. Pass in
|
||||
@ -173,9 +160,7 @@ protected:
|
||||
|
||||
nsString mCachedHash;
|
||||
nsCOMPtr<nsPIDOMWindow> mInnerWindow;
|
||||
nsRefPtr<mozilla::dom::URLSearchParams> mSearchParams;
|
||||
nsWeakPtr mDocShell;
|
||||
};
|
||||
|
||||
#endif // nsLocation_h__
|
||||
|
||||
|
@ -21,6 +21,5 @@ interface Location {
|
||||
[Throws, UnsafeInPrerendering]
|
||||
void reload(optional boolean forceget = false);
|
||||
};
|
||||
// No support for .searchParams on Location yet. See bug 1082734.
|
||||
|
||||
Location implements URLUtils;
|
||||
|
Loading…
Reference in New Issue
Block a user