Bug 1359318 - (intersection-observer) Map intersectionRect to the coordinate space of the target document. r=mstange

This commit is contained in:
Tobias Schneider
2017-06-02 14:11:31 -07:00
parent 5ff3df5354
commit 4b54676b9d
8 changed files with 8 additions and 15 deletions

View File

@@ -330,6 +330,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
@@ -338,7 +339,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
@@ -410,12 +411,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);
}
}

View File

@@ -1,3 +1,2 @@
[display-none.html]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359318

View File

@@ -1,4 +1,2 @@
[iframe-no-root.html]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359318

View File

@@ -1,3 +1,2 @@
[multiple-thresholds.html]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359318

View File

@@ -1,3 +1,2 @@
[root-margin.html]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359318

View File

@@ -1,3 +1,2 @@
[same-document-no-root.html]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359318

View File

@@ -1,3 +1,2 @@
[same-document-zero-size-target.html]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359318

View File

@@ -1,4 +1,3 @@
[shadow-content.html]
type: testharness
prefs: [dom.webcomponents.enabled:true]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359318