summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-05-15 12:45:10 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-05-15 12:45:10 +0200
commit16dcb521b33c0523c0b6eb1ba5a20fc42412080e (patch)
tree5ff6efb7d64c7f95ccc22b1bf097ee88365242b8 /dom
parenta7079d15b1797ae4e3a599d9e91fe6814cc1255b (diff)
downloaduxp-16dcb521b33c0523c0b6eb1ba5a20fc42412080e.tar.gz
Map IntersectionObserver rect to the correct viewport.
targetFrame is modified during the intersection computation loop, so it's not the viewport you want if there are scrollframes around. This bug triggers when IntersectionObservers are used on frames that wrap. Follow-up for #249.
Diffstat (limited to 'dom')
-rw-r--r--dom/base/DOMIntersectionObserver.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp
index 389b93071f..70b5534ba4 100644
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -339,6 +339,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
for (size_t i = 0; i < mObservationTargets.Length(); ++i) {
Element* target = mObservationTargets.ElementAt(i);
nsIFrame* targetFrame = target->GetPrimaryFrame();
+ nsIFrame* originalTargetFrame = targetFrame;
nsRect targetRect;
Maybe<nsRect> intersectionRect;
bool isSameDoc = root && root->GetComposedDoc() == target->GetComposedDoc();
@@ -424,7 +425,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
);
if (intersectionRect.isSome() && !isSameDoc) {
nsRect rect = intersectionRect.value();
- nsPresContext* presContext = targetFrame->PresContext();
+ nsPresContext* presContext = originalTargetFrame->PresContext();
nsLayoutUtils::TransformRect(rootFrame,
presContext->PresShell()->GetRootScrollFrame(), rect);
intersectionRect = Some(rect);