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

Unified Diff: Source/core/dom/CustomElementRegistry.cpp

Issue 14660019: Run Mutation Observer and Custom Element callbacks consistently at microtask checkpoint (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/CustomElementRegistry.h ('k') | Source/core/dom/Microtask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/CustomElementRegistry.cpp
diff --git a/Source/core/dom/CustomElementRegistry.cpp b/Source/core/dom/CustomElementRegistry.cpp
index 97896b3d66581bb66024b1efbeae679133d28112..da3dff370b898eeb32951a16936ffb5a94f9087e 100644
--- a/Source/core/dom/CustomElementRegistry.cpp
+++ b/Source/core/dom/CustomElementRegistry.cpp
@@ -29,13 +29,12 @@
*/
#include "config.h"
-
#include "core/dom/CustomElementRegistry.h"
#include "HTMLNames.h"
#include "SVGNames.h"
#include "bindings/v8/CustomElementConstructorBuilder.h"
-#include "bindings/v8/CustomElementHelpers.h"
+#include "core/dom/CustomElementCallbackDispatcher.h"
#include "core/dom/CustomElementDefinition.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
@@ -44,16 +43,6 @@
namespace WebCore {
-CustomElementInvocation::CustomElementInvocation(PassRefPtr<CustomElementCallback> callback, PassRefPtr<Element> element)
- : m_callback(callback)
- , m_element(element)
-{
-}
-
-CustomElementInvocation::~CustomElementInvocation()
-{
-}
-
void setTypeExtension(Element* element, const AtomicString& typeExtension)
{
ASSERT(element);
@@ -66,11 +55,6 @@ CustomElementRegistry::CustomElementRegistry(Document* document)
{
}
-CustomElementRegistry::~CustomElementRegistry()
-{
- deactivate();
-}
-
static inline bool nameIncludesHyphen(const AtomicString& name)
{
size_t hyphenPosition = name.find('-');
@@ -154,7 +138,7 @@ void CustomElementRegistry::registerElement(CustomElementConstructorBuilder* con
for (CustomElementUpgradeCandidateMap::ElementSet::iterator it = upgradeCandidates.begin(); it != upgradeCandidates.end(); ++it) {
(*it)->setNeedsStyleRecalc(); // :unresolved has changed
- enqueueReadyCallback(lifecycleCallbacks.get(), *it);
+ CustomElementCallbackDispatcher::instance().enqueueReadyCallback(lifecycleCallbacks.get(), *it);
}
}
@@ -239,13 +223,13 @@ void CustomElementRegistry::didGiveTypeExtension(Element* element, const AtomicS
// extension element will be unresolved in perpetuity.
didCreateUnresolvedElement(CustomElementDefinition::TypeExtension, type, element);
} else {
- enqueueReadyCallback(definition->callback(), element);
+ CustomElementCallbackDispatcher::instance().enqueueReadyCallback(definition->callback(), element);
}
}
void CustomElementRegistry::didCreateCustomTagElement(CustomElementDefinition* definition, Element* element)
{
- enqueueReadyCallback(definition->callback(), element);
+ CustomElementCallbackDispatcher::instance().enqueueReadyCallback(definition->callback(), element);
}
void CustomElementRegistry::didCreateUnresolvedElement(CustomElementDefinition::CustomElementKind kind, const AtomicString& type, Element* element)
@@ -259,54 +243,9 @@ void CustomElementRegistry::customElementWasDestroyed(Element* element)
m_candidates.remove(element);
}
-void CustomElementRegistry::enqueueReadyCallback(CustomElementCallback* callback, Element* element)
-{
- if (!callback->hasReady())
- return;
-
- bool wasInactive = m_invocations.isEmpty();
- m_invocations.append(CustomElementInvocation(callback, element));
- if (wasInactive)
- activeCustomElementRegistries().add(this);
-}
-
-void CustomElementRegistry::deactivate()
-{
- ASSERT(m_invocations.isEmpty());
- if (activeCustomElementRegistries().contains(this))
- activeCustomElementRegistries().remove(this);
-}
-
inline Document* CustomElementRegistry::document() const
{
return toDocument(m_scriptExecutionContext);
}
-void CustomElementRegistry::deliverLifecycleCallbacks()
-{
- ASSERT(!m_invocations.isEmpty());
-
- if (!m_invocations.isEmpty()) {
- Vector<CustomElementInvocation> invocations;
- m_invocations.swap(invocations);
-
- for (Vector<CustomElementInvocation>::iterator it = invocations.begin(); it != invocations.end(); ++it)
- it->callback()->ready(it->element());
- }
-
- ASSERT(m_invocations.isEmpty());
- deactivate();
-}
-
-void CustomElementRegistry::deliverAllLifecycleCallbacks()
-{
- while (!activeCustomElementRegistries().isEmpty()) {
- Vector<RefPtr<CustomElementRegistry> > registries;
- copyToVector(activeCustomElementRegistries(), registries);
- activeCustomElementRegistries().clear();
- for (size_t i = 0; i < registries.size(); ++i)
- registries[i]->deliverLifecycleCallbacks();
- }
-}
-
}
« no previous file with comments | « Source/core/dom/CustomElementRegistry.h ('k') | Source/core/dom/Microtask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698