Intersection ratio should be 1.0 for zero-area intersections.

Tag #249
This commit is contained in:
wolfbeast 2018-12-22 06:30:39 +01:00 committed by Roy Tam
commit 47f52cee1f

View file

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