| OLD | NEW |
| 1 {##############################################################################} | 1 {##############################################################################} |
| 2 {% macro generate_method(method, world_suffix) %} | 2 {% macro generate_method(method, world_suffix) %} |
| 3 {% filter conditional(method.conditional_string) %} | 3 {% filter conditional(method.conditional_string) %} |
| 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
| 5 { | 5 { |
| 6 {% if method.is_raises_exception or method.is_check_security_for_frame or | 6 {% if method.is_raises_exception or method.is_check_security_for_frame or |
| 7 method.name in ['addEventListener', 'removeEventListener'] %} | 7 method.name in ['addEventListener', 'removeEventListener'] %} |
| 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 9 {% endif %} | 9 {% endif %} |
| 10 {% if method.name in ['addEventListener', 'removeEventListener'] %} | 10 {% if method.name in ['addEventListener', 'removeEventListener'] %} |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo
cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) | 285 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo
cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 286 { | 286 { |
| 287 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 287 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 288 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix
}}(info); | 288 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix
}}(info); |
| 289 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 289 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 290 } | 290 } |
| 291 {% endmacro %} | 291 {% endmacro %} |
| 292 | 292 |
| 293 | 293 |
| 294 {##############################################################################} | 294 {##############################################################################} |
| 295 {% macro constructor_callback(constructor) %} | 295 {% macro generate_constructor(constructor) %} |
| 296 static void constructor{{constructor.overload_index}}(const v8::FunctionCallback
Info<v8::Value>& info) | 296 static void constructor{{constructor.overload_index}}(const v8::FunctionCallback
Info<v8::Value>& info) |
| 297 { | 297 { |
| 298 {% if interface_length and not constructor.overload_index %} | 298 {% if interface_length and not constructor.overload_index %} |
| 299 {# FIXME: remove this UNLIKELY: constructors are heavy, so no difference. #} | 299 {# FIXME: remove this UNLIKELY: constructors are heavy, so no difference. #} |
| 300 if (UNLIKELY(info.Length() < {{interface_length}})) { | 300 if (UNLIKELY(info.Length() < {{interface_length}})) { |
| 301 {{throw_type_error({'name': 'Constructor'}, | 301 {{throw_type_error({'name': 'Constructor'}, |
| 302 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % | 302 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % |
| 303 interface_length)}} | 303 interface_length)}} |
| 304 return; | 304 return; |
| 305 } | 305 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 322 if (exceptionState.throwIfNeeded()) | 322 if (exceptionState.throwIfNeeded()) |
| 323 return; | 323 return; |
| 324 {% endif %} | 324 {% endif %} |
| 325 | 325 |
| 326 {# FIXME: Should probably be Independent unless [ActiveDOMObject] | 326 {# FIXME: Should probably be Independent unless [ActiveDOMObject] |
| 327 or [DependentLifetime]. #} | 327 or [DependentLifetime]. #} |
| 328 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8
_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep
endent); | 328 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8
_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep
endent); |
| 329 v8SetReturnValue(info, wrapper); | 329 v8SetReturnValue(info, wrapper); |
| 330 } | 330 } |
| 331 {% endmacro %} | 331 {% endmacro %} |
| 332 |
| 333 |
| 334 {##############################################################################} |
| 335 {% macro named_constructor_callback(constructor) %} |
| 336 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V
alue>& info) |
| 337 { |
| 338 if (!info.IsConstructCall()) { |
| 339 throwTypeError(ExceptionMessages::failedToConstruct("{{constructor.name}
}", "Please use the 'new' operator, this DOM object constructor cannot be called
as a function."), info.GetIsolate()); |
| 340 return; |
| 341 } |
| 342 |
| 343 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
| 344 v8SetReturnValue(info, info.Holder()); |
| 345 return; |
| 346 } |
| 347 |
| 348 Document* document = currentDocument(); |
| 349 ASSERT(document); |
| 350 |
| 351 // Make sure the document is added to the DOM Node map. Otherwise, the {{cpp
_class}} instance |
| 352 // may end up being the only node in the map and get garbage-collected prema
turely. |
| 353 toV8(document, info.Holder(), info.GetIsolate()); |
| 354 |
| 355 {# FIXME: arguments #} |
| 356 {% set argument_list = ['*document'] %} |
| 357 RefPtr<{{cpp_class}}> impl = {{cpp_class}}::createForJSConstructor({{argumen
t_list | join(', ')}}); |
| 358 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 359 |
| 360 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8
_class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu
ration::Dependent); |
| 361 v8SetReturnValue(info, wrapper); |
| 362 } |
| 363 {% endmacro %} |
| OLD | NEW |