Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: third_party/WebKit/Source/core/dom/ElementRareData.h

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Clarify the tear-down path for observers and observations. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/ElementRareData.h
diff --git a/third_party/WebKit/Source/core/dom/ElementRareData.h b/third_party/WebKit/Source/core/dom/ElementRareData.h
index 5e27cfe6ef0a797ef74015199dba900aba584b20..dec5fd7f16706b30ef62d05d4aa80c1c95f3a190 100644
--- a/third_party/WebKit/Source/core/dom/ElementRareData.h
+++ b/third_party/WebKit/Source/core/dom/ElementRareData.h
@@ -25,6 +25,8 @@
#include "core/animation/ElementAnimations.h"
#include "core/dom/Attr.h"
#include "core/dom/DatasetDOMStringMap.h"
+#include "core/dom/IntersectionObservation.h"
+#include "core/dom/IntersectionObserver.h"
#include "core/dom/NamedNodeMap.h"
#include "core/dom/NodeRareData.h"
#include "core/dom/PseudoElement.h"
@@ -33,7 +35,9 @@
#include "core/html/ClassList.h"
#include "core/style/StyleInheritedData.h"
#include "platform/heap/Handle.h"
+#include "wtf/HashSet.h"
#include "wtf/OwnPtr.h"
+#include "wtf/WeakPtr.h"
namespace blink {
@@ -107,6 +111,25 @@ public:
m_elementAnimations = elementAnimations;
}
+ bool hasIntersectionObservation() const
+ {
+ return m_intersectionObservations && m_intersectionObservations->size();
+ }
+
+ IntersectionObservation::HashSet& intersectionObservations()
+ {
+ if (!m_intersectionObservations)
+ m_intersectionObservations = adoptPtrWillBeNoop(new IntersectionObservation::HashSet());
+ return *m_intersectionObservations.get();
+ }
+
+ WeakPtr<Element> createWeakPtr(Element* element)
+ {
+ if (!m_weakPointerFactory)
+ m_weakPointerFactory = adoptPtrWillBeNoop(new WeakPtrFactory<Element>(element));
+ return m_weakPointerFactory->createWeakPtr();
+ }
+
bool hasPseudoElements() const;
void clearPseudoElements();
@@ -144,6 +167,11 @@ private:
PersistentWillBeMember<ElementAnimations> m_elementAnimations;
OwnPtrWillBeMember<InlineCSSStyleDeclaration> m_cssomWrapper;
+ // Note that m_intersectionObservers will contain both observers for which this element is target,
+ // and observers for which this element is root. To tell them apart, check (observer->root() == element).
+ OwnPtrWillBeMember<IntersectionObservation::HashSet> m_intersectionObservations;
+ OwnPtrWillBeMember<WeakPtrFactory<Element>> m_weakPointerFactory;
+
RefPtr<ComputedStyle> m_computedStyle;
RefPtrWillBeMember<CustomElementDefinition> m_customElementDefinition;

Powered by Google App Engine
This is Rietveld 408576698