Changeset 102906 in webkit


Ignore:
Timestamp:
Dec 15, 2011 1:37:32 AM (12 years ago)
Author:
apavlov@chromium.org
Message:

Web Inspector: make ProfilesPanel scale as the number of ProfileTypes grows
https://bugs.webkit.org/show_bug.cgi?id=74391

Reviewed by Pavel Feldman.

Whenever a profile is started, this change disables all profile recording buttons, except the one
that correponds to the running profile. Once the profiling is finished, all buttons get enabled back again.

  • English.lproj/localizedStrings.js:
  • inspector/front-end/ProfileView.js:

(WebInspector.CPUProfileView.profileCallback):
(WebInspector.CPUProfileType.prototype.get buttonTooltip):
(WebInspector.CPUProfileType.prototype.get buttonStyle):
(WebInspector.CPUProfileType.prototype.buttonClicked):

  • inspector/front-end/ProfilesPanel.js:

(WebInspector.ProfilesPanel.prototype.get statusBarItems.clickHandler):
(WebInspector.ProfilesPanel.prototype.get statusBarItems):
(WebInspector.ProfilesPanel.prototype._addProfileHeader):
(WebInspector.ProfilesPanel.prototype.updateProfileTypeButtons):
(WebInspector.ProfilesPanel.prototype._updateInterface):
(WebInspector.ProfilesPanel.prototype.setRecordingProfile):
(WebInspector.ProfilesPanel.prototype.takeHeapSnapshot):
(WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
(WebInspector.ProfilerDispatcher.prototype.setRecordingProfile):

  • inspector/front-end/inspector.css:

(.record-cpu-profile-status-bar-item .glyph):
(.record-cpu-profile-status-bar-item.toggled-on .glyph):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102903 r102906  
     12011-12-14  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Web Inspector: make ProfilesPanel scale as the number of ProfileTypes grows
     4        https://bugs.webkit.org/show_bug.cgi?id=74391
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Whenever a profile is started, this change disables all profile recording buttons, except the one
     9        that correponds to the running profile. Once the profiling is finished, all buttons get enabled back again.
     10
     11        * English.lproj/localizedStrings.js:
     12        * inspector/front-end/ProfileView.js:
     13        (WebInspector.CPUProfileView.profileCallback):
     14        (WebInspector.CPUProfileType.prototype.get buttonTooltip):
     15        (WebInspector.CPUProfileType.prototype.get buttonStyle):
     16        (WebInspector.CPUProfileType.prototype.buttonClicked):
     17        * inspector/front-end/ProfilesPanel.js:
     18        (WebInspector.ProfilesPanel.prototype.get statusBarItems.clickHandler):
     19        (WebInspector.ProfilesPanel.prototype.get statusBarItems):
     20        (WebInspector.ProfilesPanel.prototype._addProfileHeader):
     21        (WebInspector.ProfilesPanel.prototype.updateProfileTypeButtons):
     22        (WebInspector.ProfilesPanel.prototype._updateInterface):
     23        (WebInspector.ProfilesPanel.prototype.setRecordingProfile):
     24        (WebInspector.ProfilesPanel.prototype.takeHeapSnapshot):
     25        (WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
     26        (WebInspector.ProfilerDispatcher.prototype.setRecordingProfile):
     27        * inspector/front-end/inspector.css:
     28        (.record-cpu-profile-status-bar-item .glyph):
     29        (.record-cpu-profile-status-bar-item.toggled-on .glyph):
     30
    1312011-12-15  Alexander Pavlov  <apavlov@chromium.org>
    232
  • trunk/Source/WebCore/inspector/front-end/ProfileView.js

    r102803 r102906  
    8686        if (error)
    8787            return;
     88
     89        if (!profile.head) {
     90            // Profiling was tentatively terminated with the "Clear all profiles." button.
     91            return;
     92        }
    8893        this.profile.head = profile.head;
    8994        this._assignParentsInProfile();
     
    575580    get buttonTooltip()
    576581    {
    577         return this._recording ? WebInspector.UIString("Stop profiling.") : WebInspector.UIString("Start profiling.");
     582        return this._recording ? WebInspector.UIString("Stop CPU profiling.") : WebInspector.UIString("Start CPU profiling.");
    578583    },
    579584
    580585    get buttonStyle()
    581586    {
    582         return this._recording ? "record-profile-status-bar-item status-bar-item toggled-on" : "record-profile-status-bar-item status-bar-item";
     587        return this._recording ? "record-cpu-profile-status-bar-item status-bar-item toggled-on" : "record-cpu-profile-status-bar-item status-bar-item";
    583588    },
    584589
    585590    buttonClicked: function()
    586591    {
    587         this._recording = !this._recording;
    588 
    589592        if (this._recording) {
     593            this.stopRecordingProfile();
     594            WebInspector.networkManager.enableResourceTracking();
     595        } else
    590596            WebInspector.networkManager.disableResourceTracking();
    591             ProfilerAgent.start();
    592         } else {
    593             ProfilerAgent.stop();
    594             WebInspector.networkManager.enableResourceTracking();
     597            this.startRecordingProfile();
    595598        }
    596599    },
  • trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js

    r101651 r102906  
    153153    get statusBarItems()
    154154    {
    155         function clickHandler(profileType, buttonElement)
     155        function clickHandler(profileType, button)
    156156        {
     157            var wasProfiling = button.toggled;
    157158            profileType.buttonClicked.call(profileType);
    158             this.updateProfileTypeButtons();
     159            this.updateProfileTypeButtons(!wasProfiling, button);
    159160        }
    160161
     
    164165            var profileType = this.getProfileType(typeId);
    165166            if (profileType.buttonStyle) {
    166                 var button = new WebInspector.StatusBarButton(profileType.buttonTooltip, profileType.buttonStyle, profileType.buttonCaption);
    167                 this._profileTypeButtonsByIdMap[typeId] = button.element;
    168                 button.element.addEventListener("click", clickHandler.bind(this, profileType, button.element), false);
     167                var button = new WebInspector.StatusBarButton(profileType.buttonTooltip, profileType.buttonStyle);
     168                this._profileTypeButtonsByIdMap[typeId] = button;
     169                button.element.addEventListener("click", clickHandler.bind(this, profileType, button), false);
    169170                items.push(button.element);
    170171            }
     
    287288    _addProfileHeader: function(profile)
    288289    {
    289         if (this.hasTemporaryProfile(profile.typeId)) {
    290             if (profile.typeId === WebInspector.CPUProfileType.TypeId)
    291                 this._removeProfileHeader(this._temporaryRecordingProfile);
    292             else
    293                 this._removeProfileHeader(this._temporaryTakingSnapshot);
    294         }
     290        if (this.hasTemporaryProfile(profile.typeId))
     291            this._removeProfileHeader(this._temporaryRecordingProfile);
    295292
    296293        var typeId = profile.typeId;
     
    353350                this.showProfile(profile);
    354351            this.dispatchEventToListeners("profile added");
     352            this.updateProfileTypeButtons(false, this._profileTypeButtonsByIdMap[typeId]);
    355353        }
    356354    },
     
    506504    },
    507505
    508     updateProfileTypeButtons: function()
     506    /**
     507     * @param {boolean} isProfiling
     508     * @param {WebInspector.StatusBarButton=} effectButton
     509     */
     510    updateProfileTypeButtons: function(isProfiling, effectButton)
    509511    {
    510512        for (var typeId in this._profileTypeButtonsByIdMap) {
    511             var buttonElement = this._profileTypeButtonsByIdMap[typeId];
     513            var button = this._profileTypeButtonsByIdMap[typeId];
    512514            var profileType = this.getProfileType(typeId);
    513             buttonElement.className = profileType.buttonStyle;
    514             buttonElement.title = profileType.buttonTooltip;
     515            button.element.className = profileType.buttonStyle;
     516            button.element.title = profileType.buttonTooltip;
    515517            // FIXME: Apply profileType.buttonCaption once captions are added to button controls.
     518            if (!isProfiling)
     519                button.disabled = false;
     520            else {
     521                if (effectButton && button !== effectButton)
     522                    button.disabled = true;
     523            }
    516524        }
    517525    },
     
    753761            this.enableToggleButton.toggled = true;
    754762            for (var typeId in this._profileTypeButtonsByIdMap)
    755                 this._profileTypeButtonsByIdMap[typeId].removeStyleClass("hidden");
     763                this._profileTypeButtonsByIdMap[typeId].visible = true;
    756764            this.profileViewStatusBarItemsContainer.removeStyleClass("hidden");
    757765            this.clearResultsButton.element.removeStyleClass("hidden");
     
    761769            this.enableToggleButton.toggled = false;
    762770            for (var typeId in this._profileTypeButtonsByIdMap)
    763                 this._profileTypeButtonsByIdMap[typeId].addStyleClass("hidden");
     771                this._profileTypeButtonsByIdMap[typeId].visible = false;
    764772            this.profileViewStatusBarItemsContainer.addStyleClass("hidden");
    765773            this.clearResultsButton.element.addStyleClass("hidden");
     
    825833    },
    826834
    827     _setRecordingProfile: function(isProfiling)
    828     {
    829         this.getProfileType(WebInspector.CPUProfileType.TypeId).setRecordingProfile(isProfiling);
    830         if (this.hasTemporaryProfile(WebInspector.CPUProfileType.TypeId) !== isProfiling) {
     835    setRecordingProfile: function(profileType, isProfiling)
     836    {
     837        this.getProfileType(profileType).setRecordingProfile(isProfiling);
     838        if (this.hasTemporaryProfile(profileType) !== isProfiling) {
    831839            if (!this._temporaryRecordingProfile) {
    832840                this._temporaryRecordingProfile = {
    833                     typeId: WebInspector.CPUProfileType.TypeId,
    834                     title: WebInspector.UIString("Recording"),
     841                    typeId: profileType,
     842                    title: WebInspector.UIString("Recording\u2026"),
    835843                    uid: -1,
    836844                    isTemporary: true
     
    839847            if (isProfiling) {
    840848                this._addProfileHeader(this._temporaryRecordingProfile);
    841                 WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
    842             } else
     849                if (profileType === WebInspector.CPUProfileType.TypeId)
     850                    WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
     851            } else {
    843852                this._removeProfileHeader(this._temporaryRecordingProfile);
    844         }
    845         this.updateProfileTypeButtons();
     853                delete this._temporaryRecordingProfile;
     854            }
     855        }
    846856    },
    847857
     
    849859    {
    850860        if (!this.hasTemporaryProfile(WebInspector.DetailedHeapshotProfileType.TypeId)) {
    851             if (!this._temporaryTakingSnapshot) {
    852                 this._temporaryTakingSnapshot = {
     861            if (!this._temporaryRecordingProfile) {
     862                this._temporaryRecordingProfile = {
    853863                    typeId: WebInspector.DetailedHeapshotProfileType.TypeId,
    854                     title: WebInspector.UIString("Snapshotting"),
     864                    title: WebInspector.UIString("Snapshotting\u2026"),
    855865                    uid: -1,
    856866                    isTemporary: true
    857867                };
    858868            }
    859             this._addProfileHeader(this._temporaryTakingSnapshot);
     869            this._addProfileHeader(this._temporaryRecordingProfile);
    860870        }
    861871        ProfilerAgent.takeHeapSnapshot();
     
    866876    {
    867877        if (this.hasTemporaryProfile(WebInspector.DetailedHeapshotProfileType.TypeId)) {
    868             this._temporaryTakingSnapshot.sidebarElement.subtitle = WebInspector.UIString("%.2f%%", (done / total) * 100);
    869             this._temporaryTakingSnapshot.sidebarElement.wait = true;
     878            this._temporaryRecordingProfile.sidebarElement.subtitle = WebInspector.UIString("%.2f%%", (done / total) * 100);
     879            this._temporaryRecordingProfile.sidebarElement.wait = true;
    870880            if (done >= total)
    871                 this._removeProfileHeader(this._temporaryTakingSnapshot);
     881                this._removeProfileHeader(this._temporaryRecordingProfile);
    872882        }
    873883    }
     
    905915    setRecordingProfile: function(isProfiling)
    906916    {
    907         this._profiler._setRecordingProfile(isProfiling);
     917        this._profiler.setRecordingProfile(WebInspector.CPUProfileType.TypeId, isProfiling);
    908918    },
    909919
  • trunk/Source/WebCore/inspector/front-end/inspector.css

    r102671 r102906  
    25082508}
    25092509
    2510 .record-profile-status-bar-item .glyph {
     2510.record-cpu-profile-status-bar-item .glyph {
    25112511    -webkit-mask-position: -288px 0;
    25122512}
    25132513
    2514 .record-profile-status-bar-item.toggled-on .glyph {
     2514.record-cpu-profile-status-bar-item.toggled-on .glyph {
    25152515    -webkit-mask-position: -288px -24px;
    25162516    background-color: rgb(216, 0, 0) !important;
Note: See TracChangeset for help on using the changeset viewer.