Add isIntersecting property to IntersectionObserverEntry.

Per updated spec.

This resolves the issue raised in #249.
This commit is contained in:
wolfbeast 2019-01-17 19:02:50 +01:00 committed by Roy Tam
commit 9222116f26
3 changed files with 11 additions and 0 deletions

View file

@ -482,6 +482,7 @@ DOMIntersectionObserver::QueueIntersectionObserverEntry(Element* aTarget,
rootBounds.forget(),
boundingClientRect.forget(),
intersectionRect.forget(),
aIntersectionRect.isSome(),
aTarget, aIntersectionRatio);
mQueuedEntries.AppendElement(entry.forget());
}

View file

@ -30,6 +30,7 @@ public:
RefPtr<DOMRect> aRootBounds,
RefPtr<DOMRect> aBoundingClientRect,
RefPtr<DOMRect> aIntersectionRect,
bool aIsIntersecting,
Element* aTarget,
double aIntersectionRatio)
: mOwner(aOwner),
@ -37,6 +38,7 @@ public:
mRootBounds(aRootBounds),
mBoundingClientRect(aBoundingClientRect),
mIntersectionRect(aIntersectionRect),
mIsIntersecting(aIsIntersecting),
mTarget(aTarget),
mIntersectionRatio(aIntersectionRatio)
{
@ -74,6 +76,11 @@ public:
return mIntersectionRect;
}
bool IsIntersecting()
{
return mIsIntersecting;
}
double IntersectionRatio()
{
return mIntersectionRatio;
@ -90,6 +97,7 @@ protected:
RefPtr<DOMRect> mRootBounds;
RefPtr<DOMRect> mBoundingClientRect;
RefPtr<DOMRect> mIntersectionRect;
bool mIsIntersecting;
RefPtr<Element> mTarget;
double mIntersectionRatio;
};

View file

@ -18,6 +18,8 @@ interface IntersectionObserverEntry {
[Constant]
readonly attribute DOMRectReadOnly intersectionRect;
[Constant]
readonly attribute boolean isIntersecting;
[Constant]
readonly attribute double intersectionRatio;
[Constant]
readonly attribute Element target;