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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp

Issue 2029923003: Recursively defining custom elements should not lead to redefinition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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 | « third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698