Index: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
index 937f9239614f4d52d4720ad2945f010c7c3609e4..031cf43724dfcc92528917cf05a45a356ba8ede6 100644 |
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp |
@@ -18,9 +18,34 @@ |
#include "core/dom/custom/CustomElementUpgradeReaction.h" |
#include "core/dom/custom/CustomElementUpgradeSorter.h" |
#include "core/dom/custom/V0CustomElementRegistrationContext.h" |
+#include "wtf/Allocator.h" |
namespace blink { |
+class CustomElementsRegistry::NameIsBeingDefined final { |
+ STACK_ALLOCATED(); |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(NameIsBeingDefined); |
+public: |
+ NameIsBeingDefined( |
+ CustomElementsRegistry* registry, |
+ const AtomicString& name) |
+ : m_registry(registry) |
+ , m_name(name) |
+ { |
+ DCHECK(!m_registry->m_namesBeingDefined.contains(name)); |
+ m_registry->m_namesBeingDefined.add(name); |
+ } |
+ |
+ ~NameIsBeingDefined() |
+ { |
+ m_registry->m_namesBeingDefined.remove(m_name); |
+ } |
+ |
+private: |
+ Member<CustomElementsRegistry> m_registry; |
+ const AtomicString& m_name; |
+}; |
+ |
CustomElementsRegistry* CustomElementsRegistry::create( |
Document* document) |
{ |
@@ -77,6 +102,14 @@ void CustomElementsRegistry::define( |
return; |
} |
+ if (m_namesBeingDefined.contains(name)) { |
+ exceptionState.throwDOMException( |
+ NotSupportedError, |
+ "this name is already being defined in this registry"); |
+ return; |
+ } |
+ NameIsBeingDefined defining(this, name); |
+ |
if (nameIsDefined(name) || v0NameIsDefined(name)) { |
exceptionState.throwDOMException( |
NotSupportedError, |