Bug 1581859: Part 3b - Update existing GetPropertyAsInterface callers to use typesafe do_GetProperty instead. r=mccr8,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D103211
This commit is contained in:
Kris Maglione 2021-03-23 23:57:11 +00:00
Родитель 4abddadf18
Коммит 6e2223e151
5 изменённых файлов: 27 добавлений и 39 удалений

Просмотреть файл

@ -12222,22 +12222,23 @@ nsDocShell::MakeEditable(bool aInWaitForUriLoad) {
return;
}
nsresult rv = props->GetPropertyAsInterface(u"docshell.previousURI"_ns,
NS_GET_IID(nsIURI),
reinterpret_cast<void**>(aURI));
nsresult rv;
nsCOMPtr<nsIURI> uri(do_GetProperty(props, u"docshell.previousURI"_ns, &rv));
if (NS_SUCCEEDED(rv)) {
uri.forget(aURI);
if (NS_FAILED(rv)) {
// There is no last visit for this channel, so this must be the first
// link. Link the visit to the referrer of this request, if any.
// Treat referrer as null if there is an error getting it.
(void)NS_GetReferrerFromChannel(aChannel, aURI);
} else {
rv = props->GetPropertyAsUint32(u"docshell.previousFlags"_ns,
aChannelRedirectFlags);
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rv),
"Could not fetch previous flags, URI will be treated like referrer");
} else {
// There is no last visit for this channel, so this must be the first
// link. Link the visit to the referrer of this request, if any.
// Treat referrer as null if there is an error getting it.
NS_GetReferrerFromChannel(aChannel, aURI);
}
}

Просмотреть файл

@ -2698,13 +2698,9 @@ void Document::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) {
// timeline will have the same global clock time as the old one.
mDocumentTimeline = nullptr;
nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel);
if (bag) {
nsCOMPtr<nsIURI> baseURI;
bag->GetPropertyAsInterface(u"baseURI"_ns, NS_GET_IID(nsIURI),
getter_AddRefs(baseURI));
if (baseURI) {
mDocumentBaseURI = baseURI;
if (nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel)) {
if (nsCOMPtr<nsIURI> baseURI = do_GetProperty(bag, u"baseURI"_ns)) {
mDocumentBaseURI = baseURI.forget();
mChromeXHRDocBaseURI = nullptr;
}
}

Просмотреть файл

@ -1257,21 +1257,15 @@ already_AddRefed<nsIPrincipal> nsOuterWindowProxy::GetNoPDFJSPrincipal(
return nullptr;
}
Document* doc = inner->GetExtantDoc();
if (!doc) {
return nullptr;
if (Document* doc = inner->GetExtantDoc()) {
if (nsCOMPtr<nsIPropertyBag2> propBag =
do_QueryInterface(doc->GetChannel())) {
nsCOMPtr<nsIPrincipal> principal(
do_GetProperty(propBag, u"noPDFJSPrincipal"_ns));
return principal.forget();
}
}
nsCOMPtr<nsIPropertyBag2> propBag(do_QueryInterface(doc->GetChannel()));
if (!propBag) {
return nullptr;
}
nsCOMPtr<nsIPrincipal> principal;
propBag->GetPropertyAsInterface(u"noPDFJSPrincipal"_ns,
NS_GET_IID(nsIPrincipal),
getter_AddRefs(principal));
return principal.forget();
return nullptr;
}
const nsOuterWindowProxy nsOuterWindowProxy::singleton;

Просмотреть файл

@ -1167,15 +1167,15 @@ nsresult NS_GetURLSpecFromDir(nsIFile* file, nsACString& url,
void NS_GetReferrerFromChannel(nsIChannel* channel, nsIURI** referrer) {
*referrer = nullptr;
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(channel));
if (props) {
if (nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(channel)) {
// We have to check for a property on a property bag because the
// referrer may be empty for security reasons (for example, when loading
// an http page with an https referrer).
nsresult rv = props->GetPropertyAsInterface(
u"docshell.internalReferrer"_ns, NS_GET_IID(nsIURI),
reinterpret_cast<void**>(referrer));
nsresult rv;
nsCOMPtr<nsIURI> uri(
do_GetProperty(props, u"docshell.internalReferrer"_ns, &rv));
if (NS_SUCCEEDED(rv)) {
uri.forget(referrer);
return;
}
}

Просмотреть файл

@ -145,10 +145,7 @@ already_AddRefed<ChannelWrapper> ChannelWrapper::Get(const GlobalObject& global,
nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(channel);
if (props) {
Unused << props->GetPropertyAsInterface(CHANNELWRAPPER_PROP_KEY,
NS_GET_IID(ChannelWrapper),
getter_AddRefs(wrapper));
wrapper = do_GetProperty(props, CHANNELWRAPPER_PROP_KEY);
if (wrapper) {
// Assume cached attributes may have changed at this point.
wrapper->ClearCachedAttributes();