Bug 1724905 - Remove native only updateURLAndHistory in nsIDocShell; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D122211
This commit is contained in:
Edgar Chen
2021-08-10 22:15:09 +00:00
parent 05f3b90e29
commit b785ba18ee
3 changed files with 32 additions and 28 deletions

View File

@@ -1095,6 +1095,31 @@ class nsDocShell final : public nsDocLoader,
}
void MaybeDisconnectChildListenersOnPageHide();
/**
* Helper for addState and document.open that does just the
* history-manipulation guts.
*
* Arguments the spec defines:
*
* @param aDocument the document we're manipulating. This will get the new
* URI.
* @param aNewURI the new URI.
* @param aData The serialized state data. May be null.
* @param aTitle The new title. May be empty.
* @param aReplace whether this should replace the exising SHEntry.
*
* Arguments we need internally because deriving them from the
* others is a bit complicated:
*
* @param aCurrentURI the current URI we're working with. Might be null.
* @param aEqualURIs whether the two URIs involved are equal.
*/
nsresult UpdateURLAndHistory(mozilla::dom::Document* aDocument,
nsIURI* aNewURI,
nsIStructuredCloneContainer* aData,
const nsAString& aTitle, bool aReplace,
nsIURI* aCurrentURI, bool aEqualURIs);
private: // data members
nsString mTitle;
nsCString mOriginalUriString;
@@ -1308,4 +1333,8 @@ class nsDocShell final : public nsDocLoader,
bool mForcedAutodetection : 1;
};
inline nsISupports* ToSupports(nsDocShell* aDocShell) {
return static_cast<nsIDocumentLoader*>(aDocShell);
}
#endif /* nsDocShell_h__ */

View File

@@ -96,30 +96,6 @@ interface nsIDocShell : nsIDocShellTreeItem
void addState(in jsval aData, in AString aTitle,
in AString aURL, in boolean aReplace);
/**
* Helper for addState and document.open that does just the
* history-manipulation guts.
*
* Arguments the spec defines:
*
* @param aDocument the document we're manipulating. This will get the new URI.
* @param aNewURI the new URI.
* @param aData The serialized state data. May be null.
* @param aTitle The new title. May be empty.
* @param aReplace whether this should replace the exising SHEntry.
*
* Arguments we need internally because deriving them from the
* others is a bit complicated:
*
* @param aCurrentURI the current URI we're working with. Might be null.
* @param aEqualURIs whether the two URIs involved are equal.
*/
[nostdcall]
void updateURLAndHistory(in Document aDocument, in nsIURI aNewURI,
in nsIStructuredCloneContainer aData, in AString aTitle,
in boolean aReplace, in nsIURI aCurrentURI,
in boolean aEqualURIs);
/**
* Reset state to a new content model within the current document and the document
* viewer. Called by the document before initiating an out of band document.write().

View File

@@ -9411,7 +9411,7 @@ Document* Document::Open(const Optional<nsAString>& /* unused */,
return this;
}
nsCOMPtr<nsIDocShell> shell(mDocumentContainer);
RefPtr<nsDocShell> shell(mDocumentContainer);
if (shell) {
bool inUnload;
shell->GetIsInUnload(&inUnload);
@@ -9441,8 +9441,7 @@ Document* Document::Open(const Optional<nsAString>& /* unused */,
// navigation.
if (shell && IsCurrentActiveDocument() &&
shell->GetIsAttemptingToNavigate()) {
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(shell));
webnav->Stop(nsIWebNavigation::STOP_NETWORK);
shell->Stop(nsIWebNavigation::STOP_NETWORK);
// The Stop call may have cancelled the onload blocker request or
// prevented it from getting added, so we need to make sure it gets added
@@ -9575,7 +9574,7 @@ Document* Document::Open(const Optional<nsAString>& /* unused */,
mParserAborted = false;
RefPtr<nsHtml5Parser> parser = nsHtml5Module::NewHtml5Parser();
mParser = parser;
parser->Initialize(this, GetDocumentURI(), shell, nullptr);
parser->Initialize(this, GetDocumentURI(), ToSupports(shell), nullptr);
nsresult rv = parser->StartExecutor();
if (NS_WARN_IF(NS_FAILED(rv))) {
aError.Throw(rv);