Changeset 51501 in webkit


Ignore:
Timestamp:
Nov 30, 2009 10:59:36 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-30 Erik Arvidsson <arv@chromium.org>

Reviewed by Adam Barth.

Clean up V8 bindings for CSSStyleDeclaration and CSSVariableDeclaration
https://bugs.webkit.org/show_bug.cgi?id=31895

No new tests. This is already covered by:

fast/dom/CSSStyleDeclaration/css-computed-style-item.html
fast/dom/CSSStyleDeclaration/css-style-item.html

  • bindings/v8/V8Collection.h: (WebCore::collectionStringIndexedPropertyGetter): (WebCore::setCollectionStringIndexedGetter):
  • bindings/v8/V8DOMWrapper.cpp: (WebCore::V8DOMWrapper::getTemplate):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51498 r51501  
     12009-11-30  Erik Arvidsson  <arv@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Clean up V8 bindings for CSSStyleDeclaration and CSSVariableDeclaration
     6        https://bugs.webkit.org/show_bug.cgi?id=31895
     7
     8        No new tests. This is already covered by:
     9                fast/dom/CSSStyleDeclaration/css-computed-style-item.html
     10                fast/dom/CSSStyleDeclaration/css-style-item.html
     11
     12        * bindings/v8/V8Collection.h:
     13        (WebCore::collectionStringIndexedPropertyGetter):
     14        (WebCore::setCollectionStringIndexedGetter):
     15        * bindings/v8/V8DOMWrapper.cpp:
     16        (WebCore::V8DOMWrapper::getTemplate):
     17
    1182009-11-30  Steve Block  <steveblock@google.com>
    219
  • trunk/WebCore/bindings/v8/V8Collection.h

    r50253 r51501  
    178178
    179179
     180    // A template for indexed getters on collections of strings.
     181    template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
     182    {
     183        // FIXME: assert that object must be a collection type
     184        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
     185        V8ClassIndex::V8WrapperType wrapperType = V8DOMWrapper::domWrapperType(info.Holder());
     186        Collection* collection = V8DOMWrapper::convertToNativeObject<Collection>(wrapperType, info.Holder());
     187        String result = collection->item(index);
     188        return v8String(result);
     189    }
     190
     191
    180192    // Add indexed getter to the function template for a collection.
    181193    template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
     
    209221    }
    210222
     223
     224    // Add indexed getter returning a string to a function template for a collection.
     225    template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
     226    {
     227        desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
     228    }
     229
    211230    v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
    212231
  • trunk/WebCore/bindings/v8/V8DOMWrapper.cpp

    r51416 r51501  
    276276        // itself and not on the prototype object.
    277277        descriptor->InstanceTemplate()->SetNamedPropertyHandler( USE_NAMED_PROPERTY_GETTER(CSSStyleDeclaration), USE_NAMED_PROPERTY_SETTER(CSSStyleDeclaration));
    278         setCollectionStringOrNullIndexedGetter<CSSStyleDeclaration>(descriptor);
     278        setCollectionStringIndexedGetter<CSSStyleDeclaration>(descriptor);
    279279        break;
    280280    case V8ClassIndex::CSSRULELIST:
     
    285285        break;
    286286    case V8ClassIndex::CSSVARIABLESDECLARATION:
    287         setCollectionStringOrNullIndexedGetter<CSSVariablesDeclaration>(descriptor);
     287        setCollectionStringIndexedGetter<CSSVariablesDeclaration>(descriptor);
    288288        break;
    289289    case V8ClassIndex::WEBKITCSSTRANSFORMVALUE:
Note: See TracChangeset for help on using the changeset viewer.