| Index: third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
|
| index f853921b9106c69b9035349d8a1941f22c9884c2..31e48e706a65e6e7d9043d97fdb0899ecafc1f49 100644
|
| --- a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
|
| @@ -19,6 +19,7 @@
|
| #include "core/frame/LocalDOMWindow.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/html/HTMLFrameOwnerElement.h"
|
| +#include "core/inspector/ConsoleMessage.h"
|
| #include "core/layout/LayoutView.h"
|
| #include "core/timing/DOMWindowPerformance.h"
|
| #include "core/timing/Performance.h"
|
| @@ -179,13 +180,29 @@ void IntersectionObserver::observe(Element* target)
|
| return;
|
|
|
| bool shouldReportRootBounds = false;
|
| + bool isDOMDescendant = false;
|
| LocalFrame* targetFrame = target->document().frame();
|
| - LocalFrame* rootFrame = rootNode()->document().frame();
|
| - if (targetFrame && rootFrame)
|
| + LocalFrame* rootFrame = m_root->document().frame();
|
| +
|
| + if (target->document() == rootNode()->document()) {
|
| + shouldReportRootBounds = true;
|
| + isDOMDescendant = target->isDescendantOf(rootNode());
|
| + } else if (targetFrame && rootFrame) {
|
| shouldReportRootBounds = targetFrame->securityContext()->getSecurityOrigin()->canAccess(rootFrame->securityContext()->getSecurityOrigin());
|
| + isDOMDescendant = (targetFrame->tree().top() == rootFrame);
|
| + }
|
| +
|
| IntersectionObservation* observation = new IntersectionObservation(*this, *target, shouldReportRootBounds);
|
| target->ensureIntersectionObserverData().addObservation(*observation);
|
| m_observations.add(observation);
|
| +
|
| + if (!isDOMDescendant) {
|
| + m_root->document().addConsoleMessage(ConsoleMessage::create(
|
| + JSMessageSource, WarningMessageLevel,
|
| + "IntersectionObserver.observe(target): target element is not a descendant of root."));
|
| + return;
|
| + }
|
| +
|
| if (!rootFrame)
|
| return;
|
| if (FrameView* rootFrameView = rootFrame->view())
|
|
|