[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8

hamaji at chromium.org hamaji at chromium.org
Wed Feb 10 22:10:52 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 5f8e88dcd2250fb866f74735cd18b2acd1188ca6
Author: hamaji at chromium.org <hamaji at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 3 13:02:13 2010 +0000

    2010-02-03  Shinichiro Hamaji  <hamaji at 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):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54278 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fa328c4..8fa9326 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,162 @@
+2010-02-03  Shinichiro Hamaji  <hamaji at 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):
+
 2010-02-03  Mikhail Naganov  <mnaganov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 3c64410..608221b 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -50,9 +50,7 @@
 #include "Settings.h"
 #include "V8Binding.h"
 #include "V8BindingState.h"
-#include "V8DOMWindow.h"
 #include "V8Event.h"
-#include "V8HTMLEmbedElement.h"
 #include "V8IsolatedContext.h"
 #include "V8NPObject.h"
 #include "V8Proxy.h"
@@ -171,9 +169,7 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
 
     v8::Handle<v8::Object> global = v8Context->Global();
     v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
-    if (jsEvent.IsEmpty() || !jsEvent->IsObject())
-        return false;
-    Event* event = V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent));
+    Event* event = V8DOMWrapper::isDOMEventWrapper(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
 
     // Based on code from kjs_bindings.cpp.
     // Note: This is more liberal than Firefox's implementation.
@@ -381,7 +377,7 @@ static NPObject* createScriptObject(Frame* frame)
 
     v8::Context::Scope scope(v8Context);
     DOMWindow* window = frame->domWindow();
-    v8::Handle<v8::Value> global = toV8(window);
+    v8::Handle<v8::Value> global = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, window);
     ASSERT(global->IsObject());
     return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), window);
 }
@@ -418,7 +414,7 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
     v8::Context::Scope scope(v8Context);
 
     DOMWindow* window = m_frame->domWindow();
-    v8::Handle<v8::Value> v8plugin = toV8(static_cast<HTMLEmbedElement*>(plugin));
+    v8::Handle<v8::Value> v8plugin = V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLEMBEDELEMENT, plugin);
     if (!v8plugin->IsObject())
         return createNoScriptObject();
 
diff --git a/WebCore/bindings/v8/ScriptObject.cpp b/WebCore/bindings/v8/ScriptObject.cpp
index 0fcd16f..8d80d34 100644
--- a/WebCore/bindings/v8/ScriptObject.cpp
+++ b/WebCore/bindings/v8/ScriptObject.cpp
@@ -36,10 +36,9 @@
 
 #include "Document.h"
 #include "Frame.h"
+#include "InspectorBackend.h"
+#include "InspectorFrontendHost.h"
 #include "V8Binding.h"
-#include "V8InjectedScriptHost.h"
-#include "V8InspectorBackend.h"
-#include "V8InspectorFrontendHost.h"
 #include "V8Proxy.h"
 
 #include <v8.h>
@@ -145,21 +144,21 @@ bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const S
 bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorBackend* value)
 {
     ScriptScope scope(scriptState);
-    scope.global()->Set(v8::String::New(name), toV8(value));
+    scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORBACKEND, value));
     return scope.success();
 }
 
 bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorFrontendHost* value)
 {
     ScriptScope scope(scriptState);
-    scope.global()->Set(v8::String::New(name), toV8(value));
+    scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORFRONTENDHOST, value));
     return scope.success();
 }
 
 bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InjectedScriptHost* value)
 {
     ScriptScope scope(scriptState);
-    scope.global()->Set(v8::String::New(name), toV8(value));
+    scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INJECTEDSCRIPTHOST, value));
     return scope.success();
 }
 #endif
diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp
index 944fd57..0f5b5c8 100644
--- a/WebCore/bindings/v8/V8AbstractEventListener.cpp
+++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp
@@ -36,7 +36,6 @@
 #include "Event.h"
 #include "Frame.h"
 #include "V8Binding.h"
-#include "V8Event.h"
 #include "V8EventListenerList.h"
 #include "V8Proxy.h"
 #include "V8Utilities.h"
@@ -85,7 +84,7 @@ void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event
     v8::Context::Scope scope(v8Context);
 
     // Get the V8 wrapper for the event object.
-    v8::Handle<v8::Value> jsEvent = toV8(event);
+    v8::Handle<v8::Value> jsEvent = V8DOMWrapper::convertEventToV8Object(event);
 
     invokeEventHandler(context, event, jsEvent);
 
diff --git a/WebCore/bindings/v8/V8Collection.h b/WebCore/bindings/v8/V8Collection.h
index 9611571..78bc69a 100644
--- a/WebCore/bindings/v8/V8Collection.h
+++ b/WebCore/bindings/v8/V8Collection.h
@@ -38,149 +38,154 @@
 #include <v8.h>
 
 namespace WebCore {
-// FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param).
-// See https://bugs.webkit.org/show_bug.cgi?id=24664.
-
-template<class T> static v8::Handle<v8::Value> getV8Object(T* implementation)
-{
-    if (!implementation)
-        return v8::Handle<v8::Value>();
-    return toV8(implementation);
-}
-
-template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object)
-{
-    return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
-}
-
-template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation)
-{
-    return getV8Object(implementation.get());
-}
-
-// Returns named property of a collection.
-template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object)
-{
-    // FIXME: assert object is a collection type
-    ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
-    ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
-    Collection* collection = toNativeCollection<Collection>(object);
-    AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name);
-    return getV8Object<ItemType>(collection->namedItem(propertyName));
-}
-
-// A template of named property accessor of collections.
-template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
-    v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
-
-    if (!value.IsEmpty())
-        return value;
-
-    // Search local callback properties next to find IDL defined
-    // properties.
-    if (info.Holder()->HasRealNamedCallbackProperty(name))
-        return notHandledByInterceptor();
-    return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder());
-}
-
-// Returns the property at the index of a collection.
-template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object)
-{
-    // FIXME: Assert that object must be a collection type.
-    ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
-    ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
-    Collection* collection = toNativeCollection<Collection>(object);
-    return getV8Object<ItemType>(collection->item(index));
-}
-
-// A template of index interceptor of collections.
-template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
-{
-    return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder());
-}
-
-// Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement.
-template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
-{
-    ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
-    Collection* collection = toNativeCollection<Collection>(info.Holder());
-    int length = collection->length();
-    v8::Handle<v8::Array> properties = v8::Array::New(length);
-    for (int i = 0; i < length; ++i) {
-        // FIXME: Do we need to check that the item function returns a non-null value for this index?
-        v8::Handle<v8::Integer> integer = v8::Integer::New(i);
-        properties->Set(integer, integer);
+    // FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param).
+    // See https://bugs.webkit.org/show_bug.cgi?id=24664.
+
+    inline v8::Handle<v8::Value> getV8Object(void* implementation, v8::Local<v8::Value> implementationType)
+    {
+        if (!implementation)
+            return v8::Handle<v8::Value>();
+        V8ClassIndex::V8WrapperType type = V8ClassIndex::FromInt(implementationType->Int32Value());
+        if (type == V8ClassIndex::NODE)
+            return V8DOMWrapper::convertNodeToV8Object(static_cast<Node*>(implementation));
+        return V8DOMWrapper::convertToV8Object(type, implementation);
     }
-    return properties;
-}
-
-// Get an array containing the names of indexed properties in a collection.
-template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
-{
-    ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
-    Collection* collection = toNativeCollection<Collection>(info.Holder());
-    int length = collection->length();
-    v8::Handle<v8::Array> properties = v8::Array::New(length);
-    for (int i = 0; i < length; ++i) {
-        // FIXME: Do we need to check that the item function returns a non-null value for this index?
-        v8::Handle<v8::Integer> integer = v8::Integer::New(i);
-        properties->Set(integer, integer);
+
+    template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object)
+    {
+        return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
+    }
+
+    template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation, v8::Local<v8::Value> implementationType)
+    {
+        return getV8Object(implementation.get(), implementationType);
+    }
+
+    // Returns named property of a collection.
+    template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object,
+                                                                                                         v8::Local<v8::Value> implementationType)
+    {
+        // FIXME: assert object is a collection type
+        ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
+        ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
+        Collection* collection = toNativeCollection<Collection>(object);
+        AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name);
+        return getV8Object<ItemType>(collection->namedItem(propertyName), implementationType);
+    }
+
+    // A template of named property accessor of collections.
+    template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+    {
+        v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name);
+
+        if (!value.IsEmpty())
+            return value;
+
+        // Search local callback properties next to find IDL defined
+        // properties.
+        if (info.Holder()->HasRealNamedCallbackProperty(name))
+            return notHandledByInterceptor();
+        return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder(), info.Data());
     }
-    return properties;
-}
-
-
-// A template for indexed getters on collections of strings that should return null if the resulting string is a null string.
-template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
-{
-    // FIXME: assert that object must be a collection type
-    ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
-    Collection* collection = toNativeCollection<Collection>(info.Holder());
-    String result = collection->item(index);
-    return v8StringOrNull(result);
-}
-
-
-// A template for indexed getters on collections of strings.
-template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
-{
-    // FIXME: assert that object must be a collection type
-    ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
-    Collection* collection = toNativeCollection<Collection>(info.Holder());
-    String result = collection->item(index);
-    return v8String(result);
-}
-
-
-// Add indexed getter to the function template for a collection.
-template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
-{
-    desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>,
-                                                        v8::Integer::New(V8ClassIndex::ToInt(type)));
-}
-
-
-// Add named getter to the function template for a collection.
-template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
-{
-    desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type)));
-}
-
-// Add indexed getter returning a string or null to a function template for a collection.
-template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
-{
-    desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
-}
-
-
-// Add indexed getter returning a string to a function template for a collection.
-template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
-{
-    desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
-}
-
-v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
+
+    // Returns the property at the index of a collection.
+    template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object,
+                                                                                                           v8::Local<v8::Value> implementationType)
+    {
+        // FIXME: Assert that object must be a collection type.
+        ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
+        ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE);
+        Collection* collection = toNativeCollection<Collection>(object);
+        return getV8Object<ItemType>(collection->item(index), implementationType);
+    }
+
+    // A template of index interceptor of collections.
+    template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+    {
+        return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder(), info.Data());
+    }
+
+    // Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement.
+    template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
+    {
+        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+        Collection* collection = toNativeCollection<Collection>(info.Holder());
+        int length = collection->length();
+        v8::Handle<v8::Array> properties = v8::Array::New(length);
+        for (int i = 0; i < length; ++i) {
+            // FIXME: Do we need to check that the item function returns a non-null value for this index?
+            v8::Handle<v8::Integer> integer = v8::Integer::New(i);
+            properties->Set(integer, integer);
+        }
+        return properties;
+    }
+
+    // Get an array containing the names of indexed properties in a collection.
+    template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
+    {
+        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+        Collection* collection = toNativeCollection<Collection>(info.Holder());
+        int length = collection->length();
+        v8::Handle<v8::Array> properties = v8::Array::New(length);
+        for (int i = 0; i < length; ++i) {
+            // FIXME: Do we need to check that the item function returns a non-null value for this index?
+            v8::Handle<v8::Integer> integer = v8::Integer::New(i);
+            properties->Set(integer, integer);
+        }
+        return properties;
+    }
+
+
+    // A template for indexed getters on collections of strings that should return null if the resulting string is a null string.
+    template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+    {
+        // FIXME: assert that object must be a collection type
+        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+        Collection* collection = toNativeCollection<Collection>(info.Holder());
+        String result = collection->item(index);
+        return v8StringOrNull(result);
+    }
+
+
+    // A template for indexed getters on collections of strings.
+    template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+    {
+        // FIXME: assert that object must be a collection type
+        ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+        Collection* collection = toNativeCollection<Collection>(info.Holder());
+        String result = collection->item(index);
+        return v8String(result);
+    }
+
+
+    // Add indexed getter to the function template for a collection.
+    template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
+    {
+        desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>,
+                                                            v8::Integer::New(V8ClassIndex::ToInt(type)));
+    }
+
+
+    // Add named getter to the function template for a collection.
+    template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
+    {
+        desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type)));
+    }
+
+    // Add indexed getter returning a string or null to a function template for a collection.
+    template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
+    {
+        desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
+    }
+
+
+    // Add indexed getter returning a string to a function template for a collection.
+    template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
+    {
+        desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
+    }
+
+    v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
 
 } // namespace WebCore
 
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index b3fedf5..793547d 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -48,9 +48,9 @@
 #include "V8BindingState.h"
 #include "V8Collection.h"
 #include "V8ConsoleMessage.h"
