Chromium Code Reviews| 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; |
| } |