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

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

Issue 1952893003: Implement custom element construction and some 'define' checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use DCHECK, revert RuntimeEnabledFeatures.in. Created 4 years, 7 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: third_party/WebKit/Source/core/dom/custom/V0CustomElementRegistry.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/V0CustomElementRegistry.cpp b/third_party/WebKit/Source/core/dom/custom/V0CustomElementRegistry.cpp
index 2ecc455436fc31c9a4b2539d45094f9b81ccd7f3..b7b4a4061e9cc4a8feaee9e5f631a782927b9616 100644
--- a/third_party/WebKit/Source/core/dom/custom/V0CustomElementRegistry.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/V0CustomElementRegistry.cpp
@@ -31,13 +31,31 @@
#include "core/dom/custom/V0CustomElementRegistry.h"
#include "bindings/core/v8/V0CustomElementConstructorBuilder.h"
+#include "bindings/core/v8/V8Binding.h"
#include "core/HTMLNames.h"
#include "core/SVGNames.h"
+#include "core/dom/Document.h"
+#include "core/dom/custom/CustomElementsRegistry.h"
#include "core/dom/custom/V0CustomElementException.h"
#include "core/dom/custom/V0CustomElementRegistrationContext.h"
+#include "core/frame/LocalDOMWindow.h"
namespace blink {
+static bool v1CustomElementIsDefined(const AtomicString& name)
+{
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
haraken 2016/05/10 09:04:22 v8::Isolate::GetCurrent() is deprecated. Can we p
+ Document* doc = toDocument(currentExecutionContext(isolate));
+ LocalDOMWindow* window = doc->domWindow();
haraken 2016/05/10 09:04:22 We should use ScriptState::domWindow(), which does
+ CustomElementsRegistry* registry = window->customElements();
+ return registry && registry->nameIsDefined(name);
+}
+
+bool V0CustomElementRegistry::nameIsDefined(const AtomicString& name) const
+{
+ return m_registeredTypeNames.contains(name);
+}
+
V0CustomElementDefinition* V0CustomElementRegistry::registerElement(Document* document, V0CustomElementConstructorBuilder* constructorBuilder, const AtomicString& userSuppliedName, V0CustomElement::NameSet validNames, ExceptionState& exceptionState)
{
AtomicString type = userSuppliedName.lower();
@@ -52,7 +70,7 @@ V0CustomElementDefinition* V0CustomElementRegistry::registerElement(Document* do
return 0;
}
- if (m_registeredTypeNames.contains(type)) {
+ if (m_registeredTypeNames.contains(type) || v1CustomElementIsDefined(type)) {
V0CustomElementException::throwException(V0CustomElementException::TypeAlreadyRegistered, type, exceptionState);
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698