+#include "V8CustomBinding.h"
 #include "V8DOMMap.h"
 #include "V8DOMWindow.h"
-#include "V8Document.h"
 #include "V8HiddenPropertyName.h"
 #include "V8History.h"
 #include "V8Index.h"
@@ -422,7 +422,7 @@ void V8DOMWindowShell::updateDocumentWrapperCache()
         return;
     }
 
-    v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document());
+    v8::Handle<v8::Value> documentWrapper = V8DOMWrapper::convertNodeToV8Object(m_frame->document());
 
     // If instantiation of the document wrapper fails, clear the cache
     // and let the DOMWindow accessor handle access to the document.
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index a715160..b9d0911 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -43,6 +43,7 @@
 #include "V8AbstractEventListener.h"
 #include "V8Binding.h"
 #include "V8Collection.h"
+#include "V8CustomBinding.h"
 #include "V8CustomEventListener.h"
 #include "V8DOMApplicationCache.h"
 #include "V8DOMMap.h"
@@ -83,6 +84,93 @@ namespace WebCore {
 typedef HashMap<Node*, v8::Object*> DOMNodeMap;
 typedef HashMap<void*, v8::Object*> DOMObjectMap;
 
+#if ENABLE(SVG)
+
+static V8ClassIndex::V8WrapperType downcastSVGPathSeg(void* pathSeg)
+{
+    SVGPathSeg* realPathSeg = reinterpret_cast<SVGPathSeg*>(pathSeg);
+
+    switch (realPathSeg->pathSegType()) {
+    case SVGPathSeg::PATHSEG_CLOSEPATH:                    return V8ClassIndex::SVGPATHSEGCLOSEPATH;
+    case SVGPathSeg::PATHSEG_MOVETO_ABS:                   return V8ClassIndex::SVGPATHSEGMOVETOABS;
+    case SVGPathSeg::PATHSEG_MOVETO_REL:                   return V8ClassIndex::SVGPATHSEGMOVETOREL;
+    case SVGPathSeg::PATHSEG_LINETO_ABS:                   return V8ClassIndex::SVGPATHSEGLINETOABS;
+    case SVGPathSeg::PATHSEG_LINETO_REL:                   return V8ClassIndex::SVGPATHSEGLINETOREL;
+    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:            return V8ClassIndex::SVGPATHSEGCURVETOCUBICABS;
+    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:            return V8ClassIndex::SVGPATHSEGCURVETOCUBICREL;
+    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:        return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICABS;
+    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:        return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICREL;
+    case SVGPathSeg::PATHSEG_ARC_ABS:                      return V8ClassIndex::SVGPATHSEGARCABS;
+    case SVGPathSeg::PATHSEG_ARC_REL:                      return V8ClassIndex::SVGPATHSEGARCREL;
+    case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:        return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALABS;
+    case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:        return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALREL;
+    case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:          return V8ClassIndex::SVGPATHSEGLINETOVERTICALABS;
+    case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:          return V8ClassIndex::SVGPATHSEGLINETOVERTICALREL;
+    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:     return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHABS;
+    case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:     return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHREL;
+    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHABS;
+    case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHREL;
+    default:                                               return V8ClassIndex::INVALID_CLASS_INDEX;
+    }
+}
+
+v8::Handle<v8::Value> V8DOMWrapper::convertSVGElementInstanceToV8Object(SVGElementInstance* instance)
+{
+    if (!instance)
+        return v8::Null();
+
+    v8::Handle<v8::Object> existingInstance = getDOMSVGElementInstanceMap().get(instance);
+    if (!existingInstance.IsEmpty())
+        return existingInstance;
+
+    instance->ref();
+
+    // Instantiate the V8 object and remember it
+    v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::SVGELEMENTINSTANCE, V8ClassIndex::SVGELEMENTINSTANCE, instance);
+    if (!result.IsEmpty()) {
+        // Only update the DOM SVG element map if the result is non-empty.
+        getDOMSVGElementInstanceMap().set(instance, v8::Persistent<v8::Object>::New(result));
+    }
+    return result;
+}
+
+v8::Handle<v8::Value> V8DOMWrapper::convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType type, void* object)
+{
+    if (!object)
+        return v8::Null();
+
+    v8::Persistent<v8::Object> result = getDOMSVGObjectWithContextMap().get(object);
+    if (!result.IsEmpty())
+        return result;
+
+    // Special case: SVGPathSegs need to be downcast to their real type
+    if (type == V8ClassIndex::SVGPATHSEG)
+        type = downcastSVGPathSeg(object);
+
+    v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, object);
+    if (!v8Object.IsEmpty()) {
+        result = v8::Persistent<v8::Object>::New(v8Object);
+        switch (type) {
+#define MAKE_CASE(TYPE, NAME)     \
+        case V8ClassIndex::TYPE: static_cast<NAME*>(object)->ref(); break;
+        SVG_OBJECT_TYPES(MAKE_CASE)
+#undef MAKE_CASE
+#define MAKE_CASE(TYPE, NAME)     \
+        case V8ClassIndex::TYPE:    \
+            static_cast<V8SVGPODTypeWrapper<NAME>*>(object)->ref(); break;
+        SVG_POD_NATIVE_TYPES(MAKE_CASE)
+#undef MAKE_CASE
+        default:
+            ASSERT_NOT_REACHED();
+        }
+        getDOMSVGObjectWithContextMap().set(object, result);
+    }
+
+    return result;
+}
+
+#endif // ENABLE(SVG)
+
 #if ENABLE(3D_CANVAS)
 void V8DOMWrapper::setIndexedPropertiesToExternalArray(v8::Handle<v8::Object> wrapper,
                                                        int index,
@@ -236,6 +324,188 @@ v8::Local<v8::Function> V8DOMWrapper::getConstructor(V8ClassIndex::V8WrapperType
     return getConstructorForContext(type, context);
 }
 
+v8::Handle<v8::Value> V8DOMWrapper::convertToV8Object(V8ClassIndex::V8WrapperType type, void* impl)
+{
+    ASSERT(type != V8ClassIndex::EVENTLISTENER);
+    ASSERT(type != V8ClassIndex::EVENTTARGET);
+    ASSERT(type != V8ClassIndex::EVENT);
+
+    // These objects can be constructed under WorkerContextExecutionProxy.  They need special
+    // handling, since if we proceed below V8Proxy::retrieve() will get called and will crash.
+    // TODO(ukai): websocket?
+    if ((type == V8ClassIndex::DOMCOREEXCEPTION
+         || type == V8ClassIndex::RANGEEXCEPTION
+         || type == V8ClassIndex::EVENTEXCEPTION
+         || type == V8ClassIndex::XMLHTTPREQUESTEXCEPTION
+         || type == V8ClassIndex::MESSAGEPORT)
+        && WorkerContextExecutionProxy::retrieve()) {
+        return WorkerContextExecutionProxy::convertToV8Object(type, impl);
+    }
+
+    bool isActiveDomObject = false;
+    switch (type) {
+#define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE:
+        DOM_NODE_TYPES(MAKE_CASE)
+#if ENABLE(SVG)
+        SVG_NODE_TYPES(MAKE_CASE)
+#endif
+        return convertNodeToV8Object(static_cast<Node*>(impl));
+    case V8ClassIndex::CSSVALUE:
+        return convertCSSValueToV8Object(static_cast<CSSValue*>(impl));
+    case V8ClassIndex::CSSRULE:
+        return convertCSSRuleToV8Object(static_cast<CSSRule*>(impl));
+    case V8ClassIndex::STYLESHEET:
+        return convertStyleSheetToV8Object(static_cast<StyleSheet*>(impl));
+    case V8ClassIndex::DOMWINDOW:
+        return convertWindowToV8Object(static_cast<DOMWindow*>(impl));
+    case V8ClassIndex::NAMEDNODEMAP:
+        return convertNamedNodeMapToV8Object(static_cast<NamedNodeMap*>(impl));
+#if ENABLE(SVG)
+        SVG_NONNODE_TYPES(MAKE_CASE)
+        if (type == V8ClassIndex::SVGELEMENTINSTANCE)
+            return convertSVGElementInstanceToV8Object(static_cast<SVGElementInstance*>(impl));
+        return convertSVGObjectWithContextToV8Object(type, impl);
+#endif
+
+        ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
+        isActiveDomObject = true;
+        break;
+    default:
+        break;
+  }
+
+#undef MAKE_CASE
+
+    if (!impl)
+        return v8::Null();
+
+    // Non DOM node
+    v8::Persistent<v8::Object> result = isActiveDomObject ? getActiveDOMObjectMap().get(impl) : getDOMObjectMap().get(impl);
+    if (result.IsEmpty()) {
+#if ENABLE(3D_CANVAS)
+        if (type == V8ClassIndex::WEBGLARRAY && impl) {
+            // Determine which subclass we are wrapping.
+            WebGLArray* array = reinterpret_cast<WebGLArray*>(impl);
+            if (array->isByteArray())
+                type = V8ClassIndex::WEBGLBYTEARRAY;
+            else if (array->isFloatArray())
+                type = V8ClassIndex::WEBGLFLOATARRAY;
+            else if (array->isIntArray())
+                type = V8ClassIndex::WEBGLINTARRAY;
+            else if (array->isShortArray())
+                type = V8ClassIndex::WEBGLSHORTARRAY;
+            else if (array->isUnsignedByteArray())
+                type = V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY;
+            else if (array->isUnsignedIntArray())
+                type = V8ClassIndex::WEBGLUNSIGNEDINTARRAY;
+            else if (array->isUnsignedShortArray())
+                type = V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY;
+        }
+#endif
+
+        v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, impl);
+        if (!v8Object.IsEmpty()) {
+            // Go through big switch statement, it has some duplications
+            // that were handled by code above (such as CSSVALUE, CSSRULE, etc).
+            switch (type) {
+#define MAKE_CASE(TYPE, NAME) \
+            case V8ClassIndex::TYPE: static_cast<NAME*>(impl)->ref(); break;
+                DOM_OBJECT_TYPES(MAKE_CASE)
+#undef MAKE_CASE
+            default:
+                ASSERT_NOT_REACHED();
+            }
+            result = v8::Persistent<v8::Object>::New(v8Object);
+            if (isActiveDomObject)
+                setJSWrapperForActiveDOMObject(impl, result);
+            else
+                setJSWrapperForDOMObject(impl, result);
+
+            if (type == V8ClassIndex::CANVASPIXELARRAY) {
+                CanvasPixelArray* pixels = reinterpret_cast<CanvasPixelArray*>(impl);
+                result->SetIndexedPropertiesToPixelData(pixels->data()->data(), pixels->length());
+            }
+
+#if ENABLE(3D_CANVAS)
+            // Set up WebGLArray subclasses' accesses similarly.
+            switch (type) {
+            case V8ClassIndex::WEBGLBYTEARRAY:
+            case V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY:
+            case V8ClassIndex::WEBGLSHORTARRAY:
+            case V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY:
+            case V8ClassIndex::WEBGLINTARRAY:
+            case V8ClassIndex::WEBGLUNSIGNEDINTARRAY:
+            case V8ClassIndex::WEBGLFLOATARRAY: {
+                WebGLArray* array = reinterpret_cast<WebGLArray*>(impl);
+                setIndexedPropertiesToExternalArray(result,
+                                                    V8ClassIndex::ToInt(type),
+                                                    array->baseAddress(),
+                                                    array->length());
+                break;
+            }
+            default:
+                break;
+            }
+#endif
+
+            // Special case for non-node objects associated with a
+            // DOMWindow. Both Safari and FF let the JS wrappers for these
+            // objects survive GC. To mimic their behavior, V8 creates
+            // hidden references from the DOMWindow to these wrapper
+            // objects. These references get cleared when the DOMWindow is
+            // reused by a new page.
+            switch (type) {
+            case V8ClassIndex::CONSOLE:
+                setHiddenWindowReference(static_cast<Console*>(impl)->frame(), V8DOMWindow::consoleIndex, result);
+                break;
+            case V8ClassIndex::HISTORY:
+                setHiddenWindowReference(static_cast<History*>(impl)->frame(), V8DOMWindow::historyIndex, result);
+                break;
+            case V8ClassIndex::NAVIGATOR:
+                setHiddenWindowReference(static_cast<Navigator*>(impl)->frame(), V8DOMWindow::navigatorIndex, result);
+                break;
+            case V8ClassIndex::SCREEN:
+                setHiddenWindowReference(static_cast<Screen*>(impl)->frame(), V8DOMWindow::screenIndex, result);
+                break;
+            case V8ClassIndex::LOCATION:
+                setHiddenWindowReference(static_cast<Location*>(impl)->frame(), V8DOMWindow::locationIndex, result);
+                break;
+            case V8ClassIndex::DOMSELECTION:
+                setHiddenWindowReference(static_cast<DOMSelection*>(impl)->frame(), V8DOMWindow::domSelectionIndex, result);
+                break;
+            case V8ClassIndex::BARINFO: {
+                BarInfo* barInfo = static_cast<BarInfo*>(impl);
+                Frame* frame = barInfo->frame();
+                switch (barInfo->type()) {
+                case BarInfo::Locationbar:
+                    setHiddenWindowReference(frame, V8DOMWindow::locationbarIndex, result);
+                    break;
+                case BarInfo::Menubar:
+                    setHiddenWindowReference(frame, V8DOMWindow::menubarIndex, result);
+                    break;
+                case BarInfo::Personalbar:
+                    setHiddenWindowReference(frame, V8DOMWindow::personalbarIndex, result);
+                    break;
+                case BarInfo::Scrollbars:
+                    setHiddenWindowReference(frame, V8DOMWindow::scrollbarsIndex, result);
+                    break;
+                case BarInfo::Statusbar:
+                    setHiddenWindowReference(frame, V8DOMWindow::statusbarIndex, result);
+                    break;
+                case BarInfo::Toolbar:
+                    setHiddenWindowReference(frame, V8DOMWindow::toolbarIndex, result);
+                    break;
+                }
+                break;
+            }
+            default:
+                break;
+            }
+        }
+    }
+    return result;
+}
+
 void V8DOMWrapper::setHiddenWindowReference(Frame* frame, const int internalIndex, v8::Handle<v8::Object> jsObject)
 {
     // Get DOMWindow
@@ -279,8 +549,12 @@ PassRefPtr<NodeFilter> V8DOMWrapper::wrapNativeNodeFilter(v8::Handle<v8::Value>
     return NodeFilter::create(condition);
 }
 
-v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl)
+v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType descriptorType, V8ClassIndex::V8WrapperType cptrType, void* impl)
 {
+    // Make a special case for document.all
+    if (descriptorType == V8ClassIndex::HTMLCOLLECTION && static_cast<HTMLCollection*>(impl)->type() == DocAll)
+        descriptorType = V8ClassIndex::HTMLALLCOLLECTION;
+
     if (V8IsolatedContext::getEntered()) {
         // This effectively disables the wrapper cache for isolated worlds.
         proxy = 0;
@@ -293,14 +567,14 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassI
     v8::Local<v8::Object> instance;
     if (proxy)
         // FIXME: Fix this to work properly with isolated worlds (see above).
-        instance = proxy->windowShell()->createWrapperFromCache(type);
+        instance = proxy->windowShell()->createWrapperFromCache(descriptorType);
     else {
-        v8::Local<v8::Function> function = getTemplate(type)->GetFunction();
+        v8::Local<v8::Function> function = getTemplate(descriptorType)->GetFunction();
         instance = SafeAllocation::newInstance(function);
     }
     if (!instance.IsEmpty()) {
         // Avoid setting the DOM wrapper for failed allocations.
-        setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl);
+        setDOMWrapper(instance, V8ClassIndex::ToInt(cptrType), impl);
     }
     return instance;
 }
