Web Inspector: [WebGL] Add injected WebGL module class
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2012 16:53:57 +0000 (16:53 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2012 16:53:57 +0000 (16:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89592

Patch by Andrey Adaikin <aandrey@chromium.org> on 2012-06-21
Reviewed by Pavel Feldman.

Adding a new InjectedScriptWebGLModule class and moving WebGL-related
stuff out of InjectedScriptManager class.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InjectedScriptManager.cpp:
* inspector/InjectedScriptManager.h:
(InjectedScriptManager):
* inspector/InjectedScriptModule.cpp:
(WebCore::InjectedScriptModule::ensureInjected):
* inspector/InjectedScriptModule.h:
(InjectedScriptModule):
* inspector/InjectedScriptWebGLModule.cpp: Copied from Source/WebCore/inspector/InjectedScriptModule.cpp.
(WebCore):
(WebCore::InjectedScriptWebGLModule::InjectedScriptWebGLModule):
(WebCore::InjectedScriptWebGLModule::moduleForState):
(WebCore::InjectedScriptWebGLModule::source):
(WebCore::InjectedScriptWebGLModule::wrapWebGLContext):
(WebCore::InjectedScriptWebGLModule::captureFrame):
* inspector/InjectedScriptWebGLModule.h: Copied from Source/WebCore/inspector/InjectedScriptModule.h.
(WebCore):
(InjectedScriptWebGLModule):
* inspector/InspectorWebGLAgent.cpp:
(WebCore::InspectorWebGLAgent::wrapWebGLRenderingContextForInstrumentation):

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

14 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InjectedScriptManager.cpp
Source/WebCore/inspector/InjectedScriptManager.h
Source/WebCore/inspector/InjectedScriptModule.cpp
Source/WebCore/inspector/InjectedScriptModule.h
Source/WebCore/inspector/InjectedScriptWebGLModule.cpp [new file with mode: 0644]
Source/WebCore/inspector/InjectedScriptWebGLModule.h [new file with mode: 0644]
Source/WebCore/inspector/InspectorWebGLAgent.cpp

index 29e88f5..7b3ae50 100644 (file)
@@ -930,11 +930,12 @@ SET(WebCore_SOURCES
     inspector/DOMNodeHighlighter.cpp
     inspector/DOMPatchSupport.cpp
     inspector/IdentifiersFactory.cpp
-    inspector/InjectedScriptModule.cpp
     inspector/InjectedScript.cpp
     inspector/InjectedScriptBase.cpp
     inspector/InjectedScriptHost.cpp
     inspector/InjectedScriptManager.cpp
+    inspector/InjectedScriptModule.cpp
+    inspector/InjectedScriptWebGLModule.cpp
     inspector/InspectorAgent.cpp
     inspector/InspectorApplicationCacheAgent.cpp
     inspector/InspectorBaseAgent.cpp
index f2c6281..1cd92ce 100644 (file)
@@ -1,3 +1,39 @@
+2012-06-21  Andrey Adaikin  <aandrey@chromium.org>
+
+        Web Inspector: [WebGL] Add injected WebGL module class
+        https://bugs.webkit.org/show_bug.cgi?id=89592
+
+        Reviewed by Pavel Feldman.
+
+        Adding a new InjectedScriptWebGLModule class and moving WebGL-related
+        stuff out of InjectedScriptManager class.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/InjectedScriptManager.cpp:
+        * inspector/InjectedScriptManager.h:
+        (InjectedScriptManager):
+        * inspector/InjectedScriptModule.cpp:
+        (WebCore::InjectedScriptModule::ensureInjected):
+        * inspector/InjectedScriptModule.h:
+        (InjectedScriptModule):
+        * inspector/InjectedScriptWebGLModule.cpp: Copied from Source/WebCore/inspector/InjectedScriptModule.cpp.
+        (WebCore):
+        (WebCore::InjectedScriptWebGLModule::InjectedScriptWebGLModule):
+        (WebCore::InjectedScriptWebGLModule::moduleForState):
+        (WebCore::InjectedScriptWebGLModule::source):
+        (WebCore::InjectedScriptWebGLModule::wrapWebGLContext):
+        (WebCore::InjectedScriptWebGLModule::captureFrame):
+        * inspector/InjectedScriptWebGLModule.h: Copied from Source/WebCore/inspector/InjectedScriptModule.h.
+        (WebCore):
+        (InjectedScriptWebGLModule):
+        * inspector/InspectorWebGLAgent.cpp:
+        (WebCore::InspectorWebGLAgent::wrapWebGLRenderingContextForInstrumentation):
+
 2012-06-21  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: do not add separator to the end of the context menu.
index 985db9a..7c670d3 100644 (file)
@@ -2653,8 +2653,6 @@ webcore_sources += \
        Source/WebCore/inspector/DOMWrapperVisitor.h \
        Source/WebCore/inspector/IdentifiersFactory.cpp \
        Source/WebCore/inspector/IdentifiersFactory.h \
-       Source/WebCore/inspector/InjectedScriptModule.cpp \
-       Source/WebCore/inspector/InjectedScriptModule.h \
        Source/WebCore/inspector/InjectedScript.cpp \
        Source/WebCore/inspector/InjectedScript.h \
        Source/WebCore/inspector/InjectedScriptBase.cpp \
@@ -2663,6 +2661,10 @@ webcore_sources += \
        Source/WebCore/inspector/InjectedScriptHost.h \
        Source/WebCore/inspector/InjectedScriptManager.cpp \
        Source/WebCore/inspector/InjectedScriptManager.h \
+       Source/WebCore/inspector/InjectedScriptModule.cpp \
+       Source/WebCore/inspector/InjectedScriptModule.h \
+       Source/WebCore/inspector/InjectedScriptWebGLModule.cpp \
+       Source/WebCore/inspector/InjectedScriptWebGLModule.h \
        Source/WebCore/inspector/InspectorAgent.cpp \
        Source/WebCore/inspector/InspectorAgent.h \
        Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp \
index b9ddf93..20f0be6 100644 (file)
@@ -890,11 +890,12 @@ SOURCES += \
     inspector/DOMNodeHighlighter.cpp \
     inspector/DOMPatchSupport.cpp \
     inspector/IdentifiersFactory.cpp \
-    inspector/InjectedScriptModule.cpp \
     inspector/InjectedScript.cpp \
     inspector/InjectedScriptBase.cpp \
     inspector/InjectedScriptHost.cpp \
     inspector/InjectedScriptManager.cpp \
+    inspector/InjectedScriptModule.cpp \
+    inspector/InjectedScriptWebGLModule.cpp \
     inspector/InspectorAgent.cpp \
     inspector/InspectorApplicationCacheAgent.cpp \
     inspector/InspectorBaseAgent.cpp \
@@ -2040,11 +2041,12 @@ HEADERS += \
     inspector/DOMPatchSupport.h \
     inspector/DOMWrapperVisitor.h \
     inspector/IdentifiersFactory.h \
-    inspector/InjectedScriptModule.h \
     inspector/InjectedScript.h \
     inspector/InjectedScriptBase.h \
     inspector/InjectedScriptHost.h \
     inspector/InjectedScriptManager.h \
+    inspector/InjectedScriptModule.h \
+    inspector/InjectedScriptWebGLModule.h \
     inspector/InspectorAgent.h \
     inspector/InspectorApplicationCacheAgent.h \
     inspector/InspectorBaseAgent.h \
index b4f141a..407888f 100644 (file)
             'inspector/DOMWrapperVisitor.h',
             'inspector/IdentifiersFactory.cpp',
             'inspector/IdentifiersFactory.h',
-            'inspector/InjectedScriptModule.cpp',
-            'inspector/InjectedScriptModule.h',
             'inspector/InjectedScript.cpp',
             'inspector/InjectedScript.h',
             'inspector/InjectedScriptBase.cpp',
             'inspector/InjectedScriptHost.h',
             'inspector/InjectedScriptManager.cpp',
             'inspector/InjectedScriptManager.h',
+            'inspector/InjectedScriptModule.cpp',
+            'inspector/InjectedScriptModule.h',
+            'inspector/InjectedScriptWebGLModule.cpp',
+            'inspector/InjectedScriptWebGLModule.h',
             'inspector/InspectorAgent.cpp',
             'inspector/InspectorApplicationCacheAgent.cpp',
             'inspector/InspectorApplicationCacheAgent.h',
index 056f894..4b69275 100755 (executable)
                                >
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptModule.cpp"
+                               RelativePath="..\inspector\InjectedScript.cpp"
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
                                </FileConfiguration>
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptModule.h"
+                               RelativePath="..\inspector\InjectedScript.h"
                                >
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScript.cpp"
+                               RelativePath="..\inspector\InjectedScriptBase.cpp"
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
                                </FileConfiguration>
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScript.h"
+                               RelativePath="..\inspector\InjectedScriptBase.h"
                                >
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptBase.cpp"
+                               RelativePath="..\inspector\InjectedScriptHost.cpp"
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
                                </FileConfiguration>
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptBase.h"
+                               RelativePath="..\inspector\InjectedScriptHost.h"
                                >
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptHost.cpp"
+                               RelativePath="..\inspector\InjectedScriptManager.cpp"
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
                                </FileConfiguration>
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptHost.h"
+                               RelativePath="..\inspector\InjectedScriptManager.h"
                                >
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptManager.cpp"
+                               RelativePath="..\inspector\InjectedScriptModule.cpp"
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
                                </FileConfiguration>
                        </File>
                        <File
-                               RelativePath="..\inspector\InjectedScriptManager.h"
+                               RelativePath="..\inspector\InjectedScriptModule.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\inspector\InjectedScriptWebGLModule.cpp"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Production|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\inspector\InjectedScriptWebGLModule.h"
                                >
                        </File>
                        <File
index 492fc12..63d2544 100644 (file)
                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0978EE0ABAA6E100874480 /* CSSCursorImageValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AA4C3A760B2B1679002334A2 /* StyleElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA4C3A740B2B1679002334A2 /* StyleElement.cpp */; };
                AA4C3A770B2B1679002334A2 /* StyleElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4C3A750B2B1679002334A2 /* StyleElement.h */; };
+               AA73183E159255B900A93E6E /* InjectedScriptWebGLModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA73183C159255B900A93E6E /* InjectedScriptWebGLModule.cpp */; };
+               AA73183F159255B900A93E6E /* InjectedScriptWebGLModule.h in Headers */ = {isa = PBXBuildFile; fileRef = AA73183D159255B900A93E6E /* InjectedScriptWebGLModule.h */; };
                AAB6054E15874C58007B5031 /* InjectedScriptBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAB6054A15874C58007B5031 /* InjectedScriptBase.cpp */; };
                AAB6054F15874C58007B5031 /* InjectedScriptBase.h in Headers */ = {isa = PBXBuildFile; fileRef = AAB6054B15874C58007B5031 /* InjectedScriptBase.h */; };
                AAB6055015874C58007B5031 /* InjectedScriptModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAB6054C15874C58007B5031 /* InjectedScriptModule.cpp */; };
                AA0978EE0ABAA6E100874480 /* CSSCursorImageValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSCursorImageValue.h; sourceTree = "<group>"; };
                AA4C3A740B2B1679002334A2 /* StyleElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StyleElement.cpp; sourceTree = "<group>"; };
                AA4C3A750B2B1679002334A2 /* StyleElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StyleElement.h; sourceTree = "<group>"; };
+               AA73183C159255B900A93E6E /* InjectedScriptWebGLModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScriptWebGLModule.cpp; sourceTree = "<group>"; };
+               AA73183D159255B900A93E6E /* InjectedScriptWebGLModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScriptWebGLModule.h; sourceTree = "<group>"; };
                AA9030FE157E16A000276247 /* InjectedWebGLScriptSource.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = InjectedWebGLScriptSource.js; sourceTree = "<group>"; };
                AA912750157E35A500454E54 /* InjectedWebGLScriptSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedWebGLScriptSource.h; sourceTree = "<group>"; };
                AAB6054A15874C58007B5031 /* InjectedScriptBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScriptBase.cpp; sourceTree = "<group>"; };
                                AAB6054C15874C58007B5031 /* InjectedScriptModule.cpp */,
                                AAB6054D15874C58007B5031 /* InjectedScriptModule.h */,
                                7A563F9512DF5C9100F4536D /* InjectedScriptSource.js */,
