Changeset 54278 in webkit


Ignore:
Timestamp:
Feb 3, 2010 5:02:13 AM (14 years ago)
Author:
hamaji@chromium.org
Message:

2010-02-03 Shinichiro Hamaji <hamaji@chromium.org>

Unreviewed revert of r54259 as it seems to break chromium's unit tests.
The tests pass with r54257 but fail with r54260.
As r54258 and r54260 don't touch code, I'm reverting this change.

[V8] Generate toV8 conversion helpers, a la JSC bindings.
https://bugs.webkit.org/show_bug.cgi?id=32563

  • bindings/v8/ScriptController.cpp: (WebCore::ScriptController::processingUserGesture): (WebCore::createScriptObject): (WebCore::ScriptController::createScriptObjectForPluginElement):
  • bindings/v8/ScriptObject.cpp: (WebCore::ScriptGlobalObject::set):
  • bindings/v8/V8AbstractEventListener.cpp: (WebCore::V8AbstractEventListener::handleEvent):
  • bindings/v8/V8Collection.h: (WebCore::getV8Object): (WebCore::toNativeCollection): (WebCore::getNamedPropertyOfCollection): (WebCore::collectionNamedPropertyGetter): (WebCore::getIndexedPropertyOfCollection): (WebCore::collectionIndexedPropertyGetter): (WebCore::nodeCollectionIndexedPropertyEnumerator): (WebCore::collectionIndexedPropertyEnumerator): (WebCore::collectionStringOrNullIndexedPropertyGetter): (WebCore::collectionStringIndexedPropertyGetter): (WebCore::setCollectionIndexedGetter): (WebCore::setCollectionNamedGetter): (WebCore::setCollectionStringOrNullIndexedGetter): (WebCore::setCollectionStringIndexedGetter):
  • bindings/v8/V8DOMWindowShell.cpp: (WebCore::V8DOMWindowShell::updateDocumentWrapperCache):
  • bindings/v8/V8DOMWrapper.cpp: (WebCore::downcastSVGPathSeg): (WebCore::V8DOMWrapper::convertSVGElementInstanceToV8Object): (WebCore::V8DOMWrapper::convertSVGObjectWithContextToV8Object): (WebCore::V8DOMWrapper::convertToV8Object): (WebCore::V8DOMWrapper::instantiateV8Object): (WebCore::V8DOMWrapper::isDOMEventWrapper): (WebCore::V8DOMWrapper::htmlElementType): (WebCore::V8DOMWrapper::svgElementType): (WebCore::V8DOMWrapper::convertEventToV8Object): (WebCore::): (WebCore::V8DOMWrapper::convertDocumentToV8Object): (WebCore::V8DOMWrapper::convertNodeToV8Object): (WebCore::V8DOMWrapper::convertNewNodeToV8Object): (WebCore::V8DOMWrapper::convertEventListenerToV8Object): (WebCore::V8DOMWrapper::convertDOMImplementationToV8Object): (WebCore::V8DOMWrapper::convertStyleSheetToV8Object): (WebCore::V8DOMWrapper::convertCSSValueToV8Object): (WebCore::V8DOMWrapper::convertCSSRuleToV8Object): (WebCore::V8DOMWrapper::convertWindowToV8Object): (WebCore::V8DOMWrapper::convertNamedNodeMapToV8Object):
  • bindings/v8/V8DOMWrapper.h: (WebCore::V8DOMWrapper::convertToV8Object): (WebCore::V8DOMWrapper::convertNodeToV8Object): (WebCore::V8DOMWrapper::convertNewNodeToV8Object): (WebCore::V8DOMWrapper::convertEventToV8Object): (WebCore::V8DOMWrapper::convertEventListenerToV8Object): (WebCore::V8DOMWrapper::instantiateV8Object):
  • bindings/v8/V8NodeFilterCondition.cpp: (WebCore::V8NodeFilterCondition::acceptNode):
  • bindings/v8/V8Proxy.cpp: (WebCore::V8Proxy::setDOMException):
  • bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp: (WebCore::toV8Object): (WebCore::V8CanvasRenderingContext2D::createPatternCallback):
  • bindings/v8/custom/V8CustomPositionCallback.cpp: (WebCore::V8CustomPositionCallback::handleEvent):
  • bindings/v8/custom/V8CustomPositionErrorCallback.cpp: (WebCore::V8CustomPositionErrorCallback::handleEvent):
  • bindings/v8/custom/V8CustomSQLStatementCallback.cpp: (WebCore::V8CustomSQLStatementCallback::handleEvent):
  • bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp: (WebCore::V8CustomSQLStatementErrorCallback::handleEvent):
  • bindings/v8/custom/V8CustomSQLTransactionCallback.cpp: (WebCore::V8CustomSQLTransactionCallback::handleEvent):
  • bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp: (WebCore::V8CustomSQLTransactionErrorCallback::handleEvent):
  • bindings/v8/custom/V8DOMWindowCustom.cpp: (WebCore::V8DOMWindow::openCallback): (WebCore::V8DOMWindow::indexedPropertyGetter): (WebCore::V8DOMWindow::namedPropertyGetter):
  • bindings/v8/custom/V8DataGridColumnListCustom.cpp: (WebCore::NAMED_PROPERTY_GETTER):
  • bindings/v8/custom/V8DocumentCustom.cpp: (WebCore::V8Document::evaluateCallback): (WebCore::V8Document::getCSSCanvasContextCallback): (WebCore::V8Document::implementationAccessorGetter):
  • bindings/v8/custom/V8DocumentLocationCustom.cpp: (WebCore::V8Document::locationAccessorGetter):
  • bindings/v8/custom/V8ElementCustom.cpp: (WebCore::V8Element::setAttributeNodeCallback): (WebCore::V8Element::setAttributeNodeNSCallback):
  • bindings/v8/custom/V8EventCustom.cpp: (WebCore::V8Event::dataTransferAccessorGetter): (WebCore::V8Event::clipboardDataAccessorGetter):
  • bindings/v8/custom/V8HTMLAllCollectionCustom.cpp: (WebCore::getNamedItems): (WebCore::getItem): (WebCore::V8HTMLAllCollection::callAsFunctionCallback):
  • bindings/v8/custom/V8HTMLAudioElementConstructor.cpp: (WebCore::V8Custom::v8HTMLAudioElementConstructorCallback):
  • bindings/v8/custom/V8HTMLCanvasElementCustom.cpp: (WebCore::V8HTMLCanvasElement::getContextCallback):
  • bindings/v8/custom/V8HTMLCollectionCustom.cpp: (WebCore::getNamedItems): (WebCore::getItem): (WebCore::V8HTMLCollection::callAsFunctionCallback):
  • bindings/v8/custom/V8HTMLDocumentCustom.cpp: (WebCore::V8HTMLDocument::namedPropertyGetter): (WebCore::V8HTMLDocument::allAccessorGetter):
  • bindings/v8/custom/V8HTMLFormElementCustom.cpp: (WebCore::V8HTMLFormElement::indexedPropertyGetter): (WebCore::V8HTMLFormElement::namedPropertyGetter):
  • bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp: (WebCore::V8HTMLFrameSetElement::namedPropertyGetter):
  • bindings/v8/custom/V8HTMLImageElementConstructor.cpp: (WebCore::V8Custom::v8HTMLImageElementConstructorCallback):
  • bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp: (WebCore::V8HTMLOptionsCollection::indexedPropertyGetter):
  • bindings/v8/custom/V8HTMLSelectElementCustom.cpp: (WebCore::V8HTMLSelectElement::namedPropertyGetter): (WebCore::V8HTMLSelectElement::indexedPropertyGetter):
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp: (WebCore::createInjectedScript): (WebCore::V8InjectedScriptHost::nodeForIdCallback): (WebCore::V8InjectedScriptHost::databaseForIdCallback):
  • bindings/v8/custom/V8MessageChannelConstructor.cpp: (WebCore::V8MessageChannel::constructorCallback):
  • bindings/v8/custom/V8MessageEventCustom.cpp: (WebCore::V8MessageEvent::portsAccessorGetter):
  • bindings/v8/custom/V8NamedNodeMapCustom.cpp: (WebCore::V8NamedNodeMap::indexedPropertyGetter): (WebCore::V8NamedNodeMap::namedPropertyGetter):
  • bindings/v8/custom/V8NodeIteratorCustom.cpp: (WebCore::toV8):
  • bindings/v8/custom/V8NodeListCustom.cpp: (WebCore::V8NodeList::namedPropertyGetter): (WebCore::V8NodeList::callAsFunctionCallback):
  • bindings/v8/custom/V8NotificationCenterCustom.cpp: (WebCore::V8NotificationCenter::createHTMLNotificationCallback): (WebCore::V8NotificationCenter::createNotificationCallback):
  • bindings/v8/custom/V8SVGMatrixCustom.cpp: (WebCore::V8SVGMatrix::multiplyCallback): (WebCore::V8SVGMatrix::inverseCallback): (WebCore::V8SVGMatrix::rotateFromVectorCallback):
  • bindings/v8/custom/V8StyleSheetListCustom.cpp: (WebCore::V8StyleSheetList::namedPropertyGetter):
  • bindings/v8/custom/V8TreeWalkerCustom.cpp: (WebCore::toV8Object):
  • bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: (WebCore::toV8Object):
  • bindings/v8/custom/V8XSLTProcessorCustom.cpp: (WebCore::V8XSLTProcessor::transformToFragmentCallback): (WebCore::V8XSLTProcessor::transformToDocumentCallback):
