Web Inspector: add source view for WebGL shader programs
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2017 21:39:58 +0000 (21:39 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2017 21:39:58 +0000 (21:39 +0000)
commita8ccc61ff7abb8ce1ae180fdaab1422da0f1b342
treea124186f3dc0fe4c3ee14c4ce540fa65863baadf
parentc318f53256c480a902d04eeaca963fd01ff0bc55
Web Inspector: add source view for WebGL shader programs
https://bugs.webkit.org/show_bug.cgi?id=138593
<rdar://problem/18936194>

Reviewed by Matt Baker.

Source/JavaScriptCore:

* inspector/protocol/Canvas.json:
 - Add `ShaderType` enum that contains "vertex" and "fragment".
 - Add `requestShaderSource` command that will return the original source code for a given
   shader program and shader type.

Source/WebCore:

Test: inspector/canvas/requestShaderSource.html

* inspector/InspectorCanvasAgent.h:
* inspector/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::requestShaderSource):

* inspector/InspectorShaderProgram.h:
* inspector/InspectorShaderProgram.cpp:
(WebCore::InspectorShaderProgram::shaderForType):

Source/WebInspectorUI:

Shader programs are now listed in the Resources sidebar as items within the owner Canvas
context. When selected, the shown content view has two editors, one for the Vertex shader
and one for the Fragment shader. These editors use CodeMirror's "clike" mode for GLSL syntax.

* Localizations/en.lproj/localizedStrings.js:
* WebInspectorUI.vcxproj/WebInspectorUI.vcxproj:
* WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters:
* UserInterface/Main.html:

* UserInterface/Controllers/CanvasManager.js:
(WI.CanvasManager):
(WI.CanvasManager.prototype.canvasRemoved):
(WI.CanvasManager.prototype.programCreated):
(WI.CanvasManager.prototype.programDeleted):
(WI.CanvasManager.prototype._mainResourceDidChange):

* UserInterface/Models/Collection.js:
* UserInterface/Models/Canvas.js:
(WI.Canvas.prototype.get shaderProgramCollection)

* UserInterface/Models/ShaderProgram.js:
(WI.ShaderProgram.prototype.requestVertexShaderSource):
(WI.ShaderProgram.prototype.requestFragmentShaderSource):
(WI.ShaderProgram.prototype._requestShaderSource):

* UserInterface/Views/CanvasTreeElement.js:
(WI.CanvasTreeElement):
(WI.CanvasTreeElement.prototype.onattach):
(WI.CanvasTreeElement.prototype.ondetach):
(WI.CanvasTreeElement.prototype.onpopulate):
(WI.CanvasTreeElement.prototype._shaderProgramAdded):
(WI.CanvasTreeElement.prototype._shaderProgramRemoved):

* UserInterface/Views/ShaderProgramTreeElement.js: Added.
(WI.ShaderProgramTreeElement):

* UserInterface/Views/ShaderProgramContentView.js: Added.
(WI.ShaderProgramContentView):
(WI.ShaderProgramContentView.prototype.shown):
(WI.ShaderProgramContentView.prototype.hidden):
(WI.ShaderProgramContentView.prototype.closed):
(WI.ShaderProgramContentView.prototype.get supportsSave):
(WI.ShaderProgramContentView.prototype.get saveData):
(WI.ShaderProgramContentView.prototype.get supportsSearch):
(WI.ShaderProgramContentView.prototype.get numberOfSearchResults):
(WI.ShaderProgramContentView.prototype.get hasPerformedSearch):
(WI.ShaderProgramContentView.prototype.set automaticallyRevealFirstSearchResult):
(WI.ShaderProgramContentView.prototype.performSearch):
(WI.ShaderProgramContentView.prototype.searchCleared):
(WI.ShaderProgramContentView.prototype.searchQueryWithSelection):
(WI.ShaderProgramContentView.prototype.revealPreviousSearchResult):
(WI.ShaderProgramContentView.prototype.revealNextSearchResult):
(WI.ShaderProgramContentView.prototype.revealPosition):
(WI.ShaderProgramContentView.prototype._editorFocused):
(WI.ShaderProgramContentView.prototype._numberOfSearchResultsDidChange):
* UserInterface/Views/ShaderProgramContentView.css: Added.
(.content-view.shader-program > .text-editor.shader):
(body[dir=ltr] .content-view.shader-program > .text-editor.shader.vertex,):
(body[dir=ltr] .content-view.shader-program > .text-editor.shader.fragment,):
(body[dir=ltr] .content-view.shader-program > .text-editor.shader + .text-editor.shader):
(body[dir=rtl] .content-view.shader-program > .text-editor.shader + .text-editor.shader):
(.content-view.shader-program > .text-editor.shader > .type-title):
(.content-view.shader-program > .text-editor.shader > .CodeMirror):

* UserInterface/Images/DocumentGL.png: Added.
* UserInterface/Images/DocumentGL@2x.png: Added.
* UserInterface/Views/ResourceIcons.css:
(.shader-program .icon):

* UserInterface/Base/Main.js:
* UserInterface/Views/ContentView.js:
(WI.ContentView.createFromRepresentedObject):
(WI.ContentView.isViewable):
* UserInterface/Views/ResourceSidebarPanel.js:
(WI.ResourceSidebarPanel.prototype.matchTreeElementAgainstCustomFilters.match):
(WI.ResourceSidebarPanel.prototype.matchTreeElementAgainstCustomFilters):
(WI.ResourceSidebarPanel.prototype._treeSelectionDidChange):
* UserInterface/Views/ResourcesTabContentView.js:
(WI.ResourcesTabContentView.prototype.canShowRepresentedObject):
Plumbing for displaying ShaderProgram content.

* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor):
(WebInspector.TextEditor.prototype._editorFocused):

* Scripts/update-codemirror-resources.rb:
* UserInterface/External/CodeMirror/clike.js: Added.
Add C-like mode for highlighting GLSL.

LayoutTests:

* inspector/canvas/requestShaderSource-expected.txt: Added.
* inspector/canvas/requestShaderSource.html: Added.

* inspector/canvas/resources/shaderProgram-utilities.js:
(linkProgram):
(linkProgram.typeForScript):
(linkProgram.createShaderFromScript):

* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220294 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/canvas/requestShaderSource-expected.txt [new file with mode: 0644]
LayoutTests/inspector/canvas/requestShaderSource.html [new file with mode: 0644]
LayoutTests/inspector/canvas/resources/shaderProgram-utilities.js
LayoutTests/platform/win/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Canvas.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorCanvasAgent.cpp
Source/WebCore/inspector/InspectorCanvasAgent.h
Source/WebCore/inspector/InspectorShaderProgram.cpp
Source/WebCore/inspector/InspectorShaderProgram.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/Scripts/update-codemirror-resources.rb
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
Source/WebInspectorUI/UserInterface/External/CodeMirror/clike.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Images/DocumentGL.png [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Images/DocumentGL@2x.png [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Models/Canvas.js
Source/WebInspectorUI/UserInterface/Models/Collection.js
Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js
Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css
Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ResourcesTabContentView.js
Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.css [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Views/TextEditor.js
Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj
Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters