Changeset 141250 in webkit


Ignore:
Timestamp:
Jan 30, 2013 4:01:07 AM (11 years ago)
Author:
aandrey@chromium.org
Message:

Web Inspector: [Canvas] support instrumenting canvases in iframes (frontend side)
https://bugs.webkit.org/show_bug.cgi?id=108319

Reviewed by Pavel Feldman.

Add a frame selector to choose between frames with canvases. Show this selector in the status
bar only if there are 2 or more frames with canvses. Otherwise, assume silently the only
frame with canvases (most common use case).

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

(WebInspector.CanvasProfileType):
(WebInspector.CanvasProfileType.prototype.get statusBarItems):
(WebInspector.CanvasProfileType.prototype._runSingleFrameCapturing):
(WebInspector.CanvasProfileType.prototype._startFrameCapturing):
(WebInspector.CanvasProfileType.prototype._frameAdded):
(WebInspector.CanvasProfileType.prototype._addFrame):
(WebInspector.CanvasProfileType.prototype._frameRemoved):
(WebInspector.CanvasProfileType.prototype._contextCreated):
(WebInspector.CanvasProfileType.prototype._selectedFrameId):
(WebInspector.CanvasProfileType.prototype._dispatchViewUpdatedEvent):
(WebInspector.CanvasDispatcher):
(WebInspector.CanvasDispatcher.prototype.contextCreated):

  • inspector/front-end/ProfilesPanel.js:

(WebInspector.ProfileType.prototype.createProfile):
(WebInspector.ProfilesPanel.prototype._onProfileTypeSelected):
(WebInspector.ProfilesPanel.prototype._updateProfileTypeSpecificUI):
(WebInspector.ProfilesPanel.prototype._registerProfileType):

  • inspector/front-end/StatusBarButton.js:

