[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

japhet at chromium.org japhet at chromium.org
Thu Feb 4 21:35:39 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit c8796878fc7ad34e744a9d86adddcd042e1a4583
Author: japhet at chromium.org <japhet at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Feb 1 22:12:14 2010 +0000

    2010-02-01  Nate Chapin  <japhet at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            [V8] Generate toV8() converter for most WebCore->V8 conversions,
            and defined custom converters in their respective V8<class>Custom.cpp.
    
            Old converters in V8DOMWrapper will be deleted in a later patch.
    
            https://bugs.webkit.org/show_bug.cgi?id=32563
    
            * Android.v8bindings.mk:
            * WebCore.gyp/WebCore.gyp:
            * WebCore.gypi:
            * bindings/scripts/CodeGeneratorV8.pm:
            * bindings/v8/V8Collection.h:
            * bindings/v8/V8DOMWrapper.cpp:
            * bindings/v8/V8DOMWrapper.h:
            * bindings/v8/V8Proxy.h:
            * bindings/v8/custom/V8BarInfoCustom.cpp: Added.
            * bindings/v8/custom/V8CSSRuleCustom.cpp: Added.
            * bindings/v8/custom/V8CSSStyleSheetCustom.cpp: Added.
            * bindings/v8/custom/V8CSSValueCustom.cpp: Added.
            * bindings/v8/custom/V8CanvasPixelArrayCustom.cpp: Added.
            * bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp:
            * bindings/v8/custom/V8ConsoleCustom.cpp:
            * bindings/v8/custom/V8DOMSelectionCustom.cpp: Added.
            * bindings/v8/custom/V8DOMWindowCustom.cpp:
            * bindings/v8/custom/V8DocumentCustom.cpp:
            * bindings/v8/custom/V8ElementCustom.cpp:
            * bindings/v8/custom/V8EventCustom.cpp:
            * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
            * bindings/v8/custom/V8HTMLElementCustom.cpp: Added.
            * bindings/v8/custom/V8HTMLSelectElementCustom.cpp:
            * bindings/v8/custom/V8HistoryCustom.cpp:
            * bindings/v8/custom/V8LocationCustom.cpp:
            * bindings/v8/custom/V8NamedNodeMapCustom.cpp:
            * bindings/v8/custom/V8NavigatorCustom.cpp:
            * bindings/v8/custom/V8NodeCustom.cpp:
            * bindings/v8/custom/V8SVGDocumentCustom.cpp: Added.
            * bindings/v8/custom/V8SVGElementCustom.cpp: Added.
            * bindings/v8/custom/V8SVGPathSegCustom.cpp: Added.
            * bindings/v8/custom/V8ScreenCustom.cpp: Added.
            * bindings/v8/custom/V8StyleSheetCustom.cpp: Added.
            * bindings/v8/custom/V8TreeWalkerCustom.cpp:
            * bindings/v8/custom/V8WebGLArrayCustom.cpp: Added.
            * bindings/v8/custom/V8WebGLByteArrayCustom.cpp:
            * bindings/v8/custom/V8WebGLFloatArrayCustom.cpp:
            * bindings/v8/custom/V8WebGLIntArrayCustom.cpp:
            * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
            * bindings/v8/custom/V8WebGLShortArrayCustom.cpp:
            * bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp:
            * bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp:
            * bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp:
            * dom/make_names.pl: Add options to generate wrapper factory for V8 bindings.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54150 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk
index 1230bc2..a8fdd33 100644
--- a/WebCore/Android.v8bindings.mk
+++ b/WebCore/Android.v8bindings.mk
@@ -87,8 +87,13 @@ LOCAL_SRC_FILES += \
 	\
 	bindings/v8/custom/V8AbstractWorkerCustom.cpp \
 	bindings/v8/custom/V8AttrCustom.cpp \
+	bindings/v8/custom/V8BarInfoCustom.cpp \
+	bindings/v8/custom/V8CSSRuleCustom.cpp \
 	bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp \
+	bindings/v8/custom/V8CSSStyleSheetCustom.cpp \
+	bindings/v8/custom/V8CSSValueCustom.cpp \
 	bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp \
+	bindings/v8/custom/V8CanvasPixelArrayCustom.cpp \
 	bindings/v8/custom/V8ClientRectListCustom.cpp \
 	bindings/v8/custom/V8ClipboardCustom.cpp \
 	bindings/v8/custom/V8CoordinatesCustom.cpp \
@@ -101,6 +106,7 @@ LOCAL_SRC_FILES += \
 	bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp \
 	bindings/v8/custom/V8CustomVoidCallback.cpp \
 	bindings/v8/custom/V8DOMApplicationCacheCustom.cpp \
+	bindings/v8/custom/V8DOMSelectionCustom.cpp \
 	bindings/v8/custom/V8DOMWindowCustom.cpp \
 	bindings/v8/custom/V8DataGridColumnListCustom.cpp \
 	bindings/v8/custom/V8DatabaseCustom.cpp \
@@ -119,6 +125,7 @@ LOCAL_SRC_FILES += \
 	bindings/v8/custom/V8HTMLCollectionCustom.cpp \
 	bindings/v8/custom/V8HTMLDataGridElementCustom.cpp \
 	bindings/v8/custom/V8HTMLDocumentCustom.cpp \
+	bindings/v8/custom/V8HTMLElementCustom.cpp \
 	bindings/v8/custom/V8HTMLFormElementCustom.cpp \
 	bindings/v8/custom/V8HTMLFrameElementCustom.cpp \
 	bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp \
@@ -140,20 +147,25 @@ LOCAL_SRC_FILES += \
 	bindings/v8/custom/V8NodeFilterCustom.cpp \
 	bindings/v8/custom/V8NodeIteratorCustom.cpp \
 	bindings/v8/custom/V8NodeListCustom.cpp \
+	bindings/v8/custom/V8ScreenCustom.cpp \
 	bindings/v8/custom/V8SQLResultSetRowListCustom.cpp \
 	bindings/v8/custom/V8SQLTransactionCustom.cpp \
 	bindings/v8/custom/V8WebSocketCustom.cpp
 
 ifeq ($(ENABLE_SVG), true)
 LOCAL_SRC_FILES += \
+	bindings/v8/custom/V8SVGDocumentCustom.cpp \
+	bindings/v8/custom/V8SVGElementCustom.cpp \
 	bindings/v8/custom/V8SVGElementInstanceCustom.cpp \
 	bindings/v8/custom/V8SVGLengthCustom.cpp \
 	bindings/v8/custom/V8SVGMatrixCustom.cpp
+	bindings/v8/custom/V8SVGPathSegCustom.cpp \
 endif
 
 LOCAL_SRC_FILES += \
 	bindings/v8/custom/V8SharedWorkerCustom.cpp \
 	bindings/v8/custom/V8StorageCustom.cpp \
+	bindings/v8/custom/V8StyleSheetCustom.cpp \
 	bindings/v8/custom/V8StyleSheetListCustom.cpp \
 	bindings/v8/custom/V8TreeWalkerCustom.cpp \
 	bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp \
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8dcea8d..2888743 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,59 @@
+2010-02-01  Nate Chapin  <japhet at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        [V8] Generate toV8() converter for most WebCore->V8 conversions,
+        and defined custom converters in their respective V8<class>Custom.cpp.
+
+        Old converters in V8DOMWrapper will be deleted in a later patch.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32563
+
+        * Android.v8bindings.mk:
+        * WebCore.gyp/WebCore.gyp:
+        * WebCore.gypi:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/V8Collection.h:
+        * bindings/v8/V8DOMWrapper.cpp:
+        * bindings/v8/V8DOMWrapper.h:
+        * bindings/v8/V8Proxy.h:
+        * bindings/v8/custom/V8BarInfoCustom.cpp: Added.
+        * bindings/v8/custom/V8CSSRuleCustom.cpp: Added.
+        * bindings/v8/custom/V8CSSStyleSheetCustom.cpp: Added.
+        * bindings/v8/custom/V8CSSValueCustom.cpp: Added.
+        * bindings/v8/custom/V8CanvasPixelArrayCustom.cpp: Added.
+        * bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp:
+        * bindings/v8/custom/V8ConsoleCustom.cpp:
+        * bindings/v8/custom/V8DOMSelectionCustom.cpp: Added.
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        * bindings/v8/custom/V8DocumentCustom.cpp:
+        * bindings/v8/custom/V8ElementCustom.cpp:
+        * bindings/v8/custom/V8EventCustom.cpp:
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        * bindings/v8/custom/V8HTMLElementCustom.cpp: Added.
+        * bindings/v8/custom/V8HTMLSelectElementCustom.cpp:
+        * bindings/v8/custom/V8HistoryCustom.cpp:
+        * bindings/v8/custom/V8LocationCustom.cpp:
+        * bindings/v8/custom/V8NamedNodeMapCustom.cpp:
+        * bindings/v8/custom/V8NavigatorCustom.cpp:
+        * bindings/v8/custom/V8NodeCustom.cpp:
+        * bindings/v8/custom/V8SVGDocumentCustom.cpp: Added.
+        * bindings/v8/custom/V8SVGElementCustom.cpp: Added.
+        * bindings/v8/custom/V8SVGPathSegCustom.cpp: Added.
+        * bindings/v8/custom/V8ScreenCustom.cpp: Added.
+        * bindings/v8/custom/V8StyleSheetCustom.cpp: Added.
+        * bindings/v8/custom/V8TreeWalkerCustom.cpp:
+        * bindings/v8/custom/V8WebGLArrayCustom.cpp: Added.
+        * bindings/v8/custom/V8WebGLByteArrayCustom.cpp:
+        * bindings/v8/custom/V8WebGLFloatArrayCustom.cpp:
+        * bindings/v8/custom/V8WebGLIntArrayCustom.cpp:
+        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+        * bindings/v8/custom/V8WebGLShortArrayCustom.cpp:
+        * bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp:
+        * bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp:
+        * bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp:
+        * dom/make_names.pl: Add options to generate wrapper factory for V8 bindings.
+
 2010-02-01  Alexander Pavlov  <apavlov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/WebCore.gyp/WebCore.gyp b/WebCore/WebCore.gyp/WebCore.gyp
index 184990a..e40da56 100644
--- a/WebCore/WebCore.gyp/WebCore.gyp
+++ b/WebCore/WebCore.gyp/WebCore.gyp
@@ -302,9 +302,8 @@
             '<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLNames.cpp',
             '<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLNames.h',
             '<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLElementFactory.cpp',
-            # Pass --wrapperFactory to make_names to get these (JSC build?)
-            #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSHTMLElementWrapperFactory.cpp',
-            #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSHTMLElementWrapperFactory.h',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.cpp',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.h',
           ],
           'action': [
             'python',
@@ -314,6 +313,7 @@
             '<@(_inputs)',
             '--',
             '--factory',
+            '--wrapperFactoryV8',
             '--extraDefines', '<(feature_defines)'
           ],
         },