@@ -328,6 +602,13 @@ bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value)
 }
 #endif
 
+bool V8DOMWrapper::isDOMEventWrapper(v8::Handle<v8::Value> value)
+{
+    // All kinds of events use EVENT as dom type in JS wrappers.
+    // See EventToV8Object
+    return isWrapperOfType(value, V8ClassIndex::EVENT);
+}
+
 bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8WrapperType classType)
 {
     if (value.IsEmpty() || !value->IsObject())
@@ -349,6 +630,359 @@ bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8
     return V8ClassIndex::FromInt(type->Int32Value()) == classType;
 }
 
+#if ENABLE(VIDEO)
+#define FOR_EACH_VIDEO_TAG(macro)                  \
+    macro(audio, AUDIO)                            \
+    macro(source, SOURCE)                          \
+    macro(video, VIDEO)
+#else
+#define FOR_EACH_VIDEO_TAG(macro)
+#endif
+
+#if ENABLE(DATAGRID)
+#define FOR_EACH_DATAGRID_TAG(macro)               \
+    macro(datagrid, DATAGRID)                        \
+    macro(dcell, DATAGRIDCELL)                       \
+    macro(dcol, DATAGRIDCOL)                         \
+    macro(drow, DATAGRIDROW)
+#else
+#define FOR_EACH_DATAGRID_TAG(macro)
+#endif
+
+#define FOR_EACH_TAG(macro)                        \
+    FOR_EACH_DATAGRID_TAG(macro)                   \
+    macro(a, ANCHOR)                               \
+    macro(applet, APPLET)                          \
+    macro(area, AREA)                              \
+    macro(base, BASE)                              \
+    macro(basefont, BASEFONT)                      \
+    macro(blockquote, BLOCKQUOTE)                  \
+    macro(body, BODY)                              \
+    macro(br, BR)                                  \
+    macro(button, BUTTON)                          \
+    macro(caption, TABLECAPTION)                   \
+    macro(col, TABLECOL)                           \
+    macro(colgroup, TABLECOL)                      \
+    macro(del, MOD)                                \
+    macro(canvas, CANVAS)                          \
+    macro(dir, DIRECTORY)                          \
+    macro(div, DIV)                                \
+    macro(dl, DLIST)                               \
+    macro(embed, EMBED)                            \
+    macro(fieldset, FIELDSET)                      \
+    macro(font, FONT)                              \
+    macro(form, FORM)                              \
+    macro(frame, FRAME)                            \
+    macro(frameset, FRAMESET)                      \
+    macro(h1, HEADING)                             \
+    macro(h2, HEADING)                             \
+    macro(h3, HEADING)                             \
+    macro(h4, HEADING)                             \
+    macro(h5, HEADING)                             \
+    macro(h6, HEADING)                             \
+    macro(head, HEAD)                              \
+    macro(hr, HR)                                  \
+    macro(html, HTML)                              \
+    macro(img, IMAGE)                              \
+    macro(iframe, IFRAME)                          \
+    macro(image, IMAGE)                            \
+    macro(input, INPUT)                            \
+    macro(ins, MOD)                                \
+    macro(isindex, ISINDEX)                        \
+    macro(keygen, SELECT)                          \
+    macro(label, LABEL)                            \
+    macro(legend, LEGEND)                          \
+    macro(li, LI)                                  \
+    macro(link, LINK)                              \
+    macro(listing, PRE)                            \
+    macro(map, MAP)                                \
+    macro(marquee, MARQUEE)                        \
+    macro(menu, MENU)                              \
+    macro(meta, META)                              \
+    macro(object, OBJECT)                          \
+    macro(ol, OLIST)                               \
+    macro(optgroup, OPTGROUP)                      \
+    macro(option, OPTION)                          \
+    macro(p, PARAGRAPH)                            \
+    macro(param, PARAM)                            \
+    macro(pre, PRE)                                \
+    macro(q, QUOTE)                                \
+    macro(script, SCRIPT)                          \
+    macro(select, SELECT)                          \
+    macro(style, STYLE)                            \
+    macro(table, TABLE)                            \
+    macro(thead, TABLESECTION)                     \
+    macro(tbody, TABLESECTION)                     \
+    macro(tfoot, TABLESECTION)                     \
+    macro(td, TABLECELL)                           \
+    macro(th, TABLECELL)                           \
+    macro(tr, TABLEROW)                            \
+    macro(textarea, TEXTAREA)                      \
+    macro(title, TITLE)                            \
+    macro(ul, ULIST)                               \
+    macro(xmp, PRE)
+
+V8ClassIndex::V8WrapperType V8DOMWrapper::htmlElementType(HTMLElement* element)
+{
+    typedef HashMap<String, V8ClassIndex::V8WrapperType> WrapperTypeMap;
+    DEFINE_STATIC_LOCAL(WrapperTypeMap, wrapperTypeMap, ());
+    if (wrapperTypeMap.isEmpty()) {
+#define ADD_TO_HASH_MAP(tag, name) \
+        wrapperTypeMap.set(#tag, V8ClassIndex::HTML##name##ELEMENT);
+        FOR_EACH_TAG(ADD_TO_HASH_MAP)
+#if ENABLE(VIDEO)
+        if (MediaPlayer::isAvailable()) {
+            FOR_EACH_VIDEO_TAG(ADD_TO_HASH_MAP)
+        }
+#endif
+#undef ADD_TO_HASH_MAP
+    }
+
+    V8ClassIndex::V8WrapperType type = wrapperTypeMap.get(element->localName().impl());
+    if (!type)
+        return V8ClassIndex::HTMLELEMENT;
+    return type;
+}
+#undef FOR_EACH_TAG
+
+#if ENABLE(SVG)
+
+#if ENABLE(SVG_ANIMATION)
+#define FOR_EACH_ANIMATION_TAG(macro) \
+    macro(animateColor, ANIMATECOLOR) \
+    macro(animate, ANIMATE) \
+    macro(animateTransform, ANIMATETRANSFORM) \
+    macro(set, SET)
+#else
+#define FOR_EACH_ANIMATION_TAG(macro)
+#endif
+
+#if ENABLE(SVG) && ENABLE(FILTERS)
+#define FOR_EACH_FILTERS_TAG(macro) \
+    macro(feBlend, FEBLEND) \
+    macro(feColorMatrix, FECOLORMATRIX) \
+    macro(feComponentTransfer, FECOMPONENTTRANSFER) \
+    macro(feComposite, FECOMPOSITE) \
+    macro(feDiffuseLighting, FEDIFFUSELIGHTING) \
+    macro(feDisplacementMap, FEDISPLACEMENTMAP) \
+    macro(feDistantLight, FEDISTANTLIGHT) \
+    macro(feFlood, FEFLOOD) \
+    macro(feFuncA, FEFUNCA) \
+    macro(feFuncB, FEFUNCB) \
+    macro(feFuncG, FEFUNCG) \
+    macro(feFuncR, FEFUNCR) \
+    macro(feGaussianBlur, FEGAUSSIANBLUR) \
+    macro(feImage, FEIMAGE) \
+    macro(feMerge, FEMERGE) \
+    macro(feMergeNode, FEMERGENODE) \
+    macro(feMorphology, FEMORPHOLOGY) \
+    macro(feOffset, FEOFFSET) \
+    macro(fePointLight, FEPOINTLIGHT) \
+    macro(feSpecularLighting, FESPECULARLIGHTING) \
+    macro(feSpotLight, FESPOTLIGHT) \
+    macro(feTile, FETILE) \
+    macro(feTurbulence, FETURBULENCE) \
+    macro(filter, FILTER)
+#else
+#define FOR_EACH_FILTERS_TAG(macro)
+#endif
+
+#if ENABLE(SVG_FONTS)
+#define FOR_EACH_FONTS_TAG(macro) \
+    macro(font-face, FONTFACE) \
+    macro(font-face-format, FONTFACEFORMAT) \
+    macro(font-face-name, FONTFACENAME) \
+    macro(font-face-src, FONTFACESRC) \
+    macro(font-face-uri, FONTFACEURI)
+#else
+#define FOR_EACH_FONTS_TAG(marco)
+#endif
+
+#if ENABLE(SVG_FOREIGN_OBJECT)
+#define FOR_EACH_FOREIGN_OBJECT_TAG(macro) \
+    macro(foreignObject, FOREIGNOBJECT)
+#else
+#define FOR_EACH_FOREIGN_OBJECT_TAG(macro)
+#endif
+
+#if ENABLE(SVG_USE)
+#define FOR_EACH_USE_TAG(macro) \
+    macro(use, USE)
+#else
+#define FOR_EACH_USE_TAG(macro)
+#endif
+
+#define FOR_EACH_TAG(macro) \
+    FOR_EACH_ANIMATION_TAG(macro) \
+    FOR_EACH_FILTERS_TAG(macro) \
+    FOR_EACH_FONTS_TAG(macro) \
+    FOR_EACH_FOREIGN_OBJECT_TAG(macro) \
+    FOR_EACH_USE_TAG(macro) \
+    macro(a, A) \
+    macro(altGlyph, ALTGLYPH) \
+    macro(circle, CIRCLE) \
+    macro(clipPath, CLIPPATH) \
+    macro(cursor, CURSOR) \
+    macro(defs, DEFS) \
+    macro(desc, DESC) \
+    macro(ellipse, ELLIPSE) \
+    macro(g, G) \
+    macro(glyph, GLYPH) \
+    macro(image, IMAGE) \
+    macro(linearGradient, LINEARGRADIENT) \
+    macro(line, LINE) \
+    macro(marker, MARKER) \
+    macro(mask, MASK) \
+    macro(metadata, METADATA) \
+    macro(path, PATH) \
+    macro(pattern, PATTERN) \
+    macro(polyline, POLYLINE) \
+    macro(polygon, POLYGON) \
+    macro(radialGradient, RADIALGRADIENT) \
+    macro(rect, RECT) \
+    macro(script, SCRIPT) \
+    macro(stop, STOP) \
+    macro(style, STYLE) \
+    macro(svg, SVG) \
+    macro(switch, SWITCH) \
+    macro(symbol, SYMBOL) \
+    macro(text, TEXT) \
+    macro(textPath, TEXTPATH) \
+    macro(title, TITLE) \
+    macro(tref, TREF) \
+    macro(tspan, TSPAN) \
+    macro(view, VIEW) \
+    // end of macro
+
+V8ClassIndex::V8WrapperType V8DOMWrapper::svgElementType(SVGElement* element)
+{
+    typedef HashMap<String, V8ClassIndex::V8WrapperType> WrapperTypeMap;
+    DEFINE_STATIC_LOCAL(WrapperTypeMap, wrapperTypeMap, ());
+    if (wrapperTypeMap.isEmpty()) {
+#define ADD_TO_HASH_MAP(tag, name) \
+        wrapperTypeMap.set(#tag, V8ClassIndex::SVG##name##ELEMENT);
+        FOR_EACH_TAG(ADD_TO_HASH_MAP)
+#undef ADD_TO_HASH_MAP
+    }
+
+    V8ClassIndex::V8WrapperType type = wrapperTypeMap.get(element->localName().impl());
+    if (!type)
+        return V8ClassIndex::SVGELEMENT;
+    return type;
+}
+#undef FOR_EACH_TAG
+
+#endif // ENABLE(SVG)
+
+v8::Handle<v8::Value> V8DOMWrapper::convertEventToV8Object(Event* event)
+{
+    if (!event)
+        return v8::Null();
+
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(event);
+    if (!wrapper.IsEmpty())
+        return wrapper;
+
+    V8ClassIndex::V8WrapperType type = V8ClassIndex::EVENT;
+
+    if (event->isUIEvent()) {
+        if (event->isKeyboardEvent())
+            type = V8ClassIndex::KEYBOARDEVENT;
+        else if (event->isTextEvent())
+            type = V8ClassIndex::TEXTEVENT;
+        else if (event->isMouseEvent())
+            type = V8ClassIndex::MOUSEEVENT;
+        else if (event->isWheelEvent())
+            type = V8ClassIndex::WHEELEVENT;
+#if ENABLE(SVG)
+        else if (event->isSVGZoomEvent())
+            type = V8ClassIndex::SVGZOOMEVENT;
+#endif
+        else if (event->isCompositionEvent())
+            type = V8ClassIndex::COMPOSITIONEVENT;
+        else
+            type = V8ClassIndex::UIEVENT;
+    } else if (event->isMutationEvent())
+        type = V8ClassIndex::MUTATIONEVENT;
+    else if (event->isOverflowEvent())
+        type = V8ClassIndex::OVERFLOWEVENT;
+    else if (event->isMessageEvent())
+        type = V8ClassIndex::MESSAGEEVENT;
+    else if (event->isPageTransitionEvent())
+        type = V8ClassIndex::PAGETRANSITIONEVENT;
+    else if (event->isPopStateEvent())
+        type = V8ClassIndex::POPSTATEEVENT;
+    else if (event->isProgressEvent()) {
+        if (event->isXMLHttpRequestProgressEvent())
+            type = V8ClassIndex::XMLHTTPREQUESTPROGRESSEVENT;
+        else
+            type = V8ClassIndex::PROGRESSEVENT;
+    } else if (event->isWebKitAnimationEvent())
+        type = V8ClassIndex::WEBKITANIMATIONEVENT;
+    else if (event->isWebKitTransitionEvent())
+        type = V8ClassIndex::WEBKITTRANSITIONEVENT;
+#if ENABLE(WORKERS)
+    else if (event->isErrorEvent())
+        type = V8ClassIndex::ERROREVENT;
+#endif
+#if ENABLE(DOM_STORAGE)
+    else if (event->isStorageEvent())
+        type = V8ClassIndex::STORAGEEVENT;
+#endif
+    else if (event->isBeforeLoadEvent())
+        type = V8ClassIndex::BEFORELOADEVENT;
+
+
+    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::EVENT, event);
+    if (result.IsEmpty()) {
+        // Instantiation failed. Avoid updating the DOM object map and
+        // return null which is already handled by callers of this function
+        // in case the event is NULL.
+        return v8::Null();
+    }
+
+    event->ref(); // fast ref
+    setJSWrapperForDOMObject(event, v8::Persistent<v8::Object>::New(result));
+
+    return result;
+}
+
+static const V8ClassIndex::V8WrapperType mapping[] = {
+    V8ClassIndex::INVALID_CLASS_INDEX,    // NONE
+    V8ClassIndex::INVALID_CLASS_INDEX,    // ELEMENT_NODE needs special treatment
+    V8ClassIndex::ATTR,                   // ATTRIBUTE_NODE
+    V8ClassIndex::TEXT,                   // TEXT_NODE
+    V8ClassIndex::CDATASECTION,           // CDATA_SECTION_NODE
+    V8ClassIndex::ENTITYREFERENCE,        // ENTITY_REFERENCE_NODE
+    V8ClassIndex::ENTITY,                 // ENTITY_NODE
+    V8ClassIndex::PROCESSINGINSTRUCTION,  // PROCESSING_INSTRUCTION_NODE
+    V8ClassIndex::COMMENT,                // COMMENT_NODE
+    V8ClassIndex::INVALID_CLASS_INDEX,    // DOCUMENT_NODE needs special treatment
+    V8ClassIndex::DOCUMENTTYPE,           // DOCUMENT_TYPE_NODE
+    V8ClassIndex::DOCUMENTFRAGMENT,       // DOCUMENT_FRAGMENT_NODE
+    V8ClassIndex::NOTATION,               // NOTATION_NODE
+    V8ClassIndex::NODE,                   // XPATH_NAMESPACE_NODE
+};
+
+v8::Handle<v8::Value> V8DOMWrapper::convertDocumentToV8Object(Document* document)
+{
+    // Find a proxy for this node.
+    //
+    // Note that if proxy is found, we might initialize the context which can
+    // instantiate a document wrapper.  Therefore, we get the proxy before
+    // checking if the node already has a wrapper.
+    V8Proxy* proxy = V8Proxy::retrieve(document->frame());
+    if (proxy)
+        proxy->windowShell()->initContextIfNeeded();
+
+    DOMNodeMapping& domNodeMap = getDOMNodeMap();
+    v8::Handle<v8::Object> wrapper = domNodeMap.get(document);
+    if (wrapper.IsEmpty())
+        return convertNewNodeToV8Object(document, proxy, domNodeMap);
+
+    return wrapper;
+}
+
 v8::Handle<v8::Object> V8DOMWrapper::getWrapper(Node* node)
 {
     ASSERT(WTF::isMainThread());
@@ -364,6 +998,101 @@ v8::Handle<v8::Object> V8DOMWrapper::getWrapper(Node* node)
     return domNodeMap.get(node);
 }
 
+v8::Handle<v8::Value> V8DOMWrapper::convertNodeToV8Object(Node* node)
+{
+    if (!node)
+        return v8::Null();
+    
+    v8::Handle<v8::Value> wrapper = getWrapper(node);
+    if (!wrapper.IsEmpty())
+        return wrapper;
+
+    Document* document = node->document();
+    if (node == document)
+        return convertDocumentToV8Object(document);
+
+    return convertNewNodeToV8Object(node, 0, getDOMNodeMap());
+}
+    
+// Caller checks node is not null.
+v8::Handle<v8::Value> V8DOMWrapper::convertNewNodeToV8Object(Node* node, V8Proxy* proxy, DOMNodeMapping& domNodeMap)
+{
+    if (!proxy && node->document())
+        proxy = V8Proxy::retrieve(node->document()->frame());
+
+    bool isDocument = false; // document type node has special handling
+    V8ClassIndex::V8WrapperType type;
+
+    Node::NodeType nodeType = node->nodeType();
+    if (nodeType == Node::ELEMENT_NODE) {
+        if (node->isHTMLElement())
+            type = htmlElementType(static_cast<HTMLElement*>(node));
+#if ENABLE(SVG)
+        else if (node->isSVGElement())
+            type = svgElementType(static_cast<SVGElement*>(node));
+#endif
+        else
+            type = V8ClassIndex::ELEMENT;
+    } else if (nodeType == Node::DOCUMENT_NODE) {
+        isDocument = true;
+        Document* document = static_cast<Document*>(node);
+        if (document->isHTMLDocument())
+            type = V8ClassIndex::HTMLDOCUMENT;
+#if ENABLE(SVG)
+        else if (document->isSVGDocument())
+            type = V8ClassIndex::SVGDOCUMENT;
+#endif
+        else
+            type = V8ClassIndex::DOCUMENT;
+    } else {
+        ASSERT(nodeType < static_cast<int>(sizeof(mapping)/sizeof(mapping[0])));
+        type = mapping[nodeType];
+        ASSERT(type != V8ClassIndex::INVALID_CLASS_INDEX);
+    }
+
+    v8::Handle<v8::Context> context;
+    if (proxy)
+        context = proxy->context();
+
+    // Enter the node's context and create the wrapper in that context.
+    if (!context.IsEmpty())
+        context->Enter();
+
+    v8::Local<v8::Object> result = instantiateV8Object(proxy, type, V8ClassIndex::NODE, node);
+
+    // Exit the node's context if it was entered.
+    if (!context.IsEmpty())
+        context->Exit();
+
+    if (result.IsEmpty()) {
+        // If instantiation failed it's important not to add the result
+        // to the DOM node map. Instead we return an empty handle, which
+        // should already be handled by callers of this function in case
+        // the node is NULL.
+        return result;
+    }
+
+    node->ref();
+    domNodeMap.set(node, v8::Persistent<v8::Object>::New(result));
+
+    if (isDocument) {
+        if (proxy)
+            proxy->windowShell()->updateDocumentWrapper(result);
+
+        if (type == V8ClassIndex::HTMLDOCUMENT) {
+            // Create marker object and insert it in two internal fields.
+            // This is used to implement temporary shadowing of
+            // document.all.
+            ASSERT(result->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
+            v8::Local<v8::Object> marker = v8::Object::New();
+            result->SetInternalField(V8HTMLDocument::markerIndex, marker);
+            result->SetInternalField(V8HTMLDocument::shadowIndex, marker);
+        }
+    }
+
+    return result;
+}
+
 // A JS object of type EventTarget is limited to a small number of possible classes.
 // Check EventTarget.h for new type conversion methods
 v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* target)
@@ -436,6 +1165,16 @@ v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* ta
     return notHandledByInterceptor();
 }
 
