Changeset 30034 in webkit


Ignore:
Timestamp:
Feb 5, 2008 8:36:31 PM (16 years ago)
Author:
weinig@apple.com
Message:

JavaScriptCore:

Reviewed by Anders Carlsson.

Fix for http://bugs.webkit.org/show_bug.cgi?id=8080
NodeList (and other DOM lists) items are not enumeratable using for..in

WebCore:

Reviewed by Anders Carlsson.

Fix for http://bugs.webkit.org/show_bug.cgi?id=8080
NodeList (and other DOM lists) items are not enumeratable using for..in

  • Match Firefox when enumerating DOM interfaces with indexGetters (support for the array bracket, nodeList[0], notation) by including all the items in the list before the attributes and methods of the interface.

Test: fast/dom/domListEnumeration.html

  • ForwardingHeaders/kjs/PropertyNameArray.h: Added.
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::customGetPropertyNames): Use the new custom method model.
  • bindings/js/JSHistoryCustom.cpp: (WebCore::JSHistory::customGetPropertyNames): ditto.
  • bindings/scripts/CodeGeneratorJS.pm: Instead of just adding a declaration of getProperyNames and implementing the method in the Custom.cpp, move to a the model used by generated getOwnPropertySlot() and put() where the custom code is written in a separate customGetPropertyNames which returns a bool indicating whether to call up to the base class. This enables adding the list indexes to the PropertyNameArray for interfaces with indexGetters automatically.

LayoutTests:

Reviewed by Anders Carlsson.

Test for http://bugs.webkit.org/show_bug.cgi?id=8080
NodeList (and other DOM lists) items are not enumeratable using for..in

  • fast/dom/domListEnumeration-expected.txt: Added.
  • fast/dom/domListEnumeration.html: Added.
  • fast/dom/resources/domListEnumeration.js: Added.
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r30003 r30034  
     12008-02-05  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Fix for http://bugs.webkit.org/show_bug.cgi?id=8080
     6        NodeList (and other DOM lists) items are not enumeratable using for..in
     7
     8        * JavaScriptCore.exp:
     9
    1102008-02-05  Mark Rowe  <mrowe@apple.com>
    211
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r29943 r30034  
    181181__ZN3KJS7UString3Rep4nullE
    182182__ZN3KJS7UString3Rep7destroyEv
     183__ZN3KJS7UString4fromEj
    183184__ZN3KJS7UString6appendERKS0_
    184185__ZN3KJS7UStringC1EPKNS_5UCharEi
  • trunk/LayoutTests/ChangeLog

    r30033 r30034  
     12008-02-05  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Test for http://bugs.webkit.org/show_bug.cgi?id=8080
     6        NodeList (and other DOM lists) items are not enumeratable using for..in
     7
     8        * fast/dom/domListEnumeration-expected.txt: Added.
     9        * fast/dom/domListEnumeration.html: Added.
     10        * fast/dom/resources/domListEnumeration.js: Added.
     11
    1122008-02-05  Nikolas Zimmermann  <zimmermann@kde.org>
    213
  • trunk/WebCore/ChangeLog

    r30032 r30034  
     12008-02-05  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Fix for http://bugs.webkit.org/show_bug.cgi?id=8080
     6        NodeList (and other DOM lists) items are not enumeratable using for..in
     7
     8        - Match Firefox when enumerating DOM interfaces with indexGetters (support for
     9          the array bracket, nodeList[0], notation) by including all the items in the
     10          list before the attributes and methods of the interface.
     11
     12        Test: fast/dom/domListEnumeration.html
     13
     14        * ForwardingHeaders/kjs/PropertyNameArray.h: Added.
     15        * bindings/js/JSDOMWindowCustom.cpp:
     16        (WebCore::JSDOMWindow::customGetPropertyNames): Use the new custom method model.
     17        * bindings/js/JSHistoryCustom.cpp:
     18        (WebCore::JSHistory::customGetPropertyNames): ditto.
     19        * bindings/scripts/CodeGeneratorJS.pm: Instead of just adding a declaration of
     20        getProperyNames and implementing the method in the Custom.cpp, move to a the
     21        model used by generated getOwnPropertySlot() and put() where the custom code
     22        is written in a separate customGetPropertyNames which returns a bool indicating
     23        whether to call up to the base class.  This enables adding the list indexes
     24        to the PropertyNameArray for interfaces with indexGetters automatically.
     25
    1262008-02-05  Samuel Weinig  <sam@webkit.org>
    227
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r30032 r30034  
    126126}
    127127
    128 void JSDOMWindow::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     128bool JSDOMWindow::customGetPropertyNames(ExecState* exec, PropertyNameArray&)
    129129{
    130130    // Only allow the window to enumerated by frames in the same origin.
    131131    if (!allowsAccessFrom(exec))
    132         return;
    133     Base::getPropertyNames(exec, propertyNames);
     132        return true;
     133    return false;
    134134}
    135135
  • trunk/WebCore/bindings/js/JSHistoryCustom.cpp

    r30032 r30034  
    8585}
    8686
    87 void JSHistory::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     87bool JSHistory::customGetPropertyNames(ExecState* exec, PropertyNameArray&)
    8888{
    8989    // Only allow the history object to enumerated by frames in the same origin.
    9090    if (!allowsAccessFromFrame(exec, impl()->frame()))
    91         return;
    92     Base::getPropertyNames(exec, propertyNames);
     91        return true;
     92    return false;
    9393}
    9494
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r30032 r30034  
    370370
    371371    # Custom getPropertyNames function
    372     push(@headerContent, "    virtual void getPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);\n") if $dataNode->extendedAttributes->{"CustomGetPropertyNames"};
     372    push(@headerContent, "    virtual void getPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);\n") if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"});
     373    push(@headerContent, "    bool customGetPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);\n") if $dataNode->extendedAttributes->{"CustomGetPropertyNames"};
    373374
    374375    # Constructor object getter
     
    587588    push(@implContentHeader, "#include \"$className.h\"\n\n");
    588589    push(@implContentHeader, "#include <wtf/GetPtr.h>\n\n");
     590
     591    push(@implContentHeader, "#include <kjs/PropertyNameArray.h>\n") if $dataNode->extendedAttributes->{"HasIndexGetter"};
    589592
    590593    AddIncludesForType($interfaceName);
     
    10561059    }
    10571060
     1061    if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"}) {
     1062        push(@implContent, "void ${className}::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)\n");
     1063        push(@implContent, "{\n");
     1064        if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"}) {
     1065            push(@implContent, "    if (customGetPropertyNames(exec, propertyNames))\n");
     1066            push(@implContent, "        return;\n");
     1067        }
     1068        if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
     1069            push(@implContent, "    for (unsigned i = 0; i < static_cast<${implClassName}*>(impl())->length(); ++i)\n");
     1070            push(@implContent, "        propertyNames.add(Identifier::from(i));\n");
     1071        }
     1072        push(@implContent, "     Base::getPropertyNames(exec, propertyNames);\n");
     1073        push(@implContent, "}\n\n");
     1074    }
     1075
    10581076    if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
    10591077        push(@implContent, "JSValue* ${className}::getConstructor(ExecState* exec)\n{\n");
    10601078        push(@implContent, "    return KJS::cacheGlobalObject<${className}Constructor>(exec, \"[[${interfaceName}.constructor]]\");\n");
    1061         push(@implContent, "}\n");
     1079        push(@implContent, "}\n\n");
    10621080    }
    10631081
Note: See TracChangeset for help on using the changeset viewer.