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

Unified Diff: Source/bindings/v8/CustomElementHelpers.h

Issue 14776002: Create wrappers for unresolved Custom Elements at the correct type (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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/bindings/v8/CustomElementHelpers.h
diff --git a/Source/bindings/v8/CustomElementHelpers.h b/Source/bindings/v8/CustomElementHelpers.h
index e1ffcb9cbef96604f82a525a4b66dfcf7da81152..b5e1f7e9a5295b71a28b22130b847f2d09eee441 100644
--- a/Source/bindings/v8/CustomElementHelpers.h
+++ b/Source/bindings/v8/CustomElementHelpers.h
@@ -43,8 +43,10 @@ namespace WebCore {
class CustomElementConstructor;
class CustomElementInvocation;
+class HTMLElement;
class QualifiedName;
class ScriptState;
+class SVGElement;
haraken 2013/05/01 18:49:12 Nit: Alphabetical order please.
class CustomElementHelpers {
public:
@@ -64,28 +66,36 @@ public:
// even for custom elements. Then generated
// ElementWrapperFactories call V8CustomElement::wrap() with
// proper prototype instances accordingly.
- static v8::Handle<v8::Object> wrap(Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
- static bool hasDefinition(Element*);
+ typedef v8::Handle<v8::Object> (*CreateSVGWrapperFunction)(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
+ typedef v8::Handle<v8::Object> (*CreateHTMLWrapperFunction)(HTMLElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
+ class CreateWrapperFunction {
dglazkov 2013/05/01 16:51:22 Effectively, CreateWrapperFunction carries the kno
dominicc (has gone to gerrit) 2013/05/02 01:29:56 I added a brief comment. It's C++ man... in any re
+ public:
+ explicit CreateWrapperFunction(CreateSVGWrapperFunction svg)
+ : m_svg(svg) { }
+ explicit CreateWrapperFunction(CreateHTMLWrapperFunction html)
+ : m_html(html) { }
+ v8::Handle<v8::Object> invoke(Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*) const;
+ private:
+ CreateSVGWrapperFunction m_svg;
+ CreateHTMLWrapperFunction m_html;
+ };
+
+ static v8::Handle<v8::Object> wrap(Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper);
+
+ static bool isCustomElement(Element*);
private:
static void invokeReadyCallbackIfNeeded(Element*, v8::Handle<v8::Context>);
- static v8::Handle<v8::Object> createWrapper(PassRefPtr<Element>, v8::Handle<v8::Object>, v8::Isolate*);
+ static v8::Handle<v8::Object> createWrapper(PassRefPtr<Element>, v8::Handle<v8::Object>, v8::Isolate*, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper);
+ static v8::Handle<v8::Object> createUpgradeCandidateWrapper(PassRefPtr<Element>, v8::Handle<v8::Object> creationContext, v8::Isolate*, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper);
dglazkov 2013/05/01 16:51:22 The new createUpgradeCandidateWrapper serves as th
};
-inline v8::Handle<v8::Object> CustomElementHelpers::wrap(Element* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+inline v8::Handle<v8::Object> CustomElementHelpers::wrap(Element* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, const CreateWrapperFunction& createWrapper)
{
ASSERT(impl);
ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty());
- return CustomElementHelpers::createWrapper(impl, creationContext, isolate);
-}
-
-inline bool CustomElementHelpers::hasDefinition(Element* element)
-{
- CustomElementRegistry* registry = element->document()->registry();
- if (registry && registry->findFor(element))
- return 1;
- return 0;
+ return CustomElementHelpers::createWrapper(impl, creationContext, isolate, createWrapper);
}
inline bool CustomElementHelpers::isValidPrototypeParameter(const ScriptValue& value, ScriptState* state)

Powered by Google App Engine
This is Rietveld 408576698