Chromium Code Reviews| Index: Source/core/dom/CustomElementRegistry.cpp |
| diff --git a/Source/core/dom/CustomElementRegistry.cpp b/Source/core/dom/CustomElementRegistry.cpp |
| index c81230671d7a509ff035a2ff4b76f57614b4e36f..2b45b4416c5504a9f760cdcaff13f6ff682bb392 100644 |
| --- a/Source/core/dom/CustomElementRegistry.cpp |
| +++ b/Source/core/dom/CustomElementRegistry.cpp |
| @@ -99,17 +99,17 @@ bool CustomElementRegistry::isValidName(const AtomicString& name) |
| return Document::isValidName(name.string()); |
| } |
| -PassRefPtr<CustomElementConstructor> CustomElementRegistry::registerElement(ScriptState* state, const AtomicString& userSuppliedName, const Dictionary& options, ExceptionCode& ec) |
| +ScriptValue CustomElementRegistry::registerElement(ScriptState* state, const AtomicString& userSuppliedName, const Dictionary& options, ExceptionCode& ec) |
| { |
| RefPtr<CustomElementRegistry> protect(this); |
| if (!CustomElementHelpers::isFeatureAllowed(state)) |
| - return 0; |
| + return ScriptValue(); |
| AtomicString name = userSuppliedName.lower(); |
| if (!isValidName(name)) { |
| ec = INVALID_CHARACTER_ERR; |
| - return 0; |
| + return ScriptValue(); |
| } |
| ScriptValue prototypeValue; |
| @@ -120,24 +120,24 @@ PassRefPtr<CustomElementConstructor> CustomElementRegistry::registerElement(Scri |
| // behavior. The spec should be fixed before WebKit implements |
| // it. https://www.w3.org/Bugs/Public/show_bug.cgi?id=20801 |
| ec = INVALID_STATE_ERR; |
| - return 0; |
| + return ScriptValue(); |
| } |
| AtomicString namespaceURI; |
| if (!CustomElementHelpers::isValidPrototypeParameter(prototypeValue, state, namespaceURI)) { |
| ec = INVALID_STATE_ERR; |
| - return 0; |
| + return ScriptValue(); |
| } |
| if (namespaceURI.isNull()) { |
| ec = NAMESPACE_ERR; |
| - return 0; |
| + return ScriptValue(); |
| } |
| AtomicString type = name; |
| if (m_definitions.contains(type)) { |
| ec = INVALID_STATE_ERR; |
| - return 0; |
| + return ScriptValue(); |
| } |
| const QualifiedName* prototypeTagName = CustomElementHelpers::findLocalName(prototypeValue); |
| @@ -147,16 +147,12 @@ PassRefPtr<CustomElementConstructor> CustomElementRegistry::registerElement(Scri |
| // A script execution could happen in isValidPrototypeParameter(), which kills the document. |
| if (!document()) { |
| ec = INVALID_STATE_ERR; |
| - return 0; |
| + return ScriptValue(); |
| } |
| RefPtr<CustomElementDefinition> definition = CustomElementDefinition::create(state, type, name, namespaceURI, prototypeValue); |
| - RefPtr<CustomElementConstructor> constructor = CustomElementConstructor::create(document(), definition->tagQName(), definition->isTypeExtension() ? definition->type() : nullAtom); |
| - if (!CustomElementHelpers::initializeConstructorWrapper(constructor.get(), prototypeValue, state)) { |
| - ec = INVALID_STATE_ERR; |
| - return 0; |
| - } |
| + ScriptValue constructor = CustomElementHelpers::createConstructor(state, prototypeValue, document(), definition->namespaceURI(), definition->name(), definition->isTypeExtension() ? definition->type() : nullAtom); |
|
Hajime Morrita
2013/06/10 04:32:22
Can this fail? We might need some guard if so.
|
| m_definitions.add(definition->type(), definition); |
| @@ -168,7 +164,7 @@ PassRefPtr<CustomElementConstructor> CustomElementRegistry::registerElement(Scri |
| activate(CustomElementInvocation(*it)); |
| } |
| - return constructor.release(); |
| + return constructor; |
| } |
| bool CustomElementRegistry::isUnresolved(Element* element) const |