OLD | NEW |
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/DatasetDOMStringMap.h" | 27 #include "core/dom/DatasetDOMStringMap.h" |
| 28 #include "core/dom/IntersectionObservation.h" |
| 29 #include "core/dom/IntersectionObserver.h" |
28 #include "core/dom/NamedNodeMap.h" | 30 #include "core/dom/NamedNodeMap.h" |
29 #include "core/dom/NodeRareData.h" | 31 #include "core/dom/NodeRareData.h" |
30 #include "core/dom/PseudoElement.h" | 32 #include "core/dom/PseudoElement.h" |
31 #include "core/dom/custom/CustomElementDefinition.h" | 33 #include "core/dom/custom/CustomElementDefinition.h" |
32 #include "core/dom/shadow/ElementShadow.h" | 34 #include "core/dom/shadow/ElementShadow.h" |
33 #include "core/html/ClassList.h" | 35 #include "core/html/ClassList.h" |
34 #include "core/style/StyleInheritedData.h" | 36 #include "core/style/StyleInheritedData.h" |
35 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
| 38 #include "wtf/HashSet.h" |
36 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
| 40 #include "wtf/WeakPtr.h" |
37 | 41 |
38 namespace blink { | 42 namespace blink { |
39 | 43 |
40 class HTMLElement; | 44 class HTMLElement; |
41 | 45 |
42 class ElementRareData : public NodeRareData { | 46 class ElementRareData : public NodeRareData { |
43 public: | 47 public: |
44 static ElementRareData* create(LayoutObject* layoutObject) | 48 static ElementRareData* create(LayoutObject* layoutObject) |
45 { | 49 { |
46 return new ElementRareData(layoutObject); | 50 return new ElementRareData(layoutObject); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 104 |
101 IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } | 105 IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } |
102 void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = si
ze; } | 106 void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = si
ze; } |
103 | 107 |
104 ElementAnimations* elementAnimations() { return m_elementAnimations.get(); } | 108 ElementAnimations* elementAnimations() { return m_elementAnimations.get(); } |
105 void setElementAnimations(ElementAnimations* elementAnimations) | 109 void setElementAnimations(ElementAnimations* elementAnimations) |
106 { | 110 { |
107 m_elementAnimations = elementAnimations; | 111 m_elementAnimations = elementAnimations; |
108 } | 112 } |
109 | 113 |
| 114 bool hasIntersectionObserver() const |
| 115 { |
| 116 return m_intersectionObservers && m_intersectionObservers->size(); |
| 117 } |
| 118 |
| 119 IntersectionObserver::WeakHashSet& intersectionObservers() |
| 120 { |
| 121 if (!m_intersectionObservers) |
| 122 m_intersectionObservers = new IntersectionObserver::WeakHashSet(); |
| 123 return *m_intersectionObservers; |
| 124 } |
| 125 |
| 126 bool hasIntersectionObservation() const |
| 127 { |
| 128 return m_intersectionObservations && m_intersectionObservations->size(); |
| 129 } |
| 130 |
| 131 IntersectionObservation::HashSet& intersectionObservations() |
| 132 { |
| 133 if (!m_intersectionObservations) |
| 134 m_intersectionObservations = new IntersectionObservation::HashSet(); |
| 135 return *m_intersectionObservations; |
| 136 } |
| 137 |
| 138 void deactivateAllIntersectionObservers() |
| 139 { |
| 140 if (!m_intersectionObservers) |
| 141 return; |
| 142 for (auto& observer: *m_intersectionObservers) |
| 143 observer->setActive(false); |
| 144 } |
| 145 |
| 146 void deactivateAllIntersectionObservations() |
| 147 { |
| 148 if (!m_intersectionObservations) |
| 149 return; |
| 150 for (auto& observation: *m_intersectionObservations) |
| 151 observation->setActive(false); |
| 152 } |
| 153 |
| 154 #if !ENABLE(OILPAN) |
| 155 WeakPtr<Element> createWeakPtr(Element* element) |
| 156 { |
| 157 if (!m_weakPointerFactory) |
| 158 m_weakPointerFactory = adoptPtrWillBeNoop(new WeakPtrFactory<Element
>(element)); |
| 159 return m_weakPointerFactory->createWeakPtr(); |
| 160 } |
| 161 #endif |
| 162 |
110 bool hasPseudoElements() const; | 163 bool hasPseudoElements() const; |
111 void clearPseudoElements(); | 164 void clearPseudoElements(); |
112 | 165 |
113 uint32_t incrementProxyCount() { return ++m_proxyCount; } | 166 uint32_t incrementProxyCount() { return ++m_proxyCount; } |
114 uint32_t decrementProxyCount() | 167 uint32_t decrementProxyCount() |
115 { | 168 { |
116 ASSERT(m_proxyCount); | 169 ASSERT(m_proxyCount); |
117 return --m_proxyCount; | 170 return --m_proxyCount; |
118 } | 171 } |
119 uint32_t proxyCount() const { return m_proxyCount; } | 172 uint32_t proxyCount() const { return m_proxyCount; } |
(...skipping 14 matching lines...) Expand all Loading... |
134 unsigned short m_proxyCount; | 187 unsigned short m_proxyCount; |
135 | 188 |
136 LayoutSize m_minimumSizeForResizing; | 189 LayoutSize m_minimumSizeForResizing; |
137 IntSize m_savedLayerScrollOffset; | 190 IntSize m_savedLayerScrollOffset; |
138 | 191 |
139 OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset; | 192 OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset; |
140 OwnPtrWillBeMember<ClassList> m_classList; | 193 OwnPtrWillBeMember<ClassList> m_classList; |
141 OwnPtrWillBeMember<ElementShadow> m_shadow; | 194 OwnPtrWillBeMember<ElementShadow> m_shadow; |
142 OwnPtrWillBeMember<NamedNodeMap> m_attributeMap; | 195 OwnPtrWillBeMember<NamedNodeMap> m_attributeMap; |
143 OwnPtrWillBeMember<AttrNodeList> m_attrNodeList; | 196 OwnPtrWillBeMember<AttrNodeList> m_attrNodeList; |
| 197 OwnPtrWillBeMember<InlineCSSStyleDeclaration> m_cssomWrapper; |
| 198 |
| 199 #if !ENABLE(OILPAN) |
| 200 OwnPtrWillBeMember<WeakPtrFactory<Element>> m_weakPointerFactory; |
| 201 #endif |
| 202 |
144 PersistentWillBeMember<ElementAnimations> m_elementAnimations; | 203 PersistentWillBeMember<ElementAnimations> m_elementAnimations; |
145 OwnPtrWillBeMember<InlineCSSStyleDeclaration> m_cssomWrapper; | 204 // Note that m_intersectionObservers will contain both observers for which t
his element is target, |
| 205 // and observers for which this element is root. To tell them apart, check
(observer->root() == element). |
146 | 206 |
147 RefPtr<ComputedStyle> m_computedStyle; | 207 RefPtr<ComputedStyle> m_computedStyle; |
148 RefPtrWillBeMember<CustomElementDefinition> m_customElementDefinition; | 208 RefPtrWillBeMember<CustomElementDefinition> m_customElementDefinition; |
149 | 209 |
150 RefPtrWillBeMember<PseudoElement> m_generatedBefore; | 210 RefPtrWillBeMember<PseudoElement> m_generatedBefore; |
151 RefPtrWillBeMember<PseudoElement> m_generatedAfter; | 211 RefPtrWillBeMember<PseudoElement> m_generatedAfter; |
152 RefPtrWillBeMember<PseudoElement> m_generatedFirstLetter; | 212 RefPtrWillBeMember<PseudoElement> m_generatedFirstLetter; |
153 RefPtrWillBeMember<PseudoElement> m_backdrop; | 213 RefPtrWillBeMember<PseudoElement> m_backdrop; |
154 | 214 |
| 215 // IntersectionObservers for which this element is root. |
| 216 PersistentWillBeMember<IntersectionObserver::WeakHashSet> m_intersectionObse
rvers; |
| 217 // IntersectionObservations for which this element is target. |
| 218 PersistentWillBeMember<IntersectionObservation::HashSet> m_intersectionObser
vations; |
| 219 |
155 explicit ElementRareData(LayoutObject*); | 220 explicit ElementRareData(LayoutObject*); |
156 }; | 221 }; |
157 | 222 |
158 inline LayoutSize defaultMinimumSizeForResizing() | 223 inline LayoutSize defaultMinimumSizeForResizing() |
159 { | 224 { |
160 return LayoutSize(LayoutUnit::max(), LayoutUnit::max()); | 225 return LayoutSize(LayoutUnit::max(), LayoutUnit::max()); |
161 } | 226 } |
162 | 227 |
163 inline ElementRareData::ElementRareData(LayoutObject* layoutObject) | 228 inline ElementRareData::ElementRareData(LayoutObject* layoutObject) |
164 : NodeRareData(layoutObject) | 229 : NodeRareData(layoutObject) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 case FIRST_LETTER: | 300 case FIRST_LETTER: |
236 return m_generatedFirstLetter.get(); | 301 return m_generatedFirstLetter.get(); |
237 default: | 302 default: |
238 return 0; | 303 return 0; |
239 } | 304 } |
240 } | 305 } |
241 | 306 |
242 } // namespace | 307 } // namespace |
243 | 308 |
244 #endif // ElementRareData_h | 309 #endif // ElementRareData_h |
OLD | NEW |