+v8::Handle<v8::Value> V8DOMWrapper::convertEventListenerToV8Object(ScriptExecutionContext* context, EventListener* listener)
+{
+    if (!listener)
+        return v8::Null();
+
+    // FIXME: can a user take a lazy event listener and set to other places?
+    V8AbstractEventListener* v8listener = static_cast<V8AbstractEventListener*>(listener);
+    return v8listener->getListenerObject(context);
+}
+
 PassRefPtr<EventListener> V8DOMWrapper::getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup)
 {
     return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute);
@@ -521,4 +1260,193 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(V8Proxy* proxy, v8::Loc
     return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute);
 }
 
+v8::Handle<v8::Value> V8DOMWrapper::convertDOMImplementationToV8Object(DOMImplementation* impl)
+{
+    v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::DOMIMPLEMENTATION, V8ClassIndex::DOMIMPLEMENTATION, impl);
+    if (result.IsEmpty()) {
+        // If the instantiation failed, we ignore it and return null instead
+        // of returning an empty handle.
+        return v8::Null();
+    }
+    return result;
+}
+
+v8::Handle<v8::Value> V8DOMWrapper::convertStyleSheetToV8Object(StyleSheet* sheet)
+{
+    if (!sheet)
+        return v8::Null();
+
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(sheet);
+    if (!wrapper.IsEmpty())
+        return wrapper;
+
+    V8ClassIndex::V8WrapperType type = V8ClassIndex::STYLESHEET;
+    if (sheet->isCSSStyleSheet())
+        type = V8ClassIndex::CSSSTYLESHEET;
+
+    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::STYLESHEET, sheet);
+    if (!result.IsEmpty()) {
+        // Only update the DOM object map if the result is non-empty.
+        sheet->ref();
+        setJSWrapperForDOMObject(sheet, v8::Persistent<v8::Object>::New(result));
+    }
+
+    // Add a hidden reference from stylesheet object to its owner node.
+    Node* ownerNode = sheet->ownerNode();
+    if (ownerNode) {
+        v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(ownerNode));
+        result->SetInternalField(V8StyleSheet::ownerNodeIndex, owner);
+    }
+
+    return result;
+}
+
+v8::Handle<v8::Value> V8DOMWrapper::convertCSSValueToV8Object(CSSValue* value)
+{
+    if (!value)
+        return v8::Null();
+
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(value);
+    if (!wrapper.IsEmpty())
+        return wrapper;
+
+    V8ClassIndex::V8WrapperType type;
+
+    if (value->isWebKitCSSTransformValue())
+        type = V8ClassIndex::WEBKITCSSTRANSFORMVALUE;
+    else if (value->isValueList())
+        type = V8ClassIndex::CSSVALUELIST;
+    else if (value->isPrimitiveValue())
+        type = V8ClassIndex::CSSPRIMITIVEVALUE;
+#if ENABLE(SVG)
+    else if (value->isSVGPaint())
+        type = V8ClassIndex::SVGPAINT;
+    else if (value->isSVGColor())
+        type = V8ClassIndex::SVGCOLOR;
+#endif
+    else
+        type = V8ClassIndex::CSSVALUE;
+
+    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSVALUE, value);
+    if (!result.IsEmpty()) {
+        // Only update the DOM object map if the result is non-empty.
+        value->ref();
+        setJSWrapperForDOMObject(value, v8::Persistent<v8::Object>::New(result));
+    }
+
+    return result;
+}
+
+v8::Handle<v8::Value> V8DOMWrapper::convertCSSRuleToV8Object(CSSRule* rule)
+{
+    if (!rule) 
+        return v8::Null();
+
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(rule);
+    if (!wrapper.IsEmpty())
+        return wrapper;
+
+    V8ClassIndex::V8WrapperType type;
+
+    switch (rule->type()) {
+    case CSSRule::STYLE_RULE:
+        type = V8ClassIndex::CSSSTYLERULE;
+        break;
+    case CSSRule::CHARSET_RULE:
+        type = V8ClassIndex::CSSCHARSETRULE;
+        break;
+    case CSSRule::IMPORT_RULE:
+        type = V8ClassIndex::CSSIMPORTRULE;
+        break;
+    case CSSRule::MEDIA_RULE:
+        type = V8ClassIndex::CSSMEDIARULE;
+        break;
+    case CSSRule::FONT_FACE_RULE:
+        type = V8ClassIndex::CSSFONTFACERULE;
+        break;
+    case CSSRule::PAGE_RULE:
+        type = V8ClassIndex::CSSPAGERULE;
+        break;
+    case CSSRule::VARIABLES_RULE:
+        type = V8ClassIndex::CSSVARIABLESRULE;
+        break;
+    case CSSRule::WEBKIT_KEYFRAME_RULE:
+        type = V8ClassIndex::WEBKITCSSKEYFRAMERULE;
+        break;
+    case CSSRule::WEBKIT_KEYFRAMES_RULE:
+        type = V8ClassIndex::WEBKITCSSKEYFRAMESRULE;
+        break;
+    default:  // CSSRule::UNKNOWN_RULE
+        type = V8ClassIndex::CSSRULE;
+        break;
+    }
+
+    v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSRULE, rule);
+    if (!result.IsEmpty()) {
+        // Only update the DOM object map if the result is non-empty.
+        rule->ref();
+        setJSWrapperForDOMObject(rule, v8::Persistent<v8::Object>::New(result));
+    }
+    return result;
+}
+
+v8::Handle<v8::Value> V8DOMWrapper::convertWindowToV8Object(DOMWindow* window)
+{
+    if (!window)
+        return v8::Null();
+    // Initializes environment of a frame, and return the global object
+    // of the frame.
+    Frame* frame = window->frame();
+    if (!frame)
+        return v8::Handle<v8::Object>();
+
+    // Special case: Because of evaluateInIsolatedWorld() one DOMWindow can have
+    // multiple contexts and multiple global objects associated with it. When
+    // code running in one of those contexts accesses the window object, we
+    // want to return the global object associated with that context, not
+    // necessarily the first global object associated with that DOMWindow.
+    v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent();
+    v8::Handle<v8::Object> currentGlobal = currentContext->Global();
+    v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, currentGlobal);
+    if (!windowWrapper.IsEmpty()) {
+        if (V8DOMWindow::toNative(windowWrapper) == window)
+            return currentGlobal;
+    }
+
+    // Otherwise, return the global object associated with this frame.
+    v8::Handle<v8::Context> context = V8Proxy::context(frame);
+    if (context.IsEmpty())
+        return v8::Handle<v8::Object>();
+
+    v8::Handle<v8::Object> global = context->Global();
+    ASSERT(!global.IsEmpty());
+    return global;
+}
+
+v8::Handle<v8::Value> V8DOMWrapper::convertNamedNodeMapToV8Object(NamedNodeMap* map)
+{
+    if (!map)
+        return v8::Null();
+
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(map);
+    if (!wrapper.IsEmpty())
+        return wrapper;
+
+    v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::NAMEDNODEMAP, V8ClassIndex::NAMEDNODEMAP, map);
+    if (result.IsEmpty())
+        return result;
+
+    // Only update the DOM object map if the result is non-empty.
+    map->ref();
+    setJSWrapperForDOMObject(map, v8::Persistent<v8::Object>::New(result));
+
+    // Add a hidden reference from named node map to its owner node.
+    if (Element* element = map->element()) {
+        v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(element));
+        result->SetInternalField(V8NamedNodeMap::ownerNodeIndex, owner);
+    }
+
+    return result;
+}
+
 }  // namespace WebCore
diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h
index 51abff7..0ccd8ac 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.h
+++ b/WebCore/bindings/v8/V8DOMWrapper.h
@@ -36,6 +36,7 @@
 #include "Node.h"
 #include "NodeFilter.h"
 #include "PlatformString.h" // for WebCore::String
+#include "V8CustomBinding.h"
 #include "V8CustomXPathNSResolver.h"
 #include "V8DOMMap.h"
 #include "V8Event.h"
@@ -122,8 +123,45 @@ namespace WebCore {
             return object.IsEmpty() ? object : object->FindInstanceInPrototypeChain(getTemplate(type));
         }
 
+        template<typename T>
+        static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType type, PassRefPtr<T> imp)
+        {
+            return convertToV8Object(type, imp.get());
+        }
+
+        static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType, void*);
+
+        // Fast-path for Node objects.
+        static v8::Handle<v8::Value> convertNodeToV8Object(PassRefPtr<Node> node)
+        {
+            return convertNodeToV8Object(node.get());
+        }
+
+        static v8::Handle<v8::Value> convertNodeToV8Object(Node*);
+
+        static v8::Handle<v8::Value> convertDocumentToV8Object(Document*);
+
+        static v8::Handle<v8::Value> convertNewNodeToV8Object(PassRefPtr<Node> node)
+        {
+            return convertNewNodeToV8Object(node.get());
+        }
+
+        static v8::Handle<v8::Value> convertNewNodeToV8Object(Node* node)
+        {
+            return convertNewNodeToV8Object(node, 0, getDOMNodeMap());
+        }
+
+        static v8::Handle<v8::Value> convertNewNodeToV8Object(Node*, V8Proxy*, DOMNodeMapping&);
+
         static V8ClassIndex::V8WrapperType domWrapperType(v8::Handle<v8::Object>);
 
+        static v8::Handle<v8::Value> convertEventToV8Object(PassRefPtr<Event> event)
+        {
+            return convertEventToV8Object(event.get());
+        }
+
+        static v8::Handle<v8::Value> convertEventToV8Object(Event*);
+
         static v8::Handle<v8::Value> convertEventTargetToV8Object(PassRefPtr<EventTarget> eventTarget)
         {
             return convertEventTargetToV8Object(eventTarget.get());
@@ -131,6 +169,14 @@ namespace WebCore {
 
         static v8::Handle<v8::Value> convertEventTargetToV8Object(EventTarget*);
 
+        // Wrap and unwrap JS event listeners.
+        static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext* context, PassRefPtr<EventListener> eventListener)
+        {
+            return convertEventListenerToV8Object(context, eventListener.get());
+        }
+
+        static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext*, EventListener*);
+
         static PassRefPtr<EventListener> getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
 
         static PassRefPtr<EventListener> getEventListener(SVGElementInstance* element, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
@@ -165,6 +211,10 @@ namespace WebCore {
             return resolver;
         }
 #endif
+        // DOMImplementation is a singleton and it is handled in a special
+        // way. A wrapper is generated per document and stored in an
+        // internal field of the document.
+        static v8::Handle<v8::Value> convertDOMImplementationToV8Object(DOMImplementation*);
 
         // Wrap JS node filter in C++.
         static PassRefPtr<NodeFilter> wrapNativeNodeFilter(v8::Handle<v8::Value>);
@@ -183,18 +233,57 @@ namespace WebCore {
         // Check whether a V8 value is a wrapper of type |classType|.
         static bool isWrapperOfType(v8::Handle<v8::Value>, V8ClassIndex::V8WrapperType);
 
+        // Check whether a V8 value is a DOM Event wrapper.
+        static bool isDOMEventWrapper(v8::Handle<v8::Value>);
+
+        static v8::Handle<v8::Value> convertStyleSheetToV8Object(StyleSheet*);
+        static v8::Handle<v8::Value> convertCSSValueToV8Object(CSSValue*);
+        static v8::Handle<v8::Value> convertCSSRuleToV8Object(CSSRule*);
+        // Returns the JS wrapper of a window object, initializes the environment
+        // of the window frame if needed.
+        static v8::Handle<v8::Value> convertWindowToV8Object(DOMWindow*);
+        static v8::Handle<v8::Value> convertNamedNodeMapToV8Object(NamedNodeMap*);
+
+#if ENABLE(SVG)
+        static v8::Handle<v8::Value> convertSVGElementInstanceToV8Object(SVGElementInstance*);
+        static v8::Handle<v8::Value> convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType, void*);
+#endif
+
 #if ENABLE(3D_CANVAS)
         static void setIndexedPropertiesToExternalArray(v8::Handle<v8::Object>,
                                                         int,
                                                         void*,
                                                         int);
 #endif
+
+        static V8ClassIndex::V8WrapperType htmlElementType(HTMLElement*);
+#if ENABLE(SVG)
+        static V8ClassIndex::V8WrapperType svgElementType(SVGElement*);
+#endif
         // Set hidden references in a DOMWindow object of a frame.
         static void setHiddenWindowReference(Frame*, const int internalIndex, v8::Handle<v8::Object>);
 
-        static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl);
+        static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl)
+        {
+            return instantiateV8Object(proxy, type, type, impl);
+        }
 
         static v8::Handle<v8::Object> getWrapper(Node*);
