Bug 1510569 - Keep track of whether we are navigating to a new URI in nsDocShell r=mconley,kmag,qdot
Previously the `WebNavigationChild` would keep track of when triggering its `nsIWebNavigation`, `goForward`, `goBack`, `gotoIndex`, and `loadURI` methods. It's `nsIWebNavigation` instance is always an `nsIDocShell` and as part of porting `OnStateChange` and `OnLocationChange` events from `WebProgressChild`/`RemoteWebProgress` to `BrowserChild`/`BrowserParent`, this informations needs to be available from the `BrowserChild`. As it stands, it is currently an expando property on the `WebProgressChild`. Instead of introducing yet another XPCOM interface for the WebProgressChild, we now store this information directly on the `nsDocShell`. Furthermore, instead of having the `WebNavigationChild` manage this part of the `nsDocShell`'s state, we can have the `nsDocShell` manage this state itself so it is always consistent. Differential Revision: https://phabricator.services.mozilla.com/D28124
This commit is contained in:
@@ -385,7 +385,8 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext)
|
||||
mHasLoadedNonBlankURI(false),
|
||||
mBlankTiming(false),
|
||||
mTitleValidForCurrentURI(false),
|
||||
mIsFrame(false) {
|
||||
mIsFrame(false),
|
||||
mIsNavigating(false) {
|
||||
mHistoryID.m0 = 0;
|
||||
mHistoryID.m1 = 0;
|
||||
mHistoryID.m2 = 0;
|
||||
@@ -3725,6 +3726,12 @@ nsDocShell::GetContentBlockingLog(Promise** aPromise) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetIsNavigating(bool* aOut) {
|
||||
*aOut = mIsNavigating;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetDeviceSizeIsPageSize(bool aValue) {
|
||||
if (mDeviceSizeIsPageSize != aValue) {
|
||||
@@ -3826,6 +3833,10 @@ nsDocShell::GoBack() {
|
||||
if (!IsNavigationAllowed()) {
|
||||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
|
||||
auto cleanupIsNavigating = MakeScopeExit([&]() { mIsNavigating = false; });
|
||||
mIsNavigating = true;
|
||||
|
||||
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||
NS_ENSURE_TRUE(rootSH, NS_ERROR_FAILURE);
|
||||
ErrorResult rv;
|
||||
@@ -3838,6 +3849,10 @@ nsDocShell::GoForward() {
|
||||
if (!IsNavigationAllowed()) {
|
||||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
|
||||
auto cleanupIsNavigating = MakeScopeExit([&]() { mIsNavigating = false; });
|
||||
mIsNavigating = true;
|
||||
|
||||
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||
NS_ENSURE_TRUE(rootSH, NS_ERROR_FAILURE);
|
||||
ErrorResult rv;
|
||||
@@ -3852,6 +3867,10 @@ nsDocShell::GotoIndex(int32_t aIndex) {
|
||||
if (!IsNavigationAllowed()) {
|
||||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
|
||||
auto cleanupIsNavigating = MakeScopeExit([&]() { mIsNavigating = false; });
|
||||
mIsNavigating = true;
|
||||
|
||||
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||
NS_ENSURE_TRUE(rootSH, NS_ERROR_FAILURE);
|
||||
return rootSH->LegacySHistory()->GotoIndex(aIndex);
|
||||
@@ -3867,6 +3886,10 @@ nsresult nsDocShell::LoadURI(const nsAString& aURI,
|
||||
if (!IsNavigationAllowed()) {
|
||||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
|
||||
auto cleanupIsNavigating = MakeScopeExit([&]() { mIsNavigating = false; });
|
||||
mIsNavigating = true;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIInputStream> postData(aLoadURIOptions.mPostData);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
Reference in New Issue
Block a user