+                               AA73183C159255B900A93E6E /* InjectedScriptWebGLModule.cpp */,
+                               AA73183D159255B900A93E6E /* InjectedScriptWebGLModule.h */,
                                AA9030FE157E16A000276247 /* InjectedWebGLScriptSource.js */,
                                1C435CD414E8545B004E10EA /* Inspector-0.1.json */,
                                1C435CD514E8545B004E10EA /* Inspector-1.0.json */,
                                7A0E76FA10BF08ED00A0276E /* InjectedScriptHost.h in Headers */,
                                F316396C1329481A00A649CB /* InjectedScriptManager.h in Headers */,
                                AAB6055115874C58007B5031 /* InjectedScriptModule.h in Headers */,
+                               AA73183F159255B900A93E6E /* InjectedScriptWebGLModule.h in Headers */,
                                A8CFF5E50A155A05000A4234 /* InlineBox.h in Headers */,
                                A8CFF5E30A155A05000A4234 /* InlineFlowBox.h in Headers */,
                                BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
                                7A0E76F910BF08ED00A0276E /* InjectedScriptHost.cpp in Sources */,
                                F316396B1329481A00A649CB /* InjectedScriptManager.cpp in Sources */,
                                AAB6055015874C58007B5031 /* InjectedScriptModule.cpp in Sources */,
