[V8] Fix Canvas layout test failures in Chromium build.
authorjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Aug 2009 22:38:31 +0000 (22:38 +0000)
committerjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Aug 2009 22:38:31 +0000 (22:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=28720

Reviewed by David Levin.

The previous fix r47757 does not handle the V8 object conversion correctly.

* bindings/v8/custom/V8DocumentCustom.cpp:
(WebCore::CALLBACK_FUNC_DECL):
* bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
(WebCore::CALLBACK_FUNC_DECL):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@47758 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bindings/v8/custom/V8DocumentCustom.cpp
WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp

index 645dd1f..ae6f9c8 100644 (file)
@@ -2,6 +2,20 @@
 
         Reviewed by David Levin.
 
+        [V8] Fix Canvas layout test failures in Chromium build.
+        https://bugs.webkit.org/show_bug.cgi?id=28720
+
+        The previous fix r47757 does not handle the V8 object conversion correctly.
+
+        * bindings/v8/custom/V8DocumentCustom.cpp:
+        (WebCore::CALLBACK_FUNC_DECL):
+        * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
+        (WebCore::CALLBACK_FUNC_DECL):
+
+2009-08-25  Jian Li  <jianli@chromium.org>
+
+        Reviewed by David Levin.
+
         [V8] Fix compiling errors in Chromium build caused by Canvas3D changes from r47752.
         https://bugs.webkit.org/show_bug.cgi?id=28717
 
index c67d87e..ef199a9 100644 (file)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "Document.h"
 
+#include "CanvasRenderingContext.h"
 #include "ExceptionCode.h"
 #include "Node.h"
 #include "XPathNSResolver.h"
@@ -93,7 +94,13 @@ CALLBACK_FUNC_DECL(DocumentGetCSSCanvasContext)
     int width = toInt32(args[2]);
     int height = toInt32(args[3]);
     CanvasRenderingContext* result = imp->getCSSCanvasContext(contextId, name, width, height);
-    return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT, result);
+    if (result->is2d())
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
+    else {
+        // FIXME: Add the conversion to CanvasRenderingContext3D when it is hooked up.
+        ASSERT_NOT_REACHED();
+        return v8::Handle<v8::Value>();
+    }
 }
 
 } // namespace WebCore
index ba381a5..2ed90b9 100644 (file)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "HTMLCanvasElement.h"
 
+#include "CanvasRenderingContext.h"
 #include "V8Binding.h"
 #include "V8CustomBinding.h"
 #include "V8Node.h"
@@ -45,7 +46,13 @@ CALLBACK_FUNC_DECL(HTMLCanvasElementGetContext)
     HTMLCanvasElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLCanvasElement>(holder);
     String contextId = toWebCoreString(args[0]);
     CanvasRenderingContext* result = imp->getContext(contextId);
-    return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT, result);
+    if (result->is2d())
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
+    else {
+        // FIXME: Add the conversion to CanvasRenderingContext3D when it is hooked up.
+        ASSERT_NOT_REACHED();
+        return v8::Handle<v8::Value>();
+    }
 }
 
 } // namespace WebCore