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 23 matching lines...) Expand all Loading... |
34 #include "sky/engine/core/dom/StyleEngine.h" | 34 #include "sky/engine/core/dom/StyleEngine.h" |
35 #include "sky/engine/core/dom/Text.h" | 35 #include "sky/engine/core/dom/Text.h" |
36 #include "sky/engine/core/dom/shadow/ElementShadow.h" | 36 #include "sky/engine/core/dom/shadow/ElementShadow.h" |
37 #include "sky/engine/core/dom/shadow/InsertionPoint.h" | 37 #include "sky/engine/core/dom/shadow/InsertionPoint.h" |
38 #include "sky/engine/core/dom/shadow/ShadowRootRareData.h" | 38 #include "sky/engine/core/dom/shadow/ShadowRootRareData.h" |
39 #include "sky/engine/core/editing/markup.h" | 39 #include "sky/engine/core/editing/markup.h" |
40 #include "sky/engine/public/platform/Platform.h" | 40 #include "sky/engine/public/platform/Platform.h" |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { | 44 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { |
45 void* pointers[3]; | 45 void* pointers[1]; |
46 unsigned countersAndFlags[1]; | 46 unsigned countersAndFlags[1]; |
47 }; | 47 }; |
48 | 48 |
49 COMPILE_ASSERT(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), shadowroot_sh
ould_stay_small); | 49 COMPILE_ASSERT(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), shadowroot_sh
ould_stay_small); |
50 | 50 |
51 ShadowRoot::ShadowRoot(Document& document) | 51 ShadowRoot::ShadowRoot(Document& document) |
52 : DocumentFragment(0, CreateShadowRoot) | 52 : DocumentFragment(0, CreateShadowRoot) |
53 , TreeScope(*this, document) | 53 , TreeScope(*this, document) |
54 , m_prev(nullptr) | |
55 , m_next(nullptr) | |
56 , m_numberOfStyles(0) | 54 , m_numberOfStyles(0) |
57 , m_registeredWithParentShadowRoot(false) | 55 , m_registeredWithParentShadowRoot(false) |
58 , m_descendantInsertionPointsIsValid(false) | 56 , m_descendantInsertionPointsIsValid(false) |
59 { | 57 { |
60 } | 58 } |
61 | 59 |
62 ShadowRoot::~ShadowRoot() | 60 ShadowRoot::~ShadowRoot() |
63 { | 61 { |
64 #if !ENABLE(OILPAN) | |
65 ASSERT(!m_prev); | |
66 ASSERT(!m_next); | |
67 | |
68 if (m_shadowRootRareData && m_shadowRootRareData->styleSheets()) | 62 if (m_shadowRootRareData && m_shadowRootRareData->styleSheets()) |
69 m_shadowRootRareData->styleSheets()->detachFromDocument(); | 63 m_shadowRootRareData->styleSheets()->detachFromDocument(); |
70 | 64 |
71 document().styleEngine()->didRemoveShadowRoot(this); | 65 document().styleEngine()->didRemoveShadowRoot(this); |
72 | 66 |
73 // We cannot let ContainerNode destructor call willBeDeletedFromDocument() | 67 // We cannot let ContainerNode destructor call willBeDeletedFromDocument() |
74 // for this ShadowRoot instance because TreeScope destructor | 68 // for this ShadowRoot instance because TreeScope destructor |
75 // clears Node::m_treeScope thus ContainerNode is no longer able | 69 // clears Node::m_treeScope thus ContainerNode is no longer able |
76 // to access it Document reference after that. | 70 // to access it Document reference after that. |
77 willBeDeletedFromDocument(); | 71 willBeDeletedFromDocument(); |
78 | 72 |
79 // We must remove all of our children first before the TreeScope destructor | 73 // We must remove all of our children first before the TreeScope destructor |
80 // runs so we don't go through TreeScopeAdopter for each child with a | 74 // runs so we don't go through TreeScopeAdopter for each child with a |
81 // destructed tree scope in each descendant. | 75 // destructed tree scope in each descendant. |
82 removeDetachedChildren(); | 76 removeDetachedChildren(); |
83 | 77 |
84 // We must call clearRareData() here since a ShadowRoot class inherits TreeS
cope | 78 // We must call clearRareData() here since a ShadowRoot class inherits TreeS
cope |
85 // as well as Node. See a comment on TreeScope.h for the reason. | 79 // as well as Node. See a comment on TreeScope.h for the reason. |
86 if (hasRareData()) | 80 if (hasRareData()) |
87 clearRareData(); | 81 clearRareData(); |
88 #endif | |
89 } | 82 } |
90 | 83 |
91 #if !ENABLE(OILPAN) | |
92 void ShadowRoot::dispose() | 84 void ShadowRoot::dispose() |
93 { | 85 { |
94 removeDetachedChildren(); | 86 removeDetachedChildren(); |
95 } | 87 } |
96 #endif | |
97 | 88 |
98 PassRefPtr<Node> ShadowRoot::cloneNode(bool, ExceptionState& exceptionState) | 89 PassRefPtr<Node> ShadowRoot::cloneNode(bool, ExceptionState& exceptionState) |
99 { | 90 { |
100 exceptionState.throwDOMException(DataCloneError, "ShadowRoot nodes are not c
lonable."); | 91 exceptionState.throwDOMException(DataCloneError, "ShadowRoot nodes are not c
lonable."); |
101 return nullptr; | 92 return nullptr; |
102 } | 93 } |
103 | 94 |
104 void ShadowRoot::recalcStyle(StyleRecalcChange change) | 95 void ShadowRoot::recalcStyle(StyleRecalcChange change) |
105 { | 96 { |
106 if (styleChangeType() >= SubtreeStyleChange) | 97 if (styleChangeType() >= SubtreeStyleChange) |
(...skipping 16 matching lines...) Expand all Loading... |
123 } | 114 } |
124 } | 115 } |
125 | 116 |
126 clearChildNeedsStyleRecalc(); | 117 clearChildNeedsStyleRecalc(); |
127 } | 118 } |
128 | 119 |
129 void ShadowRoot::insertedInto(ContainerNode* insertionPoint) | 120 void ShadowRoot::insertedInto(ContainerNode* insertionPoint) |
130 { | 121 { |
131 DocumentFragment::insertedInto(insertionPoint); | 122 DocumentFragment::insertedInto(insertionPoint); |
132 | 123 |
133 if (!insertionPoint->inDocument() || !isOldest()) | 124 if (!insertionPoint->inDocument()) |
134 return; | 125 return; |
135 | 126 |
136 // FIXME: When parsing <video controls>, insertedInto() is called many times
without invoking removedFrom. | 127 // FIXME: When parsing <video controls>, insertedInto() is called many times
without invoking removedFrom. |
137 // For now, we check m_registeredWithParentShadowroot. We would like to ASSE
RT(!m_registeredShadowRoot) here. | 128 // For now, we check m_registeredWithParentShadowroot. We would like to ASSE
RT(!m_registeredShadowRoot) here. |
138 // https://bugs.webkit.org/show_bug.cig?id=101316 | 129 // https://bugs.webkit.org/show_bug.cig?id=101316 |
139 if (m_registeredWithParentShadowRoot) | 130 if (m_registeredWithParentShadowRoot) |
140 return; | 131 return; |
141 | 132 |
142 if (ShadowRoot* root = host()->containingShadowRoot()) { | 133 if (ShadowRoot* root = host()->containingShadowRoot()) { |
143 root->addChildShadowRoot(); | 134 root->addChildShadowRoot(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 238 |
248 StyleSheetList* ShadowRoot::styleSheets() | 239 StyleSheetList* ShadowRoot::styleSheets() |
249 { | 240 { |
250 if (!ensureShadowRootRareData()->styleSheets()) | 241 if (!ensureShadowRootRareData()->styleSheets()) |
251 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); | 242 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); |
252 | 243 |
253 return m_shadowRootRareData->styleSheets(); | 244 return m_shadowRootRareData->styleSheets(); |
254 } | 245 } |
255 | 246 |
256 } | 247 } |
OLD | NEW |