summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-11-03 00:17:31 +0100
committerMoonchild <moonchild@palemoon.org>2023-11-08 13:44:49 +0100
commitcd8c5dae0cb5c23699171cf787cc70d720eec14c (patch)
treec08634f16ab478721562beb2e8b783e1a8d24215
parent7f99af410107ac25fd78c223dd2cbe5995f29656 (diff)
downloaduxp-cd8c5dae0cb5c23699171cf787cc70d720eec14c.tar.gz
Issue #2342: Use [[nodiscard]] in /dom
-rw-r--r--dom/base/FragmentOrElement.h3
-rw-r--r--dom/base/nsContentAreaDragDrop.cpp2
-rw-r--r--dom/base/nsContentUtils.h39
-rw-r--r--dom/base/nsGenericDOMDataNode.h5
-rw-r--r--dom/base/nsHTMLContentSerializer.h22
-rw-r--r--dom/base/nsIContent.h3
-rw-r--r--dom/base/nsIDocument.h4
-rw-r--r--dom/base/nsINode.h2
-rw-r--r--dom/base/nsJSUtils.h8
-rw-r--r--dom/base/nsObjectLoadingContent.h2
-rw-r--r--dom/base/nsTextFragment.h4
-rw-r--r--dom/base/nsXHTMLContentSerializer.h8
-rw-r--r--dom/base/nsXMLContentSerializer.h43
-rw-r--r--dom/bindings/ToJSValue.h46
-rw-r--r--dom/html/nsTextEditorState.h2
-rw-r--r--dom/ipc/nsIContentParent.h4
-rw-r--r--dom/media/webaudio/AlignedTArray.h4
-rw-r--r--dom/script/ScriptLoader.h4
-rw-r--r--dom/script/ScriptSettings.h20
-rw-r--r--dom/xhr/XMLHttpRequestString.h8
-rw-r--r--dom/xslt/xslt/txExecutionState.h2
21 files changed, 113 insertions, 122 deletions
diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h
index 2f65fe5174..331a526e9a 100644
--- a/dom/base/FragmentOrElement.h
+++ b/dom/base/FragmentOrElement.h
@@ -147,8 +147,7 @@ public:
virtual bool TextIsOnlyWhitespace() override;
virtual bool HasTextForTranslation() override;
virtual void AppendTextTo(nsAString& aResult) override;
- MOZ_MUST_USE
- virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) override;
+ [[nodiscard]] virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) override;
virtual nsIContent *GetBindingParent() const override;
virtual nsXBLBinding *GetXBLBinding() const override;
virtual void SetXBLBinding(nsXBLBinding* aBinding,
diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp
index 1734ab378d..49aeb2a774 100644
--- a/dom/base/nsContentAreaDragDrop.cpp
+++ b/dom/base/nsContentAreaDragDrop.cpp
@@ -84,7 +84,7 @@ private:
nsIContent **outImageOrLinkNode,
bool* outDragSelectedText);
static already_AddRefed<nsIContent> FindParentLinkNode(nsIContent* inNode);
- static MOZ_MUST_USE nsresult
+ static [[nodiscard]] nsresult
GetAnchorURL(nsIContent* inNode, nsAString& outURL);
static void GetNodeString(nsIContent* inNode, nsAString & outNodeString);
static void CreateLinkText(const nsAString& inURL, const nsAString & inText,
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
index 6e9f23054a..eac80efc6b 100644
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1508,9 +1508,10 @@ public:
* @param aResult the result. Out param.
* @return false on out of memory errors, true otherwise.
*/
- MOZ_MUST_USE
- static bool GetNodeTextContent(nsINode* aNode, bool aDeep,
- nsAString& aResult, const mozilla::fallible_t&);
+ [[nodiscard]] static bool GetNodeTextContent(nsINode* aNode,
+ bool aDeep,
+ nsAString& aResult,
+ const mozilla::fallible_t&);
static void GetNodeTextContent(nsINode* aNode, bool aDeep,
nsAString& aResult);
@@ -1869,28 +1870,29 @@ public:
*/
static bool CanAccessNativeAnon();
- MOZ_MUST_USE
- static nsresult WrapNative(JSContext *cx, nsISupports *native,
- const nsIID* aIID, JS::MutableHandle<JS::Value> vp,
- bool aAllowWrapping = true)
+ [[nodiscard]] static nsresult WrapNative(JSContext* cx,
+ nsISupports* native,
+ const nsIID* aIID,
+ JS::MutableHandle<JS::Value> vp,
+ bool aAllowWrapping = true)
{
return WrapNative(cx, native, nullptr, aIID, vp, aAllowWrapping);
}
// Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
- MOZ_MUST_USE
- static nsresult WrapNative(JSContext *cx, nsISupports *native,
- JS::MutableHandle<JS::Value> vp,
- bool aAllowWrapping = true)
+ [[nodiscard]] static nsresult WrapNative(JSContext* cx,
+ nsISupports* native,
+ JS::MutableHandle<JS::Value> vp,
+ bool aAllowWrapping = true)
{
return WrapNative(cx, native, nullptr, nullptr, vp, aAllowWrapping);
}
- MOZ_MUST_USE
- static nsresult WrapNative(JSContext *cx, nsISupports *native,
- nsWrapperCache *cache,
- JS::MutableHandle<JS::Value> vp,
- bool aAllowWrapping = true)
+ [[nodiscard]] static nsresult WrapNative(JSContext* cx,
+ nsISupports* native,
+ nsWrapperCache* cache,
+ JS::MutableHandle<JS::Value> vp,
+ bool aAllowWrapping = true)
{
return WrapNative(cx, native, cache, nullptr, vp, aAllowWrapping);
}
@@ -1914,9 +1916,8 @@ public:
* @param aString the string to convert the newlines inside [in/out]
*/
static void PlatformToDOMLineBreaks(nsString &aString);
- MOZ_MUST_USE
- static bool PlatformToDOMLineBreaks(nsString &aString,
- const mozilla::fallible_t&);
+ [[nodiscard]] static bool PlatformToDOMLineBreaks(nsString &aString,
+ const mozilla::fallible_t&);
/**
* Populates aResultString with the contents of the string-buffer aBuf, up
diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h
index c3e8ae4740..cffed2cb9e 100644
--- a/dom/base/nsGenericDOMDataNode.h
+++ b/dom/base/nsGenericDOMDataNode.h
@@ -144,9 +144,8 @@ public:
virtual bool TextIsOnlyWhitespace() override;
virtual bool HasTextForTranslation() override;
virtual void AppendTextTo(nsAString& aResult) override;
- MOZ_MUST_USE
- virtual bool AppendTextTo(nsAString& aResult,
- const mozilla::fallible_t&) override;
+ [[nodiscard]] virtual bool AppendTextTo(nsAString& aResult,
+ const mozilla::fallible_t&) override;
virtual void SaveSubtreeState() override;
#ifdef DEBUG
diff --git a/dom/base/nsHTMLContentSerializer.h b/dom/base/nsHTMLContentSerializer.h
index de63f7ee54..288abd8273 100644
--- a/dom/base/nsHTMLContentSerializer.h
+++ b/dom/base/nsHTMLContentSerializer.h
@@ -37,18 +37,16 @@ class nsHTMLContentSerializer final : public nsXHTMLContentSerializer {
nsAString& aStr) override;
protected:
- MOZ_MUST_USE
- virtual bool SerializeHTMLAttributes(nsIContent* aContent,
- nsIContent *aOriginalElement,
- nsAString& aTagPrefix,
- const nsAString& aTagNamespaceURI,
- nsIAtom* aTagName,
- int32_t aNamespace,
- nsAString& aStr);
-
- MOZ_MUST_USE
- virtual bool AppendAndTranslateEntities(const nsAString& aStr,
- nsAString& aOutputStr) override;
+ [[nodiscard]] virtual bool SerializeHTMLAttributes(nsIContent* aContent,
+ nsIContent* aOriginalElement,
+ nsAString& aTagPrefix,
+ const nsAString& aTagNamespaceURI,
+ nsIAtom* aTagName,
+ int32_t aNamespace,
+ nsAString& aStr);
+
+ [[nodiscard]] virtual bool AppendAndTranslateEntities(const nsAString& aStr,
+ nsAString& aOutputStr) override;
};
diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h
index 4d7d76e251..a0d81b9ade 100644
--- a/dom/base/nsIContent.h
+++ b/dom/base/nsIContent.h
@@ -576,8 +576,7 @@ public:
* Append the text content to aResult.
* NOTE: This asserts and returns for elements
*/
- MOZ_MUST_USE
- virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) = 0;
+ [[nodiscard]] virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) = 0;
/**
* Check if this content is focusable and in the current tab order.
diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h
index 6ae4eb4f55..174bc4cdd9 100644
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -2513,8 +2513,8 @@ public:
mozilla::ErrorResult& rv);
virtual mozilla::dom::DOMImplementation*
GetImplementation(mozilla::ErrorResult& rv) = 0;
- MOZ_MUST_USE nsresult GetURL(nsString& retval) const;
- MOZ_MUST_USE nsresult GetDocumentURI(nsString& retval) const;
+ [[nodiscard]] nsresult GetURL(nsString& retval) const;
+ [[nodiscard]] nsresult GetDocumentURI(nsString& retval) const;
// Return the URI for the document.
// The returned value may differ if the document is loaded via XHR, and
// when accessed from chrome privileged script and
diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
index 5268767a3e..857eccc4ef 100644
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -1873,7 +1873,7 @@ public:
aNodeName.SetStringBuffer(nsStringBuffer::FromString(nodeName),
nodeName.Length());
}
- MOZ_MUST_USE nsresult GetBaseURI(nsAString& aBaseURI) const;
+ [[nodiscard]] nsresult GetBaseURI(nsAString& aBaseURI) const;
// Return the base URI for the document.
// The returned value may differ if the document is loaded via XHR, and
// when accessed from chrome privileged script and
diff --git a/dom/base/nsJSUtils.h b/dom/base/nsJSUtils.h
index db70cd924d..53b1330ed7 100644
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -143,7 +143,7 @@ public:
// After getting a notification that an off-thread compilation terminated,
// this function will take the result of the parser and move it to the main
// thread.
- MOZ_MUST_USE nsresult JoinCompile(void** aOffThreadToken);
+ [[nodiscard]] nsresult JoinCompile(void** aOffThreadToken);
// Compile a script contained in a SourceText.
nsresult Compile(JS::CompileOptions& aCompileOptions,
@@ -167,7 +167,7 @@ public:
JSScript* GetScript();
// Execute the compiled script and ignore the return value.
- MOZ_MUST_USE nsresult ExecScript();
+ [[nodiscard]] nsresult ExecScript();
// Execute the compiled script a get the return value.
//
@@ -180,10 +180,10 @@ public:
// compartment given as argument to the ExecutionContext constructor. If the
// caller is in a different compartment, then the out-param value should be
// wrapped by calling |JS_WrapValue|.
- MOZ_MUST_USE nsresult
+ [[nodiscard]] nsresult
ExtractReturnValue(JS::MutableHandle<JS::Value> aRetValue);
- MOZ_MUST_USE nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
+ [[nodiscard]] nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
};
static nsresult CompileModule(JSContext* aCx,
diff --git a/dom/base/nsObjectLoadingContent.h b/dom/base/nsObjectLoadingContent.h
index 24f80dd083..3ac9914ae7 100644
--- a/dom/base/nsObjectLoadingContent.h
+++ b/dom/base/nsObjectLoadingContent.h
@@ -382,7 +382,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent
void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters,
bool aIgnoreCodebase);
- MOZ_MUST_USE nsresult BuildParametersArray();
+ [[nodiscard]] nsresult BuildParametersArray();
/**
* Loads fallback content with the specified FallbackType
diff --git a/dom/base/nsTextFragment.h b/dom/base/nsTextFragment.h
index 725d9c6753..2845a14e1a 100644
--- a/dom/base/nsTextFragment.h
+++ b/dom/base/nsTextFragment.h
@@ -136,7 +136,7 @@ public:
* Append the contents of this string fragment to aString
* @return false if an out of memory condition is detected, true otherwise
*/
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendTo(nsAString& aString,
const mozilla::fallible_t& aFallible) const {
if (mState.mIs2b) {
@@ -170,7 +170,7 @@ public:
* @param aLength the length of the substring
* @return false if an out of memory condition is detected, true otherwise
*/
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendTo(nsAString& aString, int32_t aOffset, int32_t aLength,
const mozilla::fallible_t& aFallible) const
{
diff --git a/dom/base/nsXHTMLContentSerializer.h b/dom/base/nsXHTMLContentSerializer.h
index d79f588b84..bc2ee87533 100644
--- a/dom/base/nsXHTMLContentSerializer.h
+++ b/dom/base/nsXHTMLContentSerializer.h
@@ -46,7 +46,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
nsAString& aStr,
nsresult& aResult) override;
- MOZ_MUST_USE
+ [[nodiscard]]
virtual bool AfterElementStart(nsIContent* aContent,
nsIContent* aOriginalElement,
nsAString& aStr) override;
@@ -70,7 +70,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
virtual void MaybeEnterInPreContent(nsIContent* aNode) override;
virtual void MaybeLeaveFromPreContent(nsIContent* aNode) override;
- MOZ_MUST_USE
+ [[nodiscard]]
virtual bool SerializeAttributes(nsIContent* aContent,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
@@ -82,13 +82,13 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
bool IsFirstChildOfOL(nsIContent* aElement);
- MOZ_MUST_USE
+ [[nodiscard]]
bool SerializeLIValueAttribute(nsIContent* aElement,
nsAString& aStr);
bool IsShorthandAttr(const nsIAtom* aAttrName,
const nsIAtom* aElementName);
- MOZ_MUST_USE
+ [[nodiscard]]
virtual bool AppendAndTranslateEntities(const nsAString& aStr,
nsAString& aOutputStr) override;
diff --git a/dom/base/nsXMLContentSerializer.h b/dom/base/nsXMLContentSerializer.h
index b48f9411d5..c9a4b4002a 100644
--- a/dom/base/nsXMLContentSerializer.h
+++ b/dom/base/nsXMLContentSerializer.h
@@ -72,23 +72,21 @@ class nsXMLContentSerializer : public nsIContentSerializer {
/**
* Appends a char16_t character and increments the column position
*/
- MOZ_MUST_USE
- bool AppendToString(const char16_t aChar,
- nsAString& aOutputStr);
+ [[nodiscard]] bool AppendToString(const char16_t aChar,
+ nsAString& aOutputStr);
/**
* Appends a nsAString string and increments the column position
*/
- MOZ_MUST_USE
- bool AppendToString(const nsAString& aStr,
- nsAString& aOutputStr);
+ [[nodiscard]] bool AppendToString(const nsAString& aStr,
+ nsAString& aOutputStr);
/**
* Appends a string by replacing all line-endings
* by mLineBreak, except in the case of raw output.
* It increments the column position.
*/
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendToStringConvertLF(const nsAString& aStr,
nsAString& aOutputStr);
@@ -96,7 +94,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* Appends a string by wrapping it when necessary.
* It updates the column position.
*/
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendToStringWrapped(const nsASingleFragmentString& aStr,
nsAString& aOutputStr);
@@ -104,12 +102,12 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* Appends a string by formating and wrapping it when necessary
* It updates the column position.
*/
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendToStringFormatedWrapped(const nsASingleFragmentString& aStr,
nsAString& aOutputStr);
// used by AppendToStringWrapped
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendWrapped_WhitespaceSequence(
nsASingleFragmentString::const_char_iterator &aPos,
const nsASingleFragmentString::const_char_iterator aEnd,
@@ -117,7 +115,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
nsAString &aOutputStr);
// used by AppendToStringFormatedWrapped
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendFormatedWrapped_WhitespaceSequence(
nsASingleFragmentString::const_char_iterator &aPos,
const nsASingleFragmentString::const_char_iterator aEnd,
@@ -126,7 +124,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
nsAString &aOutputStr);
// used by AppendToStringWrapped and AppendToStringFormatedWrapped
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendWrapped_NonWhitespaceSequence(
nsASingleFragmentString::const_char_iterator &aPos,
const nsASingleFragmentString::const_char_iterator aEnd,
@@ -139,7 +137,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* add mLineBreak to the string
* It updates the column position and other flags.
*/
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendNewLineToString(nsAString& aOutputStr);
@@ -147,7 +145,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* Appends a string by translating entities
* It doesn't increment the column position
*/
- MOZ_MUST_USE
+ [[nodiscard]]
virtual bool AppendAndTranslateEntities(const nsAString& aStr,
nsAString& aOutputStr);
@@ -197,7 +195,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
nsIContent *aOriginalElement,
const nsAString& aTagNamespaceURI);
- MOZ_MUST_USE
+ [[nodiscard]]
virtual bool SerializeAttributes(nsIContent* aContent,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
@@ -207,7 +205,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
uint32_t aSkipAttr,
bool aAddNSAttr);
- MOZ_MUST_USE
+ [[nodiscard]]
bool SerializeAttr(const nsAString& aPrefix,
const nsAString& aName,
const nsAString& aValue,
@@ -239,7 +237,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* aElement and aOriginalElement are the same as the corresponding arguments
* to AppendElementStart.
*/
- MOZ_MUST_USE
+ [[nodiscard]]
bool AppendEndOfElementStart(mozilla::dom::Element* aEleemnt,
mozilla::dom::Element* aOriginalElement,
nsAString& aStr);
@@ -249,7 +247,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* after the serialization ot the start tag.
* (called at the end of AppendElementStart)
*/
- MOZ_MUST_USE
+ [[nodiscard]]
virtual bool AfterElementStart(nsIContent* aContent,
nsIContent* aOriginalElement,
nsAString& aStr) { return true; };
@@ -299,17 +297,14 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* add intendation. Call only in the case of formating and if the current
* position is at 0. It updates the column position.
*/
- MOZ_MUST_USE
- bool AppendIndentation(nsAString& aStr);
+ [[nodiscard]] bool AppendIndentation(nsAString& aStr);
- MOZ_MUST_USE
- bool IncrIndentation(nsIAtom* aName);
+ [[nodiscard]] bool IncrIndentation(nsIAtom* aName);
void DecrIndentation(nsIAtom* aName);
// Functions to check for newlines that needs to be added between nodes in
// the root of a document. See mAddNewlineForRootNode
- MOZ_MUST_USE
- bool MaybeAddNewlineForRootNode(nsAString& aStr);
+ [[nodiscard]] bool MaybeAddNewlineForRootNode(nsAString& aStr);
void MaybeFlagNewlineForRootNode(nsINode* aNode);
// Functions to check if we enter in or leave from a preformated content
diff --git a/dom/bindings/ToJSValue.h b/dom/bindings/ToJSValue.h
index 25bd7639fe..0b643315ec 100644
--- a/dom/bindings/ToJSValue.h
+++ b/dom/bindings/ToJSValue.h
@@ -24,7 +24,7 @@ class Promise;
// JSContext.
// Accept strings.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
const nsAString& aArgument,
JS::MutableHandle<JS::Value> aValue);
@@ -35,7 +35,7 @@ ToJSValue(JSContext* aCx,
// desirable. So make this a template that only gets used if the argument type
// is actually boolean
template<typename T>
-MOZ_MUST_USE
+[[nodiscard]]
typename EnableIf<IsSame<T, bool>::value, bool>::Type
ToJSValue(JSContext* aCx,
T aArgument,
@@ -123,7 +123,7 @@ ToJSValue(JSContext* aCx,
}
// Accept CallbackObjects
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
ToJSValue(JSContext* aCx,
CallbackObject& aArgument,
JS::MutableHandle<JS::Value> aValue)
@@ -139,7 +139,7 @@ ToJSValue(JSContext* aCx,
// Accept objects that inherit from nsWrapperCache (e.g. most
// DOM objects).
template <class T>
-MOZ_MUST_USE
+[[nodiscard]]
typename EnableIf<IsBaseOf<nsWrapperCache, T>::value, bool>::Type
ToJSValue(JSContext* aCx,
T& aArgument,
@@ -155,7 +155,7 @@ ToJSValue(JSContext* aCx,
// Accept typed arrays built from appropriate nsTArray values
template<typename T>
-MOZ_MUST_USE
+[[nodiscard]]
typename EnableIf<IsBaseOf<AllTypedArraysBase, T>::value, bool>::Type
ToJSValue(JSContext* aCx,
const TypedArrayCreator<T>& aArgument,
@@ -175,7 +175,7 @@ ToJSValue(JSContext* aCx,
// Accept objects that inherit from nsISupports but not nsWrapperCache (e.g.
// DOM File).
template <class T>
-MOZ_MUST_USE
+[[nodiscard]]
typename EnableIf<!IsBaseOf<nsWrapperCache, T>::value &&
!IsBaseOf<CallbackObject, T>::value &&
IsBaseOf<nsISupports, T>::value, bool>::Type
@@ -193,7 +193,7 @@ ToJSValue(JSContext* aCx,
// Accept nsRefPtr/nsCOMPtr
template <typename T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
const nsCOMPtr<T>& aArgument,
JS::MutableHandle<JS::Value> aValue)
@@ -202,7 +202,7 @@ ToJSValue(JSContext* aCx,
}
template <typename T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
const RefPtr<T>& aArgument,
JS::MutableHandle<JS::Value> aValue)
@@ -211,7 +211,7 @@ ToJSValue(JSContext* aCx,
}
template <typename T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
const NonNull<T>& aArgument,
JS::MutableHandle<JS::Value> aValue)
@@ -221,7 +221,7 @@ ToJSValue(JSContext* aCx,
// Accept WebIDL dictionaries
template <class T>
-MOZ_MUST_USE
+[[nodiscard]]
typename EnableIf<IsBaseOf<DictionaryBase, T>::value, bool>::Type
ToJSValue(JSContext* aCx,
const T& aArgument,
@@ -231,7 +231,7 @@ ToJSValue(JSContext* aCx,
}
// Accept existing JS values (which may not be same-compartment with us
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
JS::MutableHandle<JS::Value> aValue)
{
@@ -240,7 +240,7 @@ ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
}
// Accept existing JS values on the Heap (which may not be same-compartment with us
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
ToJSValue(JSContext* aCx, const JS::Heap<JS::Value>& aArgument,
JS::MutableHandle<JS::Value> aValue)
{
@@ -249,7 +249,7 @@ ToJSValue(JSContext* aCx, const JS::Heap<JS::Value>& aArgument,
}
// Accept existing rooted JS values (which may not be same-compartment with us
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
ToJSValue(JSContext* aCx, const JS::Rooted<JS::Value>& aArgument,
JS::MutableHandle<JS::Value> aValue)
{
@@ -259,7 +259,7 @@ ToJSValue(JSContext* aCx, const JS::Rooted<JS::Value>& aArgument,
// Accept existing rooted JS objects (which may not be same-compartment with
// us).
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
ToJSValue(JSContext* aCx, const JS::Rooted<JSObject*>& aArgument,
JS::MutableHandle<JS::Value> aValue)
{
@@ -269,7 +269,7 @@ ToJSValue(JSContext* aCx, const JS::Rooted<JSObject*>& aArgument,
// Accept nsresult, for use in rejections, and create an XPCOM
// exception object representing that nsresult.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
nsresult aArgument,
JS::MutableHandle<JS::Value> aValue);
@@ -277,14 +277,14 @@ ToJSValue(JSContext* aCx,
// Accept ErrorResult, for use in rejections, and create an exception
// representing the failure. Note, the ErrorResult must indicate a failure
// with aArgument.Failure() returning true.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
ErrorResult& aArgument,
JS::MutableHandle<JS::Value> aValue);
// Accept owning WebIDL unions.
template <typename T>
-MOZ_MUST_USE
+[[nodiscard]]
typename EnableIf<IsBaseOf<AllOwningUnionBase, T>::value, bool>::Type
ToJSValue(JSContext* aCx,
const T& aArgument,
@@ -296,7 +296,7 @@ ToJSValue(JSContext* aCx,
// Accept pointers to other things we accept
template <typename T>
-MOZ_MUST_USE
+[[nodiscard]]
typename EnableIf<IsPointer<T>::value, bool>::Type
ToJSValue(JSContext* aCx,
T aArgument,
@@ -306,14 +306,14 @@ ToJSValue(JSContext* aCx,
}
// Accept Promise objects, which need special handling.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
Promise& aArgument,
JS::MutableHandle<JS::Value> aValue);
// Accept arrays of other things we accept
template <typename T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
T* aArguments,
size_t aLength,
@@ -340,7 +340,7 @@ ToJSValue(JSContext* aCx,
}
template <typename T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
const nsTArray<T>& aArgument,
JS::MutableHandle<JS::Value> aValue)
@@ -350,7 +350,7 @@ ToJSValue(JSContext* aCx,
}
template <typename T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
const FallibleTArray<T>& aArgument,
JS::MutableHandle<JS::Value> aValue)
@@ -360,7 +360,7 @@ ToJSValue(JSContext* aCx,
}
template <typename T, int N>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ToJSValue(JSContext* aCx,
const T(&aArgument)[N],
JS::MutableHandle<JS::Value> aValue)
diff --git a/dom/html/nsTextEditorState.h b/dom/html/nsTextEditorState.h
index 5abc88d44e..a5d2482387 100644
--- a/dom/html/nsTextEditorState.h
+++ b/dom/html/nsTextEditorState.h
@@ -154,7 +154,7 @@ public:
// Whether the value change should be notified to the frame/contet nor not.
eSetValue_Notify = 1 << 2
};
- MOZ_MUST_USE bool SetValue(const nsAString& aValue, uint32_t aFlags);
+ [[nodiscard]] bool SetValue(const nsAString& aValue, uint32_t aFlags);
void GetValue(nsAString& aValue, bool aIgnoreWrap) const;
bool HasNonEmptyValue();
// The following methods are for textarea element to use whether default
diff --git a/dom/ipc/nsIContentParent.h b/dom/ipc/nsIContentParent.h
index 6fae9060cb..fb9c31ff92 100644
--- a/dom/ipc/nsIContentParent.h
+++ b/dom/ipc/nsIContentParent.h
@@ -63,11 +63,11 @@ public:
virtual bool IsForApp() const = 0;
virtual bool IsForBrowser() const = 0;
- MOZ_MUST_USE virtual PBlobParent*
+ [[nodiscard]] virtual PBlobParent*
SendPBlobConstructor(PBlobParent* aActor,
const BlobConstructorParams& aParams) = 0;
- MOZ_MUST_USE virtual PBrowserParent*
+ [[nodiscard]] virtual PBrowserParent*
SendPBrowserConstructor(PBrowserParent* actor,
const TabId& aTabId,
const IPCTabContext& context,
diff --git a/dom/media/webaudio/AlignedTArray.h b/dom/media/webaudio/AlignedTArray.h
index 6d144d4e5c..5b9c880f65 100644
--- a/dom/media/webaudio/AlignedTArray.h
+++ b/dom/media/webaudio/AlignedTArray.h
@@ -36,7 +36,7 @@ public:
base_type::SetLength(newLen + sExtra);
}
- MOZ_MUST_USE
+ [[nodiscard]]
bool SetLength(size_type newLen, const mozilla::fallible_t&)
{
return base_type::SetLength(newLen + sExtra, mozilla::fallible);
@@ -89,7 +89,7 @@ public:
base_type::SetLength(newLen + sExtra);
}
- MOZ_MUST_USE
+ [[nodiscard]]
bool SetLength(size_type newLen, const mozilla::fallible_t&)
{
return base_type::SetLength(newLen + sExtra, mozilla::fallible);
diff --git a/dom/script/ScriptLoader.h b/dom/script/ScriptLoader.h
index 6cf108e331..54a28021b5 100644
--- a/dom/script/ScriptLoader.h
+++ b/dom/script/ScriptLoader.h
@@ -287,14 +287,14 @@ public:
insertBack(aElem);
}
- MOZ_MUST_USE
+ [[nodiscard]]
already_AddRefed<ScriptLoadRequest> Steal(ScriptLoadRequest* aElem)
{
aElem->removeFrom(*this);
return dont_AddRef(aElem);
}
- MOZ_MUST_USE
+ [[nodiscard]]
already_AddRefed<ScriptLoadRequest> StealFirst()
{
MOZ_ASSERT(!isEmpty());
diff --git a/dom/script/ScriptSettings.h b/dom/script/ScriptSettings.h
index f2e12f0be9..381f923e6e 100644
--- a/dom/script/ScriptSettings.h
+++ b/dom/script/ScriptSettings.h
@@ -224,11 +224,11 @@ public:
// If aGlobalObject represents a web-visible global, errors reported by this
// AutoJSAPI as it comes off the stack will fire the relevant error events and
// show up in the corresponding web console.
- MOZ_MUST_USE bool Init(nsIGlobalObject* aGlobalObject);
+ [[nodiscard]] bool Init(nsIGlobalObject* aGlobalObject);
// This is a helper that grabs the native global associated with aObject and
// invokes the above Init() with that.
- MOZ_MUST_USE bool Init(JSObject* aObject);
+ [[nodiscard]] bool Init(JSObject* aObject);
// Unsurprisingly, this uses aCx and enters the compartment of aGlobalObject.
// If aGlobalObject or its associated JS global are null then it returns
@@ -238,15 +238,15 @@ public:
// If aGlobalObject represents a web-visible global, errors reported by this
// AutoJSAPI as it comes off the stack will fire the relevant error events and
// show up in the corresponding web console.
- MOZ_MUST_USE bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx);
+ [[nodiscard]] bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx);
// Convenience functions to take an nsPIDOMWindow* or nsGlobalWindow*,
// when it is more easily available than an nsIGlobalObject.
- MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow);
- MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow, JSContext* aCx);
+ [[nodiscard]] bool Init(nsPIDOMWindowInner* aWindow);
+ [[nodiscard]] bool Init(nsPIDOMWindowInner* aWindow, JSContext* aCx);
- MOZ_MUST_USE bool Init(nsGlobalWindow* aWindow);
- MOZ_MUST_USE bool Init(nsGlobalWindow* aWindow, JSContext* aCx);
+ [[nodiscard]] bool Init(nsGlobalWindow* aWindow);
+ [[nodiscard]] bool Init(nsGlobalWindow* aWindow, JSContext* aCx);
JSContext* cx() const {
MOZ_ASSERT(mCx, "Must call Init before using an AutoJSAPI");
@@ -272,12 +272,12 @@ public:
//
// Note that this fails if and only if we OOM while wrapping the exception
// into the current compartment.
- MOZ_MUST_USE bool StealException(JS::MutableHandle<JS::Value> aVal);
+ [[nodiscard]] bool StealException(JS::MutableHandle<JS::Value> aVal);
// As for StealException(), but put the saved frames for any stack trace
// associated with the point the exception was thrown into aStack.
// aVal will be in the current compartment, but aStack might not be.
- MOZ_MUST_USE bool StealExceptionAndStack(JS::MutableHandle<JS::Value> aVal,
+ [[nodiscard]] bool StealExceptionAndStack(JS::MutableHandle<JS::Value> aVal,
JS::MutableHandle<JSObject*> aStack);
// Peek the current exception from the JS engine, without stealing it.
@@ -286,7 +286,7 @@ public:
//
// Note that this fails if and only if we OOM while wrapping the exception
// into the current compartment.
- MOZ_MUST_USE bool PeekException(JS::MutableHandle<JS::Value> aVal);
+ [[nodiscard]] bool PeekException(JS::MutableHandle<JS::Value> aVal);
void ClearException() {
MOZ_ASSERT(IsStackTop());
diff --git a/dom/xhr/XMLHttpRequestString.h b/dom/xhr/XMLHttpRequestString.h
index b02040b7ea..df2fc76668 100644
--- a/dom/xhr/XMLHttpRequestString.h
+++ b/dom/xhr/XMLHttpRequestString.h
@@ -44,7 +44,7 @@ public:
// This method should be called only when the string is really needed because
// it can cause the duplication of the strings in case the loading of the XHR
// is not completed yet.
- MOZ_MUST_USE bool GetAsString(nsAString& aString) const;
+ [[nodiscard]] bool GetAsString(nsAString& aString) const;
size_t SizeOfThis(MallocSizeOf aMallocSizeOf) const;
@@ -121,7 +121,7 @@ public:
return !mLength;
}
- MOZ_MUST_USE bool GetAsString(DOMString& aString) const;
+ [[nodiscard]] bool GetAsString(DOMString& aString) const;
private:
XMLHttpRequestStringSnapshot(const XMLHttpRequestStringSnapshot&) = delete;
@@ -193,7 +193,7 @@ public:
mData.Append(aString);
}
- MOZ_MUST_USE bool
+ [[nodiscard]] bool
GetAsString(nsAString& aString)
{
MutexAutoLock lock(mMutex);
@@ -206,7 +206,7 @@ public:
return mData.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
- MOZ_MUST_USE bool
+ [[nodiscard]] bool
GetAsString(DOMString& aString, uint32_t aLength)
{
MutexAutoLock lock(mMutex);
diff --git a/dom/xslt/xslt/txExecutionState.h b/dom/xslt/xslt/txExecutionState.h
index cd54671791..2a7a7912b0 100644
--- a/dom/xslt/xslt/txExecutionState.h
+++ b/dom/xslt/xslt/txExecutionState.h
@@ -60,7 +60,7 @@ public:
{
}
~txLoadedDocumentsHash();
- MOZ_MUST_USE nsresult init(const txXPathNode& aSource);
+ [[nodiscard]] nsresult init(const txXPathNode& aSource);
private:
friend class txExecutionState;