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

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

Issue 14846002: Implement the Custom Elements :unresolved pseudoclass (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Adds a test and fixes style sharing. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/CustomElementRegistry.cpp
diff --git a/Source/core/dom/CustomElementRegistry.cpp b/Source/core/dom/CustomElementRegistry.cpp
index 832c76191bab81de554f9045c19ac68db5a41b4a..b247b2d167d07903b86c8b8c61ccbafa36e135dc 100644
--- a/Source/core/dom/CustomElementRegistry.cpp
+++ b/Source/core/dom/CustomElementRegistry.cpp
@@ -170,6 +170,11 @@ PassRefPtr<CustomElementConstructor> CustomElementRegistry::registerElement(Scri
return constructor.release();
}
+bool CustomElementRegistry::isUnresolved(Element* element) const
+{
+ return m_unresolvedElements.contains(element);
+}
+
PassRefPtr<CustomElementDefinition> CustomElementRegistry::findFor(Element* element) const
{
ASSERT(element->document()->registry() == this);
@@ -226,8 +231,13 @@ PassRefPtr<Element> CustomElementRegistry::createCustomTagElement(const Qualifie
element->setIsCustomElement();
RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(tagName.localName(), tagName.namespaceURI());
- if (definition && !definition->isTypeExtension())
+ if (!definition || definition->isTypeExtension()) {
+ // If a definition for a type extension was available, this
+ // custom tag element will be unresolved in perpetuity.
+ didCreateUnresolvedElement(element.get());
+ } else {
didCreateCustomTagElement(element.get());
+ }
return element.release();
}
@@ -236,9 +246,13 @@ void CustomElementRegistry::didGiveTypeExtension(Element* element)
{
element->setIsCustomElement();
RefPtr<CustomElementDefinition> definition = findFor(element);
- if (!definition || !definition->isTypeExtension())
- return;
- activate(CustomElementInvocation(element));
+ if (!definition || !definition->isTypeExtension()) {
+ // If a definition for a custom tag was available, this type
+ // extension element will be unresolved in perpetuity.
+ didCreateUnresolvedElement(element);
+ } else {
+ activate(CustomElementInvocation(element));
+ }
}
void CustomElementRegistry::didCreateCustomTagElement(Element* element)
@@ -246,6 +260,17 @@ void CustomElementRegistry::didCreateCustomTagElement(Element* element)
activate(CustomElementInvocation(element));
}
+void CustomElementRegistry::didCreateUnresolvedElement(Element* element)
+{
+ m_unresolvedElements.add(element);
+}
+
+void CustomElementRegistry::customElementWasDestroyed(Element* element)
+{
+ ASSERT(element->isCustomElement());
+ m_unresolvedElements.remove(element);
+}
+
void CustomElementRegistry::activate(const CustomElementInvocation& invocation)
{
bool wasInactive = m_invocations.isEmpty();

Powered by Google App Engine
This is Rietveld 408576698