+
+    private:
+
+        // The first V8WrapperType specifies the function descriptor
+        // used to create JS object. The second V8WrapperType specifies
+        // the actual type of the void* for type casting.
+        // For example, a HTML element has HTMLELEMENT for the first V8WrapperType, but always
+        // use NODE as the second V8WrapperType. JS wrapper stores the second
+        // V8WrapperType and the void* as internal fields.
+        static v8::Local<v8::Object> instantiateV8Object(V8ClassIndex::V8WrapperType descType, V8ClassIndex::V8WrapperType cptrType, void* impl)
+        {
+            return instantiateV8Object(NULL, descType, cptrType, impl);
+        }
+
+        static v8::Local<v8::Object> instantiateV8Object(V8Proxy*, V8ClassIndex::V8WrapperType, V8ClassIndex::V8WrapperType, void*);
     };
 
 }
diff --git a/WebCore/bindings/v8/V8NodeFilterCondition.cpp b/WebCore/bindings/v8/V8NodeFilterCondition.cpp
index a8868b5..9f57a44 100644
--- a/WebCore/bindings/v8/V8NodeFilterCondition.cpp
+++ b/WebCore/bindings/v8/V8NodeFilterCondition.cpp
@@ -34,7 +34,6 @@
 #include "Node.h"
 #include "NodeFilter.h"
 #include "ScriptState.h"
-#include "V8Node.h"
 #include "V8Proxy.h"
 
 #include <wtf/OwnArrayPtr.h>
@@ -70,7 +69,7 @@ short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const
     v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
     v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(m_filter);
     OwnArrayPtr<v8::Handle<v8::Value> > args(new v8::Handle<v8::Value>[1]);
-    args[0] = toV8(node);
+    args[0] = V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
 
     V8Proxy* proxy = V8Proxy::retrieve();
     ASSERT(proxy);
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index 9509677..5ab36da 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -46,17 +46,12 @@
 #include "V8BindingState.h"
 #include "V8Collection.h"
 #include "V8ConsoleMessage.h"
-#include "V8DOMCoreException.h"
+#include "V8CustomBinding.h"
 #include "V8DOMMap.h"
 #include "V8DOMWindow.h"
-#include "V8EventException.h"
 #include "V8HiddenPropertyName.h"
 #include "V8Index.h"
 #include "V8IsolatedContext.h"
-#include "V8RangeException.h"
-#include "V8SVGException.h"
-#include "V8XMLHttpRequestException.h"
-#include "V8XPathException.h"
 #include "WorkerContextExecutionProxy.h"
 
 #include <algorithm>
@@ -612,25 +607,25 @@ void V8Proxy::setDOMException(int exceptionCode)
     v8::Handle<v8::Value> exception;
     switch (description.type) {
     case DOMExceptionType:
-        exception = toV8(DOMCoreException::create(description));
+        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMCOREEXCEPTION, DOMCoreException::create(description));
         break;
     case RangeExceptionType:
-        exception = toV8(RangeException::create(description));
+        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::RANGEEXCEPTION, RangeException::create(description));
         break;
     case EventExceptionType:
-        exception = toV8(EventException::create(description));
+        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::EVENTEXCEPTION, EventException::create(description));
         break;
     case XMLHttpRequestExceptionType:
-        exception = toV8(XMLHttpRequestException::create(description));
+        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XMLHTTPREQUESTEXCEPTION, XMLHttpRequestException::create(description));
         break;
 #if ENABLE(SVG)
     case SVGExceptionType:
-        exception = toV8(SVGException::create(description));
+        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGEXCEPTION, SVGException::create(description));
         break;
 #endif
 #if ENABLE(XPATH)
     case XPathExceptionType:
-        exception = toV8(XPathException::create(description));
+        exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHEXCEPTION, XPathException::create(description));
         break;
 #endif
     }
diff --git a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
index 70be193..5e6f40a 100644
--- a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
@@ -53,10 +53,10 @@ namespace WebCore {
 static v8::Handle<v8::Value> toV8Object(CanvasStyle* style)
 {
     if (style->canvasGradient())
-        return toV8(style->canvasGradient());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASGRADIENT, style->canvasGradient());
 
     if (style->canvasPattern())
-        return toV8(style->canvasPattern());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, style->canvasPattern());
 
     return v8String(style->color());
 }
@@ -348,7 +348,7 @@ v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8
             V8Proxy::setDOMException(ec);
             return notHandledByInterceptor();
         }
-        return toV8(pattern.release());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release());
     }
 
     if (V8HTMLCanvasElement::HasInstance(arg)) {
@@ -359,7 +359,7 @@ v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8
             V8Proxy::setDOMException(ec);
             return notHandledByInterceptor();
         }
-        return toV8(pattern.release());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release());
     }
 
     V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
index 19300b0..5e9a8f2 100644
--- a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
@@ -28,7 +28,6 @@
 
 #include "Frame.h"
 #include "V8CustomVoidCallback.h"  // For invokeCallback
-#include "V8Geoposition.h"
 
 namespace WebCore {
 
@@ -54,7 +53,7 @@ void V8CustomPositionCallback::handleEvent(Geoposition* position)
     v8::Context::Scope scope(context);
 
     v8::Handle<v8::Value> argv[] = {
-        toV8(position)
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::GEOPOSITION, position)
     };
 
     // Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
index c6c632b..117f374 100644
--- a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
@@ -28,7 +28,6 @@
 
 #include "Frame.h"
 #include "V8CustomVoidCallback.h"  // For invokeCallback
-#include "V8PositionError.h"
 
 namespace WebCore {
 
@@ -54,7 +53,7 @@ void V8CustomPositionErrorCallback::handleEvent(PositionError* error)
     v8::Context::Scope scope(context);
 
     v8::Handle<v8::Value> argv[] = {
-        toV8(error)
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::POSITIONERROR, error)
     };
 
     // Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp
index d30b95a..64abdc4 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp
@@ -36,8 +36,6 @@
 
 #include "Frame.h"
 #include "V8CustomVoidCallback.h"
-#include "V8SQLResultSet.h"
-#include "V8SQLTransaction.h"
 
 namespace WebCore {
 
@@ -63,8 +61,8 @@ void V8CustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR
     v8::Context::Scope scope(context);
 
     v8::Handle<v8::Value> argv[] = {
-        toV8(transaction),
-        toV8(resultSet)
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLRESULTSET, resultSet)
     };
 
     // Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
index 84a3b96..1af3562 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
@@ -36,8 +36,6 @@
 
 #include "Frame.h"
 #include "V8CustomVoidCallback.h"
-#include "V8SQLError.h"
-#include "V8SQLTransaction.h"
 
 namespace WebCore {
 
@@ -63,8 +61,8 @@ bool V8CustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction,
     v8::Context::Scope scope(context);
 
     v8::Handle<v8::Value> argv[] = {
-        toV8(transaction),
-        toV8(error)
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error)
     };
 
     // Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp
index 68002d7..2cef6b3 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp
@@ -36,7 +36,6 @@
 
 #include "Frame.h"
 #include "V8CustomVoidCallback.h"
-#include "V8SQLTransaction.h"
 
 namespace WebCore {
 
@@ -63,7 +62,7 @@ void V8CustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo
     v8::Context::Scope scope(context);
 
     v8::Handle<v8::Value> argv[] = {
-        toV8(transaction)
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction)
     };
 
     // Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp
index cf5a0ef..1a0939d 100644
--- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp
@@ -36,7 +36,6 @@
 
 #include "Frame.h"
 #include "V8CustomVoidCallback.h"
-#include "V8SQLError.h"
 
 namespace WebCore {
 
@@ -62,7 +61,7 @@ void V8CustomSQLTransactionErrorCallback::handleEvent(SQLError* error)
     v8::Context::Scope scope(context);
 
     v8::Handle<v8::Value> argv[] = {
-        toV8(error)
+        V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error)
     };
 
     // Protect the frame until the callback returns.
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index ba6c738..1e2f949 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -57,9 +57,7 @@
 #include "V8BindingState.h"
 #include "V8CustomBinding.h"
 #include "V8CustomEventListener.h"
-#include "V8HTMLCollection.h"
 #include "V8MessagePortCustom.h"
-#include "V8Node.h"
 #include "V8Proxy.h"
 #include "V8Utilities.h"
 #if ENABLE(WEB_SOCKETS)
@@ -710,7 +708,7 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args)
 
             frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, userGesture);
         }
-        return toV8(frame->domWindow());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
     }
 
     // In the case of a named frame or a new window, we'll use the
@@ -770,7 +768,7 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args)
     if (!frame)
         return v8::Undefined();
 
-    return toV8(frame->domWindow());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
 }
 
 
@@ -788,7 +786,7 @@ v8::Handle<v8::Value> V8DOMWindow::indexedPropertyGetter(uint32_t index, const v
 
     Frame* child = frame->tree()->child(index);
     if (child)
-        return toV8(child->domWindow());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
 
     return notHandledByInterceptor();
 }
@@ -811,7 +809,7 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam
     AtomicString propName = v8StringToAtomicWebCoreString(name);
     Frame* child = frame->tree()->child(propName);
     if (child)
-        return toV8(child->domWindow());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
 
     // Search IDL functions defined in the prototype
     v8::Handle<v8::Value> result = info.Holder()->GetRealNamedProperty(name);
@@ -826,8 +824,8 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam
             RefPtr<HTMLCollection> items = doc->windowNamedItems(propName);
             if (items->length() >= 1) {
                 if (items->length() == 1)
-                    return toV8(items->firstItem());
-                return toV8(items.release());
+                    return V8DOMWrapper::convertNodeToV8Object(items->firstItem());
+                return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release());
             }
         }
     }
diff --git a/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp
index 58e5d01..8980cfe 100644
--- a/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp
@@ -57,7 +57,7 @@ NAMED_PROPERTY_GETTER(DataGridColumnList)
     DataGridColumn* result = imp->itemWithName(toWebCoreString(name));
     if (!result)
         return notHandledByInterceptor();
-    return toV8(result);
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::DATAGRIDCOLUMN, result);
 }
     
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
index 1ac16b2..08b2294 100644
--- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
@@ -37,17 +37,16 @@
 #include "Node.h"
 #include "XPathNSResolver.h"
 #include "XPathResult.h"
+#include "CanvasRenderingContext.h"
 
 #include "V8Binding.h"
-#include "V8CanvasRenderingContext2D.h"
+#include "V8CustomBinding.h"
 #include "V8CustomXPathNSResolver.h"
-#include "V8DOMImplementation.h"
 #include "V8HTMLDocument.h"
 #include "V8IsolatedContext.h"
 #include "V8Node.h"
 #include "V8Proxy.h"
 #include "V8SVGDocument.h"
-#include "V8WebGLRenderingContext.h"
 #include "V8XPathNSResolver.h"
 #include "V8XPathResult.h"
 
@@ -83,7 +82,7 @@ v8::Handle<v8::Value> V8Document::evaluateCallback(const v8::Arguments& args)
     if (ec)
         return throwError(ec);
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHRESULT, result.release());
 }
 
 v8::Handle<v8::Value> V8Document::getCSSCanvasContextCallback(const v8::Arguments& args)
@@ -99,10 +98,10 @@ v8::Handle<v8::Value> V8Document::getCSSCanvasContextCallback(const v8::Argument
     if (!result)
         return v8::Undefined();
     if (result->is2d())
-        return toV8(static_cast<CanvasRenderingContext2D*>(result));
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
 #if ENABLE(3D_CANVAS)
     else if (result->is3d())
-        return toV8(static_cast<WebGLRenderingContext*>(result));
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result);
 #endif // ENABLE(3D_CANVAS)
     ASSERT_NOT_REACHED();
     return v8::Undefined();
