summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-04-24 17:00:46 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-24 17:00:46 +0000
commit42ee994d993bc170db7cad8d57e2d19b03ae9d13 (patch)
tree3ab2e31892f6cde8bffad536af1b786acf4078bc /dom
parentf25a45b9e6b24442b16f418be9d26a162c89986a (diff)
downloaduxp-42ee994d993bc170db7cad8d57e2d19b03ae9d13.tar.gz
Issue #1885 - Allow unitless rootMargin entries for IntersectionObserver.
I could have done this through a CSSLoader to allow all CSS unit quirks but I wasn't planning to start passing around document and element references everywhere, so instead just did it manually by accepting numbers/floats in addition to pixel and percent.
Diffstat (limited to 'dom')
-rw-r--r--dom/base/DOMIntersectionObserver.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp
index bc8f030d0f..fb6315cc42 100644
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -126,7 +126,9 @@ DOMIntersectionObserver::SetRootMargin(const nsAString& aString)
for (uint32_t i = 0; i < ArrayLength(nsCSSRect::sides); ++i) {
nsCSSValue value = mRootMargin.*nsCSSRect::sides[i];
- if (!(value.IsPixelLengthUnit() || value.IsPercentLengthUnit())) {
+ if (!(value.IsPixelLengthUnit() ||
+ value.IsPercentLengthUnit() ||
+ value.IsFloatUnit(value.GetUnit()))) {
return false;
}
}
@@ -327,6 +329,8 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
nsStyleCoord coord;
if (value.IsPixelLengthUnit()) {
coord.SetCoordValue(value.GetPixelLength());
+ } else if (value.IsFloatUnit(value.GetUnit())) {
+ coord.SetCoordValue(value.GetFloatValue());
} else if (value.IsPercentLengthUnit()) {
coord.SetPercentValue(value.GetPercentValue());
} else {