From 107a68cb1d12aa6ed74e4ca414e5f05e4a92c963 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 22 Dec 2018 06:30:39 +0100 Subject: Intersection ratio should be 1.0 for zero-area intersections. Tag #249 --- dom/base/DOMIntersectionObserver.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'dom/base') diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp index cb624fb17..0834bc05c 100644 --- a/dom/base/DOMIntersectionObserver.cpp +++ b/dom/base/DOMIntersectionObserver.cpp @@ -411,7 +411,13 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time double targetArea = targetRect.width * targetRect.height; double intersectionArea = !intersectionRect ? 0 : intersectionRect->width * intersectionRect->height; - double intersectionRatio = targetArea > 0.0 ? intersectionArea / targetArea : 0.0; + + double intersectionRatio; + if (targetArea > 0.0) { + intersectionRatio = intersectionArea / targetArea; + } else { + intersectionRatio = intersectionRect.isSome() ? 1.0 : 0.0; + } size_t threshold = -1; if (intersectionRatio > 0.0) { -- cgit v1.2.3