summaryrefslogtreecommitdiffstats
path: root/dom/base/nsAttrValue.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-02-03 18:18:40 +0100
committerGitHub <noreply@github.com>2020-02-03 18:18:40 +0100
commitc4e1022f578b264641f5e25fcef3069bdae7490e (patch)
tree3f9d16addf2c79865229dfa445ba99d8c8c7822a /dom/base/nsAttrValue.cpp
parent9c6a8450b3e96442035b84025b0dd13be3a9e5f8 (diff)
parent52940bc44c14382bfd26f55ff48ffaa372d43497 (diff)
downloadUXP-c4e1022f578b264641f5e25fcef3069bdae7490e.tar
UXP-c4e1022f578b264641f5e25fcef3069bdae7490e.tar.gz
UXP-c4e1022f578b264641f5e25fcef3069bdae7490e.tar.lz
UXP-c4e1022f578b264641f5e25fcef3069bdae7490e.tar.xz
UXP-c4e1022f578b264641f5e25fcef3069bdae7490e.zip
Merge pull request #1385 from win7-7/standard-pr
Match standard for colSpan/rowSpan
Diffstat (limited to 'dom/base/nsAttrValue.cpp')
-rw-r--r--dom/base/nsAttrValue.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/dom/base/nsAttrValue.cpp b/dom/base/nsAttrValue.cpp
index ebddcb7ed..2418fb501 100644
--- a/dom/base/nsAttrValue.cpp
+++ b/dom/base/nsAttrValue.cpp
@@ -1526,6 +1526,40 @@ nsAttrValue::ParseIntWithFallback(const nsAString& aString, int32_t aDefault,
SetIntValueAndType(val, eInteger, nonStrict ? &aString : nullptr);
}
+void
+nsAttrValue::ParseClampedNonNegativeInt(const nsAString& aString,
+ int32_t aDefault, int32_t aMin,
+ int32_t aMax)
+{
+ ResetIfSet();
+
+ nsContentUtils::ParseHTMLIntegerResultFlags result;
+ int32_t val = nsContentUtils::ParseHTMLInteger(aString, &result);
+ bool nonStrict = (result & nsContentUtils::eParseHTMLInteger_IsPercent) ||
+ (result & nsContentUtils::eParseHTMLInteger_NonStandard) ||
+ (result & nsContentUtils::eParseHTMLInteger_DidNotConsumeAllInput);
+
+ if (result & nsContentUtils::eParseHTMLInteger_ErrorOverflow) {
+ if (result & nsContentUtils::eParseHTMLInteger_Negative) {
+ val = aDefault;
+ } else {
+ val = aMax;
+ }
+ nonStrict = true;
+ } else if ((result & nsContentUtils::eParseHTMLInteger_Error) || val < 0) {
+ val = aDefault;
+ nonStrict = true;
+ } else if (val < aMin) {
+ val = aMin;
+ nonStrict = true;
+ } else if (val > aMax) {
+ val = aMax;
+ nonStrict = true;
+ }
+
+ SetIntValueAndType(val, eInteger, nonStrict ? &aString : nullptr);
+}
+
bool
nsAttrValue::ParseNonNegativeIntValue(const nsAString& aString)
{