@@ -128,7 +127,7 @@ v8::Handle<v8::Value> V8Document::implementationAccessorGetter(v8::Local<v8::Str
 
     // Generate a wrapper.
     Document* document = V8Document::toNative(info.Holder());
-    v8::Handle<v8::Value> wrapper = toV8(document->implementation());
+    v8::Handle<v8::Value> wrapper = V8DOMWrapper::convertDOMImplementationToV8Object(document->implementation());
 
     // Store the wrapper in the internal field.
     info.Holder()->SetInternalField(implementationIndex, wrapper);
diff --git a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp
index f86054b..8dc4672 100644
--- a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp
@@ -27,7 +27,8 @@
 #include "DOMWindow.h"
 #include "Frame.h"
 #include "V8Binding.h"
-#include "V8Location.h"
+#include "V8CustomBinding.h"
+#include "V8Document.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -39,7 +40,7 @@ v8::Handle<v8::Value> V8Document::locationAccessorGetter(v8::Local<v8::String> n
         return v8::Null();
 
     DOMWindow* window = document->frame()->domWindow();
-    return toV8(window->location());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::LOCATION, window->location());
 }
 
 void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8ElementCustom.cpp b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
index b420f6a..9901f1b 100644
--- a/WebCore/bindings/v8/custom/V8ElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
@@ -87,7 +87,7 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeCallback(const v8::Arguments& a
     if (ec)
         throwError(ec);
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> V8Element::setAttributeNSCallback(const v8::Arguments& args)
@@ -126,7 +126,7 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeNSCallback(const v8::Arguments&
     if (ec)
         throwError(ec);
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> toV8(Element* impl, bool forceNewObject)
diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp
index a13603e..41984b6 100644
--- a/WebCore/bindings/v8/custom/V8EventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp
@@ -36,8 +36,8 @@
 #include "Event.h"
 #include "V8BeforeLoadEvent.h"
 #include "V8Binding.h"
-#include "V8Clipboard.h"
 #include "V8CompositionEvent.h"
+#include "V8CustomBinding.h"
 #include "V8ErrorEvent.h"
 #include "V8KeyboardEvent.h"
 #include "V8MessageEvent.h"
@@ -70,7 +70,7 @@ v8::Handle<v8::Value> V8Event::dataTransferAccessorGetter(v8::Local<v8::String>
     Event* event = V8Event::toNative(info.Holder());
 
     if (event->isDragEvent())
-        return toV8(static_cast<MouseEvent*>(event)->clipboard());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<MouseEvent*>(event)->clipboard());
 
     return v8::Undefined();
 }
@@ -80,7 +80,7 @@ v8::Handle<v8::Value> V8Event::clipboardDataAccessorGetter(v8::Local<v8::String>
     Event* event = V8Event::toNative(info.Holder());
 
     if (event->isClipboardEvent())
-        return toV8(static_cast<ClipboardEvent*>(event)->clipboard());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<ClipboardEvent*>(event)->clipboard());
 
     return v8::Undefined();
 }
diff --git a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
index 88b3a9d..c34d9e7 100644
--- a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
@@ -36,8 +36,6 @@
 #include "V8Binding.h"
 #include "V8CustomBinding.h"
 #include "V8NamedNodesCollection.h"
-#include "V8Node.h"
-#include "V8NodeList.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -51,10 +49,10 @@ static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, Atomic
         return v8::Handle<v8::Value>();
 
     if (namedItems.size() == 1)
-        return toV8(namedItems.at(0).release());
+        return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
 
     NodeList* list = new V8NamedNodesCollection(namedItems);
-    return toV8(list);
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
 }
 
 static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v8::Value> argument)
@@ -70,7 +68,7 @@ static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v
     }
 
     RefPtr<Node> result = collection->item(index->Uint32Value());
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> V8HTMLAllCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -132,7 +130,7 @@ v8::Handle<v8::Value> V8HTMLAllCollection::callAsFunctionCallback(const v8::Argu
     Node* node = imp->namedItem(name);
     while (node) {
         if (!current)
-            return toV8(node);
+            return V8DOMWrapper::convertNodeToV8Object(node);
 
         node = imp->nextNamedItem(name);
         current--;
diff --git a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp
index 28b0a99..e634003 100644
--- a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp
@@ -36,7 +36,6 @@
 #include "Frame.h"
 #include "HTMLNames.h"
 #include "V8Binding.h"
-#include "V8Document.h"
 #include "V8HTMLAudioElement.h"
 #include "V8Proxy.h"
 
@@ -79,7 +78,7 @@ v8::Handle<v8::Value> V8Custom::v8HTMLAudioElementConstructorCallback(const v8::
 
     // Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance
     // may end up being the only node in the map and get garbage-ccollected prematurely.
-    toV8(document);
+    V8DOMWrapper::convertNodeToV8Object(document);
 
     RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document);
     audio->setAutobuffer(true);
diff --git a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
index 54a003c..0d1ff44 100644
--- a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
@@ -36,10 +36,9 @@
 #include "HTMLCanvasElement.h"
 #include "WebGLContextAttributes.h"
 #include "V8Binding.h"
-#include "V8CanvasRenderingContext2D.h"
+#include "V8CustomBinding.h"
 #include "V8Node.h"
 #include "V8Proxy.h"
-#include "V8WebGLRenderingContext.h"
 
 namespace WebCore {
 
@@ -78,10 +77,10 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Argument
     if (!result)
         return v8::Undefined();
     if (result->is2d())
-        return toV8(static_cast<CanvasRenderingContext2D*>(result));
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
 #if ENABLE(3D_CANVAS)
     else if (result->is3d())
-        return toV8(static_cast<WebGLRenderingContext*>(result));
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result);
 #endif
     ASSERT_NOT_REACHED();
     return v8::Undefined();
diff --git a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
index 29ff6eb..0741432 100644
--- a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
@@ -36,8 +36,6 @@
 #include "V8CustomBinding.h"
 #include "V8HTMLAllCollection.h"
 #include "V8NamedNodesCollection.h"
-#include "V8Node.h"
-#include "V8NodeList.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -51,10 +49,10 @@ static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicStr
         return v8::Handle<v8::Value>();
 
     if (namedItems.size() == 1)
-        return toV8(namedItems.at(0).release());
+        return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
 
     NodeList* list = new V8NamedNodesCollection(namedItems);
-    return toV8(list);
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
 }
 
 static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::Value> argument)
@@ -70,7 +68,7 @@ static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::
     }
 
     RefPtr<Node> result = collection->item(index->Uint32Value());
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -132,7 +130,7 @@ v8::Handle<v8::Value> V8HTMLCollection::callAsFunctionCallback(const v8::Argumen
     Node* node = imp->namedItem(name);
     while (node) {
         if (!current)
-            return toV8(node);
+            return V8DOMWrapper::convertNodeToV8Object(node);
 
         node = imp->nextNamedItem(name);
         current--;
diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 6478e07..3cb3ee6 100644
--- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -38,11 +38,7 @@
 #include "HTMLIFrameElement.h"
 #include "HTMLNames.h"
 #include "V8Binding.h"
-#include "V8DOMWindow.h"
-#include "V8HTMLAllCollection.h"
-#include "V8HTMLCollection.h"
 #include "V8IsolatedContext.h"
-#include "V8Node.h"
 #include "V8Proxy.h"
 #include <wtf/RefPtr.h>
 #include <wtf/StdLibExtras.h>
@@ -96,12 +92,12 @@ v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String>
         Node* node = items->firstItem();
         Frame* frame = 0;
         if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
-            return toV8(frame->domWindow());
+            return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
 
-        return toV8(node);
+        return V8DOMWrapper::convertNodeToV8Object(node);
     }
 
-    return toV8(items.release());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release());
 }
 
 v8::Handle<v8::Value> V8HTMLDocument::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo &info) 
@@ -186,9 +182,10 @@ v8::Handle<v8::Value> V8HTMLDocument::openCallback(const v8::Arguments& args)
 v8::Handle<v8::Value> V8HTMLDocument::allAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.HTMLDocument.all._get");
+    v8::HandleScope scope;
     v8::Handle<v8::Object> holder = info.Holder();
     HTMLDocument* htmlDocument = V8HTMLDocument::toNative(holder);
-    return toV8(htmlDocument->all());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, htmlDocument->all());
 }
 
 void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp
index 0a9e8dd..d819e9b 100644
--- a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp
@@ -34,9 +34,8 @@
 #include "HTMLCollection.h"
 #include "HTMLFormElement.h"
 #include "V8Binding.h"
+#include "V8CustomBinding.h"
 #include "V8NamedNodesCollection.h"
-#include "V8Node.h"
-#include "V8NodeList.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -49,7 +48,7 @@ v8::Handle<v8::Value> V8HTMLFormElement::indexedPropertyGetter(uint32_t index, c
     RefPtr<Node> formElement = form->elements()->item(index);
     if (!formElement)
         return notHandledByInterceptor();
-    return toV8(formElement.release());
+    return V8DOMWrapper::convertNodeToV8Object(formElement.release());
 }
 
 v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -75,10 +74,10 @@ v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::Strin
     ASSERT(!elements.isEmpty());
 
     if (elements.size() == 1)
-        return toV8(elements.at(0).release());
+        return V8DOMWrapper::convertNodeToV8Object(elements.at(0).release());
 
     NodeList* collection = new V8NamedNodesCollection(elements);
-    return toV8(collection);
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, collection);
 }
 
 v8::Handle<v8::Value> V8HTMLFormElement::submitCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp
index 6a45be7..214b11e 100644
--- a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp
@@ -40,7 +40,7 @@
 #include "Node.h"
 
 #include "V8Binding.h"
-#include "V8DOMWindow.h"
+#include "V8CustomBinding.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -55,7 +55,7 @@ v8::Handle<v8::Value> V8HTMLFrameSetElement::namedPropertyGetter(v8::Local<v8::S
         if (!doc)
             return v8::Undefined();
         if (Frame* frame = doc->frame())
-            return toV8(frame->domWindow());
+            return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
     }
     return notHandledByInterceptor();
 }
diff --git a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
index 2c28fa5..57efa34 100644
--- a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
@@ -36,7 +36,6 @@
 #include "Frame.h"
 #include "HTMLNames.h"
 #include "V8Binding.h"
-#include "V8Document.h"
 #include "V8HTMLImageElement.h"
 #include "V8Proxy.h"
 
@@ -79,7 +78,7 @@ v8::Handle<v8::Value> V8Custom::v8HTMLImageElementConstructorCallback(const v8::
 
     // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
     // may end up being the only node in the map and get garbage-ccollected prematurely.
-    toV8(document);
+    V8DOMWrapper::convertNodeToV8Object(document);
 
     RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document);
     if (args.Length() > 0) {
diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
index 81bc287..c060df7 100644
--- a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
@@ -37,9 +37,9 @@
 
 #include "V8Binding.h"
 #include "V8Collection.h"
+#include "V8CustomBinding.h"
 #include "V8HTMLOptionElement.h"
 #include "V8HTMLSelectElementCustom.h"
-#include "V8Node.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -123,7 +123,7 @@ v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertyGetter(uint32_t in
     if (!result)
         return notHandledByInterceptor();
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
index d0d8dac..4801dc0 100644
--- a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
@@ -37,11 +37,10 @@
 
 #include "V8Binding.h"
 #include "V8Collection.h"
+#include "V8CustomBinding.h"
 #include "V8HTMLOptionElement.h"
 #include "V8HTMLSelectElement.h"
 #include "V8NamedNodesCollection.h"
-#include "V8Node.h"
-#include "V8NodeList.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -68,10 +67,10 @@ v8::Handle<v8::Value> V8HTMLSelectElement::namedPropertyGetter(v8::Local<v8::Str
         return notHandledByInterceptor();
 
     if (items.size() == 1)
-        return toV8(items.at(0).release());
+        return V8DOMWrapper::convertNodeToV8Object(items.at(0).release());
 
     NodeList* list = new V8NamedNodesCollection(items);
-    return toV8(list);
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
 }
 
 v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
