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

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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 DCHECK(root->isV1()); 323 DCHECK(root->isV1());
325 root->owner()->setNeedsDistributionRecalc(); 324 root->owner()->setNeedsDistributionRecalc();
326 // Check slotchange recursively since this slotchange may cause another 325 // Check slotchange recursively since this slotchange may cause another
327 // slotchange. 326 // slotchange.
328 checkSlotChange(SlotChangeType::Chained); 327 checkSlotChange(SlotChangeType::Chained);
329 } 328 }
330 329
331 void HTMLSlotElement::enqueueSlotChangeEvent() { 330 void HTMLSlotElement::enqueueSlotChangeEvent() {
332 if (m_slotchangeEventEnqueued) 331 if (m_slotchangeEventEnqueued)
333 return; 332 return;
334 Microtask::enqueueMicrotask(WTF::bind( 333 MutationObserver::enqueueSlotChange(*this);
335 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
336 m_slotchangeEventEnqueued = true; 334 m_slotchangeEventEnqueued = true;
337 } 335 }
338 336
339 bool HTMLSlotElement::hasAssignedNodesSlow() const { 337 bool HTMLSlotElement::hasAssignedNodesSlow() const {
340 ShadowRoot* root = containingShadowRoot(); 338 ShadowRoot* root = containingShadowRoot();
341 DCHECK(root); 339 DCHECK(root);
342 DCHECK(root->isV1()); 340 DCHECK(root->isV1());
343 SlotAssignment& assignment = root->ensureSlotAssignment(); 341 SlotAssignment& assignment = root->ensureSlotAssignment();
344 if (assignment.findSlotByName(name()) != this) 342 if (assignment.findSlotByName(name()) != this)
345 return false; 343 return false;
(...skipping 14 matching lines...) Expand all
360 358
361 DEFINE_TRACE(HTMLSlotElement) { 359 DEFINE_TRACE(HTMLSlotElement) {
362 visitor->trace(m_assignedNodes); 360 visitor->trace(m_assignedNodes);
363 visitor->trace(m_distributedNodes); 361 visitor->trace(m_distributedNodes);
364 visitor->trace(m_oldDistributedNodes); 362 visitor->trace(m_oldDistributedNodes);
365 visitor->trace(m_distributedIndices); 363 visitor->trace(m_distributedIndices);
366 HTMLElement::trace(visitor); 364 HTMLElement::trace(visitor);
367 } 365 }
368 366
369 } // namespace blink 367 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698