summaryrefslogtreecommitdiffstats
path: root/dom/base/nsAttrValue.cpp
diff options
context:
space:
mode:
authorwin7-7 <win7-7@users.noreply.github.com>2020-02-03 16:59:23 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:28:14 +0200
commit0ebdc997574ba96199e68f0766e1f220bd00ab35 (patch)
tree393da535fa7287b5349b8fe92d08b8f6492cb59d /dom/base/nsAttrValue.cpp
parent68d3bc54fbc9b99310197c51dfd84b6f72b7fb01 (diff)
downloadUXP-0ebdc997574ba96199e68f0766e1f220bd00ab35.tar
UXP-0ebdc997574ba96199e68f0766e1f220bd00ab35.tar.gz
UXP-0ebdc997574ba96199e68f0766e1f220bd00ab35.tar.lz
UXP-0ebdc997574ba96199e68f0766e1f220bd00ab35.tar.xz
UXP-0ebdc997574ba96199e68f0766e1f220bd00ab35.zip
Issue #1384 - Match standard for colSpan/rowSpan
HTML standardizes proper behavior of colSpan and rowSpan: The main thing is that getting the .rowSpan and .colSpan IDL properties will now return the actual clamped value that we use.
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)
{