@@ -81,7 +80,7 @@ v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertyGetter(uint32_t index,
     if (!result)
         return notHandledByInterceptor();
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index f3dac9c..0ddcf97 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -40,6 +40,7 @@
 #include "Page.h"
 
 #include "V8Binding.h"
+#include "V8CustomBinding.h"
 #include "V8Database.h"
 #include "V8Node.h"
 #include "V8Proxy.h"
@@ -84,7 +85,7 @@ static ScriptObject createInjectedScript(const String& scriptSource, InjectedScr
     v8::Context::Scope contextScope(inspectedContext);
 
     // Call custom code to create InjectedScripHost wrapper specific for the context
-    // instead of calling toV8() that would create the
+    // instead of calling V8DOMWrapper::convertToV8Object that would create the
     // wrapper in the current context.
     // FIXME: make it possible to use generic bindings factory for InjectedScriptHost.
     v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(injectedScriptHost);
@@ -129,7 +130,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Argument
     if (!ic)
         return v8::Undefined();
 
-    return toV8(node);
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
 }
 
 v8::Handle<v8::Value> V8InjectedScriptHost::pushNodePathToFrontendCallback(const v8::Arguments& args)
@@ -159,7 +160,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::databaseForIdCallback(const v8::Argu
     Database* database = host->databaseForId(args[0]->ToInt32()->Value());
     if (!database)
         return v8::Undefined();
-    return toV8(database);
+    return V8DOMWrapper::convertToV8Object<Database>(V8ClassIndex::DATABASE, database);
 }
 
 v8::Handle<v8::Value> V8InjectedScriptHost::selectDatabaseCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp
index 4fb82ba..3ea8e26 100644
--- a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp
+++ b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp
@@ -35,7 +35,6 @@
 #include "Frame.h"
 #include "MessageChannel.h"
 #include "V8Binding.h"
-#include "V8MessagePort.h"
 #include "V8Proxy.h"
 #include "V8Utilities.h"
 #include "WorkerContext.h"
@@ -67,8 +66,8 @@ v8::Handle<v8::Value> V8MessageChannel::constructorCallback(const v8::Arguments&
     // Create references from the MessageChannel wrapper to the two
     // MessagePort wrappers to make sure that the MessagePort wrappers
     // stay alive as long as the MessageChannel wrapper is around.
-    messageChannel->SetInternalField(V8MessageChannel::port1Index, toV8(obj->port1()));
-    messageChannel->SetInternalField(V8MessageChannel::port2Index, toV8(obj->port2()));
+    messageChannel->SetInternalField(V8MessageChannel::port1Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port1()));
+    messageChannel->SetInternalField(V8MessageChannel::port2Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port2()));
 
     // Setup the standard wrapper object internal fields.
     V8DOMWrapper::setDOMWrapper(messageChannel, V8ClassIndex::MESSAGECHANNEL, obj.get());
diff --git a/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp b/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
index 9f2c080..9e40855 100644
--- a/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
@@ -35,8 +35,8 @@
 #include "SerializedScriptValue.h"
 
 #include "V8Binding.h"
+#include "V8CustomBinding.h"
 #include "V8DOMWindow.h"
-#include "V8MessagePort.h"
 #include "V8MessagePortCustom.h"
 #include "V8Proxy.h"
 
@@ -53,7 +53,7 @@ v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String>
 
     v8::Local<v8::Array> portArray = v8::Array::New(ports->size());
     for (size_t i = 0; i < ports->size(); ++i)
-        portArray->Set(v8::Integer::New(i), toV8((*ports)[i].get()));
+        portArray->Set(v8::Integer::New(i), V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, (*ports)[i].get()));
 
     return portArray;
 }
diff --git a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
index 611ab94..4a05b08 100644
--- a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
@@ -33,8 +33,8 @@
 
 #include "NamedNodeMap.h"
 #include "V8Binding.h"
+#include "V8CustomBinding.h"
 #include "V8Element.h"
-#include "V8Node.h"
 #include "V8Proxy.h"
 
 #include <wtf/RefPtr.h>
@@ -49,7 +49,7 @@ v8::Handle<v8::Value> V8NamedNodeMap::indexedPropertyGetter(uint32_t index, cons
     if (!result)
         return notHandledByInterceptor();
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -70,7 +70,7 @@ v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String>
     if (!result)
         return notHandledByInterceptor();
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 v8::Handle<v8::Value> toV8(NamedNodeMap* impl)
diff --git a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp
index 728b3dc..074eac3 100644
--- a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp
@@ -35,7 +35,7 @@
 #include "ScriptState.h"
 
 #include "V8Binding.h"
-#include "V8Node.h"
+#include "V8CustomBinding.h"
 #include "V8Proxy.h"
 
 #include <wtf/PassRefPtr.h>
@@ -54,7 +54,7 @@ static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ExceptionCode
     if (!object)
         return v8::Null();
 
-    return toV8(object);
+    return V8DOMWrapper::convertNodeToV8Object(object);
 }
 
 v8::Handle<v8::Value> V8NodeIterator::nextNodeCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
index 20a5471..5721a7e 100644
--- a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
@@ -32,8 +32,9 @@
 #include "V8NodeList.h" 
 
 #include "NodeList.h"
+
 #include "V8Binding.h"
-#include "V8Node.h"
+#include "V8CustomBinding.h"
 #include "V8Proxy.h"
 
 #include <wtf/RefPtr.h>
@@ -56,7 +57,7 @@ v8::Handle<v8::Value> V8NodeList::namedPropertyGetter(v8::Local<v8::String> name
     if (!result)
         return notHandledByInterceptor();
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 // Need to support call so that list(0) works.
@@ -74,7 +75,7 @@ v8::Handle<v8::Value> V8NodeList::callAsFunctionCallback(const v8::Arguments& ar
         return v8::Undefined();
 
     RefPtr<Node> result = list->item(index->Uint32Value());
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
index 5531b48..1cb4554 100644
--- a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
@@ -37,6 +37,7 @@
 #include "Notification.h"
 #include "NotificationCenter.h"
 #include "V8Binding.h"
+#include "V8CustomBinding.h"
 #include "V8CustomEventListener.h"
 #include "V8CustomVoidCallback.h"
 #include "V8Notification.h"
@@ -94,7 +95,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createHTMLNotificationCallback(const
     if (notificationCenter->context()->isWorkerContext())
         return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
 
-    return toV8(notification.get());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
 }
 
 v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8::Arguments& args)
@@ -111,7 +112,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8:
     if (notificationCenter->context()->isWorkerContext())
         return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
 
-    return toV8(notification.get());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
 }
 
 v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp
index 0a75c9f..78284cd 100644
--- a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp
@@ -31,13 +31,16 @@
 #include <config.h>
 
 #if ENABLE(SVG)
+
 #include "TransformationMatrix.h"
 
 #include "SVGException.h"
+
 #include "V8Binding.h"
-#include "V8Proxy.h"
+#include "V8CustomBinding.h"
 #include "V8SVGMatrix.h"
 #include "V8SVGPODTypeWrapper.h"
+#include "V8Proxy.h"
 
 namespace WebCore {
 
@@ -53,8 +56,7 @@ v8::Handle<v8::Value> V8SVGMatrix::multiplyCallback(const v8::Arguments& args)
     TransformationMatrix m1 = *V8SVGPODTypeWrapper<TransformationMatrix>::toNative(args.Holder());
     TransformationMatrix m2 = *V8SVGPODTypeWrapper<TransformationMatrix>::toNative(v8::Handle<v8::Object>::Cast(args[0]));
 
-    RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2));
-    return toV8(wrapper.get());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2)));
 }
 
 v8::Handle<v8::Value> V8SVGMatrix::inverseCallback(const v8::Arguments& args)
@@ -72,8 +74,7 @@ v8::Handle<v8::Value> V8SVGMatrix::inverseCallback(const v8::Arguments& args)
         return v8::Handle<v8::Value>();
     }
 
-    RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result);
-    return toV8(wrapper.get());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result));
 }
 
 v8::Handle<v8::Value> V8SVGMatrix::rotateFromVectorCallback(const v8::Arguments& args)
@@ -93,8 +94,7 @@ v8::Handle<v8::Value> V8SVGMatrix::rotateFromVectorCallback(const v8::Arguments&
         return v8::Handle<v8::Value>();
     }
 
-    RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result);
-    return toV8(wrapper.get());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result));
 }
 
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp
index cee1838..a718451 100644
--- a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp
@@ -34,8 +34,8 @@
 #include "HTMLStyleElement.h"
 #include "StyleSheetList.h"
 #include "V8Binding.h"
+#include "V8CustomBinding.h"
 #include "V8Proxy.h"
-#include "V8StyleSheet.h"
 
 namespace WebCore {
 
@@ -52,7 +52,7 @@ v8::Handle<v8::Value> V8StyleSheetList::namedPropertyGetter(v8::Local<v8::String
     if (!item)
         return notHandledByInterceptor();
 
-    return toV8(item->sheet());
+    return V8DOMWrapper::convertToV8Object(V8ClassIndex::STYLESHEET, item->sheet());
 }
 
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
index 37087df..866fae2 100644
--- a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
@@ -36,7 +36,7 @@
 #include "TreeWalker.h"
 
 #include "V8Binding.h"
-#include "V8Node.h"
+#include "V8CustomBinding.h"
 #include "V8Proxy.h"
 
 #include <wtf/PassRefPtr.h>
@@ -52,7 +52,7 @@ static inline v8::Handle<v8::Value> toV8Object(PassRefPtr<Node> object, ScriptSt
     if (!object)
         return v8::Null();
 
-    return toV8(object);
+    return V8DOMWrapper::convertNodeToV8Object(object);
 }
 
 v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index 78de5e6..1961d39 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -42,16 +42,12 @@
 
 #include "V8Binding.h"
 #include "V8WebGLArray.h"
-#include "V8WebGLBuffer.h"
 #include "V8WebGLByteArray.h"
 #include "V8WebGLFloatArray.h"
-#include "V8WebGLFramebuffer.h"
 #include "V8WebGLIntArray.h"
 #include "V8WebGLProgram.h"
-#include "V8WebGLRenderbuffer.h"
 #include "V8WebGLShader.h"
 #include "V8WebGLShortArray.h"
-#include "V8WebGLTexture.h"
 #include "V8WebGLUniformLocation.h"
 #include "V8WebGLUnsignedByteArray.h"
 #include "V8WebGLUnsignedIntArray.h"
@@ -195,23 +191,23 @@ static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info)
     case WebGLGetInfo::kTypeUnsignedLong:
         return v8::Integer::NewFromUnsigned(info.getUnsignedLong());
     case WebGLGetInfo::kTypeWebGLBuffer:
-        return toV8(info.getWebGLBuffer());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLBUFFER, info.getWebGLBuffer());
     case WebGLGetInfo::kTypeWebGLFloatArray:
-        return toV8(info.getWebGLFloatArray());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFLOATARRAY, info.getWebGLFloatArray());
     case WebGLGetInfo::kTypeWebGLFramebuffer:
-        return toV8(info.getWebGLFramebuffer());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFRAMEBUFFER, info.getWebGLFramebuffer());
     case WebGLGetInfo::kTypeWebGLIntArray:
-        return toV8(info.getWebGLIntArray());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLINTARRAY, info.getWebGLIntArray());
     // FIXME: implement WebGLObjectArray
     // case WebGLGetInfo::kTypeWebGLObjectArray:
     case WebGLGetInfo::kTypeWebGLProgram:
-        return toV8(info.getWebGLProgram());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLPROGRAM, info.getWebGLProgram());
     case WebGLGetInfo::kTypeWebGLRenderbuffer:
-        return toV8(info.getWebGLRenderbuffer());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERBUFFER, info.getWebGLRenderbuffer());
     case WebGLGetInfo::kTypeWebGLTexture:
-        return toV8(info.getWebGLTexture());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLTEXTURE, info.getWebGLTexture());
     case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
-        return toV8(info.getWebGLUnsignedByteArray());
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY, info.getWebGLUnsignedByteArray());
     default:
         notImplemented();
         return v8::Undefined();
diff --git a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp
index 89f804c..fd0305a 100644
--- a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp
@@ -36,8 +36,8 @@
 #include "Node.h"
 
 #include "V8Binding.h"
+#include "V8CustomBinding.h"
 #include "V8Document.h"
-#include "V8DocumentFragment.h"
 #include "V8Node.h"
 #include "V8Proxy.h"
 #include "XSLTProcessor.h"
@@ -78,7 +78,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToFragmentCallback(const v8::Arg
     Node* source = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0]));
     Document* owner = V8Document::toNative(v8::Handle<v8::Object>::Cast(args[1]));
     RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner);
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 
@@ -99,7 +99,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToDocumentCallback(const v8::Arg
     if (!result)
         return v8::Undefined();
 
-    return toV8(result.release());
+    return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list