Chromium Code Reviews| 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 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1628 } else { | 1628 } else { |
| 1629 $code .= <<END; | 1629 $code .= <<END; |
| 1630 ScriptValue jsValue = $getterString; | 1630 ScriptValue jsValue = $getterString; |
| 1631 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value()); | 1631 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value()); |
| 1632 v8SetReturnValue(info, jsValue.v8Value()); | 1632 v8SetReturnValue(info, jsValue.v8Value()); |
| 1633 END | 1633 END |
| 1634 } | 1634 } |
| 1635 } elsif ($attribute->type eq "EventHandler") { | 1635 } elsif ($attribute->type eq "EventHandler") { |
| 1636 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); | 1636 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
| 1637 my $getterFunc = ToMethodName($attribute->name); | 1637 my $getterFunc = ToMethodName($attribute->name); |
| 1638 my $getterString; | |
| 1638 # FIXME: Pass the main world ID for main-world-only getters. | 1639 # FIXME: Pass the main world ID for main-world-only getters. |
| 1639 $code .= " EventListener* jsValue = imp->${getterFunc}(isolatedWorldF orIsolate(info.GetIsolate()));\n"; | 1640 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; |
| 1641 if ($implementedBy) { | |
| 1642 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); | |
| 1643 $getterString = "${implementedByImplName}::${getterFunc}(imp, isolat edWorldForIsolate(info.GetIsolate()))"; | |
| 1644 } else { | |
| 1645 $getterString = "imp->${getterFunc}(isolatedWorldForIsolate(info.Get Isolate()))"; | |
| 1646 } | |
| 1647 $code .= " EventListener* jsValue = ${getterString};\n"; | |
| 1640 $code .= " v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8A bstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n"; | 1648 $code .= " v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8A bstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n"; |
| 1641 } else { | 1649 } else { |
| 1642 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info ", "imp", $forMainWorldSuffix, "return"); | 1650 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info ", "imp", $forMainWorldSuffix, "return"); |
| 1643 $code .= "${nativeValue}\n"; | 1651 $code .= "${nativeValue}\n"; |
| 1644 } | 1652 } |
| 1645 | 1653 |
| 1646 $code .= "}\n"; # end of getter | 1654 $code .= "}\n"; # end of getter |
| 1647 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 1655 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 1648 $code .= "\n"; | 1656 $code .= "\n"; |
| 1649 $implementation{nameSpaceInternal}->add($code); | 1657 $implementation{nameSpaceInternal}->add($code); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1948 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; | 1956 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; |
| 1949 | 1957 |
| 1950 if ($useExceptions) { | 1958 if ($useExceptions) { |
| 1951 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 1959 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 1952 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 1960 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 1953 $code .= " ExceptionState es(info.GetIsolate());\n"; | 1961 $code .= " ExceptionState es(info.GetIsolate());\n"; |
| 1954 } | 1962 } |
| 1955 | 1963 |
| 1956 if ($attribute->type eq "EventHandler") { | 1964 if ($attribute->type eq "EventHandler") { |
| 1957 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); | 1965 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); |
| 1958 if (!InheritsInterface($interface, "Node")) { | 1966 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; |
| 1959 my $attrImplName = GetImplName($attribute); | 1967 if ($implementedBy) { |
| 1960 $code .= " transferHiddenDependency(info.Holder(), imp->${attrImp lName}(isolatedWorldForIsolate(info.GetIsolate())), jsValue, ${v8ClassName}::eve ntListenerCacheIndex, info.GetIsolate());\n"; | 1968 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); |
| 1961 } | 1969 if (!InheritsInterface($interface, "Node")) { |
| 1962 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope" ) and $attribute->name eq "onerror") { | 1970 my $attrImplName = GetImplName($attribute); |
| 1963 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); | 1971 $code .= " transferHiddenDependency(info.Holder(), ${implemen tedByImplName}::${attrImplName}(imp, isolatedWorldForIsolate(info.GetIsolate())) , jsValue, ${v8ClassName}::eventListenerCacheIndex, info.GetIsolate());\n"; |
| 1964 $code .= " imp->set$implSetterFunctionName(V8EventListenerList::f indOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate()), isolatedWo rldForIsolate(info.GetIsolate()));\n"; | 1972 } |
| 1973 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalSc ope") and $attribute->name eq "onerror") { | |
| 1974 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); | |
| 1975 $code .= " ${implementedByImplName}::set$implSetterFunctionNa me(imp, V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate()), isolatedWorldForIsolate(info.GetIsolate()));\n"; | |
| 1976 } else { | |
| 1977 $code .= " ${implementedByImplName}::set$implSetterFunctionNa me(imp, V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreat e), isolatedWorldForIsolate(info.GetIsolate()));\n"; | |
| 1978 } | |
| 1965 } else { | 1979 } else { |
|
Nils Barth (inactive)
2013/10/24 02:41:39
You might be able to avoid having multiple branche
| |
| 1966 $code .= " imp->set$implSetterFunctionName(V8EventListenerList::g etEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolate(in fo.GetIsolate()));\n"; | 1980 if (!InheritsInterface($interface, "Node")) { |
|
Nils Barth (inactive)
2013/10/24 02:41:39
I think you can make this section simpler by havin
| |
| 1981 my $attrImplName = GetImplName($attribute); | |
| 1982 $code .= " transferHiddenDependency(info.Holder(), imp->${att rImplName}(isolatedWorldForIsolate(info.GetIsolate())), jsValue, ${v8ClassName}: :eventListenerCacheIndex, info.GetIsolate());\n"; | |
| 1983 } | |
| 1984 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalSc ope") and $attribute->name eq "onerror") { | |
| 1985 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); | |
| 1986 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate()), isolat edWorldForIsolate(info.GetIsolate()));\n"; | |
| 1987 } else { | |
| 1988 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolat e(info.GetIsolate()));\n"; | |
| 1989 } | |
| 1967 } | 1990 } |
| 1968 } else { | 1991 } else { |
| 1969 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute); | 1992 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute); |
| 1970 push(@arguments, $expression); | 1993 push(@arguments, $expression); |
| 1971 push(@arguments, "es") if $useExceptions; | 1994 push(@arguments, "es") if $useExceptions; |
| 1972 if ($attribute->extendedAttributes->{"ImplementedBy"}) { | 1995 if ($attribute->extendedAttributes->{"ImplementedBy"}) { |
| 1973 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" }; | 1996 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" }; |
| 1974 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); | 1997 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); |
| 1975 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); | 1998 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); |
| 1976 unshift(@arguments, "imp") if !$attribute->isStatic; | 1999 unshift(@arguments, "imp") if !$attribute->isStatic; |
| (...skipping 4217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6194 my $interface = shift; | 6217 my $interface = shift; |
| 6195 | 6218 |
| 6196 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6219 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
| 6197 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6220 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
| 6198 return 1 if InheritsInterface($interface, "Document"); | 6221 return 1 if InheritsInterface($interface, "Document"); |
| 6199 | 6222 |
| 6200 return 0; | 6223 return 0; |
| 6201 } | 6224 } |
| 6202 | 6225 |
| 6203 1; | 6226 1; |
| OLD | NEW |