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

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

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 , m_registeredWithParentShadowRoot(false) 62 , m_registeredWithParentShadowRoot(false)
63 , m_descendantInsertionPointsIsValid(false) 63 , m_descendantInsertionPointsIsValid(false)
64 , m_delegatesFocus(false) 64 , m_delegatesFocus(false)
65 , m_descendantSlotsIsValid(false) 65 , m_descendantSlotsIsValid(false)
66 { 66 {
67 } 67 }
68 68
69 ShadowRoot::~ShadowRoot() 69 ShadowRoot::~ShadowRoot()
70 { 70 {
71 #if !ENABLE(OILPAN) 71 #if !ENABLE(OILPAN)
72 ASSERT(!m_prev); 72 DCHECK(!m_prev);
73 ASSERT(!m_next); 73 DCHECK(!m_next);
74 74
75 if (m_shadowRootRareData && m_shadowRootRareData->styleSheets()) 75 if (m_shadowRootRareData && m_shadowRootRareData->styleSheets())
76 m_shadowRootRareData->styleSheets()->detachFromDocument(); 76 m_shadowRootRareData->styleSheets()->detachFromDocument();
77 77
78 document().styleEngine().didRemoveShadowRoot(this); 78 document().styleEngine().didRemoveShadowRoot(this);
79 79
80 // We cannot let ContainerNode destructor call willBeDeletedFromDocument() 80 // We cannot let ContainerNode destructor call willBeDeletedFromDocument()
81 // for this ShadowRoot instance because TreeScope destructor 81 // for this ShadowRoot instance because TreeScope destructor
82 // clears Node::m_treeScope thus ContainerNode is no longer able 82 // clears Node::m_treeScope thus ContainerNode is no longer able
83 // to access it Document reference after that. 83 // to access it Document reference after that.
(...skipping 16 matching lines...) Expand all
100 { 100 {
101 removeDetachedChildren(); 101 removeDetachedChildren();
102 } 102 }
103 #endif 103 #endif
104 104
105 ShadowRoot* ShadowRoot::olderShadowRootForBindings() const 105 ShadowRoot* ShadowRoot::olderShadowRootForBindings() const
106 { 106 {
107 ShadowRoot* older = olderShadowRoot(); 107 ShadowRoot* older = olderShadowRoot();
108 while (older && !older->isOpenOrV0()) 108 while (older && !older->isOpenOrV0())
109 older = older->olderShadowRoot(); 109 older = older->olderShadowRoot();
110 ASSERT(!older || older->isOpenOrV0()); 110 DCHECK(!older || older->isOpenOrV0());
111 return older; 111 return older;
112 } 112 }
113 113
114 RawPtr<Node> ShadowRoot::cloneNode(bool, ExceptionState& exceptionState) 114 RawPtr<Node> ShadowRoot::cloneNode(bool, ExceptionState& exceptionState)
115 { 115 {
116 exceptionState.throwDOMException(NotSupportedError, "ShadowRoot nodes are no t clonable."); 116 exceptionState.throwDOMException(NotSupportedError, "ShadowRoot nodes are no t clonable.");
117 return nullptr; 117 return nullptr;
118 } 118 }
119 119
120 String ShadowRoot::innerHTML() const 120 String ShadowRoot::innerHTML() const
121 { 121 {
122 return createMarkup(this, ChildrenOnly); 122 return createMarkup(this, ChildrenOnly);
123 } 123 }
124 124
125 void ShadowRoot::setInnerHTML(const String& markup, ExceptionState& exceptionSta te) 125 void ShadowRoot::setInnerHTML(const String& markup, ExceptionState& exceptionSta te)
126 { 126 {
127 if (isOrphan()) { 127 if (isOrphan()) {
128 exceptionState.throwDOMException(InvalidAccessError, "The ShadowRoot doe s not have a host."); 128 exceptionState.throwDOMException(InvalidAccessError, "The ShadowRoot doe s not have a host.");
129 return; 129 return;
130 } 130 }
131 131
132 if (RawPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(mark up, host(), AllowScriptingContent, "innerHTML", exceptionState)) 132 if (RawPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(mark up, host(), AllowScriptingContent, "innerHTML", exceptionState))
133 replaceChildrenWithFragment(this, fragment.release(), exceptionState); 133 replaceChildrenWithFragment(this, fragment.release(), exceptionState);
134 } 134 }
135 135
136 void ShadowRoot::recalcStyle(StyleRecalcChange change) 136 void ShadowRoot::recalcStyle(StyleRecalcChange change)
137 { 137 {
138 // ShadowRoot doesn't support custom callbacks. 138 // ShadowRoot doesn't support custom callbacks.
139 ASSERT(!hasCustomStyleCallbacks()); 139 DCHECK(!hasCustomStyleCallbacks());
140 140
141 StyleSharingDepthScope sharingScope(*this); 141 StyleSharingDepthScope sharingScope(*this);
142 142
143 if (getStyleChangeType() >= SubtreeStyleChange) 143 if (getStyleChangeType() >= SubtreeStyleChange)
144 change = Force; 144 change = Force;
145 145
146 // There's no style to update so just calling recalcStyle means we're update d. 146 // There's no style to update so just calling recalcStyle means we're update d.
147 clearNeedsStyleRecalc(); 147 clearNeedsStyleRecalc();
148 148
149 recalcChildStyle(change); 149 recalcChildStyle(change);
150 clearChildNeedsStyleRecalc(); 150 clearChildNeedsStyleRecalc();
151 } 151 }
152 152
153 void ShadowRoot::attach(const AttachContext& context) 153 void ShadowRoot::attach(const AttachContext& context)
154 { 154 {
155 StyleSharingDepthScope sharingScope(*this); 155 StyleSharingDepthScope sharingScope(*this);
156 DocumentFragment::attach(context); 156 DocumentFragment::attach(context);
157 } 157 }
158 158
159 Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode* inser tionPoint) 159 Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode* inser tionPoint)
160 { 160 {
161 DocumentFragment::insertedInto(insertionPoint); 161 DocumentFragment::insertedInto(insertionPoint);
162 162
163 if (!insertionPoint->inShadowIncludingDocument() || !isOldest()) 163 if (!insertionPoint->inShadowIncludingDocument() || !isOldest())
164 return InsertionDone; 164 return InsertionDone;
165 165
166 // FIXME: When parsing <video controls>, insertedInto() is called many times without invoking removedFrom. 166 // FIXME: When parsing <video controls>, insertedInto() is called many times without invoking removedFrom.
167 // For now, we check m_registeredWithParentShadowroot. We would like to ASSE RT(!m_registeredShadowRoot) here. 167 // For now, we check m_registeredWithParentShadowroot. We would like to DCHE CK(!m_registeredShadowRoot) here.
168 // https://bugs.webkit.org/show_bug.cig?id=101316 168 // https://bugs.webkit.org/show_bug.cig?id=101316
169 if (m_registeredWithParentShadowRoot) 169 if (m_registeredWithParentShadowRoot)
170 return InsertionDone; 170 return InsertionDone;
171 171
172 if (ShadowRoot* root = host()->containingShadowRoot()) { 172 if (ShadowRoot* root = host()->containingShadowRoot()) {
173 root->addChildShadowRoot(); 173 root->addChildShadowRoot();
174 m_registeredWithParentShadowRoot = true; 174 m_registeredWithParentShadowRoot = true;
175 } 175 }
176 176
177 return InsertionDone; 177 return InsertionDone;
(...skipping 29 matching lines...) Expand all
207 } 207 }
208 } 208 }
209 209
210 void ShadowRoot::registerScopedHTMLStyleChild() 210 void ShadowRoot::registerScopedHTMLStyleChild()
211 { 211 {
212 ++m_numberOfStyles; 212 ++m_numberOfStyles;
213 } 213 }
214 214
215 void ShadowRoot::unregisterScopedHTMLStyleChild() 215 void ShadowRoot::unregisterScopedHTMLStyleChild()
216 { 216 {
217 ASSERT(m_numberOfStyles > 0); 217 DCHECK_GT(m_numberOfStyles, 0u);
218 --m_numberOfStyles; 218 --m_numberOfStyles;
219 } 219 }
220 220
221 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData() 221 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData()
222 { 222 {
223 if (m_shadowRootRareData) 223 if (m_shadowRootRareData)
224 return m_shadowRootRareData.get(); 224 return m_shadowRootRareData.get();
225 225
226 m_shadowRootRareData = new ShadowRootRareData; 226 m_shadowRootRareData = new ShadowRootRareData;
227 return m_shadowRootRareData.get(); 227 return m_shadowRootRareData.get();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 325
326 void ShadowRoot::didAddSlot() 326 void ShadowRoot::didAddSlot()
327 { 327 {
328 ensureShadowRootRareData()->didAddSlot(); 328 ensureShadowRootRareData()->didAddSlot();
329 invalidateDescendantSlots(); 329 invalidateDescendantSlots();
330 } 330 }
331 331
332 void ShadowRoot::didRemoveSlot() 332 void ShadowRoot::didRemoveSlot()
333 { 333 {
334 ASSERT(m_shadowRootRareData); 334 DCHECK(m_shadowRootRareData);
335 m_shadowRootRareData->didRemoveSlot(); 335 m_shadowRootRareData->didRemoveSlot();
336 invalidateDescendantSlots(); 336 invalidateDescendantSlots();
337 } 337 }
338 338
339 void ShadowRoot::invalidateDescendantSlots() 339 void ShadowRoot::invalidateDescendantSlots()
340 { 340 {
341 m_descendantSlotsIsValid = false; 341 m_descendantSlotsIsValid = false;
342 m_shadowRootRareData->clearDescendantSlots(); 342 m_shadowRootRareData->clearDescendantSlots();
343 } 343 }
344 344
345 unsigned ShadowRoot::descendantSlotCount() const 345 unsigned ShadowRoot::descendantSlotCount() const
346 { 346 {
347 return m_shadowRootRareData ? m_shadowRootRareData->descendantSlotCount() : 0; 347 return m_shadowRootRareData ? m_shadowRootRareData->descendantSlotCount() : 0;
348 } 348 }
349 349
350 const HeapVector<Member<HTMLSlotElement>>& ShadowRoot::descendantSlots() 350 const HeapVector<Member<HTMLSlotElement>>& ShadowRoot::descendantSlots()
351 { 351 {
352 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLSlotElement>>, emptyList, (new Hea pVector<Member<HTMLSlotElement>>)); 352 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLSlotElement>>, emptyList, (new Hea pVector<Member<HTMLSlotElement>>));
353 if (m_descendantSlotsIsValid) { 353 if (m_descendantSlotsIsValid) {
354 ASSERT(m_shadowRootRareData); 354 DCHECK(m_shadowRootRareData);
355 return m_shadowRootRareData->descendantSlots(); 355 return m_shadowRootRareData->descendantSlots();
356 } 356 }
357 if (descendantSlotCount() == 0) 357 if (descendantSlotCount() == 0)
358 return emptyList; 358 return emptyList;
359 359
360 ASSERT(m_shadowRootRareData); 360 DCHECK(m_shadowRootRareData);
361 HeapVector<Member<HTMLSlotElement>> slots; 361 HeapVector<Member<HTMLSlotElement>> slots;
362 slots.reserveCapacity(descendantSlotCount()); 362 slots.reserveCapacity(descendantSlotCount());
363 for (HTMLSlotElement& slot : Traversal<HTMLSlotElement>::descendantsOf(rootN ode())) 363 for (HTMLSlotElement& slot : Traversal<HTMLSlotElement>::descendantsOf(rootN ode()))
364 slots.append(&slot); 364 slots.append(&slot);
365 m_shadowRootRareData->setDescendantSlots(slots); 365 m_shadowRootRareData->setDescendantSlots(slots);
366 m_descendantSlotsIsValid = true; 366 m_descendantSlotsIsValid = true;
367 return m_shadowRootRareData->descendantSlots(); 367 return m_shadowRootRareData->descendantSlots();
368 } 368 }
369 369
370 DEFINE_TRACE(ShadowRoot) 370 DEFINE_TRACE(ShadowRoot)
371 { 371 {
372 visitor->trace(m_prev); 372 visitor->trace(m_prev);
373 visitor->trace(m_next); 373 visitor->trace(m_next);
374 visitor->trace(m_shadowRootRareData); 374 visitor->trace(m_shadowRootRareData);
375 TreeScope::trace(visitor); 375 TreeScope::trace(visitor);
376 DocumentFragment::trace(visitor); 376 DocumentFragment::trace(visitor);
377 } 377 }
378 378
379 } // namespace blink 379 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698