Commit 31858a66 authored by dino@apple.com's avatar dino@apple.com

Bootstrap canvas profiler

https://bugs.webkit.org/show_bug.cgi?id=119652
<rdar://problem/14703665>

Reviewed by Joseph Pecoraro.

Add enough to get an empty Canvas profile recording
and displayed.

* Localizations/en.lproj/localizedStrings.js: Add canvas strings.
* UserInterface/CanvasProfileObject.js: Added. Mostly copied from CSS Selector Profiles.
* UserInterface/CanvasProfileType.js: Added. Ditto.
* UserInterface/CanvasDataGridNode.js: Added. Ditto.
* UserInterface/CanvasProfileView.js: Added. Ditto.
* UserInterface/ContentView.js:
(WebInspector.ContentView): Add support for the new View type.
(WebInspector.ContentView.isViewable):
* UserInterface/InstrumentSidebarPanel.js:
(WebInspector.InstrumentSidebarPanel): Add support for canvas profiles.
(WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphMousedOver):
(WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphMousedDown):
(WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphClicked):
(WebInspector.InstrumentSidebarPanel.prototype._profileTypeWasSelected):
(WebInspector.InstrumentSidebarPanel.prototype._profilesCleared):
* UserInterface/Main.html: Load the new files.
* UserInterface/ProfileManager.js: New methods and support for canvas profiles.
(WebInspector.ProfileManager):
(WebInspector.ProfileManager.prototype.initialize):
(WebInspector.ProfileManager.prototype.isProfilingCanvas):
(WebInspector.ProfileManager.prototype.startProfilingCanvas):
(WebInspector.ProfileManager.prototype.stopProfilingCanvas):
(WebInspector.ProfileManager.prototype._checkForInterruptions):
(WebInspector.ProfileManager.prototype._attemptToResumeProfiling):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153928 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ff5990f3
2013-08-09 Dean Jackson <dino@apple.com>
Bootstrap canvas profiler
https://bugs.webkit.org/show_bug.cgi?id=119652
<rdar://problem/14703665>
Reviewed by Joseph Pecoraro.
Add enough to get an empty Canvas profile recording
and displayed.
* Localizations/en.lproj/localizedStrings.js: Add canvas strings.
* UserInterface/CanvasProfileObject.js: Added. Mostly copied from CSS Selector Profiles.
* UserInterface/CanvasProfileType.js: Added. Ditto.
* UserInterface/CanvasDataGridNode.js: Added. Ditto.
* UserInterface/CanvasProfileView.js: Added. Ditto.
* UserInterface/ContentView.js:
(WebInspector.ContentView): Add support for the new View type.
(WebInspector.ContentView.isViewable):
* UserInterface/InstrumentSidebarPanel.js:
(WebInspector.InstrumentSidebarPanel): Add support for canvas profiles.
(WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphMousedOver):
(WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphMousedDown):
(WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphClicked):
(WebInspector.InstrumentSidebarPanel.prototype._profileTypeWasSelected):
(WebInspector.InstrumentSidebarPanel.prototype._profilesCleared):
* UserInterface/Main.html: Load the new files.
* UserInterface/ProfileManager.js: New methods and support for canvas profiles.
(WebInspector.ProfileManager):
(WebInspector.ProfileManager.prototype.initialize):
(WebInspector.ProfileManager.prototype.isProfilingCanvas):
(WebInspector.ProfileManager.prototype.startProfilingCanvas):
(WebInspector.ProfileManager.prototype.stopProfilingCanvas):
(WebInspector.ProfileManager.prototype._checkForInterruptions):
(WebInspector.ProfileManager.prototype._attemptToResumeProfiling):
2013-08-07 Timothy Hatcher <timothy@apple.com> 2013-08-07 Timothy Hatcher <timothy@apple.com>
Switch the generated images off of PDFs and onto SVGs now that bug 119492 is fixed. Switch the generated images off of PDFs and onto SVGs now that bug 119492 is fixed.
......
Bvar localizedStrings = new Object; Bvar localizedStrings = new Object;
......
/*
* Copyright (C) 2013 Apple 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
*/
WebInspector.CanvasDataGridNode = function(profileView, data)
{
WebInspector.DataGridNode.call(this, data, false);
this._profileView = profileView;
}
WebInspector.CanvasDataGridNode.prototype = {
constructor: WebInspector.CanvasDataGridNode,
get data()
{
var data = {};
return data;
},
get rawData()
{
return this._data;
},
createCell: function(columnIdentifier)
{
var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
cell.removeChildren();
if (this.rawData.url) {
var wrapperDiv = cell.createChild("div");
wrapperDiv.appendChild(this._linkifyLocation(this.rawData.url, this.rawData.lineNumber, this.rawData.columnNumber));
}
return cell;
},
_linkifyLocation: function(url, lineNumber, columnNumber)
{
return WebInspector.linkifyLocation(url, lineNumber, columnNumber || 0);
}
}
WebInspector.CanvasDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype;
/*
* Copyright (C) 2013 Apple 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
*/
WebInspector.CanvasProfileObject = function(title, id, recording, data)
{
WebInspector.ProfileObject.call(this, WebInspector.CanvasProfileType.TypeId, title, id, recording);
this._data = data || [];
};
WebInspector.CanvasProfileObject.prototype = {
constructor: WebInspector.CanvasProfileObject,
get data()
{
return this._data;
},
set data(data)
{
this._data = data;
}
};
WebInspector.CanvasProfileObject.prototype.__proto__ = WebInspector.ProfileObject.prototype;
/*
* Copyright (C) 2013 Apple 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
*/
WebInspector.CanvasProfileType = function()
{
WebInspector.ProfileType.call(this, WebInspector.CanvasProfileType.TypeId, WebInspector.UIString("Collect Canvas Profile"));
this._recording = false;
this._profileId = 1;
WebInspector.CanvasProfileType.instance = this;
}
WebInspector.CanvasProfileType.TypeId = "CANVAS";
WebInspector.CanvasProfileType.prototype = {
constructor: WebInspector.CanvasProfileType,
get buttonTooltip()
{
return this._recording ? WebInspector.UIString("Stop Canvas profiling.") : WebInspector.UIString("Start Canvas profiling.");
},
buttonClicked: function()
{
if (this._recording)
this.stopRecordingProfile();
else
this.startRecordingProfile();
},
get treeItemTitle()
{
return WebInspector.UIString("CANVAS PROFILES");
},
get description()
{
return WebInspector.UIString("Canvas profiles allow you to examine drawing operations on canvas elements.");
},
reset: function()
{
this._profileId = 1;
},
nextProfileId: function()
{
return this._profileId++;
},
isRecordingProfile: function()
{
return this._recording;
},
setRecordingProfile: function(isProfiling)
{
this._recording = isProfiling;
},
startRecordingProfile: function()
{
this._recording = true;
// FIXME: This is where we would ask the Canvas Agent to profile.
},
stopRecordingProfile: function(callback)
{
this._recording = false;
// FIXME: This is where we would ask the Canvas Agent to stop profiling.
// For now pass in an empty array of canvas calls.
callback(null, {data: []});
},
createSidebarTreeElementForProfile: function(profile)
{
return new WebInspector.ProfileSidebarTreeElement(profile, profile.title, "profile-sidebar-tree-item");
},
createView: function(profile)
{
return new WebInspector.CanvasProfileView(profile);
}
}
WebInspector.CanvasProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype;
/*
* Copyright (C) 2013 Apple 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
*/
WebInspector.CanvasProfileView = function(profile)
{
console.assert(profile instanceof WebInspector.CanvasProfileObject);
WebInspector.ProfileView.call(this, profile);
}
WebInspector.CanvasProfileView.prototype = {
constructor: WebInspector.CanvasProfileView,
updateLayout: function()
{
if (this.dataGrid)
this.dataGrid.updateLayout();
},
get recordingTitle()
{
return WebInspector.UIString("Recording Canvas Profile…");
},
displayProfile: function()
{
var columns = {"number": {title: "#", width: "5%", sortable: false},
"source": {title: WebInspector.UIString("Call"), width: "75%", sortable: false, disclosure: true},
"location": {title: WebInspector.UIString("Location"), width: "20%", sortable: false}};
this.dataGrid = new WebInspector.DataGrid(columns);
this.dataGrid.element.classList.add("canvas-profile-view");
this.element.appendChild(this.dataGrid.element);
this.dataGrid.updateLayout();
this._createProfileNodes();
},
_createProfileNodes: function()
{
var data = this.profile.data;
if (!data) {
// The profiler may have been terminated with the "Clear all profiles." button.
return;
}
this.profile.children = [];
for (var i = 0; i < data.length; ++i) {
var node = new WebInspector.CanvasDataGridNode(this, data[i]);
this.profile.children.push(node);
}
},
rebuildGridItems: function()
{
this.dataGrid.removeChildren();
var children = this.profile.children;
var count = children.length;
for (var index = 0; index < count; ++index)
this.dataGrid.appendChild(children[index]);
},
refreshData: function()
{
var child = this.dataGrid.children[0];
while (child) {
child.refresh();
child = child.traverseNextNode(false, null, true);
}
}
}
WebInspector.CanvasProfileView.prototype.__proto__ = WebInspector.ProfileView.prototype;
...@@ -65,10 +65,13 @@ WebInspector.ContentView = function(representedObject) ...@@ -65,10 +65,13 @@ WebInspector.ContentView = function(representedObject)
if (representedObject instanceof WebInspector.JavaScriptProfileObject) if (representedObject instanceof WebInspector.JavaScriptProfileObject)
return new WebInspector.JavaScriptProfileView(representedObject); return new WebInspector.JavaScriptProfileView(representedObject);
if (representedObject instanceof WebInspector.CSSSelectorProfileObject) if (representedObject instanceof WebInspector.CSSSelectorProfileObject)
return new WebInspector.CSSSelectorProfileView(representedObject); return new WebInspector.CSSSelectorProfileView(representedObject);
if (representedObject instanceof WebInspector.CanvasProfileObject)
return new WebInspector.CanvasProfileView(representedObject);
if (typeof representedObject === "string" || representedObject instanceof String) if (typeof representedObject === "string" || representedObject instanceof String)
return new WebInspector.TextContentView(representedObject); return new WebInspector.TextContentView(representedObject);
...@@ -121,6 +124,8 @@ WebInspector.ContentView.isViewable = function(representedObject) ...@@ -121,6 +124,8 @@ WebInspector.ContentView.isViewable = function(representedObject)
return true; return true;
if (representedObject instanceof WebInspector.CSSSelectorProfileObject) if (representedObject instanceof WebInspector.CSSSelectorProfileObject)
return true; return true;
if (representedObject instanceof WebInspector.CanvasProfileObject)
return true;
if (typeof representedObject === "string" || representedObject instanceof String) if (typeof representedObject === "string" || representedObject instanceof String)
return true; return true;
return false; return false;
......
...@@ -105,9 +105,15 @@ WebInspector.InstrumentSidebarPanel = function() ...@@ -105,9 +105,15 @@ WebInspector.InstrumentSidebarPanel = function()
startCSSSelectorProfileOption.textContent = WebInspector.UIString("Start CSS Selector Profile"); startCSSSelectorProfileOption.textContent = WebInspector.UIString("Start CSS Selector Profile");
startCSSSelectorProfileOption.value = WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue; startCSSSelectorProfileOption.value = WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue;
startCSSSelectorProfileOption.selected = false; startCSSSelectorProfileOption.selected = false;
var startCanvasProfileOption = document.createElement("option");
startCanvasProfileOption.textContent = WebInspector.UIString("Start Canvas Profile");
startCanvasProfileOption.value = WebInspector.InstrumentSidebarPanel.StartCanvasProfileValue;
startCanvasProfileOption.selected = false;
this._recordProfileGlyphElement.add(startJavaScriptProfileOption); this._recordProfileGlyphElement.add(startJavaScriptProfileOption);
this._recordProfileGlyphElement.add(startCSSSelectorProfileOption); this._recordProfileGlyphElement.add(startCSSSelectorProfileOption);
this._recordProfileGlyphElement.add(startCanvasProfileOption);
profilesTitleBarElement.appendChild(this._recordProfileGlyphElement); profilesTitleBarElement.appendChild(this._recordProfileGlyphElement);
...@@ -152,6 +158,7 @@ WebInspector.InstrumentSidebarPanel.ScriptIconStyleClass = "script-icon"; ...@@ -152,6 +158,7 @@ WebInspector.InstrumentSidebarPanel.ScriptIconStyleClass = "script-icon";
WebInspector.InstrumentSidebarPanel.ProfileIconStyleClass = "profile-icon"; WebInspector.InstrumentSidebarPanel.ProfileIconStyleClass = "profile-icon";
WebInspector.InstrumentSidebarPanel.StartJavaScriptProfileValue = "start-javascript-profile"; WebInspector.InstrumentSidebarPanel.StartJavaScriptProfileValue = "start-javascript-profile";
WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue = "start-css-selector-profile"; WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue = "start-css-selector-profile";
WebInspector.InstrumentSidebarPanel.StartCanvasProfileValue = "start-canvas-profile";
WebInspector.InstrumentSidebarPanel.prototype = { WebInspector.InstrumentSidebarPanel.prototype = {
constructor: WebInspector.InstrumentSidebarPanel, constructor: WebInspector.InstrumentSidebarPanel,
...@@ -277,7 +284,7 @@ WebInspector.InstrumentSidebarPanel.prototype = { ...@@ -277,7 +284,7 @@ WebInspector.InstrumentSidebarPanel.prototype = {
{ {
this._recordProfileGlyphElement.classList.remove(WebInspector.InstrumentSidebarPanel.RecordGlyphRecordingForcedStyleClass); this._recordProfileGlyphElement.classList.remove(WebInspector.InstrumentSidebarPanel.RecordGlyphRecordingForcedStyleClass);
if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors()) if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors() || WebInspector.profileManager.isProfilingCanvas())
this._recordProfileStatusElement.textContent = WebInspector.UIString("Stop Profiling"); this._recordProfileStatusElement.textContent = WebInspector.UIString("Stop Profiling");
else else
this._recordProfileStatusElement.textContent = WebInspector.UIString("Start Profiling"); this._recordProfileStatusElement.textContent = WebInspector.UIString("Start Profiling");
...@@ -300,7 +307,7 @@ WebInspector.InstrumentSidebarPanel.prototype = { ...@@ -300,7 +307,7 @@ WebInspector.InstrumentSidebarPanel.prototype = {
// We don't want to show the select if the user is currently profiling. In that case, // We don't want to show the select if the user is currently profiling. In that case,
// the user should just be able to click the record button to stop profiling. // the user should just be able to click the record button to stop profiling.
if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors()) if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors() || WebInspector.profileManager.isProfilingCanvas())
event.preventDefault(); event.preventDefault();
else { else {
// When a select is opened, a click event will be fired when the select is closed, // When a select is opened, a click event will be fired when the select is closed,
...@@ -324,6 +331,8 @@ WebInspector.InstrumentSidebarPanel.prototype = { ...@@ -324,6 +331,8 @@ WebInspector.InstrumentSidebarPanel.prototype = {
WebInspector.profileManager.stopProfilingJavaScript(); WebInspector.profileManager.stopProfilingJavaScript();
if (WebInspector.profileManager.isProfilingCSSSelectors()) if (WebInspector.profileManager.isProfilingCSSSelectors())
WebInspector.profileManager.stopProfilingCSSSelectors(); WebInspector.profileManager.stopProfilingCSSSelectors();
if (WebInspector.profileManager.isProfilingCanvas())
WebInspector.profileManager.stopProfilingCanvas();
}, },
_profileTypeWasSelected: function(event) _profileTypeWasSelected: function(event)
...@@ -331,15 +340,16 @@ WebInspector.InstrumentSidebarPanel.prototype = { ...@@ -331,15 +340,16 @@ WebInspector.InstrumentSidebarPanel.prototype = {
var selectedIndex = this._recordProfileGlyphElement.selectedIndex; var selectedIndex = this._recordProfileGlyphElement.selectedIndex;
if (selectedIndex === -1) if (selectedIndex === -1)
return; return;
var selectedValue = this._recordProfileGlyphElement.options[selectedIndex].value; var selectedValue = this._recordProfileGlyphElement.options[selectedIndex].value;
if (selectedValue === WebInspector.InstrumentSidebarPanel.StartJavaScriptProfileValue) if (selectedValue === WebInspector.InstrumentSidebarPanel.StartJavaScriptProfileValue)
WebInspector.profileManager.startProfilingJavaScript(); WebInspector.profileManager.startProfilingJavaScript();
else { else if (selectedValue === WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue)
console.assert(selectedValue === WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue);
WebInspector.profileManager.startProfilingCSSSelectors(); WebInspector.profileManager.startProfilingCSSSelectors();
else {
console.assert(selectedValue === WebInspector.InstrumentSidebarPanel.StartCanvasProfileValue);
WebInspector.profileManager.startProfilingCanvas();
} }
}, },
_recordingStarted: function(event) _recordingStarted: function(event)
...@@ -478,6 +488,7 @@ WebInspector.InstrumentSidebarPanel.prototype = { ...@@ -478,6 +488,7 @@ WebInspector.InstrumentSidebarPanel.prototype = {
WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.JavaScriptProfileView); WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.JavaScriptProfileView);
WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.CSSSelectorProfileView); WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.CSSSelectorProfileView);
WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.CanvasProfileView);
this.updateEmptyContentPlaceholder(WebInspector.UIString("No Recorded Profiles")); this.updateEmptyContentPlaceholder(WebInspector.UIString("No Recorded Profiles"));
}, },
......
...@@ -335,9 +335,13 @@ ...@@ -335,9 +335,13 @@
<script src="JavaScriptProfileView.js"></script> <script src="JavaScriptProfileView.js"></script>
<script src="CSSSelectorProfileType.js"></script> <script src="CSSSelectorProfileType.js"></script>
<script src="CSSSelectorProfileView.js"></script> <script src="CSSSelectorProfileView.js"></script>
<script src="CanvasDataGridNode.js"></script>
<script src="CanvasProfileType.js"></script>
<script src="CanvasProfileView.js"></script>
<script src="ProfileObject.js"></script> <script src="ProfileObject.js"></script>
<script src="JavaScriptProfileObject.js"></script> <script src="JavaScriptProfileObject.js"></script>
<script src="CSSSelectorProfileObject.js"></script> <script src="CSSSelectorProfileObject.js"></script>
<script src="CanvasProfileObject.js"></script>
<script src="DebuggerSidebarPanel.js"></script> <script src="DebuggerSidebarPanel.js"></script>
<script src="BreakpointTreeElement.js"></script> <script src="BreakpointTreeElement.js"></script>
<script src="Breakpoint.js"></script> <script src="Breakpoint.js"></script>
......
...@@ -29,6 +29,7 @@ WebInspector.ProfileManager = function() ...@@ -29,6 +29,7 @@ WebInspector.ProfileManager = function()
this._javaScriptProfileType = new WebInspector.JavaScriptProfileType; this._javaScriptProfileType = new WebInspector.JavaScriptProfileType;
this._cssSelectorProfileType = new WebInspector.CSSSelectorProfileType; this._cssSelectorProfileType = new WebInspector.CSSSelectorProfileType;
this._canvasProfileType = new WebInspector.CanvasProfileType;
ProfilerAgent.enable(); ProfilerAgent.enable();
ProfilerAgent.getProfileHeaders(); ProfilerAgent.getProfileHeaders();
...@@ -60,6 +61,7 @@ WebInspector.ProfileManager.prototype = { ...@@ -60,6 +61,7 @@ WebInspector.ProfileManager.prototype = {
this._recordingJavaScriptProfile = null; this._recordingJavaScriptProfile = null;
this._recordingCSSSelectorProfile = null; this._recordingCSSSelectorProfile = null;
this._recordingCanvasProfile = null;
this._isProfiling = false; this._isProfiling = false;
...@@ -122,6 +124,43 @@ WebInspector.ProfileManager.prototype = { ...@@ -122,6 +124,43 @@ WebInspector.ProfileManager.prototype = {
this._cssSelectorProfileType.stopRecordingProfile(cssProfilingStopped.bind(this)); this._cssSelectorProfileType.stopRecordingProfile(cssProfilingStopped.bind(this));
}, },
isProfilingCanvas: function()
{
return this._canvasProfileType.isRecordingProfile();
},
startProfilingCanvas: function()
{
this._canvasProfileType.startRecordingProfile();
var id = this._canvasProfileType.nextProfileId();
this._recordingCanvasProfile = new WebInspector.CanvasProfileObject(WebInspector.UIString("Canvas Profile %d").format(id), id, true);
this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfileWasAdded, {profile: this._recordingCanvasProfile});
this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfilingStarted);
},
stopProfilingCanvas: function()
{
function canvasProfilingStopped(error, profile)
{
if (error)
return;
console.assert(this._recordingCanvasProfile);
this._recordingCanvasProfile.data = profile.data;
this._recordingCanvasProfile.recording = false;
this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfileWasUpdated, {profile: this._recordingCanvasProfile});
this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfilingEnded, {profile: this._recordingCanvasProfile});
this._recordingCanvasProfile = null;
}