| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { | 42 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { |
| 43 void* pointers[1]; | 43 void* pointers[1]; |
| 44 unsigned countersAndFlags[1]; | 44 unsigned countersAndFlags[1]; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 COMPILE_ASSERT(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), shadowroot_sh
ould_stay_small); | 47 COMPILE_ASSERT(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), shadowroot_sh
ould_stay_small); |
| 48 | 48 |
| 49 ShadowRoot::ShadowRoot(Document& document) | 49 ShadowRoot::ShadowRoot(Document& document) |
| 50 : DocumentFragment(0, CreateShadowRoot) | 50 : DocumentFragment(0, CreateShadowRoot) |
| 51 , TreeScope(*this, document) | 51 , TreeScope(*this, document) |
| 52 , m_registeredWithParentShadowRoot(false) | |
| 53 , m_descendantInsertionPointsIsValid(false) | 52 , m_descendantInsertionPointsIsValid(false) |
| 54 { | 53 { |
| 55 } | 54 } |
| 56 | 55 |
| 57 ShadowRoot::~ShadowRoot() | 56 ShadowRoot::~ShadowRoot() |
| 58 { | 57 { |
| 59 document().styleEngine()->didRemoveShadowRoot(this); | 58 document().styleEngine()->didRemoveShadowRoot(this); |
| 60 | 59 |
| 61 // We cannot let ContainerNode destructor call willBeDeletedFromDocument() | 60 // We cannot let ContainerNode destructor call willBeDeletedFromDocument() |
| 62 // for this ShadowRoot instance because TreeScope destructor | 61 // for this ShadowRoot instance because TreeScope destructor |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 107 } |
| 109 } | 108 } |
| 110 | 109 |
| 111 clearChildNeedsStyleRecalc(); | 110 clearChildNeedsStyleRecalc(); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void ShadowRoot::insertedInto(ContainerNode* insertionPoint) | 113 void ShadowRoot::insertedInto(ContainerNode* insertionPoint) |
| 115 { | 114 { |
| 116 DocumentFragment::insertedInto(insertionPoint); | 115 DocumentFragment::insertedInto(insertionPoint); |
| 117 | 116 |
| 118 if (!insertionPoint->inDocument()) | 117 if (ShadowRoot* root = host()->containingShadowRoot()) |
| 119 return; | |
| 120 | |
| 121 // FIXME: When parsing <video controls>, insertedInto() is called many times
without invoking removedFrom. | |
| 122 // For now, we check m_registeredWithParentShadowroot. We would like to ASSE
RT(!m_registeredShadowRoot) here. | |
| 123 // https://bugs.webkit.org/show_bug.cig?id=101316 | |
| 124 if (m_registeredWithParentShadowRoot) | |
| 125 return; | |
| 126 | |
| 127 if (ShadowRoot* root = host()->containingShadowRoot()) { | |
| 128 root->addChildShadowRoot(); | 118 root->addChildShadowRoot(); |
| 129 m_registeredWithParentShadowRoot = true; | |
| 130 } | |
| 131 } | 119 } |
| 132 | 120 |
| 133 void ShadowRoot::removedFrom(ContainerNode* insertionPoint) | 121 void ShadowRoot::removedFrom(ContainerNode* insertionPoint) |
| 134 { | 122 { |
| 135 if (insertionPoint->inDocument() && m_registeredWithParentShadowRoot) { | 123 ShadowRoot* root = host()->containingShadowRoot(); |
| 136 ShadowRoot* root = host()->containingShadowRoot(); | 124 if (!root) |
| 137 if (!root) | 125 root = insertionPoint->containingShadowRoot(); |
| 138 root = insertionPoint->containingShadowRoot(); | 126 if (root) |
| 139 if (root) | 127 root->removeChildShadowRoot(); |
| 140 root->removeChildShadowRoot(); | |
| 141 m_registeredWithParentShadowRoot = false; | |
| 142 } | |
| 143 | 128 |
| 144 DocumentFragment::removedFrom(insertionPoint); | 129 DocumentFragment::removedFrom(insertionPoint); |
| 145 } | 130 } |
| 146 | 131 |
| 147 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData() | 132 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData() |
| 148 { | 133 { |
| 149 if (m_shadowRootRareData) | 134 if (m_shadowRootRareData) |
| 150 return m_shadowRootRareData.get(); | 135 return m_shadowRootRareData.get(); |
| 151 | 136 |
| 152 m_shadowRootRareData = adoptPtr(new ShadowRootRareData); | 137 m_shadowRootRareData = adoptPtr(new ShadowRootRareData); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 Vector<RefPtr<InsertionPoint> > insertionPoints; | 198 Vector<RefPtr<InsertionPoint> > insertionPoints; |
| 214 for (InsertionPoint* insertionPoint = Traversal<InsertionPoint>::firstWithin
(*this); insertionPoint; insertionPoint = Traversal<InsertionPoint>::next(*inser
tionPoint, this)) | 199 for (InsertionPoint* insertionPoint = Traversal<InsertionPoint>::firstWithin
(*this); insertionPoint; insertionPoint = Traversal<InsertionPoint>::next(*inser
tionPoint, this)) |
| 215 insertionPoints.append(insertionPoint); | 200 insertionPoints.append(insertionPoint); |
| 216 | 201 |
| 217 ensureShadowRootRareData()->setDescendantInsertionPoints(insertionPoints); | 202 ensureShadowRootRareData()->setDescendantInsertionPoints(insertionPoints); |
| 218 | 203 |
| 219 return m_shadowRootRareData->descendantInsertionPoints(); | 204 return m_shadowRootRareData->descendantInsertionPoints(); |
| 220 } | 205 } |
| 221 | 206 |
| 222 } | 207 } |
| OLD | NEW |