@@ -329,9 +329,8 @@
             '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGNames.h',
             '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGElementFactory.cpp',
             '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGElementFactory.h',
-            # Pass --wrapperFactory to make_names to get these (JSC build?)
-            #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSSVGElementWrapperFactory.cpp',
-            #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSSVGElementWrapperFactory.h',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/V8SVGElementWrapperFactory.cpp',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/V8SVGElementWrapperFactory.h',
           ],
           'action': [
             'python',
@@ -341,6 +340,7 @@
             '<@(_inputs)',
             '--',
             '--factory',
+            '--wrapperFactoryV8',
             '--extraDefines', '<(feature_defines)'
           ],
         },
@@ -586,6 +586,8 @@
         '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGElementFactory.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGNames.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/UserAgentStyleSheetsData.cpp',
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.cpp',
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/V8SVGElementWrapperFactory.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/XLinkNames.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/XMLNSNames.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/XMLNames.cpp',
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index fc5f70e..d82a4e1 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -654,7 +654,10 @@
             'bindings/v8/ChildThreadDOMData.h',
             'bindings/v8/custom/V8AbstractWorkerCustom.cpp',
             'bindings/v8/custom/V8AttrCustom.cpp',
+            'bindings/v8/custom/V8BarInfoCustom.cpp',
+            'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp',
             'bindings/v8/custom/V8WebGLArrayCustom.h',
+            'bindings/v8/custom/V8WebGLArrayCustom.cpp',
             'bindings/v8/custom/V8WebGLArrayBufferCustom.cpp',
             'bindings/v8/custom/V8WebGLByteArrayCustom.cpp',
             'bindings/v8/custom/V8WebGLIntArrayCustom.cpp',
@@ -667,7 +670,10 @@
             'bindings/v8/custom/V8WebGLRenderingContextCustom.cpp',
             'bindings/v8/custom/V8ClipboardCustom.cpp',
             'bindings/v8/custom/V8CoordinatesCustom.cpp',
+            'bindings/v8/custom/V8CSSRuleCustom.cpp',
             'bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp',
+            'bindings/v8/custom/V8CSSStyleSheetCustom.cpp',
+            'bindings/v8/custom/V8CSSValueCustom.cpp',
             'bindings/v8/custom/V8ConsoleCustom.cpp',
             'bindings/v8/custom/V8CustomBinding.h',
             'bindings/v8/custom/V8CustomEventListener.cpp',
@@ -693,6 +699,7 @@
             'bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp',
             'bindings/v8/custom/V8DocumentLocationCustom.cpp',
             'bindings/v8/custom/V8DOMApplicationCacheCustom.cpp',
+            'bindings/v8/custom/V8DOMSelectionCustom.cpp',
             'bindings/v8/custom/V8DOMWindowCustom.cpp',
             'bindings/v8/custom/V8DocumentCustom.cpp',
             'bindings/v8/custom/V8ElementCustom.cpp',
@@ -708,6 +715,7 @@
             'bindings/v8/custom/V8HTMLCollectionCustom.cpp',
             'bindings/v8/custom/V8HTMLDataGridElementCustom.cpp',
             'bindings/v8/custom/V8HTMLDocumentCustom.cpp',
+            'bindings/v8/custom/V8HTMLElementCustom.cpp',
             'bindings/v8/custom/V8HTMLFormElementCustom.cpp',
             'bindings/v8/custom/V8HTMLFrameElementCustom.cpp',
             'bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp',
@@ -743,10 +751,15 @@
             'bindings/v8/custom/V8StorageCustom.cpp',
             'bindings/v8/custom/V8SQLResultSetRowListCustom.cpp',
             'bindings/v8/custom/V8SQLTransactionCustom.cpp',
+            'bindings/v8/custom/V8SVGDocumentCustom.cpp',
+            'bindings/v8/custom/V8SVGElementCustom.cpp',
             'bindings/v8/custom/V8SVGElementInstanceCustom.cpp',
             'bindings/v8/custom/V8SVGLengthCustom.cpp',
             'bindings/v8/custom/V8SVGMatrixCustom.cpp',
+            'bindings/v8/custom/V8SVGPathSegCustom.cpp',
+            'bindings/v8/custom/V8ScreenCustom.cpp',
             'bindings/v8/custom/V8SharedWorkerCustom.cpp',
+            'bindings/v8/custom/V8StyleSheetCustom.cpp',
             'bindings/v8/custom/V8StyleSheetListCustom.cpp',
             'bindings/v8/custom/V8TreeWalkerCustom.cpp',
             'bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp',
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 1da8517..75c2077 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -156,14 +156,15 @@ sub AddIncludesForType
 
     # When we're finished with the one-file-per-class
     # reorganization, we won't need these special cases.
-    if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)) {
-    } elsif ($type =~ /SVGPathSeg/) {
-        $joinedName = $type;
-        $joinedName =~ s/Abs|Rel//;
-        $implIncludes{"${joinedName}.h"} = 1;
-    } else {
+    if (!$codeGenerator->IsPrimitiveType($type) and !AvoidInclusionOfType($type) and $type ne "Date") {
         # default, include the same named file
-        $implIncludes{GetImplementationFileName(${type})} = 1;
+        $implIncludes{GetV8HeaderName(${type})} = 1;
+
+        if ($type =~ /SVGPathSeg/) {
+            $joinedName = $type;
+            $joinedName =~ s/Abs|Rel//;
+            $implIncludes{"${joinedName}.h"} = 1;
+        }
     }
 
     # additional includes (things needed to compile the bindings but not the header)
@@ -210,17 +211,6 @@ sub AddClassForwardIfNeeded
     push(@headerContent, "class $implClassName;\n\n") unless $codeGenerator->IsSVGAnimatedType($implClassName);
 }
 
-sub GetImplementationFileName
-{
-    my $iface = shift;
-    return "Event.h" if $iface eq "DOMTimeStamp";
-    return "NamedAttrMap.h" if $iface eq "NamedNodeMap";
-    return "NameNodeList.h" if $iface eq "NodeList";
-    return "XMLHttpRequest.h" if $iface eq "XMLHttpRequest";
-
-    return "${iface}.h";
-}
-
 # If the node has a [Conditional=XXX] attribute, returns an "ENABLE(XXX)" string for use in an #if.
 sub GenerateConditionalString
 {
@@ -258,7 +248,6 @@ sub GenerateHeader
 
     # Get correct pass/store types respecting PODType flag
     my $podType = $dataNode->extendedAttributes->{"PODType"};
-    my $passType = $podType ? "JSSVGPODTypeWrapper<$podType>*" : "$implClassName*";
 
     push(@headerContent, "#include \"$podType.h\"\n") if $podType and ($podType ne "double" and $podType ne "float" and $podType ne "RGBA32");
 
@@ -268,15 +257,23 @@ sub GenerateHeader
     push(@headerContent, "#include \"V8Index.h\"\n");
     push(@headerContent, GetHeaderClassInclude($implClassName));
     push(@headerContent, "\nnamespace WebCore {\n");
+    if ($podType) {
+        push(@headerContent, "\ntemplate<typename PODType> class V8SVGPODTypeWrapper;\n");
+    }
     push(@headerContent, "\nclass $className {\n");
-    
-    my $toNativeReturnType = GetReturnTypeForToNative($interfaceName);
+
+    my $nativeType = GetNativeTypeForConversions($interfaceName);
+    if ($podType) {
+        $nativeType = "V8SVGPODTypeWrapper<${nativeType} >";
+    }
+    my $forceNewObjectParameter = IsDOMNodeType($interfaceName) ? ", bool forceNewObject = false" : "";
     push(@headerContent, <<END);
 
  public:
   static bool HasInstance(v8::Handle<v8::Value> value);
   static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
-  static ${toNativeReturnType}* toNative(v8::Handle<v8::Object>);
+  static ${nativeType}* toNative(v8::Handle<v8::Object>);
+  static v8::Handle<v8::Object> wrap(${nativeType}*${forceNewObjectParameter});
 END
 
     if ($implClassName eq "DOMWindow") {
@@ -346,7 +343,13 @@ END
   friend class V8ClassIndex;
 };
 
+  v8::Handle<v8::Value> toV8(${nativeType}*${forceNewObjectParameter});
+END
+    if (IsRefPtrType($implClassName)) {
+        push(@headerContent, <<END);
+  v8::Handle<v8::Value> toV8(PassRefPtr<${nativeType} >${forceNewObjectParameter});
 END
+    }
 
     push(@headerContent, "}\n\n");
     push(@headerContent, "#endif // $className" . "_H\n");
@@ -665,7 +668,7 @@ sub GenerateNormalAttrGetter
         $attrIsPodType = 0;
     }
 
