diff options
author | Moonchild <moonchild@palemoon.org> | 2022-04-24 17:00:46 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-24 17:00:46 +0000 |
commit | 42ee994d993bc170db7cad8d57e2d19b03ae9d13 (patch) | |
tree | 3ab2e31892f6cde8bffad536af1b786acf4078bc | |
parent | f25a45b9e6b24442b16f418be9d26a162c89986a (diff) | |
download | uxp-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.
-rw-r--r-- | dom/base/DOMIntersectionObserver.cpp | 6 | ||||
-rw-r--r-- | layout/style/nsCSSParser.cpp | 2 |
2 files changed, 6 insertions, 2 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 { diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 387f6ed27f..72427792fa 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -2311,7 +2311,7 @@ CSSParserImpl::ParseMarginString(const nsSubstring& aBuffer, } else { UngetToken(); // Parse a margin, and check that there's nothing else after it. - marginParsed = ParseGroupedBoxProperty(VARIANT_LP, aValue, 0) && + marginParsed = ParseGroupedBoxProperty(VARIANT_LPN, aValue, 0) && !GetToken(true); } |