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

Unified Diff: Source/bindings/scripts/v8_attributes.py

Issue 362993004: Implement Blink-in-JS for DOM attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/scripts/v8_attributes.py
diff --git a/Source/bindings/scripts/v8_attributes.py b/Source/bindings/scripts/v8_attributes.py
index e1c6489078fe98ad7a45cc33c0cbaceb9e01c335..615e0074d884642e1cdd4a83278a2b012ebae6cd 100644
--- a/Source/bindings/scripts/v8_attributes.py
+++ b/Source/bindings/scripts/v8_attributes.py
@@ -71,6 +71,11 @@ def attribute_context(interface, attribute):
(has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')) and
idl_type.name in ('Float', 'Double'))
+ # [ImplementedInPrivateScript]
+ is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes
+ if is_implemented_in_private_script:
+ includes.add('bindings/core/v8/PrivateScriptRunner.h')
+ includes.add('core/frame/LocalFrame.h')
if (base_idl_type == 'EventHandler' and
interface.name in ['Window', 'WorkerGlobalScope'] and
@@ -108,6 +113,7 @@ def attribute_context(interface, attribute):
'is_getter_raises_exception': # [RaisesException]
'RaisesException' in extended_attributes and
extended_attributes['RaisesException'] in (None, 'Getter'),
+ 'is_implemented_in_private_script': is_implemented_in_private_script,
'is_initialized_by_event_constructor':
'InitializedByEventConstructor' in extended_attributes,
'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute),
@@ -127,11 +133,14 @@ def attribute_context(interface, attribute):
'per_context_enabled_function': v8_utilities.per_context_enabled_function_name(attribute), # [PerContextEnabled]
'property_attributes': property_attributes(attribute),
'put_forwards': 'PutForwards' in extended_attributes,
+ 'raw_cpp_type': idl_type.cpp_type_args(raw_type=True),
'reflect_empty': extended_attributes.get('ReflectEmpty'),
'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
'reflect_missing': extended_attributes.get('ReflectMissing'),
'reflect_only': extended_attributes['ReflectOnly'].split('|')
if 'ReflectOnly' in extended_attributes else None,
+ 'returned_v8_value_to_local_cpp_value': v8_types.v8_value_to_cpp_value(
+ idl_type, extended_attributes, 'v8Value', 0, isolate='scriptState->isolate()'),
'setter_callback': setter_callback_name(interface, attribute),
'v8_type': v8_types.v8_type(base_idl_type),
'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled]
@@ -179,8 +188,19 @@ def getter_context(interface, attribute, context):
context['cpp_value_original'] = cpp_value
cpp_value = 'cppValue'
# EventHandler has special handling
- if base_idl_type != 'EventHandler' and idl_type.is_interface_type:
- release = True
+ if base_idl_type != 'EventHandler':
+ release = idl_type.release
+
+ if 'ImplementedInPrivateScript' in extended_attributes:
+ if (not idl_type.is_wrapper_type and
+ not idl_type.is_basic_type):
+ raise Exception('Private scripts supports only primitive types and DOM wrappers.')
+
+ context['cpp_value_original'] = cpp_value
+ cpp_value = 'result'
+ # EventHandler has special handling
+ if base_idl_type != 'EventHandler':
+ release = idl_type.release
def v8_set_return_value_statement(for_main_world=False):
if context['is_keep_alive_for_gc']:
@@ -202,6 +222,10 @@ def getter_expression(interface, attribute, context):
this_getter_base_name = getter_base_name(interface, attribute, arguments)
getter_name = scoped_name(interface, attribute, this_getter_base_name)
+ if 'ImplementedInPrivateScript' in attribute.extended_attributes:
+ arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())')
+ arguments.append('impl')
+ arguments.append('&result')
arguments.extend(v8_utilities.call_with_arguments(
attribute.extended_attributes.get('CallWith')))
# Members of IDL partial interface definitions are implemented in C++ as
@@ -226,6 +250,10 @@ CONTENT_ATTRIBUTE_GETTER_NAMES = {
def getter_base_name(interface, attribute, arguments):
extended_attributes = attribute.extended_attributes
+
+ if 'ImplementedInPrivateScript' in extended_attributes:
+ return '%sAttributeGetterImplementedInPrivateScript' % uncapitalize(cpp_name(attribute))
+
if 'Reflect' not in extended_attributes:
return uncapitalize(cpp_name(attribute))
@@ -310,6 +338,9 @@ def setter_context(interface, attribute, context):
'is_setter_raises_exception': is_setter_raises_exception,
'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(
extended_attributes, 'v8Value', 'cppValue'),
+ 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
+ 'cppValue', isolate='scriptState->isolate()',
+ creation_context='scriptState->context()->Global()'),
})
# setter_expression() depends on context values we set above.
@@ -332,7 +363,11 @@ def setter_expression(interface, attribute, context):
not attribute.is_static):
arguments.append('*impl')
idl_type = attribute.idl_type
- if idl_type.base_type == 'EventHandler':
+ if 'ImplementedInPrivateScript' in extended_attributes:
+ arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())')
+ arguments.append('impl')
+ arguments.append('cppValue')
+ elif idl_type.base_type == 'EventHandler':
getter_name = scoped_name(interface, attribute, cpp_name(attribute))
context['event_handler_getter_expression'] = '%s(%s)' % (
getter_name, ', '.join(arguments))
@@ -361,6 +396,9 @@ CONTENT_ATTRIBUTE_SETTER_NAMES = {
def setter_base_name(interface, attribute, arguments):
+ if 'ImplementedInPrivateScript' in attribute.extended_attributes:
+ return '%sAttributeSetterImplementedInPrivateScript' % uncapitalize(cpp_name(attribute))
+
if 'Reflect' not in attribute.extended_attributes:
return 'set%s' % capitalize(cpp_name(attribute))
arguments.append(scoped_content_attribute_name(interface, attribute))

Powered by Google App Engine
This is Rietveld 408576698