-    my $getterStringUsesImp = $implClassName ne "double";
+    my $getterStringUsesImp = $implClassName ne "float";
 
   # Getter
     push(@implContentDecls, <<END);
@@ -821,13 +824,16 @@ END
             push(@implContentDecls, GenerateSVGContextAssignment($implClassName, "wrapper.get()", "    "));
         } else {
             push(@implContentDecls, GenerateSVGContextRetrieval($implClassName, "    "));
-            $result = "V8Proxy::withSVGContext($result, context)";
+            # The templating associated with passing withSVGContext()'s return value directly into toV8 can get compilers confused,
+            # so just manually set the return value to a PassRefPtr of the expected type.
+            push(@implContentDecls, "    PassRefPtr<$attrType> resultAsPassRefPtr = V8Proxy::withSVGContext($result, context);\n");
+            $result = "resultAsPassRefPtr";
         }
     }
 
     if ($attrIsPodType) {
-        my $classIndex = uc($attrType);
-        push(@implContentDecls, "    return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n");
+        $implIncludes{"V8${attrType}.h"} = 1;
+        push(@implContentDecls, "    return toV8(wrapper.release().get());\n");
     } else {
         push(@implContentDecls, "    " . ReturnNativeToJSValue($attribute->signature, $result, "    ").";\n");
     }
@@ -943,7 +949,7 @@ END
         push(@implContentDecls, "    ExceptionCode ec = 0;\n");
     }
 
-    if ($implClassName eq "double") {
+    if ($implClassName eq "float") {
         push(@implContentDecls, "    *imp = $result;\n");
     } else {
         my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName);
@@ -1472,7 +1478,9 @@ sub GenerateImplementation
          "#include \"config.h\"\n" .
          "#include \"V8Proxy.h\"\n" .
          "#include \"V8Binding.h\"\n" .
-         "#include \"V8BindingState.h\"\n\n" .
+         "#include \"V8BindingState.h\"\n" .
+         "#include \"V8DOMWrapper.h\"\n" .
+         "#include \"V8IsolatedContext.h\"\n\n" .
          "#undef LOG\n\n");
 
     push(@implFixedHeader, "\n#if ${conditionalString}\n\n") if $conditionalString;
@@ -1888,7 +1896,10 @@ END
 END
     }
 
-    $toNativeReturnType = GetReturnTypeForToNative($interfaceName);
+    my $nativeType = GetNativeTypeForConversions($interfaceName);
+    if ($dataNode->extendedAttributes->{"PODType"}) {
+        $nativeType = "V8SVGPODTypeWrapper<${nativeType}>";
+    }
     push(@implContent, <<END);
   
   // Custom toString template
@@ -1906,8 +1917,8 @@ v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() {
   return ${className}_cache_;
 }
 
-${toNativeReturnType}* ${className}::toNative(v8::Handle<v8::Object> object) {
-  return reinterpret_cast<${toNativeReturnType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); 
+${nativeType}* ${className}::toNative(v8::Handle<v8::Object> object) {
+  return reinterpret_cast<${nativeType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); 
 }
 
 bool ${className}::HasInstance(v8::Handle<v8::Value> value) {
@@ -1928,6 +1939,8 @@ v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate() {
 }
 END
     }
+    
+    GenerateToV8Converters($dataNode, $interfaceName, $className, $nativeType);
 
     push(@implContent, <<END);
 } // namespace WebCore
@@ -1936,7 +1949,171 @@ END
     push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
 }
 
-sub GetReturnTypeForToNative
+sub GenerateToV8Converters 
+{
+    my $dataNode = shift;
+    my $interfaceName = shift;
+    my $className = shift;
+    my $nativeType = shift;
+    
+    my $wrapperType = "V8ClassIndex::" . uc($interfaceName);
+    my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName);
+    my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : "";
+    my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : "";
+    
+    push(@implContent, <<END);   
+
+v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) {
+  V8Proxy* proxy = 0;
+  v8::Handle<v8::Object> wrapper;
+END
+
+    if (IsNodeSubType($dataNode)) {
+        push(@implContent, <<END);
+  if (impl->document()) {
+    proxy = V8Proxy::retrieve(impl->document()->frame());
+    if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl))
+      proxy->windowShell()->initContextIfNeeded();
+  }
+
+END
+    }
+
+    if ($domMapFunction) {
+        push(@implContent, "  if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName);
+        if (IsNodeSubType($dataNode)) {
+            push(@implContent, "  wrapper = V8DOMWrapper::getWrapper(impl);\n");
+        } else {
+            push(@implContent, "  wrapper = ${domMapFunction}.get(impl);\n");
+        }
+        push(@implContent, <<END);
+  if (!wrapper.IsEmpty())
+    return wrapper;
+END
+        push(@implContent, "  }\n") if IsDOMNodeType($interfaceName);
+    }
+    if (IsNodeSubType($dataNode)) {
+        push(@implContent, <<END);
+
+  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();
+END
+    }
+
+    push(@implContent, <<END);
+  wrapper = V8DOMWrapper::instantiateV8Object(proxy, ${wrapperType}, impl);
+END
+
+    if (IsNodeSubType($dataNode)) {
+        push(@implContent, <<END);
+  // Exit the node's context if it was entered.
+  if (!context.IsEmpty())
+    context->Exit();
+END
+    }
+    
+    push(@implContent, <<END);
+  if (wrapper.IsEmpty())
+    return wrapper;
+END
+    push(@implContent, "\n  impl->ref();\n") if IsRefPtrType($interfaceName);
+
+    if ($domMapFunction) {
+        push(@implContent, <<END);
+  ${domMapFunction}.set(impl, v8::Persistent<v8::Object>::New(wrapper));
+END
+    }
+
+    push(@implContent, <<END);
+  return wrapper;
+}
+END
+
+    if (IsRefPtrType($interfaceName)) {
+        push(@implContent, <<END);
+
+v8::Handle<v8::Value> toV8(PassRefPtr<${nativeType} > impl${forceNewObjectInput}) {
+  return toV8(impl.get()${forceNewObjectCall});
+}
+END
+    }
+    
+    if (!HasCustomToV8Implementation($dataNode, $interfaceName)) {
+        push(@implContent, <<END);
+
+v8::Handle<v8::Value> toV8(${nativeType}* impl${forceNewObjectInput}) {
+  if (!impl)
+    return v8::Null();
+  return ${className}::wrap(impl${forceNewObjectCall});
+}
+END
+    }
+}
+
+sub HasCustomToV8Implementation {
+    # FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)?
+    $dataNode = shift;
+    $interfaceName = shift;
+    
+    # We generate a custom converter (but JSC doesn't) for the following:
+    return 1 if $interfaceName eq "BarInfo";
+    return 1 if $interfaceName eq "CSSStyleSheet";
+    return 1 if $interfaceName eq "CanvasPixelArray";
+    return 1 if $interfaceName eq "Console";
+    return 1 if $interfaceName eq "DOMSelection";
+    return 1 if $interfaceName eq "DOMWindow";
+    return 1 if $interfaceName eq "Element";
+    return 1 if $interfaceName eq "Location";
+    return 1 if $interfaceName eq "HTMLDocument";
+    return 1 if $interfaceName eq "HTMLElement";
+    return 1 if $interfaceName eq "History";
+    return 1 if $interfaceName eq "NamedNodeMap";
+    return 1 if $interfaceName eq "Navigator";
+    return 1 if $interfaceName eq "SVGDocument";
+    return 1 if $interfaceName eq "SVGElement";
+    return 1 if $interfaceName eq "Screen";
+    
+    # We don't generate a custom converter (but JSC does) for the following:
+    return 0 if $interfaceName eq "AbstractWorker";
+    return 0 if $interfaceName eq "CanvasRenderingContext";
+    return 0 if $interfaceName eq "ImageData";
+    return 0 if $interfaceName eq "SVGElementInstance";
+
+    # For everything else, do what JSC does.
+    return $dataNode->extendedAttributes->{"CustomToJS"};
+}
+
+sub GetDomMapFunction
+{
+    my $dataNode = shift;
+    my $type = shift;
+    return "getDOMSVGElementInstanceMap()" if $type eq "SVGElementInstance";
+    return "getDOMNodeMap()" if IsNodeSubType($dataNode);
+    # Only use getDOMSVGObjectWithContextMap() for non-node svg objects
+    return "getDOMSVGObjectWithContextMap()" if $type =~ /SVG/;
+    return "" if $type eq "DOMImplementation";
+    return "getActiveDOMObjectMap()" if IsActiveDomType($type);
+    return "getDOMObjectMap()";
+}
+
+sub IsActiveDomType
+{
+    # FIXME: Consider making this an .idl attribute.
+    my $type = shift;
+    return 1 if $type eq "MessagePort";
+    return 1 if $type eq "XMLHttpRequest";
+    return 1 if $type eq "WebSocket";
+    return 1 if $type eq "Worker";
+    return 1 if $type eq "SharedWorker";
+    return 0;
+}
+
+sub GetNativeTypeForConversions
 {
     my $type = shift;
     return "FloatRect" if $type eq "SVGRect";
@@ -1991,7 +2168,6 @@ sub GenerateFunctionCallString()
 
     my $first = 1;
     my $index = 0;
-    my $nodeToReturn = 0;
 
     foreach my $parameter (@{$function->parameters}) {
         if ($index eq $numberOfParameters) {
@@ -2013,10 +2189,6 @@ sub GenerateFunctionCallString()
         } else {
             $functionString .= $paramName;
         }
-
-        if ($parameter->extendedAttributes->{"Return"}) {
-            $nodeToReturn = $parameter->name;
-        }
         $index++;
     }
 
@@ -2035,19 +2207,7 @@ sub GenerateFunctionCallString()
     my $return = "result";
     my $returnIsRef = IsRefPtrType($returnType);
 
-    if ($nodeToReturn) {
-        # Special case for insertBefore, replaceChild, removeChild and
-        # appendChild functions from Node.
-        $result .= $indent . "bool success = $functionString;\n";
-        if (@{$function->raisesExceptions}) {
-            $result .= $indent . "if (UNLIKELY(ec)) goto fail;\n";
-        }
-        $result .= $indent . "if (success)\n";
-        $result .= $indent . "    " .
-            "return V8DOMWrapper::convertNodeToV8Object($nodeToReturn);\n";
-        $result .= $indent . "return v8::Null();\n";
-        return $result;
-    } elsif ($returnType eq "void") {
+    if ($returnType eq "void") {
         $result .= $indent . "$functionString;\n";
     } elsif ($copyFirst) {
         $result .=
@@ -2106,8 +2266,8 @@ sub GenerateFunctionCallString()
     }
 
     if ($returnsPodType) {
-        my $classIndex = uc($returnType);
-        $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n";
+        $implIncludes{"V8${returnType}.h"} = 1;
+        $result .= $indent . "return toV8(wrapper.release());\n";
     } else {
         $return .= ".release()" if ($returnIsRef);
         $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n";
@@ -2167,6 +2327,7 @@ sub IsRefPtrType
     return 0 if $type eq "unsigned";
     return 0 if $type eq "unsigned long";
     return 0 if $type eq "unsigned short";
+    return 0 if $type eq "SVGAnimatedPoints";
 
     return 1;
 }
@@ -2207,7 +2368,7 @@ sub GetNativeType
     return "SVGTransform" if $type eq "SVGTransform";
     return "SVGLength" if $type eq "SVGLength";
     return "SVGAngle" if $type eq "SVGAngle";
-    return "double" if $type eq "SVGNumber";
+    return "float" if $type eq "SVGNumber";
     return "SVGPreserveAspectRatio" if $type eq "SVGPreserveAspectRatio";
     return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType";
     return "DOMTimeStamp" if $type eq "DOMTimeStamp";
@@ -2422,7 +2583,11 @@ sub JSValueToNative
 sub GetV8HeaderName
 {
     my $type = shift;
-    return "V8" . GetImplementationFileName($type);
+    return "V8Event.h" if $type eq "DOMTimeStamp";
+    return "EventListener.h" if $type eq "EventListener";
+    return "EventTarget.h" if $type eq "EventTarget";
+    return "SerializedScriptValue.h" if $type eq "SerializedScriptValue";
+    return "V8${type}.h";
 }
 
 
@@ -2547,7 +2712,6 @@ sub ReturnNativeToJSValue
     my $value = shift;
     my $indent = shift;
     my $type = GetTypeFromSignature($signature);
-    my $className= "V8$type";
 
     return "return v8::Date::New(static_cast<double>($value))" if $type eq "DOMTimeStamp";
     return "return v8Boolean($value)" if $type eq "boolean";
@@ -2574,29 +2738,20 @@ sub ReturnNativeToJSValue
         return "return v8String($value)";
     }
 
-    # V8 specific.
-    my $implClassName = $type;
     AddIncludesForType($type);
 
     # special case for non-DOM node interfaces
     if (IsDOMNodeType($type)) {
-        if ($signature->extendedAttributes->{"ReturnsNew"}) {
-            return "return V8DOMWrapper::convertNewNodeToV8Object($value)";
-        } else {
-            return "return V8DOMWrapper::convertNodeToV8Object($value)";
-        }
+        return "return toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")");
     }
 
