Changeset 28366 in webkit


Ignore:
Timestamp:
Dec 3, 2007, 2:07:43 PM (18 years ago)
Author:
mitz@apple.com
Message:

JavaScriptCore:

Reviewed by Darin Adler.

  • fix an ASSERT when getIntIdentifier is called with 0 or -1
  • bindings/npruntime.cpp: (_NPN_GetIntIdentifier): We cannot use the hashmap for 0 and -1 since they are the empty value and the deleted value. Instead, keep the identifiers for those two integers in a static array.

WebKitTools:

Reviewed by Darin Adler.

  • added a testGetIntIdentifier() method to TestNetscapePlugIn
  • DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c: (pluginInvoke):

LayoutTests:

Reviewed by Darin Adler.

  • added a test of the behavior of getIntIdentifier with the integers 0 and -1
  • plugins/getintidentifier-special-values-expected.txt: Added.
  • plugins/getintidentifier-special-values.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r28346 r28366  
     12007-12-03  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - fix an ASSERT when getIntIdentifier is called with 0 or -1
     6
     7        * bindings/npruntime.cpp:
     8        (_NPN_GetIntIdentifier): We cannot use the hashmap for 0 and -1 since
     9        they are the empty value and the deleted value. Instead, keep the
     10        identifiers for those two integers in a static array.
     11
    1122007-12-02  Darin Adler  <darin@apple.com>
    213
  • trunk/JavaScriptCore/bindings/npruntime.cpp

    r25000 r28366  
    9797NPIdentifier _NPN_GetIntIdentifier(int32_t intid)
    9898{
    99     PrivateIdentifier* identifier = 0;
    100    
    101     identifier = getIntIdentifierMap()->get(intid);
    102     if (identifier == 0) {
    103         identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
    104         // We never release identifier names, so this dictionary will grow.
    105         identifier->isString = false;
    106         identifier->value.number = intid;
    107 
    108         getIntIdentifierMap()->set(intid, identifier);
     99    PrivateIdentifier* identifier;
     100
     101    if (intid == 0 || intid == -1) {
     102        static PrivateIdentifier* negativeOneAndZeroIdentifiers[2];
     103
     104        identifier = negativeOneAndZeroIdentifiers[intid + 1];
     105        if (!identifier) {
     106            identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
     107            identifier->isString = false;
     108            identifier->isString = intid;
     109
     110            negativeOneAndZeroIdentifiers[intid + 1] = identifier;
     111        }
     112    } else {
     113        identifier = getIntIdentifierMap()->get(intid);
     114        if (!identifier) {
     115            identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
     116            // We never release identifier names, so this dictionary will grow.
     117            identifier->isString = false;
     118            identifier->value.number = intid;
     119
     120            getIntIdentifierMap()->set(intid, identifier);
     121        }
    109122    }
    110123    return (NPIdentifier)identifier;
  • trunk/LayoutTests/ChangeLog

    r28363 r28366  
     12007-12-03  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - added a test of the behavior of getIntIdentifier with the integers
     6          0 and -1
     7
     8        * plugins/getintidentifier-special-values-expected.txt: Added.
     9        * plugins/getintidentifier-special-values.html: Added.
     10
    1112007-12-03  Rob Buis  <buis@kde.org>
    212
  • trunk/WebKitTools/ChangeLog

    r28338 r28366  
     12007-12-03  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - added a testGetIntIdentifier() method to TestNetscapePlugIn
     6
     7        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
     8        (pluginInvoke):
     9
    1102007-12-03  Alexey Proskuryakov  <ap@webkit.org>
    211
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c

    r25128 r28366  
    9494#define ID_DESTROY_STREAM           6
    9595#define ID_TEST_ENUMERATE           7
    96 #define NUM_METHOD_IDENTIFIERS      8
     96#define ID_TEST_GETINTIDENTIFIER    8
     97#define NUM_METHOD_IDENTIFIERS      9
    9798
    9899static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
     
    105106    "testInvokeDefault",
    106107    "destroyStream",
    107     "testEnumerate"
     108    "testEnumerate",
     109    "testGetIntIdentifier"
    108110};
    109111
     
    283285                NPObject* outArray = NPVARIANT_TO_OBJECT(args[1]);
    284286                NPIdentifier pushIdentifier = browser->getstringidentifier("push");
    285                
     287
    286288                for (uint32_t i = 0; i < count; i++) {
    287289                    NPUTF8* string = browser->utf8fromidentifier(identifiers[i]);
     
    297299                    browser->memfree(string);
    298300                }
    299                
     301
    300302                browser->memfree(identifiers);
    301303            }
     
    308310        INT32_TO_NPVARIANT(npError, *result);
    309311        return true;       
    310     }
     312    } else if (name == pluginMethodIdentifiers[ID_TEST_GETINTIDENTIFIER]) {
     313        if (argCount == 1 && NPVARIANT_IS_DOUBLE(args[0])) {
     314            NPIdentifier identifier = browser->getintidentifier((int)NPVARIANT_TO_DOUBLE(args[0]));
     315            INT32_TO_NPVARIANT((int32)identifier, *result);
     316            return true;
     317        }
     318    }
    311319    return false;
    312320}
Note: See TracChangeset for help on using the changeset viewer.