Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| index e6e061fd43441c0744f6756e3e144a599401666e..672de19c2b05196618c1be8a39cad9543ceedbf4 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| @@ -31,9 +31,11 @@ |
| #include "core/html/HTMLSlotElement.h" |
| #include "core/HTMLNames.h" |
| +#include "core/dom/Microtask.h" |
| #include "core/dom/NodeTraversal.h" |
| #include "core/dom/shadow/ElementShadow.h" |
| #include "core/dom/shadow/InsertionPoint.h" |
| +#include "core/events/Event.h" |
| #include "core/html/AssignedNodesOptions.h" |
| namespace blink { |
| @@ -103,10 +105,23 @@ void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) |
| void HTMLSlotElement::clearDistribution() |
| { |
| m_assignedNodes.clear(); |
| + m_oldDistributedNodes.swap(m_distributedNodes); |
| m_distributedNodes.clear(); |
| m_distributedIndices.clear(); |
| } |
| +bool HTMLSlotElement::hasSlotChangeEventListener() |
| +{ |
| + return eventTargetData() && eventTargetData()->eventListenerMap.find(EventTypeNames::slotchange); |
| +} |
| + |
| +void HTMLSlotElement::dispatchSlotChangeEvent() |
| +{ |
| + RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::slotchange); |
| + event->setTarget(this); |
| + dispatchScopedEvent(event); |
| +} |
| + |
| Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const |
| { |
| const auto& it = m_distributedIndices.find(&node); |
| @@ -218,12 +233,22 @@ void HTMLSlotElement::updateDistributedNodesWithFallback() |
| } |
| } |
| +void HTMLSlotElement::didUpdateDistribution() |
| +{ |
| + if (hasSlotChangeEventListener() && m_distributedNodes != m_oldDistributedNodes) { |
| + // TODO(hayato): Do not enqueue a slotchange event for the same slot twice in the microtask queue |
| + Microtask::enqueueMicrotask(WTF::bind(&HTMLSlotElement::dispatchSlotChangeEvent, this)); |
|
yhirano
2016/02/17 05:23:12
ditto
hayato
2016/02/17 06:07:33
Done.
|
| + } |
| + // TODO(hayato): Call setNeedsDistributionRecalc if the distribution changes due to the fallback elements |
| +} |
| + |
| DEFINE_TRACE(HTMLSlotElement) |
| { |
| #if ENABLE(OILPAN) |
| visitor->trace(m_assignedNodes); |
| visitor->trace(m_distributedNodes); |
| visitor->trace(m_distributedIndices); |
| + visitor->trace(m_oldDistributedNodes); |
| #endif |
| HTMLElement::trace(visitor); |
| } |