[IntersectionObserver] Do not hold a strong reference to the root element
authorajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2018 14:13:06 +0000 (14:13 +0000)
committerajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2018 14:13:06 +0000 (14:13 +0000)
commit49d44f8f5f29a46ed30345520b5f307c5e1457c0
tree85532bdd0de12487ed2c427df2d72509c3d83564
parent1e391f613bed97b2cd75889c9ecf7328ebc7c9cd
[IntersectionObserver] Do not hold a strong reference to the root element
https://bugs.webkit.org/show_bug.cgi?id=188575

Reviewed by Simon Fraser.

Source/WebCore:

Make IntersectionObserver have only a raw pointer to its root element rather than
a reference, so that an otherwise-unreachable root isn't kept alive. Add logic to
to clear this pointer when the root element gets deleted.

Test: intersection-observer/root-element-deleted.html

* dom/Element.cpp:
(WebCore::Element::~Element):
(WebCore::Element::disconnectFromIntersectionObservers):
(WebCore::Element::ensureIntersectionObserverData):
(WebCore::Element::intersectionObserverData):
* dom/Element.h:
* dom/ElementRareData.cpp:
* dom/ElementRareData.h:
(WebCore::ElementRareData::intersectionObserverData):
(WebCore::ElementRareData::setIntersectionObserverData):
* page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::create):
(WebCore::IntersectionObserver::IntersectionObserver):
(WebCore::IntersectionObserver::~IntersectionObserver):
(WebCore::IntersectionObserver::rootDestroyed):
* page/IntersectionObserver.h:
(WebCore::IntersectionObserver::root const):

LayoutTests:

* intersection-observer/root-element-deleted-expected.txt: Added.
* intersection-observer/root-element-deleted.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234884 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/intersection-observer/root-element-deleted-expected.txt [new file with mode: 0644]
LayoutTests/intersection-observer/root-element-deleted.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/ElementRareData.cpp
Source/WebCore/dom/ElementRareData.h
Source/WebCore/page/IntersectionObserver.cpp
Source/WebCore/page/IntersectionObserver.h