mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-07-20 22:29:28 +00:00
import from UXP: Issue #249 - Stabilize and align Intersection Observers (5af41078)
This commit is contained in:
@@ -49,6 +49,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMIntersectionObserver)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mQueuedEntries)
|
||||
tmp->Disconnect();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMIntersectionObserver)
|
||||
@@ -253,6 +254,12 @@ EdgeInclusiveIntersection(const nsRect& aRect, const nsRect& aOtherRect)
|
||||
return Some(nsRect(left, top, right - left, bottom - top));
|
||||
}
|
||||
|
||||
enum class BrowsingContextInfo {
|
||||
SimilarOriginBrowsingContext,
|
||||
DifferentOriginBrowsingContext,
|
||||
UnknownBrowsingContext
|
||||
};
|
||||
|
||||
void
|
||||
DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time)
|
||||
{
|
||||
@@ -367,11 +374,22 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
|
||||
}
|
||||
}
|
||||
|
||||
nsRect rootIntersectionRect = rootRect;
|
||||
bool isInSimilarOriginBrowsingContext = rootFrame && targetFrame &&
|
||||
CheckSimilarOrigin(root, target);
|
||||
nsRect rootIntersectionRect;
|
||||
BrowsingContextInfo isInSimilarOriginBrowsingContext =
|
||||
BrowsingContextInfo::UnknownBrowsingContext;
|
||||
|
||||
if (isInSimilarOriginBrowsingContext) {
|
||||
if (rootFrame && targetFrame) {
|
||||
rootIntersectionRect = rootRect;
|
||||
}
|
||||
|
||||
if (root && target) {
|
||||
isInSimilarOriginBrowsingContext = CheckSimilarOrigin(root, target) ?
|
||||
BrowsingContextInfo::SimilarOriginBrowsingContext :
|
||||
BrowsingContextInfo::DifferentOriginBrowsingContext;
|
||||
}
|
||||
|
||||
if (isInSimilarOriginBrowsingContext ==
|
||||
BrowsingContextInfo::SimilarOriginBrowsingContext) {
|
||||
rootIntersectionRect.Inflate(rootMargin);
|
||||
}
|
||||
|
||||
@@ -421,7 +439,9 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
|
||||
if (target->UpdateIntersectionObservation(this, threshold)) {
|
||||
QueueIntersectionObserverEntry(
|
||||
target, time,
|
||||
isInSimilarOriginBrowsingContext ? Some(rootIntersectionRect) : Nothing(),
|
||||
isInSimilarOriginBrowsingContext ==
|
||||
BrowsingContextInfo::DifferentOriginBrowsingContext ?
|
||||
Nothing() : Some(rootIntersectionRect),
|
||||
targetRect, intersectionRect, intersectionRatio
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user