OLD | NEW |
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 25 matching lines...) Expand all Loading... |
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/editing/serializers/Serialization.h" | 39 #include "core/editing/serializers/Serialization.h" |
40 #include "core/html/HTMLShadowElement.h" | 40 #include "core/html/HTMLShadowElement.h" |
41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { | 45 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { |
46 #if ENABLE(OILPAN) | |
47 char emptyClassFieldsDueToGCMixinMarker[1]; | 46 char emptyClassFieldsDueToGCMixinMarker[1]; |
48 #endif | |
49 Member<void*> willbeMember[4]; | 47 Member<void*> willbeMember[4]; |
50 unsigned countersAndFlags[1]; | 48 unsigned countersAndFlags[1]; |
51 }; | 49 }; |
52 | 50 |
53 static_assert(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), "ShadowRoot sh
ould stay small"); | 51 static_assert(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), "ShadowRoot sh
ould stay small"); |
54 | 52 |
55 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type) | 53 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type) |
56 : DocumentFragment(0, CreateShadowRoot) | 54 : DocumentFragment(0, CreateShadowRoot) |
57 , TreeScope(*this, document) | 55 , TreeScope(*this, document) |
58 , m_prev(nullptr) | 56 , m_prev(nullptr) |
59 , m_next(nullptr) | 57 , m_next(nullptr) |
60 , m_slotAssignment(nullptr) | 58 , m_slotAssignment(nullptr) |
61 , m_numberOfStyles(0) | 59 , m_numberOfStyles(0) |
62 , m_type(static_cast<unsigned>(type)) | 60 , m_type(static_cast<unsigned>(type)) |
63 , m_registeredWithParentShadowRoot(false) | 61 , m_registeredWithParentShadowRoot(false) |
64 , m_descendantInsertionPointsIsValid(false) | 62 , m_descendantInsertionPointsIsValid(false) |
65 , m_delegatesFocus(false) | 63 , m_delegatesFocus(false) |
66 , m_descendantSlotsIsValid(false) | 64 , m_descendantSlotsIsValid(false) |
67 { | 65 { |
68 } | 66 } |
69 | 67 |
70 ShadowRoot::~ShadowRoot() | 68 ShadowRoot::~ShadowRoot() |
71 { | 69 { |
72 #if !ENABLE(OILPAN) | |
73 DCHECK(!m_prev); | |
74 DCHECK(!m_next); | |
75 | |
76 if (m_shadowRootRareData && m_shadowRootRareData->styleSheets()) | |
77 m_shadowRootRareData->styleSheets()->detachFromDocument(); | |
78 | |
79 document().styleEngine().didRemoveShadowRoot(this); | |
80 | |
81 // We cannot let ContainerNode destructor call willBeDeletedFromDocument() | |
82 // for this ShadowRoot instance because TreeScope destructor | |
83 // clears Node::m_treeScope thus ContainerNode is no longer able | |
84 // to access it Document reference after that. | |
85 willBeDeletedFromDocument(); | |
86 | |
87 // We must remove all of our children first before the TreeScope destructor | |
88 // runs so we don't go through TreeScopeAdopter for each child with a | |
89 // destructed tree scope in each descendant. | |
90 removeDetachedChildren(); | |
91 | |
92 // We must call clearRareData() here since a ShadowRoot class inherits TreeS
cope | |
93 // as well as Node. See a comment on TreeScope.h for the reason. | |
94 if (hasRareData()) | |
95 clearRareData(); | |
96 #endif | |
97 } | 70 } |
98 | 71 |
99 #if !ENABLE(OILPAN) | |
100 void ShadowRoot::dispose() | |
101 { | |
102 removeDetachedChildren(); | |
103 } | |
104 #endif | |
105 | |
106 ShadowRoot* ShadowRoot::olderShadowRootForBindings() const | 72 ShadowRoot* ShadowRoot::olderShadowRootForBindings() const |
107 { | 73 { |
108 ShadowRoot* older = olderShadowRoot(); | 74 ShadowRoot* older = olderShadowRoot(); |
109 while (older && !older->isOpenOrV0()) | 75 while (older && !older->isOpenOrV0()) |
110 older = older->olderShadowRoot(); | 76 older = older->olderShadowRoot(); |
111 DCHECK(!older || older->isOpenOrV0()); | 77 DCHECK(!older || older->isOpenOrV0()); |
112 return older; | 78 return older; |
113 } | 79 } |
114 | 80 |
115 Node* ShadowRoot::cloneNode(bool, ExceptionState& exceptionState) | 81 Node* ShadowRoot::cloneNode(bool, ExceptionState& exceptionState) |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 { | 345 { |
380 visitor->trace(m_prev); | 346 visitor->trace(m_prev); |
381 visitor->trace(m_next); | 347 visitor->trace(m_next); |
382 visitor->trace(m_shadowRootRareData); | 348 visitor->trace(m_shadowRootRareData); |
383 visitor->trace(m_slotAssignment); | 349 visitor->trace(m_slotAssignment); |
384 TreeScope::trace(visitor); | 350 TreeScope::trace(visitor); |
385 DocumentFragment::trace(visitor); | 351 DocumentFragment::trace(visitor); |
386 } | 352 } |
387 | 353 |
388 } // namespace blink | 354 } // namespace blink |
OLD | NEW |