-    if ($type eq "EventTarget" or $type eq "SVGElementInstance") {
+    if ($type eq "EventTarget") {
         return "return V8DOMWrapper::convertEventTargetToV8Object($value)";
     }
 
-    if ($type eq "Event") {
-        return "return V8DOMWrapper::convertEventToV8Object($value)";
-    }
-
     if ($type eq "EventListener") {
-        return "return V8DOMWrapper::convertEventListenerToV8Object(imp->scriptExecutionContext(), $value)";
+        $implIncludes{"V8AbstractEventListener.h"} = 1;
+        return "return ${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())";
     }
 
     if ($type eq "SerializedScriptValue") {
@@ -2616,18 +2771,15 @@ sub ReturnNativeToJSValue
         return "return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::$classIndex, $value)";
     }
 
-    else {
-        $implIncludes{"wtf/RefCounted.h"} = 1;
-        $implIncludes{"wtf/RefPtr.h"} = 1;
-        $implIncludes{"wtf/GetPtr.h"} = 1;
-        my $classIndex = uc($type);
-
-        if (IsPodType($type)) {
-            $value = GenerateSVGStaticPodTypeWrapper($type, $value);
-        }
+    $implIncludes{"wtf/RefCounted.h"} = 1;
+    $implIncludes{"wtf/RefPtr.h"} = 1;
+    $implIncludes{"wtf/GetPtr.h"} = 1;
 
-        return "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, $value)";
+    if (IsPodType($type)) {
+        $value = GenerateSVGStaticPodTypeWrapper($type, $value) . ".get()";
     }
+
+    return "return toV8($value)";
 }
 
 sub GenerateSVGStaticPodTypeWrapper {
diff --git a/WebCore/bindings/v8/V8Collection.h b/WebCore/bindings/v8/V8Collection.h
index 84150d8..78bc69a 100644
--- a/WebCore/bindings/v8/V8Collection.h
+++ b/WebCore/bindings/v8/V8Collection.h
@@ -109,7 +109,6 @@ namespace WebCore {
     template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
     {
         ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
-        ASSERT(V8DOMWrapper::domWrapperType(info.Holder()) == V8ClassIndex::NODE);
         Collection* collection = toNativeCollection<Collection>(info.Holder());
         int length = collection->length();
         v8::Handle<v8::Array> properties = v8::Array::New(length);
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index 2a8713e..b9d0911 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -45,6 +45,7 @@
 #include "V8Collection.h"
 #include "V8CustomBinding.h"
 #include "V8CustomEventListener.h"
+#include "V8DOMApplicationCache.h"
 #include "V8DOMMap.h"
 #include "V8DOMWindow.h"
 #include "V8EventListenerList.h"
@@ -52,12 +53,18 @@
 #include "V8HTMLDocument.h"
 #include "V8Index.h"
 #include "V8IsolatedContext.h"
-#include "V8MessageChannel.h"
 #include "V8Location.h"
+#include "V8MessageChannel.h"
 #include "V8NamedNodeMap.h"
+#include "V8Node.h"
 #include "V8NodeList.h"
+#include "V8Notification.h"
 #include "V8Proxy.h"
+#include "V8SVGElementInstance.h"
+#include "V8SharedWorker.h"
 #include "V8StyleSheet.h"
+#include "V8WebSocket.h"
+#include "V8Worker.h"
 #include "WebGLArray.h"
 #include "WebGLContextAttributes.h"
 #include "WebGLUniformLocation.h"
@@ -976,14 +983,14 @@ v8::Handle<v8::Value> V8DOMWrapper::convertDocumentToV8Object(Document* document
     return wrapper;
 }
 
-static v8::Handle<v8::Value> getWrapper(Node* node)
+v8::Handle<v8::Object> V8DOMWrapper::getWrapper(Node* node)
 {
     ASSERT(WTF::isMainThread());
     V8IsolatedContext* context = V8IsolatedContext::getEntered();
     if (LIKELY(!context)) {
         v8::Persistent<v8::Object>* wrapper = node->wrapper();
         if (!wrapper)
-            return v8::Handle<v8::Value>();
+            return v8::Handle<v8::Object>();
         return *wrapper;
     }
 
@@ -1094,75 +1101,64 @@ v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* ta
         return v8::Null();
 
 #if ENABLE(SVG)
-    SVGElementInstance* instance = target->toSVGElementInstance();
-    if (instance)
-        return convertToV8Object(V8ClassIndex::SVGELEMENTINSTANCE, instance);
+    if (SVGElementInstance* instance = target->toSVGElementInstance())
+        return toV8(instance);
 #endif
 
 #if ENABLE(WORKERS)
-    Worker* worker = target->toWorker();
-    if (worker)
-        return convertToV8Object(V8ClassIndex::WORKER, worker);
+    if (Worker* worker = target->toWorker())
+        return toV8(worker);
 #endif // WORKERS
 
 #if ENABLE(SHARED_WORKERS)
-    SharedWorker* sharedWorker = target->toSharedWorker();
-    if (sharedWorker)
-        return convertToV8Object(V8ClassIndex::SHAREDWORKER, sharedWorker);
+    if (SharedWorker* sharedWorker = target->toSharedWorker())
+        return toV8(sharedWorker);
 #endif // SHARED_WORKERS
 
 #if ENABLE(NOTIFICATIONS)
-    Notification* notification = target->toNotification();
-    if (notification)
-        return convertToV8Object(V8ClassIndex::NOTIFICATION, notification);
+    if (Notification* notification = target->toNotification())
+        return toV8(notification);
 #endif
 
 #if ENABLE(WEB_SOCKETS)
-    WebSocket* webSocket = target->toWebSocket();
-    if (webSocket)
-        return convertToV8Object(V8ClassIndex::WEBSOCKET, webSocket);
+    if (WebSocket* webSocket = target->toWebSocket())
+        return toV8(webSocket);
 #endif
 
-    Node* node = target->toNode();
-    if (node)
-        return convertNodeToV8Object(node);
+    if (Node* node = target->toNode())
+        return toV8(node);
 
     if (DOMWindow* domWindow = target->toDOMWindow())
-        return convertToV8Object(V8ClassIndex::DOMWINDOW, domWindow);
+        return toV8(domWindow);
 
     // XMLHttpRequest is created within its JS counterpart.
-    XMLHttpRequest* xmlHttpRequest = target->toXMLHttpRequest();
-    if (xmlHttpRequest) {
+    if (XMLHttpRequest* xmlHttpRequest = target->toXMLHttpRequest()) {
         v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(xmlHttpRequest);
         ASSERT(!wrapper.IsEmpty());
         return wrapper;
     }
 
     // MessagePort is created within its JS counterpart
-    MessagePort* port = target->toMessagePort();
-    if (port) {
+    if (MessagePort* port = target->toMessagePort()) {
         v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(port);
         ASSERT(!wrapper.IsEmpty());
         return wrapper;
     }
 
-    XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload();
-    if (upload) {
+    if (XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload()) {
         v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(upload);
         ASSERT(!wrapper.IsEmpty());
         return wrapper;
     }
 
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
-    DOMApplicationCache* domAppCache = target->toDOMApplicationCache();
-    if (domAppCache)
-        return convertToV8Object(V8ClassIndex::DOMAPPLICATIONCACHE, domAppCache);
+    if (DOMApplicationCache* domAppCache = target->toDOMApplicationCache())
+        return toV8(domAppCache);
 #endif
 
 #if ENABLE(EVENTSOURCE)
-    EventSource* eventSource = target->toEventSource();
-    if (eventSource)
-        return convertToV8Object(V8ClassIndex::EVENTSOURCE, eventSource);
+    if (EventSource* eventSource = target->toEventSource())
+        return toV8(eventSource);
 #endif
 
     ASSERT(0);
diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h
index 3cff691..0ccd8ac 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.h
+++ b/WebCore/bindings/v8/V8DOMWrapper.h
@@ -256,14 +256,21 @@ namespace WebCore {
                                                         int);
 #endif
 
-    private:
-        // Set hidden references in a DOMWindow object of a frame.
-        static void setHiddenWindowReference(Frame*, const int internalIndex, v8::Handle<v8::Object>);
-
         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)
+        {
+            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
diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h
index 598340d..cb02ee3 100644
--- a/WebCore/bindings/v8/V8Proxy.h
+++ b/WebCore/bindings/v8/V8Proxy.h
@@ -191,7 +191,9 @@ namespace WebCore {
             setSVGContext(object.get(), context);
             return object;
         }
-        static void* withSVGContext(void* object, SVGElement* context)
+
+        template <typename T>
+        static T* withSVGContext(T* object, SVGElement* context)
         {
             setSVGContext(object, context);
             return object;
diff --git a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
index b45ef35..5e6f40a 100644
--- a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
@@ -50,7 +50,7 @@
 
 namespace WebCore {
 
-static v8::Handle<v8::Value> toV8(CanvasStyle* style)
+static v8::Handle<v8::Value> toV8Object(CanvasStyle* style)
 {
     if (style->canvasGradient())
         return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASGRADIENT, style->canvasGradient());
@@ -78,7 +78,7 @@ static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value)
 v8::Handle<v8::Value> V8CanvasRenderingContext2D::strokeStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
     CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
-    return toV8(impl->strokeStyle());
+    return toV8Object(impl->strokeStyle());
 }
 
 void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -90,7 +90,7 @@ void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String>
 v8::Handle<v8::Value> V8CanvasRenderingContext2D::fillStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
     CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
-    return toV8(impl->fillStyle());
+    return toV8Object(impl->fillStyle());
 }
 
 void V8CanvasRenderingContext2D::fillStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
index 0dbdcd7..45cc222 100644
--- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
@@ -32,7 +32,7 @@
 #include "V8Console.h"
 
 #include "V8Binding.h"
-#include "V8CustomBinding.h"
+#include "V8DOMWindow.h"
 #include "V8Proxy.h"
 #include <v8.h>
 
@@ -54,4 +54,17 @@ v8::Handle<v8::Value> V8Console::profileEndCallback(const v8::Arguments& args)
     return v8::Undefined();
 }
 
+v8::Handle<v8::Value> toV8(Console* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+    if (wrapper.IsEmpty()) {
+        wrapper = V8Console::wrap(impl);
+        if (!wrapper.IsEmpty())
+            V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::consoleIndex, wrapper);
+    }
+    return wrapper;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 2933b4d..5460f50 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -925,4 +925,37 @@ bool V8DOMWindow::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t inde
     return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false);
 }
 
+v8::Handle<v8::Value> toV8(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;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
index 5adfa71..08b2294 100644
--- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
@@ -42,8 +42,11 @@
 #include "V8Binding.h"
 #include "V8CustomBinding.h"
 #include "V8CustomXPathNSResolver.h"
+#include "V8HTMLDocument.h"
+#include "V8IsolatedContext.h"
 #include "V8Node.h"
 #include "V8Proxy.h"
+#include "V8SVGDocument.h"
 #include "V8XPathNSResolver.h"
 #include "V8XPathResult.h"
 
@@ -132,4 +135,20 @@ v8::Handle<v8::Value> V8Document::implementationAccessorGetter(v8::Local<v8::Str
     return wrapper;
 }
 
+v8::Handle<v8::Value> toV8(Document* impl, bool forceNewObject)
+{
+    if (!impl)
+        return v8::Null();
+    if (impl->isHTMLDocument())
+        return toV8(static_cast<HTMLDocument*>(impl), forceNewObject);
+    if (impl->isSVGDocument())
+        return toV8(static_cast<SVGDocument*>(impl), forceNewObject);
+    v8::Handle<v8::Value> wrapper = V8Document::wrap(impl, forceNewObject);
+    if (!V8IsolatedContext::getEntered()) {
+        if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
+            proxy->windowShell()->updateDocumentWrapper(wrapper);
+    }
+    return wrapper;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8ElementCustom.cpp b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
index 0f13f9d..9901f1b 100644
--- a/WebCore/bindings/v8/custom/V8ElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
@@ -44,7 +44,9 @@
 #include "V8Binding.h"
 #include "V8BindingState.h"
 #include "V8CustomBinding.h"
+#include "V8HTMLElement.h"
 #include "V8Proxy.h"
+#include "V8SVGElement.h"
 
 #include <wtf/RefPtr.h>
 
@@ -127,4 +129,14 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeNSCallback(const v8::Arguments&
     return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
+v8::Handle<v8::Value> toV8(Element* impl, bool forceNewObject)
+{
+    if (!impl)
+        return v8::Null();
+    if (impl->isHTMLElement())
+        return toV8(static_cast<HTMLElement*>(impl), forceNewObject);
+    if (impl->isSVGElement())
+        return toV8(static_cast<SVGElement*>(impl), forceNewObject);
+    return V8Element::wrap(impl, forceNewObject);
+}
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp
index 65cd41e..41984b6 100644
--- a/WebCore/bindings/v8/custom/V8EventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp
@@ -34,10 +34,28 @@
 #include "Clipboard.h"
 #include "ClipboardEvent.h"
 #include "Event.h"
-#include "MouseEvent.h"
+#include "V8BeforeLoadEvent.h"
 #include "V8Binding.h"
+#include "V8CompositionEvent.h"
 #include "V8CustomBinding.h"
+#include "V8ErrorEvent.h"
+#include "V8KeyboardEvent.h"
+#include "V8MessageEvent.h"
+#include "V8MouseEvent.h"
+#include "V8MutationEvent.h"
+#include "V8OverflowEvent.h"
+#include "V8PageTransitionEvent.h"
+#include "V8PopStateEvent.h"
+#include "V8ProgressEvent.h"
 #include "V8Proxy.h"
+#include "V8SVGZoomEvent.h"
+#include "V8StorageEvent.h"
+#include "V8TextEvent.h"
+#include "V8UIEvent.h"
+#include "V8WebKitAnimationEvent.h"
+#include "V8WebKitTransitionEvent.h"
+#include "V8WheelEvent.h"
+#include "V8XMLHttpRequestProgressEvent.h"
 
 namespace WebCore {
 
@@ -67,4 +85,56 @@ v8::Handle<v8::Value> V8Event::clipboardDataAccessorGetter(v8::Local<v8::String>
     return v8::Undefined();
 }
 
+v8::Handle<v8::Value> toV8(Event* impl)
+{
+    if (!impl)
+        return v8::Null();
+    if (impl->isUIEvent()) {
+        if (impl->isKeyboardEvent())
+            return toV8(static_cast<KeyboardEvent*>(impl));
+        if (impl->isTextEvent())
+            return toV8(static_cast<TextEvent*>(impl));
+        if (impl->isMouseEvent())
+            return toV8(static_cast<MouseEvent*>(impl));
+        if (impl->isWheelEvent())
+            return toV8(static_cast<WheelEvent*>(impl));
+#if ENABLE(SVG)
+        if (impl->isSVGZoomEvent())
+            return toV8(static_cast<SVGZoomEvent*>(impl));
+#endif
+        if (impl->isCompositionEvent())
+            return toV8(static_cast<CompositionEvent*>(impl));
+        return toV8(static_cast<UIEvent*>(impl));
+    }
+    if (impl->isMutationEvent())
+        return toV8(static_cast<MutationEvent*>(impl));
+    if (impl->isOverflowEvent())
+        return toV8(static_cast<OverflowEvent*>(impl));
+    if (impl->isMessageEvent())
+        return toV8(static_cast<MessageEvent*>(impl));
+    if (impl->isPageTransitionEvent())
+        return toV8(static_cast<PageTransitionEvent*>(impl));
+    if (impl->isPopStateEvent())
+        return toV8(static_cast<PopStateEvent*>(impl));
+    if (impl->isProgressEvent()) {
+        if (impl->isXMLHttpRequestProgressEvent())
+            return toV8(static_cast<XMLHttpRequestProgressEvent*>(impl));
+        return toV8(static_cast<ProgressEvent*>(impl));
+    }
+    if (impl->isWebKitAnimationEvent())
+        return toV8(static_cast<WebKitAnimationEvent*>(impl));
+    if (impl->isWebKitTransitionEvent())
+        return toV8(static_cast<WebKitTransitionEvent*>(impl));
+#if ENABLE(WORKERS)
+    if (impl->isErrorEvent())
+        return toV8(static_cast<ErrorEvent*>(impl));
+#endif
+#if ENABLE(DOM_STORAGE)
+    if (impl->isStorageEvent())
+        return toV8(static_cast<StorageEvent*>(impl));
+#endif
+    if (impl->isBeforeLoadEvent())
+        return toV8(static_cast<BeforeLoadEvent*>(impl));
+    return V8Event::wrap(impl);
+}
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
index 8bb3c3a..0741432 100644
--- a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
@@ -34,6 +34,7 @@
 #include "HTMLCollection.h"
 #include "V8Binding.h"
 #include "V8CustomBinding.h"
+#include "V8HTMLAllCollection.h"
 #include "V8NamedNodesCollection.h"
 #include "V8Proxy.h"
 
@@ -138,4 +139,11 @@ v8::Handle<v8::Value> V8HTMLCollection::callAsFunctionCallback(const v8::Argumen
     return v8::Undefined();
 }
 
+v8::Handle<v8::Value> toV8(HTMLCollection* impl)
+{
+    if (impl->type() == DocAll)
+        return toV8(static_cast<HTMLAllCollection*>(impl));
+    return V8HTMLCollection::wrap(impl);
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 13243ef..3cb3ee6 100644
--- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -38,6 +38,7 @@
 #include "HTMLIFrameElement.h"
 #include "HTMLNames.h"
 #include "V8Binding.h"
+#include "V8IsolatedContext.h"
 #include "V8Proxy.h"
 #include <wtf/RefPtr.h>
 #include <wtf/StdLibExtras.h>
@@ -195,4 +196,22 @@ void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8:
     info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, value);
 }
 
+v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8HTMLDocument::wrap(impl, forceNewObject);
+    if (!V8IsolatedContext::getEntered()) {
+        if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
+            proxy->windowShell()->updateDocumentWrapper(wrapper);
+    }
+    // Create marker object and insert it in two internal fields.
+    // This is used to implement temporary shadowing of document.all.
+    ASSERT(wrapper->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
+    v8::Local<v8::Object> marker = v8::Object::New();
+    wrapper->SetInternalField(V8HTMLDocument::markerIndex, marker);
+    wrapper->SetInternalField(V8HTMLDocument::shadowIndex, marker);
+    return wrapper;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
index 0904b3e..4801dc0 100644
--- a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp
@@ -76,7 +76,6 @@ v8::Handle<v8::Value> V8HTMLSelectElement::namedPropertyGetter(v8::Local<v8::Str
 v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
 {
     ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
-    ASSERT(V8DOMWrapper::domWrapperType(info.Holder()) == V8ClassIndex::NODE);
     RefPtr<Node> result = V8HTMLSelectElement::toNative(info.Holder())->item(index);
     if (!result)
         return notHandledByInterceptor();
diff --git a/WebCore/bindings/v8/custom/V8HistoryCustom.cpp b/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
index b857d6e..5e9c7c8 100644
--- a/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
@@ -37,6 +37,7 @@
 #include "V8Binding.h"
 #include "V8BindingState.h"
 #include "V8CustomBinding.h"
+#include "V8DOMWindow.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -99,4 +100,17 @@ bool V8History::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Val
     return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), history->frame(), false);
 }
 
+v8::Handle<v8::Value> toV8(History* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+    if (wrapper.IsEmpty()) {
+        wrapper = V8History::wrap(impl);
+        if (!wrapper.IsEmpty())
+            V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::historyIndex, wrapper);
+    }
+    return wrapper;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8LocationCustom.cpp b/WebCore/bindings/v8/custom/V8LocationCustom.cpp
index ce816b6..7c9c529 100644
--- a/WebCore/bindings/v8/custom/V8LocationCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8LocationCustom.cpp
@@ -43,6 +43,7 @@
 #include "V8BindingState.h"
 #include "V8CustomBinding.h"
 #include "V8CustomEventListener.h"
+#include "V8DOMWindow.h"
 #include "V8Location.h"
 #include "V8Utilities.h"
 #include "V8Proxy.h"
@@ -358,5 +359,18 @@ bool V8Location::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Va
     return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), false);
 }
 
+v8::Handle<v8::Value> toV8(Location* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+    if (wrapper.IsEmpty()) {
+        wrapper = V8Location::wrap(impl);
+        if (!wrapper.IsEmpty())
+            V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::locationIndex, wrapper);
+    }
+    return wrapper;
+}
+
 }  // namespace WebCore
 
diff --git a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
index c7fff5a..4a05b08 100644
--- a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp
@@ -34,6 +34,7 @@
 #include "NamedNodeMap.h"
 #include "V8Binding.h"
 #include "V8CustomBinding.h"
+#include "V8Element.h"
 #include "V8Proxy.h"
 
 #include <wtf/RefPtr.h>
@@ -72,4 +73,18 @@ v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String>
     return V8DOMWrapper::convertNodeToV8Object(result.release());
 }
 
+v8::Handle<v8::Value> toV8(NamedNodeMap* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8NamedNodeMap::wrap(impl);
+    // Add a hidden reference from named node map to its owner node.
+    Element* element = impl->element();
+    if (!wrapper.IsEmpty() && element) {
+        v8::Handle<v8::Value> owner = toV8(element);
+        wrapper->SetInternalField(V8NamedNodeMap::ownerNodeIndex, owner);
+    }
+    return wrapper;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp
index 266745d..75922e7 100644
--- a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp
@@ -32,6 +32,8 @@
 #include "V8Navigator.h"
 
 #include "RuntimeEnabledFeatures.h"
+#include "V8DOMWindow.h"
+#include "V8DOMWrapper.h"
 
 namespace WebCore {
 
@@ -42,4 +44,17 @@ bool V8Navigator::GeolocationEnabled()
 }
 #endif
 
+v8::Handle<v8::Value> toV8(Navigator* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);
+    if (wrapper.IsEmpty()) {
+        wrapper = V8Navigator::wrap(impl);
+        if (!wrapper.IsEmpty())
+            V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::navigatorIndex, wrapper);
+    }
+    return wrapper;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8NodeCustom.cpp b/WebCore/bindings/v8/custom/V8NodeCustom.cpp
index 79afbe8..06489fd 100644
--- a/WebCore/bindings/v8/custom/V8NodeCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeCustom.cpp
@@ -35,11 +35,23 @@
 #include "EventListener.h"
 
 #include "V8AbstractEventListener.h"
+#include "V8Attr.h"
 #include "V8Binding.h"
+#include "V8CDATASection.h"
+#include "V8Comment.h"
 #include "V8CustomBinding.h"
 #include "V8CustomEventListener.h"
+#include "V8Document.h"
+#include "V8DocumentFragment.h"
+#include "V8DocumentType.h"
+#include "V8Element.h"
+#include "V8Entity.h"
+#include "V8EntityReference.h"
 #include "V8Node.h"
+#include "V8Notation.h"
+#include "V8ProcessingInstruction.h"
 #include "V8Proxy.h"
+#include "V8Text.h"
 
 #include <wtf/RefPtr.h>
 
@@ -152,4 +164,43 @@ v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args)
     return v8::Null();
 }
 
