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.
This commit is contained in:
Moonchild 2022-04-24 17:00:46 +00:00 committed by roytam1
commit 7c93047283
2 changed files with 6 additions and 2 deletions

View file

@ -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 {