Title: [126585] trunk/Source/WebCore
Revision
126585
Author
[email protected]
Date
2012-08-24 07:39:02 -0700 (Fri, 24 Aug 2012)

Log Message

Web Inspector: [WebGL] A follow up to simplify code with nested closures
https://bugs.webkit.org/show_bug.cgi?id=94931

Patch by Andrey Adaikin <[email protected]> on 2012-08-24
Reviewed by Pavel Feldman.

Simplifies the code with nested closures.

* inspector/InjectedScriptWebGLModuleSource.js:
(.):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126584 => 126585)


--- trunk/Source/WebCore/ChangeLog	2012-08-24 14:05:40 UTC (rev 126584)
+++ trunk/Source/WebCore/ChangeLog	2012-08-24 14:39:02 UTC (rev 126585)
@@ -1,3 +1,15 @@
+2012-08-24  Andrey Adaikin  <[email protected]>
+
+        Web Inspector: [WebGL] A follow up to simplify code with nested closures
+        https://bugs.webkit.org/show_bug.cgi?id=94931
+
+        Reviewed by Pavel Feldman.
+
+        Simplifies the code with nested closures.
+
+        * inspector/InjectedScriptWebGLModuleSource.js:
+        (.):
+
 2012-08-24  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Get rid of frontendReused logic on front-end.

Modified: trunk/Source/WebCore/inspector/InjectedScriptWebGLModuleSource.js (126584 => 126585)


--- trunk/Source/WebCore/inspector/InjectedScriptWebGLModuleSource.js	2012-08-24 14:05:40 UTC (rev 126584)
+++ trunk/Source/WebCore/inspector/InjectedScriptWebGLModuleSource.js	2012-08-24 14:39:02 UTC (rev 126585)
@@ -863,71 +863,77 @@
 
 WebGLRenderingContextResource.WrapFunctions = {
     __proto__: null
-};
+}
 
-(function(items) {
-    items.forEach(function(item) {
-        var methodName = item[0];
-        var resourceConstructor = item[1];
-        WebGLRenderingContextResource.WrapFunctions[methodName] = function()
-        {
-            var wrappedObject = this.result();
-            if (!wrappedObject)
-                return;
-            var resource = new resourceConstructor(wrappedObject);
-            var manager = this._glResource.manager();
-            if (manager)
-                manager.registerResource(resource);
+/**
+ * @param {string} methodName
+ * @param {Function} resourceConstructor
+ */
+function createResourceWrapFunction(methodName, resourceConstructor)
+{
+    /** @this WebGLRenderingContextResource.WrapFunction */
+    WebGLRenderingContextResource.WrapFunctions[methodName] = function()
+    {
+        var wrappedObject = this.result();
+        if (!wrappedObject)
+            return;
+        var resource = new resourceConstructor(wrappedObject);
+        var manager = this._glResource.manager();
+        if (manager)
+            manager.registerResource(resource);
+        resource.pushCall(this.call());
+    }
+}
+createResourceWrapFunction("createBuffer", WebGLBufferResource);
+createResourceWrapFunction("createShader", WebGLShaderResource);
+createResourceWrapFunction("createProgram", WebGLProgramResource);
+createResourceWrapFunction("createTexture", WebGLTextureResource);
+createResourceWrapFunction("createFramebuffer", WebGLFramebufferResource);
+createResourceWrapFunction("createRenderbuffer", WebGLRenderbufferResource);
+createResourceWrapFunction("getUniformLocation", Resource);
+
+/**
+ * @param {string} methodName
+ */
+function customWrapFunction(methodName)
+{
+    var customPushCall = "pushCall_" + methodName;
+    /**
+     * @param {Object|number} target
+     * @this WebGLRenderingContextResource.WrapFunction
+     */
+    WebGLRenderingContextResource.WrapFunctions[methodName] = function(target)
+    {
+        var resource = this._glResource.currentBinding(target);
+        if (!resource)
+            return;
+        if (resource[customPushCall])
+            resource[customPushCall].call(resource, this.call());
+        else
             resource.pushCall(this.call());
-        };
-    });
-})([
-    ["createBuffer", WebGLBufferResource],
-    ["createShader", WebGLShaderResource],
-    ["createProgram", WebGLProgramResource],
-    ["createTexture", WebGLTextureResource],
-    ["createFramebuffer", WebGLFramebufferResource],
-    ["createRenderbuffer", WebGLRenderbufferResource],
-    ["getUniformLocation", Resource]
-]);
+    }
+}
+customWrapFunction("attachShader");
+customWrapFunction("bindAttribLocation");
+customWrapFunction("compileShader");
+customWrapFunction("detachShader");
+customWrapFunction("linkProgram");
+customWrapFunction("shaderSource");
+customWrapFunction("bufferData");
+customWrapFunction("bufferSubData");
+customWrapFunction("compressedTexImage2D");
+customWrapFunction("compressedTexSubImage2D");
+customWrapFunction("copyTexImage2D");
+customWrapFunction("copyTexSubImage2D");
+customWrapFunction("generateMipmap");
+customWrapFunction("texImage2D");
+customWrapFunction("texSubImage2D");
+customWrapFunction("texParameterf");
+customWrapFunction("texParameteri");
+customWrapFunction("framebufferRenderbuffer");
+customWrapFunction("framebufferTexture2D");
+customWrapFunction("renderbufferStorage");
 
-(function(methods) {
-    methods.forEach(function(methodName) {
-        var customPushCall = "pushCall_" + methodName;
-        WebGLRenderingContextResource.WrapFunctions[methodName] = function(target)
-        {
-            var resource = this._glResource.currentBinding(target);
-            if (resource) {
-                if (resource[customPushCall])
-                    resource[customPushCall].call(resource, this.call());
-                else
-                    resource.pushCall(this.call());
-            }
-        };
-    });
-})([
-    "attachShader",
-    "bindAttribLocation",
-    "compileShader",
-    "detachShader",
-    "linkProgram",
-    "shaderSource",
-    "bufferData",
-    "bufferSubData",
-    "compressedTexImage2D",
-    "compressedTexSubImage2D",
-    "copyTexImage2D",
-    "copyTexSubImage2D",
-    "generateMipmap",
-    "texImage2D",
-    "texSubImage2D",
-    "texParameterf",
-    "texParameteri",
-    "framebufferRenderbuffer",
-    "framebufferTexture2D",
-    "renderbufferStorage"
-]);
-
 /**
  * @constructor
  */
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to