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

Side by Side Diff: Source/bindings/templates/attributes.cpp

Issue 362993004: Implement Blink-in-JS for DOM attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro attribute_getter(attribute, world_suffix) %} 2 {% macro attribute_getter(attribute, world_suffix) %}
3 {% filter conditional(attribute.conditional_string) %} 3 {% filter conditional(attribute.conditional_string) %}
4 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 4 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
5 {%- if attribute.is_expose_js_accessors %} 5 {%- if attribute.is_expose_js_accessors %}
6 const v8::FunctionCallbackInfo<v8::Value>& info 6 const v8::FunctionCallbackInfo<v8::Value>& info
7 {%- else %} 7 {%- else %}
8 const v8::PropertyCallbackInfo<v8::Value>& info 8 const v8::PropertyCallbackInfo<v8::Value>& info
9 {%- endif %}) 9 {%- endif %})
10 { 10 {
(...skipping 30 matching lines...) Expand all
41 {% if attribute.is_call_with_script_state %} 41 {% if attribute.is_call_with_script_state %}
42 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); 42 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
43 {% endif %} 43 {% endif %}
44 {% if attribute.is_check_security_for_node or 44 {% if attribute.is_check_security_for_node or
45 attribute.is_getter_raises_exception %} 45 attribute.is_getter_raises_exception %}
46 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate()); 46 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate());
47 {% endif %} 47 {% endif %}
48 {% if attribute.is_nullable and not attribute.is_nullable_simple %} 48 {% if attribute.is_nullable and not attribute.is_nullable_simple %}
49 bool isNull = false; 49 bool isNull = false;
50 {% endif %} 50 {% endif %}
51 {% if attribute.cpp_value_original %} 51 {% if attribute.is_implemented_in_private_script %}
52 {{attribute.cpp_type}} result;
53 if (!{{attribute.cpp_value_original}})
54 return;
55 {% elif attribute.cpp_value_original %}
52 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_origina l}}); 56 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_origina l}});
53 {% endif %} 57 {% endif %}
54 {# Checks #} 58 {# Checks #}
55 {% if attribute.is_getter_raises_exception %} 59 {% if attribute.is_getter_raises_exception %}
56 if (UNLIKELY(exceptionState.throwIfNeeded())) 60 if (UNLIKELY(exceptionState.throwIfNeeded()))
57 return; 61 return;
58 {% endif %} 62 {% endif %}
59 {% if attribute.is_check_security_for_node %} 63 {% if attribute.is_check_security_for_node %}
60 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), {{attribute .cpp_value}}, exceptionState)) { 64 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), {{attribute .cpp_value}}, exceptionState)) {
61 v8SetReturnValueNull(info); 65 v8SetReturnValueNull(info);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 {% endif %} 329 {% endif %}
326 {% if attribute.has_custom_setter %} 330 {% if attribute.has_custom_setter %}
327 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); 331 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info);
328 {% else %} 332 {% else %}
329 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v 8Value, info); 333 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v 8Value, info);
330 {% endif %} 334 {% endif %}
331 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 335 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
332 } 336 }
333 {% endfilter %} 337 {% endfilter %}
334 {% endmacro %} 338 {% endmacro %}
339
340
341 {##############################################################################}
342 {% macro attribute_getter_implemented_in_private_script(attribute) %}
343 static bool {{attribute.name}}AttributeGetterImplementedInPrivateScript(LocalFra me* frame, {{cpp_class}}* holderImpl, {{attribute.cpp_type}}* result)
344 {
345 if (!frame)
346 return false;
347 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::privat eScriptIsolatedWorld());
348 if (context.IsEmpty())
349 return false;
350 ScriptState* scriptState = ScriptState::from(context);
351 if (!scriptState->executionContext())
352 return false;
353
354 ScriptState::Scope scope(scriptState);
355 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob al(), scriptState->isolate());
356
357 // FIXME: Support exceptions thrown from Blink-in-JS.
358 v8::TryCatch block;
359 v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(s criptState, "{{cpp_class}}", "{{attribute.name}}", holder);
360 if (block.HasCaught())
361 return false;
362 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{attribute .name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolat e());
363 {{attribute.private_script_v8_value_to_local_cpp_value}};
364 if (block.HasCaught())
365 return false;
366 *result = cppValue;
367 return true;
368 }
369 {% endmacro %}
370
371
372 {% macro attribute_setter_implemented_in_private_script(attribute) %}
373 static bool {{attribute.name}}AttributeSetterImplementedInPrivateScript(LocalFra me* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue)
374 {
375 if (!frame)
376 return false;
377 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::privat eScriptIsolatedWorld());
378 if (context.IsEmpty())
379 return false;
380 ScriptState* scriptState = ScriptState::from(context);
381 if (!scriptState->executionContext())
382 return false;
383
384 ScriptState::Scope scope(scriptState);
385 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob al(), scriptState->isolate());
386
387 // FIXME: Support exceptions thrown from Blink-in-JS.
388 v8::TryCatch block;
389 PrivateScriptRunner::runDOMAttributeSetter(scriptState, "{{cpp_class}}", "{{ attribute.name}}", holder, {{attribute.private_script_cpp_value_to_v8_value}});
390 if (block.HasCaught())
391 return false;
392 return true;
393 }
394 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698