+                               AA73183E159255B900A93E6E /* InjectedScriptWebGLModule.cpp in Sources */,
                                A8CFF5E60A155A05000A4234 /* InlineBox.cpp in Sources */,
                                A8CFF5E40A155A05000A4234 /* InlineFlowBox.cpp in Sources */,
                                BCEA4859097D93020094C9E4 /* InlineTextBox.cpp in Sources */,
index e8c64fb..52ec749 100644 (file)
@@ -37,9 +37,6 @@
 #include "InjectedScript.h"
 #include "InjectedScriptHost.h"
 #include "InjectedScriptSource.h"
-#if ENABLE(WEBGL)
-#include "InjectedWebGLScriptSource.h"
-#endif
 #include "InspectorValues.h"
 #include "ScriptObject.h"
 #include <wtf/PassOwnPtr.h>
@@ -190,19 +187,6 @@ InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* inspectedSc
     return result;
 }
 
-#if ENABLE(WEBGL)
-ScriptObject InjectedScriptManager::wrapWebGLRenderingContextForInstrumentation(const ScriptObject&)
-{
-    // FIXME(88973): Inject via this.injectScript()
-    return ScriptObject();
-}
-
-String InjectedScriptManager::injectedWebGLScriptSource()
-{
-    return String(reinterpret_cast<const char*>(InjectedWebGLScriptSource_js), sizeof(InjectedWebGLScriptSource_js));
-}
-#endif
-
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 726bb37..43590d1 100644 (file)
@@ -64,10 +64,6 @@ public:
     void discardInjectedScriptsFor(DOMWindow*);
     void releaseObjectGroup(const String& objectGroup);
 
