Bug 1635094 - Cleanup the ReferrerInfo code. r=ckerschb
The cast in InitWithNode is wrong. AsElement() asserts instead of checking the flag, so we always pass an element (and if we didn't we'd have type confusion problems). I audited the callers and we're fine. Anyhow, always require an element, and add two convenience constructors for C++ code. Differential Revision: https://phabricator.services.mozilla.com/D73636
This commit is contained in:
@@ -11996,7 +11996,6 @@ nsresult nsDocShell::OnLinkClickSync(
|
||||
// referrer, since the current URI in this docshell may be a
|
||||
// new document that we're in the process of loading.
|
||||
RefPtr<Document> referrerDoc = aContent->OwnerDoc();
|
||||
NS_ENSURE_TRUE(referrerDoc, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Now check that the referrerDoc's inner window is the current inner
|
||||
// window for mScriptGlobal. If it's not, then we don't want to
|
||||
@@ -12029,12 +12028,9 @@ nsresult nsDocShell::OnLinkClickSync(
|
||||
GetIsExecutingOnLoadHandler(&inOnLoadHandler);
|
||||
uint32_t loadType = inOnLoadHandler ? LOAD_NORMAL_REPLACE : LOAD_LINK;
|
||||
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo();
|
||||
if (isElementAnchorOrArea) {
|
||||
referrerInfo->InitWithNode(aContent);
|
||||
} else {
|
||||
referrerInfo->InitWithDocument(referrerDoc);
|
||||
}
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
isElementAnchorOrArea ? new ReferrerInfo(*aContent->AsElement())
|
||||
: new ReferrerInfo(*referrerDoc);
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(aURI);
|
||||
loadState->SetReferrerInfo(referrerInfo);
|
||||
|
||||
Reference in New Issue
Block a user