Changeset 153928 in webkit


Ignore:
Timestamp:
Aug 11, 2013 4:10:57 PM (11 years ago)
Author:
dino@apple.com
Message:

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):

Location:
trunk/Source/WebInspectorUI
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r153894 r153928  
     12013-08-09  Dean Jackson  <dino@apple.com>
     2
     3        Bootstrap canvas profiler
     4        https://bugs.webkit.org/show_bug.cgi?id=119652
     5        <rdar://problem/14703665>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Add enough to get an empty Canvas profile recording
     10        and displayed.
     11
     12        * Localizations/en.lproj/localizedStrings.js: Add canvas strings.
     13        * UserInterface/CanvasProfileObject.js: Added. Mostly copied from CSS Selector Profiles.
     14        * UserInterface/CanvasProfileType.js: Added. Ditto.
     15        * UserInterface/CanvasDataGridNode.js: Added. Ditto.
     16        * UserInterface/CanvasProfileView.js: Added. Ditto.
     17        * UserInterface/ContentView.js:
     18        (WebInspector.ContentView): Add support for the new View type.
     19        (WebInspector.ContentView.isViewable):
     20        * UserInterface/InstrumentSidebarPanel.js:
     21        (WebInspector.InstrumentSidebarPanel): Add support for canvas profiles.
     22        (WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphMousedOver):
     23        (WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphMousedDown):
     24        (WebInspector.InstrumentSidebarPanel.prototype._recordProfileGlyphClicked):
     25        (WebInspector.InstrumentSidebarPanel.prototype._profileTypeWasSelected):
     26        (WebInspector.InstrumentSidebarPanel.prototype._profilesCleared):
     27        * UserInterface/Main.html: Load the new files.
     28        * UserInterface/ProfileManager.js: New methods and support for canvas profiles.
     29        (WebInspector.ProfileManager):
     30        (WebInspector.ProfileManager.prototype.initialize):
     31        (WebInspector.ProfileManager.prototype.isProfilingCanvas):
     32        (WebInspector.ProfileManager.prototype.startProfilingCanvas):
     33        (WebInspector.ProfileManager.prototype.stopProfilingCanvas):
     34        (WebInspector.ProfileManager.prototype._checkForInterruptions):
     35        (WebInspector.ProfileManager.prototype._attemptToResumeProfiling):
     36
    1372013-08-07  Timothy Hatcher  <timothy@apple.com>
    238
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r152979 r153928  
    5555localizedStrings["Breakpoints"] = "Breakpoints";
    5656localizedStrings["Bubbling"] = "Bubbling";
     57localizedStrings["CANVAS PROFILES"] = "CANVAS PROFILES";
    5758localizedStrings["CSS SELECTOR PROFILES"] = "CSS SELECTOR PROFILES";
    5859localizedStrings["CSS Selector Profile %d"] = "CSS Selector Profile %d";
    5960localizedStrings["CSS selector profiles show how long the selector matching has taken in total and how many times a certain selector has matched DOM elements (the results are approximate due to matching algorithm optimizations.)"] = "CSS selector profiles show how long the selector matching has taken in total and how many times a certain selector has matched DOM elements (the results are approximate due to matching algorithm optimizations.)";
    6061localizedStrings["Cached"] = "Cached";
     62localizedStrings["Call"] = "Call";
    6163localizedStrings["Call Stack"] = "Call Stack";
    6264localizedStrings["Calls"] = "Calls";
     65localizedStrings["Canvas Profile %d"] = "Canvas Profile %d";
     66localizedStrings["Canvas profiles allow you to examine drawing operations on canvas elements."] = "Canvas profiles allow you to examine drawing operations on canvas elements.";
    6367localizedStrings["Capturing"] = "Capturing";
    6468localizedStrings["Catch Variables"] = "Catch Variables";
     
    7377localizedStrings["Collapse columns"] = "Collapse columns";
    7478localizedStrings["Collect CSS Selector Profile"] = "Collect CSS Selector Profile";
     79localizedStrings["Collect Canvas Profile"] = "Collect Canvas Profile";
    7580localizedStrings["Collect JavaScript Profile"] = "Collect JavaScript Profile";
    7681localizedStrings["Comment"] = "Comment";
     
    281286localizedStrings["Recording"] = "Recording";
    282287localizedStrings["Recording CSS Selector Profile\u2026"] = "Recording CSS Selector Profile\u2026";
     288localizedStrings["Recording Canvas Profile\u2026"] = "Recording Canvas Profile\u2026";
    283289localizedStrings["Recording JavaScript Profile\u2026"] = "Recording JavaScript Profile\u2026";
    284290localizedStrings["Recording\u2026"] = "Recording\u2026";
     
    336342localizedStrings["Start CSS Selector Profile"] = "Start CSS Selector Profile";
    337343localizedStrings["Start CSS selector profiling."] = "Start CSS selector profiling.";
     344localizedStrings["Start Canvas Profile"] = "Start Canvas Profile";
     345localizedStrings["Start Canvas profiling."] = "Start Canvas profiling.";
    338346localizedStrings["Start JavaScript Profile"] = "Start JavaScript Profile";
    339347localizedStrings["Start JavaScript profiling."] = "Start JavaScript profiling.";
     
    346354localizedStrings["Step over (%s or %s)"] = "Step over (%s or %s)";
    347355localizedStrings["Stop CSS selector profiling."] = "Stop CSS selector profiling.";
     356localizedStrings["Stop Canvas profiling."] = "Stop Canvas profiling.";
    348357localizedStrings["Stop JavaScript profiling."] = "Stop JavaScript profiling.";
    349358localizedStrings["Stop Profiling"] = "Stop Profiling";
  • trunk/Source/WebInspectorUI/UserInterface/ContentView.js

    r151453 r153928  
    6666        if (representedObject instanceof WebInspector.JavaScriptProfileObject)
    6767            return new WebInspector.JavaScriptProfileView(representedObject);
    68        
     68
    6969        if (representedObject instanceof WebInspector.CSSSelectorProfileObject)
    7070            return new WebInspector.CSSSelectorProfileView(representedObject);
     71
     72        if (representedObject instanceof WebInspector.CanvasProfileObject)
     73            return new WebInspector.CanvasProfileView(representedObject);
    7174
    7275        if (typeof representedObject === "string" || representedObject instanceof String)
     
    121124        return true;
    122125    if (representedObject instanceof WebInspector.CSSSelectorProfileObject)
     126        return true;
     127    if (representedObject instanceof WebInspector.CanvasProfileObject)
    123128        return true;
    124129    if (typeof representedObject === "string" || representedObject instanceof String)
  • trunk/Source/WebInspectorUI/UserInterface/InstrumentSidebarPanel.js

    r153894 r153928  
    106106    startCSSSelectorProfileOption.value = WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue;
    107107    startCSSSelectorProfileOption.selected = false;
    108    
     108
     109    var startCanvasProfileOption = document.createElement("option");
     110    startCanvasProfileOption.textContent = WebInspector.UIString("Start Canvas Profile");
     111    startCanvasProfileOption.value = WebInspector.InstrumentSidebarPanel.StartCanvasProfileValue;
     112    startCanvasProfileOption.selected = false;
     113
    109114    this._recordProfileGlyphElement.add(startJavaScriptProfileOption);
    110115    this._recordProfileGlyphElement.add(startCSSSelectorProfileOption);
     116    this._recordProfileGlyphElement.add(startCanvasProfileOption);
    111117
    112118    profilesTitleBarElement.appendChild(this._recordProfileGlyphElement);
     
    153159WebInspector.InstrumentSidebarPanel.StartJavaScriptProfileValue = "start-javascript-profile";
    154160WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue = "start-css-selector-profile";
     161WebInspector.InstrumentSidebarPanel.StartCanvasProfileValue = "start-canvas-profile";
    155162
    156163WebInspector.InstrumentSidebarPanel.prototype = {
     
    278285        this._recordProfileGlyphElement.classList.remove(WebInspector.InstrumentSidebarPanel.RecordGlyphRecordingForcedStyleClass);
    279286
    280         if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors())
     287        if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors() || WebInspector.profileManager.isProfilingCanvas())
    281288            this._recordProfileStatusElement.textContent = WebInspector.UIString("Stop Profiling");
    282289        else
     
    301308        // We don't want to show the select if the user is currently profiling. In that case,
    302309        // the user should just be able to click the record button to stop profiling.
    303         if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors())
     310        if (WebInspector.profileManager.isProfilingJavaScript() || WebInspector.profileManager.isProfilingCSSSelectors() || WebInspector.profileManager.isProfilingCanvas())
    304311            event.preventDefault();
    305312        else {
     
    325332        if (WebInspector.profileManager.isProfilingCSSSelectors())
    326333            WebInspector.profileManager.stopProfilingCSSSelectors();
     334        if (WebInspector.profileManager.isProfilingCanvas())
     335            WebInspector.profileManager.stopProfilingCanvas();
    327336    },
    328337
     
    332341        if (selectedIndex === -1)
    333342            return;
    334        
     343
    335344        var selectedValue = this._recordProfileGlyphElement.options[selectedIndex].value;
    336345        if (selectedValue === WebInspector.InstrumentSidebarPanel.StartJavaScriptProfileValue)
    337346            WebInspector.profileManager.startProfilingJavaScript();
     347        else if (selectedValue === WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue)
     348            WebInspector.profileManager.startProfilingCSSSelectors();
    338349        else {
    339             console.assert(selectedValue === WebInspector.InstrumentSidebarPanel.StartCSSSelectorProfileValue);
    340             WebInspector.profileManager.startProfilingCSSSelectors();
    341         }
    342        
     350            console.assert(selectedValue === WebInspector.InstrumentSidebarPanel.StartCanvasProfileValue);
     351            WebInspector.profileManager.startProfilingCanvas();
     352        }
    343353    },
    344354
     
    479489        WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.JavaScriptProfileView);
    480490        WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.CSSSelectorProfileView);
     491        WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.CanvasProfileView);
    481492       
    482493        this.updateEmptyContentPlaceholder(WebInspector.UIString("No Recorded Profiles"));
  • trunk/Source/WebInspectorUI/UserInterface/Main.html

    r153087 r153928  
    336336    <script src="CSSSelectorProfileType.js"></script>
    337337    <script src="CSSSelectorProfileView.js"></script>
     338    <script src="CanvasDataGridNode.js"></script>
     339    <script src="CanvasProfileType.js"></script>
     340    <script src="CanvasProfileView.js"></script>
    338341    <script src="ProfileObject.js"></script>
    339342    <script src="JavaScriptProfileObject.js"></script>
    340343    <script src="CSSSelectorProfileObject.js"></script>
     344    <script src="CanvasProfileObject.js"></script>
    341345    <script src="DebuggerSidebarPanel.js"></script>
    342346    <script src="BreakpointTreeElement.js"></script>
  • trunk/Source/WebInspectorUI/UserInterface/ProfileManager.js

    r151453 r153928  
    3030    this._javaScriptProfileType = new WebInspector.JavaScriptProfileType;
    3131    this._cssSelectorProfileType = new WebInspector.CSSSelectorProfileType;
     32    this._canvasProfileType = new WebInspector.CanvasProfileType;
    3233
    3334    ProfilerAgent.enable();
     
    6162        this._recordingJavaScriptProfile = null;
    6263        this._recordingCSSSelectorProfile = null;
     64        this._recordingCanvasProfile = null;
    6365
    6466        this._isProfiling = false;
     
    121123
    122124        this._cssSelectorProfileType.stopRecordingProfile(cssProfilingStopped.bind(this));
     125    },
     126
     127    isProfilingCanvas: function()
     128    {
     129        return this._canvasProfileType.isRecordingProfile();
     130    },
     131
     132    startProfilingCanvas: function()
     133    {
     134        this._canvasProfileType.startRecordingProfile();
     135
     136        var id = this._canvasProfileType.nextProfileId();
     137        this._recordingCanvasProfile = new WebInspector.CanvasProfileObject(WebInspector.UIString("Canvas Profile %d").format(id), id, true);
     138        this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfileWasAdded, {profile: this._recordingCanvasProfile});
     139
     140        this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfilingStarted);
     141    },
     142
     143    stopProfilingCanvas: function()
     144    {
     145        function canvasProfilingStopped(error, profile)
     146        {
     147            if (error)
     148                return;
     149
     150            console.assert(this._recordingCanvasProfile);
     151
     152            this._recordingCanvasProfile.data = profile.data;
     153            this._recordingCanvasProfile.recording = false;
     154
     155            this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfileWasUpdated, {profile: this._recordingCanvasProfile});
     156            this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfilingEnded, {profile: this._recordingCanvasProfile});
     157
     158            this._recordingCanvasProfile = null;
     159        }
     160
     161        this._canvasProfileType.stopRecordingProfile(canvasProfilingStopped.bind(this));
    123162    },
    124163
     
    212251            this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfilingInterrupted, {profile: this._recordingCSSSelectorProfile});
    213252            this._cssSelectorProfileType.setRecordingProfile(false);
     253        } else if (this._recordingCanvasProfile) {
     254            this.dispatchEventToListeners(WebInspector.ProfileManager.Event.ProfilingInterrupted, {profile: this._recordingCanvasProfile});
     255            this._canvasProfileType.setRecordingProfile(false);
    214256        }
    215257    },
     
    223265        else if (this._recordingCSSSelectorProfile)
    224266            this.startProfilingCSSSelectors();
     267        else if (this._recordingCanvasProfile)
     268            this.startProfilingCanvas();
    225269    }
    226270};
Note: See TracChangeset for help on using the changeset viewer.