-#if ENABLE(WEBGL)
-    ScriptObject wrapWebGLRenderingContextForInstrumentation(const ScriptObject&);
-#endif
-
     typedef bool (*InspectedStateAccessCheck)(ScriptState*);
     InspectedStateAccessCheck inspectedStateAccessCheck() const { return m_inspectedStateAccessCheck; }
 
@@ -77,10 +73,6 @@ private:
     String injectedScriptSource();
     ScriptObject createInjectedScript(const String& source, ScriptState*, int id);
 
-#if ENABLE(WEBGL)
-    String injectedWebGLScriptSource();
-#endif
-
     static bool canAccessInspectedWindow(ScriptState*);
     static bool canAccessInspectedWorkerContext(ScriptState*);
 
index 4b163f9..14d29a2 100644 (file)
@@ -46,9 +46,9 @@ InjectedScriptModule::InjectedScriptModule(const String& name)
 {
 }
 
-void InjectedScriptModule::ensureInjected(InjectedScriptManager& injectedScriptManager, ScriptState* scriptState)
+void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, ScriptState* scriptState)
 {
-    InjectedScript injectedScript = injectedScriptManager.injectedScriptFor(scriptState);
+    InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(scriptState);
     ASSERT(!injectedScript.hasNoValue());
     if (injectedScript.hasNoValue())
         return;
@@ -71,7 +71,7 @@ void InjectedScriptModule::ensureInjected(InjectedScriptManager& injectedScriptM
     }
 
     ScriptObject moduleObject(scriptState, resultValue);
-    initialize(moduleObject, injectedScriptManager.inspectedStateAccessCheck());
+    initialize(moduleObject, injectedScriptManager->inspectedStateAccessCheck());
 }
 
 } // namespace WebCore
index ac54a0b..fbfbaa0 100644 (file)
@@ -50,7 +50,7 @@ protected:
     // a static factory method that would create a new instance of the class
     // and call its ensureInjected() method immediately.
     InjectedScriptModule(const String& name);
-    void ensureInjected(InjectedScriptManager&, ScriptState*);
+    void ensureInjected(InjectedScriptManager*, ScriptState*);
 };
 
 #endif