Location:
trunk/WebCore
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54277 r54278  
     12010-02-03  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Unreviewed revert of r54259 as it seems to break chromium's unit tests.
     4        The tests pass with r54257 but fail with r54260.
     5        As r54258 and r54260 don't touch code, I'm reverting this change.
     6
     7        [V8] Generate toV8 conversion helpers, a la JSC bindings.
     8        https://bugs.webkit.org/show_bug.cgi?id=32563
     9
     10        * bindings/v8/ScriptController.cpp:
     11        (WebCore::ScriptController::processingUserGesture):
     12        (WebCore::createScriptObject):
     13        (WebCore::ScriptController::createScriptObjectForPluginElement):
     14        * bindings/v8/ScriptObject.cpp:
     15        (WebCore::ScriptGlobalObject::set):
     16        * bindings/v8/V8AbstractEventListener.cpp:
     17        (WebCore::V8AbstractEventListener::handleEvent):
     18        * bindings/v8/V8Collection.h:
     19        (WebCore::getV8Object):
     20        (WebCore::toNativeCollection):
     21        (WebCore::getNamedPropertyOfCollection):
     22        (WebCore::collectionNamedPropertyGetter):
     23        (WebCore::getIndexedPropertyOfCollection):
     24        (WebCore::collectionIndexedPropertyGetter):
     25        (WebCore::nodeCollectionIndexedPropertyEnumerator):
     26        (WebCore::collectionIndexedPropertyEnumerator):
     27        (WebCore::collectionStringOrNullIndexedPropertyGetter):
     28        (WebCore::collectionStringIndexedPropertyGetter):
     29        (WebCore::setCollectionIndexedGetter):
     30        (WebCore::setCollectionNamedGetter):
     31        (WebCore::setCollectionStringOrNullIndexedGetter):
     32        (WebCore::setCollectionStringIndexedGetter):
     33        * bindings/v8/V8DOMWindowShell.cpp:
     34        (WebCore::V8DOMWindowShell::updateDocumentWrapperCache):
     35        * bindings/v8/V8DOMWrapper.cpp:
     36        (WebCore::downcastSVGPathSeg):
     37        (WebCore::V8DOMWrapper::convertSVGElementInstanceToV8Object):
     38        (WebCore::V8DOMWrapper::convertSVGObjectWithContextToV8Object):
     39        (WebCore::V8DOMWrapper::convertToV8Object):
     40        (WebCore::V8DOMWrapper::instantiateV8Object):
     41        (WebCore::V8DOMWrapper::isDOMEventWrapper):
     42        (WebCore::V8DOMWrapper::htmlElementType):
     43        (WebCore::V8DOMWrapper::svgElementType):
     44        (WebCore::V8DOMWrapper::convertEventToV8Object):
     45        (WebCore::):
     46        (WebCore::V8DOMWrapper::convertDocumentToV8Object):
     47        (WebCore::V8DOMWrapper::convertNodeToV8Object):
     48        (WebCore::V8DOMWrapper::convertNewNodeToV8Object):
     49        (WebCore::V8DOMWrapper::convertEventListenerToV8Object):
     50        (WebCore::V8DOMWrapper::convertDOMImplementationToV8Object):
     51        (WebCore::V8DOMWrapper::convertStyleSheetToV8Object):
     52        (WebCore::V8DOMWrapper::convertCSSValueToV8Object):
     53        (WebCore::V8DOMWrapper::convertCSSRuleToV8Object):
     54        (WebCore::V8DOMWrapper::convertWindowToV8Object):
     55        (WebCore::V8DOMWrapper::convertNamedNodeMapToV8Object):
     56        * bindings/v8/V8DOMWrapper.h:
     57        (WebCore::V8DOMWrapper::convertToV8Object):
     58        (WebCore::V8DOMWrapper::convertNodeToV8Object):
     59        (WebCore::V8DOMWrapper::convertNewNodeToV8Object):
     60        (WebCore::V8DOMWrapper::convertEventToV8Object):
     61        (WebCore::V8DOMWrapper::convertEventListenerToV8Object):
     62        (WebCore::V8DOMWrapper::instantiateV8Object):
     63        * bindings/v8/V8NodeFilterCondition.cpp:
     64        (WebCore::V8NodeFilterCondition::acceptNode):
     65        * bindings/v8/V8Proxy.cpp:
     66        (WebCore::V8Proxy::setDOMException):
     67        * bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp:
     68        (WebCore::toV8Object):
     69        (WebCore::V8CanvasRenderingContext2D::createPatternCallback):
     70        * bindings/v8/custom/V8CustomPositionCallback.cpp:
     71        (WebCore::V8CustomPositionCallback::handleEvent):
     72        * bindings/v8/custom/V8CustomPositionErrorCallback.cpp:
     73        (WebCore::V8CustomPositionErrorCallback::handleEvent):
     74        * bindings/v8/custom/V8CustomSQLStatementCallback.cpp:
     75        (WebCore::V8CustomSQLStatementCallback::handleEvent):
     76        * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:
     77        (WebCore::V8CustomSQLStatementErrorCallback::handleEvent):
     78        * bindings/v8/custom/V8CustomSQLTransactionCallback.cpp:
     79        (WebCore::V8CustomSQLTransactionCallback::handleEvent):
     80        * bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp:
     81        (WebCore::V8CustomSQLTransactionErrorCallback::handleEvent):
     82        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     83        (WebCore::V8DOMWindow::openCallback):
     84        (WebCore::V8DOMWindow::indexedPropertyGetter):
     85        (WebCore::V8DOMWindow::namedPropertyGetter):
     86        * bindings/v8/custom/V8DataGridColumnListCustom.cpp:
     87        (WebCore::NAMED_PROPERTY_GETTER):
     88        * bindings/v8/custom/V8DocumentCustom.cpp:
     89        (WebCore::V8Document::evaluateCallback):
     90        (WebCore::V8Document::getCSSCanvasContextCallback):
     91        (WebCore::V8Document::implementationAccessorGetter):
     92        * bindings/v8/custom/V8DocumentLocationCustom.cpp:
     93        (WebCore::V8Document::locationAccessorGetter):
     94        * bindings/v8/custom/V8ElementCustom.cpp:
     95        (WebCore::V8Element::setAttributeNodeCallback):
     96        (WebCore::V8Element::setAttributeNodeNSCallback):
     97        * bindings/v8/custom/V8EventCustom.cpp:
     98        (WebCore::V8Event::dataTransferAccessorGetter):
     99        (WebCore::V8Event::clipboardDataAccessorGetter):
     100        * bindings/v8/custom/V8HTMLAllCollectionCustom.cpp:
     101        (WebCore::getNamedItems):
     102        (WebCore::getItem):
     103        (WebCore::V8HTMLAllCollection::callAsFunctionCallback):
     104        * bindings/v8/custom/V8HTMLAudioElementConstructor.cpp:
     105        (WebCore::V8Custom::v8HTMLAudioElementConstructorCallback):
     106        * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
     107        (WebCore::V8HTMLCanvasElement::getContextCallback):
     108        * bindings/v8/custom/V8HTMLCollectionCustom.cpp:
     109        (WebCore::getNamedItems):
     110        (WebCore::getItem):
     111        (WebCore::V8HTMLCollection::callAsFunctionCallback):
     112        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
     113        (WebCore::V8HTMLDocument::namedPropertyGetter):
     114        (WebCore::V8HTMLDocument::allAccessorGetter):
     115        * bindings/v8/custom/V8HTMLFormElementCustom.cpp:
     116        (WebCore::V8HTMLFormElement::indexedPropertyGetter):
     117        (WebCore::V8HTMLFormElement::namedPropertyGetter):
     118        * bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp:
     119        (WebCore::V8HTMLFrameSetElement::namedPropertyGetter):
     120        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
     121        (WebCore::V8Custom::v8HTMLImageElementConstructorCallback):
     122        * bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
     123        (WebCore::V8HTMLOptionsCollection::indexedPropertyGetter):
     124        * bindings/v8/custom/V8HTMLSelectElementCustom.cpp:
     125        (WebCore::V8HTMLSelectElement::namedPropertyGetter):
     126        (WebCore::V8HTMLSelectElement::indexedPropertyGetter):
     127        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     128        (WebCore::createInjectedScript):
     129        (WebCore::V8InjectedScriptHost::nodeForIdCallback):
     130        (WebCore::V8InjectedScriptHost::databaseForIdCallback):
     131        * bindings/v8/custom/V8MessageChannelConstructor.cpp:
     132        (WebCore::V8MessageChannel::constructorCallback):
     133        * bindings/v8/custom/V8MessageEventCustom.cpp:
     134        (WebCore::V8MessageEvent::portsAccessorGetter):
     135        * bindings/v8/custom/V8NamedNodeMapCustom.cpp:
     136        (WebCore::V8NamedNodeMap::indexedPropertyGetter):
     137        (WebCore::V8NamedNodeMap::namedPropertyGetter):
     138        * bindings/v8/custom/V8NodeIteratorCustom.cpp:
     139        (WebCore::toV8):
     140        * bindings/v8/custom/V8NodeListCustom.cpp:
     141        (WebCore::V8NodeList::namedPropertyGetter):
     142        (WebCore::V8NodeList::callAsFunctionCallback):
     143        * bindings/v8/custom/V8NotificationCenterCustom.cpp:
     144        (WebCore::V8NotificationCenter::createHTMLNotificationCallback):
     145        (WebCore::V8NotificationCenter::createNotificationCallback):
     146        * bindings/v8/custom/V8SVGMatrixCustom.cpp:
     147        (WebCore::V8SVGMatrix::multiplyCallback):
     148        (WebCore::V8SVGMatrix::inverseCallback):
     149        (WebCore::V8SVGMatrix::rotateFromVectorCallback):
     150        * bindings/v8/custom/V8StyleSheetListCustom.cpp:
     151        (WebCore::V8StyleSheetList::namedPropertyGetter):
     152        * bindings/v8/custom/V8TreeWalkerCustom.cpp:
     153        (WebCore::toV8Object):
     154        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
     155        (WebCore::toV8Object):
     156        * bindings/v8/custom/V8XSLTProcessorCustom.cpp:
     157        (WebCore::V8XSLTProcessor::transformToFragmentCallback):
     158        (WebCore::V8XSLTProcessor::transformToDocumentCallback):
     159
    11602010-02-03  Mikhail Naganov  <mnaganov@chromium.org>
    2161
  • trunk/WebCore/bindings/v8/ScriptController.cpp

    r54259 r54278  
    5151#include "V8Binding.h"
    5252#include "V8BindingState.h"
    53 #include "V8DOMWindow.h"
    5453#include "V8Event.h"
    55 #include "V8HTMLEmbedElement.h"
    5654#include "V8IsolatedContext.h"
    5755#include "V8NPObject.h"
     
    172170    v8::Handle<v8::Object> global = v8Context->Global();
    173171    v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
    174     if (jsEvent.IsEmpty() || !jsEvent->IsObject())
    175         return false;
    176     Event* event = V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent));
     172    Event* event = V8DOMWrapper::isDOMEventWrapper(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
    177173
    178174    // Based on code from kjs_bindings.cpp.
     
    382378    v8::Context::Scope scope(v8Context);
    383379    DOMWindow* window = frame->domWindow();
    384     v8::Handle<v8::Value> global = toV8(window);
     380    v8::Handle<v8::Value> global = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, window);
    385381    ASSERT(global->IsObject());
    386382    return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), window);
     
    419415
    420416    DOMWindow* window = m_frame->domWindow();
    421     v8::Handle<v8::Value> v8plugin = toV8(static_cast<HTMLEmbedElement*>(plugin));
     417    v8::Handle<v8::Value> v8plugin = V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLEMBEDELEMENT, plugin);
    422418    if (!v8plugin->IsObject())
    423419        return createNoScriptObject();
  • trunk/WebCore/bindings/v8/ScriptObject.cpp

    r54259 r54278  
    3737#include "Document.h"
    3838#include "Frame.h"
     39#include "InspectorBackend.h"
     40#include "InspectorFrontendHost.h"
    3941#include "V8Binding.h"
    40 #include "V8InjectedScriptHost.h"
    41 #include "V8InspectorBackend.h"
    42 #include "V8InspectorFrontendHost.h"
    4342#include "V8Proxy.h"
    4443
     
    146145{
    147146    ScriptScope scope(scriptState);
    148     scope.global()->Set(v8::String::New(name), toV8(value));
     147    scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORBACKEND, value));
    149148    return scope.success();
    150149}
     
    153152{
    154153    ScriptScope scope(scriptState);
    155     scope.global()->Set(v8::String::New(name), toV8(value));
     154    scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORFRONTENDHOST, value));
    156155    return scope.success();
    157156}
     
    160159{
    161160    ScriptScope scope(scriptState);
    162     scope.global()->Set(v8::String::New(name), toV8(value));
     161    scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INJECTEDSCRIPTHOST, value));
    163162    return scope.success();
    164163}
  • trunk/WebCore/bindings/v8/V8AbstractEventListener.cpp

    r54259 r54278  
    3737#include "Frame.h"
    3838#include "V8Binding.h"
    39 #include "V8Event.h"
    4039#include "V8EventListenerList.h"
    4140#include "V8Proxy.h"
     
    8685
    8786    // Get the V8 wrapper for the event object.
    88     v8::Handle<v8::Value> jsEvent = toV8(event);
     87    v8::Handle<v8::Value> jsEvent = V8DOMWrapper::convertEventToV8Object(event);
    8988
    9089    invokeEventHandler(context, event, jsEvent);
  • trunk/WebCore/bindings/v8/V8Collection.h

    r54259 r54278  
    3939
    4040namespace WebCore {
    41 // FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param).
    42 // See https://bugs.webkit.org/show_bug.cgi?id=24664.
     41    // FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param).
     42    // See https://bugs.webkit.org/show_bug.cgi?id=24664.
    4343
    44 template<class T> static v8::Handle<v8::Value> getV8Object(T* implementation)
    45 {
    46     if (!implementation)
    47         return v8::Handle<v8::Value>();
    48     return toV8(implementation);
    49 }
     44    inline v8::Handle<v8::Value> getV8Object(void* implementation, v8::Local<v8::Value> implementationType)
     45    {
     46        if (!implementation)
     47            return v8::Handle<v8::Value>();
     48        V8ClassIndex::V8WrapperType type = V8ClassIndex::FromInt(implementationType->Int32Value());
     49        if (type == V8ClassIndex::NODE)
     50            return V8DOMWrapper::convertNodeToV8Object(static_cast<Node*>(implementation));
     51        return V8DOMWrapper::convertToV8Object(type, implementation);
     52    }
    5053
    51 template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object)
    52 {
    53     return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
    54 }
     54    template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object)
     55    {
     56        return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
     57    }
    5558
    56 template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation)
    57 {
    58     return getV8Object(implementation.get());
    59 }
     59    template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation, v8::Local<v8::Value> implementationType)
     60    {
     61        return getV8Object(implementation.get(), implementationType);
     62    }
    6063
    61 // Returns named property of a collection.
    62 template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object)
    63 {
    64     // FIXME: assert object is a collection type
    65     ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
    66     ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
    67     Collection* collection = toNativeCollection<Collection>(object);
    68     AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name);
    69     return getV8Object<ItemType>(collection->namedItem(propertyName));
    70 }
     64    // Returns named property of a collection.
     65    template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object,
     66                                                                                                         v8::Local<v8::Value> implementationType)
     67    {
     68        // FIXME: assert object is a collection type
     69        ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
     70        ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
     71        Collection* collection = toNativeCollection<Collection>(object);
     72        AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name);
     73        return getV8Object<ItemType>(collection->namedItem(propertyName), implementationType);
     74    }
    7175
    72 // A template of named property accessor of collections.
    73 template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
    74 {
    75     v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
     76    // A template of named property accessor of collections.
     77    template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
     78    {
     79        v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
    7680
    77     if (!value.IsEmpty())
    78         return value;
     81        if (!value.IsEmpty())
     82            return value;
    7983
    80     // Search local callback properties next to find IDL defined
    81     // properties.
    82     if (info.Holder()->HasRealNamedCallbackProperty(name))
    83         return notHandledByInterceptor();
    84     return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder());
    85 }
     84        // Search local callback properties next to find IDL defined
     85        // properties.
     86        if (info.Holder()->HasRealNamedCallbackProperty(name))
     87            return notHandledByInterceptor();
     88        return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder(), info.Data());
     89    }
    8690
    87 // Returns the property at the index of a collection.
    88 template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object)
    89 {
    90     // FIXME: Assert that object must be a collection type.
    91     ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
    92     ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
    93     Collection* collection = toNativeCollection<Collection>(object);
    94     return getV8Object<ItemType>(collection->item(index));
    95 }
     91    // Returns the property at the index of a collection.
     92    template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object,
     93                                                                                                           v8::Local<v8::Value> implementationType)
     94    {
     95        // FIXME: Assert that object must be a collection type.
     96        ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
     97        ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
     98        Collection* collection = toNativeCollection<Collection>(object);
     99        return getV8Object<ItemType>(collection->item(index), implementationType);
     100    }
    96101
    97 // A template of index interceptor of collections.
    98 template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
    99 {
    100     return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder());
    101 }
     102    // A template of index interceptor of collections.
     103    template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
     104    {
     105        return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder(), info.Data());
     106    }
    102107
    103 // Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement.
    104 template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
    105 {
    106     ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
    107     Collection* collection = toNativeCollection<Collection>(info.Holder());
    108     int length = collection->length();
    109     v8::Handle<v8::Array> properties = v8::Array::New(length);
    110     for (int i = 0; i < length; ++i) {
    111         // FIXME: Do we need to check that the item function returns a non-null value for this index?
    112         v8::Handle<v8::Integer> integer = v8::Integer::New(i);
    113         properties->Set(integer, integer);
     108    // Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement.
     109    template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
     110    {
     111        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
     112        Collection* collection = toNativeCollection<Collection>(info.Holder());
     113        int length = collection->length();
     114        v8::Handle<v8::Array> properties = v8::Array::New(length);
     115        for (int i = 0; i < length; ++i) {
     116            // FIXME: Do we need to check that the item function returns a non-null value for this index?
     117            v8::Handle<v8::Integer> integer = v8::Integer::New(i);
     118            properties->Set(integer, integer);
     119        }
     120        return properties;
    114121    }
    115     return properties;
    116 }
    117122
    118 // Get an array containing the names of indexed properties in a collection.
    119 template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
    120 {
    121     ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
    122     Collection* collection = toNativeCollection<Collection>(info.Holder());
    123     int length = collection->length();
    124     v8::Handle<v8::Array> properties = v8::Array::New(length);
    125     for (int i = 0; i < length; ++i) {
    126         // FIXME: Do we need to check that the item function returns a non-null value for this index?
    127         v8::Handle<v8::Integer> integer = v8::Integer::New(i);
    128         properties->Set(integer, integer);
     123    // Get an array containing the names of indexed properties in a collection.
     124    template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
     125    {
     126        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
     127        Collection* collection = toNativeCollection<Collection>(info.Holder());
     128        int length = collection->length();
     129        v8::Handle<v8::Array> properties = v8::Array::New(length);
     130        for (int i = 0; i < length; ++i) {
     131            // FIXME: Do we need to check that the item function returns a non-null value for this index?
     132            v8::Handle<v8::Integer> integer = v8::Integer::New(i);
     133            properties->Set(integer, integer);
     134        }
     135        return properties;
    129136    }
    130     return properties;
    131 }
    132137
    133138
    134 // A template for indexed getters on collections of strings that should return null if the resulting string is a null string.
    135 template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
    136 {
    137     // FIXME: assert that object must be a collection type
    138     ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
    139     Collection* collection = toNativeCollection<Collection>(info.Holder());
    140     String result = collection->item(index);
    141     return v8StringOrNull(result);
    142 }
     139    // A template for indexed getters on collections of strings that should return null if the resulting string is a null string.
     140    template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
     141    {
     142        // FIXME: assert that object must be a collection type
     143        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
     144        Collection* collection = toNativeCollection<Collection>(info.Holder());
     145        String result = collection->item(index);
     146        return v8StringOrNull(result);
     147    }
    143148
    144149
    145 // A template for indexed getters on collections of strings.
    146 template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
    147 {
    148     // FIXME: assert that object must be a collection type
    149     ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
    150     Collection* collection = toNativeCollection<Collection>(info.Holder());
    151     String result = collection->item(index);
    152     return v8String(result);
    153 }
     150    // A template for indexed getters on collections of strings.
     151    template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
     152    {
     153        // FIXME: assert that object must be a collection type
     154        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
     155        Collection* collection = toNativeCollection<Collection>(info.Holder());
     156        String result = collection->item(index);
     157        return v8String(result);
     158    }
    154159
    155160
    156 // Add indexed getter to the function template for a collection.
    157 template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
    158 {
    159     desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>,
    160                                                         v8::Integer::New(V8ClassIndex::ToInt(type)));
    161 }
     161    // Add indexed getter to the function template for a collection.
     162    template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
     163    {
     164        desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>,
     165                                                            v8::Integer::New(V8ClassIndex::ToInt(type)));
     166    }
    162167
    163168
    164 // Add named getter to the function template for a collection.
    165 template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
    166 {
    167     desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type)));
    168 }
     169    // Add named getter to the function template for a collection.
     170    template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
     171    {
     172        desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type)));
     173    }
    169174
    170 // Add indexed getter returning a string or null to a function template for a collection.
    171 template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
    172 {
    173     desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
    174 }
     175    // Add indexed getter returning a string or null to a function template for a collection.
     176    template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
     177    {
     178        desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
     179    }
    175180
    176181
    177 // Add indexed getter returning a string to a function template for a collection.
    178 template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
    179 {
    180     desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
    181 }
     182    // Add indexed getter returning a string to a function template for a collection.
     183    template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
     184    {
     185        desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
     186    }
    182187
    183 v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
     188    v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
    184189
    185190} // namespace WebCore
  • trunk/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r54259 r54278  
    4949#include "V8Collection.h"
    5050#include "V8ConsoleMessage.h"
     51#include "V8CustomBinding.h"
    5152#include "V8DOMMap.h"
    5253#include "V8DOMWindow.h"
    53 #include "V8Document.h"
    5454#include "V8HiddenPropertyName.h"
    5555#include "V8History.h"
     
    423423    }
    424424
    425     v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document());
     425    v8::Handle<v8::Value> documentWrapper = V8DOMWrapper::convertNodeToV8Object(m_frame->document());
    426426
    427427    // If instantiation of the document wrapper fails, clear the cache
  • trunk/WebCore/bindings/v8/V8DOMWrapper.cpp

    r54259 r54278  
    4444#include "V8Binding.h"
    4545#include "V8Collection.h"
     46#include "V8CustomBinding.h"
    4647#include "V8CustomEventListener.h"
    4748#include "V8DOMApplicationCache.h"
     
    8485typedef HashMap<void*, v8::Object*> DOMObjectMap;
    8586
     87#if ENABLE(SVG)
     88
     89static V8ClassIndex::V8WrapperType downcastSVGPathSeg(void* pathSeg)
     90{
     91    SVGPathSeg* realPathSeg = reinterpret_cast<SVGPathSeg*>(pathSeg);
     92
     93    switch (realPathSeg->pathSegType()) {
     94    case SVGPathSeg::PATHSEG_CLOSEPATH:                    return V8ClassIndex::SVGPATHSEGCLOSEPATH;
     95    case SVGPathSeg::PATHSEG_MOVETO_ABS:                   return V8ClassIndex::SVGPATHSEGMOVETOABS;
     96    case SVGPathSeg::PATHSEG_MOVETO_REL:                   return V8ClassIndex::SVGPATHSEGMOVETOREL;
     97    case SVGPathSeg::PATHSEG_LINETO_ABS:                   return V8ClassIndex::SVGPATHSEGLINETOABS;
     98    case SVGPathSeg::PATHSEG_LINETO_REL:                   return V8ClassIndex::SVGPATHSEGLINETOREL;
     99    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:            return V8ClassIndex::SVGPATHSEGCURVETOCUBICABS;
     100    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:            return V8ClassIndex::SVGPATHSEGCURVETOCUBICREL;
     101    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:        return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICABS;
     102    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:        return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICREL;
     103    case SVGPathSeg::PATHSEG_ARC_ABS:                      return V8ClassIndex::SVGPATHSEGARCABS;
     104    case SVGPathSeg::PATHSEG_ARC_REL:                      return V8ClassIndex::SVGPATHSEGARCREL;
     105    case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:        return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALABS;
     106    case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:        return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALREL;
     107    case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:          return V8ClassIndex::SVGPATHSEGLINETOVERTICALABS;
     108    case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:          return V8ClassIndex::SVGPATHSEGLINETOVERTICALREL;
     109    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:     return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHABS;
     110    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:     return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHREL;
     111    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHABS;
     112    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHREL;
     113    default:                                               return V8ClassIndex::INVALID_CLASS_INDEX;
     114    }
     115}
     116
     117v8::Handle<v8::Value> V8DOMWrapper::convertSVGElementInstanceToV8Object(SVGElementInstance* instance)
     118{
     119    if (!instance)
     120        return v8::Null();
     121
     122    v8::Handle<v8::Object> existingInstance = getDOMSVGElementInstanceMap().get(instance);
     123    if (!existingInstance.IsEmpty())
     124        return existingInstance;
     125
     126    instance->ref();
     127
     128    // Instantiate the V8 object and remember it
     129    v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::SVGELEMENTINSTANCE, V8ClassIndex::SVGELEMENTINSTANCE, instance);
     130    if (!result.IsEmpty()) {
     131        // Only update the DOM SVG element map if the result is non-empty.
     132        getDOMSVGElementInstanceMap().set(instance, v8::Persistent<v8::Object>::New(result));
     133    }
     134    return result;
     135}
     136
     137v8::Handle<v8::Value> V8DOMWrapper::convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType type, void* object)
     138{
     139    if (!object)
     140        return v8::Null();
     141
     142    v8::Persistent<v8::Object> result = getDOMSVGObjectWithContextMap().get(object);
     143    if (!result.IsEmpty())
     144        return result;
     145
     146    // Special case: SVGPathSegs need to be downcast to their real type
     147    if (type == V8ClassIndex::SVGPATHSEG)
     148        type = downcastSVGPathSeg(object);
     149
     150    v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, object);
     151    if (!v8Object.IsEmpty()) {
     152        result = v8::Persistent<v8::Object>::New(v8Object);
     153        switch (type) {
     154#define MAKE_CASE(TYPE, NAME)     \
     155        case V8ClassIndex::TYPE: static_cast<NAME*>(object)->ref(); break;
     156        SVG_OBJECT_TYPES(MAKE_CASE)
     157#undef MAKE_CASE
     158#define MAKE_CASE(TYPE, NAME)     \
     159        case V8ClassIndex::TYPE:    \
     160            static_cast<V8SVGPODTypeWrapper<NAME>*>(object)->ref(); break;
     161        SVG_POD_NATIVE_TYPES(MAKE_CASE)
     162#undef MAKE_CASE
     163        default:
     164            ASSERT_NOT_REACHED();
     165        }
     166        getDOMSVGObjectWithContextMap().set(object, result);
     167    }
     168
     169    return result;
     170}
     171
     172#endif // ENABLE(SVG)
     173
    86174#if ENABLE(3D_CANVAS)
    87175void V8DOMWrapper::setIndexedPropertiesToExternalArray(v8::Handle<v8::Object> wrapper,
     
    237325}
    238326
     327v8::Handle<v8::Value> V8DOMWrapper::convertToV8Object(V8ClassIndex::V8WrapperType type, void* impl)
     328{
     329    ASSERT(type != V8ClassIndex::EVENTLISTENER);
     330    ASSERT(type != V8ClassIndex::EVENTTARGET);
     331    ASSERT(type != V8ClassIndex::EVENT);
     332
     333    // These objects can be constructed under WorkerContextExecutionProxy.  They need special
     334    // handling, since if we proceed below V8Proxy::retrieve() will get called and will crash.
     335    // TODO(ukai): websocket?
     336    if ((type == V8ClassIndex::DOMCOREEXCEPTION
     337         || type == V8ClassIndex::RANGEEXCEPTION
     338         || type == V8ClassIndex::EVENTEXCEPTION
     339         || type == V8ClassIndex::XMLHTTPREQUESTEXCEPTION
     340         || type == V8ClassIndex::MESSAGEPORT)
     341        && WorkerContextExecutionProxy::retrieve()) {
     342        return WorkerContextExecutionProxy::convertToV8Object(type, impl);
     343    }
     344
     345    bool isActiveDomObject = false;
     346    switch (type) {
     347#define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE:
     348        DOM_NODE_TYPES(MAKE_CASE)
     349#if ENABLE(SVG)
     350        SVG_NODE_TYPES(MAKE_CASE)
     351#endif
     352        return convertNodeToV8Object(static_cast<Node*>(impl));
     353    case V8ClassIndex::CSSVALUE:
     354        return convertCSSValueToV8Object(static_cast<CSSValue*>(impl));
     355    case V8ClassIndex::CSSRULE:
     356        return convertCSSRuleToV8Object(static_cast<CSSRule*>(impl));
     357    case V8ClassIndex::STYLESHEET:
     358        return convertStyleSheetToV8Object(static_cast<StyleSheet*>(impl));
     359    case V8ClassIndex::DOMWINDOW:
     360        return convertWindowToV8Object(static_cast<DOMWindow*>(impl));
     361    case V8ClassIndex::NAMEDNODEMAP:
     362        return convertNamedNodeMapToV8Object(static_cast<NamedNodeMap*>(impl));
     363#if ENABLE(SVG)
     364        SVG_NONNODE_TYPES(MAKE_CASE)
     365        if (type == V8ClassIndex::SVGELEMENTINSTANCE)
     366            return convertSVGElementInstanceToV8Object(static_cast<SVGElementInstance*>(impl));
     367        return convertSVGObjectWithContextToV8Object(type, impl);
     368#endif
     369
     370        ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
     371        isActiveDomObject = true;
     372        break;
     373    default:
     374        break;
     375  }
     376
     377#undef MAKE_CASE
     378
     379    if (!impl)
     380        return v8::Null();
     381
     382    // Non DOM node
     383    v8::Persistent<v8::Object> result = isActiveDomObject ? getActiveDOMObjectMap().get(impl) : getDOMObjectMap().get(impl);
     384    if (result.IsEmpty()) {
     385#if ENABLE(3D_CANVAS)
     386        if (type == V8ClassIndex::WEBGLARRAY && impl) {
     387            // Determine which subclass we are wrapping.
     388            WebGLArray* array = reinterpret_cast<WebGLArray*>(impl);
     389            if (array->isByteArray())
     390                type = V8ClassIndex::WEBGLBYTEARRAY;
     391            else if (array->isFloatArray())
     392                type = V8ClassIndex::WEBGLFLOATARRAY;
     393            else if (array->isIntArray())
     394                type = V8ClassIndex::WEBGLINTARRAY;
     395            else if (array->isShortArray())
     396                type = V8ClassIndex::WEBGLSHORTARRAY;
     397            else if (array->isUnsignedByteArray())
     398                type = V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY;
     399            else if (array->isUnsignedIntArray())
     400                type = V8ClassIndex::WEBGLUNSIGNEDINTARRAY;
     401            else if (array->isUnsignedShortArray())
     402                type = V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY;
     403        }
     404#endif
     405
     406        v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, impl);
     407        if (!v8Object.IsEmpty()) {
     408            // Go through big switch statement, it has some duplications
     409            // that were handled by code above (such as CSSVALUE, CSSRULE, etc).
     410            switch (type) {
     411#define MAKE_CASE(TYPE, NAME) \
     412            case V8ClassIndex::TYPE: static_cast<NAME*>(impl)->ref(); break;
     413                DOM_OBJECT_TYPES(MAKE_CASE)
     414#undef MAKE_CASE
     415            default:
     416                ASSERT_NOT_REACHED();
     417            }
     418            result = v8::Persistent<v8::Object>::New(v8Object);
     419            if (isActiveDomObject)
     420                setJSWrapperForActiveDOMObject(impl, result);
     421            else
     422                setJSWrapperForDOMObject(impl, result);
     423
     424            if (type == V8ClassIndex::CANVASPIXELARRAY) {
     425                CanvasPixelArray* pixels = reinterpret_cast<CanvasPixelArray*>(impl);
     426                result->SetIndexedPropertiesToPixelData(pixels->data()->data(), pixels->length());
     427            }
     428
     429#if ENABLE(3D_CANVAS)
     430            // Set up WebGLArray subclasses' accesses similarly.
     431            switch (type) {
     432            case V8ClassIndex::WEBGLBYTEARRAY:
     433            case V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY:
     434            case V8ClassIndex::WEBGLSHORTARRAY:
     435            case V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY:
     436            case V8ClassIndex::WEBGLINTARRAY:
     437            case V8ClassIndex::WEBGLUNSIGNEDINTARRAY:
     438            case V8ClassIndex::WEBGLFLOATARRAY: {
     439                WebGLArray* array = reinterpret_cast<WebGLArray*>(impl);
     440                setIndexedPropertiesToExternalArray(result,
     441                                                    V8ClassIndex::ToInt(type),
     442                                                    array->baseAddress(),
     443                                                    array->length());
     444                break;
     445            }
     446            default:
     447                break;
     448            }
     449#endif
     450
     451            // Special case for non-node objects associated with a
     452            // DOMWindow. Both Safari and FF let the JS wrappers for these
     453            // objects survive GC. To mimic their behavior, V8 creates
     454            // hidden references from the DOMWindow to these wrapper
     455            // objects. These references get cleared when the DOMWindow is
     456            // reused by a new page.
     457            switch (type) {
     458            case V8ClassIndex::CONSOLE:
     459                setHiddenWindowReference(static_cast<Console*>(impl)->frame(), V8DOMWindow::consoleIndex, result);
     460                break;
     461            case V8ClassIndex::HISTORY:
     462                setHiddenWindowReference(static_cast<History*>(impl)->frame(), V8DOMWindow::historyIndex, result);
     463                break;
     464            case V8ClassIndex::NAVIGATOR:
     465                setHiddenWindowReference(static_cast<Navigator*>(impl)->frame(), V8DOMWindow::navigatorIndex, result);
     466                break;
     467            case V8ClassIndex::SCREEN:
     468                setHiddenWindowReference(static_cast<Screen*>(impl)->frame(), V8DOMWindow::screenIndex, result);
     469                break;
     470            case V8ClassIndex::LOCATION:
     471                setHiddenWindowReference(static_cast<Location*>(impl)->frame(), V8DOMWindow::locationIndex, result);
     472                break;
     473            case V8ClassIndex::DOMSELECTION:
     474                setHiddenWindowReference(static_cast<DOMSelection*>(impl)->frame(), V8DOMWindow::domSelectionIndex, result);
     475                break;
     476            case V8ClassIndex::BARINFO: {
     477                BarInfo* barInfo = static_cast<BarInfo*>(impl);
     478                Frame* frame = barInfo->frame();
     479                switch (barInfo->type()) {
     480                case BarInfo::Locationbar:
     481                    setHiddenWindowReference(frame, V8DOMWindow::locationbarIndex, result);
     482                    break;
     483                case BarInfo::Menubar:
     484                    setHiddenWindowReference(frame, V8DOMWindow::menubarIndex, result);
     485                    break;
     486                case BarInfo::Personalbar:
     487                    setHiddenWindowReference(frame, V8DOMWindow::personalbarIndex, result);
     488                    break;
     489                case BarInfo::Scrollbars:
     490                    setHiddenWindowReference(frame, V8DOMWindow::scrollbarsIndex, result);
     491                    break;
     492                case BarInfo::Statusbar:
     493                    setHiddenWindowReference(frame, V8DOMWindow::statusbarIndex, result);
     494                    break;
     495                case BarInfo::Toolbar:
     496                    setHiddenWindowReference(frame, V8DOMWindow::toolbarIndex, result);
     497                    break;
     498                }
     499                break;
     500            }
     501            default:
     502                break;
     503            }
     504        }
     505    }
     506    return result;
     507}
     508
    239509void V8DOMWrapper::setHiddenWindowReference(Frame* frame, const int internalIndex, v8::Handle<v8::Object> jsObject)
    240510{
     
    280550}
    281551
    282 v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl)
    283 {
     552v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType descriptorType, V8ClassIndex::V8WrapperType cptrType, void* impl)
     553{
     554    // Make a special case for document.all
     555    if (descriptorType == V8ClassIndex::HTMLCOLLECTION && static_cast<HTMLCollection*>(impl)->type() == DocAll)
     556        descriptorType = V8ClassIndex::HTMLALLCOLLECTION;
     557
    284558    if (V8IsolatedContext::getEntered()) {
    285559        // This effectively disables the wrapper cache for isolated worlds.
     
    294568    if (proxy)
    295569        // FIXME: Fix this to work properly with isolated worlds (see above).
    296         instance = proxy->windowShell()->createWrapperFromCache(type);
     570        instance = proxy->windowShell()->createWrapperFromCache(descriptorType);
    297571    else {
    298         v8::Local<v8::Function> function = getTemplate(type)->GetFunction();
     572        v8::Local<v8::Function> function = getTemplate(descriptorType)->GetFunction();
    299573        instance = SafeAllocation::newInstance(function);
    300574    }
    301575    if (!instance.IsEmpty()) {
    302576        // Avoid setting the DOM wrapper for failed allocations.
    303         setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl);
     577        setDOMWrapper(instance, V8ClassIndex::ToInt(cptrType), impl);
    304578    }
    305579    return instance;
     
    329603#endif
    330604
     605bool V8DOMWrapper::isDOMEventWrapper(v8::Handle<v8::Value> value)
     606{
     607    // All kinds of events use EVENT as dom type in JS wrappers.
     608    // See EventToV8Object
     609    return isWrapperOfType(value, V8ClassIndex::EVENT);
     610}
     611
    331612bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8WrapperType classType)
    332613{
     
    348629
    349630    return V8ClassIndex::FromInt(type->Int32Value()) == classType;
     631}
     632
     633#if ENABLE(VIDEO)
     634#define FOR_EACH_VIDEO_TAG(macro)                  \
     635    macro(audio, AUDIO)                            \
     636    macro(source, SOURCE)                          \
     637    macro(video, VIDEO)
     638#else
     639#define FOR_EACH_VIDEO_TAG(macro)
     640#endif
     641
     642#if ENABLE(DATAGRID)
     643#define FOR_EACH_DATAGRID_TAG(macro)               \
     644    macro(datagrid, DATAGRID)                        \
     645    macro(dcell, DATAGRIDCELL)                       \
     646    macro(dcol, DATAGRIDCOL)                         \
     647    macro(drow, DATAGRIDROW)
     648#else
     649#define FOR_EACH_DATAGRID_TAG(macro)
     650#endif
     651
     652#define FOR_EACH_TAG(macro)                        \
     653    FOR_EACH_DATAGRID_TAG(macro)                   \
     654    macro(a, ANCHOR)                               \
     655    macro(applet, APPLET)                          \
     656    macro(area, AREA)                              \
     657    macro(base, BASE)                              \
     658    macro(basefont, BASEFONT)                      \
     659    macro(blockquote, BLOCKQUOTE)                  \
     660    macro(body, BODY)                              \
     661    macro(br, BR)                                  \
     662    macro(button, BUTTON)                          \
     663    macro(caption, TABLECAPTION)                   \
     664    macro(col, TABLECOL)                           \
     665    macro(colgroup, TABLECOL)                      \
     666    macro(del, MOD)                                \
     667    macro(canvas, CANVAS)                          \
     668    macro(dir, DIRECTORY)                          \
     669    macro(div, DIV)                                \
     670    macro(dl, DLIST)                               \
     671    macro(embed, EMBED)                            \
     672    macro(fieldset, FIELDSET)                      \
     673    macro(font, FONT)                              \
     674    macro(form, FORM)                              \
     675    macro(frame, FRAME)                            \
     676    macro(frameset, FRAMESET)                      \
     677    macro(h1, HEADING)                             \
     678    macro(h2, HEADING)                             \
     679    macro(h3, HEADING)                             \
     680    macro(h4, HEADING)                             \
     681    macro(h5, HEADING)                             \
     682    macro(h6, HEADING)                             \
     683    macro(head, HEAD)                              \
     684    macro(hr, HR)                                  \
     685    macro(html, HTML)                              \
     686    macro(img, IMAGE)                              \
     687    macro(iframe, IFRAME)                          \
     688    macro(image, IMAGE)                            \
     689    macro(input, INPUT)                            \
     690    macro(ins, MOD)                                \
     691    macro(isindex, ISINDEX)                        \
     692    macro(keygen, SELECT)                          \
     693    macro(label, LABEL)                            \
     694    macro(legend, LEGEND)                          \
     695    macro(li, LI)                                  \
     696    macro(link, LINK)                              \
     697    macro(listing, PRE)                            \
     698    macro(map, MAP)                                \
     699    macro(marquee, MARQUEE)                        \
     700    macro(menu, MENU)                              \
     701    macro(meta, META)                              \
     702    macro(object, OBJECT)                          \
     703    macro(ol, OLIST)                               \
     704    macro(optgroup, OPTGROUP)                      \
     705    macro(option, OPTION)                          \
     706    macro(p, PARAGRAPH)                            \
     707    macro(param, PARAM)                            \
     708    macro(pre, PRE)                                \
     709    macro(q, QUOTE)                                \
     710    macro(script, SCRIPT)                          \
     711    macro(select, SELECT)                          \
     712    macro(style, STYLE)                            \
     713    macro(table, TABLE)                            \
     714    macro(thead, TABLESECTION)                     \
     715    macro(tbody, TABLESECTION)                     \
     716    macro(tfoot, TABLESECTION)                     \
     717    macro(td, TABLECELL)                           \
     718    macro(th, TABLECELL)                           \
     719    macro(tr, TABLEROW)                            \
     720    macro(textarea, TEXTAREA)                      \
     721    macro(title, TITLE)                            \
     722    macro(ul, ULIST)                               \
     723    macro(xmp, PRE)
     724
     725V8ClassIndex::V8WrapperType V8DOMWrapper::htmlElementType(HTMLElement* element)
     726{
     727    typedef HashMap<String, V8ClassIndex::V8WrapperType> WrapperTypeMap;
     728    DEFINE_STATIC_LOCAL(WrapperTypeMap, wrapperTypeMap, ());
     729    if (wrapperTypeMap.isEmpty()) {
     730#define ADD_TO_HASH_MAP(tag, name) \
     731        wrapperTypeMap.set(#tag, V8ClassIndex::HTML##name##ELEMENT);
     732        FOR_EACH_TAG(ADD_TO_HASH_MAP)
     733#if ENABLE(VIDEO)
     734        if (MediaPlayer::isAvailable()) {
     735            FOR_EACH_VIDEO_TAG(ADD_TO_HASH_MAP)
     736        }
     737#endif
     738#undef ADD_TO_HASH_MAP
     739    }
     740
     741    V8ClassIndex::V8WrapperType type = wrapperTypeMap.get(element->localName().impl());
     742    if (!type)
     743        return V8ClassIndex::HTMLELEMENT;
     744    return type;
     745}
     746#undef FOR_EACH_TAG
     747
     748#if ENABLE(SVG)
     749
     750#if ENABLE(SVG_ANIMATION)
     751#define FOR_EACH_ANIMATION_TAG(macro) \
     752    macro(animateColor, ANIMATECOLOR) \
     753    macro(animate, ANIMATE) \
     754    macro(animateTransform, ANIMATETRANSFORM) \
     755    macro(set, SET)
     756#else
     757#define FOR_EACH_ANIMATION_TAG(macro)
     758#endif
     759
     760#if ENABLE(SVG) && ENABLE(FILTERS)
     761#define FOR_EACH_FILTERS_TAG(macro) \
     762    macro(feBlend, FEBLEND) \
     763    macro(feColorMatrix, FECOLORMATRIX) \
     764    macro(feComponentTransfer, FECOMPONENTTRANSFER) \
     765    macro(feComposite, FECOMPOSITE) \
     766    macro(feDiffuseLighting, FEDIFFUSELIGHTING) \
     767    macro(feDisplacementMap, FEDISPLACEMENTMAP) \
     768    macro(feDistantLight, FEDISTANTLIGHT) \
     769    macro(feFlood, FEFLOOD) \
     770    macro(feFuncA, FEFUNCA) \
     771    macro(feFuncB, FEFUNCB) \
     772    macro(feFuncG, FEFUNCG) \
     773    macro(feFuncR, FEFUNCR) \
     774    macro(feGaussianBlur, FEGAUSSIANBLUR) \
     775    macro(feImage, FEIMAGE) \
     776    macro(feMerge, FEMERGE) \
     777    macro(feMergeNode, FEMERGENODE) \
     778    macro(feMorphology, FEMORPHOLOGY) \
     779    macro(feOffset, FEOFFSET) \
     780    macro(fePointLight, FEPOINTLIGHT) \
     781    macro(feSpecularLighting, FESPECULARLIGHTING) \
     782    macro(feSpotLight, FESPOTLIGHT) \
     783    macro(feTile, FETILE) \
     784    macro(feTurbulence, FETURBULENCE) \
     785    macro(filter, FILTER)
     786#else
     787#define FOR_EACH_FILTERS_TAG(macro)
     788#endif
     789
     790#if ENABLE(SVG_FONTS)
     791#define FOR_EACH_FONTS_TAG(macro) \
     792    macro(font-face, FONTFACE) \
     793    macro(font-face-format, FONTFACEFORMAT) \
     794    macro(font-face-name, FONTFACENAME) \
     795    macro(font-face-src, FONTFACESRC) \
     796    macro(font-face-uri, FONTFACEURI)
     797#else
     798#define FOR_EACH_FONTS_TAG(marco)
     799#endif
     800
     801#if ENABLE(SVG_FOREIGN_OBJECT)
     802#define FOR_EACH_FOREIGN_OBJECT_TAG(macro) \
     803    macro(foreignObject, FOREIGNOBJECT)
     804#else
     805#define FOR_EACH_FOREIGN_OBJECT_TAG(macro)
     806#endif
     807
     808#if ENABLE(SVG_USE)
     809#define FOR_EACH_USE_TAG(macro) \
     810    macro(use, USE)
     811#else
     812#define FOR_EACH_USE_TAG(macro)
     813#endif
     814
     815#define FOR_EACH_TAG(macro) \
     816    FOR_EACH_ANIMATION_TAG(macro) \
     817    FOR_EACH_FILTERS_TAG(macro) \
     818    FOR_EACH_FONTS_TAG(macro) \
     819    FOR_EACH_FOREIGN_OBJECT_TAG(macro) \
     820    FOR_EACH_USE_TAG(macro) \
     821    macro(a, A) \
     822    macro(altGlyph, ALTGLYPH) \
     823    macro(circle, CIRCLE) \
     824    macro(clipPath, CLIPPATH) \
     825    macro(cursor, CURSOR) \
     826    macro(defs, DEFS) \
     827    macro(desc, DESC) \
     828    macro(ellipse, ELLIPSE) \
     829    macro(g, G) \
     830    macro(glyph, GLYPH) \
     831    macro(image, IMAGE) \
     832    macro(linearGradient, LINEARGRADIENT) \
     833    macro(line, LINE) \
     834    macro(marker, MARKER) \
     835    macro(mask, MASK) \
     836    macro(metadata, METADATA) \
     837    macro(path, PATH) \
     838    macro(pattern, PATTERN) \
     839    macro(polyline, POLYLINE) \
     840    macro(polygon, POLYGON) \
     841    macro(radialGradient, RADIALGRADIENT) \
     842    macro(rect, RECT) \
     843    macro(script, SCRIPT) \
     844    macro(stop, STOP) \
     845    macro(style, STYLE) \
     846    macro(svg, SVG) \
     847    macro(switch, SWITCH) \
     848    macro(symbol, SYMBOL) \
     849    macro(text, TEXT) \
     850    macro(textPath, TEXTPATH) \
     851    macro(title, TITLE) \
     852    macro(tref, TREF) \
     853    macro(tspan, TSPAN) \
     854    macro(view, VIEW) \
     855    // end of macro
     856
     857V8ClassIndex::V8WrapperType V8DOMWrapper::svgElementType(SVGElement* element)
     858{
     859    typedef HashMap<String, V8ClassIndex::V8WrapperType> WrapperTypeMap;
     860    DEFINE_STATIC_LOCAL(WrapperTypeMap, wrapperTypeMap, ());
     861    if (wrapperTypeMap.isEmpty()) {
     862#define ADD_TO_HASH_MAP(tag, name) \
     863        wrapperTypeMap.set(#tag, V8ClassIndex::SVG##name##ELEMENT);
     864        FOR_EACH_TAG(ADD_TO_HASH_MAP)
     865#undef ADD_TO_HASH_MAP
     866    }
     867
     868    V8ClassIndex::V8WrapperType type = wrapperTypeMap.get(element->localName().impl());
     869    if (!type)
     870        return V8ClassIndex::SVGELEMENT;
     871    return type;
     872}
     873#undef FOR_EACH_TAG
     874
     875#endif // ENABLE(SVG)
     876
     877v8::Handle<v8::Value> V8DOMWrapper::convertEventToV8Object(Event* event)
     878{
     879    if (!event)
     880        return v8::Null();
     881
     882    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(event);
     883    if (!wrapper.IsEmpty())
     884        return wrapper;
     885
     886    V8ClassIndex::V8WrapperType type = V8ClassIndex::EVENT;
     887
     888    if (event->isUIEvent()) {
     889        if (event->isKeyboardEvent())
     890            type = V8ClassIndex::KEYBOARDEVENT;
     891        else if (event->isTextEvent())
     892            type = V8ClassIndex::TEXTEVENT;
     893        else if (event->isMouseEvent())
     894            type = V8ClassIndex::MOUSEEVENT;
     895        else if (event->isWheelEvent())
     896            type = V8ClassIndex::WHEELEVENT;
     897#if ENABLE(SVG)
     898        else if (event->isSVGZoomEvent())
     899            type = V8ClassIndex::SVGZOOMEVENT;
     900#endif
     901        else if (event->isCompositionEvent())
     902            type = V8ClassIndex::COMPOSITIONEVENT;
     903        else
     904            type = V8ClassIndex::UIEVENT;
     905    } else if (event->isMutationEvent())
     906        type = V8ClassIndex::MUTATIONEVENT;
     907    else if (event->isOverflowEvent())
     908        type = V8ClassIndex::OVERFLOWEVENT;
     909    else if (event->isMessageEvent())
     910        type = V8ClassIndex::MESSAGEEVENT;
     911    else if (event->isPageTransitionEvent())
     912        type = V8ClassIndex::PAGETRANSITIONEVENT;
     913    else if (event->isPopStateEvent())
     914        type = V8ClassIndex::POPSTATEEVENT;
     915    else if (event->isProgressEvent()) {
     916        if (event->isXMLHttpRequestProgressEvent())
     917            type = V8ClassIndex::XMLHTTPREQUESTPROGRESSEVENT;
     918        else
     919            type = V8ClassIndex::PROGRESSEVENT;
     920    } else if (event->isWebKitAnimationEvent())
     921        type = V8ClassIndex::WEBKITANIMATIONEVENT;
     922    else if (event->isWebKitTransitionEvent())
     923        type = V8ClassIndex::WEBKITTRANSITIONEVENT;
     924#if ENABLE(WORKERS)
     925    else if (event->isErrorEvent())
     926        type = V8ClassIndex::ERROREVENT;
     927#endif
     928#if ENABLE(DOM_STORAGE)
     929    else if (event->isStorageEvent())
     930        type = V8ClassIndex::STORAGEEVENT;
     931#endif
     932    else if (event->isBeforeLoadEvent())
     933        type = V8ClassIndex::BEFORELOADEVENT;
     934
     935
     936    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::EVENT, event);
     937    if (result.IsEmpty()) {
     938        // Instantiation failed. Avoid updating the DOM object map and
     939        // return null which is already handled by callers of this function
     940        // in case the event is NULL.
     941        return v8::Null();
     942    }
     943
     944    event->ref(); // fast ref
     945    setJSWrapperForDOMObject(event, v8::Persistent<v8::Object>::New(result));
     946
     947    return result;
     948}
     949
     950static const V8ClassIndex::V8WrapperType mapping[] = {
     951    V8ClassIndex::INVALID_CLASS_INDEX,    // NONE
     952    V8ClassIndex::INVALID_CLASS_INDEX,    // ELEMENT_NODE needs special treatment
     953    V8ClassIndex::ATTR,                   // ATTRIBUTE_NODE
     954    V8ClassIndex::TEXT,                   // TEXT_NODE
     955    V8ClassIndex::CDATASECTION,           // CDATA_SECTION_NODE
     956    V8ClassIndex::ENTITYREFERENCE,        // ENTITY_REFERENCE_NODE
     957    V8ClassIndex::ENTITY,                 // ENTITY_NODE
     958    V8ClassIndex::PROCESSINGINSTRUCTION,  // PROCESSING_INSTRUCTION_NODE
     959    V8ClassIndex::COMMENT,                // COMMENT_NODE
     960    V8ClassIndex::INVALID_CLASS_INDEX,    // DOCUMENT_NODE needs special treatment
     961    V8ClassIndex::DOCUMENTTYPE,           // DOCUMENT_TYPE_NODE
     962    V8ClassIndex::DOCUMENTFRAGMENT,       // DOCUMENT_FRAGMENT_NODE
     963    V8ClassIndex::NOTATION,               // NOTATION_NODE
     964    V8ClassIndex::NODE,                   // XPATH_NAMESPACE_NODE
     965};
     966
     967v8::Handle<v8::Value> V8DOMWrapper::convertDocumentToV8Object(Document* document)
     968{
     969    // Find a proxy for this node.
     970    //
     971    // Note that if proxy is found, we might initialize the context which can
     972    // instantiate a document wrapper.  Therefore, we get the proxy before
     973    // checking if the node already has a wrapper.
     974    V8Proxy* proxy = V8Proxy::retrieve(document->frame());
     975    if (proxy)
     976        proxy->windowShell()->initContextIfNeeded();
     977
     978    DOMNodeMapping& domNodeMap = getDOMNodeMap();
     979    v8::Handle<v8::Object> wrapper = domNodeMap.get(document);
     980    if (wrapper.IsEmpty())
     981        return convertNewNodeToV8Object(document, proxy, domNodeMap);
     982
     983    return wrapper;
    350984}
    351985
     
    365999}
    3661000
     1001v8::Handle<v8::Value> V8DOMWrapper::convertNodeToV8Object(Node* node)
     1002{
     1003    if (!node)
     1004        return v8::Null();
     1005   
     1006    v8::Handle<v8::Value> wrapper = getWrapper(node);
     1007    if (!wrapper.IsEmpty())
     1008        return wrapper;
     1009
     1010    Document* document = node->document();
     1011    if (node == document)
     1012        return convertDocumentToV8Object(document);
     1013
     1014    return convertNewNodeToV8Object(node, 0, getDOMNodeMap());
     1015}
     1016   
     1017// Caller checks node is not null.
     1018v8::Handle<v8::Value> V8DOMWrapper::convertNewNodeToV8Object(Node* node, V8Proxy* proxy, DOMNodeMapping& domNodeMap)
     1019{
     1020    if (!proxy && node->document())
     1021        proxy = V8Proxy::retrieve(node->document()->frame());
     1022
     1023    bool isDocument = false; // document type node has special handling
     1024    V8ClassIndex::V8WrapperType type;
     1025
     1026    Node::NodeType nodeType = node->nodeType();
     1027    if (nodeType == Node::ELEMENT_NODE) {
     1028        if (node->isHTMLElement())
     1029            type = htmlElementType(static_cast<HTMLElement*>(node));
     1030#if ENABLE(SVG)
     1031        else if (node->isSVGElement())
     1032            type = svgElementType(static_cast<SVGElement*>(node));
     1033#endif
     1034        else
     1035            type = V8ClassIndex::ELEMENT;
     1036    } else if (nodeType == Node::DOCUMENT_NODE) {
     1037        isDocument = true;
     1038        Document* document = static_cast<Document*>(node);
     1039        if (document->isHTMLDocument())
     1040            type = V8ClassIndex::HTMLDOCUMENT;
     1041#if ENABLE(SVG)
     1042        else if (document->isSVGDocument())
     1043            type = V8ClassIndex::SVGDOCUMENT;
     1044#endif
     1045        else
     1046            type = V8ClassIndex::DOCUMENT;
     1047    } else {
     1048        ASSERT(nodeType < static_cast<int>(sizeof(mapping)/sizeof(mapping[0])));
     1049        type = mapping[nodeType];
     1050        ASSERT(type != V8ClassIndex::INVALID_CLASS_INDEX);
     1051    }
     1052
     1053    v8::Handle<v8::Context> context;
     1054    if (proxy)
     1055        context = proxy->context();
     1056
     1057    // Enter the node's context and create the wrapper in that context.
     1058    if (!context.IsEmpty())
     1059        context->Enter();
     1060
     1061    v8::Local<v8::Object> result = instantiateV8Object(proxy, type, V8ClassIndex::NODE, node);
     1062
     1063    // Exit the node's context if it was entered.
     1064    if (!context.IsEmpty())
     1065        context->Exit();
     1066
     1067    if (result.IsEmpty()) {
     1068        // If instantiation failed it's important not to add the result
     1069        // to the DOM node map. Instead we return an empty handle, which
     1070        // should already be handled by callers of this function in case
     1071        // the node is NULL.
     1072        return result;
     1073    }
     1074
     1075    node->ref();
     1076    domNodeMap.set(node, v8::Persistent<v8::Object>::New(result));
     1077
     1078    if (isDocument) {
     1079        if (proxy)
     1080            proxy->windowShell()->updateDocumentWrapper(result);
     1081
     1082        if (type == V8ClassIndex::HTMLDOCUMENT) {
     1083            // Create marker object and insert it in two internal fields.
     1084            // This is used to implement temporary shadowing of
     1085            // document.all.
     1086            ASSERT(result->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
     1087            v8::Local<v8::Object> marker = v8::Object::New();
     1088            result->SetInternalField(V8HTMLDocument::markerIndex, marker);
     1089            result->SetInternalField(V8HTMLDocument::shadowIndex, marker);
     1090        }
     1091    }
     1092
     1093    return result;
     1094}
     1095
    3671096// A JS object of type EventTarget is limited to a small number of possible classes.
    3681097// Check EventTarget.h for new type conversion methods
     
    4371166}
    4381167
     1168v8::Handle<v8::Value> V8DOMWrapper::convertEventListenerToV8Object(ScriptExecutionContext* context, EventListener* listener)
     1169{
     1170    if (!listener)
     1171        return v8::Null();
     1172
     1173    // FIXME: can a user take a lazy event listener and set to other places?
     1174    V8AbstractEventListener* v8listener = static_cast<V8AbstractEventListener*>(listener);
     1175    return v8listener->getListenerObject(context);
     1176}
     1177
    4391178PassRefPtr<EventListener> V8DOMWrapper::getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup)
    4401179{
     
    5221261}
    5231262
     1263v8::Handle<v8::Value> V8DOMWrapper::convertDOMImplementationToV8Object(DOMImplementation* impl)
     1264{
     1265    v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::DOMIMPLEMENTATION, V8ClassIndex::DOMIMPLEMENTATION, impl);
     1266    if (result.IsEmpty()) {
     1267        // If the instantiation failed, we ignore it and return null instead
     1268        // of returning an empty handle.
     1269        return v8::Null();
     1270    }
     1271    return result;
     1272}
     1273
     1274v8::Handle<v8::Value> V8DOMWrapper::convertStyleSheetToV8Object(StyleSheet* sheet)
     1275{
     1276    if (!sheet)
     1277        return v8::Null();
     1278
     1279    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(sheet);
     1280    if (!wrapper.IsEmpty())
     1281        return wrapper;
     1282
     1283    V8ClassIndex::V8WrapperType type = V8ClassIndex::STYLESHEET;
     1284    if (sheet->isCSSStyleSheet())
     1285        type = V8ClassIndex::CSSSTYLESHEET;
     1286
     1287    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::STYLESHEET, sheet);
     1288    if (!result.IsEmpty()) {
     1289        // Only update the DOM object map if the result is non-empty.
     1290        sheet->ref();
     1291        setJSWrapperForDOMObject(sheet, v8::Persistent<v8::Object>::New(result));
     1292    }
     1293
     1294    // Add a hidden reference from stylesheet object to its owner node.
     1295    Node* ownerNode = sheet->ownerNode();
     1296    if (ownerNode) {
     1297        v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(ownerNode));
     1298        result->SetInternalField(V8StyleSheet::ownerNodeIndex, owner);
     1299    }
     1300
     1301    return result;
     1302}
     1303
     1304v8::Handle<v8::Value> V8DOMWrapper::convertCSSValueToV8Object(CSSValue* value)
     1305{
     1306    if (!value)
     1307        return v8::Null();
     1308
     1309    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(value);
     1310    if (!wrapper.IsEmpty())
     1311        return wrapper;
     1312
     1313    V8ClassIndex::V8WrapperType type;
     1314
     1315    if (value->isWebKitCSSTransformValue())
     1316        type = V8ClassIndex::WEBKITCSSTRANSFORMVALUE;
     1317    else if (value->isValueList())
     1318        type = V8ClassIndex::CSSVALUELIST;
     1319    else if (value->isPrimitiveValue())
     1320        type = V8ClassIndex::CSSPRIMITIVEVALUE;
     1321#if ENABLE(SVG)
     1322    else if (value->isSVGPaint())
     1323        type = V8ClassIndex::SVGPAINT;
     1324    else if (value->isSVGColor())
     1325        type = V8ClassIndex::SVGCOLOR;
     1326#endif
     1327    else
     1328        type = V8ClassIndex::CSSVALUE;
     1329
     1330    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSVALUE, value);
     1331    if (!result.IsEmpty()) {
     1332        // Only update the DOM object map if the result is non-empty.
     1333        value->ref();
     1334        setJSWrapperForDOMObject(value, v8::Persistent<v8::Object>::New(result));
     1335    }
     1336
     1337    return result;
     1338}
     1339
     1340v8::Handle<v8::Value> V8DOMWrapper::convertCSSRuleToV8Object(CSSRule* rule)
     1341{
     1342    if (!rule)
     1343        return v8::Null();
     1344
     1345    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(rule);
     1346    if (!wrapper.IsEmpty())
     1347        return wrapper;
     1348
     1349    V8ClassIndex::V8WrapperType type;
     1350
     1351    switch (rule->type()) {
     1352    case CSSRule::STYLE_RULE:
     1353        type = V8ClassIndex::CSSSTYLERULE;
     1354        break;
     1355    case CSSRule::CHARSET_RULE:
     1356        type = V8ClassIndex::CSSCHARSETRULE;
     1357        break;
     1358    case CSSRule::IMPORT_RULE:
     1359        type = V8ClassIndex::CSSIMPORTRULE;
     1360        break;
     1361    case CSSRule::MEDIA_RULE:
     1362        type = V8ClassIndex::CSSMEDIARULE;
     1363        break;
     1364    case CSSRule::FONT_FACE_RULE:
     1365        type = V8ClassIndex::CSSFONTFACERULE;
     1366        break;
     1367    case CSSRule::PAGE_RULE:
     1368        type = V8ClassIndex::CSSPAGERULE;
     1369        break;
     1370    case CSSRule::VARIABLES_RULE:
     1371        type = V8ClassIndex::CSSVARIABLESRULE;
     1372        break;
     1373    case CSSRule::WEBKIT_KEYFRAME_RULE:
     1374        type = V8ClassIndex::WEBKITCSSKEYFRAMERULE;
     1375        break;
     1376    case CSSRule::WEBKIT_KEYFRAMES_RULE:
     1377        type = V8ClassIndex::WEBKITCSSKEYFRAMESRULE;
     1378        break;
     1379    default:  // CSSRule::UNKNOWN_RULE
     1380        type = V8ClassIndex::CSSRULE;
     1381        break;
     1382    }
     1383
     1384    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSRULE, rule);
     1385    if (!result.IsEmpty()) {
     1386        // Only update the DOM object map if the result is non-empty.
     1387        rule->ref();
     1388        setJSWrapperForDOMObject(rule, v8::Persistent<v8::Object>::New(result));
     1389    }
     1390    return result;
     1391}
     1392
     1393v8::Handle<v8::Value> V8DOMWrapper::convertWindowToV8Object(DOMWindow* window)
     1394{
     1395    if (!window)
     1396        return v8::Null();
     1397    // Initializes environment of a frame, and return the global object
     1398    // of the frame.
     1399    Frame* frame = window->frame();
     1400    if (!frame)
     1401        return v8::Handle<v8::Object>();
     1402
     1403    // Special case: Because of evaluateInIsolatedWorld() one DOMWindow can have
     1404    // multiple contexts and multiple global objects associated with it. When
     1405    // code running in one of those contexts accesses the window object, we
     1406    // want to return the global object associated with that context, not
     1407    // necessarily the first global object associated with that DOMWindow.
     1408    v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent();
     1409    v8::Handle<v8::Object> currentGlobal = currentContext->Global();
     1410    v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, currentGlobal);
     1411    if (!windowWrapper.IsEmpty()) {
     1412        if (V8DOMWindow::toNative(windowWrapper) == window)
     1413            return currentGlobal;
     1414    }
     1415
     1416    // Otherwise, return the global object associated with this frame.
     1417    v8::Handle<v8::Context> context = V8Proxy::context(frame);
     1418    if (context.IsEmpty())
     1419        return v8::Handle<v8::Object>();
     1420
     1421    v8::Handle<v8::Object> global = context->Global();
     1422    ASSERT(!global.IsEmpty());
     1423    return global;
     1424}
     1425
     1426v8::Handle<v8::Value> V8DOMWrapper::convertNamedNodeMapToV8Object(NamedNodeMap* map)
     1427{
     1428    if (!map)
     1429        return v8::Null();
     1430
     1431    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(map);
     1432    if (!wrapper.IsEmpty())
     1433        return wrapper;
     1434
     1435    v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::NAMEDNODEMAP, V8ClassIndex::NAMEDNODEMAP, map);
     1436    if (result.IsEmpty())
     1437        return result;
     1438
     1439    // Only update the DOM object map if the result is non-empty.
     1440    map->ref();
     1441    setJSWrapperForDOMObject(map, v8::Persistent<v8::Object>::New(result));
     1442
     1443    // Add a hidden reference from named node map to its owner node.
     1444    if (Element* element = map->element()) {
     1445        v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(element));
     1446        result->SetInternalField(V8NamedNodeMap::ownerNodeIndex, owner);
     1447    }
     1448
     1449    return result;
     1450}
     1451
    5241452}  // namespace WebCore
  • trunk/WebCore/bindings/v8/V8DOMWrapper.h

    r54259 r54278  
    3737#include "NodeFilter.h"
    3838#include "PlatformString.h" // for WebCore::String
     39#include "V8CustomBinding.h"
    3940#include "V8CustomXPathNSResolver.h"
    4041#include "V8DOMMap.h"
     
    123124        }
    124125
     126        template<typename T>
     127        static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType type, PassRefPtr<T> imp)
     128        {
     129            return convertToV8Object(type, imp.get());
     130        }
     131
     132        static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType, void*);
     133
     134        // Fast-path for Node objects.
     135        static v8::Handle<v8::Value> convertNodeToV8Object(PassRefPtr<Node> node)
     136        {
     137            return convertNodeToV8Object(node.get());
     138        }
     139
     140        static v8::Handle<v8::Value> convertNodeToV8Object(Node*);
     141
     142        static v8::Handle<v8::Value> convertDocumentToV8Object(Document*);
     143
     144        static v8::Handle<v8::Value> convertNewNodeToV8Object(PassRefPtr<Node> node)
     145        {
     146            return convertNewNodeToV8Object(node.get());
     147        }
     148
     149        static v8::Handle<v8::Value> convertNewNodeToV8Object(Node* node)
     150        {
     151            return convertNewNodeToV8Object(node, 0, getDOMNodeMap());
     152        }
     153
     154        static v8::Handle<v8::Value> convertNewNodeToV8Object(Node*, V8Proxy*, DOMNodeMapping&);
     155
    125156        static V8ClassIndex::V8WrapperType domWrapperType(v8::Handle<v8::Object>);
    126157
     158        static v8::Handle<v8::Value> convertEventToV8Object(PassRefPtr<Event> event)
     159        {
     160            return convertEventToV8Object(event.get());
     161        }
     162
     163        static v8::Handle<v8::Value> convertEventToV8Object(Event*);
     164
    127165        static v8::Handle<v8::Value> convertEventTargetToV8Object(PassRefPtr<EventTarget> eventTarget)
    128166        {
     
    131169
    132170        static v8::Handle<v8::Value> convertEventTargetToV8Object(EventTarget*);
     171
     172        // Wrap and unwrap JS event listeners.
     173        static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext* context, PassRefPtr<EventListener> eventListener)
     174        {
     175            return convertEventListenerToV8Object(context, eventListener.get());
     176        }
     177
     178        static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext*, EventListener*);
    133179
    134180        static PassRefPtr<EventListener> getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
     
    166212        }
    167213#endif
     214        // DOMImplementation is a singleton and it is handled in a special
     215        // way. A wrapper is generated per document and stored in an
     216        // internal field of the document.
     217        static v8::Handle<v8::Value> convertDOMImplementationToV8Object(DOMImplementation*);
    168218
    169219        // Wrap JS node filter in C++.
     
    184234        static bool isWrapperOfType(v8::Handle<v8::Value>, V8ClassIndex::V8WrapperType);
    185235
     236        // Check whether a V8 value is a DOM Event wrapper.
     237        static bool isDOMEventWrapper(v8::Handle<v8::Value>);
     238
     239        static v8::Handle<v8::Value> convertStyleSheetToV8Object(StyleSheet*);
     240        static v8::Handle<v8::Value> convertCSSValueToV8Object(CSSValue*);
     241        static v8::Handle<v8::Value> convertCSSRuleToV8Object(CSSRule*);
     242        // Returns the JS wrapper of a window object, initializes the environment
     243        // of the window frame if needed.
     244        static v8::Handle<v8::Value> convertWindowToV8Object(DOMWindow*);
     245        static v8::Handle<v8::Value> convertNamedNodeMapToV8Object(NamedNodeMap*);
     246
     247#if ENABLE(SVG)
     248        static v8::Handle<v8::Value> convertSVGElementInstanceToV8Object(SVGElementInstance*);
     249        static v8::Handle<v8::Value> convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType, void*);
     250#endif
     251
    186252#if ENABLE(3D_CANVAS)
    187253        static void setIndexedPropertiesToExternalArray(v8::Handle<v8::Object>,
     
    190256                                                        int);
    191257#endif
     258
     259        static V8ClassIndex::V8WrapperType htmlElementType(HTMLElement*);
     260#if ENABLE(SVG)
     261        static V8ClassIndex::V8WrapperType svgElementType(SVGElement*);
     262#endif
    192263        // Set hidden references in a DOMWindow object of a frame.
    193264        static void setHiddenWindowReference(Frame*, const int internalIndex, v8::Handle<v8::Object>);
    194265
    195         static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl);
     266        static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl)
     267        {
     268            return instantiateV8Object(proxy, type, type, impl);
     269        }
    196270
    197271        static v8::Handle<v8::Object> getWrapper(Node*);
     272
     273    private:
     274
     275        // The first V8WrapperType specifies the function descriptor
     276        // used to create JS object. The second V8WrapperType specifies
     277        // the actual type of the void* for type casting.
     278        // For example, a HTML element has HTMLELEMENT for the first V8WrapperType, but always
     279        // use NODE as the second V8WrapperType. JS wrapper stores the second
     280        // V8WrapperType and the void* as internal fields.
     281        static v8::Local<v8::Object> instantiateV8Object(V8ClassIndex::V8WrapperType descType, V8ClassIndex::V8WrapperType cptrType, void* impl)
     282        {
     283            return instantiateV8Object(NULL, descType, cptrType, impl);
     284        }
     285
     286        static v8::Local<v8::Object> instantiateV8Object(V8Proxy*, V8ClassIndex::V8WrapperType, V8ClassIndex::V8WrapperType, void*);
    198287    };
    199288
  • trunk/WebCore/bindings/v8/V8NodeFilterCondition.cpp

    r54259 r54278  
    3535#include "NodeFilter.h"
    3636#include "ScriptState.h"
    37 #include "V8Node.h"
    3837#include "V8Proxy.h"
    3938
     
    7170    v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(m_filter);
    7271    OwnArrayPtr<v8::Handle<v8::Value> > args(new v8::Handle<v8::Value>[1]);
    73     args[0] = toV8(node);
     72    args[0] = V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
    7473
    7574    V8Proxy* proxy = V8Proxy::retrieve();
  • trunk/WebCore/bindings/v8/V8Proxy.cpp

    r54259 r54278  
    4747#include "V8Collection.h"
    4848#include "V8ConsoleMessage.h"
    49 #include "V8DOMCoreException.h"
     49#include "V8CustomBinding.h"
    5050#include "V8DOMMap.h"
    5151#include "V8DOMWindow.h"
    52 #include "V8EventException.h"
    5352#include "V8HiddenPropertyName.h"
    5453#include "V8Index.h"
    5554#include "V8IsolatedContext.h"
    56 #include "V8RangeException.h"
    57 #include "V8SVGException.h"
    58 #include "V8XMLHttpRequestException.h"
    59 #include "V8XPathException.h"
    6055#include "WorkerContextExecutionProxy.h"
    6156
     
    613608    switch (description.type) {
    614609    case DOMExceptionType:
    615         exception = toV8(DOMCoreException::create(description));
     610        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMCOREEXCEPTION, DOMCoreException::create(description));
    616611        break;
    617612    case RangeExceptionType:
    618         exception = toV8(RangeException::create(description));
     613        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::RANGEEXCEPTION, RangeException::create(description));
    619614        break;
    620615    case EventExceptionType:
    621         exception = toV8(EventException::create(description));
     616        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::EVENTEXCEPTION, EventException::create(description));
    622617        break;
    623618    case XMLHttpRequestExceptionType:
    624         exception = toV8(XMLHttpRequestException::create(description));
     619        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XMLHTTPREQUESTEXCEPTION, XMLHttpRequestException::create(description));
    625620        break;
    626621#if ENABLE(SVG)
    627622    case SVGExceptionType:
    628         exception = toV8(SVGException::create(description));
     623        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGEXCEPTION, SVGException::create(description));
    629624        break;
    630625#endif
    631626#if ENABLE(XPATH)
    632627    case XPathExceptionType:
    633         exception = toV8(XPathException::create(description));
     628        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHEXCEPTION, XPathException::create(description));
    634629        break;
    635630#endif
  • trunk/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp

    r54259 r54278  
    5454{
    5555    if (style->canvasGradient())
    56         return toV8(style->canvasGradient());
     56        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASGRADIENT, style->canvasGradient());
    5757
    5858    if (style->canvasPattern())
    59         return toV8(style->canvasPattern());
     59        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, style->canvasPattern());
    6060
    6161    return v8String(style->color());
     
    349349            return notHandledByInterceptor();
    350350        }
    351         return toV8(pattern.release());
     351        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release());
    352352    }
    353353
     
    360360            return notHandledByInterceptor();
    361361        }
    362         return toV8(pattern.release());
     362        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release());
    363363    }
    364364
  • trunk/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp

    r54259 r54278  
    2929#include "Frame.h"
    3030#include "V8CustomVoidCallback.h"  // For invokeCallback
    31 #include "V8Geoposition.h"
    3231
    3332namespace WebCore {
     
    5554
    5655    v8::Handle<v8::Value> argv[] = {
    57         toV8(position)
     56        V8DOMWrapper::convertToV8Object(V8ClassIndex::GEOPOSITION, position)
    5857    };
    5958
  • trunk/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp

    r54259 r54278  
    2929#include "Frame.h"
    3030#include "V8CustomVoidCallback.h"  // For invokeCallback
    31 #include "V8PositionError.h"
    3231
    3332namespace WebCore {
     
    5554
    5655    v8::Handle<v8::Value> argv[] = {
    57         toV8(error)
     56        V8DOMWrapper::convertToV8Object(V8ClassIndex::POSITIONERROR, error)
    5857    };
    5958
  • trunk/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp

    r54259 r54278  
    3737#include "Frame.h"
    3838#include "V8CustomVoidCallback.h"
    39 #include "V8SQLResultSet.h"
    40 #include "V8SQLTransaction.h"
    4139
    4240namespace WebCore {
     
    6462
    6563    v8::Handle<v8::Value> argv[] = {
    66         toV8(transaction),
    67         toV8(resultSet)
     64        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
     65        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLRESULTSET, resultSet)
    6866    };
    6967
  • trunk/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp

    r54259 r54278  
    3737#include "Frame.h"
    3838#include "V8CustomVoidCallback.h"
    39 #include "V8SQLError.h"
    40 #include "V8SQLTransaction.h"
    4139
    4240namespace WebCore {
     
    6462
    6563    v8::Handle<v8::Value> argv[] = {
    66         toV8(transaction),
    67         toV8(error)
     64        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
     65        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error)
    6866    };
    6967
  • trunk/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp

    r54259 r54278  
    3737#include "Frame.h"
    3838#include "V8CustomVoidCallback.h"
    39 #include "V8SQLTransaction.h"
    4039
    4140namespace WebCore {
     
    6463
    6564    v8::Handle<v8::Value> argv[] = {
    66         toV8(transaction)
     65        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction)
    6766    };
    6867
  • trunk/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp

    r54259 r54278  
    3737#include "Frame.h"
    3838#include "V8CustomVoidCallback.h"
    39 #include "V8SQLError.h"
    4039
    4140namespace WebCore {
     
    6362
    6463    v8::Handle<v8::Value> argv[] = {
    65         toV8(error)
     64        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error)
    6665    };
    6766
  • trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r54259 r54278  
    5858#include "V8CustomBinding.h"
    5959#include "V8CustomEventListener.h"
    60 #include "V8HTMLCollection.h"
    6160#include "V8MessagePortCustom.h"
    62 #include "V8Node.h"
    6361#include "V8Proxy.h"
    6462#include "V8Utilities.h"
     
    711709            frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, userGesture);
    712710        }
    713         return toV8(frame->domWindow());
     711        return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
    714712    }
    715713
     
    771769        return v8::Undefined();
    772770
    773     return toV8(frame->domWindow());
     771    return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
    774772}
    775773
     
    789787    Frame* child = frame->tree()->child(index);
    790788    if (child)
    791         return toV8(child->domWindow());
     789        return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
    792790
    793791    return notHandledByInterceptor();
     
    812810    Frame* child = frame->tree()->child(propName);
    813811    if (child)
    814         return toV8(child->domWindow());
     812        return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
    815813
    816814    // Search IDL functions defined in the prototype
     
    827825            if (items->length() >= 1) {
    828826                if (items->length() == 1)
    829                     return toV8(items->firstItem());
    830                 return toV8(items.release());
     827                    return V8DOMWrapper::convertNodeToV8Object(items->firstItem());
     828                return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release());
    831829            }
    832830        }
  • trunk/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp

    r54259 r54278  
    5858    if (!result)
    5959        return notHandledByInterceptor();
    60     return toV8(result);
     60    return V8DOMWrapper::convertToV8Object(V8ClassIndex::DATAGRIDCOLUMN, result);
    6161}
    6262   
  • trunk/WebCore/bindings/v8/custom/V8DocumentCustom.cpp

    r54259 r54278  
    3838#include "XPathNSResolver.h"
    3939#include "XPathResult.h"
     40#include "CanvasRenderingContext.h"
    4041
    4142#include "V8Binding.h"
    42 #include "V8CanvasRenderingContext2D.h"
     43#include "V8CustomBinding.h"
    4344#include "V8CustomXPathNSResolver.h"
    44 #include "V8DOMImplementation.h"
    4545#include "V8HTMLDocument.h"
    4646#include "V8IsolatedContext.h"
     
    4848#include "V8Proxy.h"
    4949#include "V8SVGDocument.h"
    50 #include "V8WebGLRenderingContext.h"
    5150#include "V8XPathNSResolver.h"
    5251#include "V8XPathResult.h"
     
    8483        return throwError(ec);
    8584
    86     return toV8(result.release());
     85    return V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHRESULT, result.release());
    8786}
    8887
     
    10099        return v8::Undefined();
    101100    if (result->is2d())
    102         return toV8(static_cast<CanvasRenderingContext2D*>(result));
     101        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
    103102#if ENABLE(3D_CANVAS)
    104103    else if (result->is3d())
    105         return toV8(static_cast<WebGLRenderingContext*>(result));
     104        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result);
    106105#endif // ENABLE(3D_CANVAS)
    107106    ASSERT_NOT_REACHED();
     
    129128    // Generate a wrapper.
    130129    Document* document = V8Document::toNative(info.Holder());
    131     v8::Handle<v8::Value> wrapper = toV8(document->implementation());
     130    v8::Handle<v8::Value> wrapper = V8DOMWrapper::convertDOMImplementationToV8Object(document->implementation());
    132131
    133132    // Store the wrapper in the internal field.
  • trunk/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp

    r54259 r54278  
    2828#include "Frame.h"
    2929#include "V8Binding.h"
    30 #include "V8Location.h"
     30#include "V8CustomBinding.h"
     31#include "V8Document.h"
    3132#include "V8Proxy.h"
    3233
     
    4041
    4142    DOMWindow* window = document->frame()->domWindow();
    42     return toV8(window->location());
     43    return V8DOMWrapper::convertToV8Object(V8ClassIndex::LOCATION, window->location());
    4344}
    4445
  • trunk/WebCore/bindings/v8/custom/V8ElementCustom.cpp

    r54259 r54278  
    8888        throwError(ec);
    8989
    90     return toV8(result.release());
     90    return V8DOMWrapper::convertNodeToV8Object(result.release());
    9191}
    9292
     
    127127        throwError(ec);
    128128
    129     return toV8(result.release());
     129    return V8DOMWrapper::convertNodeToV8Object(result.release());
    130130}
    131131
  • trunk/WebCore/bindings/v8/custom/V8EventCustom.cpp

    r54259 r54278  
    3737#include "V8BeforeLoadEvent.h"
    3838#include "V8Binding.h"
    39 #include "V8Clipboard.h"
    4039#include "V8CompositionEvent.h"
     40#include "V8CustomBinding.h"
    4141#include "V8ErrorEvent.h"
    4242#include "V8KeyboardEvent.h"
     
    7171
    7272    if (event->isDragEvent())
    73         return toV8(static_cast<MouseEvent*>(event)->clipboard());
     73        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<MouseEvent*>(event)->clipboard());
    7474
    7575    return v8::Undefined();
     
    8181
    8282    if (event->isClipboardEvent())
    83         return toV8(static_cast<ClipboardEvent*>(event)->clipboard());
     83        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<ClipboardEvent*>(event)->clipboard());
    8484
    8585    return v8::Undefined();
  • trunk/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp

    r54259 r54278  
    3737#include "V8CustomBinding.h"
    3838#include "V8NamedNodesCollection.h"
    39 #include "V8Node.h"
    40 #include "V8NodeList.h"
    4139#include "V8Proxy.h"
    4240
     
    5250
    5351    if (namedItems.size() == 1)
    54         return toV8(namedItems.at(0).release());
     52        return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
    5553
    5654    NodeList* list = new V8NamedNodesCollection(namedItems);
    57     return toV8(list);
     55    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
    5856}
    5957
     
    7169
    7270    RefPtr<Node> result = collection->item(index->Uint32Value());
    73     return toV8(result.release());
     71    return V8DOMWrapper::convertNodeToV8Object(result.release());
    7472}
    7573
     
    133131    while (node) {
    134132        if (!current)
    135             return toV8(node);
     133            return V8DOMWrapper::convertNodeToV8Object(node);
    136134
    137135        node = imp->nextNamedItem(name);
  • trunk/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp

    r54259 r54278  
    3737#include "HTMLNames.h"
    3838#include "V8Binding.h"
    39 #include "V8Document.h"
    4039#include "V8HTMLAudioElement.h"
    4140#include "V8Proxy.h"
     
    8079    // Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance
    8180    // may end up being the only node in the map and get garbage-ccollected prematurely.
    82     toV8(document);
     81    V8DOMWrapper::convertNodeToV8Object(document);
    8382
    8483    RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document);
  • trunk/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp

    r54259 r54278  
    3737#include "WebGLContextAttributes.h"
    3838#include "V8Binding.h"
    39 #include "V8CanvasRenderingContext2D.h"
     39#include "V8CustomBinding.h"
    4040#include "V8Node.h"
    4141#include "V8Proxy.h"
    42 #include "V8WebGLRenderingContext.h"
    4342
    4443namespace WebCore {
     
    7978        return v8::Undefined();
    8079    if (result->is2d())
    81         return toV8(static_cast<CanvasRenderingContext2D*>(result));
     80        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
    8281#if ENABLE(3D_CANVAS)
    8382    else if (result->is3d())
    84         return toV8(static_cast<WebGLRenderingContext*>(result));
     83        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result);
    8584#endif
    8685    ASSERT_NOT_REACHED();
  • trunk/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp

    r54259 r54278  
    3737#include "V8HTMLAllCollection.h"
    3838#include "V8NamedNodesCollection.h"
    39 #include "V8Node.h"
    40 #include "V8NodeList.h"
    4139#include "V8Proxy.h"
    4240
     
    5250
    5351    if (namedItems.size() == 1)
    54         return toV8(namedItems.at(0).release());
     52        return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
    5553
    5654    NodeList* list = new V8NamedNodesCollection(namedItems);
    57     return toV8(list);
     55    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
    5856}
    5957
     
    7169
    7270    RefPtr<Node> result = collection->item(index->Uint32Value());
    73     return toV8(result.release());
     71    return V8DOMWrapper::convertNodeToV8Object(result.release());
    7472}
    7573
     
    133131    while (node) {
    134132        if (!current)
    135             return toV8(node);
     133            return V8DOMWrapper::convertNodeToV8Object(node);
    136134
    137135        node = imp->nextNamedItem(name);
  • trunk/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp

    r54259 r54278  
    3939#include "HTMLNames.h"
    4040#include "V8Binding.h"
    41 #include "V8DOMWindow.h"
    42 #include "V8HTMLAllCollection.h"
    43 #include "V8HTMLCollection.h"
    4441#include "V8IsolatedContext.h"
    45 #include "V8Node.h"
    4642#include "V8Proxy.h"
    4743#include <wtf/RefPtr.h>
     
    9793        Frame* frame = 0;
    9894        if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
    99             return toV8(frame->domWindow());
    100 
    101         return toV8(node);
    102     }
    103 
    104     return toV8(items.release());
     95            return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
     96
     97        return V8DOMWrapper::convertNodeToV8Object(node);
     98    }
     99
     100    return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release());
    105101}
    106102
     
    187183{
    188184    INC_STATS("DOM.HTMLDocument.all._get");
     185    v8::HandleScope scope;
    189186    v8::Handle<v8::Object> holder = info.Holder();
    190187    HTMLDocument* htmlDocument = V8HTMLDocument::toNative(holder);
    191     return toV8(htmlDocument->all());
     188    return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, htmlDocument->all());
    192189}
    193190
  • trunk/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp

    r54259 r54278  
    3535#include "HTMLFormElement.h"
    3636#include "V8Binding.h"
     37#include "V8CustomBinding.h"
    3738#include "V8NamedNodesCollection.h"
    38 #include "V8Node.h"
    39 #include "V8NodeList.h"
    4039#include "V8Proxy.h"
    4140
     
    5049    if (!formElement)
    5150        return notHandledByInterceptor();
    52     return toV8(formElement.release());
     51    return V8DOMWrapper::convertNodeToV8Object(formElement.release());
    5352}
    5453
     
    7675
    7776    if (elements.size() == 1)
    78         return toV8(elements.at(0).release());
     77        return V8DOMWrapper::convertNodeToV8Object(elements.at(0).release());
    7978
    8079    NodeList* collection = new V8NamedNodesCollection(elements);
    81     return toV8(collection);
     80    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, collection);
    8281}
    8382
  • trunk/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp

    r54259 r54278  
    4141
    4242#include "V8Binding.h"
    43 #include "V8DOMWindow.h"
     43#include "V8CustomBinding.h"
    4444#include "V8Proxy.h"
    4545
     
    5656            return v8::Undefined();
    5757        if (Frame* frame = doc->frame())
    58             return toV8(frame->domWindow());
     58            return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
    5959    }
    6060    return notHandledByInterceptor();
  • trunk/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp

    r54259 r54278  
    3737#include "HTMLNames.h"
    3838#include "V8Binding.h"
    39 #include "V8Document.h"
    4039#include "V8HTMLImageElement.h"
    4140#include "V8Proxy.h"
     
    8079    // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
    8180    // may end up being the only node in the map and get garbage-ccollected prematurely.
    82     toV8(document);
     81    V8DOMWrapper::convertNodeToV8Object(document);
    8382
    8483    RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document);
  • trunk/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp

    r54259 r54278  
    3838#include "V8Binding.h"
    3939#include "V8Collection.h"
     40#include "V8CustomBinding.h"
    4041#include "V8HTMLOptionElement.h"
    4142#include "V8HTMLSelectElementCustom.h"
    42 #include "V8Node.h"
    4343#include "V8Proxy.h"
    4444
     
    124124        return notHandledByInterceptor();
    125125
    126     return toV8(result.release());
     126    return V8DOMWrapper::convertNodeToV8Object(result.release());
    127127}
    128128
  • trunk/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp

    r54259 r54278  
    3838#include "V8Binding.h"
    3939#include "V8Collection.h"
     40#include "V8CustomBinding.h"
    4041#include "V8HTMLOptionElement.h"
    4142#include "V8HTMLSelectElement.h"
    4243#include "V8NamedNodesCollection.h"
    43 #include "V8Node.h"
    44 #include "V8NodeList.h"
    4544#include "V8Proxy.h"
    4645
     
    6968
    7069    if (items.size() == 1)
    71         return toV8(items.at(0).release());
     70        return V8DOMWrapper::convertNodeToV8Object(items.at(0).release());
    7271
    7372    NodeList* list = new V8NamedNodesCollection(items);
    74     return toV8(list);
     73    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
    7574}
    7675
     
    8281        return notHandledByInterceptor();
    8382
    84     return toV8(result.release());
     83    return V8DOMWrapper::convertNodeToV8Object(result.release());
    8584}
    8685
  • trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

    r54259 r54278  
    4141
    4242#include "V8Binding.h"
     43#include "V8CustomBinding.h"
    4344#include "V8Database.h"
    4445#include "V8Node.h"
     
    8586
    8687    // Call custom code to create InjectedScripHost wrapper specific for the context
    87     // instead of calling toV8() that would create the
     88    // instead of calling V8DOMWrapper::convertToV8Object that would create the
    8889    // wrapper in the current context.
    8990    // FIXME: make it possible to use generic bindings factory for InjectedScriptHost.
     
    130131        return v8::Undefined();
    131132
    132     return toV8(node);
     133    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
    133134}
    134135
     
    160161    if (!database)
    161162        return v8::Undefined();
    162     return toV8(database);
     163    return V8DOMWrapper::convertToV8Object<Database>(V8ClassIndex::DATABASE, database);
    163164}
    164165
  • trunk/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp

    r54259 r54278  
    3636#include "MessageChannel.h"
    3737#include "V8Binding.h"
    38 #include "V8MessagePort.h"
    3938#include "V8Proxy.h"
    4039#include "V8Utilities.h"
     
    6867    // MessagePort wrappers to make sure that the MessagePort wrappers
    6968    // stay alive as long as the MessageChannel wrapper is around.
    70     messageChannel->SetInternalField(V8MessageChannel::port1Index, toV8(obj->port1()));
    71     messageChannel->SetInternalField(V8MessageChannel::port2Index, toV8(obj->port2()));
     69    messageChannel->SetInternalField(V8MessageChannel::port1Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port1()));
     70    messageChannel->SetInternalField(V8MessageChannel::port2Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port2()));
    7271
    7372    // Setup the standard wrapper object internal fields.
  • trunk/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp

    r54259 r54278  
    3636
    3737#include "V8Binding.h"
     38#include "V8CustomBinding.h"
    3839#include "V8DOMWindow.h"
    39 #include "V8MessagePort.h"
    4040#include "V8MessagePortCustom.h"
    4141#include "V8Proxy.h"
     
    5454    v8::Local<v8::Array> portArray = v8::Array::New(ports->size());
    5555    for (size_t i = 0; i < ports->size(); ++i)
    56         portArray->Set(v8::Integer::New(i), toV8((*ports)[i].get()));
     56        portArray->Set(v8::Integer::New(i), V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, (*ports)[i].get()));
    5757
    5858    return portArray;
  • trunk/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp

    r54259 r54278  
    3434#include "NamedNodeMap.h"
    3535#include "V8Binding.h"
     36#include "V8CustomBinding.h"
    3637#include "V8Element.h"
    37 #include "V8Node.h"
    3838#include "V8Proxy.h"
    3939
     
    5050        return notHandledByInterceptor();
    5151
    52     return toV8(result.release());
     52    return V8DOMWrapper::convertNodeToV8Object(result.release());
    5353}
    5454
     
    7171        return notHandledByInterceptor();
    7272
    73     return toV8(result.release());
     73    return V8DOMWrapper::convertNodeToV8Object(result.release());
    7474}
    7575
  • trunk/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp

    r54259 r54278  
    3636
    3737#include "V8Binding.h"
    38 #include "V8Node.h"
     38#include "V8CustomBinding.h"
    3939#include "V8Proxy.h"
    4040
     
    5555        return v8::Null();
    5656
    57     return toV8(object);
     57    return V8DOMWrapper::convertNodeToV8Object(object);
    5858}
    5959
  • trunk/WebCore/bindings/v8/custom/V8NodeListCustom.cpp

    r54259 r54278  
    3333
    3434#include "NodeList.h"
     35
    3536#include "V8Binding.h"
    36 #include "V8Node.h"
     37#include "V8CustomBinding.h"
    3738#include "V8Proxy.h"
    3839
     
    5758        return notHandledByInterceptor();
    5859
    59     return toV8(result.release());
     60    return V8DOMWrapper::convertNodeToV8Object(result.release());
    6061}
    6162
     
    7576
    7677    RefPtr<Node> result = list->item(index->Uint32Value());
    77     return toV8(result.release());
     78    return V8DOMWrapper::convertNodeToV8Object(result.release());
    7879}
    7980
  • trunk/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp

    r54259 r54278  
    3838#include "NotificationCenter.h"
    3939#include "V8Binding.h"
     40#include "V8CustomBinding.h"
    4041#include "V8CustomEventListener.h"
    4142#include "V8CustomVoidCallback.h"
     
    9596        return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
    9697
    97     return toV8(notification.get());
     98    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
    9899}
    99100
     
    112113        return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
    113114
    114     return toV8(notification.get());
     115    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
    115116}
    116117
  • trunk/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp

    r54259 r54278  
    3232
    3333#if ENABLE(SVG)
     34
    3435#include "TransformationMatrix.h"
    3536
    3637#include "SVGException.h"
     38
    3739#include "V8Binding.h"
    38 #include "V8Proxy.h"
     40#include "V8CustomBinding.h"
    3941#include "V8SVGMatrix.h"
    4042#include "V8SVGPODTypeWrapper.h"
     43#include "V8Proxy.h"
    4144
    4245namespace WebCore {
     
    5457    TransformationMatrix m2 = *V8SVGPODTypeWrapper<TransformationMatrix>::toNative(v8::Handle<v8::Object>::Cast(args[0]));
    5558
    56     RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2));
    57     return toV8(wrapper.get());
     59    return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2)));
    5860}
    5961
     
    7375    }
    7476
    75     RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result);
    76     return toV8(wrapper.get());
     77    return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result));
    7778}
    7879
     
    9495    }
    9596
    96     RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result);
    97     return toV8(wrapper.get());
     97    return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result));
    9898}
    9999
  • trunk/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp

    r54259 r54278  
    3535#include "StyleSheetList.h"
    3636#include "V8Binding.h"
     37#include "V8CustomBinding.h"
    3738#include "V8Proxy.h"
    38 #include "V8StyleSheet.h"
    3939
    4040namespace WebCore {
     
    5353        return notHandledByInterceptor();
    5454
    55     return toV8(item->sheet());
     55    return V8DOMWrapper::convertToV8Object(V8ClassIndex::STYLESHEET, item->sheet());
    5656}
    5757
  • trunk/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp

    r54259 r54278  
    3737
    3838#include "V8Binding.h"
    39 #include "V8Node.h"
     39#include "V8CustomBinding.h"
    4040#include "V8Proxy.h"
    4141
     
    5353        return v8::Null();
    5454
    55     return toV8(object);
     55    return V8DOMWrapper::convertNodeToV8Object(object);
    5656}
    5757
  • trunk/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp

    r54259 r54278  
    4343#include "V8Binding.h"
    4444#include "V8WebGLArray.h"
    45 #include "V8WebGLBuffer.h"
    4645#include "V8WebGLByteArray.h"
    4746#include "V8WebGLFloatArray.h"
    48 #include "V8WebGLFramebuffer.h"
    4947#include "V8WebGLIntArray.h"
    5048#include "V8WebGLProgram.h"
    51 #include "V8WebGLRenderbuffer.h"
    5249#include "V8WebGLShader.h"
    5350#include "V8WebGLShortArray.h"
    54 #include "V8WebGLTexture.h"
    5551#include "V8WebGLUniformLocation.h"
    5652#include "V8WebGLUnsignedByteArray.h"
     
    196192        return v8::Integer::NewFromUnsigned(info.getUnsignedLong());
    197193    case WebGLGetInfo::kTypeWebGLBuffer:
    198         return toV8(info.getWebGLBuffer());
     194        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLBUFFER, info.getWebGLBuffer());
    199195    case WebGLGetInfo::kTypeWebGLFloatArray:
    200         return toV8(info.getWebGLFloatArray());
     196        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFLOATARRAY, info.getWebGLFloatArray());
    201197    case WebGLGetInfo::kTypeWebGLFramebuffer:
    202         return toV8(info.getWebGLFramebuffer());
     198        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFRAMEBUFFER, info.getWebGLFramebuffer());
    203199    case WebGLGetInfo::kTypeWebGLIntArray:
    204         return toV8(info.getWebGLIntArray());
     200        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLINTARRAY, info.getWebGLIntArray());
    205201    // FIXME: implement WebGLObjectArray
    206202    // case WebGLGetInfo::kTypeWebGLObjectArray:
    207203    case WebGLGetInfo::kTypeWebGLProgram:
    208         return toV8(info.getWebGLProgram());
     204        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLPROGRAM, info.getWebGLProgram());
    209205    case WebGLGetInfo::kTypeWebGLRenderbuffer:
    210         return toV8(info.getWebGLRenderbuffer());
     206        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERBUFFER, info.getWebGLRenderbuffer());
    211207    case WebGLGetInfo::kTypeWebGLTexture:
    212         return toV8(info.getWebGLTexture());
     208        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLTEXTURE, info.getWebGLTexture());
    213209    case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
    214         return toV8(info.getWebGLUnsignedByteArray());
     210        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY, info.getWebGLUnsignedByteArray());
    215211    default:
    216212        notImplemented();
  • trunk/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp

    r54259 r54278  
    3737
    3838#include "V8Binding.h"
     39#include "V8CustomBinding.h"
    3940#include "V8Document.h"
    40 #include "V8DocumentFragment.h"
    4141#include "V8Node.h"
    4242#include "V8Proxy.h"
     
    7979    Document* owner = V8Document::toNative(v8::Handle<v8::Object>::Cast(args[1]));
    8080    RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner);
    81     return toV8(result.release());
     81    return V8DOMWrapper::convertNodeToV8Object(result.release());
    8282}
    8383
     
    100100        return v8::Undefined();
    101101
    102     return toV8(result.release());
     102    return V8DOMWrapper::convertNodeToV8Object(result.release());
    103103}
    104104
Note: See TracChangeset for help on using the changeset viewer.