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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp

Issue 2622193002: Dispatch slotchange events in "notify mutation observers" steps (Closed)
Patch Set: fixed Created 3 years, 11 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) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 m_distributedNodes.clear(); 142 m_distributedNodes.clear();
143 m_distributedIndices.clear(); 143 m_distributedIndices.clear();
144 } 144 }
145 145
146 void HTMLSlotElement::saveAndClearDistribution() { 146 void HTMLSlotElement::saveAndClearDistribution() {
147 m_oldDistributedNodes.swap(m_distributedNodes); 147 m_oldDistributedNodes.swap(m_distributedNodes);
148 clearDistribution(); 148 clearDistribution();
149 } 149 }
150 150
151 void HTMLSlotElement::dispatchSlotChangeEvent() { 151 void HTMLSlotElement::dispatchSlotChangeEvent() {
152 m_slotchangeEventEnqueued = false;
153 Event* event = Event::createBubble(EventTypeNames::slotchange); 152 Event* event = Event::createBubble(EventTypeNames::slotchange);
154 event->setTarget(this); 153 event->setTarget(this);
155 dispatchScopedEvent(event); 154 dispatchScopedEvent(event);
156 } 155 }
157 156
158 Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const { 157 Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const {
159 DCHECK(supportsDistribution()); 158 DCHECK(supportsDistribution());
160 const auto& it = m_distributedIndices.find(&node); 159 const auto& it = m_distributedIndices.find(&node);
161 if (it == m_distributedIndices.end()) 160 if (it == m_distributedIndices.end())
162 return nullptr; 161 return nullptr;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 DCHECK(root->isV1()); 324 DCHECK(root->isV1());
326 root->owner()->setNeedsDistributionRecalc(); 325 root->owner()->setNeedsDistributionRecalc();
327 // Check slotchange recursively since this slotchange may cause another 326 // Check slotchange recursively since this slotchange may cause another
328 // slotchange. 327 // slotchange.
329 checkSlotChange(SlotChangeType::Chained); 328 checkSlotChange(SlotChangeType::Chained);
330 } 329 }
331 330
332 void HTMLSlotElement::enqueueSlotChangeEvent() { 331 void HTMLSlotElement::enqueueSlotChangeEvent() {
333 if (m_slotchangeEventEnqueued) 332 if (m_slotchangeEventEnqueued)
334 return; 333 return;
335 Microtask::enqueueMicrotask(WTF::bind( 334 MutationObserver::enqueueSlotChange(*this);
336 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
337 m_slotchangeEventEnqueued = true; 335 m_slotchangeEventEnqueued = true;
338 } 336 }
339 337
340 bool HTMLSlotElement::hasAssignedNodesSlow() const { 338 bool HTMLSlotElement::hasAssignedNodesSlow() const {
341 ShadowRoot* root = containingShadowRoot(); 339 ShadowRoot* root = containingShadowRoot();
342 DCHECK(root); 340 DCHECK(root);
343 DCHECK(root->isV1()); 341 DCHECK(root->isV1());
344 SlotAssignment& assignment = root->ensureSlotAssignment(); 342 SlotAssignment& assignment = root->ensureSlotAssignment();
345 if (assignment.findSlotByName(name()) != this) 343 if (assignment.findSlotByName(name()) != this)
346 return false; 344 return false;
(...skipping 14 matching lines...) Expand all
361 359
362 DEFINE_TRACE(HTMLSlotElement) { 360 DEFINE_TRACE(HTMLSlotElement) {
363 visitor->trace(m_assignedNodes); 361 visitor->trace(m_assignedNodes);
364 visitor->trace(m_distributedNodes); 362 visitor->trace(m_distributedNodes);
365 visitor->trace(m_oldDistributedNodes); 363 visitor->trace(m_oldDistributedNodes);
366 visitor->trace(m_distributedIndices); 364 visitor->trace(m_distributedIndices);
367 HTMLElement::trace(visitor); 365 HTMLElement::trace(visitor);
368 } 366 }
369 367
370 } // namespace blink 368 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698