summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-12-22 14:10:14 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-12-22 14:10:14 +0100
commit6cfd7509c781c11a99edb4332bc7b0142eb57faf (patch)
tree916783c4c7dbdbf998c7c45c70dc80fd6287fdba /dom
parent0626e1cef06081bf93ee45eab47f6520816c967f (diff)
downloadUXP-6cfd7509c781c11a99edb4332bc7b0142eb57faf.tar
UXP-6cfd7509c781c11a99edb4332bc7b0142eb57faf.tar.gz
UXP-6cfd7509c781c11a99edb4332bc7b0142eb57faf.tar.lz
UXP-6cfd7509c781c11a99edb4332bc7b0142eb57faf.tar.xz
UXP-6cfd7509c781c11a99edb4332bc7b0142eb57faf.zip
Map intersectionRect to the coordinate space of the target document.
Spec says: "Map intersectionRect to the coordinate space of the viewport of the Document containing the target." Tag #249
Diffstat (limited to 'dom')
-rw-r--r--dom/base/DOMIntersectionObserver.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp
index f0be34ec0..5798335b4 100644
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -319,6 +319,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
nsIFrame* targetFrame = target->GetPrimaryFrame();
nsRect targetRect;
Maybe<nsRect> intersectionRect;
+ bool isSameDoc = root && root->GetComposedDoc() == target->GetComposedDoc();
if (rootFrame && targetFrame) {
// If mRoot is set we are testing intersection with a container element
@@ -327,7 +328,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
// Skip further processing of this target if it is not in the same
// Document as the intersection root, e.g. if root is an element of
// the main document and target an element from an embedded iframe.
- if (target->GetComposedDoc() != root->GetComposedDoc()) {
+ if (!isSameDoc) {
continue;
}
// Skip further processing of this target if is not a descendant of the
@@ -399,12 +400,12 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
intersectionRectRelativeToRoot,
rootIntersectionRect
);
- if (intersectionRect.isSome()) {
- intersectionRect = Some(nsLayoutUtils::TransformFrameRectToAncestor(
- nsLayoutUtils::GetContainingBlockForClientRect(rootFrame),
- intersectionRect.value(),
- targetFrame->PresContext()->PresShell()->GetRootScrollFrame()
- ));
+ if (intersectionRect.isSome() && !isSameDoc) {
+ nsRect rect = intersectionRect.value();
+ nsPresContext* presContext = targetFrame->PresContext();
+ nsLayoutUtils::TransformRect(rootFrame,
+ presContext->PresShell()->GetRootScrollFrame(), rect);
+ intersectionRect = Some(rect);
}
}