+v8::Handle<v8::Value> toV8(Node* impl, bool forceNewObject)
+{
+    if (!impl)
+        return v8::Null();
+
+    if (!forceNewObject) {
+        v8::Handle<v8::Value> wrapper = V8DOMWrapper::getWrapper(impl);
+        if (!wrapper.IsEmpty())
+            return wrapper;
+    }
+    switch (impl->nodeType()) {
+    case Node::ELEMENT_NODE:
+        return toV8(static_cast<Element*>(impl), forceNewObject);
+    case Node::ATTRIBUTE_NODE:
+        return toV8(static_cast<Attr*>(impl), forceNewObject);
+    case Node::TEXT_NODE:
+        return toV8(static_cast<Text*>(impl), forceNewObject);
+    case Node::CDATA_SECTION_NODE:
+        return toV8(static_cast<CDATASection*>(impl), forceNewObject);
+    case Node::ENTITY_REFERENCE_NODE:
+        return toV8(static_cast<EntityReference*>(impl), forceNewObject);
+    case Node::ENTITY_NODE:
+        return toV8(static_cast<Entity*>(impl), forceNewObject);
+    case Node::PROCESSING_INSTRUCTION_NODE:
+        return toV8(static_cast<ProcessingInstruction*>(impl), forceNewObject);
+    case Node::COMMENT_NODE:
+        return toV8(static_cast<Comment*>(impl), forceNewObject);
+    case Node::DOCUMENT_NODE:
+        return toV8(static_cast<Document*>(impl), forceNewObject);
+    case Node::DOCUMENT_TYPE_NODE:
+        return toV8(static_cast<DocumentType*>(impl), forceNewObject);
+    case Node::DOCUMENT_FRAGMENT_NODE:
+        return toV8(static_cast<DocumentFragment*>(impl), forceNewObject);
+    case Node::NOTATION_NODE:
+        return toV8(static_cast<Notation*>(impl), forceNewObject);
+    default: break; // XPATH_NAMESPACE_NODE
+    }
+    return V8Node::wrap(impl, forceNewObject);
+}
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
index b848197..866fae2 100644
--- a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp
@@ -44,7 +44,7 @@
 
 namespace WebCore {
 
-static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ScriptState* state)
+static inline v8::Handle<v8::Value> toV8Object(PassRefPtr<Node> object, ScriptState* state)
 {
     if (state->hadException())
         return throwError(state->exception());
@@ -62,7 +62,7 @@ v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args
 
     EmptyScriptState state;
     RefPtr<Node> result = treeWalker->parentNode(&state);
-    return toV8(result.release(), &state);
+    return toV8Object(result.release(), &state);
 }
 
 v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args)