(WebInspector.StatusBarComboBox.prototype.size):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141249 r141250  
     12013-01-30  Andrey Adaikin  <aandrey@chromium.org>
     2
     3        Web Inspector: [Canvas] support instrumenting canvases in iframes (frontend side)
     4        https://bugs.webkit.org/show_bug.cgi?id=108319
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Add a frame selector to choose between frames with canvases. Show this selector in the status
     9        bar only if there are 2 or more frames with canvses. Otherwise, assume silently the only
     10        frame with canvases (most common use case).
     11
     12        * English.lproj/localizedStrings.js:
     13        * inspector/front-end/CanvasProfileView.js:
     14        (WebInspector.CanvasProfileType):
     15        (WebInspector.CanvasProfileType.prototype.get statusBarItems):
     16        (WebInspector.CanvasProfileType.prototype._runSingleFrameCapturing):
     17        (WebInspector.CanvasProfileType.prototype._startFrameCapturing):
     18        (WebInspector.CanvasProfileType.prototype._frameAdded):
     19        (WebInspector.CanvasProfileType.prototype._addFrame):
     20        (WebInspector.CanvasProfileType.prototype._frameRemoved):
     21        (WebInspector.CanvasProfileType.prototype._contextCreated):
     22        (WebInspector.CanvasProfileType.prototype._selectedFrameId):
     23        (WebInspector.CanvasProfileType.prototype._dispatchViewUpdatedEvent):
     24        (WebInspector.CanvasDispatcher):
     25        (WebInspector.CanvasDispatcher.prototype.contextCreated):
     26        * inspector/front-end/ProfilesPanel.js:
     27        (WebInspector.ProfileType.prototype.createProfile):
     28        (WebInspector.ProfilesPanel.prototype._onProfileTypeSelected):
     29        (WebInspector.ProfilesPanel.prototype._updateProfileTypeSpecificUI):
     30        (WebInspector.ProfilesPanel.prototype._registerProfileType):
     31        * inspector/front-end/StatusBarButton.js:
     32        (WebInspector.StatusBarComboBox.prototype.size):
     33
    1342013-01-30  Vladislav Kaznacheev  <kaznacheev@chromium.org>
    235
  • trunk/Source/WebCore/English.lproj/localizedStrings.js

    r140813 r141250  
    779779localizedStrings["Stop capturing canvas frames."] = "Stop capturing canvas frames.";
    780780localizedStrings["Start capturing canvas frames."] = "Start capturing canvas frames.";
     781localizedStrings["Canvas capture mode"] = "Canvas capture mode";
     782localizedStrings["Single Frame"] = "Single Frame";
     783localizedStrings["Capture a single canvas frame."] = "Capture a single canvas frame.";
     784localizedStrings["Consecutive Frames"] = "Consecutive Frames";
     785localizedStrings["Capture consecutive canvas frames."] = "Capture consecutive canvas frames.";
     786localizedStrings["Frame containing the canvases to capture."] = "Frame containing the canvases to capture.";
    781787localizedStrings["Trace Log %d"] = "Trace Log %d";
    782788localizedStrings["CANVAS PROFILE"] = "CANVAS PROFILE";
  • trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js

    r140678 r141250  
    381381    this._lastProfileHeader = null;
    382382
    383     this._capturingModeSelector = new WebInspector.StatusBarComboBox(null);
     383    this._capturingModeSelector = new WebInspector.StatusBarComboBox(this._dispatchViewUpdatedEvent.bind(this));
    384384    this._capturingModeSelector.element.title = WebInspector.UIString("Canvas capture mode.");
    385385    this._capturingModeSelector.createOption(WebInspector.UIString("Single Frame"), WebInspector.UIString("Capture a single canvas frame."), "");
    386386    this._capturingModeSelector.createOption(WebInspector.UIString("Consecutive Frames"), WebInspector.UIString("Capture consecutive canvas frames."), "1");
     387
     388    /** @type {!Object.<string, Element>} */
     389    this._frameOptions = {};
     390
     391    /** @type {!Object.<string, boolean>} */
     392    this._framesWithCanvases = {};
     393
     394    this._frameSelector = new WebInspector.StatusBarComboBox(this._dispatchViewUpdatedEvent.bind(this));
     395    this._frameSelector.element.title = WebInspector.UIString("Frame containing the canvases to capture.");
     396    this._frameSelector.element.addStyleClass("hidden");
     397    WebInspector.runtimeModel.contextLists().forEach(this._addFrame, this);
     398    WebInspector.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.FrameExecutionContextListAdded, this._frameAdded, this);
     399    WebInspector.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.FrameExecutionContextListRemoved, this._frameRemoved, this);
    387400
    388401    this._decorationElement = document.createElement("div");
     
    395408    reloadPageButton.addEventListener("click", this._onReloadPageButtonClick.bind(this), false);
    396409
     410    this._dispatcher = new WebInspector.CanvasDispatcher(this);
     411
    397412    // FIXME: enable/disable by a UI action?
    398413    CanvasAgent.enable(this._updateDecorationElement.bind(this));
     
    405420    get statusBarItems()
    406421    {
    407         return [this._capturingModeSelector.element];
     422        return [this._capturingModeSelector.element, this._frameSelector.element];
    408423    },
    409424
     
    442457    _runSingleFrameCapturing: function(profilesPanel)
    443458    {
    444         CanvasAgent.captureFrame(this._didStartCapturingFrame.bind(this, profilesPanel));
     459        CanvasAgent.captureFrame(this._selectedFrameId(), this._didStartCapturingFrame.bind(this, profilesPanel));
    445460    },
    446461
     
    450465    _startFrameCapturing: function(profilesPanel)
    451466    {
    452         CanvasAgent.startCapturing(this._didStartCapturingFrame.bind(this, profilesPanel));
     467        CanvasAgent.startCapturing(this._selectedFrameId(), this._didStartCapturingFrame.bind(this, profilesPanel));
    453468    },
    454469
     
    566581    },
    567582
     583    /**
     584     * @param {WebInspector.Event} event
     585     */
     586    _frameAdded: function(event)
     587    {
     588        var contextList = /** @type {WebInspector.FrameExecutionContextList} */ (event.data);
     589        this._addFrame(contextList);
     590    },
     591
     592    /**
     593     * @param {WebInspector.FrameExecutionContextList} contextList
     594     */
     595    _addFrame: function(contextList)
     596    {
     597        var frameId = contextList.frameId;
     598        var option = document.createElement("option");
     599        option.text = contextList.displayName;
     600        option.title = contextList.url;
     601        option.value = frameId;
     602
     603        this._frameOptions[frameId] = option;
     604
     605        if (this._framesWithCanvases[frameId]) {
     606            this._frameSelector.addOption(option);
     607            this._dispatchViewUpdatedEvent();
     608        }
     609    },
     610
     611    /**
     612     * @param {WebInspector.Event} event
     613     */
     614    _frameRemoved: function(event)
     615    {
     616        var contextList = /** @type {WebInspector.FrameExecutionContextList} */ (event.data);
     617        var frameId = contextList.frameId;
     618        var option = this._frameOptions[frameId];
     619        if (option && this._framesWithCanvases[frameId]) {
     620            this._frameSelector.removeOption(option);
     621            this._dispatchViewUpdatedEvent();
     622        }
     623        delete this._frameOptions[frameId];
     624        delete this._framesWithCanvases[frameId];
     625    },
     626
     627    /**
     628     * @param {string} frameId
     629     */
     630    _contextCreated: function(frameId)
     631    {
     632        if (this._framesWithCanvases[frameId])
     633            return;
     634        this._framesWithCanvases[frameId] = true;
     635        var option = this._frameOptions[frameId];
     636        if (option) {
     637            this._frameSelector.addOption(option);
     638            this._dispatchViewUpdatedEvent();
     639        }
     640    },
     641
     642    /**
     643     * @return {string|undefined}
     644     */
     645    _selectedFrameId: function()
     646    {
     647        var option = this._frameSelector.selectedOption();
     648        return option ? option.value : undefined;
     649    },
     650
     651    _dispatchViewUpdatedEvent: function()
     652    {
     653        this._frameSelector.element.enableStyleClass("hidden", this._frameSelector.size() <= 1);
     654        this.dispatchEventToListeners(WebInspector.ProfileType.Events.ViewUpdated);
     655    },
     656
    568657    __proto__: WebInspector.ProfileType.prototype
     658}
     659
     660/**
     661 * @constructor
     662 * @implements {CanvasAgent.Dispatcher}
     663 * @param {WebInspector.CanvasProfileType} profileType
     664 */
     665WebInspector.CanvasDispatcher = function(profileType)
     666{
     667    this._profileType = profileType;
     668    InspectorBackend.registerCanvasDispatcher(this);
     669}
     670
     671WebInspector.CanvasDispatcher.prototype = {
     672    /**
     673     * @param {string} frameId
     674     */
     675    contextCreated: function(frameId)
     676    {
     677        this._profileType._contextCreated(frameId);
     678    }
    569679}
    570680
  • trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js

    r140678 r141250  
    2828/**
    2929 * @constructor
     30 * @extends {WebInspector.Object}
    3031 * @param {string} id
    3132 * @param {string} name
     
    4142}
    4243
     44WebInspector.ProfileType.Events = {
     45  ViewUpdated: "view-updated",
     46}
     47
    4348WebInspector.ProfileType.prototype = {
    4449    get statusBarItems()
     
    110115    {
    111116        throw new Error("Not supported for " + this._name + " profiles.");
    112     }
     117    },
     118
     119    __proto__: WebInspector.Object.prototype
    113120}
    114121
     
    367374    {
    368375        this._selectedProfileType = /** @type {!WebInspector.ProfileType} */ (event.data);
     376        this._updateProfileTypeSpecificUI();
     377    },
     378
     379    _updateProfileTypeSpecificUI: function()
     380    {
    369381        this.recordButton.title = this._selectedProfileType.buttonTooltip;
    370382
     
    455467        this.sidebarTree.appendChild(profileType.treeElement);
    456468        profileType.treeElement.childrenListElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
     469        profileType.addEventListener(WebInspector.ProfileType.Events.ViewUpdated, this._updateProfileTypeSpecificUI, this);
    457470    },
    458471
  • trunk/Source/WebCore/inspector/front-end/StatusBarButton.js

    r139972 r141250  
    290290WebInspector.StatusBarComboBox.prototype = {
    291291    /**
     292     * @return {number}
     293     */
     294    size: function()
     295    {
     296        return this._selectElement.childElementCount;
     297    },
     298
     299    /**
    292300     * @param {!Element} option
    293301     */
Note: See TracChangeset for help on using the changeset viewer.