diff --git a/Source/WebCore/inspector/InjectedScriptWebGLModule.cpp b/Source/WebCore/inspector/InjectedScriptWebGLModule.cpp
new file mode 100644 (file)
index 0000000..72ede51
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(INSPECTOR) && ENABLE(WEBGL)
+
+#include "InjectedScriptWebGLModule.h"
+
+#include "InjectedScript.h"
+#include "InjectedScriptManager.h"
+#include "InjectedWebGLScriptSource.h"
+#include "ScriptFunctionCall.h"
+#include "ScriptObject.h"
+
+namespace WebCore {
+
+InjectedScriptWebGLModule::InjectedScriptWebGLModule()
+    : InjectedScriptModule("InjectedScriptWebGLModule")
+{
+}
+
+InjectedScriptWebGLModule InjectedScriptWebGLModule::moduleForState(InjectedScriptManager* injectedScriptManager, ScriptState* scriptState)
+{
+    InjectedScriptWebGLModule result;
+    result.ensureInjected(injectedScriptManager, scriptState);
+    return result;
+}
+
+String InjectedScriptWebGLModule::source() const
+{
+    return String(reinterpret_cast<const char*>(InjectedWebGLScriptSource_js), sizeof(InjectedWebGLScriptSource_js));
+}
+
+ScriptObject InjectedScriptWebGLModule::wrapWebGLContext(const ScriptObject& glContext)
+{
+    ScriptFunctionCall function(injectedScriptObject(), "wrapWebGLContext");
+    function.appendArgument(glContext);
+    bool hadException = false;
+    ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException);
+    if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
+        ASSERT_NOT_REACHED();
+        return ScriptObject();
+    }
+    return ScriptObject(glContext.scriptState(), resultValue);
+}
+
+void InjectedScriptWebGLModule::captureFrame(ErrorString* errorString, const String& contextId)
+{
+    ScriptFunctionCall function(injectedScriptObject(), "captureFrame");
+    function.appendArgument(contextId);
+    bool hadException = false;
+    callFunctionWithEvalEnabled(function, hadException);
+    ASSERT(!hadException);
+    if (hadException)
+        *errorString = "Internal error";
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR) && ENABLE(WEBGL)
diff --git a/Source/WebCore/inspector/InjectedScriptWebGLModule.h b/Source/WebCore/inspector/InjectedScriptWebGLModule.h
new file mode 100644 (file)
index 0000000..50c9e52
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InjectedScriptWebGLModule_h
+#define InjectedScriptWebGLModule_h
+
+#include "InjectedScriptModule.h"
+#include "PlatformString.h"
+#include "ScriptState.h"
+
+namespace WebCore {
+
+class InjectedScriptManager;
+class ScriptObject;
+
+#if ENABLE(INSPECTOR) && ENABLE(WEBGL)
+
+class InjectedScriptWebGLModule : public InjectedScriptModule {
+public:
+    virtual String source() const;
+
+    static InjectedScriptWebGLModule moduleForState(InjectedScriptManager*, ScriptState*);
+
+    ScriptObject wrapWebGLContext(const ScriptObject& glContext);
+    void captureFrame(ErrorString*, const String& contextId);
+
+private:
+    InjectedScriptWebGLModule();
+};
+
+#endif
+
+} // namespace WebCore
+
+#endif
index e8c457b..4dc4d35 100644 (file)
@@ -35,6 +35,7 @@
 #include "InspectorWebGLAgent.h"
 
 #include "InjectedScriptManager.h"
+#include "InjectedScriptWebGLModule.h" 
 #include "InspectorFrontend.h"
 #include "InspectorState.h"
 #include "InstrumentingAgents.h"
@@ -96,7 +97,16 @@ void InspectorWebGLAgent::disable(ErrorString*)
 
 ScriptObject InspectorWebGLAgent::wrapWebGLRenderingContextForInstrumentation(const ScriptObject& glContext)
 {
-    return m_injectedScriptManager->wrapWebGLRenderingContextForInstrumentation(glContext);
+    if (glContext.hasNoValue()) {
+        ASSERT_NOT_REACHED();
+        return ScriptObject();
+    }
+    InjectedScriptWebGLModule module = InjectedScriptWebGLModule::moduleForState(m_injectedScriptManager, glContext.scriptState());
+    if (module.hasNoValue()) {
+        ASSERT_NOT_REACHED();
+        return ScriptObject();
+    }
+    return module.wrapWebGLContext(glContext);
 }
 
 } // namespace WebCore