@@ -72,7 +72,7 @@ v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args
 
     EmptyScriptState state;
     RefPtr<Node> result = treeWalker->firstChild(&state);
-    return toV8(result.release(), &state);
+    return toV8Object(result.release(), &state);
 }
 
 v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args)
@@ -82,7 +82,7 @@ v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args)
 
     EmptyScriptState state;
     RefPtr<Node> result = treeWalker->lastChild(&state);
-    return toV8(result.release(), &state);
+    return toV8Object(result.release(), &state);
 }
 
 v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args)
@@ -92,7 +92,7 @@ v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args)
 
     EmptyScriptState state;
     RefPtr<Node> result = treeWalker->nextNode(&state);
-    return toV8(result.release(), &state);
+    return toV8Object(result.release(), &state);
 }
 
 v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& args)
@@ -102,7 +102,7 @@ v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& ar
 
     EmptyScriptState state;
     RefPtr<Node> result = treeWalker->previousNode(&state);
-    return toV8(result.release(), &state);
+    return toV8Object(result.release(), &state);
 }
 
 v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& args)
@@ -112,7 +112,7 @@ v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& arg
 
     EmptyScriptState state;
     RefPtr<Node> result = treeWalker->nextSibling(&state);
-    return toV8(result.release(), &state);
+    return toV8Object(result.release(), &state);
 }
 
 v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments& args)
