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

Unified Diff: bindings/scripts/v8_utilities.py

Issue 2786203002: Roll 50: Copied IDLs, PYTHON scripts from WebKit removed deleted files in WebCore (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « bindings/scripts/v8_union.py ('k') | bindings/tests/idls/core/SVGTestInterface.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bindings/scripts/v8_utilities.py
diff --git a/bindings/scripts/v8_utilities.py b/bindings/scripts/v8_utilities.py
index 1cd44abbe378c6d69e80cb8f24d0d6a28e0f9958..1e8733a9ab764c81ebedc4be55b40692539130bb 100644
--- a/bindings/scripts/v8_utilities.py
+++ b/bindings/scripts/v8_utilities.py
@@ -35,7 +35,7 @@ import re
from idl_types import IdlTypeBase
import idl_types
-from idl_definitions import Exposure, IdlInterface
+from idl_definitions import Exposure, IdlInterface, IdlAttribute
from v8_globals import includes
ACRONYMS = [
@@ -125,7 +125,7 @@ def scoped_name(interface, definition, base_name):
if partial_interface_implemented_as:
return '%s::%s' % (partial_interface_implemented_as, base_name)
if (definition.is_static or
- definition.name in ('Constructor', 'NamedConstructor')):
+ definition.name in ('Constructor', 'NamedConstructor')):
return '%s::%s' % (cpp_name(interface), base_name)
return 'impl->%s' % base_name
@@ -176,7 +176,7 @@ def activity_logging_world_check(member):
if 'LogActivity' not in extended_attributes:
return False
if ('PerWorldBindings' not in extended_attributes and
- 'LogAllWorlds' not in extended_attributes):
+ 'LogAllWorlds' not in extended_attributes):
return True
return False
@@ -186,7 +186,7 @@ CALL_WITH_ARGUMENTS = {
'ScriptState': 'scriptState',
'ExecutionContext': 'executionContext',
'ScriptArguments': 'scriptArguments.release()',
- 'ActiveWindow': 'callingDOMWindow(info.GetIsolate())',
+ 'ActiveWindow': 'currentDOMWindow(info.GetIsolate())',
'FirstWindow': 'enteredDOMWindow(info.GetIsolate())',
'Document': 'document',
'ThisValue': 'ScriptValue(scriptState, info.This())',
@@ -211,24 +211,11 @@ def call_with_arguments(call_with_values):
if extended_attribute_value_contains(call_with_values, value)]
-# [Conditional]
-DELIMITER_TO_OPERATOR = {
- '|': '||',
- ',': '&&',
-}
-
-
-def conditional_string(definition_or_member):
- extended_attributes = definition_or_member.extended_attributes
- if 'Conditional' not in extended_attributes:
- return None
- return 'ENABLE(%s)' % extended_attributes['Conditional']
-
-
# [Constructor], [NamedConstructor]
def is_constructor_attribute(member):
# TODO(yukishiino): replace this with [Constructor] and [NamedConstructor] extended attribute
- return member.idl_type.name.endswith('Constructor')
+ return (type(member) == IdlAttribute and
+ member.idl_type.name.endswith('Constructor'))
# [DeprecateAs]
@@ -236,7 +223,7 @@ def deprecate_as(member):
extended_attributes = member.extended_attributes
if 'DeprecateAs' not in extended_attributes:
return None
- includes.add('core/frame/UseCounter.h')
+ includes.add('core/frame/Deprecation.h')
return extended_attributes['DeprecateAs']
@@ -248,6 +235,7 @@ EXPOSED_EXECUTION_CONTEXT_METHOD = {
'SharedWorker': 'isSharedWorkerGlobalScope',
'Window': 'isDocument',
'Worker': 'isWorkerGlobalScope',
+ 'Worklet': 'isWorkletGlobalScope',
}
@@ -291,7 +279,7 @@ class ExposureSet:
@staticmethod
def _code(exposure):
- exposed = ('context->%s()' %
+ exposed = ('executionContext->%s()' %
EXPOSED_EXECUTION_CONTEXT_METHOD[exposure.exposed])
if exposure.runtime_enabled is not None:
runtime_enabled = ('RuntimeEnabledFeatures::%sEnabled()' %
@@ -379,6 +367,29 @@ def measure_as(definition_or_member, interface):
return None
+def runtime_feature_name(definition_or_member):
+ extended_attributes = definition_or_member.extended_attributes
+ if 'RuntimeEnabled' not in extended_attributes:
+ return None
+ return extended_attributes['RuntimeEnabled']
+
+
+def is_origin_trial_enabled(definition_or_member):
+ return 'OriginTrialEnabled' in definition_or_member.extended_attributes
+
+
+def origin_trial_name(definition_or_member):
+ return definition_or_member.extended_attributes['OriginTrialEnabled'] if is_origin_trial_enabled(definition_or_member) else None
+
+
+def origin_trial_enabled_function(definition_or_member):
+ trial_name = origin_trial_name(definition_or_member)
+ feature_name = runtime_feature_name(definition_or_member)
+ if not feature_name or not trial_name:
+ return
+ return 'OriginTrials::%sEnabled' % uncapitalize(feature_name)
+
+
# [RuntimeEnabled]
def runtime_enabled_function_name(definition_or_member):
"""Returns the name of the RuntimeEnabledFeatures function.
@@ -387,10 +398,16 @@ def runtime_enabled_function_name(definition_or_member):
Given extended attribute RuntimeEnabled=FeatureName, return:
RuntimeEnabledFeatures::{featureName}Enabled
"""
- extended_attributes = definition_or_member.extended_attributes
- if 'RuntimeEnabled' not in extended_attributes:
- return None
- feature_name = extended_attributes['RuntimeEnabled']
+ feature_name = runtime_feature_name(definition_or_member)
+
+ # If an origin trial is on the method/attribute, it overrides the runtime
+ # enabled status. For now, we are unconditionally installing these
+ # attributes/methods, so we are acting as though the runtime enabled
+ # function doesn't exist. (It is checked in the generated OriginTrials
+ # function, instead)
+ trial_name = origin_trial_name(definition_or_member)
+ if not feature_name or trial_name:
+ return
return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)
@@ -401,17 +418,13 @@ def is_unforgeable(interface, member):
not member.is_static)
-# [TypeChecking=Interface] / [LegacyInterfaceTypeChecking]
+# [LegacyInterfaceTypeChecking]
def is_legacy_interface_type_checking(interface, member):
- if not ('TypeChecking' in interface.extended_attributes or
- 'TypeChecking' in member.extended_attributes):
- return True
- if 'LegacyInterfaceTypeChecking' in member.extended_attributes:
- return True
- return False
+ return ('LegacyInterfaceTypeChecking' in interface.extended_attributes or
+ 'LegacyInterfaceTypeChecking' in member.extended_attributes)
-# [Unforgeable], [Global], [PrimaryGlobal] and [DoNotExposeJSAccessors]
+# [Unforgeable], [Global], [PrimaryGlobal]
def on_instance(interface, member):
"""Returns True if the interface's member needs to be defined on every
instance object.
@@ -419,60 +432,57 @@ def on_instance(interface, member):
The following members must be defiend on an instance object.
- [Unforgeable] members
- regular members of [Global] or [PrimaryGlobal] interfaces
- - members on which [DoNotExposeJSAccessors] is specified
"""
- # TODO(yukishiino): Implement this function following the spec.
- return not on_prototype(interface, member)
+ if member.is_static:
+ return False
+
+ # TODO(yukishiino): Remove a hack for toString once we support
+ # Symbol.toStringTag.
+ if (interface.name == 'Window' and member.name == 'toString'):
+ return False
+
+ # TODO(yukishiino): Implement "interface object" and its [[Call]] method
+ # in a better way. Then we can get rid of this hack.
+ if is_constructor_attribute(member):
+ return True
+
+ if ('PrimaryGlobal' in interface.extended_attributes or
+ 'Global' in interface.extended_attributes or
+ 'Unforgeable' in member.extended_attributes or
+ 'Unforgeable' in interface.extended_attributes):
+ return True
+ return False
-# [ExposeJSAccessors]
def on_prototype(interface, member):
"""Returns True if the interface's member needs to be defined on the
prototype object.
Most members are defined on the prototype object. Exceptions are as
follows.
- - constant members
- static members (optional)
- [Unforgeable] members
- members of [Global] or [PrimaryGlobal] interfaces
- named properties of [Global] or [PrimaryGlobal] interfaces
- However, if [ExposeJSAccessors] is specified, the member is defined on the
- prototype object.
"""
- # TODO(yukishiino): Implement this function following the spec.
-
- if ('ExposeJSAccessors' in interface.extended_attributes and
- 'DoNotExposeJSAccessors' in interface.extended_attributes):
- raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors are specified at a time in an interface: ' + interface.name)
- if ('ExposeJSAccessors' in member.extended_attributes and
- 'DoNotExposeJSAccessors' in member.extended_attributes):
- raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors are specified at a time on a member: ' + member.name + ' in an interface: ' + interface.name)
-
- # Note that ExposeJSAccessors and DoNotExposeJSAccessors are more powerful
- # than 'static', [Unforgeable] and [OverrideBuiltins].
- if 'ExposeJSAccessors' in member.extended_attributes:
- return True
- if 'DoNotExposeJSAccessors' in member.extended_attributes:
- return False
-
- # These members must not be placed on prototype chains.
- if (is_constructor_attribute(member) or
- member.is_static or
- is_unforgeable(interface, member) or
- 'OverrideBuiltins' in interface.extended_attributes):
+ if member.is_static:
return False
- # TODO(yukishiino): We should handle [Global] and [PrimaryGlobal] instead of
- # Window.
- if (interface.name == 'Window'):
- return member.idl_type.name == 'EventHandler'
-
- if 'ExposeJSAccessors' in interface.extended_attributes:
+ # TODO(yukishiino): Remove a hack for toString once we support
+ # Symbol.toStringTag.
+ if (interface.name == 'Window' and member.name == 'toString'):
return True
- if 'DoNotExposeJSAccessors' in interface.extended_attributes:
+
+ # TODO(yukishiino): Implement "interface object" and its [[Call]] method
+ # in a better way. Then we can get rid of this hack.
+ if is_constructor_attribute(member):
return False
+ if ('PrimaryGlobal' in interface.extended_attributes or
+ 'Global' in interface.extended_attributes or
+ 'Unforgeable' in member.extended_attributes or
+ 'Unforgeable' in interface.extended_attributes):
+ return False
return True
@@ -482,10 +492,10 @@ def on_interface(interface, member):
interface object.
The following members must be defiend on an interface object.
- - constant members
- static members
"""
- # TODO(yukishiino): Implement this function following the spec.
+ if member.is_static:
+ return True
return False
« no previous file with comments | « bindings/scripts/v8_union.py ('k') | bindings/tests/idls/core/SVGTestInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698