@@ -618,7 +618,9 @@ void DOMIntersectionObserver::Update(Document* aDocument,
618
618
// length of observer.thresholds if intersectionRatio is greater than or
619
619
// equal to the last entry in observer.thresholds.
620
620
int32_t thresholdIndex = -1 ;
621
- // FIXME(emilio): Why the isIntersecting check?
621
+
622
+ // If not intersecting, we can just shortcut, as we know that the thresholds
623
+ // are always between 0 and 1.
622
624
if (isIntersecting) {
623
625
thresholdIndex = mThresholds .IndexOfFirstElementGt (intersectionRatio);
624
626
if (thresholdIndex == 0 ) {
@@ -628,26 +630,30 @@ void DOMIntersectionObserver::Update(Document* aDocument,
628
630
// neither Chrome nor the WPT tests expect this behavior, so treat these
629
631
// two cases as one.
630
632
//
631
- // FIXME(emilio): Looks like a good candidate for a spec issue.
633
+ // See https://github.com/w3c/IntersectionObserver/issues/432 about
634
+ // this.
632
635
thresholdIndex = -1 ;
633
636
}
634
637
}
635
638
636
639
// Steps 2.10 - 2.15.
637
640
if (target->UpdateIntersectionObservation (this , thresholdIndex)) {
641
+ // See https://github.com/w3c/IntersectionObserver/issues/432 about
642
+ // why we use thresholdIndex > 0 rather than isIntersecting for the
643
+ // entry's isIntersecting value.
638
644
QueueIntersectionObserverEntry (
639
645
target, time ,
640
646
origin == BrowsingContextOrigin::Similar ? Some (rootBounds)
641
647
: Nothing (),
642
- targetRect, intersectionRect, intersectionRatio);
648
+ targetRect, intersectionRect, thresholdIndex > 0 , intersectionRatio);
643
649
}
644
650
}
645
651
}
646
652
647
653
void DOMIntersectionObserver::QueueIntersectionObserverEntry (
648
654
Element* aTarget, DOMHighResTimeStamp time, const Maybe<nsRect>& aRootRect,
649
655
const nsRect& aTargetRect, const Maybe<nsRect>& aIntersectionRect,
650
- double aIntersectionRatio) {
656
+ bool aIsIntersecting, double aIntersectionRatio) {
651
657
RefPtr<DOMRect> rootBounds;
652
658
if (aRootRect.isSome ()) {
653
659
rootBounds = new DOMRect (this );
@@ -661,7 +667,7 @@ void DOMIntersectionObserver::QueueIntersectionObserverEntry(
661
667
}
662
668
RefPtr<DOMIntersectionObserverEntry> entry = new DOMIntersectionObserverEntry (
663
669
this , time , rootBounds.forget (), boundingClientRect.forget (),
664
- intersectionRect.forget (), aIntersectionRect. isSome () , aTarget,
670
+ intersectionRect.forget (), aIsIntersecting , aTarget,
665
671
aIntersectionRatio);
666
672
mQueuedEntries .AppendElement (entry.forget ());
667
673
}
0 commit comments