| OLD | NEW |
| 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> | 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> |
| 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> | 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
| 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> | 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> |
| 5 # Copyright (C) 2006 Apple Computer, Inc. | 5 # Copyright (C) 2006 Apple Computer, Inc. |
| 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. | 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. |
| 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. | 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. | 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 "unsigned long" => 1, | 160 "unsigned long" => 1, |
| 161 "unsigned long long" => 1, | 161 "unsigned long long" => 1, |
| 162 "float" => 1, | 162 "float" => 1, |
| 163 "double" => 1, | 163 "double" => 1, |
| 164 ); | 164 ); |
| 165 | 165 |
| 166 my %nonWrapperTypes = ("CompareHow" => 1, | 166 my %nonWrapperTypes = ("CompareHow" => 1, |
| 167 "DOMTimeStamp" => 1, | 167 "DOMTimeStamp" => 1, |
| 168 "Dictionary" => 1, | 168 "Dictionary" => 1, |
| 169 "EventListener" => 1, | 169 "EventListener" => 1, |
| 170 "EventHandler" => 1, |
| 170 "MediaQueryListListener" => 1, | 171 "MediaQueryListListener" => 1, |
| 171 "NodeFilter" => 1, | 172 "NodeFilter" => 1, |
| 172 "SerializedScriptValue" => 1, | 173 "SerializedScriptValue" => 1, |
| 173 "any" => 1, | 174 "any" => 1, |
| 174 ); | 175 ); |
| 175 | 176 |
| 176 my %typedArrayHash = ("ArrayBuffer" => [], | 177 my %typedArrayHash = ("ArrayBuffer" => [], |
| 177 "ArrayBufferView" => [], | 178 "ArrayBufferView" => [], |
| 178 "Uint8Array" => ["unsigned char", "v8::kExternalUnsignedBy
teArray"], | 179 "Uint8Array" => ["unsigned char", "v8::kExternalUnsignedBy
teArray"], |
| 179 "Uint8ClampedArray" => ["unsigned char", "v8::kExternalPix
elArray"], | 180 "Uint8ClampedArray" => ["unsigned char", "v8::kExternalPix
elArray"], |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return 0; | 414 return 0; |
| 414 } | 415 } |
| 415 | 416 |
| 416 sub AddIncludesForType | 417 sub AddIncludesForType |
| 417 { | 418 { |
| 418 my $type = shift; | 419 my $type = shift; |
| 419 | 420 |
| 420 return if SkipIncludeHeader($type); | 421 return if SkipIncludeHeader($type); |
| 421 | 422 |
| 422 # Default includes | 423 # Default includes |
| 423 if ($type eq "EventListener") { | 424 if ($type eq "EventListener" or $type eq "EventHandler") { |
| 424 AddToImplIncludes("core/dom/EventListener.h"); | 425 AddToImplIncludes("core/dom/EventListener.h"); |
| 425 } elsif ($type eq "SerializedScriptValue") { | 426 } elsif ($type eq "SerializedScriptValue") { |
| 426 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 427 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
| 427 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { | 428 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { |
| 428 AddToImplIncludes("bindings/v8/ScriptValue.h"); | 429 AddToImplIncludes("bindings/v8/ScriptValue.h"); |
| 429 } elsif ($type eq "ArrayBuffer") { | 430 } elsif ($type eq "ArrayBuffer") { |
| 430 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h"); | 431 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h"); |
| 431 } else { | 432 } else { |
| 432 AddToImplIncludes("V8${type}.h"); | 433 AddToImplIncludes("V8${type}.h"); |
| 433 } | 434 } |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 return toV8(impl.get(), creationContext, isolate); | 906 return toV8(impl.get(), creationContext, isolate); |
| 906 } | 907 } |
| 907 | 908 |
| 908 END | 909 END |
| 909 | 910 |
| 910 if (IsConstructorTemplate($interface, "Event")) { | 911 if (IsConstructorTemplate($interface, "Event")) { |
| 911 $header{nameSpaceWebCore}->add("bool fill${implClassName}Init(${implClas
sName}Init&, const Dictionary&);\n\n"); | 912 $header{nameSpaceWebCore}->add("bool fill${implClassName}Init(${implClas
sName}Init&, const Dictionary&);\n\n"); |
| 912 } | 913 } |
| 913 } | 914 } |
| 914 | 915 |
| 915 sub HasEventListenerAttribute | 916 sub HasEventHandlerAttribute |
| 916 { | 917 { |
| 917 my $interface = shift; | 918 my $interface = shift; |
| 918 | 919 |
| 919 foreach my $attribute (@{$interface->attributes}) { | 920 foreach my $attribute (@{$interface->attributes}) { |
| 920 return 1 if $attribute->type eq "EventListener"; | 921 return 1 if $attribute->type eq "EventHandler"; |
| 921 } | 922 } |
| 922 | 923 |
| 923 return 0; | 924 return 0; |
| 924 } | 925 } |
| 925 | 926 |
| 926 sub GetInternalFields | 927 sub GetInternalFields |
| 927 { | 928 { |
| 928 my $interface = shift; | 929 my $interface = shift; |
| 929 | 930 |
| 930 my @customInternalFields = (); | 931 my @customInternalFields = (); |
| 931 # Event listeners on DOM nodes are explicitly supported in the GC controller
. | 932 # Event listeners on DOM nodes are explicitly supported in the GC controller
. |
| 932 if (!InheritsInterface($interface, "Node") && | 933 if (!InheritsInterface($interface, "Node") && |
| 933 (InheritsInterface($interface, "EventTarget") || HasEventListenerAttribu
te($interface))) { | 934 (InheritsInterface($interface, "EventTarget") || HasEventHandlerAttribut
e($interface))) { |
| 934 push(@customInternalFields, "eventListenerCacheIndex"); | 935 push(@customInternalFields, "eventListenerCacheIndex"); |
| 935 } | 936 } |
| 936 return @customInternalFields; | 937 return @customInternalFields; |
| 937 } | 938 } |
| 938 | 939 |
| 939 sub GenerateHeaderCustomInternalFieldIndices | 940 sub GenerateHeaderCustomInternalFieldIndices |
| 940 { | 941 { |
| 941 my $interface = shift; | 942 my $interface = shift; |
| 942 my @customInternalFields = GetInternalFields($interface); | 943 my @customInternalFields = GetInternalFields($interface); |
| 943 my $customFieldCounter = 0; | 944 my $customFieldCounter = 0; |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 $functionName = "${implClassName}::${functionName}"; | 1428 $functionName = "${implClassName}::${functionName}"; |
| 1428 } else { | 1429 } else { |
| 1429 $functionName = "imp->${functionName}"; | 1430 $functionName = "imp->${functionName}"; |
| 1430 } | 1431 } |
| 1431 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{"Cal
lWith"}, " ", 0); | 1432 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{"Cal
lWith"}, " ", 0); |
| 1432 $code .= $subCode; | 1433 $code .= $subCode; |
| 1433 unshift(@arguments, @$arg); | 1434 unshift(@arguments, @$arg); |
| 1434 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; | 1435 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; |
| 1435 | 1436 |
| 1436 my $expression; | 1437 my $expression; |
| 1437 if ($attribute->type eq "EventListener" && $interface->name eq "Window") { | 1438 if ($attribute->type eq "EventHandler" && $interface->name eq "Window") { |
| 1438 $code .= " if (!imp->document())\n"; | 1439 $code .= " if (!imp->document())\n"; |
| 1439 $code .= " return;\n"; | 1440 $code .= " return;\n"; |
| 1440 } | 1441 } |
| 1441 | 1442 |
| 1442 if ($useExceptions || $isNullable) { | 1443 if ($useExceptions || $isNullable) { |
| 1443 if ($nativeType =~ /^V8StringResource/) { | 1444 if ($nativeType =~ /^V8StringResource/) { |
| 1444 $code .= " " . ConvertToV8StringResource($attribute, $nativeType,
"v", $getterString) . ";\n"; | 1445 $code .= " " . ConvertToV8StringResource($attribute, $nativeType,
"v", $getterString) . ";\n"; |
| 1445 } else { | 1446 } else { |
| 1446 $code .= " $nativeType v = $getterString;\n"; | 1447 $code .= " $nativeType v = $getterString;\n"; |
| 1447 } | 1448 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 $code .= " return;\n"; | 1562 $code .= " return;\n"; |
| 1562 } elsif ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAt
tribute"}) { | 1563 } elsif ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAt
tribute"}) { |
| 1563 my $getterFunc = ToMethodName($attribute->name); | 1564 my $getterFunc = ToMethodName($attribute->name); |
| 1564 $code .= <<END; | 1565 $code .= <<END; |
| 1565 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); | 1566 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); |
| 1566 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::N
ull(info.GetIsolate())); | 1567 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::N
ull(info.GetIsolate())); |
| 1567 info.Holder()->SetHiddenValue(propertyName, value); | 1568 info.Holder()->SetHiddenValue(propertyName, value); |
| 1568 v8SetReturnValue(info, value); | 1569 v8SetReturnValue(info, value); |
| 1569 return; | 1570 return; |
| 1570 END | 1571 END |
| 1571 } elsif ($attribute->type eq "EventListener") { | 1572 } elsif ($attribute->type eq "EventHandler") { |
| 1572 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); | 1573 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
| 1573 my $getterFunc = ToMethodName($attribute->name); | 1574 my $getterFunc = ToMethodName($attribute->name); |
| 1574 # FIXME: Pass the main world ID for main-world-only getters. | 1575 # FIXME: Pass the main world ID for main-world-only getters. |
| 1575 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld
ForIsolate(info.GetIsolate()));\n"; | 1576 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld
ForIsolate(info.GetIsolate()));\n"; |
| 1576 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8
AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon
text())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n"; | 1577 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8
AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon
text())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n"; |
| 1577 $code .= " return;\n"; | 1578 $code .= " return;\n"; |
| 1578 } else { | 1579 } else { |
| 1579 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended
Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info
", "imp", $forMainWorldSuffix, "return"); | 1580 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended
Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info
", "imp", $forMainWorldSuffix, "return"); |
| 1580 $code .= "${nativeValue}\n"; | 1581 $code .= "${nativeValue}\n"; |
| 1581 $code .= " return;\n"; | 1582 $code .= " return;\n"; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 } | 1796 } |
| 1796 | 1797 |
| 1797 if (!$attribute->isStatic) { | 1798 if (!$attribute->isStatic) { |
| 1798 $code .= <<END; | 1799 $code .= <<END; |
| 1799 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1800 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1800 END | 1801 END |
| 1801 } | 1802 } |
| 1802 } | 1803 } |
| 1803 | 1804 |
| 1804 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu
tes, "parameter"); | 1805 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu
tes, "parameter"); |
| 1805 if ($attribute->type eq "EventListener") { | 1806 if ($attribute->type eq "EventHandler") { |
| 1806 if ($interface->name eq "Window") { | 1807 if ($interface->name eq "Window") { |
| 1807 $code .= " if (!imp->document())\n"; | 1808 $code .= " if (!imp->document())\n"; |
| 1808 $code .= " return;\n"; | 1809 $code .= " return;\n"; |
| 1809 } | 1810 } |
| 1810 } else { | 1811 } else { |
| 1811 $code .= JSValueToNativeStatement($attribute->type, $attribute->extended
Attributes, "value", "v", " ", "info.GetIsolate()"); | 1812 $code .= JSValueToNativeStatement($attribute->type, $attribute->extended
Attributes, "value", "v", " ", "info.GetIsolate()"); |
| 1812 } | 1813 } |
| 1813 | 1814 |
| 1814 if (IsEnumType($attrType)) { | 1815 if (IsEnumType($attrType)) { |
| 1815 # setter ignores invalid enumeration values | 1816 # setter ignores invalid enumeration values |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1834 | 1835 |
| 1835 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt
tributes); | 1836 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt
tributes); |
| 1836 | 1837 |
| 1837 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep
tion"} || $attribute->extendedAttributes->{"RaisesException"}; | 1838 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep
tion"} || $attribute->extendedAttributes->{"RaisesException"}; |
| 1838 | 1839 |
| 1839 if ($useExceptions) { | 1840 if ($useExceptions) { |
| 1840 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 1841 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 1841 $code .= " ExceptionState es(info.GetIsolate());\n"; | 1842 $code .= " ExceptionState es(info.GetIsolate());\n"; |
| 1842 } | 1843 } |
| 1843 | 1844 |
| 1844 if ($attribute->type eq "EventListener") { | 1845 if ($attribute->type eq "EventHandler") { |
| 1845 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); | 1846 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); |
| 1846 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); | 1847 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
| 1847 if (!InheritsInterface($interface, "Node")) { | 1848 if (!InheritsInterface($interface, "Node")) { |
| 1848 my $attrImplName = GetImplName($attribute); | 1849 my $attrImplName = GetImplName($attribute); |
| 1849 $code .= " transferHiddenDependency(info.Holder(), imp->${attrImp
lName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::event
ListenerCacheIndex, info.GetIsolate());\n"; | 1850 $code .= " transferHiddenDependency(info.Holder(), imp->${attrImp
lName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::event
ListenerCacheIndex, info.GetIsolate());\n"; |
| 1850 } | 1851 } |
| 1851 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 1852 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
| 1852 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope"
) and $attribute->name eq "onerror") { | 1853 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope"
) and $attribute->name eq "onerror") { |
| 1853 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); | 1854 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); |
| 1854 $code .= " imp->set$implSetterFunctionName(V8EventListenerList::f
indOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(info.Ge
tIsolate()));\n"; | 1855 $code .= " imp->set$implSetterFunctionName(V8EventListenerList::f
indOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(info.Ge
tIsolate()));\n"; |
| (...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3914 my $attrExt = $attribute->extendedAttributes; | 3915 my $attrExt = $attribute->extendedAttributes; |
| 3915 | 3916 |
| 3916 # Generate special code for the constructor attributes. | 3917 # Generate special code for the constructor attributes. |
| 3917 if ($attrType =~ /Constructor$/) { | 3918 if ($attrType =~ /Constructor$/) { |
| 3918 if (!HasCustomGetter($attrExt)) { | 3919 if (!HasCustomGetter($attrExt)) { |
| 3919 $hasConstructors = 1; | 3920 $hasConstructors = 1; |
| 3920 } | 3921 } |
| 3921 next; | 3922 next; |
| 3922 } | 3923 } |
| 3923 | 3924 |
| 3924 if ($attrType eq "EventListener" && $interfaceName eq "Window") { | 3925 if ($attrType eq "EventHandler" && $interfaceName eq "Window") { |
| 3925 $attrExt->{"OnProto"} = 1; | 3926 $attrExt->{"OnProto"} = 1; |
| 3926 } | 3927 } |
| 3927 | 3928 |
| 3928 if ($attrType eq "SerializedScriptValue") { | 3929 if ($attrType eq "SerializedScriptValue") { |
| 3929 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 3930 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
| 3930 } | 3931 } |
| 3931 | 3932 |
| 3932 GenerateNormalAttrGetter($attribute, $interface, ""); | 3933 GenerateNormalAttrGetter($attribute, $interface, ""); |
| 3933 GenerateNormalAttrGetterCallback($attribute, $interface, ""); | 3934 GenerateNormalAttrGetterCallback($attribute, $interface, ""); |
| 3934 if ($attrExt->{"PerWorldBindings"}) { | 3935 if ($attrExt->{"PerWorldBindings"}) { |
| (...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6020 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 6021 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 6021 $found = 1; | 6022 $found = 1; |
| 6022 } | 6023 } |
| 6023 return 1 if $found; | 6024 return 1 if $found; |
| 6024 }, 0); | 6025 }, 0); |
| 6025 | 6026 |
| 6026 return $found; | 6027 return $found; |
| 6027 } | 6028 } |
| 6028 | 6029 |
| 6029 1; | 6030 1; |
| OLD | NEW |