зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1571031 - Change Location::Reload to take an ErroResult, since it's what both callers expect. r=bzbarsky
Not sure what you think of the `return aRv.Throw()` pattern, I find it nice, but it seems we don't use it a lot. Also Location.h is inconsistent on aError vs. aRv, if you want me to change to one or the other let me know. Differential Revision: https://phabricator.services.mozilla.com/D40450 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c9df10668e
Коммит
fbee3c2fc2
|
@ -731,10 +731,10 @@ void Location::SetSearch(const nsAString& aSearch,
|
|||
SetURI(uri, aSubjectPrincipal, aRv);
|
||||
}
|
||||
|
||||
nsresult Location::Reload(bool aForceget) {
|
||||
void Location::Reload(bool aForceget, ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
|
||||
if (!docShell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
if (StaticPrefs::dom_block_reload_from_resize_event_handler()) {
|
||||
|
@ -753,8 +753,7 @@ nsresult Location::Reload(bool aForceget) {
|
|||
pcx->RebuildAllStyleData(NS_STYLE_HINT_REFLOW,
|
||||
RestyleHint::RestyleSubtree());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,14 +766,12 @@ nsresult Location::Reload(bool aForceget) {
|
|||
}
|
||||
|
||||
nsresult rv = nsDocShell::Cast(docShell)->Reload(reloadFlags);
|
||||
if (rv == NS_BINDING_ABORTED) {
|
||||
// This happens when we attempt to reload a POST result and the user says
|
||||
// no at the "do you want to reload?" prompt. Don't propagate this one
|
||||
// back to callers.
|
||||
rv = NS_OK;
|
||||
if (rv != NS_BINDING_ABORTED) {
|
||||
// NS_BINDING_ABORTED is returned when we attempt to reload a POST result
|
||||
// and the user says no at the "do you want to reload?" prompt. Don't
|
||||
// propagate this one back to callers.
|
||||
return aRv.Throw(rv);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void Location::Replace(const nsAString& aUrl, nsIPrincipal& aSubjectPrincipal,
|
||||
|
|
|
@ -50,7 +50,7 @@ class Location final : public nsISupports, public nsWrapperCache {
|
|||
return;
|
||||
}
|
||||
|
||||
aError = Reload(aForceget);
|
||||
Reload(aForceget, aError);
|
||||
}
|
||||
|
||||
void GetHref(nsAString& aHref, nsIPrincipal& aSubjectPrincipal,
|
||||
|
@ -128,7 +128,7 @@ class Location final : public nsISupports, public nsWrapperCache {
|
|||
|
||||
nsresult ToString(nsAString& aString) { return GetHref(aString); }
|
||||
|
||||
nsresult Reload(bool aForceget);
|
||||
void Reload(bool aForceget, ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
virtual ~Location();
|
||||
|
|
|
@ -140,9 +140,7 @@ void nsHistory::GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
|||
void nsHistory::Go(int32_t aDelta, ErrorResult& aRv) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
|
||||
if (!win || !win->HasActiveDocument()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
||||
return;
|
||||
return aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
||||
if (!aDelta) {
|
||||
|
@ -150,17 +148,12 @@ void nsHistory::Go(int32_t aDelta, ErrorResult& aRv) {
|
|||
// "When the go(delta) method is invoked, if delta is zero, the user agent
|
||||
// must act as if the location.reload() method was called instead."
|
||||
RefPtr<Location> location = win->Location();
|
||||
nsresult rv = location->Reload(false);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
return;
|
||||
return location->Reload(false, aRv);
|
||||
}
|
||||
|
||||
RefPtr<ChildSHistory> session_history = GetSessionHistory();
|
||||
if (!session_history) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче