Modified: trunk/Source/WebCore/ChangeLog (141249 => 141250)
--- trunk/Source/WebCore/ChangeLog 2013-01-30 11:59:44 UTC (rev 141249)
+++ trunk/Source/WebCore/ChangeLog 2013-01-30 12:01:07 UTC (rev 141250)
@@ -1,3 +1,36 @@
+2013-01-30 Andrey Adaikin <aand...@chromium.org>
+
+ 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):
+
2013-01-30 Vladislav Kaznacheev <kaznach...@chromium.org>
Web Inspector: Change the Elements panel sidebar layout based on its aspect ratio.
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js (141249 => 141250)
--- trunk/Source/WebCore/English.lproj/localizedStrings.js 2013-01-30 11:59:44 UTC (rev 141249)
+++ trunk/Source/WebCore/English.lproj/localizedStrings.js 2013-01-30 12:01:07 UTC (rev 141250)
@@ -778,6 +778,12 @@
localizedStrings["Capture next canvas frame."] = "Capture next canvas frame.";
localizedStrings["Stop capturing canvas frames."] = "Stop capturing canvas frames.";
localizedStrings["Start capturing canvas frames."] = "Start capturing canvas frames.";
+localizedStrings["Canvas capture mode"] = "Canvas capture mode";
+localizedStrings["Single Frame"] = "Single Frame";
+localizedStrings["Capture a single canvas frame."] = "Capture a single canvas frame.";
+localizedStrings["Consecutive Frames"] = "Consecutive Frames";
+localizedStrings["Capture consecutive canvas frames."] = "Capture consecutive canvas frames.";
+localizedStrings["Frame containing the canvases to capture."] = "Frame containing the canvases to capture.";
localizedStrings["Trace Log %d"] = "Trace Log %d";
localizedStrings["CANVAS PROFILE"] = "CANVAS PROFILE";
localizedStrings["Canvas calls instrumentation"] = "Canvas calls instrumentation";
Modified: trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js (141249 => 141250)
--- trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js 2013-01-30 11:59:44 UTC (rev 141249)
+++ trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js 2013-01-30 12:01:07 UTC (rev 141250)
@@ -380,11 +380,24 @@
this._recording = false;
this._lastProfileHeader = null;
- this._capturingModeSelector = new WebInspector.StatusBarComboBox(null);
+ this._capturingModeSelector = new WebInspector.StatusBarComboBox(this._dispatchViewUpdatedEvent.bind(this));
this._capturingModeSelector.element.title = WebInspector.UIString("Canvas capture mode.");
this._capturingModeSelector.createOption(WebInspector.UIString("Single Frame"), WebInspector.UIString("Capture a single canvas frame."), "");
this._capturingModeSelector.createOption(WebInspector.UIString("Consecutive Frames"), WebInspector.UIString("Capture consecutive canvas frames."), "1");
+ /** @type {!Object.<string, Element>} */
+ this._frameOptions = {};
+
+ /** @type {!Object.<string, boolean>} */
+ this._framesWithCanvases = {};
+
+ this._frameSelector = new WebInspector.StatusBarComboBox(this._dispatchViewUpdatedEvent.bind(this));
+ this._frameSelector.element.title = WebInspector.UIString("Frame containing the canvases to capture.");
+ this._frameSelector.element.addStyleClass("hidden");
+ WebInspector.runtimeModel.contextLists().forEach(this._addFrame, this);
+ WebInspector.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.FrameExecutionContextListAdded, this._frameAdded, this);
+ WebInspector.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.FrameExecutionContextListRemoved, this._frameRemoved, this);
+
this._decorationElement = document.createElement("div");
this._decorationElement.addStyleClass("profile-canvas-decoration");
this._decorationElement.addStyleClass("hidden");
@@ -394,6 +407,8 @@
reloadPageButton.textContent = WebInspector.UIString("Reload");
reloadPageButton.addEventListener("click", this._onReloadPageButtonClick.bind(this), false);
+ this._dispatcher = new WebInspector.CanvasDispatcher(this);
+
// FIXME: enable/disable by a UI action?
CanvasAgent.enable(this._updateDecorationElement.bind(this));
WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._updateDecorationElement, this);
@@ -404,7 +419,7 @@
WebInspector.CanvasProfileType.prototype = {
get statusBarItems()
{
- return [this._capturingModeSelector.element];
+ return [this._capturingModeSelector.element, this._frameSelector.element];
},
get buttonTooltip()
@@ -441,7 +456,7 @@
*/
_runSingleFrameCapturing: function(profilesPanel)
{
- CanvasAgent.captureFrame(this._didStartCapturingFrame.bind(this, profilesPanel));
+ CanvasAgent.captureFrame(this._selectedFrameId(), this._didStartCapturingFrame.bind(this, profilesPanel));
},
/**
@@ -449,7 +464,7 @@
*/
_startFrameCapturing: function(profilesPanel)
{
- CanvasAgent.startCapturing(this._didStartCapturingFrame.bind(this, profilesPanel));
+ CanvasAgent.startCapturing(this._selectedFrameId(), this._didStartCapturingFrame.bind(this, profilesPanel));
},
_stopFrameCapturing: function()
@@ -565,11 +580,106 @@
return !this._capturingModeSelector.selectedOption().value;
},
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _frameAdded: function(event)
+ {
+ var contextList = /** @type {WebInspector.FrameExecutionContextList} */ (event.data);
+ this._addFrame(contextList);
+ },
+
+ /**
+ * @param {WebInspector.FrameExecutionContextList} contextList
+ */
+ _addFrame: function(contextList)
+ {
+ var frameId = contextList.frameId;
+ var option = document.createElement("option");
+ option.text = contextList.displayName;
+ option.title = contextList.url;
+ option.value = frameId;
+
+ this._frameOptions[frameId] = option;
+
+ if (this._framesWithCanvases[frameId]) {
+ this._frameSelector.addOption(option);
+ this._dispatchViewUpdatedEvent();
+ }
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _frameRemoved: function(event)
+ {
+ var contextList = /** @type {WebInspector.FrameExecutionContextList} */ (event.data);
+ var frameId = contextList.frameId;
+ var option = this._frameOptions[frameId];
+ if (option && this._framesWithCanvases[frameId]) {
+ this._frameSelector.removeOption(option);
+ this._dispatchViewUpdatedEvent();
+ }
+ delete this._frameOptions[frameId];
+ delete this._framesWithCanvases[frameId];
+ },
+
+ /**
+ * @param {string} frameId
+ */
+ _contextCreated: function(frameId)
+ {
+ if (this._framesWithCanvases[frameId])
+ return;
+ this._framesWithCanvases[frameId] = true;
+ var option = this._frameOptions[frameId];
+ if (option) {
+ this._frameSelector.addOption(option);
+ this._dispatchViewUpdatedEvent();
+ }
+ },
+
+ /**
+ * @return {string|undefined}
+ */
+ _selectedFrameId: function()
+ {
+ var option = this._frameSelector.selectedOption();
+ return option ? option.value : undefined;
+ },
+
+ _dispatchViewUpdatedEvent: function()
+ {
+ this._frameSelector.element.enableStyleClass("hidden", this._frameSelector.size() <= 1);
+ this.dispatchEventToListeners(WebInspector.ProfileType.Events.ViewUpdated);
+ },
+
__proto__: WebInspector.ProfileType.prototype
}
/**
* @constructor
+ * @implements {CanvasAgent.Dispatcher}
+ * @param {WebInspector.CanvasProfileType} profileType
+ */
+WebInspector.CanvasDispatcher = function(profileType)
+{
+ this._profileType = profileType;
+ InspectorBackend.registerCanvasDispatcher(this);
+}
+
+WebInspector.CanvasDispatcher.prototype = {
+ /**
+ * @param {string} frameId
+ */
+ contextCreated: function(frameId)
+ {
+ this._profileType._contextCreated(frameId);
+ }
+}
+
+/**
+ * @constructor
* @extends {WebInspector.ProfileHeader}
* @param {!WebInspector.CanvasProfileType} type
* @param {string} title
Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (141249 => 141250)
--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2013-01-30 11:59:44 UTC (rev 141249)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2013-01-30 12:01:07 UTC (rev 141250)
@@ -27,6 +27,7 @@
/**
* @constructor
+ * @extends {WebInspector.Object}
* @param {string} id
* @param {string} name
*/
@@ -40,6 +41,10 @@
this.treeElement = null;
}
+WebInspector.ProfileType.Events = {
+ ViewUpdated: "view-updated",
+}
+
WebInspector.ProfileType.prototype = {
get statusBarItems()
{
@@ -109,7 +114,9 @@
createProfile: function(profile)
{
throw new Error("Not supported for " + this._name + " profiles.");
- }
+ },
+
+ __proto__: WebInspector.Object.prototype
}
/**
@@ -366,6 +373,11 @@
_onProfileTypeSelected: function(event)
{
this._selectedProfileType = /** @type {!WebInspector.ProfileType} */ (event.data);
+ this._updateProfileTypeSpecificUI();
+ },
+
+ _updateProfileTypeSpecificUI: function()
+ {
this.recordButton.title = this._selectedProfileType.buttonTooltip;
this._profileTypeStatusBarItemsContainer.removeChildren();
@@ -454,6 +466,7 @@
profileType.treeElement.hidden = true;
this.sidebarTree.appendChild(profileType.treeElement);
profileType.treeElement.childrenListElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
+ profileType.addEventListener(WebInspector.ProfileType.Events.ViewUpdated, this._updateProfileTypeSpecificUI, this);
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/StatusBarButton.js (141249 => 141250)
--- trunk/Source/WebCore/inspector/front-end/StatusBarButton.js 2013-01-30 11:59:44 UTC (rev 141249)
+++ trunk/Source/WebCore/inspector/front-end/StatusBarButton.js 2013-01-30 12:01:07 UTC (rev 141250)
@@ -289,6 +289,14 @@
WebInspector.StatusBarComboBox.prototype = {
/**
+ * @return {number}
+ */
+ size: function()
+ {
+ return this._selectElement.childElementCount;
+ },
+
+ /**
* @param {!Element} option
*/
addOption: function(option)