@@ -122,7 +122,7 @@ v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments&
 
     EmptyScriptState state;
     RefPtr<Node> result = treeWalker->previousSibling(&state);
-    return toV8(result.release(), &state);
+    return toV8Object(result.release(), &state);
 }
 
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
index 6d52c83..95f6879 100644
--- a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLByteArray::setCallback(const v8::Arguments& args)
     return setWebGLArray<WebGLByteArray, V8WebGLByteArray>(args, V8ClassIndex::WEBGLBYTEARRAY);
 }
 
+v8::Handle<v8::Value> toV8(WebGLByteArray* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8WebGLByteArray::wrap(impl);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalByteArray, impl->length());
+    return wrapper;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
index 4d4b0e2..5882450 100644
--- a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLFloatArray::setCallback(const v8::Arguments& args)
     return setWebGLArray<WebGLFloatArray, V8WebGLFloatArray>(args, V8ClassIndex::WEBGLFLOATARRAY);
 }
 
+v8::Handle<v8::Value> toV8(WebGLFloatArray* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8WebGLFloatArray::wrap(impl);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length());
+    return wrapper;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
index 7dde0a0..7e2f2ed 100644
--- a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLIntArray::setCallback(const v8::Arguments& args)
     return setWebGLArray<WebGLIntArray, V8WebGLIntArray>(args, V8ClassIndex::WEBGLINTARRAY);
 }
 
+v8::Handle<v8::Value> toV8(WebGLIntArray* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8WebGLIntArray::wrap(impl);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalIntArray, impl->length());
+    return wrapper;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index 19b73d4..1961d39 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -175,7 +175,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::bufferSubDataCallback(const v8::A
     return v8::Undefined();
 }
 
-static v8::Handle<v8::Value> toV8(const WebGLGetInfo& info)
+static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info)
 {
     switch (info.getType()) {
     case WebGLGetInfo::kTypeBool:
@@ -261,7 +261,7 @@ static v8::Handle<v8::Value> getObjectParameter(const v8::Arguments& args, Objec
         V8Proxy::setDOMException(ec);
         return v8::Undefined();
     }
-    return toV8(info);
+    return toV8Object(info);
 }
 
 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value, bool& ok)
@@ -317,7 +317,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getFramebufferAttachmentParameter
         V8Proxy::setDOMException(ec);
         return v8::Undefined();
     }
-    return toV8(info);
+    return toV8Object(info);
 }
 
 v8::Handle<v8::Value> V8WebGLRenderingContext::getParameterCallback(const v8::Arguments& args)
@@ -342,7 +342,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getParameterCallback(const v8::Ar
         V8Proxy::setDOMException(ec);
         return v8::Undefined();
     }
-    return toV8(info);
+    return toV8Object(info);
 }
 
 v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const v8::Arguments& args)
@@ -368,7 +368,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const
         V8Proxy::setDOMException(ec);
         return v8::Undefined();
     }
-    return toV8(info);
+    return toV8Object(info);
 }
 
 v8::Handle<v8::Value> V8WebGLRenderingContext::getRenderbufferParameterCallback(const v8::Arguments& args)
@@ -400,7 +400,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const
         V8Proxy::setDOMException(ec);
         return v8::Undefined();
     }
-    return toV8(info);
+    return toV8Object(info);
 }
 
 v8::Handle<v8::Value> V8WebGLRenderingContext::getTexParameterCallback(const v8::Arguments& args)
@@ -434,7 +434,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu
         V8Proxy::setDOMException(ec);
         return v8::Undefined();
     }
-    return toV8(info);
+    return toV8Object(info);
 }
 
 v8::Handle<v8::Value> V8WebGLRenderingContext::getVertexAttribCallback(const v8::Arguments& args)
diff --git a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
index 9d3b478..4cbccf5 100644
--- a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLShortArray::setCallback(const v8::Arguments& args)
     return setWebGLArray<WebGLShortArray, V8WebGLShortArray>(args, V8ClassIndex::WEBGLSHORTARRAY);
 }
 
+v8::Handle<v8::Value> toV8(WebGLShortArray* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8WebGLShortArray::wrap(impl);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalShortArray, impl->length());
+    return wrapper;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
index 3cc658a..962e390 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedByteArray::setCallback(const v8::Arguments&
     return setWebGLArray<WebGLUnsignedByteArray, V8WebGLUnsignedByteArray>(args, V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY);
 }
 
+v8::Handle<v8::Value> toV8(WebGLUnsignedByteArray* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8WebGLUnsignedByteArray::wrap(impl);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length());
+    return wrapper;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
index 93ccbd4..eb0b7cf 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedIntArray::setCallback(const v8::Arguments&
     return setWebGLArray<WebGLUnsignedIntArray, V8WebGLUnsignedIntArray>(args, V8ClassIndex::WEBGLUNSIGNEDINTARRAY);
 }
 
+v8::Handle<v8::Value> toV8(WebGLUnsignedIntArray* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8WebGLUnsignedIntArray::wrap(impl);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedIntArray, impl->length());
+    return wrapper;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
index d9e47cd..5f30de3 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
@@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedShortArray::setCallback(const v8::Arguments
     return setWebGLArray<WebGLUnsignedShortArray, V8WebGLUnsignedShortArray>(args, V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY);
 }
 
+v8::Handle<v8::Value> toV8(WebGLUnsignedShortArray* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8WebGLUnsignedShortArray::wrap(impl);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length());
+    return wrapper;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/dom/make_names.pl b/WebCore/dom/make_names.pl
index daf45ef..083e309 100755
--- a/WebCore/dom/make_names.pl
+++ b/WebCore/dom/make_names.pl
@@ -38,7 +38,8 @@ use InFilesParser;
 use Switch;
 
 my $printFactory = 0; 
-my $printWrapperFactory = 0;
+my $printWrapperFactory = 0; 
+my $printWrapperFactoryV8 = 0; 
 my $tagsFile = "";
 my $attrsFile = "";
 my $outputDir = ".";
@@ -55,7 +56,8 @@ GetOptions(
     'outputDir=s' => \$outputDir,
     'extraDefines=s' => \$extraDefines,
     'preprocessor=s' => \$preprocessor,
-    'wrapperFactory' => \$printWrapperFactory
+    'wrapperFactory' => \$printWrapperFactory,
+    'wrapperFactoryV8' => \$printWrapperFactoryV8
 );
 
 die "You must specify at least one of --tags <file> or --attrs <file>" unless (length($tagsFile) || length($attrsFile));
