Title: [137996] trunk/Source/WebCore
Revision
137996
Author
aand...@chromium.org
Date
2012-12-18 01:02:09 -0800 (Tue, 18 Dec 2012)

Log Message

Web Inspector: [WebGL] handle video elements used in WebGL
https://bugs.webkit.org/show_bug.cgi?id=105170

Reviewed by Yury Semikhatsky.

Copy current image of video elements into a canvas to use it later in the replay.

* inspector/InjectedScriptCanvasModuleSource.js:
(.):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (137995 => 137996)


--- trunk/Source/WebCore/ChangeLog	2012-12-18 08:45:31 UTC (rev 137995)
+++ trunk/Source/WebCore/ChangeLog	2012-12-18 09:02:09 UTC (rev 137996)
@@ -1,3 +1,15 @@
+2012-12-17  Andrey Adaikin  <aand...@chromium.org>
+
+        Web Inspector: [WebGL] handle video elements used in WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=105170
+
+        Reviewed by Yury Semikhatsky.
+
+        Copy current image of video elements into a canvas to use it later in the replay.
+
+        * inspector/InjectedScriptCanvasModuleSource.js:
+        (.):
+
 2012-12-17  Luke Macpherson   <macpher...@chromium.org>
 
         Add ASSERTions to ensure that CSSPropertys that are variables only ever refer to CSSValues that are variables.

Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js (137995 => 137996)


--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js	2012-12-18 08:45:31 UTC (rev 137995)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js	2012-12-18 09:02:09 UTC (rev 137996)
@@ -91,29 +91,16 @@
             var img = /** @type {HTMLImageElement} */ (obj);
             // Special case for Images with Blob URIs: cloneNode will fail if the Blob URI has already been revoked.
             // FIXME: Maybe this is a bug in WebKit core?
-            if (/^blob:/.test(img.src)) {
-                var canvas = inspectedWindow.document.createElement("canvas");
-                var context = /** @type {CanvasRenderingContext2D} */ (Resource.wrappedObject(canvas.getContext("2d")));
-                canvas.width = img.width;
-                canvas.height = img.height;
-                context.drawImage(img, 0, 0);
-                return canvas;
-            }
+            if (/^blob:/.test(img.src))
+                return TypeUtils.cloneIntoCanvas(img, img.width, img.height);
             return img.cloneNode(true);
         }
 
-        if (obj instanceof HTMLCanvasElement) {
-            var result = obj.cloneNode(true);
-            var context = /** @type {CanvasRenderingContext2D} */ (Resource.wrappedObject(result.getContext("2d")));
-            context.drawImage(obj, 0, 0);
-            return result;
-        }
+        if (obj instanceof HTMLCanvasElement)
+            return TypeUtils.cloneIntoCanvas(obj, obj.width, obj.height);
 
-        if (obj instanceof HTMLVideoElement) {
-            var result = obj.cloneNode(true);
-            // FIXME: Copy HTMLVideoElement's current image into a 2d canvas.
-            return result;
-        }
+        if (obj instanceof HTMLVideoElement)
+            return TypeUtils.cloneIntoCanvas(obj, obj.videoWidth, obj.videoHeight);
 
         if (obj instanceof ImageData) {
             var context = TypeUtils._dummyCanvas2dContext();
@@ -129,6 +116,22 @@
     },
 
     /**
+     * @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} obj
+     * @param {number} width
+     * @param {number} height
+     * @return {HTMLCanvasElement}
+     */
+    cloneIntoCanvas: function(obj, width, height)
+    {
+        var canvas = /** @type {HTMLCanvasElement} */ (inspectedWindow.document.createElement("canvas"));
+        canvas.width = width;
+        canvas.height = height;
+        var context = /** @type {CanvasRenderingContext2D} */ (Resource.wrappedObject(canvas.getContext("2d")));
+        context.drawImage(obj, 0, 0);
+        return canvas;
+    },
+
+    /**
      * @param {Object=} obj
      * @return {Object}
      */
@@ -149,7 +152,7 @@
     {
         var context = TypeUtils._dummyCanvas2dContextInstance;
         if (!context) {
-            var canvas = inspectedWindow.document.createElement("canvas");
+            var canvas = /** @type {HTMLCanvasElement} */ (inspectedWindow.document.createElement("canvas"));
             context = /** @type {CanvasRenderingContext2D} */ (Resource.wrappedObject(canvas.getContext("2d")));
             TypeUtils._dummyCanvas2dContextInstance = context;
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to