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

Unified Diff: Source/core/dom/CustomElementRegistry.cpp

Issue 16708002: Simplify Custom Element constructors to be functions, not wrappers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix callback functions as parameters Created 7 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
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

Powered by Google App Engine
This is Rietveld 408576698