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

Side by Side Diff: third_party/WebKit/Source/core/dom/ElementRareData.h

Issue 1943803002: Move PseudoElements storage to their own object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 Member<InlineCSSStyleDeclaration> m_cssomWrapper; 156 Member<InlineCSSStyleDeclaration> m_cssomWrapper;
157 Member<InlineStylePropertyMap> m_cssomMapWrapper; 157 Member<InlineStylePropertyMap> m_cssomMapWrapper;
158 OwnPtr<CompositorProxiedPropertySet> m_proxiedProperties; 158 OwnPtr<CompositorProxiedPropertySet> m_proxiedProperties;
159 159
160 Member<ElementAnimations> m_elementAnimations; 160 Member<ElementAnimations> m_elementAnimations;
161 Member<NodeIntersectionObserverData> m_intersectionObserverData; 161 Member<NodeIntersectionObserverData> m_intersectionObserverData;
162 162
163 RefPtr<ComputedStyle> m_computedStyle; 163 RefPtr<ComputedStyle> m_computedStyle;
164 Member<V0CustomElementDefinition> m_customElementDefinition; 164 Member<V0CustomElementDefinition> m_customElementDefinition;
165 165
166 Member<PseudoElement> m_generatedBefore; 166 Member<PseudoElementData> m_pseudoElementData;
167 Member<PseudoElement> m_generatedAfter;
168 Member<PseudoElement> m_generatedFirstLetter;
169 Member<PseudoElement> m_backdrop;
170 167
171 explicit ElementRareData(LayoutObject*); 168 explicit ElementRareData(LayoutObject*);
172 }; 169 };
173 170
174 inline LayoutSize defaultMinimumSizeForResizing() 171 inline LayoutSize defaultMinimumSizeForResizing()
175 { 172 {
176 return LayoutSize(LayoutUnit::max(), LayoutUnit::max()); 173 return LayoutSize(LayoutUnit::max(), LayoutUnit::max());
177 } 174 }
178 175
179 inline ElementRareData::ElementRareData(LayoutObject* layoutObject) 176 inline ElementRareData::ElementRareData(LayoutObject* layoutObject)
180 : NodeRareData(layoutObject) 177 : NodeRareData(layoutObject)
181 , m_tabindex(0) 178 , m_tabindex(0)
182 , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) 179 , m_minimumSizeForResizing(defaultMinimumSizeForResizing())
183 , m_classList(nullptr) 180 , m_classList(nullptr)
184 { 181 {
185 m_isElementRareData = true; 182 m_isElementRareData = true;
186 } 183 }
187 184
188 inline ElementRareData::~ElementRareData() 185 inline ElementRareData::~ElementRareData()
189 { 186 {
190 DCHECK(!m_generatedBefore);
191 DCHECK(!m_generatedAfter);
192 DCHECK(!m_generatedFirstLetter);
193 DCHECK(!m_backdrop);
194 } 187 }
195 188
196 inline bool ElementRareData::hasPseudoElements() const 189 inline bool ElementRareData::hasPseudoElements() const
197 { 190 {
198 return m_generatedBefore || m_generatedAfter || m_backdrop || m_generatedFir stLetter; 191 return (m_pseudoElementData && m_pseudoElementData->hasPseudoElements());
199 } 192 }
200 193
201 inline void ElementRareData::clearPseudoElements() 194 inline void ElementRareData::clearPseudoElements()
202 { 195 {
203 setPseudoElement(PseudoIdBefore, nullptr); 196 if (m_pseudoElementData)
sof 2016/05/05 06:54:41 How about (unconditionally) doing m_pseudoElementD
ramya.v 2016/05/05 08:57:09 If we do unconditionally, if clearPseudoElements i
sof 2016/05/05 13:21:25 m_pseudoElementClearData.clear() would work just f
ramya.v 2016/05/06 04:07:13 Hi added suggested changes. Few tests are failing
204 setPseudoElement(PseudoIdAfter, nullptr); 197 m_pseudoElementData->clearPseudoElements();
205 setPseudoElement(PseudoIdBackdrop, nullptr);
206 setPseudoElement(PseudoIdFirstLetter, nullptr);
207 } 198 }
208 199
209 inline void ElementRareData::setPseudoElement(PseudoId pseudoId, PseudoElement* element) 200 inline void ElementRareData::setPseudoElement(PseudoId pseudoId, PseudoElement* element)
210 { 201 {
211 switch (pseudoId) { 202 if (!m_pseudoElementData)
212 case PseudoIdBefore: 203 m_pseudoElementData = PseudoElementData::create();
213 if (m_generatedBefore) 204 m_pseudoElementData->setPseudoElement(pseudoId, element);
214 m_generatedBefore->dispose();
215 m_generatedBefore = element;
216 break;
217 case PseudoIdAfter:
218 if (m_generatedAfter)
219 m_generatedAfter->dispose();
220 m_generatedAfter = element;
221 break;
222 case PseudoIdBackdrop:
223 if (m_backdrop)
224 m_backdrop->dispose();
225 m_backdrop = element;
226 break;
227 case PseudoIdFirstLetter:
228 if (m_generatedFirstLetter)
229 m_generatedFirstLetter->dispose();
230 m_generatedFirstLetter = element;
231 break;
232 default:
233 ASSERT_NOT_REACHED();
234 }
235 } 205 }
236 206
237 inline PseudoElement* ElementRareData::pseudoElement(PseudoId pseudoId) const 207 inline PseudoElement* ElementRareData::pseudoElement(PseudoId pseudoId) const
238 { 208 {
239 switch (pseudoId) { 209 if (!m_pseudoElementData)
240 case PseudoIdBefore: 210 return nullptr;
241 return m_generatedBefore.get(); 211 return m_pseudoElementData->pseudoElement(pseudoId);
242 case PseudoIdAfter:
243 return m_generatedAfter.get();
244 case PseudoIdBackdrop:
245 return m_backdrop.get();
246 case PseudoIdFirstLetter:
247 return m_generatedFirstLetter.get();
248 default:
249 return 0;
250 }
251 } 212 }
252 213
253 inline void ElementRareData::incrementCompositorProxiedProperties(uint32_t prope rties) 214 inline void ElementRareData::incrementCompositorProxiedProperties(uint32_t prope rties)
254 { 215 {
255 ensureCompositorProxiedPropertySet().increment(properties); 216 ensureCompositorProxiedPropertySet().increment(properties);
256 } 217 }
257 218
258 inline void ElementRareData::decrementCompositorProxiedProperties(uint32_t prope rties) 219 inline void ElementRareData::decrementCompositorProxiedProperties(uint32_t prope rties)
259 { 220 {
260 m_proxiedProperties->decrement(properties); 221 m_proxiedProperties->decrement(properties);
261 if (m_proxiedProperties->isEmpty()) 222 if (m_proxiedProperties->isEmpty())
262 clearCompositorProxiedPropertySet(); 223 clearCompositorProxiedPropertySet();
263 } 224 }
264 225
265 inline CompositorProxiedPropertySet& ElementRareData::ensureCompositorProxiedPro pertySet() 226 inline CompositorProxiedPropertySet& ElementRareData::ensureCompositorProxiedPro pertySet()
266 { 227 {
267 if (!m_proxiedProperties) 228 if (!m_proxiedProperties)
268 m_proxiedProperties = CompositorProxiedPropertySet::create(); 229 m_proxiedProperties = CompositorProxiedPropertySet::create();
269 return *m_proxiedProperties; 230 return *m_proxiedProperties;
270 } 231 }
271 232
272 } // namespace blink 233 } // namespace blink
273 234
274 #endif // ElementRareData_h 235 #endif // ElementRareData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698