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

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

Issue 262093006: Oilpan: Make the Node hierarchy RefCountedGarbageCollected instead of TreeShared. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Another build fix. Created 6 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 | Annotate | Revision Log
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public DoublyLinkedListNode<ShadowRoot> { 46 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public DoublyLinkedListNode<ShadowRoot> {
47 void* pointers[3]; 47 void* pointers[3];
48 unsigned countersAndFlags[1]; 48 unsigned countersAndFlags[1];
49 }; 49 };
50 50
51 COMPILE_ASSERT(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), shadowroot_sh ould_stay_small); 51 COMPILE_ASSERT(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), shadowroot_sh ould_stay_small);
52 52
53 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type) 53 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type)
54 : DocumentFragment(0, CreateShadowRoot) 54 : DocumentFragment(0, CreateShadowRoot)
55 , TreeScope(*this, document) 55 , TreeScope(*this, document)
56 , m_prev(0) 56 , m_prev(nullptr)
57 , m_next(0) 57 , m_next(nullptr)
58 , m_numberOfStyles(0) 58 , m_numberOfStyles(0)
59 , m_type(type) 59 , m_type(type)
60 , m_registeredWithParentShadowRoot(false) 60 , m_registeredWithParentShadowRoot(false)
61 , m_descendantInsertionPointsIsValid(false) 61 , m_descendantInsertionPointsIsValid(false)
62 { 62 {
63 ScriptWrappable::init(this); 63 ScriptWrappable::init(this);
64 } 64 }
65 65
66 ShadowRoot::~ShadowRoot() 66 ShadowRoot::~ShadowRoot()
67 { 67 {
68 #if !ENABLE(OILPAN)
68 ASSERT(!m_prev); 69 ASSERT(!m_prev);
69 ASSERT(!m_next); 70 ASSERT(!m_next);
70 71
71 #if !ENABLE(OILPAN)
72 if (m_shadowRootRareData && m_shadowRootRareData->styleSheets()) 72 if (m_shadowRootRareData && m_shadowRootRareData->styleSheets())
73 m_shadowRootRareData->styleSheets()->detachFromDocument(); 73 m_shadowRootRareData->styleSheets()->detachFromDocument();
74 74
75 document().styleEngine()->didRemoveShadowRoot(this); 75 document().styleEngine()->didRemoveShadowRoot(this);
76 #endif
77 76
78 #if !ENABLE(OILPAN)
79 // We cannot let ContainerNode destructor call willBeDeletedFromDocument() 77 // We cannot let ContainerNode destructor call willBeDeletedFromDocument()
80 // for this ShadowRoot instance because TreeScope destructor 78 // for this ShadowRoot instance because TreeScope destructor
81 // clears Node::m_treeScope thus ContainerNode is no longer able 79 // clears Node::m_treeScope thus ContainerNode is no longer able
82 // to access it Document reference after that. 80 // to access it Document reference after that.
83 willBeDeletedFromDocument(); 81 willBeDeletedFromDocument();
84 #endif
85 82
86 // We must remove all of our children first before the TreeScope destructor 83 // We must remove all of our children first before the TreeScope destructor
87 // runs so we don't go through TreeScopeAdopter for each child with a 84 // runs so we don't go through TreeScopeAdopter for each child with a
88 // destructed tree scope in each descendant. 85 // destructed tree scope in each descendant.
89 removeDetachedChildren(); 86 removeDetachedChildren();
87 #endif
90 88
91 // We must call clearRareData() here since a ShadowRoot class inherits TreeS cope 89 // We must call clearRareData() here since a ShadowRoot class inherits TreeS cope
92 // as well as Node. See a comment on TreeScope.h for the reason. 90 // as well as Node. See a comment on TreeScope.h for the reason.
93 if (hasRareData()) 91 if (hasRareData())
94 clearRareData(); 92 clearRareData();
95 } 93 }
96 94
97 void ShadowRoot::dispose() 95 void ShadowRoot::dispose()
98 { 96 {
97 #if !ENABLE(OILPAN)
99 removeDetachedChildren(); 98 removeDetachedChildren();
99 #endif
100 } 100 }
101 101
102 ShadowRoot* ShadowRoot::olderShadowRootForBindings() const 102 ShadowRoot* ShadowRoot::olderShadowRootForBindings() const
103 { 103 {
104 ShadowRoot* older = olderShadowRoot(); 104 ShadowRoot* older = olderShadowRoot();
105 while (older && !older->shouldExposeToBindings()) 105 while (older && !older->shouldExposeToBindings())
106 older = older->olderShadowRoot(); 106 older = older->olderShadowRoot();
107 ASSERT(!older || older->shouldExposeToBindings()); 107 ASSERT(!older || older->shouldExposeToBindings());
108 return older; 108 return older;
109 } 109 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 StyleSheetList* ShadowRoot::styleSheets() 332 StyleSheetList* ShadowRoot::styleSheets()
333 { 333 {
334 if (!ensureShadowRootRareData()->styleSheets()) 334 if (!ensureShadowRootRareData()->styleSheets())
335 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); 335 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this));
336 336
337 return m_shadowRootRareData->styleSheets(); 337 return m_shadowRootRareData->styleSheets();
338 } 338 }
339 339
340 void ShadowRoot::trace(Visitor* visitor) 340 void ShadowRoot::trace(Visitor* visitor)
341 { 341 {
342 visitor->trace(m_prev);
343 visitor->trace(m_next);
342 visitor->trace(m_shadowRootRareData); 344 visitor->trace(m_shadowRootRareData);
343 TreeScope::trace(visitor); 345 TreeScope::trace(visitor);
344 DocumentFragment::trace(visitor); 346 DocumentFragment::trace(visitor);
345 } 347 }
346 348
347 } 349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698