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

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: Use toV8 in the constructor. Remove unused variable. 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..67e779fd140baca63cf438bad5e0aed1d797bfb7 100644
--- a/Source/bindings/v8/CustomElementHelpers.h
+++ b/Source/bindings/v8/CustomElementHelpers.h
@@ -43,7 +43,9 @@ namespace WebCore {
class CustomElementConstructor;
class CustomElementInvocation;
+class HTMLElement;
class QualifiedName;
+class SVGElement;
class ScriptState;
class CustomElementHelpers {
@@ -60,32 +62,45 @@ public:
static void invokeReadyCallbacksIfNeeded(ScriptExecutionContext*, const Vector<CustomElementInvocation>&);
+ 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*);
+
+ // CustomElementHelpers::wrap is a factory for both HTMLElement
+ // and SVGElement wrappers. CreateWrapperFunction is a type safe
+ // way of passing a wrapping function for specific elements of
+ // either type; it's used as a fallback when creating wrappers for
+ // type extensions.
+ class CreateWrapperFunction {
+ 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;
+ };
+
// You can just use toV8(Node*) to get correct wrapper objects,
// 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 v8::Handle<v8::Object> wrap(Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper);
- static bool hasDefinition(Element*);
+ 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);
};
-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