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

Side by Side 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: Implemented root margin Created 5 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com> 3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 * 19 *
20 */ 20 */
21 21
22 #ifndef ElementRareData_h 22 #ifndef ElementRareData_h
23 #define ElementRareData_h 23 #define ElementRareData_h
24 24
25 #include "core/animation/ElementAnimations.h" 25 #include "core/animation/ElementAnimations.h"
26 #include "core/dom/Attr.h" 26 #include "core/dom/Attr.h"
27 #include "core/dom/CompositorProxiedPropertySet.h" 27 #include "core/dom/CompositorProxiedPropertySet.h"
28 #include "core/dom/DatasetDOMStringMap.h" 28 #include "core/dom/DatasetDOMStringMap.h"
29 #include "core/dom/IntersectionObservation.h"
30 #include "core/dom/IntersectionObserver.h"
29 #include "core/dom/NamedNodeMap.h" 31 #include "core/dom/NamedNodeMap.h"
30 #include "core/dom/NodeRareData.h" 32 #include "core/dom/NodeRareData.h"
31 #include "core/dom/PseudoElement.h" 33 #include "core/dom/PseudoElement.h"
32 #include "core/dom/custom/CustomElementDefinition.h" 34 #include "core/dom/custom/CustomElementDefinition.h"
33 #include "core/dom/shadow/ElementShadow.h" 35 #include "core/dom/shadow/ElementShadow.h"
34 #include "core/html/ClassList.h" 36 #include "core/html/ClassList.h"
35 #include "core/style/StyleInheritedData.h" 37 #include "core/style/StyleInheritedData.h"
36 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
39 #include "wtf/HashSet.h"
37 #include "wtf/OwnPtr.h" 40 #include "wtf/OwnPtr.h"
41 #include "wtf/WeakPtr.h"
38 42
39 namespace blink { 43 namespace blink {
40 44
41 class HTMLElement; 45 class HTMLElement;
42 class CompositorProxiedPropertySet; 46 class CompositorProxiedPropertySet;
43 47
44 class ElementRareData : public NodeRareData { 48 class ElementRareData : public NodeRareData {
45 public: 49 public:
46 static ElementRareData* create(LayoutObject* layoutObject) 50 static ElementRareData* create(LayoutObject* layoutObject)
47 { 51 {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 106
103 IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } 107 IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; }
104 void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = si ze; } 108 void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = si ze; }
105 109
106 ElementAnimations* elementAnimations() { return m_elementAnimations.get(); } 110 ElementAnimations* elementAnimations() { return m_elementAnimations.get(); }
107 void setElementAnimations(ElementAnimations* elementAnimations) 111 void setElementAnimations(ElementAnimations* elementAnimations)
108 { 112 {
109 m_elementAnimations = elementAnimations; 113 m_elementAnimations = elementAnimations;
110 } 114 }
111 115
116 bool hasIntersectionObserver() const
117 {
esprehn 2015/12/12 00:14:13 move all of this code to your separate object, put
szager1 2015/12/16 19:15:34 Done.
118 return m_intersectionObservers && m_intersectionObservers->size();
119 }
120
121 IntersectionObserver::WeakHashSet& intersectionObservers()
122 {
123 if (!m_intersectionObservers)
124 m_intersectionObservers = new IntersectionObserver::WeakHashSet();
125 return *m_intersectionObservers;
126 }
127
128 bool hasIntersectionObservation() const
129 {
130 return m_intersectionObservations && m_intersectionObservations->size();
131 }
132
133 IntersectionObservation::HashSet& intersectionObservations()
134 {
135 if (!m_intersectionObservations)
136 m_intersectionObservations = new IntersectionObservation::HashSet();
137 return *m_intersectionObservations;
138 }
139
140 void deactivateAllIntersectionObservers()
141 {
142 if (!m_intersectionObservers)
143 return;
144 for (auto& observer: *m_intersectionObservers)
145 observer->setActive(false);
146 }
147
148 void deactivateAllIntersectionObservations()
149 {
150 if (!m_intersectionObservations)
151 return;
152 for (auto& observation: *m_intersectionObservations)
153 observation->setActive(false);
154 }
155
156 #if !ENABLE(OILPAN)
157 WeakPtr<Element> createWeakPtr(Element* element)
158 {
159 if (!m_weakPointerFactory)
160 m_weakPointerFactory = adoptPtrWillBeNoop(new WeakPtrFactory<Element >(element));
161 return m_weakPointerFactory->createWeakPtr();
162 }
163 #endif
164
112 bool hasPseudoElements() const; 165 bool hasPseudoElements() const;
113 void clearPseudoElements(); 166 void clearPseudoElements();
114 167
115 void incrementCompositorProxiedProperties(uint32_t properties); 168 void incrementCompositorProxiedProperties(uint32_t properties);
116 void decrementCompositorProxiedProperties(uint32_t properties); 169 void decrementCompositorProxiedProperties(uint32_t properties);
117 CompositorProxiedPropertySet* proxiedPropertyCounts() const { return m_proxi edProperties.get(); } 170 CompositorProxiedPropertySet* proxiedPropertyCounts() const { return m_proxi edProperties.get(); }
118 171
119 void setCustomElementDefinition(PassRefPtrWillBeRawPtr<CustomElementDefiniti on> definition) { m_customElementDefinition = definition; } 172 void setCustomElementDefinition(PassRefPtrWillBeRawPtr<CustomElementDefiniti on> definition) { m_customElementDefinition = definition; }
120 CustomElementDefinition* customElementDefinition() const { return m_customEl ementDefinition.get(); } 173 CustomElementDefinition* customElementDefinition() const { return m_customEl ementDefinition.get(); }
121 174
(...skipping 10 matching lines...) Expand all
132 short m_tabindex; 185 short m_tabindex;
133 186
134 LayoutSize m_minimumSizeForResizing; 187 LayoutSize m_minimumSizeForResizing;
135 IntSize m_savedLayerScrollOffset; 188 IntSize m_savedLayerScrollOffset;
136 189
137 OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset; 190 OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset;
138 OwnPtrWillBeMember<ClassList> m_classList; 191 OwnPtrWillBeMember<ClassList> m_classList;
139 OwnPtrWillBeMember<ElementShadow> m_shadow; 192 OwnPtrWillBeMember<ElementShadow> m_shadow;
140 OwnPtrWillBeMember<NamedNodeMap> m_attributeMap; 193 OwnPtrWillBeMember<NamedNodeMap> m_attributeMap;
141 OwnPtrWillBeMember<AttrNodeList> m_attrNodeList; 194 OwnPtrWillBeMember<AttrNodeList> m_attrNodeList;
142 PersistentWillBeMember<ElementAnimations> m_elementAnimations;
143 OwnPtrWillBeMember<InlineCSSStyleDeclaration> m_cssomWrapper; 195 OwnPtrWillBeMember<InlineCSSStyleDeclaration> m_cssomWrapper;
144 OwnPtr<CompositorProxiedPropertySet> m_proxiedProperties; 196 OwnPtr<CompositorProxiedPropertySet> m_proxiedProperties;
145 197
198 #if !ENABLE(OILPAN)
199 OwnPtrWillBeMember<WeakPtrFactory<Element>> m_weakPointerFactory;
esprehn 2015/12/12 00:14:13 move to controller
szager1 2015/12/16 19:15:34 Done.
200 #endif
201
202 PersistentWillBeMember<ElementAnimations> m_elementAnimations;
203 // Note that m_intersectionObservers will contain both observers for which t his element is target,
ojan 2015/12/12 01:06:28 This comment is in the wrong place?
szager1 2015/12/16 19:15:34 That's an obsolete comment, I removed it.
204 // and observers for which this element is root. To tell them apart, check (observer->root() == element).
esprehn 2015/12/12 00:14:13 keep two sets instead? This doesn't seem right
szager1 2015/12/16 19:15:34 same comment
205
146 RefPtr<ComputedStyle> m_computedStyle; 206 RefPtr<ComputedStyle> m_computedStyle;
147 RefPtrWillBeMember<CustomElementDefinition> m_customElementDefinition; 207 RefPtrWillBeMember<CustomElementDefinition> m_customElementDefinition;
148 208
149 RefPtrWillBeMember<PseudoElement> m_generatedBefore; 209 RefPtrWillBeMember<PseudoElement> m_generatedBefore;
150 RefPtrWillBeMember<PseudoElement> m_generatedAfter; 210 RefPtrWillBeMember<PseudoElement> m_generatedAfter;
151 RefPtrWillBeMember<PseudoElement> m_generatedFirstLetter; 211 RefPtrWillBeMember<PseudoElement> m_generatedFirstLetter;
152 RefPtrWillBeMember<PseudoElement> m_backdrop; 212 RefPtrWillBeMember<PseudoElement> m_backdrop;
153 213
214 // IntersectionObservers for which this element is root.
215 PersistentWillBeMember<IntersectionObserver::WeakHashSet> m_intersectionObse rvers;
216 // IntersectionObservations for which this element is target.
217 PersistentWillBeMember<IntersectionObservation::HashSet> m_intersectionObser vations;
esprehn 2015/12/12 00:14:13 PersistentWillBeMember<IntersectionObserverControl
szager1 2015/12/16 19:15:34 Done.
218
154 explicit ElementRareData(LayoutObject*); 219 explicit ElementRareData(LayoutObject*);
155 }; 220 };
156 221
157 inline LayoutSize defaultMinimumSizeForResizing() 222 inline LayoutSize defaultMinimumSizeForResizing()
158 { 223 {
159 return LayoutSize(LayoutUnit::max(), LayoutUnit::max()); 224 return LayoutSize(LayoutUnit::max(), LayoutUnit::max());
160 } 225 }
161 226
162 inline ElementRareData::ElementRareData(LayoutObject* layoutObject) 227 inline ElementRareData::ElementRareData(LayoutObject* layoutObject)
163 : NodeRareData(layoutObject) 228 : NodeRareData(layoutObject)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 inline CompositorProxiedPropertySet& ElementRareData::ensureCompositorProxiedPro pertySet() 317 inline CompositorProxiedPropertySet& ElementRareData::ensureCompositorProxiedPro pertySet()
253 { 318 {
254 if (!m_proxiedProperties) 319 if (!m_proxiedProperties)
255 m_proxiedProperties = CompositorProxiedPropertySet::create(); 320 m_proxiedProperties = CompositorProxiedPropertySet::create();
256 return *m_proxiedProperties; 321 return *m_proxiedProperties;
257 } 322 }
258 323
259 } // namespace 324 } // namespace
260 325
261 #endif // ElementRareData_h 326 #endif // ElementRareData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698