[DOM] Pass error up the chain in SetColorValue.

This commit is contained in:
Moonchild 2024-08-07 11:58:14 +02:00 committed by roytam1
commit 314ba652f4
2 changed files with 7 additions and 9 deletions

View file

@ -1598,12 +1598,12 @@ nsAttrValue::ParsePositiveIntValue(const nsAString& aString)
return true;
}
void
bool
nsAttrValue::SetColorValue(nscolor aColor, const nsAString& aString)
{
nsStringBuffer* buf = GetStringBuffer(aString).take();
if (!buf) {
return;
return false;
}
MiscContainer* cont = EnsureEmptyMiscContainer();
@ -1612,6 +1612,7 @@ nsAttrValue::SetColorValue(nscolor aColor, const nsAString& aString)
// Save the literal string we were passed for round-tripping.
cont->mStringBits = reinterpret_cast<uintptr_t>(buf) | eStringBase;
return true;
}
bool
@ -1635,13 +1636,11 @@ nsAttrValue::ParseColor(const nsAString& aString)
if (colorStr.First() == '#') {
nsDependentString withoutHash(colorStr.get() + 1, colorStr.Length() - 1);
if (NS_HexToRGBA(withoutHash, nsHexColorType::NoAlpha, &color)) {
SetColorValue(color, aString);
return true;
return SetColorValue(color, aString);
}
} else {
if (NS_ColorNameToRGB(colorStr, &color)) {
SetColorValue(color, aString);
return true;
return SetColorValue(color, aString);
}
}
@ -1652,8 +1651,7 @@ nsAttrValue::ParseColor(const nsAString& aString)
// Use NS_LooseHexToRGB as a fallback if nothing above worked.
if (NS_LooseHexToRGB(colorStr, &color)) {
SetColorValue(color, aString);
return true;
return SetColorValue(color, aString);
}
return false;