| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 {% from 'macros.cpp' import activity_logging, feature_observation, deprecation_n
     otification, custom_element_invocation with context %} | 
|  | 2 | 
|  | 3 {% macro attribute_getter(attribute, for_main_world_suffix) %} | 
|  | 4 {% if not attribute.has_custom_getter %} | 
|  | 5 {% if attribute.conditional_string %} | 
|  | 6 #if {{attribute.conditional_string}} | 
|  | 7 {% endif %} | 
|  | 8 static void {{attribute.name}}AttrGetter{{for_main_world_suffix}}(v8::Local<v8::
     String> name, const v8::PropertyCallbackInfo<v8::Value>& info) | 
|  | 9 { | 
|  | 10 {% if attribute.compact_getter %}{## Generate super-compact call for regular att
     ribute getter. FIXME: remove. this is dirty. #} | 
|  | 11     Element* imp = V8Element::toNative(info.Holder()); | 
|  | 12     v8SetReturnValueString(info, {{attribute.getter_native_value_expression}}, i
     nfo.GetIsolate()); | 
|  | 13     return; | 
|  | 14 {% else %}{# compact getter #} | 
|  | 15 {% if not attribute.is_static %} | 
|  | 16     {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 
|  | 17 {% endif %} | 
|  | 18 {% if attribute.check_security_for_node %} | 
|  | 19     if (!BindingSecurity::shouldAllowAccessToNode(imp->{{attribute.cpp_name}}())
     ) { | 
|  | 20         v8SetReturnValueNull(info); | 
|  | 21         return; | 
|  | 22     } | 
|  | 23 {% endif %} | 
|  | 24 {% if attribute.getter_use_exceptions %} | 
|  | 25     ExceptionState es(info.GetIsolate()); | 
|  | 26 {% endif %} | 
|  | 27 {% if attribute.is_nullable %} | 
|  | 28     bool isNull = false; | 
|  | 29 {% endif %} | 
|  | 30 {% if attribute.script_execution_context %} | 
|  | 31     ScriptExecutionContext* scriptContext = getScriptExecutionContext(); | 
|  | 32 {% endif %} | 
|  | 33 {% if attribute.is_nullable or attribute.getter_use_exceptions %} | 
|  | 34     {{attribute.assign_native_value_to_local_variable_statement | indent}} | 
|  | 35 {% endif %} | 
|  | 36 {% if attribute.is_nullable %} | 
|  | 37     if (isNull) { | 
|  | 38         v8SetReturnValueNull(info); | 
|  | 39         return; | 
|  | 40     } | 
|  | 41 {% endif %} | 
|  | 42 {% if attribute.getter_use_exceptions %} | 
|  | 43     if (UNLIKELY(es.throwIfNeeded())) | 
|  | 44         return; | 
|  | 45 {% endif %} | 
|  | 46 {% if attribute.should_keep_attribute_alive %}{###### should_keep_attribute_aliv
     e #} | 
|  | 47 {# FIXME: still partly Perl here: ${getterString} #} | 
|  | 48 {% if attribute.array_type %} | 
|  | 49     v8SetReturnValue(info, v8Array(${getterString}, info.GetIsolate())); | 
|  | 50     return; | 
|  | 51 {% else %} | 
|  | 52     {{attribute.native_type}} result = {{attribute.getter_native_value_expressio
     n}}; | 
|  | 53 {% if for_main_world_suffix %} | 
|  | 54     v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMData
     Store::getWrapper{{for_main_world_suffix}}(result.get())) : v8Undefined(); | 
|  | 55 {% else %} | 
|  | 56     v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMData
     Store::getWrapper<V8{{attribute.type}}>(result.get(), info.GetIsolate())) : v8Un
     defined(); | 
|  | 57 {% endif %} | 
|  | 58     if (wrapper.IsEmpty()) { | 
|  | 59 {# FIXME: Could use wrap here since the wrapper is empty. #} | 
|  | 60         wrapper = toV8(result.get(), info.Holder(), info.GetIsolate()); | 
|  | 61         if (!wrapper.IsEmpty()) | 
|  | 62             V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attr
     ibute.name}}", wrapper); | 
|  | 63     } | 
|  | 64     v8SetReturnValue(info, wrapper); | 
|  | 65     return; | 
|  | 66 {% endif %}{# array_type #} | 
|  | 67 {% else %}{# should_keep_attribute_alive #} | 
|  | 68 {% if (attribute.svg_animated_type or interface_name == "SVGViewSpec") and attri
     bute.svg_type_needing_tear_off %} | 
|  | 69 {# Convert from abstract SVGProperty to real type, so the right toJS() method ca
     n be invoked. #} | 
|  | 70 {% if for_main_world_suffix == "ForMainWorld" %} | 
|  | 71     v8SetReturnValue(info, toV8ForMainWorld(static_cast<{{attribute.svg_type_nee
     ding_tear_off}}*>({{attribute.getter_native_value_expression}}), info.Holder(), 
     info.GetIsolate())); | 
|  | 72 {% else %} | 
|  | 73     v8SetReturnValue(info, toV8Fast(static_cast<{{attribute.svg_type_needing_tea
     r_off}}*>({{attribute.getter_native_value_expression}}), info, imp)); | 
|  | 74 {% endif %} | 
|  | 75     return; | 
|  | 76 {% elif attribute.tear_off_and_not_list %} | 
|  | 77 {% if for_main_world_suffix == "ForMainWorld" %} | 
|  | 78     v8SetReturnValue(info, toV8ForMainWorld({{attribute.wrapped_value}}, info.Ho
     lder(), info.GetIsolate())); | 
|  | 79 {% else %} | 
|  | 80     v8SetReturnValue(info, toV8Fast({{attribute.wrapped_value}}, info, imp)); | 
|  | 81 {% endif %} | 
|  | 82     return; | 
|  | 83 {% elif attribute.type == "SerializedScriptValue" and attribute.cached_attribute
      %} | 
|  | 84     RefPtr<SerializedScriptValue> serialized = imp->{{getter_function}}(); | 
|  | 85     value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::N
     ull(info.GetIsolate())); | 
|  | 86     info.Holder()->SetHiddenValue(propertyName, value); | 
|  | 87     v8SetReturnValue(info, value); | 
|  | 88     return; | 
|  | 89 {% elif attribute.type == "EventListener" %} | 
|  | 90     EventListener* listener = imp->{{attribute.getter_function}}(isolatedWorldFo
     rIsolate(info.GetIsolate())); | 
|  | 91     v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8AbstractEventListe
     ner::cast(listener)->getListenerObject(imp->scriptExecutionContext())) : v8::Han
     dle<v8::Value>(v8::Null(info.GetIsolate()))); | 
|  | 92     return; | 
|  | 93 {% else %}{# Main case #} | 
|  | 94     {{attribute.return_js_value_statements[for_main_world_suffix] | indent}} | 
|  | 95     return; | 
|  | 96 {% endif %} | 
|  | 97 {% endif %}{# should_keep_attribute_alive #} | 
|  | 98 {% endif %}{# compact getter #} | 
|  | 99 } | 
|  | 100 | 
|  | 101 {% if attribute.conditional_string %} | 
|  | 102 #endif // {{attribute.conditional_string}} | 
|  | 103 {% endif %} | 
|  | 104 {% endif %} | 
|  | 105 {% endmacro %} | 
|  | 106 | 
|  | 107 | 
|  | 108 {##############################################################################} | 
|  | 109 {% macro attribute_getter_callback(attribute, for_main_world_suffix) %} | 
|  | 110 {% if attribute.conditional_string %} | 
|  | 111 #if {{attribute.conditional_string}} | 
|  | 112 {% endif %} | 
|  | 113 static void {{attribute.name}}AttrGetterCallback{{for_main_world_suffix}}(v8::Lo
     cal<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) | 
|  | 114 { | 
|  | 115     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 
|  | 116 {{- feature_observation(attribute.measure_as)}} | 
|  | 117 {{- deprecation_notification(attribute.deprecate_as)}} | 
|  | 118 {% if for_main_world_suffix in attribute.getter_activity_logging %} | 
|  | 119 {{activity_logging("Getter", attribute.name)}} | 
|  | 120 {% endif %} | 
|  | 121 {% if attribute.has_custom_getter %} | 
|  | 122     {{v8_class_name}}::{{attribute.name}}AttrGetterCustom(name, info); | 
|  | 123 {% else %} | 
|  | 124     {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetter{{for_main_world_s
     uffix}}(name, info); | 
|  | 125 {% endif %} | 
|  | 126     TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 
|  | 127 } | 
|  | 128 | 
|  | 129 {% if attribute.conditional_string %} | 
|  | 130 #endif // {{attribute.conditional_string}} | 
|  | 131 {% endif %} | 
|  | 132 {% endmacro %} | 
|  | 133 | 
|  | 134 | 
|  | 135 {##############################################################################} | 
|  | 136 {% macro attribute_setter(attribute, for_main_world_suffix) %} | 
|  | 137 {% if attribute.conditional_string %} | 
|  | 138 #if {{attribute.conditional_string}} | 
|  | 139 {% endif %} | 
|  | 140 static void {{attribute.name}}AttrSetter{{for_main_world_suffix}}(v8::Local<v8::
     String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& 
     info) | 
|  | 141 { | 
|  | 142 {% if attribute.compact_setter %}{## Generate super-compact call for regular att
     ribute setter. FIXME: remove. this is dirty. #} | 
|  | 143     Element* imp = V8Element::toNative(info.Holder()); | 
|  | 144     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, string
     Resource, value); | 
|  | 145     imp->setAttribute({{attribute.compact_setter_namespace}}::{{attribute.compac
     t_setter_content_attribute_name}}Attr, stringResource); | 
|  | 146 {% else %}{# Compact setter #} | 
|  | 147 {% if not attribute.is_static %} | 
|  | 148     {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 
|  | 149 {% endif %} | 
|  | 150 {% if attribute.type == "EventListener" %} | 
|  | 151 {% if interface_name == "Window" %} | 
|  | 152     if (!imp->document()) | 
|  | 153         return; | 
|  | 154 {% endif %} | 
|  | 155 {% else %} | 
|  | 156     {{attribute.assign_js_value_to_local_variable_statement | indent}} | 
|  | 157 {% endif %} | 
|  | 158 {{custom_element_invocation(attribute.custom_element_invocation_scope) -}} | 
|  | 159 {% if attribute.setter_use_exceptions %} | 
|  | 160     ExceptionState es(info.GetIsolate()); | 
|  | 161 {% endif %} | 
|  | 162 {% if attribute.script_execution_context %} | 
|  | 163     ScriptExecutionContext* scriptContext = getScriptExecutionContext(); | 
|  | 164 {% endif %} | 
|  | 165 {% if False %}{# TODO SVGNumber #} | 
|  | 166 {% elif attribute.type == "EventListener" %}{########### EventListener hack #} | 
|  | 167 {% if attribute.not_inherits_node %} | 
|  | 168     transferHiddenDependency(info.Holder(), imp->{{attribute.event_listener_sett
     er_function_name_not_inherits_node}}(isolatedWorldForIsolate(info.GetIsolate()))
     , value, {{v8_class_name}}::eventListenerCacheIndex, info.GetIsolate()); | 
|  | 169 {% endif %} | 
|  | 170 {% if attribute.event_listener_on_error %} | 
|  | 171     imp->set{{attribute.event_listener_setter_function_name}}(V8EventListenerLis
     t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf
     o.GetIsolate())); | 
|  | 172 {% else %} | 
|  | 173     imp->set{{attribute.event_listener_setter_function_name}}(V8EventListenerLis
     t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate(
     info.GetIsolate())); | 
|  | 174 {% endif %} | 
|  | 175 {% else %} | 
|  | 176     {{attribute.set_value_statement | indent}} | 
|  | 177 {% endif %} | 
|  | 178 {% if attribute.setter_use_exceptions %} | 
|  | 179     es.throwIfNeeded(); | 
|  | 180 {% endif %} | 
|  | 181     return; | 
|  | 182 {% endif %}{# Compact setter #} | 
|  | 183 } | 
|  | 184 | 
|  | 185 {% if attribute.conditional_string %} | 
|  | 186 #endif // {{attribute.conditional_string}} | 
|  | 187 {% endif %} | 
|  | 188 {% endmacro %} | 
|  | 189 | 
|  | 190 | 
|  | 191 {##############################################################################} | 
|  | 192 {% macro attribute_setter_callback(attribute, for_main_world_suffix) %} | 
|  | 193 {% if attribute.conditional_string %} | 
|  | 194 #if {{attribute.conditional_string}} | 
|  | 195 {% endif %} | 
|  | 196 static void {{attribute.name}}AttrSetterCallback{{for_main_world_suffix}}(v8::Lo
     cal<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo
     <void>& info) | 
|  | 197 { | 
|  | 198     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 
|  | 199 {{feature_observation(attribute.measure_as) -}} | 
|  | 200 {{deprecation_notification(attribute.deprecate_as) -}} | 
|  | 201 {% if for_main_world_suffix in attribute.setter_activity_logging %} | 
|  | 202 {{activity_logging("Setter", attribute.name) -}} | 
|  | 203 {% endif %} | 
|  | 204 {{custom_element_invocation(attribute.custom_element_invocation_scope) -}} | 
|  | 205 {% if attribute.has_custom_setter %} | 
|  | 206     {{v8_class_name}}::{{attribute.name}}AttrSetterCustom(name, value, info); | 
|  | 207 {% else %} | 
|  | 208     {{cpp_class_name}}V8Internal::{{attribute.name}}AttrSetter{{for_main_world_s
     uffix}}(name, value, info); | 
|  | 209 {% endif %} | 
|  | 210     TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 
|  | 211 } | 
|  | 212 | 
|  | 213 {% if attribute.conditional_string %} | 
|  | 214 #endif // {{attribute.conditional_string}} | 
|  | 215 {% endif %} | 
|  | 216 {% endmacro %} | 
|  | 217 | 
|  | 218 | 
|  | 219 {##############################################################################} | 
|  | 220 {# FIXME: instead pass a list of normal_attributes #} | 
|  | 221 {% macro batched_attribute() %} | 
|  | 222 static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attrs[] = { | 
|  | 223 {% for attribute in attributes %} | 
|  | 224 {% if attribute.is_normal %} | 
|  | 225 {% if attribute.conditional_string %} | 
|  | 226 #if {{attribute.conditional_string}} | 
|  | 227 {% endif %} | 
|  | 228     // Attribute '{{attribute.name}}' | 
|  | 229     {{attribute.batched_attribute}} | 
|  | 230 {% if attribute.conditional_string %} | 
|  | 231 #endif // {{attribute.conditional_string}} | 
|  | 232 {% endif %} | 
|  | 233 {% endif %} | 
|  | 234 {% endfor %} | 
|  | 235 }; | 
|  | 236 {% endmacro %} | 
|  | 237 | 
|  | 238 | 
|  | 239 {##############################################################################} | 
|  | 240 {# FIXME: instead pass a list of enabled_at_runtime_attributes #} | 
|  | 241 {% macro enabled_at_runtime_batched_attribute() %} | 
|  | 242 {% for attribute in attributes %} | 
|  | 243 {% if attribute.enabled_at_runtime %} | 
|  | 244 {% if attribute.conditional_string %} | 
|  | 245 #if {{attribute.conditional_string}} | 
|  | 246 {% endif %} | 
|  | 247     if ({{attribute.enable_function}}()) { | 
|  | 248         static const V8DOMConfiguration::BatchedAttribute attrData =\ | 
|  | 249         // Attribute '{{attribute.name}}' | 
|  | 250         {{attribute.batched_attribute}} | 
|  | 251         V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
     e, currentWorldType); | 
|  | 252     } | 
|  | 253 {% if attribute.conditional_string %} | 
|  | 254 #endif // {{attribute.conditional_string}}{% endif %} | 
|  | 255 {% endif %} | 
|  | 256 {% endfor %} | 
|  | 257 {% endmacro %} | 
| OLD | NEW | 
|---|