@@ -71,7 +73,7 @@ $parameters{namespacePrefix} = $parameters{namespace} unless $parameters{namespa
 mkpath($outputDir);
 my $namesBasePath = "$outputDir/$parameters{namespace}Names";
 my $factoryBasePath = "$outputDir/$parameters{namespace}ElementFactory";
-my $wrapperFactoryBasePath = "$outputDir/JS$parameters{namespace}ElementWrapperFactory";
+my $wrapperFactoryFileName = "$parameters{namespace}ElementWrapperFactory";
 
 printNamesHeaderFile("$namesBasePath.h");
 printNamesCppFile("$namesBasePath.cpp");
@@ -81,9 +83,17 @@ if ($printFactory) {
     printFactoryHeaderFile("$factoryBasePath.h");
 }
 
+die "You cannot specify both --wrapperFactory and --wrapperFactoryV8" if $printWrapperFactory && $printWrapperFactoryV8;
+my $wrapperFactoryType = "";
 if ($printWrapperFactory) {
-    printWrapperFactoryCppFile("$wrapperFactoryBasePath.cpp");
-    printWrapperFactoryHeaderFile("$wrapperFactoryBasePath.h");
+    $wrapperFactoryType = "JS";
+} elsif ($printWrapperFactoryV8) {
+    $wrapperFactoryType = "V8";
+}
+
+if ($wrapperFactoryType) {
+    printWrapperFactoryCppFile($outputDir, $wrapperFactoryType, $wrapperFactoryFileName);
+    printWrapperFactoryHeaderFile($outputDir, $wrapperFactoryType, $wrapperFactoryFileName);
 }
 
 ### Hash initialization
@@ -555,6 +565,7 @@ print F "\nvoid init()
 sub printJSElementIncludes
 {
     my $F = shift;
+    my $wrapperFactoryType = shift;
 
     my %tagsSeen;
     for my $tagName (sort keys %tags) {
@@ -562,7 +573,7 @@ sub printJSElementIncludes
         next if defined($tagsSeen{$JSInterfaceName}) || usesDefaultJSWrapper($tagName);
         $tagsSeen{$JSInterfaceName} = 1;
 
-        print F "#include \"JS${JSInterfaceName}.h\"\n";
+        print F "#include \"${wrapperFactoryType}${JSInterfaceName}.h\"\n";
     }
 }
 
@@ -799,6 +810,7 @@ sub usesDefaultJSWrapper
 sub printWrapperFunctions
 {
     my $F = shift;
+    my $wrapperFactoryType = shift;
 
     my %tagsSeen;
     for my $tagName (sort keys %tags) {
@@ -813,10 +825,11 @@ sub printWrapperFunctions
             print F "#if ${conditionalString}\n\n";
         }
 
-        # Hack for the media tags
-        # FIXME: This should have been done via a CustomWrapper attribute and a separate *Custom file.
-        if ($tags{$tagName}{wrapperOnlyIfMediaIsAvailable}) {
-            print F <<END
+        if ($wrapperFactoryType eq "JS") {
+            # Hack for the media tags
+            # FIXME: This should have been done via a CustomWrapper attribute and a separate *Custom file.
+            if ($tags{$tagName}{wrapperOnlyIfMediaIsAvailable}) {
+                print F <<END
 static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element)
 {
     if (!MediaPlayer::isAvailable())
@@ -826,8 +839,8 @@ static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObjec
 
 END
 ;
-        } else {
-            print F <<END
+            } else {
+                print F <<END
 static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element)
 {
     return CREATE_DOM_NODE_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get());
@@ -835,6 +848,16 @@ static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObjec
 
 END
 ;
+            }
+        } elsif ($wrapperFactoryType eq "V8") {
+            print F <<END
+static v8::Handle<v8::Value> create${JSInterfaceName}Wrapper($parameters{namespace}Element* element)
+{
+    return toV8(static_cast<${JSInterfaceName}*>(element));
+}
+
+END
+;
         }
 
         if ($conditional) {
@@ -845,9 +868,11 @@ END
 
 sub printWrapperFactoryCppFile
 {
-    my $cppPath = shift;
+    my $outputDir = shift;
+    my $wrapperFactoryType = shift;
+    my $wrapperFactoryFileName = shift;
     my $F;
-    open F, ">$cppPath";
+    open F, ">" . $outputDir . "/" . $wrapperFactoryType . $wrapperFactoryFileName . ".cpp";
 
     printLicenseHeader($F);
 
@@ -855,38 +880,73 @@ sub printWrapperFactoryCppFile
 
     print F "#if $parameters{guardFactoryWith}\n\n" if $parameters{guardFactoryWith};
 
-    print F "#include \"JS$parameters{namespace}ElementWrapperFactory.h\"\n";
+    print F "#include \"$wrapperFactoryType$parameters{namespace}ElementWrapperFactory.h\"\n";
 
-    printJSElementIncludes($F);
+    printJSElementIncludes($F, $wrapperFactoryType);
 
     print F "\n#include \"$parameters{namespace}Names.h\"\n\n";
 
     printElementIncludes($F);
 
     print F "\n#include <wtf/StdLibExtras.h>\n\n";
-    
-    print F <<END
+
+    if ($wrapperFactoryType eq "JS") {    
+        print F <<END
 using namespace JSC;
+END
+;
+    } elsif ($wrapperFactoryType eq "V8") {
+        print F <<END
+#include "V8$parameters{namespace}Element.h"
+        
+#include <v8.h>
+END
+;
+    }
+
+    print F <<END
 
 namespace WebCore {
 
 using namespace $parameters{namespace}Names;
 
+END
+;
+    if ($wrapperFactoryType eq "JS") {
+        print F <<END
 typedef JSNode* (*Create$parameters{namespace}ElementWrapperFunction)(ExecState*, JSDOMGlobalObject*, PassRefPtr<$parameters{namespace}Element>);
 
 END
 ;
+    } elsif ($wrapperFactoryType eq "V8") {
+        print F <<END
+typedef v8::Handle<v8::Value> (*Create$parameters{namespace}ElementWrapperFunction)($parameters{namespace}Element*);
+
+END
+;
+    }
 
-    printWrapperFunctions($F);
+    printWrapperFunctions($F, $wrapperFactoryType);
 
-    print F <<END
+    if ($wrapperFactoryType eq "JS") {
+        print F <<END
 JSNode* createJS$parameters{namespace}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element)
-{   
+{
+    typedef HashMap<WebCore::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap;
+    DEFINE_STATIC_LOCAL(FunctionMap, map, ());
+    if (map.isEmpty()) {
+END
+;
+    } elsif ($wrapperFactoryType eq "V8") {
+        print F <<END
+v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element* element, bool forceNewObject)
+{
     typedef HashMap<WebCore::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap;
     DEFINE_STATIC_LOCAL(FunctionMap, map, ());
     if (map.isEmpty()) {
 END
 ;
+    }
 
     for my $tag (sort keys %tags) {
         # Do not add the name to the map if it does not have a JS wrapper constructor or uses the default wrapper.
@@ -910,8 +970,22 @@ END
     }
     Create$parameters{namespace}ElementWrapperFunction createWrapperFunction = map.get(element->localName().impl());
     if (createWrapperFunction)
+END
+;
+    if ($wrapperFactoryType eq "JS") {
+        print F <<END
         return createWrapperFunction(exec, globalObject, element);
     return CREATE_DOM_NODE_WRAPPER(exec, globalObject, $parameters{namespace}Element, element.get());
+END
+;
+    } elsif ($wrapperFactoryType eq "V8") {
+        print F <<END
+        return createWrapperFunction(element);
+    return V8$parameters{namespace}Element::wrap(element, forceNewObject);
+END
+;
+    }
+    print F <<END
 }
 
 }
@@ -926,18 +1000,21 @@ END
 
 sub printWrapperFactoryHeaderFile
 {
-    my $headerPath = shift;
+    my $outputDir = shift;
+    my $wrapperFactoryType = shift;
+    my $wrapperFactoryFileName = shift;
     my $F;
-    open F, ">$headerPath";
+    open F, ">" . $outputDir . "/" . $wrapperFactoryType . $wrapperFactoryFileName . ".h";
 
     printLicenseHeader($F);
 
-    print F "#ifndef JS$parameters{namespace}ElementWrapperFactory_h\n";
-    print F "#define JS$parameters{namespace}ElementWrapperFactory_h\n\n";
+    print F "#ifndef $wrapperFactoryType$parameters{namespace}ElementWrapperFactory_h\n";
+    print F "#define $wrapperFactoryType$parameters{namespace}ElementWrapperFactory_h\n\n";
 
     print F "#if $parameters{guardFactoryWith}\n" if $parameters{guardFactoryWith};
 
-    print F <<END
+    if ($wrapperFactoryType eq "JS") {
+        print F <<END
 #include <wtf/Forward.h>
 
 namespace JSC {
@@ -956,10 +1033,23 @@ namespace WebCore {
  
 END
 ;
+    } elsif ($wrapperFactoryType eq "V8") {
+        print F <<END
+#include <v8.h>
+
+namespace WebCore {
+
+    class $parameters{namespace}Element;
+
+    v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element*, bool);
+}
+END
+;
+    }
 
     print F "#endif // $parameters{guardFactoryWith}\n\n" if $parameters{guardFactoryWith};
 
-    print F "#endif // JS$parameters{namespace}ElementWrapperFactory_h\n";
+    print F "#endif // $wrapperFactoryType$parameters{namespace}ElementWrapperFactory_h\n";
 
     close F;
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list