зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1663757 - Part 4: Track current remote URI on CanonicalBrowsingContext, r=annyG,farre
This URI is intended to reflect the currentURI field on the content nsIDocShell, and is the value used for getters like `window.location.href`. For most documents, this generally matches the Document URI on WindowGlobalParent, it does not match in specific cases such as error pages or when performing a session restore. The field is kept up-to-date by listening to `OnLocationChange` notifications from the content process, and is ignored when the BrowsingContext is loaded in the parent process. Differential Revision: https://phabricator.services.mozilla.com/D105559
This commit is contained in:
Родитель
1dfe5d5e5b
Коммит
64fd29f182
|
@ -70,6 +70,10 @@ CanonicalBrowsingContext::CanonicalBrowsingContext(WindowContext* aParentWindow,
|
||||||
// You are only ever allowed to create CanonicalBrowsingContexts in the
|
// You are only ever allowed to create CanonicalBrowsingContexts in the
|
||||||
// parent process.
|
// parent process.
|
||||||
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
|
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
|
||||||
|
|
||||||
|
// The initial URI in a BrowsingContext is always "about:blank".
|
||||||
|
MOZ_ALWAYS_SUCCEEDS(
|
||||||
|
NS_NewURI(getter_AddRefs(mCurrentRemoteURI), "about:blank"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
@ -1656,6 +1660,22 @@ void CanonicalBrowsingContext::EndDocumentLoad(bool aForProcessSwitch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsIURI> CanonicalBrowsingContext::GetCurrentURI() const {
|
||||||
|
nsCOMPtr<nsIURI> currentURI;
|
||||||
|
if (nsIDocShell* docShell = GetDocShell()) {
|
||||||
|
MOZ_ALWAYS_SUCCEEDS(
|
||||||
|
nsDocShell::Cast(docShell)->GetCurrentURI(getter_AddRefs(currentURI)));
|
||||||
|
} else {
|
||||||
|
currentURI = mCurrentRemoteURI;
|
||||||
|
}
|
||||||
|
return currentURI.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanonicalBrowsingContext::SetCurrentRemoteURI(nsIURI* aCurrentRemoteURI) {
|
||||||
|
MOZ_ASSERT(!GetDocShell());
|
||||||
|
mCurrentRemoteURI = aCurrentRemoteURI;
|
||||||
|
}
|
||||||
|
|
||||||
void CanonicalBrowsingContext::ResetSHEntryHasUserInteractionCache() {
|
void CanonicalBrowsingContext::ResetSHEntryHasUserInteractionCache() {
|
||||||
WindowContext* topWc = GetTopWindowContext();
|
WindowContext* topWc = GetTopWindowContext();
|
||||||
if (topWc && !topWc->IsDiscarded()) {
|
if (topWc && !topWc->IsDiscarded()) {
|
||||||
|
|
|
@ -208,6 +208,10 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
||||||
void Reload(uint32_t aReloadFlags);
|
void Reload(uint32_t aReloadFlags);
|
||||||
void Stop(uint32_t aStopFlags);
|
void Stop(uint32_t aStopFlags);
|
||||||
|
|
||||||
|
// Get the publicly exposed current URI loaded in this BrowsingContext.
|
||||||
|
already_AddRefed<nsIURI> GetCurrentURI() const;
|
||||||
|
void SetCurrentRemoteURI(nsIURI* aCurrentRemoteURI);
|
||||||
|
|
||||||
BrowserParent* GetBrowserParent() const;
|
BrowserParent* GetBrowserParent() const;
|
||||||
|
|
||||||
// Internal method to change which process a BrowsingContext is being loaded
|
// Internal method to change which process a BrowsingContext is being loaded
|
||||||
|
@ -360,6 +364,10 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
||||||
// entries are added or replaced.
|
// entries are added or replaced.
|
||||||
void ResetSHEntryHasUserInteractionCache();
|
void ResetSHEntryHasUserInteractionCache();
|
||||||
|
|
||||||
|
// The current URI loaded in this BrowsingContext. This value is only set for
|
||||||
|
// BrowsingContexts loaded in content processes.
|
||||||
|
nsCOMPtr<nsIURI> mCurrentRemoteURI;
|
||||||
|
|
||||||
// The current remoteness change which is in a pending state.
|
// The current remoteness change which is in a pending state.
|
||||||
RefPtr<PendingRemotenessChange> mPendingRemotenessChange;
|
RefPtr<PendingRemotenessChange> mPendingRemotenessChange;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
interface URI;
|
||||||
interface nsIDocShell;
|
interface nsIDocShell;
|
||||||
interface nsISecureBrowserUI;
|
interface nsISecureBrowserUI;
|
||||||
interface nsIWebProgress;
|
interface nsIWebProgress;
|
||||||
|
@ -265,6 +266,10 @@ interface CanonicalBrowsingContext : BrowsingContext {
|
||||||
readonly attribute MediaController? mediaController;
|
readonly attribute MediaController? mediaController;
|
||||||
|
|
||||||
void resetScalingZoom();
|
void resetScalingZoom();
|
||||||
|
|
||||||
|
// The current URI loaded in this BrowsingContext according to nsDocShell.
|
||||||
|
// This may not match the current window global's document URI in some cases.
|
||||||
|
readonly attribute URI? currentURI;
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=Window, ChromeOnly]
|
[Exposed=Window, ChromeOnly]
|
||||||
|
|
|
@ -2686,6 +2686,8 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnLocationChange(
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
browsingContext->SetCurrentRemoteURI(aLocation);
|
||||||
|
|
||||||
nsCOMPtr<nsIBrowser> browser = GetBrowser();
|
nsCOMPtr<nsIBrowser> browser = GetBrowser();
|
||||||
if (!mozilla::SessionHistoryInParent() && browser) {
|
if (!mozilla::SessionHistoryInParent() && browser) {
|
||||||
Unused << browser->UpdateWebNavigationForLocationChange(aCanGoBack,
|
Unused << browser->UpdateWebNavigationForLocationChange(aCanGoBack,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче