Make our bindings' GetOwnPropertySlot() behave according to specification
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 19:15:44 +0000 (19:15 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 19:15:44 +0000 (19:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148092

Reviewed by Geoffrey Garen.

Source/WebCore:

Make our bindings' GetOwnPropertySlot() behave according to
specification. In particular, our bindings use to do:
1. Indexed getter
2. Check static properties
3. Prototype check
4. Named getter
5. Check own properties

According to the specification [1][2], we should do:
- If the interface has [OverrideBuiltins]:
    1. Indexed getter
    2. Named getter
    3. Static / own properties
- Otherwise:
    1. Indexed getter
    2. Static / own properties
    3. Prototype check
    4. Named getter

This patch adds support for the [OverrideBuiltins] IDL extended
attribute [3] and aligns our bindings implementation with the Web IDL
specification weither that IDL extended attribute is present or
not.

[1] https://heycam.github.io/webidl/#getownproperty-guts
[2] https://heycam.github.io/webidl/#dfn-named-property-visibility
[3] https://heycam.github.io/webidl/#OverrideBuiltins

Performance:
- PerformanceTests/Bindings/childNodes-traversal.html: ~Same
- PerformanceTests/Bindings/children-traversal.html: +104% :)

No new tests, covered by:
fast/dom/htmlcollection-getownproperty.html
fast/dom/collection-length-should-not-be-overridden.html
fast/forms/input-named-action-overrides-action-attribute.html

* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::JSHTMLCollection::nameGetter):
Add assertions to make sure we don't use HTMLCollection's namedGetter()
for HTMLFormControlsCollection / HTMLOptionsCollection subclasses.
We should use the subclasses' namedGetter() instead.

* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
(WebCore::JSHTMLOptionsCollection::canGetItemsForName):
(WebCore::JSHTMLOptionsCollection::nameGetter):
Add code for handling named getter requests on
HTMLOptionsCollection.

* bindings/js/JSNodeListCustom.cpp:
(WebCore::JSNodeList::canGetItemsForName):
(WebCore::JSNodeList::nameGetter):
Refactor custom code for the NodeList named getter, now that the
IDL interface is using [CustomNamedGetter] instead of
[JSCustomGetOwnPropertySlotAndDescriptor].

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateGetOwnPropertySlotBody):
(GenerateHeaderContentHeader): Deleted.
- Add support for the [OverrideBuiltins] IDL extended attribute and
update the generated getOwnPropertySlot() methods to match the
Web IDL specification.
- Also drop the JSC::HasImpureGetOwnPropertySlot flag for interfaces
that have a named getter but NOT the [OverrideBuiltins] IDL extended
attribute. Without [OverrideBuiltins], named properties can no longer
shadow own properties so we no longer need to mark GetOwnPropertySlot
as impure. This allows caching of properties.

* bindings/scripts/IDLAttributes.txt:
Add [OverrideBuiltins] IDL extended attribute [3].

* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
(WebCore::JSTestActiveDOMObject::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
(WebCore::JSTestCustomNamedGetter::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestEventTarget.cpp:
(WebCore::JSTestEventTarget::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestException.cpp:
(WebCore::JSTestException::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterface::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObj::getOwnPropertySlot):
Rebaseline the bindings tests as their getOwnPropertySlot() method
is now different.

* bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.cpp: Added.
* bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.h: Added.
* bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltinsPrivate.h: Added.
* bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp: Added.
* bindings/scripts/test/JS/JSTestOverrideBuiltins.h: Added.
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
* bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.h: Added.
* bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.mm: Added.
* bindings/scripts/test/ObjC/DOMTestOverrideBuiltinsInternal.h: Added.
* bindings/scripts/test/TestOverrideBuiltins.idl: Added.
Add bindings test coverage for the new [OverrideBuiltins] IDL extended
attribute [3].

* dom/DOMStringMap.idl:
Add [OverrideBuiltins] IDL extended attribute to match the specification:
https://html.spec.whatwg.org/multipage/infrastructure.html#domstringmap

* dom/NodeList.idl:
Use CustomNamedGetter IDL extended attribute instead of
JSCustomGetOwnPropertySlotAndDescriptor as NodeList merely implements
a custom named getter. This makes sure that the order in which the
named getter is called is correct as per the Web IDL specification.

* html/HTMLDocument.idl:
Add [OverrideBuiltins] IDL extended attribute to match the specification:
https://html.spec.whatwg.org/multipage/dom.html#the-document-object

* html/HTMLFormElement.idl:
Add [OverrideBuiltins] IDL extended attribute to match the specification:
https://html.spec.whatwg.org/multipage/forms.html#the-form-element

* html/HTMLOptionsCollection.idl:
Add missing 'getter' in front of the named getter, as the per the HTML
specification. Without this, HTMLOptionsCollection would not be
recognized as a named properties object, which means that we would not
check the HTMLOptionsCollection prototype before querying the named
getter on HTMLCollection. This used to work because the bindings
generator was hard-coding the prototype check for every HTML*Collection
IDL interface. In this patch, we generalized the check to every
interface that has a named getter.

LayoutTests:

* fast/dom/childnode-item-after-itemname.html:
Update the test so the item's id in the NodeList is "testItem"
instead of "item". NodeList has a method called item() which now
takes priority over the name when accessing Nodelist.item, as per
the Web IDL specification.

* fast/dom/htmlcollection-getownproperty-expected.txt:
Rebaseline test. This is a progression.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188590 268f45cc-cd09-0410-ab3c-d52691b4dbfc

32 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/childnode-item-after-itemname.html
LayoutTests/fast/dom/htmlcollection-getownproperty-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
Source/WebCore/bindings/js/JSNodeListCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltinsPrivate.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.h
Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h
Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.mm [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltinsInternal.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/TestOverrideBuiltins.idl [new file with mode: 0644]
Source/WebCore/dom/DOMStringMap.idl
Source/WebCore/dom/NodeList.idl
Source/WebCore/html/HTMLDocument.idl
Source/WebCore/html/HTMLFormElement.idl
Source/WebCore/html/HTMLOptionsCollection.idl

index 83d5745..af17bfc 100644 (file)
@@ -1,3 +1,19 @@
+2015-08-18  Chris Dumez  <cdumez@apple.com>
+
+        Make our bindings' GetOwnPropertySlot() behave according to specification
+        https://bugs.webkit.org/show_bug.cgi?id=148092
+
+        Reviewed by Geoffrey Garen.
+
+        * fast/dom/childnode-item-after-itemname.html:
+        Update the test so the item's id in the NodeList is "testItem"
+        instead of "item". NodeList has a method called item() which now
+        takes priority over the name when accessing Nodelist.item, as per
+        the Web IDL specification.
+
+        * fast/dom/htmlcollection-getownproperty-expected.txt:
+        Rebaseline test. This is a progression.
+
 2015-08-18  Jon Honeycutt  <jhoneycutt@apple.com>
 
         Remove failing expectations for some WK1 tests that have passed recent
index b9c9c31..b7dfcce 100644 (file)
@@ -3,14 +3,14 @@
 <body>
 <p>This tests accessing the first element in childNodes after accessing the second element by its id.
 WebKit should retrieve each element correctly, and you should see 2 1 below:</p>
-<span id="item"></span><span id="tests" style="display: none;">1<span id="item">2</span></span>
+<span id="testItem"></span><span id="tests" style="display: none;">1<span id="testItem">2</span></span>
 <script>
 
 if (window.testRunner)
     testRunner.dumpAsText();
 
 var tests = document.querySelector('#tests');
-document.writeln(tests.childNodes['item'].textContent);
+document.writeln(tests.childNodes['testItem'].textContent);
 document.writeln(tests.childNodes[0].textContent);
 
 </script>
index 475e936..c9c4fb4 100644 (file)
@@ -14,7 +14,7 @@ PASS htmlCollection.length is 4
 * Named properties should not mask own properties on HTMLCollection
 htmlCollection.foo = 'foo'
 PASS htmlCollection.namedItem('foo') is document.getElementById('fooP')
-FAIL htmlCollection.foo should be foo (of type string). Was [object HTMLParagraphElement] (of type object).
+PASS htmlCollection.foo is "foo"
 
 * Named properties should not mask indexed properties
 PASS htmlCollection.item(0) is testDiv.firstElementChild
@@ -24,9 +24,7 @@ PASS htmlCollection['0'] is testDiv.firstElementChild
 
 * Own properties on HTMLCollection should mask properties on prototype
 htmlCollection.toString = 'InstanceToString'
-FAIL htmlCollection.toString should be InstanceToString (of type string). Was function toString() {
-    [native code]
-} (of type function).
+PASS htmlCollection.toString is "InstanceToString"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 8762eea..5153505 100644 (file)
@@ -1,3 +1,137 @@
+2015-08-18  Chris Dumez  <cdumez@apple.com>
+
+        Make our bindings' GetOwnPropertySlot() behave according to specification
+        https://bugs.webkit.org/show_bug.cgi?id=148092
+
+        Reviewed by Geoffrey Garen.
+
+        Make our bindings' GetOwnPropertySlot() behave according to
+        specification. In particular, our bindings use to do:
+        1. Indexed getter
+        2. Check static properties
+        3. Prototype check
+        4. Named getter
+        5. Check own properties
+
+        According to the specification [1][2], we should do:
+        - If the interface has [OverrideBuiltins]:
+            1. Indexed getter
+            2. Named getter
+            3. Static / own properties
+        - Otherwise:
+            1. Indexed getter
+            2. Static / own properties
+            3. Prototype check
+            4. Named getter
+
+        This patch adds support for the [OverrideBuiltins] IDL extended
+        attribute [3] and aligns our bindings implementation with the Web IDL
+        specification weither that IDL extended attribute is present or
+        not.
+        
+        [1] https://heycam.github.io/webidl/#getownproperty-guts
+        [2] https://heycam.github.io/webidl/#dfn-named-property-visibility
+        [3] https://heycam.github.io/webidl/#OverrideBuiltins
+
+        Performance:
+        - PerformanceTests/Bindings/childNodes-traversal.html: ~Same
+        - PerformanceTests/Bindings/children-traversal.html: +104% :)
+
+        No new tests, covered by:
+        fast/dom/htmlcollection-getownproperty.html
+        fast/dom/collection-length-should-not-be-overridden.html
+        fast/forms/input-named-action-overrides-action-attribute.html
+
+        * bindings/js/JSHTMLCollectionCustom.cpp:
+        (WebCore::JSHTMLCollection::nameGetter):
+        Add assertions to make sure we don't use HTMLCollection's namedGetter()
+        for HTMLFormControlsCollection / HTMLOptionsCollection subclasses.
+        We should use the subclasses' namedGetter() instead.
+
+        * bindings/js/JSHTMLOptionsCollectionCustom.cpp:
+        (WebCore::JSHTMLOptionsCollection::canGetItemsForName):
+        (WebCore::JSHTMLOptionsCollection::nameGetter):
+        Add code for handling named getter requests on
+        HTMLOptionsCollection.
+
+        * bindings/js/JSNodeListCustom.cpp:
+        (WebCore::JSNodeList::canGetItemsForName):
+        (WebCore::JSNodeList::nameGetter):
+        Refactor custom code for the NodeList named getter, now that the
+        IDL interface is using [CustomNamedGetter] instead of
+        [JSCustomGetOwnPropertySlotAndDescriptor].
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateGetOwnPropertySlotBody):
+        (GenerateHeaderContentHeader): Deleted.
+        - Add support for the [OverrideBuiltins] IDL extended attribute and
+        update the generated getOwnPropertySlot() methods to match the
+        Web IDL specification.
+        - Also drop the JSC::HasImpureGetOwnPropertySlot flag for interfaces
+        that have a named getter but NOT the [OverrideBuiltins] IDL extended
+        attribute. Without [OverrideBuiltins], named properties can no longer
+        shadow own properties so we no longer need to mark GetOwnPropertySlot
+        as impure. This allows caching of properties.
+
+        * bindings/scripts/IDLAttributes.txt:
+        Add [OverrideBuiltins] IDL extended attribute [3].
+
+        * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
+        (WebCore::JSTestActiveDOMObject::getOwnPropertySlot):
+        * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
+        (WebCore::JSTestCustomNamedGetter::getOwnPropertySlot):
+        * bindings/scripts/test/JS/JSTestEventTarget.cpp:
+        (WebCore::JSTestEventTarget::getOwnPropertySlot):
+        * bindings/scripts/test/JS/JSTestException.cpp:
+        (WebCore::JSTestException::getOwnPropertySlot):
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore::JSTestInterface::getOwnPropertySlot):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::JSTestObj::getOwnPropertySlot):
+        Rebaseline the bindings tests as their getOwnPropertySlot() method
+        is now different.
+
+        * bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.cpp: Added.
+        * bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.h: Added.
+        * bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltinsPrivate.h: Added.
+        * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp: Added.
+        * bindings/scripts/test/JS/JSTestOverrideBuiltins.h: Added.
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        * bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.h: Added.
+        * bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.mm: Added.
+        * bindings/scripts/test/ObjC/DOMTestOverrideBuiltinsInternal.h: Added.
+        * bindings/scripts/test/TestOverrideBuiltins.idl: Added.
+        Add bindings test coverage for the new [OverrideBuiltins] IDL extended
+        attribute [3].
+
+        * dom/DOMStringMap.idl:
+        Add [OverrideBuiltins] IDL extended attribute to match the specification:
+        https://html.spec.whatwg.org/multipage/infrastructure.html#domstringmap
+
+        * dom/NodeList.idl:
+        Use CustomNamedGetter IDL extended attribute instead of
+        JSCustomGetOwnPropertySlotAndDescriptor as NodeList merely implements
+        a custom named getter. This makes sure that the order in which the
+        named getter is called is correct as per the Web IDL specification.
+
+        * html/HTMLDocument.idl:
+        Add [OverrideBuiltins] IDL extended attribute to match the specification:
+        https://html.spec.whatwg.org/multipage/dom.html#the-document-object
+
+        * html/HTMLFormElement.idl:
+        Add [OverrideBuiltins] IDL extended attribute to match the specification:
+        https://html.spec.whatwg.org/multipage/forms.html#the-form-element
+
+        * html/HTMLOptionsCollection.idl:
+        Add missing 'getter' in front of the named getter, as the per the HTML
+        specification. Without this, HTMLOptionsCollection would not be
+        recognized as a named properties object, which means that we would not
+        check the HTMLOptionsCollection prototype before querying the named
+        getter on HTMLCollection. This used to work because the bindings
+        generator was hard-coding the prototype check for every HTML*Collection
+        IDL interface. In this patch, we generalized the check to every
+        interface that has a named getter.
+
 2015-08-18  Per Arne Vollan  <peavo@outlook.com>
 
         [Win] Popup menu displayed at incorrect position when page is scrolled and device scale factor != 1.
index ef26839..364024f 100644 (file)
@@ -48,6 +48,8 @@ bool JSHTMLCollection::canGetItemsForName(ExecState*, HTMLCollection* collection
 EncodedJSValue JSHTMLCollection::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName)
 {
     JSHTMLCollection* collection = jsCast<JSHTMLCollection*>(slotBase);
+    ASSERT_WITH_MESSAGE(collection->impl().type() != FormControls, "Should call the subclass' nameGetter");
+    ASSERT_WITH_MESSAGE(collection->impl().type() != SelectOptions, "Should call the subclass' nameGetter");
     const AtomicString& name = propertyNameToAtomicString(propertyName);
     return JSValue::encode(toJS(exec, collection->globalObject(), collection->impl().namedItem(name)));
 }
index 3e3d94a..7c0d690 100644 (file)
@@ -37,6 +37,18 @@ using namespace JSC;
 
 namespace WebCore {
 
+bool JSHTMLOptionsCollection::canGetItemsForName(ExecState*, HTMLOptionsCollection* collection, PropertyName propertyName)
+{
+    return collection->hasNamedItem(propertyNameToAtomicString(propertyName));
+}
+
+EncodedJSValue JSHTMLOptionsCollection::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName)
+{
+    JSHTMLCollection* collection = jsCast<JSHTMLCollection*>(slotBase);
+    const AtomicString& name = propertyNameToAtomicString(propertyName);
+    return JSValue::encode(toJS(exec, collection->globalObject(), collection->impl().namedItem(name)));
+}
+
 void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue value)
 {
     ExceptionCode ec = 0;
index ee230cb..69d3be7 100644 (file)
@@ -51,13 +51,20 @@ bool JSNodeListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handl
     return false;
 }
 
-bool JSNodeList::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+bool JSNodeList::canGetItemsForName(ExecState*, NodeList* nodeList, PropertyName propertyName)
 {
-    if (Node* item = impl().namedItem(propertyNameToAtomicString(propertyName))) {
-        slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS(exec, globalObject(), item));
-        return true;
-    }
-    return false;
+    // FIXME: NodeList should not have a named getter. It currently has one because getElementByTagName()
+    // returns a NodeList instead of an HTMLCollection.
+    return nodeList->namedItem(propertyNameToAtomicString(propertyName));
+}
+
+EncodedJSValue JSNodeList::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName)
+{
+    // FIXME: NodeList should not have a named getter. It currently has one because getElementByTagName()
+    // returns a NodeList instead of an HTMLCollection.
+    JSNodeList* nodeList = jsCast<JSNodeList*>(slotBase);
+    const AtomicString& name = propertyNameToAtomicString(propertyName);
+    return JSValue::encode(toJS(exec, nodeList->globalObject(), nodeList->impl().namedItem(name)));
 }
 
 JSC::JSValue createWrapper(JSDOMGlobalObject& globalObject, NodeList& nodeList)
index 92e37bb..e5f3cf4 100644 (file)
@@ -381,15 +381,26 @@ sub GenerateGetOwnPropertySlotBody
 
     my @getOwnPropertySlotImpl = ();
 
-    my $manualLookupGetterGeneration = sub {
-        my $requiresManualLookup = $indexedGetterFunction || $namedGetterFunction;
-        if ($requiresManualLookup) {
-            push(@getOwnPropertySlotImpl, "    const ${namespaceMaybe}HashTableValue* entry = getStaticValueSlotEntryWithoutCaching<$className>(exec, propertyName);\n");
-            push(@getOwnPropertySlotImpl, "    if (entry) {\n");
-            push(@getOwnPropertySlotImpl, "        slot.setCacheableCustom(thisObject, entry->attributes(), entry->propertyGetter());\n");
-            push(@getOwnPropertySlotImpl, "        return true;\n");
-            push(@getOwnPropertySlotImpl, "    }\n");
+    my $ownPropertyCheck = sub {
+        if ($hasAttributes) {
+            if ($inlined) {
+                push(@getOwnPropertySlotImpl, "    if (${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, *info()->staticPropHashTable, thisObject, propertyName, slot))\n");
+            } else {
+                push(@getOwnPropertySlotImpl, "    if (${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, ${className}Table, thisObject, propertyName, slot))\n");
+            }
+        } else {
+            push(@getOwnPropertySlotImpl, "    if (Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))\n");
         }
+        push(@getOwnPropertySlotImpl, "        return true;\n");
+    };
+
+    # FIXME: As per the Web IDL specification, the prototype check is supposed to skip "named properties objects":
+    # https://heycam.github.io/webidl/#dfn-named-property-visibility
+    # https://heycam.github.io/webidl/#dfn-named-properties-object
+    my $prototypeCheck = sub {
+        push(@getOwnPropertySlotImpl, "    ${namespaceMaybe}JSValue proto = thisObject->prototype();\n");
+        push(@getOwnPropertySlotImpl, "    if (proto.isObject() && jsCast<${namespaceMaybe}JSObject*>(proto)->hasProperty(exec, propertyName))\n");
+        push(@getOwnPropertySlotImpl, "        return false;\n\n");
     };
 
     if ($indexedGetterFunction) {
@@ -414,19 +425,15 @@ sub GenerateGetOwnPropertySlotBody
         push(@getOwnPropertySlotImpl, "    }\n");
     }
 
-    if (!$interface->extendedAttributes->{"CustomNamedGetter"} and InstanceAttributeCount($interface) > 0) {
-        &$manualLookupGetterGeneration();
-    }
-
-    # FIXME: We should do this for every interface for every interface that has a named getter.
-    if ($interfaceName eq "NamedNodeMap" or $interfaceName =~ /^HTML\w*Collection$/) {
-        push(@getOwnPropertySlotImpl, "    ${namespaceMaybe}JSValue proto = thisObject->prototype();\n");
-        push(@getOwnPropertySlotImpl, "    if (proto.isObject() && jsCast<${namespaceMaybe}JSObject*>(proto)->hasProperty(exec, propertyName))\n");
-        push(@getOwnPropertySlotImpl, "        return false;\n\n");
-    }
+    my $hasNamedGetter = $namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"};
+    if ($hasNamedGetter) {
+        if (!$interface->extendedAttributes->{"OverrideBuiltins"}) {
+            &$ownPropertyCheck();
+            &$prototypeCheck();
+        }
 
-    if ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"}) {
-        push(@getOwnPropertySlotImpl, "    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {\n");
+        # The first condition is to make sure we use the subclass' named getter instead of the base class one when possible.
+        push(@getOwnPropertySlotImpl, "    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {\n");
         push(@getOwnPropertySlotImpl, "        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);\n");
         push(@getOwnPropertySlotImpl, "        return true;\n");
         push(@getOwnPropertySlotImpl, "    }\n");
@@ -437,26 +444,17 @@ sub GenerateGetOwnPropertySlotBody
         }
     }
 
-    if ($interface->extendedAttributes->{"CustomNamedGetter"}) {
-        &$manualLookupGetterGeneration();
-    }
-
     if ($interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}) {
         push(@getOwnPropertySlotImpl, "    if (thisObject->getOwnPropertySlotDelegate(exec, propertyName, slot))\n");
         push(@getOwnPropertySlotImpl, "        return true;\n");
     }
 
-    if ($hasAttributes) {
-        # FIXME: We are supposed to check for own properties *before* calling the named getter.
-        if ($inlined) {
-            push(@getOwnPropertySlotImpl, "    return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, *info()->staticPropHashTable, thisObject, propertyName, slot);\n");
-        } else {
-            push(@getOwnPropertySlotImpl, "    return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, ${className}Table, thisObject, propertyName, slot);\n");
-        }
-    } else {
-        push(@getOwnPropertySlotImpl, "    return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);\n");
+    if (!$hasNamedGetter || $interface->extendedAttributes->{"OverrideBuiltins"}) {
+        &$ownPropertyCheck();
     }
 
+    push(@getOwnPropertySlotImpl, "    return false;\n");
+
     return @getOwnPropertySlotImpl;
 }
 
@@ -578,13 +576,12 @@ sub HasComplexGetOwnProperty
     my $namedGetterFunction = GetNamedGetterFunction($interface);
     my $indexedGetterFunction = GetIndexedGetterFunction($interface);
 
-    my $hasImpureNamedGetter = $namedGetterFunction
-        || $interface->extendedAttributes->{"CustomNamedGetter"};
+    my $hasNamedGetter = $namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"};
 
     my $hasComplexGetter = $indexedGetterFunction
         || $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}
         || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}
-        || $hasImpureNamedGetter;
+        || $hasNamedGetter;
 
     return 1 if $interface->extendedAttributes->{"CheckSecurity"};
     return 1 if IsDOMGlobalObject($interface);
@@ -730,13 +727,13 @@ sub InstanceOverridesGetOwnPropertySlot
     my $namedGetterFunction = GetNamedGetterFunction($interface);
     my $indexedGetterFunction = GetIndexedGetterFunction($interface);
 
-    my $hasImpureNamedGetter = $namedGetterFunction
+    my $hasNamedGetter = $namedGetterFunction
         || $interface->extendedAttributes->{"CustomNamedGetter"};
 
     my $hasComplexGetter = $indexedGetterFunction
         || $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}
         || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}
-        || $hasImpureNamedGetter;
+        || $hasNamedGetter;
 
     return $numInstanceAttributes > 0 || $hasComplexGetter;
 
@@ -915,14 +912,15 @@ sub GenerateHeader
     my $namedGetterFunction = GetNamedGetterFunction($interface);
     my $indexedGetterFunction = GetIndexedGetterFunction($interface);
 
-    my $hasImpureNamedGetter = $namedGetterFunction
-        || $interface->extendedAttributes->{"CustomNamedGetter"};
+    my $hasImpureNamedGetter = $interface->extendedAttributes->{"OverrideBuiltins"}
+        && ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"});
 
     my $hasComplexGetter =
         $indexedGetterFunction
         || $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}
         || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"}
-        || $hasImpureNamedGetter;
+        || $namedGetterFunction
+        || $interface->extendedAttributes->{"CustomNamedGetter"};
     
     my $hasGetter = InstanceOverridesGetOwnPropertySlot($interface);
 
@@ -2186,7 +2184,9 @@ sub GenerateImplementation
 
             if ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"}) {
                 &$propertyNameGeneration();
-                push(@implContent, "    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {\n");
+
+                # The first condition is to make sure we use the subclass' named getter instead of the base class one when possible.
+                push(@implContent, "    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {\n");
                 push(@implContent, "        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);\n");
                 push(@implContent, "        return true;\n");
                 push(@implContent, "    }\n");
index 0acc413..d331a7c 100644 (file)
@@ -99,6 +99,7 @@ ObjCPolymorphic
 ObjCProtocol
 ObjCUseDefaultView
 OperationsNotDeletable
+OverrideBuiltins
 PassContext
 RaisesException
 Reflect=*
diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.cpp
new file mode 100644 (file)
index 0000000..3d006bf
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ *  This file is part of the WebKit open source project.
+ *  This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitDOMTestOverrideBuiltins.h"
+
+#include "CSSImportRule.h"
+#include "DOMObjectCache.h"
+#include "Document.h"
+#include "ExceptionCode.h"
+#include "ExceptionCodeDescription.h"
+#include "JSMainThreadExecState.h"
+#include "WebKitDOMNodePrivate.h"
+#include "WebKitDOMPrivate.h"
+#include "WebKitDOMTestOverrideBuiltinsPrivate.h"
+#include "gobject/ConvertToUTF8String.h"
+#include <wtf/GetPtr.h>
+#include <wtf/RefPtr.h>
+
+#define WEBKIT_DOM_TEST_OVERRIDE_BUILTINS_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS, WebKitDOMTestOverrideBuiltinsPrivate)
+
+typedef struct _WebKitDOMTestOverrideBuiltinsPrivate {
+    RefPtr<WebCore::TestOverrideBuiltins> coreObject;
+} WebKitDOMTestOverrideBuiltinsPrivate;
+
+namespace WebKit {
+
+WebKitDOMTestOverrideBuiltins* kit(WebCore::TestOverrideBuiltins* obj)
+{
+    if (!obj)
+        return 0;
+
+    if (gpointer ret = DOMObjectCache::get(obj))
+        return WEBKIT_DOM_TEST_OVERRIDE_BUILTINS(ret);
+
+    return wrapTestOverrideBuiltins(obj);
+}
+
+WebCore::TestOverrideBuiltins* core(WebKitDOMTestOverrideBuiltins* request)
+{
+    return request ? static_cast<WebCore::TestOverrideBuiltins*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
+}
+
+WebKitDOMTestOverrideBuiltins* wrapTestOverrideBuiltins(WebCore::TestOverrideBuiltins* coreObject)
+{
+    ASSERT(coreObject);
+    return WEBKIT_DOM_TEST_OVERRIDE_BUILTINS(g_object_new(WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS, "core-object", coreObject, nullptr));
+}
+
+} // namespace WebKit
+
+G_DEFINE_TYPE(WebKitDOMTestOverrideBuiltins, webkit_dom_test_override_builtins, WEBKIT_DOM_TYPE_OBJECT)
+
+static void webkit_dom_test_override_builtins_finalize(GObject* object)
+{
+    WebKitDOMTestOverrideBuiltinsPrivate* priv = WEBKIT_DOM_TEST_OVERRIDE_BUILTINS_GET_PRIVATE(object);
+
+    WebKit::DOMObjectCache::forget(priv->coreObject.get());
+
+    priv->~WebKitDOMTestOverrideBuiltinsPrivate();
+    G_OBJECT_CLASS(webkit_dom_test_override_builtins_parent_class)->finalize(object);
+}
+
+static GObject* webkit_dom_test_override_builtins_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties)
+{
+    GObject* object = G_OBJECT_CLASS(webkit_dom_test_override_builtins_parent_class)->constructor(type, constructPropertiesCount, constructProperties);
+
+    WebKitDOMTestOverrideBuiltinsPrivate* priv = WEBKIT_DOM_TEST_OVERRIDE_BUILTINS_GET_PRIVATE(object);
+    priv->coreObject = static_cast<WebCore::TestOverrideBuiltins*>(WEBKIT_DOM_OBJECT(object)->coreObject);
+    WebKit::DOMObjectCache::put(priv->coreObject.get(), object);
+
+    return object;
+}
+
+static void webkit_dom_test_override_builtins_class_init(WebKitDOMTestOverrideBuiltinsClass* requestClass)
+{
+    GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
+    g_type_class_add_private(gobjectClass, sizeof(WebKitDOMTestOverrideBuiltinsPrivate));
+    gobjectClass->constructor = webkit_dom_test_override_builtins_constructor;
+    gobjectClass->finalize = webkit_dom_test_override_builtins_finalize;
+}
+
+static void webkit_dom_test_override_builtins_init(WebKitDOMTestOverrideBuiltins* request)
+{
+    WebKitDOMTestOverrideBuiltinsPrivate* priv = WEBKIT_DOM_TEST_OVERRIDE_BUILTINS_GET_PRIVATE(request);
+    new (priv) WebKitDOMTestOverrideBuiltinsPrivate();
+}
+
+WebKitDOMNode* webkit_dom_test_override_builtins_named_item(WebKitDOMTestOverrideBuiltins* self, const gchar* name)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OVERRIDE_BUILTINS(self), 0);
+    g_return_val_if_fail(name, 0);
+    WebCore::TestOverrideBuiltins* item = WebKit::core(self);
+    WTF::String convertedName = WTF::String::fromUTF8(name);
+    RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->namedItem(convertedName));
+    return WebKit::kit(gobjectResult.get());
+}
+
diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.h
new file mode 100644 (file)
index 0000000..a6954b4
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  This file is part of the WebKit open source project.
+ *  This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitDOMTestOverrideBuiltins_h
+#define WebKitDOMTestOverrideBuiltins_h
+
+#ifdef WEBKIT_DOM_USE_UNSTABLE_API
+
+#include <glib-object.h>
+#include <webkitdom/WebKitDOMObject.h>
+#include <webkitdom/webkitdomdefines-unstable.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS            (webkit_dom_test_override_builtins_get_type())
+#define WEBKIT_DOM_TEST_OVERRIDE_BUILTINS(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS, WebKitDOMTestOverrideBuiltins))
+#define WEBKIT_DOM_TEST_OVERRIDE_BUILTINS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS, WebKitDOMTestOverrideBuiltinsClass)
+#define WEBKIT_DOM_IS_TEST_OVERRIDE_BUILTINS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS))
+#define WEBKIT_DOM_IS_TEST_OVERRIDE_BUILTINS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS))
+#define WEBKIT_DOM_TEST_OVERRIDE_BUILTINS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_DOM_TYPE_TEST_OVERRIDE_BUILTINS, WebKitDOMTestOverrideBuiltinsClass))
+
+struct _WebKitDOMTestOverrideBuiltins {
+    WebKitDOMObject parent_instance;
+};
+
+struct _WebKitDOMTestOverrideBuiltinsClass {
+    WebKitDOMObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_dom_test_override_builtins_get_type(void);
+
+/**
+ * webkit_dom_test_override_builtins_named_item:
+ * @self: A #WebKitDOMTestOverrideBuiltins
+ * @name: A #gchar
+ *
+ * Returns: (transfer none): A #WebKitDOMNode
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API WebKitDOMNode*
+webkit_dom_test_override_builtins_named_item(WebKitDOMTestOverrideBuiltins* self, const gchar* name);
+
+G_END_DECLS
+
+#endif /* WEBKIT_DOM_USE_UNSTABLE_API */
+#endif /* WebKitDOMTestOverrideBuiltins_h */
diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltinsPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltinsPrivate.h
new file mode 100644 (file)
index 0000000..e35ca52
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  This file is part of the WebKit open source project.
+ *  This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitDOMTestOverrideBuiltinsPrivate_h
+#define WebKitDOMTestOverrideBuiltinsPrivate_h
+
+#include "TestOverrideBuiltins.h"
+#include <webkitdom/WebKitDOMTestOverrideBuiltins.h>
+
+namespace WebKit {
+WebKitDOMTestOverrideBuiltins* wrapTestOverrideBuiltins(WebCore::TestOverrideBuiltins*);
+WebKitDOMTestOverrideBuiltins* kit(WebCore::TestOverrideBuiltins*);
+WebCore::TestOverrideBuiltins* core(WebKitDOMTestOverrideBuiltins*);
+} // namespace WebKit
+
+#endif /* WebKitDOMTestOverrideBuiltinsPrivate_h */
index 752acb7..65edc52 100644 (file)
@@ -170,7 +170,9 @@ bool JSTestActiveDOMObject::getOwnPropertySlot(JSObject* object, ExecState* exec
 {
     auto* thisObject = jsCast<JSTestActiveDOMObject*>(object);
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    return getStaticValueSlot<JSTestActiveDOMObject, Base>(exec, JSTestActiveDOMObjectTable, thisObject, propertyName, slot);
+    if (getStaticValueSlot<JSTestActiveDOMObject, Base>(exec, JSTestActiveDOMObjectTable, thisObject, propertyName, slot))
+        return true;
+    return false;
 }
 
 EncodedJSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
index dc2e600..b8b5a4c 100644 (file)
@@ -164,11 +164,17 @@ bool JSTestCustomNamedGetter::getOwnPropertySlot(JSObject* object, ExecState* ex
 {
     auto* thisObject = jsCast<JSTestCustomNamedGetter*>(object);
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
+    if (getStaticValueSlot<JSTestCustomNamedGetter, Base>(exec, JSTestCustomNamedGetterTable, thisObject, propertyName, slot))
+        return true;
+    JSValue proto = thisObject->prototype();
+    if (proto.isObject() && jsCast<JSObject*>(proto)->hasProperty(exec, propertyName))
+        return false;
+
+    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
         return true;
     }
-    return getStaticValueSlot<JSTestCustomNamedGetter, Base>(exec, JSTestCustomNamedGetterTable, thisObject, propertyName, slot);
+    return false;
 }
 
 bool JSTestCustomNamedGetter::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot)
@@ -176,7 +182,7 @@ bool JSTestCustomNamedGetter::getOwnPropertySlotByIndex(JSObject* object, ExecSt
     auto* thisObject = jsCast<JSTestCustomNamedGetter*>(object);
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
     Identifier propertyName = Identifier::from(exec, index);
-    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
+    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
         return true;
     }
index b87af21..e641572 100644 (file)
@@ -59,7 +59,7 @@ public:
 private:
     TestCustomNamedGetter* m_impl;
 public:
-    static const unsigned StructureFlags = JSC::HasImpureGetOwnPropertySlot | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
+    static const unsigned StructureFlags = JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
 protected:
     JSTestCustomNamedGetter(JSC::Structure*, JSDOMGlobalObject*, Ref<TestCustomNamedGetter>&&);
 
index 51cce17..3332a07 100644 (file)
@@ -183,16 +183,17 @@ bool JSTestEventTarget::getOwnPropertySlot(JSObject* object, ExecState* exec, Pr
         slot.setValue(thisObject, attributes, toJS(exec, thisObject->globalObject(), thisObject->impl().item(index)));
         return true;
     }
-    const HashTableValue* entry = getStaticValueSlotEntryWithoutCaching<JSTestEventTarget>(exec, propertyName);
-    if (entry) {
-        slot.setCacheableCustom(thisObject, entry->attributes(), entry->propertyGetter());
+    if (getStaticValueSlot<JSTestEventTarget, Base>(exec, JSTestEventTargetTable, thisObject, propertyName, slot))
         return true;
-    }
-    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
+    JSValue proto = thisObject->prototype();
+    if (proto.isObject() && jsCast<JSObject*>(proto)->hasProperty(exec, propertyName))
+        return false;
+
+    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
         return true;
     }
-    return getStaticValueSlot<JSTestEventTarget, Base>(exec, JSTestEventTargetTable, thisObject, propertyName, slot);
+    return false;
 }
 
 bool JSTestEventTarget::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot)
@@ -205,7 +206,7 @@ bool JSTestEventTarget::getOwnPropertySlotByIndex(JSObject* object, ExecState* e
         return true;
     }
     Identifier propertyName = Identifier::from(exec, index);
-    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
+    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
         return true;
     }
index 072463a..492b77d 100644 (file)
@@ -63,7 +63,7 @@ public:
 private:
     TestEventTarget* m_impl;
 public:
-    static const unsigned StructureFlags = JSC::HasImpureGetOwnPropertySlot | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::MasqueradesAsUndefined | JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | Base::StructureFlags;
+    static const unsigned StructureFlags = JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::MasqueradesAsUndefined | JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | Base::StructureFlags;
 protected:
     JSTestEventTarget(JSC::Structure*, JSDOMGlobalObject*, Ref<TestEventTarget>&&);
 
index fe80698..bd1f8e4 100644 (file)
@@ -160,7 +160,9 @@ bool JSTestException::getOwnPropertySlot(JSObject* object, ExecState* exec, Prop
 {
     auto* thisObject = jsCast<JSTestException*>(object);
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    return getStaticValueSlot<JSTestException, Base>(exec, JSTestExceptionTable, thisObject, propertyName, slot);
+    if (getStaticValueSlot<JSTestException, Base>(exec, JSTestExceptionTable, thisObject, propertyName, slot))
+        return true;
+    return false;
 }
 
 EncodedJSValue jsTestExceptionName(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
index 3f2deeb..b913bad 100644 (file)
@@ -441,7 +441,9 @@ bool JSTestInterface::getOwnPropertySlot(JSObject* object, ExecState* exec, Prop
 {
     auto* thisObject = jsCast<JSTestInterface*>(object);
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    return getStaticValueSlot<JSTestInterface, Base>(exec, JSTestInterfaceTable, thisObject, propertyName, slot);
+    if (getStaticValueSlot<JSTestInterface, Base>(exec, JSTestInterfaceTable, thisObject, propertyName, slot))
+        return true;
+    return false;
 }
 
 #if ENABLE(Condition22) || ENABLE(Condition23)
index ce02154..a7ec273 100644 (file)
@@ -703,7 +703,9 @@ bool JSTestObj::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyNa
 {
     auto* thisObject = jsCast<JSTestObj*>(object);
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    return getStaticValueSlot<JSTestObj, Base>(exec, JSTestObjTable, thisObject, propertyName, slot);
+    if (getStaticValueSlot<JSTestObj, Base>(exec, JSTestObjTable, thisObject, propertyName, slot))
+        return true;
+    return false;
 }
 
 EncodedJSValue jsTestObjReadOnlyLongAttr(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp
new file mode 100644 (file)
index 0000000..306db28
--- /dev/null
@@ -0,0 +1,275 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSTestOverrideBuiltins.h"
+
+#include "ExceptionCode.h"
+#include "JSDOMBinding.h"
+#include "JSNode.h"
+#include "Node.h"
+#include "TestOverrideBuiltins.h"
+#include "wtf/text/AtomicString.h"
+#include <runtime/Error.h>
+#include <wtf/GetPtr.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+// Functions
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestOverrideBuiltinsPrototypeFunctionNamedItem(JSC::ExecState*);
+
+// Attributes
+
+JSC::EncodedJSValue jsTestOverrideBuiltinsConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
+
+class JSTestOverrideBuiltinsPrototype : public JSC::JSNonFinalObject {
+public:
+    typedef JSC::JSNonFinalObject Base;
+    static JSTestOverrideBuiltinsPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        JSTestOverrideBuiltinsPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestOverrideBuiltinsPrototype>(vm.heap)) JSTestOverrideBuiltinsPrototype(vm, globalObject, structure);
+        ptr->finishCreation(vm);
+        return ptr;
+    }
+
+    DECLARE_INFO;
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+private:
+    JSTestOverrideBuiltinsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+        : JSC::JSNonFinalObject(vm, structure)
+    {
+    }
+
+    void finishCreation(JSC::VM&);
+};
+
+class JSTestOverrideBuiltinsConstructor : public DOMConstructorObject {
+private:
+    JSTestOverrideBuiltinsConstructor(JSC::Structure*, JSDOMGlobalObject*);
+    void finishCreation(JSC::VM&, JSDOMGlobalObject*);
+
+public:
+    typedef DOMConstructorObject Base;
+    static JSTestOverrideBuiltinsConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+    {
+        JSTestOverrideBuiltinsConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestOverrideBuiltinsConstructor>(vm.heap)) JSTestOverrideBuiltinsConstructor(structure, globalObject);
+        ptr->finishCreation(vm, globalObject);
+        return ptr;
+    }
+
+    DECLARE_INFO;
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+};
+
+/* Hash table */
+
+static const struct CompactHashIndex JSTestOverrideBuiltinsTableIndex[2] = {
+    { -1, -1 },
+    { 0, -1 },
+};
+
+
+static const HashTableValue JSTestOverrideBuiltinsTableValues[] =
+{
+    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestOverrideBuiltinsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
+};
+
+static const HashTable JSTestOverrideBuiltinsTable = { 1, 1, true, JSTestOverrideBuiltinsTableValues, 0, JSTestOverrideBuiltinsTableIndex };
+const ClassInfo JSTestOverrideBuiltinsConstructor::s_info = { "TestOverrideBuiltinsConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverrideBuiltinsConstructor) };
+
+JSTestOverrideBuiltinsConstructor::JSTestOverrideBuiltinsConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
+    : DOMConstructorObject(structure, globalObject)
+{
+}
+
+void JSTestOverrideBuiltinsConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(info()));
+    putDirect(vm, vm.propertyNames->prototype, JSTestOverrideBuiltins::getPrototype(vm, globalObject), DontDelete | ReadOnly | DontEnum);
+    putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestOverrideBuiltins"))), ReadOnly | DontEnum);
+    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSTestOverrideBuiltinsPrototypeTableValues[] =
+{
+    { "namedItem", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestOverrideBuiltinsPrototypeFunctionNamedItem), (intptr_t) (0) },
+};
+
+const ClassInfo JSTestOverrideBuiltinsPrototype::s_info = { "TestOverrideBuiltinsPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverrideBuiltinsPrototype) };
+
+void JSTestOverrideBuiltinsPrototype::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    reifyStaticProperties(vm, JSTestOverrideBuiltinsPrototypeTableValues, *this);
+}
+
+const ClassInfo JSTestOverrideBuiltins::s_info = { "TestOverrideBuiltins", &Base::s_info, &JSTestOverrideBuiltinsTable, CREATE_METHOD_TABLE(JSTestOverrideBuiltins) };
+
+JSTestOverrideBuiltins::JSTestOverrideBuiltins(Structure* structure, JSDOMGlobalObject* globalObject, Ref<TestOverrideBuiltins>&& impl)
+    : JSDOMWrapper(structure, globalObject)
+    , m_impl(&impl.leakRef())
+{
+}
+
+JSObject* JSTestOverrideBuiltins::createPrototype(VM& vm, JSGlobalObject* globalObject)
+{
+    return JSTestOverrideBuiltinsPrototype::create(vm, globalObject, JSTestOverrideBuiltinsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+JSObject* JSTestOverrideBuiltins::getPrototype(VM& vm, JSGlobalObject* globalObject)
+{
+    return getDOMPrototype<JSTestOverrideBuiltins>(vm, globalObject);
+}
+
+void JSTestOverrideBuiltins::destroy(JSC::JSCell* cell)
+{
+    JSTestOverrideBuiltins* thisObject = static_cast<JSTestOverrideBuiltins*>(cell);
+    thisObject->JSTestOverrideBuiltins::~JSTestOverrideBuiltins();
+}
+
+JSTestOverrideBuiltins::~JSTestOverrideBuiltins()
+{
+    releaseImpl();
+}
+
+bool JSTestOverrideBuiltins::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+{
+    auto* thisObject = jsCast<JSTestOverrideBuiltins*>(object);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
+        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
+        return true;
+    }
+    if (getStaticValueSlot<JSTestOverrideBuiltins, Base>(exec, JSTestOverrideBuiltinsTable, thisObject, propertyName, slot))
+        return true;
+    return false;
+}
+
+bool JSTestOverrideBuiltins::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot)
+{
+    auto* thisObject = jsCast<JSTestOverrideBuiltins*>(object);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+    Identifier propertyName = Identifier::from(exec, index);
+    if (thisObject->classInfo() == info() && canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
+        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
+        return true;
+    }
+    return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
+}
+
+EncodedJSValue jsTestOverrideBuiltinsConstructor(ExecState* exec, JSObject*, EncodedJSValue thisValue, PropertyName)
+{
+    JSTestOverrideBuiltins* domObject = jsDynamicCast<JSTestOverrideBuiltins*>(JSValue::decode(thisValue));
+    if (!domObject)
+        return throwVMTypeError(exec);
+    return JSValue::encode(JSTestOverrideBuiltins::getConstructor(exec->vm(), domObject->globalObject()));
+}
+
+JSValue JSTestOverrideBuiltins::getConstructor(VM& vm, JSGlobalObject* globalObject)
+{
+    return getDOMConstructor<JSTestOverrideBuiltinsConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestOverrideBuiltinsPrototypeFunctionNamedItem(ExecState* exec)
+{
+    JSValue thisValue = exec->thisValue();
+    JSTestOverrideBuiltins* castedThis = jsDynamicCast<JSTestOverrideBuiltins*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, "TestOverrideBuiltins", "namedItem");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestOverrideBuiltins::info());
+    auto& impl = castedThis->impl();
+    String name = exec->argument(0).toString(exec)->value(exec);
+    if (UNLIKELY(exec->hadException()))
+        return JSValue::encode(jsUndefined());
+    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.namedItem(name)));
+    return JSValue::encode(result);
+}
+
+bool JSTestOverrideBuiltinsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
+{
+    UNUSED_PARAM(handle);
+    UNUSED_PARAM(visitor);
+    return false;
+}
+
+void JSTestOverrideBuiltinsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+    auto* jsTestOverrideBuiltins = jsCast<JSTestOverrideBuiltins*>(handle.slot()->asCell());
+    auto& world = *static_cast<DOMWrapperWorld*>(context);
+    uncacheWrapper(world, &jsTestOverrideBuiltins->impl(), jsTestOverrideBuiltins);
+}
+
+#if ENABLE(BINDING_INTEGRITY)
+#if PLATFORM(WIN)
+#pragma warning(disable: 4483)
+extern "C" { extern void (*const __identifier("??_7TestOverrideBuiltins@WebCore@@6B@")[])(); }
+#else
+extern "C" { extern void* _ZTVN7WebCore20TestOverrideBuiltinsE[]; }
+#endif
+#endif
+JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestOverrideBuiltins* impl)
+{
+    if (!impl)
+        return jsNull();
+    if (JSValue result = getExistingWrapper<JSTestOverrideBuiltins>(globalObject, impl))
+        return result;
+
+#if ENABLE(BINDING_INTEGRITY)
+    void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
+#if PLATFORM(WIN)
+    void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestOverrideBuiltins@WebCore@@6B@"));
+#else
+    void* expectedVTablePointer = &_ZTVN7WebCore20TestOverrideBuiltinsE[2];
+#if COMPILER(CLANG)
+    // If this fails TestOverrideBuiltins does not have a vtable, so you need to add the
+    // ImplementationLacksVTable attribute to the interface definition
+    COMPILE_ASSERT(__is_polymorphic(TestOverrideBuiltins), TestOverrideBuiltins_is_not_polymorphic);
+#endif
+#endif
+    // If you hit this assertion you either have a use after free bug, or
+    // TestOverrideBuiltins has subclasses. If TestOverrideBuiltins has subclasses that get passed
+    // to toJS() we currently require TestOverrideBuiltins you to opt out of binding hardening
+    // by adding the SkipVTableValidation attribute to the interface IDL definition
+    RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
+#endif
+    return createNewWrapper<JSTestOverrideBuiltins>(globalObject, impl);
+}
+
+TestOverrideBuiltins* JSTestOverrideBuiltins::toWrapped(JSC::JSValue value)
+{
+    if (auto* wrapper = jsDynamicCast<JSTestOverrideBuiltins*>(value))
+        return &wrapper->impl();
+    return nullptr;
+}
+
+}
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.h b/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.h
new file mode 100644 (file)
index 0000000..7cc8f0b
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef JSTestOverrideBuiltins_h
+#define JSTestOverrideBuiltins_h
+
+#include "JSDOMWrapper.h"
+#include "TestOverrideBuiltins.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSTestOverrideBuiltins : public JSDOMWrapper {
+public:
+    typedef JSDOMWrapper Base;
+    static JSTestOverrideBuiltins* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<TestOverrideBuiltins>&& impl)
+    {
+        JSTestOverrideBuiltins* ptr = new (NotNull, JSC::allocateCell<JSTestOverrideBuiltins>(globalObject->vm().heap)) JSTestOverrideBuiltins(structure, globalObject, WTF::move(impl));
+        ptr->finishCreation(globalObject->vm());
+        return ptr;
+    }
+
+    static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*);
+    static JSC::JSObject* getPrototype(JSC::VM&, JSC::JSGlobalObject*);
+    static TestOverrideBuiltins* toWrapped(JSC::JSValue);
+    static bool getOwnPropertySlot(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);
+    static bool getOwnPropertySlotByIndex(JSC::JSObject*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&);
+    static void destroy(JSC::JSCell*);
+    ~JSTestOverrideBuiltins();
+
+    DECLARE_INFO;
+
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+    static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
+    TestOverrideBuiltins& impl() const { return *m_impl; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
+
+private:
+    TestOverrideBuiltins* m_impl;
+public:
+    static const unsigned StructureFlags = JSC::HasImpureGetOwnPropertySlot | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
+protected:
+    JSTestOverrideBuiltins(JSC::Structure*, JSDOMGlobalObject*, Ref<TestOverrideBuiltins>&&);
+
+    void finishCreation(JSC::VM& vm)
+    {
+        Base::finishCreation(vm);
+        ASSERT(inherits(info()));
+    }
+
+private:
+    static bool canGetItemsForName(JSC::ExecState*, TestOverrideBuiltins*, JSC::PropertyName);
+    static JSC::EncodedJSValue nameGetter(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
+};
+
+class JSTestOverrideBuiltinsOwner : public JSC::WeakHandleOwner {
+public:
+    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&);
+    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
+};
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, TestOverrideBuiltins*)
+{
+    static NeverDestroyed<JSTestOverrideBuiltinsOwner> owner;
+    return &owner.get();
+}
+
+JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestOverrideBuiltins*);
+inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestOverrideBuiltins& impl) { return toJS(exec, globalObject, &impl); }
+
+
+} // namespace WebCore
+
+#endif
index be1ebf7..43a87cd 100644 (file)
@@ -245,7 +245,9 @@ bool JSTestTypedefs::getOwnPropertySlot(JSObject* object, ExecState* exec, Prope
 {
     auto* thisObject = jsCast<JSTestTypedefs*>(object);
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    return getStaticValueSlot<JSTestTypedefs, Base>(exec, JSTestTypedefsTable, thisObject, propertyName, slot);
+    if (getStaticValueSlot<JSTestTypedefs, Base>(exec, JSTestTypedefsTable, thisObject, propertyName, slot))
+        return true;
+    return false;
 }
 
 EncodedJSValue jsTestTypedefsUnsignedLongLongAttr(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.h
new file mode 100644 (file)
index 0000000..4b7a179
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import <WebCore/DOMObject.h>
+
+@class DOMNode;
+@class NSString;
+
+WEBKIT_CLASS_AVAILABLE_MAC(9876_5)
+WEBCORE_EXPORT @interface DOMTestOverrideBuiltins : DOMObject
+- (DOMNode *)namedItem:(NSString *)name;
+@end
diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.mm
new file mode 100644 (file)
index 0000000..73d6f06
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the WebKit open source project.
+ * This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "DOMInternal.h"
+
+#import "DOMTestOverrideBuiltins.h"
+
+#import "DOMNodeInternal.h"
+#import "DOMTestOverrideBuiltinsInternal.h"
+#import "ExceptionHandlers.h"
+#import "JSMainThreadExecState.h"
+#import "Node.h"
+#import "TestOverrideBuiltins.h"
+#import "ThreadCheck.h"
+#import "URL.h"
+#import "WebCoreObjCExtras.h"
+#import "WebScriptObjectPrivate.h"
+#import <wtf/GetPtr.h>
+
+#define IMPL reinterpret_cast<WebCore::TestOverrideBuiltins*>(_internal)
+
+@implementation DOMTestOverrideBuiltins
+
+- (void)dealloc
+{
+    if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestOverrideBuiltins class], self))
+        return;
+
+    if (_internal)
+        IMPL->deref();
+    [super dealloc];
+}
+
+- (void)finalize
+{
+    if (_internal)
+        IMPL->deref();
+    [super finalize];
+}
+
+- (DOMNode *)namedItem:(NSString *)name
+{
+    WebCore::JSMainThreadNullState state;
+    return kit(WTF::getPtr(IMPL->namedItem(name)));
+}
+
+@end
+
+WebCore::TestOverrideBuiltins* core(DOMTestOverrideBuiltins *wrapper)
+{
+    return wrapper ? reinterpret_cast<WebCore::TestOverrideBuiltins*>(wrapper->_internal) : 0;
+}
+
+DOMTestOverrideBuiltins *kit(WebCore::TestOverrideBuiltins* value)
+{
+    WebCoreThreadViolationCheckRoundOne();
+    if (!value)
+        return nil;
+    if (DOMTestOverrideBuiltins *wrapper = getDOMWrapper(value))
+        return [[wrapper retain] autorelease];
+    DOMTestOverrideBuiltins *wrapper = [[DOMTestOverrideBuiltins alloc] _init];
+    wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value);
+    value->ref();
+    addDOMWrapper(wrapper, value);
+    return [wrapper autorelease];
+}
diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltinsInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltinsInternal.h
new file mode 100644 (file)
index 0000000..8612b1b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the WebKit open source project.
+ * This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import <WebCore/DOMTestOverrideBuiltins.h>
+
+namespace WebCore {
+class TestOverrideBuiltins;
+}
+
+WEBCORE_EXPORT WebCore::TestOverrideBuiltins* core(DOMTestOverrideBuiltins *);
+WEBCORE_EXPORT DOMTestOverrideBuiltins *kit(WebCore::TestOverrideBuiltins*);
diff --git a/Source/WebCore/bindings/scripts/test/TestOverrideBuiltins.idl b/Source/WebCore/bindings/scripts/test/TestOverrideBuiltins.idl
new file mode 100644 (file)
index 0000000..68fd8da
--- /dev/null
@@ -0,0 +1,6 @@
+[
+    OverrideBuiltins
+] interface TestOverrideBuiltins
+{
+    getter Node namedItem([Default=Undefined] optional DOMString name);
+};
index 0e6b1af..3932ba9 100644 (file)
@@ -29,6 +29,7 @@
     CustomEnumerateProperty,
     CustomNamedSetter,
     JSCustomGetOwnPropertySlotAndDescriptor,
