mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1628961
- Replace MOZ_MUST_USE with [[nodiscard]] in docshell and uriloader. r=smaug
Also move MOZ_MUST_USE before function declarations' specifiers and return type. While clang and gcc's __attribute__((warn_unused_result)) can appear before, between, or after function specifiers and return types, the [[nodiscard]] attribute must precede the function specifiers. I also needed to wrap the nsDocLoader::RemoveChildLoader() function declaration with // clang-format off and // clang-format on. clang-format insists on indenting the function declaration because it is confused by the NS_DECL_ macros without trailing semicolons before the [[nodiscard]] attribute. Differential Revision: https://phabricator.services.mozilla.com/D70478 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
df4d1be06b
commit
72e3388f74
@ -980,7 +980,7 @@ class nsDocShell final : public nsDocLoader,
|
||||
* passing the return value of MaybeInitTiming(): if it's possible to reset
|
||||
* the Timing, this method will do it.
|
||||
*/
|
||||
MOZ_MUST_USE bool MaybeInitTiming();
|
||||
[[nodiscard]] bool MaybeInitTiming();
|
||||
void MaybeResetInitTiming(bool aReset);
|
||||
|
||||
// Convenience method for getting our parent docshell. Can return null
|
||||
|
@ -3,9 +3,6 @@
|
||||
* 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/. */
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
#ifndef nsDocLoader_h__
|
||||
#define nsDocLoader_h__
|
||||
|
||||
@ -63,7 +60,7 @@ class nsDocLoader : public nsIDocumentLoader,
|
||||
|
||||
nsDocLoader();
|
||||
|
||||
virtual MOZ_MUST_USE nsresult Init();
|
||||
[[nodiscard]] virtual nsresult Init();
|
||||
|
||||
static already_AddRefed<nsDocLoader> GetAsDocLoader(nsISupports* aSupports);
|
||||
// Needed to deal with ambiguous inheritance from nsISupports...
|
||||
@ -72,8 +69,8 @@ class nsDocLoader : public nsIDocumentLoader,
|
||||
}
|
||||
|
||||
// Add aDocLoader as a child to the docloader service.
|
||||
static MOZ_MUST_USE nsresult
|
||||
AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader);
|
||||
[[nodiscard]] static nsresult AddDocLoaderAsChildOfRoot(
|
||||
nsDocLoader* aDocLoader);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDocLoader, nsIDocumentLoader)
|
||||
@ -89,16 +86,20 @@ class nsDocLoader : public nsIDocumentLoader,
|
||||
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
// Turn off clang-format to work around [[nodiscard]] bug 1629756.
|
||||
// clang-format off
|
||||
NS_DECL_NSISUPPORTSPRIORITY
|
||||
|
||||
// Implementation specific methods...
|
||||
|
||||
// Remove aChild from our childlist. This nulls out the child's mParent
|
||||
// pointer.
|
||||
MOZ_MUST_USE nsresult RemoveChildLoader(nsDocLoader* aChild);
|
||||
[[nodiscard]] nsresult RemoveChildLoader(nsDocLoader* aChild);
|
||||
// clang-format on
|
||||
|
||||
// Add aChild to our child list. This will set aChild's mParent pointer to
|
||||
// |this|.
|
||||
MOZ_MUST_USE nsresult AddChildLoader(nsDocLoader* aChild);
|
||||
[[nodiscard]] nsresult AddChildLoader(nsDocLoader* aChild);
|
||||
nsDocLoader* GetParent() const { return mParent; }
|
||||
|
||||
struct nsListenerInfo {
|
||||
@ -160,7 +161,7 @@ class nsDocLoader : public nsIDocumentLoader,
|
||||
protected:
|
||||
virtual ~nsDocLoader();
|
||||
|
||||
virtual MOZ_MUST_USE nsresult SetDocLoaderParent(nsDocLoader* aLoader);
|
||||
[[nodiscard]] virtual nsresult SetDocLoaderParent(nsDocLoader* aLoader);
|
||||
|
||||
bool IsBusy();
|
||||
|
||||
@ -204,8 +205,9 @@ class nsDocLoader : public nsIDocumentLoader,
|
||||
void FireOnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
|
||||
nsIURI* aUri, uint32_t aFlags);
|
||||
|
||||
MOZ_MUST_USE bool RefreshAttempted(nsIWebProgress* aWebProgress, nsIURI* aURI,
|
||||
int32_t aDelay, bool aSameURI);
|
||||
[[nodiscard]] bool RefreshAttempted(nsIWebProgress* aWebProgress,
|
||||
nsIURI* aURI, int32_t aDelay,
|
||||
bool aSameURI);
|
||||
|
||||
// this function is overridden by the docshell, it is provided so that we
|
||||
// can pass more information about redirect state (the normal OnStateChange
|
||||
@ -227,7 +229,7 @@ class nsDocLoader : public nsIDocumentLoader,
|
||||
|
||||
// Inform a parent docloader that aChild is about to call its onload
|
||||
// handler.
|
||||
MOZ_MUST_USE bool ChildEnteringOnload(nsIDocumentLoader* aChild) {
|
||||
[[nodiscard]] bool ChildEnteringOnload(nsIDocumentLoader* aChild) {
|
||||
// It's ok if we're already in the list -- we'll just be in there twice
|
||||
// and then the RemoveObject calls from ChildDoneWithOnload will remove
|
||||
// us.
|
||||
|
@ -37,10 +37,10 @@ class nsURILoader final : public nsIURILoader {
|
||||
* Equivalent to nsIURILoader::openChannel, but allows specifying whether the
|
||||
* channel is opened already.
|
||||
*/
|
||||
MOZ_MUST_USE nsresult OpenChannel(nsIChannel* channel, uint32_t aFlags,
|
||||
nsIInterfaceRequestor* aWindowContext,
|
||||
bool aChannelOpen,
|
||||
nsIStreamListener** aListener);
|
||||
[[nodiscard]] nsresult OpenChannel(nsIChannel* channel, uint32_t aFlags,
|
||||
nsIInterfaceRequestor* aWindowContext,
|
||||
bool aChannelOpen,
|
||||
nsIStreamListener** aListener);
|
||||
|
||||
/**
|
||||
* we shouldn't need to have an owning ref count on registered
|
||||
|
@ -26,7 +26,7 @@ class ContentHandlerService : public nsIHandlerService {
|
||||
NS_DECL_NSIHANDLERSERVICE
|
||||
|
||||
ContentHandlerService();
|
||||
MOZ_MUST_USE nsresult Init();
|
||||
[[nodiscard]] nsresult Init();
|
||||
static void nsIHandlerInfoToHandlerInfo(nsIHandlerInfo* aInfo,
|
||||
HandlerInfo* aHandlerInfo);
|
||||
|
||||
|
@ -35,8 +35,8 @@ class ExternalHelperAppChild : public PExternalHelperAppChild,
|
||||
|
||||
private:
|
||||
virtual ~ExternalHelperAppChild();
|
||||
MOZ_MUST_USE nsresult DivertToParent(nsIDivertableChannel* divertable,
|
||||
nsIRequest* request);
|
||||
[[nodiscard]] nsresult DivertToParent(nsIDivertableChannel* divertable,
|
||||
nsIRequest* request);
|
||||
|
||||
RefPtr<nsExternalAppHandler> mHandler;
|
||||
nsresult mStatus;
|
||||
|
@ -12,14 +12,14 @@
|
||||
|
||||
class nsMIMEInfoAndroid final : public nsIMIMEInfo {
|
||||
public:
|
||||
static MOZ_MUST_USE bool GetMimeInfoForMimeType(
|
||||
[[nodiscard]] static bool GetMimeInfoForMimeType(
|
||||
const nsACString& aMimeType, nsMIMEInfoAndroid** aMimeInfo);
|
||||
static MOZ_MUST_USE bool GetMimeInfoForFileExt(const nsACString& aFileExt,
|
||||
nsMIMEInfoAndroid** aMimeInfo);
|
||||
[[nodiscard]] static bool GetMimeInfoForFileExt(
|
||||
const nsACString& aFileExt, nsMIMEInfoAndroid** aMimeInfo);
|
||||
|
||||
static MOZ_MUST_USE nsresult GetMimeInfoForURL(const nsACString& aURL,
|
||||
bool* found,
|
||||
nsIHandlerInfo** info);
|
||||
[[nodiscard]] static nsresult GetMimeInfoForURL(const nsACString& aURL,
|
||||
bool* found,
|
||||
nsIHandlerInfo** info);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMIMEINFO
|
||||
@ -35,8 +35,8 @@ class nsMIMEInfoAndroid final : public nsIMIMEInfo {
|
||||
*/
|
||||
void AddUniqueExtension(const nsACString& aExtension);
|
||||
|
||||
virtual MOZ_MUST_USE nsresult LaunchDefaultWithFile(nsIFile* aFile);
|
||||
virtual MOZ_MUST_USE nsresult LoadUriInternal(nsIURI* aURI);
|
||||
[[nodiscard]] virtual nsresult LaunchDefaultWithFile(nsIFile* aFile);
|
||||
[[nodiscard]] virtual nsresult LoadUriInternal(nsIURI* aURI);
|
||||
nsCOMPtr<nsIMutableArray> mHandlerApps;
|
||||
nsCString mType;
|
||||
nsTArray<nsCString> mExtensions;
|
||||
|
@ -18,8 +18,8 @@ class nsOSHelperAppService : public nsExternalHelperAppService {
|
||||
const nsACString& aFileExt, bool* aFound,
|
||||
nsIMIMEInfo** aMIMEInfo) override;
|
||||
|
||||
MOZ_MUST_USE nsresult OSProtocolHandlerExists(const char* aScheme,
|
||||
bool* aExists) override;
|
||||
[[nodiscard]] nsresult OSProtocolHandlerExists(const char* aScheme,
|
||||
bool* aExists) override;
|
||||
|
||||
NS_IMETHOD GetProtocolHandlerInfoFromOS(const nsACString& aScheme,
|
||||
bool* found,
|
||||
|
@ -73,7 +73,7 @@ class nsDecodeAppleFile : public nsIOutputStream {
|
||||
nsDecodeAppleFile();
|
||||
virtual ~nsDecodeAppleFile();
|
||||
|
||||
MOZ_MUST_USE nsresult Initialize(nsIOutputStream* output, nsIFile* file);
|
||||
[[nodiscard]] nsresult Initialize(nsIOutputStream* output, nsIFile* file);
|
||||
|
||||
private:
|
||||
#define MAX_BUFFERSIZE 1024
|
||||
|
@ -19,9 +19,10 @@ class nsMIMEInfoMac : public nsMIMEInfoImpl {
|
||||
NS_IMETHOD LaunchWithFile(nsIFile* aFile) override;
|
||||
|
||||
protected:
|
||||
virtual MOZ_MUST_USE nsresult LoadUriInternal(nsIURI* aURI) override;
|
||||
[[nodiscard]] virtual nsresult LoadUriInternal(nsIURI* aURI) override;
|
||||
#ifdef DEBUG
|
||||
virtual MOZ_MUST_USE nsresult LaunchDefaultWithFile(nsIFile* aFile) override {
|
||||
[[nodiscard]] virtual nsresult LaunchDefaultWithFile(
|
||||
nsIFile* aFile) override {
|
||||
MOZ_ASSERT_UNREACHABLE("do not call this method, use LaunchWithFile");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ class nsOSHelperAppService : public nsExternalHelperAppService {
|
||||
// spec, a unix path or a windows path depending on the
|
||||
// platform
|
||||
// aFile --> an nsIFile representation of that platform application path.
|
||||
MOZ_MUST_USE nsresult GetFileTokenForPath(const char16_t* platformAppPath,
|
||||
nsIFile** aFile) override;
|
||||
[[nodiscard]] nsresult GetFileTokenForPath(const char16_t* platformAppPath,
|
||||
nsIFile** aFile) override;
|
||||
|
||||
MOZ_MUST_USE nsresult OSProtocolHandlerExists(const char* aScheme,
|
||||
bool* aHandlerExists) override;
|
||||
[[nodiscard]] nsresult OSProtocolHandlerExists(const char* aScheme,
|
||||
bool* aHandlerExists) override;
|
||||
};
|
||||
|
||||
#endif // nsOSHelperAppService_h__
|
||||
|
@ -61,7 +61,7 @@ class nsExternalHelperAppService : public nsIExternalHelperAppService,
|
||||
* Initializes internal state. Will be called automatically when
|
||||
* this service is first instantiated.
|
||||
*/
|
||||
MOZ_MUST_USE nsresult Init();
|
||||
[[nodiscard]] nsresult Init();
|
||||
|
||||
/**
|
||||
* nsIExternalProtocolService methods that we provide in this class. Other
|
||||
|
@ -27,17 +27,18 @@ class nsChildProcessMIMEInfo : public nsMIMEInfoImpl {
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual MOZ_MUST_USE nsresult LoadUriInternal(nsIURI* aURI) override {
|
||||
[[nodiscard]] virtual nsresult LoadUriInternal(nsIURI* aURI) override {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual MOZ_MUST_USE nsresult LaunchDefaultWithFile(nsIFile* aFile) override {
|
||||
[[nodiscard]] virtual nsresult LaunchDefaultWithFile(
|
||||
nsIFile* aFile) override {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
#endif
|
||||
static MOZ_MUST_USE nsresult OpenApplicationWithURI(nsIFile* aApplication,
|
||||
const nsCString& aURI) {
|
||||
[[nodiscard]] static nsresult OpenApplicationWithURI(nsIFile* aApplication,
|
||||
const nsCString& aURI) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user