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 @@
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_prototype(isolate, prototype)
, m_wrapperType(wrapperType)
{
ASSERT(!m_prototype.isEmpty());
ASSERT(m_wrapperType);
}
} // namespace blink
......@@ -37,25 +37,21 @@
namespace blink {
struct WrapperTypeInfo;
class CustomElementBinding {
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() { }
v8::Handle<v8::Object> prototype() { return m_prototype.newLocal(m_isolate); }
const WrapperTypeInfo* wrapperType() { return m_wrapperType; }
private:
CustomElementBinding(v8::Isolate*, v8::Handle<v8::Object> prototype, const WrapperTypeInfo*);
CustomElementBinding(v8::Isolate*, v8::Handle<v8::Object> prototype);
v8::Isolate* m_isolate;
ScopedPersistent<v8::Object> m_prototype;
const WrapperTypeInfo* m_wrapperType;
};
}
} // namespace blink
#endif // CustomElementBinding_h
......@@ -37,12 +37,12 @@
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8Document.h"
#include "bindings/core/v8/V8HTMLElement.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8PerContextData.h"
#include "bindings/core/v8/V8SVGElement.h"
#include "core/HTMLNames.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/custom/CustomElementDefinition.h"
#include "core/dom/custom/CustomElementDescriptor.h"
......@@ -57,7 +57,6 @@ static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>&);
CustomElementConstructorBuilder::CustomElementConstructorBuilder(ScriptState* scriptState, const Dictionary* options)
: m_scriptState(scriptState)
, m_options(options)
, m_wrapperType(0)
{
ASSERT(m_scriptState->context() == m_scriptState->isolate()->GetCurrentContext());
}
......@@ -139,17 +138,9 @@ bool CustomElementConstructorBuilder::validateOptions(const AtomicString& 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(m_wrapperType);
tagName = QualifiedName(nullAtom, localName, namespaceURI);
return m_wrapperType;
return true;
}
PassRefPtr<CustomElementLifecycleCallbacks> CustomElementConstructorBuilder::createCallbacks()
......@@ -248,7 +239,7 @@ bool CustomElementConstructorBuilder::didRegisterDefinition(CustomElementDefinit
{
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
......
......@@ -84,11 +84,10 @@ private:
RefPtr<ScriptState> m_scriptState;
const Dictionary* m_options;
v8::Handle<v8::Object> m_prototype;
const WrapperTypeInfo* m_wrapperType;
v8::Handle<v8::Function> m_constructor;
RefPtr<V8CustomElementLifecycleCallbacks> m_callbacks;
};
}
} // namespace blink
#endif // CustomElementConstructorBuilder_h
......@@ -63,8 +63,6 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
self._outputs.update({
(self.namespace + 'ElementFactory.h'): self.generate_factory_header,
(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('"')
......@@ -94,14 +92,6 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
def generate_factory_implementation(self):
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):
if tag['interfaceName']:
return tag['interfaceName']
......
......@@ -48,8 +48,6 @@ make_element_factory_files = make_qualified_names_files + [
"$_scripts_dir/make_element_factory.py",
"$_scripts_dir/templates/ElementFactory.cpp.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 + [
......@@ -193,4 +191,3 @@ template("make_token_matcher") {
deps = make_core_generated_deps
}
}
......@@ -42,8 +42,6 @@
'make_element_factory.py',
'templates/ElementFactory.cpp.tmpl',
'templates/ElementFactory.h.tmpl',
'templates/ElementWrapperFactory.cpp.tmpl',
'templates/ElementWrapperFactory.h.tmpl',
],
'make_element_type_helpers_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") {
"$blink_core_output_dir/MathMLNames.cpp",
"$blink_core_output_dir/SVGNames.cpp",
"$blink_core_output_dir/UserAgentStyleSheetsData.cpp",
"$blink_core_output_dir/V8HTMLElementWrapperFactory.cpp",
"$blink_core_output_dir/XLinkNames.cpp",
"$blink_core_output_dir/XMLNSNames.cpp",
"$blink_core_output_dir/XMLNames.cpp",
......@@ -412,7 +411,6 @@ source_set("core_generated") {
# Additional .cpp files for SVG.
"$blink_core_output_dir/SVGElementFactory.cpp",
"$blink_core_output_dir/V8SVGElementWrapperFactory.cpp",
# Generated from make_style_shorthands.py
"$blink_core_output_dir/StylePropertyShorthand.cpp",
......@@ -691,8 +689,6 @@ process_in_files("make_core_generated_html_element_factory") {
"$blink_core_output_dir/HTMLElementFactory.h",
"$blink_core_output_dir/HTMLNames.cpp",
"$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") {
"$blink_core_output_dir/SVGElementFactory.h",
"$blink_core_output_dir/SVGNames.cpp",
"$blink_core_output_dir/SVGNames.h",
"$blink_core_output_dir/V8SVGElementWrapperFactory.cpp",
"$blink_core_output_dir/V8SVGElementWrapperFactory.h",
]
}
......
......@@ -228,7 +228,6 @@
'<(blink_core_output_dir)/MathMLNames.cpp',
'<(blink_core_output_dir)/SVGNames.cpp',
'<(blink_core_output_dir)/UserAgentStyleSheetsData.cpp',
'<(blink_core_output_dir)/V8HTMLElementWrapperFactory.cpp',
'<(blink_core_output_dir)/XLinkNames.cpp',
'<(blink_core_output_dir)/XMLNSNames.cpp',
'<(blink_core_output_dir)/XMLNames.cpp',
......@@ -270,7 +269,6 @@
# Additional .cpp files for SVG.
'<(blink_core_output_dir)/SVGElementFactory.cpp',
'<(blink_core_output_dir)/V8SVGElementWrapperFactory.cpp',
# Generated from make_style_shorthands.py
'<(blink_core_output_dir)/StylePropertyShorthand.cpp',
......
......@@ -407,8 +407,6 @@
'<(blink_core_output_dir)/HTMLElementFactory.h',
'<(blink_core_output_dir)/HTMLNames.cpp',
'<(blink_core_output_dir)/HTMLNames.h',
'<(blink_core_output_dir)/V8HTMLElementWrapperFactory.cpp',
'<(blink_core_output_dir)/V8HTMLElementWrapperFactory.h',
],
'action': [
'python',
......@@ -448,8 +446,6 @@
'<(blink_core_output_dir)/SVGElementFactory.h',
'<(blink_core_output_dir)/SVGNames.cpp',
'<(blink_core_output_dir)/SVGNames.h',
'<(blink_core_output_dir)/V8SVGElementWrapperFactory.cpp',
'<(blink_core_output_dir)/V8SVGElementWrapperFactory.h',
],
'action': [
'python',
......
......@@ -30,7 +30,6 @@
#include "core/CSSPropertyNames.h"
#include "core/CSSValueKeywords.h"
#include "core/HTMLNames.h"
#include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/v8
#include "core/XMLNames.h"
#include "core/css/CSSMarkup.h"
#include "core/css/CSSValuePool.h"
......
......@@ -28,7 +28,6 @@
#include "bindings/core/v8/ScriptEventListener.h"
#include "core/HTMLNames.h"
#include "core/SVGNames.h"
#include "core/V8SVGElementWrapperFactory.h" // FIXME: should be bindings/core/v8
#include "core/XLinkNames.h"
#include "core/XMLNames.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