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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp

Issue 1904703002: Move v0 things from ShadowRootRareData into ShadowRootRareDataV0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 4 years, 8 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 18 matching lines...) Expand all
29 #include "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
30 #include "core/css/StyleSheetList.h" 30 #include "core/css/StyleSheetList.h"
31 #include "core/css/resolver/StyleResolver.h" 31 #include "core/css/resolver/StyleResolver.h"
32 #include "core/css/resolver/StyleSharingDepthScope.h" 32 #include "core/css/resolver/StyleSharingDepthScope.h"
33 #include "core/dom/ElementTraversal.h" 33 #include "core/dom/ElementTraversal.h"
34 #include "core/dom/StyleEngine.h" 34 #include "core/dom/StyleEngine.h"
35 #include "core/dom/Text.h" 35 #include "core/dom/Text.h"
36 #include "core/dom/shadow/ElementShadow.h" 36 #include "core/dom/shadow/ElementShadow.h"
37 #include "core/dom/shadow/InsertionPoint.h" 37 #include "core/dom/shadow/InsertionPoint.h"
38 #include "core/dom/shadow/ShadowRootRareData.h" 38 #include "core/dom/shadow/ShadowRootRareData.h"
39 #include "core/dom/shadow/ShadowRootRareDataV0.h"
39 #include "core/editing/serializers/Serialization.h" 40 #include "core/editing/serializers/Serialization.h"
40 #include "core/html/HTMLShadowElement.h" 41 #include "core/html/HTMLShadowElement.h"
41 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
42 43
43 namespace blink { 44 namespace blink {
44 45
45 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public DoublyLinkedListNode<ShadowRoot> { 46 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public DoublyLinkedListNode<ShadowRoot> {
46 char emptyClassFieldsDueToGCMixinMarker[1]; 47 char emptyClassFieldsDueToGCMixinMarker[1];
47 Member<void*> willbeMember[4]; 48 Member<void*> willbeMember[5];
48 unsigned countersAndFlags[1]; 49 unsigned countersAndFlags[1];
49 }; 50 };
50 51
51 static_assert(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), "ShadowRoot sh ould stay small"); 52 static_assert(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), "ShadowRoot sh ould stay small");
52 53
53 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type) 54 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type)
54 : DocumentFragment(0, CreateShadowRoot) 55 : DocumentFragment(0, CreateShadowRoot)
55 , TreeScope(*this, document) 56 , TreeScope(*this, document)
56 , m_prev(nullptr) 57 , m_prev(nullptr)
57 , m_next(nullptr) 58 , m_next(nullptr)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 188
188 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData() 189 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData()
189 { 190 {
190 if (m_shadowRootRareData) 191 if (m_shadowRootRareData)
191 return m_shadowRootRareData.get(); 192 return m_shadowRootRareData.get();
192 193
193 m_shadowRootRareData = new ShadowRootRareData; 194 m_shadowRootRareData = new ShadowRootRareData;
194 return m_shadowRootRareData.get(); 195 return m_shadowRootRareData.get();
195 } 196 }
196 197
198 ShadowRootRareDataV0* ShadowRoot::ensureShadowRootRareDataV0()
199 {
200 if (m_shadowRootRareDataV0)
201 return m_shadowRootRareDataV0.get();
202
203 m_shadowRootRareDataV0 = new ShadowRootRareDataV0;
204 return m_shadowRootRareDataV0.get();
205 }
206
197 bool ShadowRoot::containsShadowElements() const 207 bool ShadowRoot::containsShadowElements() const
198 { 208 {
199 return m_shadowRootRareData ? m_shadowRootRareData->containsShadowElements() : 0; 209 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->containsShadowElemen ts() : false;
200 } 210 }
201 211
202 bool ShadowRoot::containsContentElements() const 212 bool ShadowRoot::containsContentElements() const
203 { 213 {
204 return m_shadowRootRareData ? m_shadowRootRareData->containsContentElements( ) : 0; 214 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->containsContentEleme nts() : false;
205 } 215 }
206 216
207 bool ShadowRoot::containsShadowRoots() const 217 bool ShadowRoot::containsShadowRoots() const
208 { 218 {
209 return m_shadowRootRareData ? m_shadowRootRareData->containsShadowRoots() : 0; 219 return m_shadowRootRareData ? m_shadowRootRareData->containsShadowRoots() : false;
210 } 220 }
211 221
212 unsigned ShadowRoot::descendantShadowElementCount() const 222 unsigned ShadowRoot::descendantShadowElementCount() const
213 { 223 {
214 return m_shadowRootRareData ? m_shadowRootRareData->descendantShadowElementC ount() : 0; 224 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->descendantShadowElem entCount() : 0;
215 } 225 }
216 226
217 HTMLShadowElement* ShadowRoot::shadowInsertionPointOfYoungerShadowRoot() const 227 HTMLShadowElement* ShadowRoot::shadowInsertionPointOfYoungerShadowRoot() const
218 { 228 {
219 return m_shadowRootRareData ? m_shadowRootRareData->shadowInsertionPointOfYo ungerShadowRoot() : 0; 229 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->shadowInsertionPoint OfYoungerShadowRoot() : nullptr;
220 } 230 }
221 231
222 void ShadowRoot::setShadowInsertionPointOfYoungerShadowRoot(HTMLShadowElement* s hadowInsertionPoint) 232 void ShadowRoot::setShadowInsertionPointOfYoungerShadowRoot(HTMLShadowElement* s hadowInsertionPoint)
223 { 233 {
224 if (!m_shadowRootRareData && !shadowInsertionPoint) 234 if (!m_shadowRootRareDataV0 && !shadowInsertionPoint)
225 return; 235 return;
226 ensureShadowRootRareData()->setShadowInsertionPointOfYoungerShadowRoot(shado wInsertionPoint); 236 ensureShadowRootRareDataV0()->setShadowInsertionPointOfYoungerShadowRoot(sha dowInsertionPoint);
227 } 237 }
228 238
229 void ShadowRoot::didAddInsertionPoint(InsertionPoint* insertionPoint) 239 void ShadowRoot::didAddInsertionPoint(InsertionPoint* insertionPoint)
230 { 240 {
231 ensureShadowRootRareData()->didAddInsertionPoint(insertionPoint); 241 ensureShadowRootRareDataV0()->didAddInsertionPoint(insertionPoint);
232 invalidateDescendantInsertionPoints(); 242 invalidateDescendantInsertionPoints();
233 } 243 }
234 244
235 void ShadowRoot::didRemoveInsertionPoint(InsertionPoint* insertionPoint) 245 void ShadowRoot::didRemoveInsertionPoint(InsertionPoint* insertionPoint)
236 { 246 {
237 m_shadowRootRareData->didRemoveInsertionPoint(insertionPoint); 247 m_shadowRootRareDataV0->didRemoveInsertionPoint(insertionPoint);
238 invalidateDescendantInsertionPoints(); 248 invalidateDescendantInsertionPoints();
239 } 249 }
240 250
241 void ShadowRoot::addChildShadowRoot() 251 void ShadowRoot::addChildShadowRoot()
242 { 252 {
243 ensureShadowRootRareData()->didAddChildShadowRoot(); 253 ensureShadowRootRareData()->didAddChildShadowRoot();
244 } 254 }
245 255
246 void ShadowRoot::removeChildShadowRoot() 256 void ShadowRoot::removeChildShadowRoot()
247 { 257 {
248 // FIXME: Why isn't this an ASSERT? 258 // FIXME: Why isn't this an ASSERT?
249 if (!m_shadowRootRareData) 259 if (!m_shadowRootRareData)
250 return; 260 return;
251 m_shadowRootRareData->didRemoveChildShadowRoot(); 261 m_shadowRootRareData->didRemoveChildShadowRoot();
252 } 262 }
253 263
254 unsigned ShadowRoot::childShadowRootCount() const 264 unsigned ShadowRoot::childShadowRootCount() const
255 { 265 {
256 return m_shadowRootRareData ? m_shadowRootRareData->childShadowRootCount() : 0; 266 return m_shadowRootRareData ? m_shadowRootRareData->childShadowRootCount() : 0;
257 } 267 }
258 268
259 void ShadowRoot::invalidateDescendantInsertionPoints() 269 void ShadowRoot::invalidateDescendantInsertionPoints()
260 { 270 {
261 m_descendantInsertionPointsIsValid = false; 271 m_descendantInsertionPointsIsValid = false;
262 m_shadowRootRareData->clearDescendantInsertionPoints(); 272 m_shadowRootRareDataV0->clearDescendantInsertionPoints();
263 } 273 }
264 274
265 const HeapVector<Member<InsertionPoint>>& ShadowRoot::descendantInsertionPoints( ) 275 const HeapVector<Member<InsertionPoint>>& ShadowRoot::descendantInsertionPoints( )
266 { 276 {
267 DEFINE_STATIC_LOCAL(HeapVector<Member<InsertionPoint>>, emptyList, (new Heap Vector<Member<InsertionPoint>>)); 277 DEFINE_STATIC_LOCAL(HeapVector<Member<InsertionPoint>>, emptyList, (new Heap Vector<Member<InsertionPoint>>));
268 if (m_shadowRootRareData && m_descendantInsertionPointsIsValid) 278 if (m_shadowRootRareDataV0 && m_descendantInsertionPointsIsValid)
269 return m_shadowRootRareData->descendantInsertionPoints(); 279 return m_shadowRootRareDataV0->descendantInsertionPoints();
270 280
271 m_descendantInsertionPointsIsValid = true; 281 m_descendantInsertionPointsIsValid = true;
272 282
273 if (!containsInsertionPoints()) 283 if (!containsInsertionPoints())
274 return emptyList; 284 return emptyList;
275 285
276 HeapVector<Member<InsertionPoint>> insertionPoints; 286 HeapVector<Member<InsertionPoint>> insertionPoints;
277 for (InsertionPoint& insertionPoint : Traversal<InsertionPoint>::descendants Of(*this)) 287 for (InsertionPoint& insertionPoint : Traversal<InsertionPoint>::descendants Of(*this))
278 insertionPoints.append(&insertionPoint); 288 insertionPoints.append(&insertionPoint);
279 289
280 ensureShadowRootRareData()->setDescendantInsertionPoints(insertionPoints); 290 ensureShadowRootRareDataV0()->setDescendantInsertionPoints(insertionPoints);
281 291
282 return m_shadowRootRareData->descendantInsertionPoints(); 292 return m_shadowRootRareDataV0->descendantInsertionPoints();
283 } 293 }
284 294
285 StyleSheetList* ShadowRoot::styleSheets() 295 StyleSheetList* ShadowRoot::styleSheets()
286 { 296 {
287 if (!ensureShadowRootRareData()->styleSheets()) 297 if (!ensureShadowRootRareData()->styleSheets())
288 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); 298 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this));
289 299
290 return m_shadowRootRareData->styleSheets(); 300 return m_shadowRootRareData->styleSheets();
291 } 301 }
292 302
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (!m_slotAssignment) 349 if (!m_slotAssignment)
340 m_slotAssignment = SlotAssignment::create(); 350 m_slotAssignment = SlotAssignment::create();
341 m_slotAssignment->resolveAssignment(*this); 351 m_slotAssignment->resolveAssignment(*this);
342 } 352 }
343 353
344 DEFINE_TRACE(ShadowRoot) 354 DEFINE_TRACE(ShadowRoot)
345 { 355 {
346 visitor->trace(m_prev); 356 visitor->trace(m_prev);
347 visitor->trace(m_next); 357 visitor->trace(m_next);
348 visitor->trace(m_shadowRootRareData); 358 visitor->trace(m_shadowRootRareData);
359 visitor->trace(m_shadowRootRareDataV0);
349 visitor->trace(m_slotAssignment); 360 visitor->trace(m_slotAssignment);
350 TreeScope::trace(visitor); 361 TreeScope::trace(visitor);
351 DocumentFragment::trace(visitor); 362 DocumentFragment::trace(visitor);
352 } 363 }
353 364
354 } // namespace blink 365 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h ('k') | third_party/WebKit/Source/core/dom/shadow/ShadowRootRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698