+    OverrideBuiltins,
     SkipVTableValidation,
 ] interface DOMStringMap {
 };
index fc31b1b..033de99 100644 (file)
@@ -20,8 +20,8 @@
 
 [
     CustomIsReachable,
+    CustomNamedGetter,
     CustomToJSObject,
-    JSCustomGetOwnPropertySlotAndDescriptor,
     JSCustomHeader,
     SkipVTableValidation,
     ReportExtraMemoryCost,
index a673acd..7758713 100644 (file)
@@ -22,6 +22,7 @@
     CustomGetOwnPropertySlot,
     CustomNamedGetter,
     NewImpurePropertyFiresWatchpoints,
+    OverrideBuiltins,
 ] interface HTMLDocument : Document {
     [Custom, ForwardDeclareInHeader] void open();
     void close();
index 2b7276d..25be713 100644 (file)
@@ -20,6 +20,7 @@
 
 [
     CustomNamedGetter,
+    OverrideBuiltins,
 ] interface HTMLFormElement : HTMLElement {
     [Reflect=accept_charset] attribute DOMString acceptCharset;
     [Reflect, URL] attribute DOMString action;
index 1dba443..25d3dd2 100644 (file)
@@ -26,7 +26,7 @@
     attribute long selectedIndex;
     [CustomSetter, SetterRaisesException] attribute unsigned long length;
 
-    Node namedItem([Default=Undefined] optional DOMString name);
+    getter Node namedItem([Default=Undefined] optional DOMString name);
 
 #if (!defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C) && (!defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT)
     [RaisesException] void add(HTMLElement element, [Default=Undefined] optional HTMLElement? before);