Changeset 31225 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Mar 21, 2008, 7:36:34 PM (17 years ago)
Author:
[email protected]
Message:

Global properties that use LocalStorage are not correctly listed as enumerable.

Reviewed by Geoff Garen

The problem was caused by JSObject::getPropertyAttributes not being aware
of the JSVariableObject SymbolTable. The fix is to make getPropertyAttributes
virtual and override in JSVariableObject. This does not produce any performance
regression.

Location:
trunk/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r31216 r31225  
     12008-03-21  Oliver Hunt  <[email protected]>
     2
     3        Reviewed by Geoff Garen.
     4
     5        Global properties that use LocalStorage are not correctly listed as enumerable.
     6
     7        The problem was caused by JSObject::getPropertyAttributes not being aware
     8        of the JSVariableObject SymbolTable.  The fix is to make getPropertyAttributes
     9        virtual and override in JSVariableObject.  This does not produce any performance
     10        regression.
     11
     12        * JavaScriptCore.exp:
     13        * kjs/JSVariableObject.cpp:
     14        (KJS::JSVariableObject::getPropertyNames):
     15        (KJS::JSVariableObject::getPropertyAttributes):
     16        * kjs/JSVariableObject.h:
     17        * kjs/object.h:
     18
    1192008-03-21  Arkadiusz Miskiewicz  <[email protected]>
    220
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r31208 r31225  
    230230__ZNK3KJS16JSVariableObject16isVariableObjectEv
    231231__ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE
     232__ZNK3KJS16JSVariableObject21getPropertyAttributesERKNS_10IdentifierERj
    232233__ZNK3KJS19InternalFunctionImp14implementsCallEv
    233234__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv
     
    256257__ZNK3KJS8JSObject14implementsCallEv
    257258__ZNK3KJS8JSObject19implementsConstructEv
     259__ZNK3KJS8JSObject21getPropertyAttributesERKNS_10IdentifierERj
    258260__ZNK3KJS8JSObject21implementsHasInstanceEv
    259261__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
  • trunk/JavaScriptCore/kjs/JSVariableObject.cpp

    r31114 r31225  
    8585void JSVariableObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    8686{
    87     SymbolTable::const_iterator::Keys end = symbolTable().end().keys();
    88     for (SymbolTable::const_iterator::Keys it = symbolTable().begin().keys(); it != end; ++it)
    89         propertyNames.add(Identifier(it->get()));
     87    SymbolTable::const_iterator end = symbolTable().end();
     88    for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it)
     89        if ((localStorage()[it->second].attributes & DontEnum) == 0)
     90            propertyNames.add(Identifier(it->first.get()));
     91   
     92    JSObject::getPropertyNames(exec, propertyNames);
     93}
    9094
    91     JSObject::getPropertyNames(exec, propertyNames);
     95bool JSVariableObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const
     96{
     97    size_t index = symbolTable().get(propertyName.ustring().rep());
     98    if (index != missingSymbolMarker()) {
     99        attributes = localStorage()[index].attributes;
     100        return true;
     101    }
     102    return JSObject::getPropertyAttributes(propertyName, attributes);
    92103}
    93104
  • trunk/JavaScriptCore/kjs/JSVariableObject.h

    r31114 r31225  
    3838    class JSVariableObject : public JSObject {
    3939    public:
    40         SymbolTable& symbolTable() { return *d->symbolTable; }
    41         LocalStorage& localStorage() { return d->localStorage; }
     40        SymbolTable& symbolTable() const { return *d->symbolTable; }
     41        LocalStorage& localStorage() const { return d->localStorage; }
    4242       
    4343        void saveLocalStorage(SavedProperties&) const;
     
    5353        virtual bool isVariableObject() const;
    5454        virtual bool isDynamicScope() const = 0;
     55
     56        virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
    5557
    5658    protected:
  • trunk/JavaScriptCore/kjs/object.h

    r31114 r31225  
    404404    virtual JSObject *toObject(ExecState *exec) const;
    405405   
    406     bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
     406    virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
    407407   
    408408    // WebCore uses this to make document.all and style.filter undetectable
Note: See TracChangeset for help on using the changeset viewer.