summaryrefslogtreecommitdiffstats
path: root/dom/html/nsGenericHTMLElement.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /dom/html/nsGenericHTMLElement.cpp
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/nsGenericHTMLElement.cpp')
-rw-r--r--dom/html/nsGenericHTMLElement.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
index 1014ba2a25..1deaf719d3 100644
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -646,7 +646,6 @@ already_AddRefed<nsIURI> nsGenericHTMLElement::GetHrefURIForAnchors() const {
// We use the nsAttrValue's copy of the URI string to avoid copying.
nsCOMPtr<nsIURI> uri;
GetURIAttr(nsGkAtoms::href, nullptr, getter_AddRefs(uri));
-
return uri.forget();
}
@@ -1661,34 +1660,50 @@ uint32_t nsGenericHTMLElement::GetDimensionAttrAsUnsignedInt(
void nsGenericHTMLElement::GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr,
nsAString& aResult) const {
nsCOMPtr<nsIURI> uri;
- bool hadAttr = GetURIAttr(aAttr, aBaseAttr, getter_AddRefs(uri));
- if (!hadAttr) {
+ const nsAttrValue* attr = GetURIAttr(aAttr, aBaseAttr, getter_AddRefs(uri));
+ if (!attr) {
aResult.Truncate();
return;
}
-
if (!uri) {
// Just return the attr value
- GetAttr(aAttr, aResult);
+ attr->ToString(aResult);
return;
}
-
nsAutoCString spec;
uri->GetSpec(spec);
CopyUTF8toUTF16(spec, aResult);
}
-bool nsGenericHTMLElement::GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr,
- nsIURI** aURI) const {
+void nsGenericHTMLElement::GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr,
+ nsACString& aResult) const {
+ nsCOMPtr<nsIURI> uri;
+ const nsAttrValue* attr = GetURIAttr(aAttr, aBaseAttr, getter_AddRefs(uri));
+ if (!attr) {
+ aResult.Truncate();
+ return;
+ }
+ if (!uri) {
+ // Just return the attr value
+ nsAutoString value;
+ attr->ToString(value);
+ CopyUTF16toUTF8(value, aResult);
+ return;
+ }
+ uri->GetSpec(aResult);
+}
+
+const nsAttrValue* nsGenericHTMLElement::GetURIAttr(nsAtom* aAttr,
+ nsAtom* aBaseAttr,
+ nsIURI** aURI) const {
*aURI = nullptr;
const nsAttrValue* attr = mAttrs.GetAttr(aAttr);
if (!attr) {
- return false;
+ return nullptr;
}
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
-
if (aBaseAttr) {
nsAutoString baseAttrValue;
if (GetAttr(aBaseAttr, baseAttrValue)) {
@@ -1696,7 +1711,7 @@ bool nsGenericHTMLElement::GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr,
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(
getter_AddRefs(baseAttrURI), baseAttrValue, OwnerDoc(), baseURI);
if (NS_FAILED(rv)) {
- return true;
+ return attr;
}
baseURI.swap(baseAttrURI);
}
@@ -1706,7 +1721,7 @@ bool nsGenericHTMLElement::GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr,
// return true, and *aURI will be null.
nsContentUtils::NewURIWithDocumentCharset(aURI, attr->GetStringValue(),
OwnerDoc(), baseURI);
- return true;
+ return attr;
}
bool nsGenericHTMLElement::IsLabelable() const {