| OLD | NEW |
| 1 {% include 'copyright_block.txt' %} | 1 {% include 'copyright_block.txt' %} |
| 2 #include "{{v8_class_or_partial}}.h" | 2 #include "{{v8_class_or_partial}}.h" |
| 3 | 3 |
| 4 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} | 4 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} |
| 5 #include "{{filename}}" | 5 #include "{{filename}}" |
| 6 {% endfor %} | 6 {% endfor %} |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class | 9 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class |
| 10 if has_visit_dom_wrapper else '0' %} | 10 if has_visit_dom_wrapper else '0' %} |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 {% endfor %} | 43 {% endfor %} |
| 44 {% endif %} | 44 {% endif %} |
| 45 | 45 |
| 46 {# Constants #} | 46 {# Constants #} |
| 47 {% from 'constants.cpp' import constant_getter_callback | 47 {% from 'constants.cpp' import constant_getter_callback |
| 48 with context %} | 48 with context %} |
| 49 {% for constant in special_getter_constants %} | 49 {% for constant in special_getter_constants %} |
| 50 {{constant_getter_callback(constant)}} | 50 {{constant_getter_callback(constant)}} |
| 51 {% endfor %} | 51 {% endfor %} |
| 52 {# Attributes #} | 52 {# Attributes #} |
| 53 {% block replaceable_attribute_setter_and_callback %} | 53 {% if has_replaceable_attributes %} |
| 54 {% if has_replaceable_attributes or has_constructor_attributes %} | |
| 55 template<class CallbackInfo> | 54 template<class CallbackInfo> |
| 56 static bool {{cpp_class}}CreateDataProperty(v8::Local<v8::Name> name, v8::Local<
v8::Value> v8Value, const CallbackInfo& info) | 55 static bool {{cpp_class}}CreateDataProperty(v8::Local<v8::Name> name, v8::Local<
v8::Value> v8Value, const CallbackInfo& info) |
| 57 { | 56 { |
| 58 {% if is_check_security %} | 57 {% if is_check_security %} |
| 59 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 58 #error TODO(yukishiino): Supports [Replaceable] accessor-type properties with se
curity check (if we really need it). |
| 60 v8::String::Utf8Value attributeName(name); | |
| 61 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | |
| 62 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo
w(info.GetIsolate()), impl, exceptionState)) { | |
| 63 exceptionState.throwIfNeeded(); | |
| 64 return false; | |
| 65 } | |
| 66 {% endif %} | 59 {% endif %} |
| 67 ASSERT(info.This()->IsObject()); | 60 ASSERT(info.This()->IsObject()); |
| 68 return v8CallBoolean(v8::Local<v8::Object>::Cast(info.This())->CreateDataPro
perty(info.GetIsolate()->GetCurrentContext(), name, v8Value)); | 61 return v8CallBoolean(v8::Local<v8::Object>::Cast(info.This())->CreateDataPro
perty(info.GetIsolate()->GetCurrentContext(), name, v8Value)); |
| 69 } | 62 } |
| 70 | 63 |
| 71 {% if needs_constructor_setter_callback %} | |
| 72 static void {{cpp_class}}ConstructorAttributeSetterCallback(v8::Local<v8::Name>,
v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) | |
| 73 { | |
| 74 do { | |
| 75 v8::Local<v8::Value> data = info.Data(); | |
| 76 ASSERT(data->IsExternal()); | |
| 77 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()-
>CreationContext()); | |
| 78 if (!perContextData) | |
| 79 break; | |
| 80 const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data); | |
| 81 if (!wrapperTypeInfo) | |
| 82 break; | |
| 83 {{cpp_class}}CreateDataProperty(v8String(info.GetIsolate(), wrapperTypeI
nfo->interfaceName), v8Value, info); | |
| 84 } while (false); // do ... while (false) just for use of break | |
| 85 } | |
| 86 | |
| 87 {% endif %} | 64 {% endif %} |
| 88 {% endif %} | |
| 89 {% endblock %} | |
| 90 {##############################################################################} | 65 {##############################################################################} |
| 91 {% from 'attributes.cpp' import constructor_getter_callback, | 66 {% from 'attributes.cpp' import constructor_getter_callback, |
| 92 attribute_getter, attribute_getter_callback, | 67 attribute_getter, attribute_getter_callback, |
| 93 attribute_setter, attribute_setter_callback, | 68 attribute_setter, attribute_setter_callback, |
| 94 attribute_getter_implemented_in_private_script, | 69 attribute_getter_implemented_in_private_script, |
| 95 attribute_setter_implemented_in_private_script | 70 attribute_setter_implemented_in_private_script |
| 96 with context %} | 71 with context %} |
| 97 {% for attribute in attributes if attribute.should_be_exposed_to_script %} | 72 {% for attribute in attributes if attribute.should_be_exposed_to_script %} |
| 98 {% for world_suffix in attribute.world_suffixes %} | 73 {% for world_suffix in attribute.world_suffixes %} |
| 99 {% if not attribute.constructor_type %} | 74 {% if not attribute.has_custom_getter and not attribute.constructor_type %} |
| 100 {% if not attribute.has_custom_getter %} | |
| 101 {{attribute_getter(attribute, world_suffix)}} | 75 {{attribute_getter(attribute, world_suffix)}} |
| 102 {% endif %} | 76 {% endif %} |
| 77 {% if not attribute.constructor_type %} |
| 103 {{attribute_getter_callback(attribute, world_suffix)}} | 78 {{attribute_getter_callback(attribute, world_suffix)}} |
| 79 {% elif attribute.needs_constructor_getter_callback %} |
| 80 {{constructor_getter_callback(attribute, world_suffix)}} |
| 104 {% endif %} | 81 {% endif %} |
| 105 {% if attribute.has_setter %} | 82 {% if attribute.has_setter %} |
| 106 {% if not attribute.has_custom_setter and | 83 {% if not attribute.has_custom_setter %} |
| 107 (not attribute.constructor_type or attribute.needs_constructor_setter_cal
lback) %} | |
| 108 {{attribute_setter(attribute, world_suffix)}} | 84 {{attribute_setter(attribute, world_suffix)}} |
| 109 {% endif %} | 85 {% endif %} |
| 110 {% if not attribute.constructor_type or attribute.needs_constructor_setter_callb
ack %} | |
| 111 {{attribute_setter_callback(attribute, world_suffix)}} | 86 {{attribute_setter_callback(attribute, world_suffix)}} |
| 112 {% endif %} | 87 {% endif %} |
| 113 {% endif %} | |
| 114 {% endfor %} | 88 {% endfor %} |
| 115 {% endfor %} | 89 {% endfor %} |
| 116 {##############################################################################} | 90 {##############################################################################} |
| 117 {% for attribute in attributes if attribute.needs_constructor_getter_callback %} | |
| 118 {% for world_suffix in attribute.world_suffixes %} | |
| 119 {{constructor_getter_callback(attribute, world_suffix)}} | |
| 120 {% endfor %} | |
| 121 {% endfor %} | |
| 122 {##############################################################################} | |
| 123 {% block security_check_functions %} | 91 {% block security_check_functions %} |
| 124 {% if has_access_check_callbacks %} | 92 {% if has_access_check_callbacks %} |
| 125 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object
> accessedObject, v8::Local<v8::Value> data) | 93 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object
> accessedObject, v8::Local<v8::Value> data) |
| 126 { | 94 { |
| 127 // TODO(jochen): Take accessingContext into account. | 95 // TODO(jochen): Take accessingContext into account. |
| 128 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); | 96 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); |
| 129 return BindingSecurity::shouldAllowAccessTo(v8::Isolate::GetCurrent(), calli
ngDOMWindow(v8::Isolate::GetCurrent()), impl, DoNotReportSecurityError); | 97 return BindingSecurity::shouldAllowAccessTo(v8::Isolate::GetCurrent(), calli
ngDOMWindow(v8::Isolate::GetCurrent()), impl, DoNotReportSecurityError); |
| 130 } | 98 } |
| 131 | 99 |
| 132 {% endif %} | 100 {% endif %} |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 {{method_implemented_in_private_script(method)}} | 404 {{method_implemented_in_private_script(method)}} |
| 437 {% endfor %} | 405 {% endfor %} |
| 438 {% for attribute in attributes if attribute.is_implemented_in_private_script %} | 406 {% for attribute in attributes if attribute.is_implemented_in_private_script %} |
| 439 {{attribute_getter_implemented_in_private_script(attribute)}} | 407 {{attribute_getter_implemented_in_private_script(attribute)}} |
| 440 {% if attribute.has_setter %} | 408 {% if attribute.has_setter %} |
| 441 {{attribute_setter_implemented_in_private_script(attribute)}} | 409 {{attribute_setter_implemented_in_private_script(attribute)}} |
| 442 {% endif %} | 410 {% endif %} |
| 443 {% endfor %} | 411 {% endfor %} |
| 444 {% block partial_interface %}{% endblock %} | 412 {% block partial_interface %}{% endblock %} |
| 445 } // namespace blink | 413 } // namespace blink |
| OLD | NEW |