mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1800553 - part 2: Change HTMLAnchorElement::GetText
to a const
method r=smaug
This needs to change `nsContentUtils` methods because of used by the method. Then, we can make some there callers are also `const` methods. Depends on D162065 Differential Revision: https://phabricator.services.mozilla.com/D162066
This commit is contained in:
parent
bb73eac1f4
commit
ad4f56856b
@ -5630,7 +5630,8 @@ nsresult nsContentUtils::SetNodeTextContent(nsIContent* aContent,
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
static bool AppendNodeTextContentsRecurse(nsINode* aNode, nsAString& aResult,
|
||||
static bool AppendNodeTextContentsRecurse(const nsINode* aNode,
|
||||
nsAString& aResult,
|
||||
const fallible_t& aFallible) {
|
||||
for (nsIContent* child = aNode->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
@ -5651,10 +5652,10 @@ static bool AppendNodeTextContentsRecurse(nsINode* aNode, nsAString& aResult,
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsContentUtils::AppendNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
bool nsContentUtils::AppendNodeTextContent(const nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult,
|
||||
const fallible_t& aFallible) {
|
||||
if (Text* text = aNode->GetAsText()) {
|
||||
if (const Text* text = aNode->GetAsText()) {
|
||||
return text->AppendTextTo(aResult, aFallible);
|
||||
}
|
||||
if (aDeep) {
|
||||
@ -7522,14 +7523,14 @@ mozilla::LogModule* nsContentUtils::ResistFingerprintingLog() {
|
||||
}
|
||||
mozilla::LogModule* nsContentUtils::DOMDumpLog() { return sDOMDumpLog; }
|
||||
|
||||
bool nsContentUtils::GetNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
bool nsContentUtils::GetNodeTextContent(const nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult,
|
||||
const fallible_t& aFallible) {
|
||||
aResult.Truncate();
|
||||
return AppendNodeTextContent(aNode, aDeep, aResult, aFallible);
|
||||
}
|
||||
|
||||
void nsContentUtils::GetNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
void nsContentUtils::GetNodeTextContent(const nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult) {
|
||||
if (!GetNodeTextContent(aNode, aDeep, aResult, fallible)) {
|
||||
NS_ABORT_OOM(0); // Unfortunately we don't know the allocation size
|
||||
|
@ -1945,17 +1945,17 @@ class nsContentUtils {
|
||||
* @param aResult the result. Out param.
|
||||
* @return false on out of memory errors, true otherwise.
|
||||
*/
|
||||
[[nodiscard]] static bool GetNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
[[nodiscard]] static bool GetNodeTextContent(const nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult,
|
||||
const mozilla::fallible_t&);
|
||||
|
||||
static void GetNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
static void GetNodeTextContent(const nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult);
|
||||
|
||||
/**
|
||||
* Same as GetNodeTextContents but appends the result rather than sets it.
|
||||
*/
|
||||
static bool AppendNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
static bool AppendNodeTextContent(const nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult,
|
||||
const mozilla::fallible_t&);
|
||||
|
||||
|
@ -171,7 +171,8 @@ nsDOMTokenList* HTMLAnchorElement::RelList() {
|
||||
return mRelList;
|
||||
}
|
||||
|
||||
void HTMLAnchorElement::GetText(nsAString& aText, mozilla::ErrorResult& aRv) {
|
||||
void HTMLAnchorElement::GetText(nsAString& aText,
|
||||
mozilla::ErrorResult& aRv) const {
|
||||
if (NS_WARN_IF(
|
||||
!nsContentUtils::GetNodeTextContent(this, true, aText, fallible))) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -122,8 +122,8 @@ class HTMLAnchorElement final : public nsGenericHTMLElement,
|
||||
void SetType(const nsAString& aValue, mozilla::ErrorResult& rv) {
|
||||
SetHTMLAttr(nsGkAtoms::type, aValue, rv);
|
||||
}
|
||||
void GetText(nsAString& aValue, mozilla::ErrorResult& rv);
|
||||
void SetText(const nsAString& aValue, mozilla::ErrorResult& rv);
|
||||
void GetText(nsAString& aText, mozilla::ErrorResult& aRv) const;
|
||||
void SetText(const nsAString& aText, mozilla::ErrorResult& aRv);
|
||||
|
||||
// Link::GetOrigin is OK for us
|
||||
|
||||
|
@ -94,7 +94,7 @@ nsresult HTMLOutputElement::BindToTree(BindContext& aContext,
|
||||
return rv;
|
||||
}
|
||||
|
||||
void HTMLOutputElement::GetValue(nsAString& aValue) {
|
||||
void HTMLOutputElement::GetValue(nsAString& aValue) const {
|
||||
nsContentUtils::GetNodeTextContent(this, true, aValue);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class HTMLOutputElement final : public nsGenericHTMLFormControlElement,
|
||||
|
||||
void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aRv);
|
||||
|
||||
void GetValue(nsAString& aValue);
|
||||
void GetValue(nsAString& aValue) const;
|
||||
void SetValue(const nsAString& aValue, ErrorResult& aRv);
|
||||
|
||||
// nsIConstraintValidation::WillValidate is fine.
|
||||
|
@ -129,7 +129,7 @@ void HTMLScriptElement::SetInnerHTML(const nsAString& aInnerHTML,
|
||||
aError = nsContentUtils::SetNodeTextContent(this, aInnerHTML, true);
|
||||
}
|
||||
|
||||
void HTMLScriptElement::GetText(nsAString& aValue, ErrorResult& aRv) {
|
||||
void HTMLScriptElement::GetText(nsAString& aValue, ErrorResult& aRv) const {
|
||||
if (!nsContentUtils::GetNodeTextContent(this, false, aValue, fallible)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
@ -157,7 +157,7 @@ bool HTMLScriptElement::GetScriptType(nsAString& aType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTMLScriptElement::GetScriptText(nsAString& text) {
|
||||
void HTMLScriptElement::GetScriptText(nsAString& text) const {
|
||||
GetText(text, IgnoreErrors());
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
|
||||
// nsIScriptElement
|
||||
virtual bool GetScriptType(nsAString& type) override;
|
||||
virtual void GetScriptText(nsAString& text) override;
|
||||
virtual void GetScriptText(nsAString& text) const override;
|
||||
virtual void GetScriptCharset(nsAString& charset) override;
|
||||
virtual void FreezeExecutionAttrs(Document* aOwnerDoc) override;
|
||||
virtual CORSMode GetCORSMode() const override;
|
||||
@ -54,7 +54,7 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
bool aNotify) override;
|
||||
|
||||
// WebIDL
|
||||
void GetText(nsAString& aValue, ErrorResult& aRv);
|
||||
void GetText(nsAString& aValue, ErrorResult& aRv) const;
|
||||
|
||||
void SetText(const nsAString& aValue, ErrorResult& aRv);
|
||||
|
||||
|
@ -343,7 +343,7 @@ void HTMLTextAreaElement::SetLastValueChangeWasInteractive(
|
||||
}
|
||||
|
||||
void HTMLTextAreaElement::GetDefaultValue(nsAString& aDefaultValue,
|
||||
ErrorResult& aError) {
|
||||
ErrorResult& aError) const {
|
||||
if (!nsContentUtils::GetNodeTextContent(this, false, aDefaultValue,
|
||||
fallible)) {
|
||||
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -242,7 +242,7 @@ class HTMLTextAreaElement final : public TextControlElement,
|
||||
SetHTMLAttr(nsGkAtoms::wrap, aWrap, aError);
|
||||
}
|
||||
void GetType(nsAString& aType);
|
||||
void GetDefaultValue(nsAString& aDefaultValue, ErrorResult& aError);
|
||||
void GetDefaultValue(nsAString& aDefaultValue, ErrorResult& aError) const;
|
||||
void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError);
|
||||
void GetValue(nsAString& aValue);
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ JSObject* HTMLTitleElement::WrapNode(JSContext* cx,
|
||||
return HTMLTitleElement_Binding::Wrap(cx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void HTMLTitleElement::GetText(DOMString& aText, ErrorResult& aError) {
|
||||
void HTMLTitleElement::GetText(DOMString& aText, ErrorResult& aError) const {
|
||||
if (!nsContentUtils::GetNodeTextContent(this, false, aText, fallible)) {
|
||||
aError = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class HTMLTitleElement final : public nsGenericHTMLElement,
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// HTMLTitleElement
|
||||
void GetText(DOMString& aText, ErrorResult& aError);
|
||||
void GetText(DOMString& aText, ErrorResult& aError) const;
|
||||
void SetText(const nsAString& aText, ErrorResult& aError);
|
||||
|
||||
// nsIMutationObserver
|
||||
|
@ -91,7 +91,7 @@ class nsIScriptElement : public nsIScriptLoaderObserver {
|
||||
/**
|
||||
* Script source text for inline script elements.
|
||||
*/
|
||||
virtual void GetScriptText(nsAString& text) = 0;
|
||||
virtual void GetScriptText(nsAString& text) const = 0;
|
||||
|
||||
virtual void GetScriptCharset(nsAString& charset) = 0;
|
||||
|
||||
|
@ -131,7 +131,7 @@ void SVGAElement::SetType(const nsAString& aType, mozilla::ErrorResult& rv) {
|
||||
SetAttr(nsGkAtoms::type, aType, rv);
|
||||
}
|
||||
|
||||
void SVGAElement::GetText(nsAString& aText, mozilla::ErrorResult& rv) {
|
||||
void SVGAElement::GetText(nsAString& aText, mozilla::ErrorResult& rv) const {
|
||||
if (NS_WARN_IF(
|
||||
!nsContentUtils::GetNodeTextContent(this, true, aText, fallible))) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -81,7 +81,7 @@ class SVGAElement final : public SVGAElementBase, public Link {
|
||||
void SetHreflang(const nsAString& aHreflang, mozilla::ErrorResult& rv);
|
||||
void GetType(nsAString& aType);
|
||||
void SetType(const nsAString& aType, mozilla::ErrorResult& rv);
|
||||
void GetText(nsAString& aText, mozilla::ErrorResult& rv);
|
||||
void GetText(nsAString& aText, mozilla::ErrorResult& rv) const;
|
||||
void SetText(const nsAString& aText, mozilla::ErrorResult& rv);
|
||||
|
||||
void NodeInfoChanged(Document* aOldDoc) final {
|
||||
|
@ -100,7 +100,7 @@ bool SVGScriptElement::GetScriptType(nsAString& type) {
|
||||
return GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
|
||||
}
|
||||
|
||||
void SVGScriptElement::GetScriptText(nsAString& text) {
|
||||
void SVGScriptElement::GetScriptText(nsAString& text) const {
|
||||
nsContentUtils::GetNodeTextContent(this, false, text);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class SVGScriptElement final : public SVGScriptElementBase,
|
||||
|
||||
// nsIScriptElement
|
||||
virtual bool GetScriptType(nsAString& type) override;
|
||||
virtual void GetScriptText(nsAString& text) override;
|
||||
virtual void GetScriptText(nsAString& text) const override;
|
||||
virtual void GetScriptCharset(nsAString& charset) override;
|
||||
virtual void FreezeExecutionAttrs(Document* aOwnerDoc) override;
|
||||
virtual CORSMode GetCORSMode() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user