Chromium Code Reviews| 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) |