Changeset 196648 in webkit
- Timestamp:
- Feb 16, 2016 12:23:02 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r196646 r196648 1 2016-02-16 Chris Dumez <cdumez@apple.com> 2 3 [Web IDL] Operations should be on the instance for global objects or if [Unforgeable] 4 https://bugs.webkit.org/show_bug.cgi?id=154120 5 <rdar://problem/24613231> 6 7 Reviewed by Gavin Barraclough. 8 9 * inspector/model/remote-object-get-properties-expected.txt: 10 Rebaseline test because the order of static properties has changed: 11 functions are now before constants instead of after. 12 1 13 2016-02-16 Ryan Haddad <ryanhaddad@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r196621 r196648 1 2016-02-16 Chris Dumez <cdumez@apple.com> 2 3 [Web IDL] Operations should be on the instance for global objects or if [Unforgeable] 4 https://bugs.webkit.org/show_bug.cgi?id=154120 5 <rdar://problem/24613231> 6 7 Reviewed by Gavin Barraclough. 8 9 Rebaseline now that more checks are passing. 10 11 * web-platform-tests/html/dom/interfaces-expected.txt: 12 1 13 2016-02-15 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt
r196621 r196648 3825 3825 PASS Window interface: attribute toolbar 3826 3826 PASS Window interface: attribute status 3827 FAIL Window interface: operation close() assert_equals: property should be writable if and only if not unforgeable expected true but got false 3827 PASS Window interface: operation close() 3828 3828 PASS Window interface: attribute closed 3829 FAIL Window interface: operation stop() desc is not an Object. (evaluating '"get" in desc') 3830 FAIL Window interface: operation focus() assert_equals: property should be writable if and only if not unforgeable expected true but got false 3831 FAIL Window interface: operation blur() assert_equals: property should be writable if and only if not unforgeable expected true but got false 3829 PASS Window interface: operation stop() 3830 PASS Window interface: operation focus() 3831 PASS Window interface: operation blur() 3832 3832 PASS Window interface: attribute frames 3833 3833 PASS Window interface: attribute length … … 3835 3835 PASS Window interface: attribute parent 3836 3836 PASS Window interface: attribute frameElement 3837 FAIL Window interface: operation open(DOMString,DOMString,DOMString,boolean) desc is not an Object. (evaluating '"get" in desc')3837 FAIL Window interface: operation open(DOMString,DOMString,DOMString,boolean) assert_equals: property has wrong .length expected 0 but got 2 3838 3838 FAIL Window interface: attribute navigator assert_equals: setter must be undefined for readonly attributes expected (undefined) undefined but got (function) function "function navigator() { 3839 3839 [native code] … … 3841 3841 FAIL Window interface: attribute external assert_own_property: The global object must have a property "external" expected property "external" missing 3842 3842 PASS Window interface: attribute applicationCache 3843 FAIL Window interface: operation alert() desc is not an Object. (evaluating '"get" in desc') 3844 FAIL Window interface: operation confirm(DOMString) desc is not an Object. (evaluating '"get" in desc') 3845 FAIL Window interface: operation prompt(DOMString,DOMString) desc is not an Object. (evaluating '"get" in desc') 3846 FAIL Window interface: operation print() desc is not an Object. (evaluating '"get" in desc') 3847 FAIL Window interface: operation showModalDialog(DOMString,any) desc is not an Object. (evaluating '"get" in desc') 3848 FAIL Window interface: operation postMessage(any,DOMString,[object Object]) assert_equals: property should be writable if and only if not unforgeable expected true but got false 3849 FAIL Window interface: operation captureEvents() desc is not an Object. (evaluating '"get" in desc') 3850 FAIL Window interface: operation releaseEvents() desc is not an Object. (evaluating '"get" in desc') 3843 PASS Window interface: operation alert() 3844 PASS Window interface: operation confirm(DOMString) 3845 PASS Window interface: operation prompt(DOMString,DOMString) 3846 PASS Window interface: operation print() 3847 PASS Window interface: operation showModalDialog(DOMString,any) 3848 PASS Window interface: operation postMessage(any,DOMString,[object Object]) 3849 PASS Window interface: operation captureEvents() 3850 PASS Window interface: operation releaseEvents() 3851 3851 PASS Window interface: attribute onabort 3852 3852 FAIL Window interface: attribute onautocomplete assert_own_property: The global object must have a property "onautocomplete" expected property "onautocomplete" missing … … 3925 3925 PASS Window interface: attribute onstorage 3926 3926 PASS Window interface: attribute onunload 3927 FAIL Window interface: operation btoa(DOMString) desc is not an Object. (evaluating '"get" in desc') 3928 FAIL Window interface: operation atob(DOMString) desc is not an Object. (evaluating '"get" in desc') 3929 FAIL Window interface: operation setTimeout(Function,long,any) desc is not an Object. (evaluating '"get" in desc') 3930 FAIL Window interface: operation setTimeout(DOMString,long,any) desc is not an Object. (evaluating '"get" in desc') 3931 FAIL Window interface: operation clearTimeout(long) desc is not an Object. (evaluating '"get" in desc') 3932 FAIL Window interface: operation setInterval(Function,long,any) desc is not an Object. (evaluating '"get" in desc') 3933 FAIL Window interface: operation setInterval(DOMString,long,any) desc is not an Object. (evaluating '"get" in desc') 3934 FAIL Window interface: operation clearInterval(long) desc is not an Object. (evaluating '"get" in desc') 3927 PASS Window interface: operation btoa(DOMString) 3928 PASS Window interface: operation atob(DOMString) 3929 PASS Window interface: operation setTimeout(Function,long,any) 3930 PASS Window interface: operation setTimeout(DOMString,long,any) 3931 PASS Window interface: operation clearTimeout(long) 3932 PASS Window interface: operation setInterval(Function,long,any) 3933 PASS Window interface: operation setInterval(DOMString,long,any) 3934 PASS Window interface: operation clearInterval(long) 3935 3935 FAIL Window interface: operation createImageBitmap(ImageBitmapSource,long,long,long,long) assert_own_property: global object missing non-static operation expected property "createImageBitmap" missing 3936 3936 PASS Window interface: attribute sessionStorage … … 4143 4143 PASS Location interface: window.location must have own property "search" 4144 4144 PASS Location interface: window.location must have own property "hash" 4145 FAIL Location interface: window.location must have own property "assign" assert_own_property: Doesn't have the unforgeable operation property expected property "assign" missing 4146 FAIL Location interface: calling assign(USVString) on window.location with too few arguments must throw TypeError assert_own_property: expected property "assign" missing 4147 FAIL Location interface: window.location must have own property "replace" assert_own_property: Doesn't have the unforgeable operation property expected property "replace" missing 4148 FAIL Location interface: calling replace(USVString) on window.location with too few arguments must throw TypeError assert_own_property: expected property "replace" missing 4149 FAIL Location interface: window.location must have own property "reload" assert_own_property: Doesn't have the unforgeable operation property expected property "reload" missing 4145 FAIL Location interface: window.location must have own property "assign" assert_equals: property should be writable if and only if not unforgeable expected false but got true 4146 FAIL Location interface: calling assign(USVString) on window.location with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 4147 [native code] 4148 }" did not throw 4149 FAIL Location interface: window.location must have own property "replace" assert_equals: property should be writable if and only if not unforgeable expected false but got true 4150 FAIL Location interface: calling replace(USVString) on window.location with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 4151 [native code] 4152 }" did not throw 4153 FAIL Location interface: window.location must have own property "reload" assert_equals: property should be writable if and only if not unforgeable expected false but got true 4150 4154 PASS Location interface: window.location must have own property "ancestorOrigins" 4151 4155 PASS PopStateEvent interface: existence and properties of interface object -
trunk/LayoutTests/inspector/model/remote-object-get-properties-expected.txt
r196538 r196648 72 72 cancelBubble 73 73 clipboardData 74 stopPropagation 75 preventDefault 76 initEvent 77 stopImmediatePropagation 74 78 NONE 75 79 CAPTURING_PHASE … … 92 96 SELECT 93 97 CHANGE 94 stopPropagation95 preventDefault96 initEvent97 stopImmediatePropagation98 98 toString 99 99 toLocaleString -
trunk/Source/JavaScriptCore/ChangeLog
r196644 r196648 1 2016-02-16 Chris Dumez <cdumez@apple.com> 2 3 [Web IDL] Operations should be on the instance for global objects or if [Unforgeable] 4 https://bugs.webkit.org/show_bug.cgi?id=154120 5 <rdar://problem/24613231> 6 7 Reviewed by Gavin Barraclough. 8 9 Have putEntry() take a thisValue parameter in addition to the base, 10 instead of relying on PropertySlot::thisValue() because this did not 11 always do the right thing. In particular, when JSDOMWindow::put() was 12 called to set a function, it would end up setting the new value on the 13 JSDOMWindowShell instead of the actual JSDOMWindow. 14 JSDOMWindow::getOwnPropertySlot() would then not be able to find it. 15 Therefore the following would fail: 16 $ window.open = "test" 17 $ console.log(window.open) // prints the native function instead of "test" 18 19 * runtime/JSObject.cpp: 20 (JSC::JSObject::putInlineSlow): 21 * runtime/Lookup.h: 22 (JSC::putEntry): 23 (JSC::lookupPut): 24 1 25 2016-02-16 Keith Miller <keith_miller@apple.com> 2 26 -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r196524 r196648 417 417 if (obj->classInfo()->hasStaticSetterOrReadonlyProperties()) { 418 418 if (auto* entry = obj->findPropertyHashEntry(propertyName)) { 419 putEntry(exec, entry, obj, propertyName, value, slot);419 putEntry(exec, entry, obj, this, propertyName, value, slot); 420 420 return; 421 421 } -
trunk/Source/JavaScriptCore/runtime/Lookup.h
r196374 r196648 269 269 } 270 270 271 inline void putEntry(ExecState* exec, const HashTableValue* entry, JSObject* base, PropertyName propertyName, JSValue value, PutPropertySlot& slot) 271 // 'base' means the object holding the property (possibly in the prototype chain of the object put was called on). 272 // 'thisValue' is the object that put is being applied to (in the case of a proxy, the proxy target). 273 // 'slot.thisValue()' is the object the put was originally performed on (in the case of a proxy, the proxy itself). 274 inline void putEntry(ExecState* exec, const HashTableValue* entry, JSObject* base, JSObject* thisValue, PropertyName propertyName, JSValue value, PutPropertySlot& slot) 272 275 { 273 276 // If this is a function put it as an override property. 274 277 if (entry->attributes() & BuiltinOrFunction) { 275 if (JSObject* thisObject = jsDynamicCast<JSObject*>( slot.thisValue()))278 if (JSObject* thisObject = jsDynamicCast<JSObject*>(thisValue)) 276 279 thisObject->putDirect(exec->vm(), propertyName, value); 277 280 } else if (entry->attributes() & Accessor) { … … 279 282 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); 280 283 } else if (!(entry->attributes() & ReadOnly)) { 281 JSValue thisValue = entry->attributes() & CustomAccessor ? slot.thisValue() : JSValue(base);282 entry->propertyPutter()(exec, JSValue::encode( thisValue), JSValue::encode(value));284 JSValue updateThisValue = entry->attributes() & CustomAccessor ? slot.thisValue() : JSValue(base); 285 entry->propertyPutter()(exec, JSValue::encode(updateThisValue), JSValue::encode(value)); 283 286 if (entry->attributes() & CustomAccessor) 284 287 slot.setCustomAccessor(base, entry->propertyPutter()); … … 301 304 return false; 302 305 303 putEntry(exec, entry, base, propertyName, value, slot);306 putEntry(exec, entry, base, base, propertyName, value, slot); 304 307 return true; 305 308 } -
trunk/Source/WebCore/ChangeLog
r196641 r196648 1 2016-02-16 Chris Dumez <cdumez@apple.com> 2 3 [Web IDL] Operations should be on the instance for global objects or if [Unforgeable] 4 https://bugs.webkit.org/show_bug.cgi?id=154120 5 <rdar://problem/24613231> 6 7 Reviewed by Gavin Barraclough. 8 9 Operations should be on the instance for global objects or if 10 [Unforgeable] as per the Web IDL specification: 11 - http://heycam.github.io/webidl/#es-operations 12 - http://heycam.github.io/webidl/#dfn-unforgeable-on-an-interface 13 14 This patch implements this behavior in order to align 15 with the specification and other browsers. 16 17 No new tests, already covered by existing tests. 18 19 * bindings/js/JSDOMWindowCustom.cpp: 20 (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess): 21 Update function names now that they have "Instance" in their 22 name instead of "Prototype". 23 24 (WebCore::JSDOMWindow::getOwnPropertySlot): 25 - Update function names now that they have "Instance" in their 26 name instead of "Prototype". 27 - Move the functions hard-coding *before* the static table check 28 now that these functions are in the static table to maintain 29 the previous behavior. 30 31 * bindings/js/JSLocationCustom.cpp: 32 (WebCore::JSLocation::getOwnPropertySlotDelegate): 33 Update function names now that they have "Instance" in their 34 name instead of "Prototype". 35 36 * bindings/scripts/CodeGeneratorJS.pm: 37 - Move functions to the instance if their interface is a global 38 object or if they are marked as [Unforgeable]. Operations are 39 now treated more like attributes, as they can now be either on 40 the instance or the prototype. In a lot of places, I now use 41 the naming "properties" instead of "attributes" as "properties" 42 refer both "attributes" and "operations" / "functions". 43 44 * bindings/scripts/test/JS/JSTestInterface.cpp: 45 * bindings/scripts/test/JS/JSTestObj.cpp: 46 Rebaseline bindings tests. 47 1 48 2016-02-16 Simon Fraser <simon.fraser@apple.com> 2 49 -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r196628 r196648 110 110 } 111 111 if (propertyName == exec->propertyNames().close) { 112 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionClose, 0>);112 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>); 113 113 return true; 114 114 } … … 123 123 // Always provide the original function, on a fresh uncached function object. 124 124 if (propertyName == exec->propertyNames().blur) { 125 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionBlur, 0>);125 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionBlur, 0>); 126 126 return true; 127 127 } 128 128 if (propertyName == exec->propertyNames().close) { 129 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionClose, 0>);129 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>); 130 130 return true; 131 131 } 132 132 if (propertyName == exec->propertyNames().focus) { 133 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionFocus, 0>);133 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>); 134 134 return true; 135 135 } 136 136 if (propertyName == exec->propertyNames().postMessage) { 137 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionPostMessage, 2>);137 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>); 138 138 return true; 139 139 } … … 259 259 if (Base::getOwnPropertySlot(thisObject, exec, propertyName, slot)) 260 260 return true; 261 if (!thisObject->staticFunctionsReified()) { 262 if (auto* entry = JSDOMWindow::info()->staticPropHashTable->entry(propertyName)) { 263 slot.setCacheableCustom(thisObject, entry->attributes(), entry->propertyGetter()); 264 return true; 265 } 266 } 261 267 262 // FIXME: These are all bogus. Keeping these here make some tests pass that check these properties 268 263 // are own properties of the window, but introduces other problems instead (e.g. if you overwrite 269 264 // & delete then the original value is restored!) Should be removed. 270 265 if (propertyName == exec->propertyNames().blur) { 271 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionBlur, 0>);266 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionBlur, 0>); 272 267 return true; 273 268 } 274 269 if (propertyName == exec->propertyNames().close) { 275 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionClose, 0>);270 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>); 276 271 return true; 277 272 } 278 273 if (propertyName == exec->propertyNames().focus) { 279 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindow PrototypeFunctionFocus, 0>);274 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>); 280 275 return true; 281 276 } 282 277 if (propertyName == exec->propertyNames().postMessage) { 283 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionPostMessage, 2>); 284 return true; 285 } 278 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>); 279 return true; 280 } 281 282 if (!thisObject->staticFunctionsReified()) { 283 if (auto* entry = JSDOMWindow::info()->staticPropHashTable->entry(propertyName)) { 284 if (entry->attributes() & BuiltinOrFunctionOrAccessor) 285 return setUpStaticFunctionSlot(exec, entry, thisObject, propertyName, slot); 286 slot.setCacheableCustom(thisObject, entry->attributes(), entry->propertyGetter()); 287 return true; 288 } 289 } 290 286 291 // FIXME: this looks pretty bogus. It seems highly likely that if !canShowModalDialog the 287 292 // funtion should still be present, or should be omitted entirely - present but reads as -
trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp
r196423 r196648 51 51 // Make these read-only / non-configurable to prevent writes via defineProperty. 52 52 if (propertyName == exec->propertyNames().replace) { 53 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsLocation PrototypeFunctionReplace, 1>);53 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsLocationInstanceFunctionReplace, 1>); 54 54 return true; 55 55 } 56 56 if (propertyName == exec->propertyNames().reload) { 57 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsLocation PrototypeFunctionReload, 0>);57 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsLocationInstanceFunctionReload, 0>); 58 58 return true; 59 59 } 60 60 if (propertyName == exec->propertyNames().assign) { 61 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsLocation PrototypeFunctionAssign, 1>);61 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsLocationInstanceFunctionAssign, 1>); 62 62 return true; 63 63 } -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r196588 r196648 4 4 # Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> 5 5 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 6 # Copyright (C) 2006, 2007-2010, 2013-2 105Apple Inc. All rights reserved.6 # Copyright (C) 2006, 2007-2010, 2013-2016 Apple Inc. All rights reserved. 7 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 8 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. … … 384 384 sub GenerateGetOwnPropertySlotBody 385 385 { 386 my ($interface, $interfaceName, $className, $has Attributes, $inlined) = @_;386 my ($interface, $interfaceName, $className, $hasInstanceProperties, $inlined) = @_; 387 387 388 388 my $namespaceMaybe = ($inlined ? "JSC::" : ""); … … 393 393 394 394 my $ownPropertyCheck = sub { 395 if ($has Attributes) {396 if ($inlined) {397 push(@getOwnPropertySlotImpl, " if (${namespaceMaybe}getStaticValueSlot<$className, Base>(state, *info()->staticPropHashTable, thisObject, propertyName, slot))\n");398 } else {399 push(@getOwnPropertySlotImpl, " if (${namespaceMaybe}getStaticValueSlot<$className, Base>(state, ${className}Table, thisObject, propertyName, slot))\n");400 }395 if ($hasInstanceProperties) { 396 my $instanceFunctionCount = InstanceFunctionCount($interface); 397 # If there are functions on the instance, then call getStaticPropertySlot() instead of getStaticValueSlot(). 398 my $staticPropertyGetFunction = $namespaceMaybe . ($instanceFunctionCount eq 0 ? "getStaticValueSlot" : "getStaticPropertySlot"); 399 my $staticPropertyTable = $inlined ? "*info()->staticPropHashTable" : "${className}Table"; 400 push(@getOwnPropertySlotImpl, " if ($staticPropertyGetFunction<$className, Base>(state, ${staticPropertyTable}, thisObject, propertyName, slot))\n"); 401 401 } else { 402 402 push(@getOwnPropertySlotImpl, " if (Base::getOwnPropertySlot(thisObject, state, propertyName, slot))\n"); … … 606 606 } 607 607 608 my $kind = $function->isStatic ? "Constructor" : "Prototype";608 my $kind = $function->isStatic ? "Constructor" : (OperationShouldBeOnInstance($interface, $function) ? "Instance" : "Prototype"); 609 609 return $codeGenerator->WK_lcfirst($className) . $kind . "Function" . $codeGenerator->WK_ucfirst($function->signature->name); 610 610 } … … 730 730 } 731 731 732 # https://heycam.github.io/webidl/#es-operations 733 sub OperationShouldBeOnInstance 734 { 735 my $interface = shift; 736 my $function = shift; 737 738 # FIXME: The bindings generator does not support putting runtime-enabled on the instance yet. 739 return 0 if $function->signature->extendedAttributes->{"EnabledAtRuntime"}; 740 741 return 1 if IsDOMGlobalObject($interface); 742 743 # [Unforgeable] operations should be on the instance. 744 # https://heycam.github.io/webidl/#Unforgeable 745 return 1 if $function->signature->extendedAttributes->{"Unforgeable"} || $interface->extendedAttributes->{"Unforgeable"}; 746 747 return 0; 748 } 749 732 750 sub GetIndexedGetterFunction 733 751 { … … 742 760 } 743 761 744 sub InstanceAttributeCount 762 sub InstanceFunctionCount 763 { 764 my $interface = shift; 765 my $count = 0; 766 767 foreach my $function (@{$interface->functions}) { 768 $count++ if OperationShouldBeOnInstance($interface, $function); 769 } 770 771 return $count; 772 } 773 774 sub PrototypeFunctionCount 775 { 776 my $interface = shift; 777 my $count = 0; 778 779 foreach my $function (@{$interface->functions}) { 780 $count++ if !$function->isStatic && !OperationShouldBeOnInstance($interface, $function); 781 } 782 783 return $count; 784 } 785 786 sub InstancePropertyCount 745 787 { 746 788 my $interface = shift; 747 789 my $count = 0; 748 790 foreach my $attribute (@{$interface->attributes}) { 749 $count = $count + AttributeShouldBeOnInstance($interface, $attribute); 750 } 751 $count = $count + 1 if ConstructorShouldBeOnInstance($interface); 791 $count++ if AttributeShouldBeOnInstance($interface, $attribute); 792 } 793 $count += InstanceFunctionCount($interface); 794 $count++ if ConstructorShouldBeOnInstance($interface); 752 795 return $count; 753 796 } 754 797 755 sub Prototype AttributeCount798 sub PrototypePropertyCount 756 799 { 757 800 my $interface = shift; 758 801 my $count = 0; 759 802 foreach my $attribute (@{$interface->attributes}) { 760 $count = $count + 1 if !AttributeShouldBeOnInstance($interface, $attribute); 761 } 762 $count = $count + 1 if !ConstructorShouldBeOnInstance($interface); 803 $count++ if !AttributeShouldBeOnInstance($interface, $attribute); 804 } 805 $count += PrototypeFunctionCount($interface); 806 $count++ if !ConstructorShouldBeOnInstance($interface); 763 807 return $count; 764 808 } … … 767 811 { 768 812 my $interface = shift; 769 my $numInstance Attributes = InstanceAttributeCount($interface);813 my $numInstanceProperties = InstancePropertyCount($interface); 770 814 771 815 my $namedGetterFunction = GetNamedGetterFunction($interface); … … 780 824 || $hasNamedGetter; 781 825 782 return $numInstance Attributes > 0 || $hasComplexGetter;826 return $numInstanceProperties > 0 || $hasComplexGetter; 783 827 784 828 } … … 787 831 { 788 832 my $interface = shift; 789 my $numPrototype Attributes = PrototypeAttributeCount($interface);833 my $numPrototypeProperties = PrototypePropertyCount($interface); 790 834 my $numConstants = @{$interface->constants}; 791 my $numFunctions = @{$interface->functions}; 792 return $numFunctions > 0 || $numConstants > 0 || $numPrototypeAttributes > 0; 835 return $numConstants > 0 || $numPrototypeProperties > 0; 793 836 } 794 837 … … 945 988 } 946 989 947 my $hasStaticPropertyTable = Instance AttributeCount($interface) > 0 ? "true" : "false";990 my $hasStaticPropertyTable = InstancePropertyCount($interface) > 0 ? "true" : "false"; 948 991 push(@headerContent, " static const bool hasStaticPropertyTable = $hasStaticPropertyTable;\n\n"); 949 992 … … 1336 1379 } 1337 1380 1338 sub Generate AttributesHashTable1339 { 1340 my ($object, $interface, $isInstance, $hashKeys, $hashSpecials, $hashValue1, $hashValue2, $conditionals, $ entries) = @_;1381 sub GeneratePropertiesHashTable 1382 { 1383 my ($object, $interface, $isInstance, $hashKeys, $hashSpecials, $hashValue1, $hashValue2, $conditionals, $runtimeEnabledFunctions) = @_; 1341 1384 1342 1385 # FIXME: These should be functions on $interface. … … 1344 1387 my $className = "JS$interfaceName"; 1345 1388 1346 # - Add all attributes in a hashtable definition 1347 my $numAttributes = 0; 1348 if ($isInstance) { 1349 $numAttributes = InstanceAttributeCount($interface); 1350 } else { 1351 $numAttributes = PrototypeAttributeCount($interface); 1352 } 1353 1389 # - Add all properties in a hashtable definition 1390 my $propertyCount = $isInstance ? InstancePropertyCount($interface) : PrototypePropertyCount($interface); 1354 1391 1355 1392 if (ConstructorShouldBeOnInstance($interface) == $isInstance) { 1356 1393 1357 1394 if (NeedsConstructorProperty($interface)) { 1358 die if !$ numAttributes;1395 die if !$propertyCount; 1359 1396 push(@$hashKeys, "constructor"); 1360 1397 my $getter = "js" . $interfaceName . "Constructor"; … … 1367 1404 } 1368 1405 1369 return 0 if !$ numAttributes;1406 return 0 if !$propertyCount; 1370 1407 1371 1408 foreach my $attribute (@{$interface->attributes}) { … … 1404 1441 } 1405 1442 1406 return $numAttributes; 1443 foreach my $function (@{$interface->functions}) { 1444 next if ($function->signature->extendedAttributes->{"Private"}); 1445 next if ($function->isStatic); 1446 next if $function->{overloadIndex} && $function->{overloadIndex} > 1; 1447 next if OperationShouldBeOnInstance($interface, $function) != $isInstance; 1448 my $name = $function->signature->name; 1449 push(@$hashKeys, $name); 1450 1451 my $functionName = GetFunctionName($interface, $className, $function); 1452 push(@$hashValue1, $functionName); 1453 1454 my $functionLength = GetFunctionLength($function); 1455 push(@$hashValue2, $functionLength); 1456 1457 push(@$hashSpecials, ComputeFunctionSpecial($interface, $function)); 1458 1459 my $conditional = $function->signature->extendedAttributes->{"Conditional"}; 1460 if ($conditional) { 1461 $conditionals->{$name} = $conditional; 1462 } 1463 1464 if ($function->signature->extendedAttributes->{"EnabledAtRuntime"}) { 1465 if ($isInstance) { 1466 die "We currently do not support [EnabledAtRuntime] operations on the instance."; 1467 } else { 1468 push(@$runtimeEnabledFunctions, $function); 1469 } 1470 } 1471 } 1472 1473 return $propertyCount; 1407 1474 } 1408 1475 … … 1534 1601 # declaration in the IDL. 1535 1602 1536 my $kind = $function->isStatic ? "Constructor" : "Prototype";1603 my $kind = $function->isStatic ? "Constructor" : (OperationShouldBeOnInstance($interface, $function) ? "Instance" : "Prototype"); 1537 1604 my $functionName = "js${interfaceName}${kind}Function" . $codeGenerator->WK_ucfirst($function->signature->name); 1538 1605 … … 1865 1932 my %conditionals = (); 1866 1933 my $hashName = $className . "Table"; 1867 1868 my $numInstanceAttributes = GenerateAttributesHashTable($object, $interface, 1, 1934 my @runtimeEnabledFunctions = (); 1935 1936 # Generate hash table for properties on the instance. 1937 my $numInstanceProperties = GeneratePropertiesHashTable($object, $interface, 1, 1869 1938 \@hashKeys, \@hashSpecials, 1870 1939 \@hashValue1, \@hashValue2, 1871 \%conditionals );1872 1873 $object->GenerateHashTable($hashName, $numInstance Attributes,1940 \%conditionals, \@runtimeEnabledFunctions); 1941 1942 $object->GenerateHashTable($hashName, $numInstanceProperties, 1874 1943 \@hashKeys, \@hashSpecials, 1875 1944 \@hashValue1, \@hashValue2, 1876 \%conditionals, 0) if $numInstance Attributes > 0;1877 1878 # - Add all constants1945 \%conditionals, 0) if $numInstanceProperties > 0; 1946 1947 # - Add all interface object (aka constructor) properties (constants, static attributes, static operations). 1879 1948 if (NeedsConstructorProperty($interface)) { 1880 1949 my $hashSize = 0; … … 1982 2051 @hashSpecials = (); 1983 2052 %conditionals = (); 1984 1985 1986 my $numPrototypeAttributes = GenerateAttributesHashTable($object, $interface, 0, 2053 @runtimeEnabledFunctions = (); 2054 2055 # Generate hash table for properties on the prototype. 2056 my $numPrototypeProperties = GeneratePropertiesHashTable($object, $interface, 0, 1987 2057 \@hashKeys, \@hashSpecials, 1988 2058 \@hashValue1, \@hashValue2, 1989 \%conditionals );1990 my $hashSize = $numPrototype Attributes;2059 \%conditionals, \@runtimeEnabledFunctions); 2060 my $hashSize = $numPrototypeProperties; 1991 2061 1992 2062 foreach my $constant (@{$interface->constants}) { … … 2006 2076 } 2007 2077 2008 my @runtimeEnabledFunctions = ();2009 2010 foreach my $function (@{$interface->functions}) {2011 next if ($function->signature->extendedAttributes->{"Private"});2012 next if ($function->isStatic);2013 next if $function->{overloadIndex} && $function->{overloadIndex} > 1;2014 my $name = $function->signature->name;2015 push(@hashKeys, $name);2016 2017 my $functionName = GetFunctionName($interface, $className, $function);2018 push(@hashValue1, $functionName);2019 2020 my $functionLength = GetFunctionLength($function);2021 push(@hashValue2, $functionLength);2022 2023 push(@hashSpecials, ComputeFunctionSpecial($interface, $function));2024 2025 my $conditional = $function->signature->extendedAttributes->{"Conditional"};2026 if ($conditional) {2027 $conditionals{$name} = $conditional;2028 }2029 2030 push(@runtimeEnabledFunctions, $function) if $function->signature->extendedAttributes->{"EnabledAtRuntime"};2031 2032 $hashSize++;2033 }2034 2035 2078 my $justGenerateValueArray = !IsDOMGlobalObject($interface); 2036 2079 … … 2047 2090 2048 2091 if (PrototypeOverridesGetOwnPropertySlot($interface)) { 2049 my $numPrototypeAttributes = PrototypeAttributeCount($interface); 2092 my $prototypePropertyCount = PrototypePropertyCount($interface); 2093 my $prototypeFunctionCount = PrototypeFunctionCount($interface); 2094 my $prototypeAttributeCount = $prototypePropertyCount - $prototypeFunctionCount; 2050 2095 if (IsDOMGlobalObject($interface)) { 2051 2096 push(@implContent, "bool ${className}Prototype::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)\n"); … … 2055 2100 push(@implContent, " auto* thisObject = jsCast<${className}Prototype*>(object);\n"); 2056 2101 2057 if ($numConstants eq 0 && $ numFunctions eq 0 && $numPrototypeAttributeseq 0) {2102 if ($numConstants eq 0 && $prototypePropertyCount eq 0) { 2058 2103 push(@implContent, " return Base::getOwnPropertySlot(thisObject, state, propertyName, slot);\n"); 2059 } elsif ($numConstants eq 0 && $ numPrototypeAttributeseq 0) {2104 } elsif ($numConstants eq 0 && $prototypeAttributeCount eq 0) { 2060 2105 push(@implContent, " return getStaticFunctionSlot<JSObject>(state, ${className}PrototypeTable, thisObject, propertyName, slot);\n"); 2061 } elsif ($ numFunctions eq 0 && $numPrototypeAttributeseq 0) {2106 } elsif ($prototypePropertyCount eq 0) { 2062 2107 push(@implContent, " return getStaticValueSlot<${className}Prototype, JSObject>(state, ${className}PrototypeTable, thisObject, propertyName, slot);\n"); 2063 2108 } else { … … 2065 2110 } 2066 2111 push(@implContent, "}\n\n"); 2067 } elsif ($numConstants > 0 || $num Functions > 0 || $numPrototypeAttributes > 0) {2112 } elsif ($numConstants > 0 || $numPrototypeProperties > 0) { 2068 2113 push(@implContent, "void ${className}Prototype::finishCreation(VM& vm)\n"); 2069 2114 push(@implContent, "{\n"); … … 2116 2161 push(@implContent, "const ClassInfo $className" . "::s_info = { \"${visibleInterfaceName}\", &Base::s_info, "); 2117 2162 2118 if ($numInstance Attributes > 0) {2163 if ($numInstanceProperties > 0) { 2119 2164 push(@implContent, "&${className}Table"); 2120 2165 } else { … … 2185 2230 push(@implContent, " auto* thisObject = jsCast<${className}*>(object);\n"); 2186 2231 push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, info());\n"); 2187 push(@implContent, GenerateGetOwnPropertySlotBody($interface, $interfaceName, $className, $numInstance Attributes > 0, 0));2232 push(@implContent, GenerateGetOwnPropertySlotBody($interface, $interfaceName, $className, $numInstanceProperties > 0, 0)); 2188 2233 push(@implContent, "}\n\n"); 2189 2234 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
r196563 r196648 324 324 #endif 325 325 #if ENABLE(Condition22) || ENABLE(Condition23) 326 { "implementsMethod1", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionImplementsMethod1), (intptr_t) (0) } }, 327 #else 328 { 0, 0, NoIntrinsic, { 0, 0 } }, 329 #endif 330 #if ENABLE(Condition22) || ENABLE(Condition23) 331 { "implementsMethod2", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionImplementsMethod2), (intptr_t) (2) } }, 332 #else 333 { 0, 0, NoIntrinsic, { 0, 0 } }, 334 #endif 335 #if ENABLE(Condition22) || ENABLE(Condition23) 336 { "implementsMethod3", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionImplementsMethod3), (intptr_t) (0) } }, 337 #else 338 { 0, 0, NoIntrinsic, { 0, 0 } }, 339 #endif 340 #if ENABLE(Condition11) || ENABLE(Condition12) 341 { "supplementalMethod1", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod1), (intptr_t) (0) } }, 342 #else 343 { 0, 0, NoIntrinsic, { 0, 0 } }, 344 #endif 345 #if ENABLE(Condition11) || ENABLE(Condition12) 346 { "supplementalMethod2", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod2), (intptr_t) (2) } }, 347 #else 348 { 0, 0, NoIntrinsic, { 0, 0 } }, 349 #endif 350 #if ENABLE(Condition11) || ENABLE(Condition12) 351 { "supplementalMethod3", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod3), (intptr_t) (0) } }, 352 #else 353 { 0, 0, NoIntrinsic, { 0, 0 } }, 354 #endif 355 #if ENABLE(Condition11) || ENABLE(Condition12) 356 { "builtinFunction", JSC::Builtin, NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(testSupplementalBuiltinFunctionCodeGenerator), (intptr_t) (0) } }, 357 #else 358 { 0, 0, NoIntrinsic, { 0, 0 } }, 359 #endif 360 #if ENABLE(Condition22) || ENABLE(Condition23) 326 361 { "IMPLEMENTSCONSTANT1", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, 327 362 #else … … 340 375 #if ENABLE(Condition11) || ENABLE(Condition12) 341 376 { "SUPPLEMENTALCONSTANT2", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, 342 #else343 { 0, 0, NoIntrinsic, { 0, 0 } },344 #endif345 #if ENABLE(Condition22) || ENABLE(Condition23)346 { "implementsMethod1", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionImplementsMethod1), (intptr_t) (0) } },347 #else348 { 0, 0, NoIntrinsic, { 0, 0 } },349 #endif350 #if ENABLE(Condition22) || ENABLE(Condition23)351 { "implementsMethod2", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionImplementsMethod2), (intptr_t) (2) } },352 #else353 { 0, 0, NoIntrinsic, { 0, 0 } },354 #endif355 #if ENABLE(Condition22) || ENABLE(Condition23)356 { "implementsMethod3", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionImplementsMethod3), (intptr_t) (0) } },357 #else358 { 0, 0, NoIntrinsic, { 0, 0 } },359 #endif360 #if ENABLE(Condition11) || ENABLE(Condition12)361 { "supplementalMethod1", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod1), (intptr_t) (0) } },362 #else363 { 0, 0, NoIntrinsic, { 0, 0 } },364 #endif365 #if ENABLE(Condition11) || ENABLE(Condition12)366 { "supplementalMethod2", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod2), (intptr_t) (2) } },367 #else368 { 0, 0, NoIntrinsic, { 0, 0 } },369 #endif370 #if ENABLE(Condition11) || ENABLE(Condition12)371 { "supplementalMethod3", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod3), (intptr_t) (0) } },372 #else373 { 0, 0, NoIntrinsic, { 0, 0 } },374 #endif375 #if ENABLE(Condition11) || ENABLE(Condition12)376 { "builtinFunction", JSC::Builtin, NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(testSupplementalBuiltinFunctionCodeGenerator), (intptr_t) (0) } },377 377 #else 378 378 { 0, 0, NoIntrinsic, { 0, 0 } }, -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r196563 r196648 589 589 { "putForwardsAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsAttribute) } }, 590 590 { "putForwardsNullableAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsNullableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsNullableAttribute) } }, 591 #if ENABLE(Condition1)592 { "CONDITIONAL_CONST", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } },593 #else594 { 0, 0, NoIntrinsic, { 0, 0 } },595 #endif596 { "CONST_VALUE_0", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } },597 { "CONST_VALUE_1", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } },598 { "CONST_VALUE_2", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } },599 { "CONST_VALUE_4", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } },600 { "CONST_VALUE_8", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } },601 { "CONST_VALUE_9", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(-1) } },602 { "CONST_VALUE_11", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0xffffffff) } },603 { "CONST_VALUE_12", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x01) } },604 { "CONST_VALUE_13", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0X20) } },605 { "CONST_VALUE_14", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x1abc) } },606 { "CONST_JAVASCRIPT", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(15) } },607 { "readonly", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } },608 591 { "voidMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t) (0) } }, 609 592 { "voidMethodWithArgs", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t) (3) } }, … … 706 689 { "testPromiseFunctionWithException", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunctionWithException), (intptr_t) (0) } }, 707 690 { "testPromiseFunctionWithOptionalIntArgument", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgument), (intptr_t) (0) } }, 691 #if ENABLE(Condition1) 692 { "CONDITIONAL_CONST", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } }, 693 #else 694 { 0, 0, NoIntrinsic, { 0, 0 } }, 695 #endif 696 { "CONST_VALUE_0", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } }, 697 { "CONST_VALUE_1", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, 698 { "CONST_VALUE_2", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, 699 { "CONST_VALUE_4", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } }, 700 { "CONST_VALUE_8", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } }, 701 { "CONST_VALUE_9", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(-1) } }, 702 { "CONST_VALUE_11", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0xffffffff) } }, 703 { "CONST_VALUE_12", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x01) } }, 704 { "CONST_VALUE_13", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0X20) } }, 705 { "CONST_VALUE_14", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x1abc) } }, 706 { "CONST_JAVASCRIPT", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(15) } }, 707 { "readonly", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } }, 708 708 }; 709 709
Note: See TracChangeset
for help on using the changeset viewer.