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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/InsertionPoint.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "core/dom/shadow/InsertionPoint.h" 31 #include "core/dom/shadow/InsertionPoint.h"
32 32
33 #include "core/HTMLNames.h" 33 #include "core/HTMLNames.h"
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/ElementTraversal.h" 35 #include "core/dom/ElementTraversal.h"
36 #include "core/dom/QualifiedName.h" 36 #include "core/dom/QualifiedName.h"
37 #include "core/dom/StaticNodeList.h" 37 #include "core/dom/StaticNodeList.h"
38 #include "core/dom/StyleChangeReason.h" 38 #include "core/dom/StyleChangeReason.h"
39 #include "core/dom/StyleEngine.h"
39 #include "core/dom/shadow/ElementShadow.h" 40 #include "core/dom/shadow/ElementShadow.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 using namespace HTMLNames; 44 using namespace HTMLNames;
44 45
45 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document) 46 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document)
46 : HTMLElement(tagName, document, CreateInsertionPoint) 47 : HTMLElement(tagName, document, CreateInsertionPoint)
47 , m_registeredWithShadowRoot(false) 48 , m_registeredWithShadowRoot(false)
48 { 49 {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 182
182 bool InsertionPoint::layoutObjectIsNeeded(const ComputedStyle& style) 183 bool InsertionPoint::layoutObjectIsNeeded(const ComputedStyle& style)
183 { 184 {
184 return !isActive() && HTMLElement::layoutObjectIsNeeded(style); 185 return !isActive() && HTMLElement::layoutObjectIsNeeded(style);
185 } 186 }
186 187
187 void InsertionPoint::childrenChanged(const ChildrenChange& change) 188 void InsertionPoint::childrenChanged(const ChildrenChange& change)
188 { 189 {
189 HTMLElement::childrenChanged(change); 190 HTMLElement::childrenChanged(change);
190 if (ShadowRoot* root = containingShadowRoot()) { 191 if (ShadowRoot* root = containingShadowRoot()) {
191 if (ElementShadow* rootOwner = root->owner()) 192 if (ElementShadow* rootOwner = root->owner()) {
192 rootOwner->setNeedsDistributionRecalc(); 193 rootOwner->setNeedsDistributionRecalc();
194 if (document().shadowCascadeOrder() == ShadowCascadeOrder::ShadowCas cadeV1)
195 document().updateAssignment();
196 }
193 } 197 }
194 } 198 }
195 199
196 Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* i nsertionPoint) 200 Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* i nsertionPoint)
197 { 201 {
198 HTMLElement::insertedInto(insertionPoint); 202 HTMLElement::insertedInto(insertionPoint);
199 if (ShadowRoot* root = containingShadowRoot()) { 203 if (ShadowRoot* root = containingShadowRoot()) {
200 if (ElementShadow* rootOwner = root->owner()) { 204 if (ElementShadow* rootOwner = root->owner()) {
201 rootOwner->setNeedsDistributionRecalc(); 205 rootOwner->setNeedsDistributionRecalc();
206 if (document().shadowCascadeOrder() == ShadowCascadeOrder::ShadowCas cadeV1)
207 document().updateAssignment();
202 if (canBeActive() && !m_registeredWithShadowRoot && insertionPoint-> treeScope().rootNode() == root) { 208 if (canBeActive() && !m_registeredWithShadowRoot && insertionPoint-> treeScope().rootNode() == root) {
203 m_registeredWithShadowRoot = true; 209 m_registeredWithShadowRoot = true;
204 root->didAddInsertionPoint(this); 210 root->didAddInsertionPoint(this);
205 if (canAffectSelector()) 211 if (canAffectSelector())
206 rootOwner->willAffectSelector(); 212 rootOwner->willAffectSelector();
207 } 213 }
208 } 214 }
209 } 215 }
210 216
211 // We could have been distributed into in a detached subtree, make sure to 217 // We could have been distributed into in a detached subtree, make sure to
212 // clear the distribution when inserted again to avoid cycles. 218 // clear the distribution when inserted again to avoid cycles.
213 clearDistribution(); 219 clearDistribution();
214 220
215 return InsertionDone; 221 return InsertionDone;
216 } 222 }
217 223
218 void InsertionPoint::removedFrom(ContainerNode* insertionPoint) 224 void InsertionPoint::removedFrom(ContainerNode* insertionPoint)
219 { 225 {
220 ShadowRoot* root = containingShadowRoot(); 226 ShadowRoot* root = containingShadowRoot();
221 if (!root) 227 if (!root)
222 root = insertionPoint->containingShadowRoot(); 228 root = insertionPoint->containingShadowRoot();
223 229
224 if (root) { 230 if (root) {
225 if (ElementShadow* rootOwner = root->owner()) 231 if (ElementShadow* rootOwner = root->owner()) {
226 rootOwner->setNeedsDistributionRecalc(); 232 rootOwner->setNeedsDistributionRecalc();
233 if (document().shadowCascadeOrder() == ShadowCascadeOrder::ShadowCas cadeV1)
234 document().updateAssignment();
235 }
227 } 236 }
228 237
229 // host can be null when removedFrom() is called from ElementShadow destruct or. 238 // host can be null when removedFrom() is called from ElementShadow destruct or.
230 ElementShadow* rootOwner = root ? root->owner() : 0; 239 ElementShadow* rootOwner = root ? root->owner() : 0;
231 240
232 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. 241 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up.
233 clearDistribution(); 242 clearDistribution();
234 243
235 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) { 244 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) {
236 DCHECK(root); 245 DCHECK(root);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (!insertionPoints) 294 if (!insertionPoints)
286 return; 295 return;
287 for (size_t i = 0; i < insertionPoints->size(); ++i) 296 for (size_t i = 0; i < insertionPoints->size(); ++i)
288 results.append(insertionPoints->at(i).get()); 297 results.append(insertionPoints->at(i).get());
289 DCHECK_NE(current, insertionPoints->last().get()); 298 DCHECK_NE(current, insertionPoints->last().get());
290 current = insertionPoints->last().get(); 299 current = insertionPoints->last().get();
291 } 300 }
292 } 301 }
293 302
294 } // namespace blink 303 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698