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

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

Issue 1899653002: Support slotchange event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 void ShadowRoot::attach(const AttachContext& context) 120 void ShadowRoot::attach(const AttachContext& context)
121 { 121 {
122 StyleSharingDepthScope sharingScope(*this); 122 StyleSharingDepthScope sharingScope(*this);
123 DocumentFragment::attach(context); 123 DocumentFragment::attach(context);
124 } 124 }
125 125
126 Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode* inser tionPoint) 126 Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode* inser tionPoint)
127 { 127 {
128 DocumentFragment::insertedInto(insertionPoint); 128 DocumentFragment::insertedInto(insertionPoint);
129 if (isV1())
130 document().updateAssignment();
129 131
130 if (!insertionPoint->inShadowIncludingDocument() || !isOldest()) 132 if (!insertionPoint->inShadowIncludingDocument() || !isOldest())
131 return InsertionDone; 133 return InsertionDone;
132 134
133 // FIXME: When parsing <video controls>, insertedInto() is called many times without invoking removedFrom. 135 // FIXME: When parsing <video controls>, insertedInto() is called many times without invoking removedFrom.
134 // For now, we check m_registeredWithParentShadowroot. We would like to DCHE CK(!m_registeredShadowRoot) here. 136 // For now, we check m_registeredWithParentShadowroot. We would like to DCHE CK(!m_registeredShadowRoot) here.
135 // https://bugs.webkit.org/show_bug.cig?id=101316 137 // https://bugs.webkit.org/show_bug.cig?id=101316
136 if (m_registeredWithParentShadowRoot) 138 if (m_registeredWithParentShadowRoot)
137 return InsertionDone; 139 return InsertionDone;
138 140
139 if (ShadowRoot* root = host()->containingShadowRoot()) { 141 if (ShadowRoot* root = host()->containingShadowRoot()) {
140 root->addChildShadowRoot(); 142 root->addChildShadowRoot();
141 m_registeredWithParentShadowRoot = true; 143 m_registeredWithParentShadowRoot = true;
142 } 144 }
143 145
146
144 return InsertionDone; 147 return InsertionDone;
145 } 148 }
146 149
147 void ShadowRoot::removedFrom(ContainerNode* insertionPoint) 150 void ShadowRoot::removedFrom(ContainerNode* insertionPoint)
148 { 151 {
149 if (insertionPoint->inShadowIncludingDocument()) { 152 if (insertionPoint->inShadowIncludingDocument()) {
150 document().styleEngine().shadowRootRemovedFromDocument(this); 153 document().styleEngine().shadowRootRemovedFromDocument(this);
151 if (m_registeredWithParentShadowRoot) { 154 if (m_registeredWithParentShadowRoot) {
152 ShadowRoot* root = host()->containingShadowRoot(); 155 ShadowRoot* root = host()->containingShadowRoot();
153 if (!root) 156 if (!root)
154 root = insertionPoint->containingShadowRoot(); 157 root = insertionPoint->containingShadowRoot();
155 if (root) 158 if (root)
156 root->removeChildShadowRoot(); 159 root->removeChildShadowRoot();
157 m_registeredWithParentShadowRoot = false; 160 m_registeredWithParentShadowRoot = false;
158 } 161 }
159 } 162 }
160 163
161 DocumentFragment::removedFrom(insertionPoint); 164 DocumentFragment::removedFrom(insertionPoint);
162 } 165 }
163 166
164 void ShadowRoot::childrenChanged(const ChildrenChange& change) 167 void ShadowRoot::childrenChanged(const ChildrenChange& change)
165 { 168 {
166 ContainerNode::childrenChanged(change); 169 ContainerNode::childrenChanged(change);
167 170
168 if (change.isChildElementChange()) 171 if (change.isChildElementChange())
169 checkForSiblingStyleChanges(change.type == ElementRemoved ? SiblingEleme ntRemoved : SiblingElementInserted, change.siblingBeforeChange, change.siblingAf terChange); 172 checkForSiblingStyleChanges(change.type == ElementRemoved ? SiblingEleme ntRemoved : SiblingElementInserted, change.siblingBeforeChange, change.siblingAf terChange);
170 173
171 if (InsertionPoint* point = shadowInsertionPointOfYoungerShadowRoot()) { 174 if (InsertionPoint* point = shadowInsertionPointOfYoungerShadowRoot()) {
172 if (ShadowRoot* root = point->containingShadowRoot()) 175 if (ShadowRoot* root = point->containingShadowRoot()) {
173 root->owner()->setNeedsDistributionRecalc(); 176 root->owner()->setNeedsDistributionRecalc();
177 if (document().shadowCascadeOrder() == ShadowCascadeOrder::ShadowCas cadeV1)
178 document().updateAssignment();
179 }
174 } 180 }
175 } 181 }
176 182
177 void ShadowRoot::registerScopedHTMLStyleChild() 183 void ShadowRoot::registerScopedHTMLStyleChild()
178 { 184 {
179 ++m_numberOfStyles; 185 ++m_numberOfStyles;
180 } 186 }
181 187
182 void ShadowRoot::unregisterScopedHTMLStyleChild() 188 void ShadowRoot::unregisterScopedHTMLStyleChild()
183 { 189 {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 DCHECK(m_shadowRootRareData); 333 DCHECK(m_shadowRootRareData);
328 HeapVector<Member<HTMLSlotElement>> slots; 334 HeapVector<Member<HTMLSlotElement>> slots;
329 slots.reserveCapacity(descendantSlotCount()); 335 slots.reserveCapacity(descendantSlotCount());
330 for (HTMLSlotElement& slot : Traversal<HTMLSlotElement>::descendantsOf(rootN ode())) 336 for (HTMLSlotElement& slot : Traversal<HTMLSlotElement>::descendantsOf(rootN ode()))
331 slots.append(&slot); 337 slots.append(&slot);
332 m_shadowRootRareData->setDescendantSlots(slots); 338 m_shadowRootRareData->setDescendantSlots(slots);
333 m_descendantSlotsIsValid = true; 339 m_descendantSlotsIsValid = true;
334 return m_shadowRootRareData->descendantSlots(); 340 return m_shadowRootRareData->descendantSlots();
335 } 341 }
336 342
343 void ShadowRoot::assignV1()
344 {
345 if (!m_slotAssignment)
346 m_slotAssignment = SlotAssignment::create();
347 m_slotAssignment->resolveAssignment(*this);
348 }
349
337 void ShadowRoot::distributeV1() 350 void ShadowRoot::distributeV1()
338 { 351 {
339 if (!m_slotAssignment) 352 if (!m_slotAssignment)
340 m_slotAssignment = SlotAssignment::create(); 353 m_slotAssignment = SlotAssignment::create();
341 m_slotAssignment->resolveAssignment(*this); 354 m_slotAssignment->resolveDistribution(*this);
342 } 355 }
343 356
344 DEFINE_TRACE(ShadowRoot) 357 DEFINE_TRACE(ShadowRoot)
345 { 358 {
346 visitor->trace(m_prev); 359 visitor->trace(m_prev);
347 visitor->trace(m_next); 360 visitor->trace(m_next);
348 visitor->trace(m_shadowRootRareData); 361 visitor->trace(m_shadowRootRareData);
349 visitor->trace(m_slotAssignment); 362 visitor->trace(m_slotAssignment);
350 TreeScope::trace(visitor); 363 TreeScope::trace(visitor);
351 DocumentFragment::trace(visitor); 364 DocumentFragment::trace(visitor);
352 } 365 }
353 366
354 } // namespace blink 367 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698