| 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 24f43a00be0a8af290568ed7142b269d10466fd2..cca839fc37d293f3ec5268455c9114185713afad 100644
|
| --- a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
|
| @@ -172,30 +172,6 @@ LayoutObject* IntersectionObserver::rootLayoutObject() const
|
| return toElement(node)->layoutObject();
|
| }
|
|
|
| -bool IntersectionObserver::isDescendantOfRoot(const Element* target) const
|
| -{
|
| - // Is m_root an ancestor, through the DOM and frame trees, of target?
|
| - Node* node = rootNode();
|
| - if (!node || !target || target == node)
|
| - return false;
|
| - if (!target->inDocument() || !node->inDocument())
|
| - return false;
|
| -
|
| - Document* rootDocument = &node->document();
|
| - Document* targetDocument = &target->document();
|
| - while (targetDocument != rootDocument) {
|
| - target = targetDocument->ownerElement();
|
| - if (!target)
|
| - return false;
|
| - targetDocument = &target->document();
|
| - }
|
| - if (node->isDocumentNode()) {
|
| - ASSERT(targetDocument == node);
|
| - return true;
|
| - }
|
| - return target->isDescendantOf(node);
|
| -}
|
| -
|
| void IntersectionObserver::observe(Element* target, ExceptionState& exceptionState)
|
| {
|
| if (!m_root) {
|
| @@ -210,10 +186,6 @@ void IntersectionObserver::observe(Element* target, ExceptionState& exceptionSta
|
| exceptionState.throwDOMException(HierarchyRequestError, "Cannot use the same element for root and target.");
|
| return;
|
| }
|
| - if (!isDescendantOfRoot(target)) {
|
| - exceptionState.throwDOMException(HierarchyRequestError, "Observed element must be a descendant of the observer's root element.");
|
| - return;
|
| - }
|
|
|
| // TODO(szager): Add a pointer to the spec that describes this policy.
|
| bool shouldReportRootBounds = target->document().frame()->securityContext()->securityOrigin()->canAccess(rootNode()->document().frame()->securityContext()->securityOrigin());
|
| @@ -241,7 +213,7 @@ void IntersectionObserver::unobserve(Element* target, ExceptionState&)
|
|
|
| void IntersectionObserver::computeIntersectionObservations()
|
| {
|
| - if (!m_root)
|
| + if (!m_root || !m_root->inDocument())
|
| return;
|
| Document* callbackDocument = toDocument(m_callback->executionContext());
|
| if (!callbackDocument)
|
| @@ -358,12 +330,6 @@ void IntersectionObserver::deliver()
|
| m_callback->handleEvent(entries, *this);
|
| }
|
|
|
| -void IntersectionObserver::setActive(bool active)
|
| -{
|
| - for (auto& observation : m_observations)
|
| - observation->setActive(m_root && active && isDescendantOfRoot(observation->target()));
|
| -}
|
| -
|
| bool IntersectionObserver::hasPercentMargin() const
|
| {
|
| return (m_topMargin.type() == Percent
|
|
|