Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl

Issue 2794453002: [Bindings] Replace V8HiddenValue in generated code with V8PrivateProperty (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {% extends 'interface_base.cpp.tmpl' %} 1 {% extends 'interface_base.cpp.tmpl' %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% block indexed_property_getter %} 4 {% block indexed_property_getter %}
5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
6 {% set getter = indexed_property_getter %} 6 {% set getter = indexed_property_getter %}
7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) {
8 {% if getter.is_raises_exception %} 8 {% if getter.is_raises_exception %}
9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}"); 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}");
10 {% endif %} 10 {% endif %}
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 properly supports the incumbent realm. #} 484 properly supports the incumbent realm. #}
485 {% block origin_safe_method_setter %} 485 {% block origin_safe_method_setter %}
486 {% if has_origin_safe_method_setter %} 486 {% if has_origin_safe_method_setter %}
487 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { 487 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) {
488 if (!name->IsString()) 488 if (!name->IsString())
489 return; 489 return;
490 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info .Holder(), info.GetIsolate()); 490 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info .Holder(), info.GetIsolate());
491 if (holder.IsEmpty()) 491 if (holder.IsEmpty())
492 return; 492 return;
493 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 493 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
494 v8::String::Utf8Value attributeName(name); 494 v8::String::Utf8Value methodName(name);
495 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", *attributeName); 495 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", *methodName);
496 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) { 496 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) {
497 return; 497 return;
498 } 498 }
499 499
500 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand le if info.Holder() is an Object. #} 500 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand le if info.Holder() is an Object. #}
501 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::Loc al<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value); 501 {% raw %}
502 // |methodName| must be same with {{method.name}} in
503 // {{method.name}}OriginSafeMethodGetter{{world_suffix}} defined in
504 // methods.cpp.tmpl
505 {% endraw %}
506 V8PrivateProperty::getSymbol(info.GetIsolate(), *methodName)
507 .set(v8::Local<v8::Object>::Cast(info.Holder()), v8Value);
502 } 508 }
503 {% endif %} 509 {% endif %}
504 {% endblock %} 510 {% endblock %}
505 511
506 {% block origin_safe_method_setter_callback %} 512 {% block origin_safe_method_setter_callback %}
507 {% if has_origin_safe_method_setter %} 513 {% if has_origin_safe_method_setter %}
508 void {{v8_class_or_partial}}::{{cpp_class}}OriginSafeMethodSetterCallback(v8::Lo cal<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo <void>& info) { 514 void {{v8_class_or_partial}}::{{cpp_class}}OriginSafeMethodSetterCallback(v8::Lo cal<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo <void>& info) {
509 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in fo); 515 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in fo);
510 } 516 }
511 {% endif %} 517 {% endif %}
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 929 }
924 930
925 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 931 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
926 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { 932 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) {
927 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 933 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
928 } 934 }
929 935
930 {% endfor %} 936 {% endfor %}
931 {% endif %} 937 {% endif %}
932 {% endblock %} 938 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698