bindings: Cleans up V8{HTML,SVG}ElementWrapperFactory.

Removes unnecessary code around ElementWrapperFactory.

BUG=235436

Review URL: https://codereview.chromium.org/552733002

git-svn-id: svn://svn.chromium.org/blink/trunk@181558 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 502e5bfc
...@@ -33,18 +33,16 @@ ...@@ -33,18 +33,16 @@
namespace blink { namespace blink {
PassOwnPtr<CustomElementBinding> CustomElementBinding::create(v8::Isolate* isolate, v8::Handle<v8::Object> prototype, const WrapperTypeInfo* wrapperType) PassOwnPtr<CustomElementBinding> CustomElementBinding::create(v8::Isolate* isolate, v8::Handle<v8::Object> prototype)
{ {
return adoptPtr(new CustomElementBinding(isolate, prototype, wrapperType)); return adoptPtr(new CustomElementBinding(isolate, prototype));
} }
CustomElementBinding::CustomElementBinding(v8::Isolate* isolate, v8::Handle<v8::Object> prototype, const WrapperTypeInfo* wrapperType) CustomElementBinding::CustomElementBinding(v8::Isolate* isolate, v8::Handle<v8::Object> prototype)
: m_isolate(isolate) : m_isolate(isolate)
, m_prototype(isolate, prototype) , m_prototype(isolate, prototype)
, m_wrapperType(wrapperType)
{ {
ASSERT(!m_prototype.isEmpty()); ASSERT(!m_prototype.isEmpty());
ASSERT(m_wrapperType);
} }
} // namespace blink } // namespace blink
...@@ -37,25 +37,21 @@ ...@@ -37,25 +37,21 @@
namespace blink { namespace blink {
struct WrapperTypeInfo;
class CustomElementBinding { class CustomElementBinding {
public: public:
static PassOwnPtr<CustomElementBinding> create(v8::Isolate*, v8::Handle<v8::Object> prototype, const WrapperTypeInfo*); static PassOwnPtr<CustomElementBinding> create(v8::Isolate*, v8::Handle<v8::Object> prototype);
~CustomElementBinding() { } ~CustomElementBinding() { }
v8::Handle<v8::Object> prototype() { return m_prototype.newLocal(m_isolate); } v8::Handle<v8::Object> prototype() { return m_prototype.newLocal(m_isolate); }
const WrapperTypeInfo* wrapperType() { return m_wrapperType; }
private: private:
CustomElementBinding(v8::Isolate*, v8::Handle<v8::Object> prototype, const WrapperTypeInfo*); CustomElementBinding(v8::Isolate*, v8::Handle<v8::Object> prototype);
v8::Isolate* m_isolate; v8::Isolate* m_isolate;
ScopedPersistent<v8::Object> m_prototype; ScopedPersistent<v8::Object> m_prototype;
const WrapperTypeInfo* m_wrapperType;
}; };
} } // namespace blink
#endif // CustomElementBinding_h #endif // CustomElementBinding_h
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
#include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/V8Binding.h" #include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8Document.h" #include "bindings/core/v8/V8Document.h"
#include "bindings/core/v8/V8HTMLElement.h"
#include "bindings/core/v8/V8HiddenValue.h" #include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8PerContextData.h" #include "bindings/core/v8/V8PerContextData.h"
#include "bindings/core/v8/V8SVGElement.h"
#include "core/HTMLNames.h" #include "core/HTMLNames.h"
#include "core/SVGNames.h" #include "core/SVGNames.h"
#include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/v8
#include "core/V8SVGElementWrapperFactory.h" // FIXME: should be bindings/core/v8
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/dom/custom/CustomElementDefinition.h" #include "core/dom/custom/CustomElementDefinition.h"
#include "core/dom/custom/CustomElementDescriptor.h" #include "core/dom/custom/CustomElementDescriptor.h"
...@@ -57,7 +57,6 @@ static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>&); ...@@ -57,7 +57,6 @@ static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>&);
CustomElementConstructorBuilder::CustomElementConstructorBuilder(ScriptState* scriptState, const Dictionary* options) CustomElementConstructorBuilder::CustomElementConstructorBuilder(ScriptState* scriptState, const Dictionary* options)
: m_scriptState(scriptState) : m_scriptState(scriptState)
, m_options(options) , m_options(options)
, m_wrapperType(0)
{ {
ASSERT(m_scriptState->context() == m_scriptState->isolate()->GetCurrentContext()); ASSERT(m_scriptState->context() == m_scriptState->isolate()->GetCurrentContext());
} }
...@@ -139,17 +138,9 @@ bool CustomElementConstructorBuilder::validateOptions(const AtomicString& type, ...@@ -139,17 +138,9 @@ bool CustomElementConstructorBuilder::validateOptions(const AtomicString& type,
localName = type; localName = type;
} }
if (!extendsProvidedAndNonNull)
m_wrapperType = &V8HTMLElement::wrapperTypeInfo;
else if (namespaceURI == HTMLNames::xhtmlNamespaceURI)
m_wrapperType = findWrapperTypeForHTMLTagName(localName);
else
m_wrapperType = findWrapperTypeForSVGTagName(localName);
ASSERT(!tryCatch.HasCaught()); ASSERT(!tryCatch.HasCaught());
ASSERT(m_wrapperType);
tagName = QualifiedName(nullAtom, localName, namespaceURI); tagName = QualifiedName(nullAtom, localName, namespaceURI);
return m_wrapperType; return true;
} }
PassRefPtr<CustomElementLifecycleCallbacks> CustomElementConstructorBuilder::createCallbacks() PassRefPtr<CustomElementLifecycleCallbacks> CustomElementConstructorBuilder::createCallbacks()
...@@ -248,7 +239,7 @@ bool CustomElementConstructorBuilder::didRegisterDefinition(CustomElementDefinit ...@@ -248,7 +239,7 @@ bool CustomElementConstructorBuilder::didRegisterDefinition(CustomElementDefinit
{ {
ASSERT(!m_constructor.IsEmpty()); ASSERT(!m_constructor.IsEmpty());
return m_callbacks->setBinding(definition, CustomElementBinding::create(m_scriptState->isolate(), m_prototype, m_wrapperType)); return m_callbacks->setBinding(definition, CustomElementBinding::create(m_scriptState->isolate(), m_prototype));
} }
ScriptValue CustomElementConstructorBuilder::bindingsReturnValue() const ScriptValue CustomElementConstructorBuilder::bindingsReturnValue() const
......
...@@ -84,11 +84,10 @@ private: ...@@ -84,11 +84,10 @@ private:
RefPtr<ScriptState> m_scriptState; RefPtr<ScriptState> m_scriptState;
const Dictionary* m_options; const Dictionary* m_options;
v8::Handle<v8::Object> m_prototype; v8::Handle<v8::Object> m_prototype;
const WrapperTypeInfo* m_wrapperType;
v8::Handle<v8::Function> m_constructor; v8::Handle<v8::Function> m_constructor;
RefPtr<V8CustomElementLifecycleCallbacks> m_callbacks; RefPtr<V8CustomElementLifecycleCallbacks> m_callbacks;
}; };
} } // namespace blink
#endif // CustomElementConstructorBuilder_h #endif // CustomElementConstructorBuilder_h
...@@ -63,8 +63,6 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter): ...@@ -63,8 +63,6 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
self._outputs.update({ self._outputs.update({
(self.namespace + 'ElementFactory.h'): self.generate_factory_header, (self.namespace + 'ElementFactory.h'): self.generate_factory_header,
(self.namespace + 'ElementFactory.cpp'): self.generate_factory_implementation, (self.namespace + 'ElementFactory.cpp'): self.generate_factory_implementation,
('V8' + self.namespace + 'ElementWrapperFactory.h'): self.generate_wrapper_factory_header,
('V8' + self.namespace + 'ElementWrapperFactory.cpp'): self.generate_wrapper_factory_implementation,
}) })
fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName'].strip('"') fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName'].strip('"')
...@@ -94,14 +92,6 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter): ...@@ -94,14 +92,6 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
def generate_factory_implementation(self): def generate_factory_implementation(self):
return self._template_context return self._template_context
@template_expander.use_jinja('ElementWrapperFactory.h.tmpl', filters=filters)
def generate_wrapper_factory_header(self):
return self._template_context
@template_expander.use_jinja('ElementWrapperFactory.cpp.tmpl', filters=filters)
def generate_wrapper_factory_implementation(self):
return self._template_context
def _interface(self, tag): def _interface(self, tag):
if tag['interfaceName']: if tag['interfaceName']:
return tag['interfaceName'] return tag['interfaceName']
......
...@@ -48,8 +48,6 @@ make_element_factory_files = make_qualified_names_files + [ ...@@ -48,8 +48,6 @@ make_element_factory_files = make_qualified_names_files + [
"$_scripts_dir/make_element_factory.py", "$_scripts_dir/make_element_factory.py",
"$_scripts_dir/templates/ElementFactory.cpp.tmpl", "$_scripts_dir/templates/ElementFactory.cpp.tmpl",
"$_scripts_dir/templates/ElementFactory.h.tmpl", "$_scripts_dir/templates/ElementFactory.h.tmpl",
"$_scripts_dir/templates/ElementWrapperFactory.cpp.tmpl",
"$_scripts_dir/templates/ElementWrapperFactory.h.tmpl",
] ]
make_element_type_helpers_files = make_qualified_names_files + [ make_element_type_helpers_files = make_qualified_names_files + [
...@@ -193,4 +191,3 @@ template("make_token_matcher") { ...@@ -193,4 +191,3 @@ template("make_token_matcher") {
deps = make_core_generated_deps deps = make_core_generated_deps
} }
} }
...@@ -42,8 +42,6 @@ ...@@ -42,8 +42,6 @@
'make_element_factory.py', 'make_element_factory.py',
'templates/ElementFactory.cpp.tmpl', 'templates/ElementFactory.cpp.tmpl',
'templates/ElementFactory.h.tmpl', 'templates/ElementFactory.h.tmpl',
'templates/ElementWrapperFactory.cpp.tmpl',
'templates/ElementWrapperFactory.h.tmpl',
], ],
'make_element_type_helpers_files': [ 'make_element_type_helpers_files': [
'<@(make_qualified_names_files)', '<@(make_qualified_names_files)',
......
{% from "macros.tmpl" import license %}
{{ license() }}
#include "config.h"
#include "V8{{namespace}}ElementWrapperFactory.h"
#include "{{namespace}}Names.h"
{% for tag in tags|sort if tag.has_js_interface %}
#include "bindings/core/v8/V8{{tag.interface}}.h"
{% endfor %}
{% for tag in tags|sort if tag.has_js_interface %}
#include "core/{{namespace|lower}}/{{tag.js_interface}}.h"
{% endfor %}
#include "core/{{namespace|lower}}/{{fallback_js_interface}}.h"
#include "core/dom/Document.h"
#include "core/frame/Settings.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "wtf/StdLibExtras.h"
namespace blink {
using namespace {{namespace}}Names;
const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString& name)
{
typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap;
DEFINE_STATIC_LOCAL(NameTypeMap, map, ());
if (map.isEmpty()) {
// FIXME: This seems wrong. We should list every interface here, not
// just the ones that have specialized JavaScript interfaces.
{% for tag in tags|sort if tag.has_js_interface %}
{% filter enable_conditional(tag.Conditional) %}
map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::wrapperTypeInfo);
{% endfilter %}
{% endfor %}
}
if (const WrapperTypeInfo* result = map.get(name.impl()))
return result;
return &V8{{fallback_js_interface}}::wrapperTypeInfo;
}
} // namespace blink
{% from "macros.tmpl" import license %}
{{ license() }}
#ifndef V8{{namespace}}ElementWrapperFactory_h
#define V8{{namespace}}ElementWrapperFactory_h
#include "bindings/core/v8/V8{{namespace}}Element.h"
#include "bindings/core/v8/V8{{fallback_js_interface}}.h"
#include <v8.h>
namespace blink {
const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString& name);
}
#endif // V8{{namespace}}ElementWrapperFactory_h
...@@ -370,7 +370,6 @@ source_set("core_generated") { ...@@ -370,7 +370,6 @@ source_set("core_generated") {
"$blink_core_output_dir/MathMLNames.cpp", "$blink_core_output_dir/MathMLNames.cpp",
"$blink_core_output_dir/SVGNames.cpp", "$blink_core_output_dir/SVGNames.cpp",
"$blink_core_output_dir/UserAgentStyleSheetsData.cpp", "$blink_core_output_dir/UserAgentStyleSheetsData.cpp",
"$blink_core_output_dir/V8HTMLElementWrapperFactory.cpp",
"$blink_core_output_dir/XLinkNames.cpp", "$blink_core_output_dir/XLinkNames.cpp",
"$blink_core_output_dir/XMLNSNames.cpp", "$blink_core_output_dir/XMLNSNames.cpp",
"$blink_core_output_dir/XMLNames.cpp", "$blink_core_output_dir/XMLNames.cpp",
...@@ -412,7 +411,6 @@ source_set("core_generated") { ...@@ -412,7 +411,6 @@ source_set("core_generated") {
# Additional .cpp files for SVG. # Additional .cpp files for SVG.
"$blink_core_output_dir/SVGElementFactory.cpp", "$blink_core_output_dir/SVGElementFactory.cpp",
"$blink_core_output_dir/V8SVGElementWrapperFactory.cpp",
# Generated from make_style_shorthands.py # Generated from make_style_shorthands.py
"$blink_core_output_dir/StylePropertyShorthand.cpp", "$blink_core_output_dir/StylePropertyShorthand.cpp",
...@@ -691,8 +689,6 @@ process_in_files("make_core_generated_html_element_factory") { ...@@ -691,8 +689,6 @@ process_in_files("make_core_generated_html_element_factory") {
"$blink_core_output_dir/HTMLElementFactory.h", "$blink_core_output_dir/HTMLElementFactory.h",
"$blink_core_output_dir/HTMLNames.cpp", "$blink_core_output_dir/HTMLNames.cpp",
"$blink_core_output_dir/HTMLNames.h", "$blink_core_output_dir/HTMLNames.h",
"$blink_core_output_dir/V8HTMLElementWrapperFactory.cpp",
"$blink_core_output_dir/V8HTMLElementWrapperFactory.h",
] ]
} }
...@@ -723,8 +719,6 @@ process_in_files("make_core_generated_svg_names") { ...@@ -723,8 +719,6 @@ process_in_files("make_core_generated_svg_names") {
"$blink_core_output_dir/SVGElementFactory.h", "$blink_core_output_dir/SVGElementFactory.h",
"$blink_core_output_dir/SVGNames.cpp", "$blink_core_output_dir/SVGNames.cpp",
"$blink_core_output_dir/SVGNames.h", "$blink_core_output_dir/SVGNames.h",
"$blink_core_output_dir/V8SVGElementWrapperFactory.cpp",
"$blink_core_output_dir/V8SVGElementWrapperFactory.h",
] ]
} }
......
...@@ -228,7 +228,6 @@ ...@@ -228,7 +228,6 @@
'<(blink_core_output_dir)/MathMLNames.cpp', '<(blink_core_output_dir)/MathMLNames.cpp',
'<(blink_core_output_dir)/SVGNames.cpp', '<(blink_core_output_dir)/SVGNames.cpp',
'<(blink_core_output_dir)/UserAgentStyleSheetsData.cpp', '<(blink_core_output_dir)/UserAgentStyleSheetsData.cpp',
'<(blink_core_output_dir)/V8HTMLElementWrapperFactory.cpp',
'<(blink_core_output_dir)/XLinkNames.cpp', '<(blink_core_output_dir)/XLinkNames.cpp',
'<(blink_core_output_dir)/XMLNSNames.cpp', '<(blink_core_output_dir)/XMLNSNames.cpp',
'<(blink_core_output_dir)/XMLNames.cpp', '<(blink_core_output_dir)/XMLNames.cpp',
...@@ -270,7 +269,6 @@ ...@@ -270,7 +269,6 @@
# Additional .cpp files for SVG. # Additional .cpp files for SVG.
'<(blink_core_output_dir)/SVGElementFactory.cpp', '<(blink_core_output_dir)/SVGElementFactory.cpp',
'<(blink_core_output_dir)/V8SVGElementWrapperFactory.cpp',
# Generated from make_style_shorthands.py # Generated from make_style_shorthands.py
'<(blink_core_output_dir)/StylePropertyShorthand.cpp', '<(blink_core_output_dir)/StylePropertyShorthand.cpp',
......
...@@ -407,8 +407,6 @@ ...@@ -407,8 +407,6 @@
'<(blink_core_output_dir)/HTMLElementFactory.h', '<(blink_core_output_dir)/HTMLElementFactory.h',
'<(blink_core_output_dir)/HTMLNames.cpp', '<(blink_core_output_dir)/HTMLNames.cpp',
'<(blink_core_output_dir)/HTMLNames.h', '<(blink_core_output_dir)/HTMLNames.h',
'<(blink_core_output_dir)/V8HTMLElementWrapperFactory.cpp',
'<(blink_core_output_dir)/V8HTMLElementWrapperFactory.h',
], ],
'action': [ 'action': [
'python', 'python',
...@@ -448,8 +446,6 @@ ...@@ -448,8 +446,6 @@
'<(blink_core_output_dir)/SVGElementFactory.h', '<(blink_core_output_dir)/SVGElementFactory.h',
'<(blink_core_output_dir)/SVGNames.cpp', '<(blink_core_output_dir)/SVGNames.cpp',
'<(blink_core_output_dir)/SVGNames.h', '<(blink_core_output_dir)/SVGNames.h',
'<(blink_core_output_dir)/V8SVGElementWrapperFactory.cpp',
'<(blink_core_output_dir)/V8SVGElementWrapperFactory.h',
], ],
'action': [ 'action': [
'python', 'python',
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "core/CSSPropertyNames.h" #include "core/CSSPropertyNames.h"
#include "core/CSSValueKeywords.h" #include "core/CSSValueKeywords.h"
#include "core/HTMLNames.h" #include "core/HTMLNames.h"
#include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/v8
#include "core/XMLNames.h" #include "core/XMLNames.h"
#include "core/css/CSSMarkup.h" #include "core/css/CSSMarkup.h"
#include "core/css/CSSValuePool.h" #include "core/css/CSSValuePool.h"
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "bindings/core/v8/ScriptEventListener.h" #include "bindings/core/v8/ScriptEventListener.h"
#include "core/HTMLNames.h" #include "core/HTMLNames.h"
#include "core/SVGNames.h" #include "core/SVGNames.h"
#include "core/V8SVGElementWrapperFactory.h" // FIXME: should be bindings/core/v8
#include "core/XLinkNames.h" #include "core/XLinkNames.h"
#include "core/XMLNames.h" #include "core/XMLNames.h"
#include "core/css/CSSCursorImageValue.h" #include "core/css/CSSCursorImageValue.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment