Template Upload
270
node_modules/weinre/web/client/ApplicationCacheItemsView.js
generated
vendored
Normal file
@ -0,0 +1,270 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.ApplicationCacheItemsView = function(treeElement, appcacheDomain)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
|
||||
this.element.addStyleClass("storage-view");
|
||||
this.element.addStyleClass("table");
|
||||
|
||||
// FIXME: Delete Button semantics are not yet defined.
|
||||
// FIXME: Needs better tooltip. (Localized)
|
||||
this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString("Delete"), "delete-storage-status-bar-item");
|
||||
this.deleteButton.visible = false;
|
||||
this.deleteButton.addEventListener("click", this._deleteButtonClicked.bind(this), false);
|
||||
|
||||
// FIXME: Refresh Button semantics are not yet defined.
|
||||
// FIXME: Needs better tooltip. (Localized)
|
||||
this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
|
||||
this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
|
||||
|
||||
if (Preferences.onlineDetectionEnabled) {
|
||||
this.connectivityIcon = document.createElement("img");
|
||||
this.connectivityIcon.className = "storage-application-cache-connectivity-icon";
|
||||
this.connectivityIcon.src = "";
|
||||
this.connectivityMessage = document.createElement("span");
|
||||
this.connectivityMessage.className = "storage-application-cache-connectivity";
|
||||
this.connectivityMessage.textContent = "";
|
||||
}
|
||||
|
||||
this.divider = document.createElement("span");
|
||||
this.divider.className = "status-bar-item status-bar-divider";
|
||||
|
||||
this.statusIcon = document.createElement("img");
|
||||
this.statusIcon.className = "storage-application-cache-status-icon";
|
||||
this.statusIcon.src = "";
|
||||
this.statusMessage = document.createElement("span");
|
||||
this.statusMessage.className = "storage-application-cache-status";
|
||||
this.statusMessage.textContent = "";
|
||||
|
||||
this._treeElement = treeElement;
|
||||
this._appcacheDomain = appcacheDomain;
|
||||
|
||||
this._emptyMsgElement = document.createElement("div");
|
||||
this._emptyMsgElement.className = "storage-empty-view";
|
||||
this._emptyMsgElement.textContent = WebInspector.UIString("No Application Cache information available.");
|
||||
this.element.appendChild(this._emptyMsgElement);
|
||||
|
||||
this.updateStatus(applicationCache.UNCACHED);
|
||||
}
|
||||
|
||||
WebInspector.ApplicationCacheItemsView.prototype = {
|
||||
get statusBarItems()
|
||||
{
|
||||
if (Preferences.onlineDetectionEnabled) {
|
||||
return [
|
||||
this.refreshButton.element, this.deleteButton.element,
|
||||
this.connectivityIcon, this.connectivityMessage, this.divider,
|
||||
this.statusIcon, this.statusMessage
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
this.refreshButton.element, this.deleteButton.element, this.divider,
|
||||
this.statusIcon, this.statusMessage
|
||||
];
|
||||
}
|
||||
},
|
||||
|
||||
show: function(parentElement)
|
||||
{
|
||||
WebInspector.View.prototype.show.call(this, parentElement);
|
||||
this.updateNetworkState(navigator.onLine);
|
||||
this._update();
|
||||
},
|
||||
|
||||
hide: function()
|
||||
{
|
||||
WebInspector.View.prototype.hide.call(this);
|
||||
this.deleteButton.visible = false;
|
||||
},
|
||||
|
||||
updateStatus: function(status)
|
||||
{
|
||||
var statusInformation = {};
|
||||
statusInformation[applicationCache.UNCACHED] = { src: "Images/warningOrangeDot.png", text: "UNCACHED" };
|
||||
statusInformation[applicationCache.IDLE] = { src: "Images/warningOrangeDot.png", text: "IDLE" };
|
||||
statusInformation[applicationCache.CHECKING] = { src: "Images/successGreenDot.png", text: "CHECKING" };
|
||||
statusInformation[applicationCache.DOWNLOADING] = { src: "Images/successGreenDot.png", text: "DOWNLOADING" };
|
||||
statusInformation[applicationCache.UPDATEREADY] = { src: "Images/successGreenDot.png", text: "UPDATEREADY" };
|
||||
statusInformation[applicationCache.OBSOLETE] = { src: "Images/errorRedDot.png", text: "OBSOLETE" };
|
||||
|
||||
var info = statusInformation[status];
|
||||
if (!info) {
|
||||
console.error("Unknown Application Cache Status was Not Handled: %d", status);
|
||||
return;
|
||||
}
|
||||
|
||||
this.statusIcon.src = info.src;
|
||||
this.statusMessage.textContent = info.text;
|
||||
},
|
||||
|
||||
updateNetworkState: function(isNowOnline)
|
||||
{
|
||||
if (Preferences.onlineDetectionEnabled) {
|
||||
if (isNowOnline) {
|
||||
this.connectivityIcon.src = "Images/successGreenDot.png";
|
||||
this.connectivityMessage.textContent = WebInspector.UIString("Online");
|
||||
} else {
|
||||
this.connectivityIcon.src = "Images/errorRedDot.png";
|
||||
this.connectivityMessage.textContent = WebInspector.UIString("Offline");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_update: function()
|
||||
{
|
||||
WebInspector.ApplicationCacheDispatcher.getApplicationCachesAsync(this._updateCallback.bind(this));
|
||||
},
|
||||
|
||||
_updateCallback: function(applicationCaches)
|
||||
{
|
||||
// FIXME: applicationCaches is just one cache.
|
||||
// FIXME: are these variables needed anywhere else?
|
||||
this._manifest = applicationCaches.manifest;
|
||||
this._creationTime = applicationCaches.creationTime;
|
||||
this._updateTime = applicationCaches.updateTime;
|
||||
this._size = applicationCaches.size;
|
||||
this._resources = applicationCaches.resources;
|
||||
var lastPathComponent = applicationCaches.lastPathComponent;
|
||||
|
||||
if (!this._manifest) {
|
||||
this._emptyMsgElement.removeStyleClass("hidden");
|
||||
this.deleteButton.visible = false;
|
||||
if (this._dataGrid)
|
||||
this._dataGrid.element.addStyleClass("hidden");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._dataGrid)
|
||||
this._createDataGrid();
|
||||
|
||||
this._populateDataGrid();
|
||||
this._dataGrid.autoSizeColumns(20, 80);
|
||||
this._dataGrid.element.removeStyleClass("hidden");
|
||||
this._emptyMsgElement.addStyleClass("hidden");
|
||||
this.deleteButton.visible = true;
|
||||
|
||||
var totalSizeString = Number.bytesToString(this._size);
|
||||
this._treeElement.subtitle = WebInspector.UIString("%s (%s)", lastPathComponent, totalSizeString);
|
||||
|
||||
// FIXME: For Chrome, put creationTime and updateTime somewhere.
|
||||
// NOTE: localizedString has not yet been added.
|
||||
// WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, this._creationTime, this._updateTime);
|
||||
},
|
||||
|
||||
_createDataGrid: function()
|
||||
{
|
||||
var columns = { 0: {}, 1: {}, 2: {} };
|
||||
columns[0].title = WebInspector.UIString("Resource");
|
||||
columns[0].sort = "ascending";
|
||||
columns[0].sortable = true;
|
||||
columns[1].title = WebInspector.UIString("Type");
|
||||
columns[1].sortable = true;
|
||||
columns[2].title = WebInspector.UIString("Size");
|
||||
columns[2].aligned = "right";
|
||||
columns[2].sortable = true;
|
||||
this._dataGrid = new WebInspector.DataGrid(columns);
|
||||
this.element.appendChild(this._dataGrid.element);
|
||||
this._dataGrid.addEventListener("sorting changed", this._populateDataGrid, this);
|
||||
this._dataGrid.updateWidths();
|
||||
},
|
||||
|
||||
_populateDataGrid: function()
|
||||
{
|
||||
var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.selectedNode.resource : null;
|
||||
var sortDirection = this._dataGrid.sortOrder === "ascending" ? 1 : -1;
|
||||
|
||||
function numberCompare(field, resource1, resource2)
|
||||
{
|
||||
return sortDirection * (resource1[field] - resource2[field]);
|
||||
}
|
||||
function localeCompare(field, resource1, resource2)
|
||||
{
|
||||
return sortDirection * (resource1[field] + "").localeCompare(resource2[field] + "")
|
||||
}
|
||||
|
||||
var comparator;
|
||||
switch (parseInt(this._dataGrid.sortColumnIdentifier)) {
|
||||
case 0: comparator = localeCompare.bind(this, "name"); break;
|
||||
case 1: comparator = localeCompare.bind(this, "type"); break;
|
||||
case 2: comparator = numberCompare.bind(this, "size"); break;
|
||||
default: localeCompare.bind(this, "resource"); // FIXME: comparator = ?
|
||||
}
|
||||
|
||||
this._resources.sort(comparator);
|
||||
this._dataGrid.removeChildren();
|
||||
|
||||
var nodeToSelect;
|
||||
for (var i = 0; i < this._resources.length; ++i) {
|
||||
var data = {};
|
||||
var resource = this._resources[i];
|
||||
data[0] = resource.name;
|
||||
data[1] = resource.type;
|
||||
data[2] = Number.bytesToString(resource.size);
|
||||
var node = new WebInspector.DataGridNode(data);
|
||||
node.resource = resource;
|
||||
node.selectable = true;
|
||||
this._dataGrid.appendChild(node);
|
||||
if (resource === selectedResource) {
|
||||
nodeToSelect = node;
|
||||
nodeToSelect.selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nodeToSelect)
|
||||
this._dataGrid.children[0].selected = true;
|
||||
},
|
||||
|
||||
resize: function()
|
||||
{
|
||||
if (this._dataGrid)
|
||||
this._dataGrid.updateWidths();
|
||||
},
|
||||
|
||||
_deleteButtonClicked: function(event)
|
||||
{
|
||||
if (!this._dataGrid || !this._dataGrid.selectedNode)
|
||||
return;
|
||||
|
||||
// FIXME: Delete Button semantics are not yet defined. (Delete a single, or all?)
|
||||
this._deleteCallback(this._dataGrid.selectedNode);
|
||||
},
|
||||
|
||||
_deleteCallback: function(node)
|
||||
{
|
||||
// FIXME: Should we delete a single (selected) resource or all resources?
|
||||
// InspectorBackend.deleteCachedResource(...)
|
||||
// this._update();
|
||||
},
|
||||
|
||||
_refreshButtonClicked: function(event)
|
||||
{
|
||||
// FIXME: Is this a refresh button or a re-fetch manifest button?
|
||||
// this._update();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ApplicationCacheItemsView.prototype.__proto__ = WebInspector.View.prototype;
|
70
node_modules/weinre/web/client/AuditCategories.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.AuditCategories.PagePerformance = function() {
|
||||
WebInspector.AuditCategory.call(this, WebInspector.AuditCategories.PagePerformance.AuditCategoryName);
|
||||
}
|
||||
|
||||
WebInspector.AuditCategories.PagePerformance.AuditCategoryName = "Web Page Performance";
|
||||
|
||||
WebInspector.AuditCategories.PagePerformance.prototype = {
|
||||
initialize: function()
|
||||
{
|
||||
this.addRule(new WebInspector.AuditRules.UnusedCssRule(), WebInspector.AuditRule.Severity.Warning);
|
||||
this.addRule(new WebInspector.AuditRules.CssInHeadRule(), WebInspector.AuditRule.Severity.Severe);
|
||||
this.addRule(new WebInspector.AuditRules.StylesScriptsOrderRule(), WebInspector.AuditRule.Severity.Severe);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditCategories.PagePerformance.prototype.__proto__ = WebInspector.AuditCategory.prototype;
|
||||
|
||||
WebInspector.AuditCategories.NetworkUtilization = function() {
|
||||
WebInspector.AuditCategory.call(this, WebInspector.AuditCategories.NetworkUtilization.AuditCategoryName);
|
||||
}
|
||||
|
||||
WebInspector.AuditCategories.NetworkUtilization.AuditCategoryName = "Network Utilization";
|
||||
|
||||
WebInspector.AuditCategories.NetworkUtilization.prototype = {
|
||||
initialize: function()
|
||||
{
|
||||
this.addRule(new WebInspector.AuditRules.GzipRule(), WebInspector.AuditRule.Severity.Severe);
|
||||
this.addRule(new WebInspector.AuditRules.ImageDimensionsRule(), WebInspector.AuditRule.Severity.Warning);
|
||||
this.addRule(new WebInspector.AuditRules.CookieSizeRule(400), WebInspector.AuditRule.Severity.Warning);
|
||||
this.addRule(new WebInspector.AuditRules.StaticCookielessRule(5), WebInspector.AuditRule.Severity.Warning);
|
||||
this.addRule(new WebInspector.AuditRules.CombineJsResourcesRule(2), WebInspector.AuditRule.Severity.Severe);
|
||||
this.addRule(new WebInspector.AuditRules.CombineCssResourcesRule(2), WebInspector.AuditRule.Severity.Severe);
|
||||
this.addRule(new WebInspector.AuditRules.MinimizeDnsLookupsRule(4), WebInspector.AuditRule.Severity.Warning);
|
||||
this.addRule(new WebInspector.AuditRules.ParallelizeDownloadRule(4, 10, 0.5), WebInspector.AuditRule.Severity.Warning);
|
||||
this.addRule(new WebInspector.AuditRules.BrowserCacheControlRule(), WebInspector.AuditRule.Severity.Severe);
|
||||
this.addRule(new WebInspector.AuditRules.ProxyCacheControlRule(), WebInspector.AuditRule.Severity.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditCategories.NetworkUtilization.prototype.__proto__ = WebInspector.AuditCategory.prototype;
|
92
node_modules/weinre/web/client/AuditFormatters.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.applyFormatters = function(value)
|
||||
{
|
||||
var formatter;
|
||||
var type = typeof value;
|
||||
var args;
|
||||
|
||||
switch (type) {
|
||||
case "string":
|
||||
case "boolean":
|
||||
case "number":
|
||||
formatter = WebInspector.AuditFormatters.text;
|
||||
args = [ value.toString() ];
|
||||
break;
|
||||
|
||||
case "object":
|
||||
if (value instanceof Array) {
|
||||
formatter = WebInspector.AuditFormatters.concat;
|
||||
args = value;
|
||||
} else if (value.type && value.arguments) {
|
||||
formatter = WebInspector.AuditFormatters[value.type];
|
||||
args = value.arguments;
|
||||
}
|
||||
}
|
||||
if (!formatter)
|
||||
throw "Invalid value or formatter: " + type + JSON.stringify(value);
|
||||
|
||||
return formatter.apply(null, args);
|
||||
}
|
||||
|
||||
WebInspector.AuditFormatters = {
|
||||
text: function(text)
|
||||
{
|
||||
return document.createTextNode(text);
|
||||
},
|
||||
|
||||
snippet: function(snippetText)
|
||||
{
|
||||
var div = document.createElement("div");
|
||||
div.innerText = snippetText;
|
||||
div.className = "source-code";
|
||||
return div;
|
||||
},
|
||||
|
||||
concat: function()
|
||||
{
|
||||
var parent = document.createElement("span");
|
||||
for (var arg = 0; arg < arguments.length; ++arg)
|
||||
parent.appendChild(WebInspector.applyFormatters(arguments[arg]));
|
||||
return parent;
|
||||
},
|
||||
|
||||
url: function(url, displayText, allowExternalNavigation)
|
||||
{
|
||||
var a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.title = url;
|
||||
a.textContent = displayText || url;
|
||||
if (allowExternalNavigation)
|
||||
a.target = "_blank";
|
||||
return a;
|
||||
}
|
||||
};
|
254
node_modules/weinre/web/client/AuditLauncherView.js
generated
vendored
Normal file
@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.AuditLauncherView = function(runnerCallback)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
this._runnerCallback = runnerCallback;
|
||||
this._categoryIdPrefix = "audit-category-item-";
|
||||
this._auditRunning = false;
|
||||
|
||||
this.element.addStyleClass("audit-launcher-view");
|
||||
|
||||
this._contentElement = document.createElement("div");
|
||||
this._contentElement.className = "audit-launcher-view-content";
|
||||
this.element.appendChild(this._contentElement);
|
||||
this._boundCategoryClickListener = this._categoryClicked.bind(this);
|
||||
|
||||
this._resetResourceCount();
|
||||
|
||||
this._sortedCategories = [];
|
||||
|
||||
this._headerElement = document.createElement("h1");
|
||||
this._headerElement.className = "no-audits";
|
||||
this._headerElement.textContent = WebInspector.UIString("No audits to run");
|
||||
this._contentElement.appendChild(this._headerElement);
|
||||
|
||||
WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this);
|
||||
WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceFinished, this);
|
||||
}
|
||||
|
||||
WebInspector.AuditLauncherView.prototype = {
|
||||
_resetResourceCount: function()
|
||||
{
|
||||
this._loadedResources = 0;
|
||||
this._totalResources = 0;
|
||||
},
|
||||
|
||||
_onResourceStarted: function(event)
|
||||
{
|
||||
var resource = event.data;
|
||||
// Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway.
|
||||
if (resource.type === WebInspector.Resource.Type.WebSocket)
|
||||
return;
|
||||
++this._totalResources;
|
||||
this._updateResourceProgress();
|
||||
},
|
||||
|
||||
_onResourceFinished: function(event)
|
||||
{
|
||||
var resource = event.data;
|
||||
// See resorceStarted for details.
|
||||
if (resource.type === WebInspector.Resource.Type.WebSocket)
|
||||
return;
|
||||
++this._loadedResources;
|
||||
this._updateResourceProgress();
|
||||
},
|
||||
|
||||
addCategory: function(category)
|
||||
{
|
||||
if (!this._sortedCategories.length)
|
||||
this._createLauncherUI();
|
||||
|
||||
var categoryElement = this._createCategoryElement(category.displayName, category.id);
|
||||
category._checkboxElement = categoryElement.firstChild;
|
||||
if (this._selectAllCheckboxElement.checked) {
|
||||
category._checkboxElement.checked = true;
|
||||
++this._currentCategoriesCount;
|
||||
}
|
||||
|
||||
function compareCategories(a, b)
|
||||
{
|
||||
var aTitle = a.displayName || "";
|
||||
var bTitle = b.displayName || "";
|
||||
return aTitle.localeCompare(bTitle);
|
||||
}
|
||||
var insertBefore = insertionIndexForObjectInListSortedByFunction(category, this._sortedCategories, compareCategories);
|
||||
this._categoriesElement.insertBefore(categoryElement, this._categoriesElement.children[insertBefore] || null);
|
||||
this._sortedCategories.splice(insertBefore, 0, category);
|
||||
this._updateButton();
|
||||
},
|
||||
|
||||
_setAuditRunning: function(auditRunning)
|
||||
{
|
||||
if (this._auditRunning === auditRunning)
|
||||
return;
|
||||
this._auditRunning = auditRunning;
|
||||
this._updateButton();
|
||||
this._updateResourceProgress();
|
||||
},
|
||||
|
||||
_launchButtonClicked: function(event)
|
||||
{
|
||||
var catIds = [];
|
||||
var childNodes = this._categoriesElement.childNodes;
|
||||
for (var category = 0; category < this._sortedCategories.length; ++category) {
|
||||
if (this._sortedCategories[category]._checkboxElement.checked)
|
||||
catIds.push(this._sortedCategories[category].id);
|
||||
}
|
||||
|
||||
this._setAuditRunning(true);
|
||||
this._runnerCallback(catIds, this._auditPresentStateElement.checked, this._setAuditRunning.bind(this, false));
|
||||
},
|
||||
|
||||
_selectAllClicked: function(checkCategories)
|
||||
{
|
||||
var childNodes = this._categoriesElement.childNodes;
|
||||
for (var i = 0, length = childNodes.length; i < length; ++i)
|
||||
childNodes[i].firstChild.checked = checkCategories;
|
||||
this._currentCategoriesCount = checkCategories ? this._sortedCategories.length : 0;
|
||||
this._updateButton();
|
||||
},
|
||||
|
||||
_categoryClicked: function(event)
|
||||
{
|
||||
this._currentCategoriesCount += event.target.checked ? 1 : -1;
|
||||
this._selectAllCheckboxElement.checked = this._currentCategoriesCount === this._sortedCategories.length;
|
||||
this._updateButton();
|
||||
},
|
||||
|
||||
_createCategoryElement: function(title, id)
|
||||
{
|
||||
var labelElement = document.createElement("label");
|
||||
labelElement.id = this._categoryIdPrefix + id;
|
||||
|
||||
var element = document.createElement("input");
|
||||
element.type = "checkbox";
|
||||
if (id !== "")
|
||||
element.addEventListener("click", this._boundCategoryClickListener, false);
|
||||
labelElement.appendChild(element);
|
||||
labelElement.appendChild(document.createTextNode(title));
|
||||
|
||||
return labelElement;
|
||||
},
|
||||
|
||||
_createLauncherUI: function()
|
||||
{
|
||||
this._headerElement = document.createElement("h1");
|
||||
this._headerElement.textContent = WebInspector.UIString("Select audits to run");
|
||||
|
||||
for (var child = 0; child < this._contentElement.children.length; ++child)
|
||||
this._contentElement.removeChild(this._contentElement.children[child]);
|
||||
|
||||
this._contentElement.appendChild(this._headerElement);
|
||||
|
||||
function handleSelectAllClick(event)
|
||||
{
|
||||
this._selectAllClicked(event.target.checked);
|
||||
}
|
||||
var categoryElement = this._createCategoryElement(WebInspector.UIString("Select All"), "");
|
||||
categoryElement.id = "audit-launcher-selectall";
|
||||
this._selectAllCheckboxElement = categoryElement.firstChild;
|
||||
this._selectAllCheckboxElement.checked = true;
|
||||
this._selectAllCheckboxElement.addEventListener("click", handleSelectAllClick.bind(this), false);
|
||||
this._contentElement.appendChild(categoryElement);
|
||||
|
||||
this._categoriesElement = document.createElement("div");
|
||||
this._categoriesElement.className = "audit-categories-container";
|
||||
this._contentElement.appendChild(this._categoriesElement);
|
||||
|
||||
this._currentCategoriesCount = 0;
|
||||
|
||||
var flexibleSpaceElement = document.createElement("div");
|
||||
flexibleSpaceElement.className = "flexible-space";
|
||||
this._contentElement.appendChild(flexibleSpaceElement);
|
||||
|
||||
this._buttonContainerElement = document.createElement("div");
|
||||
this._buttonContainerElement.className = "button-container";
|
||||
|
||||
var labelElement = document.createElement("label");
|
||||
this._auditPresentStateElement = document.createElement("input");
|
||||
this._auditPresentStateElement.name = "audit-mode";
|
||||
this._auditPresentStateElement.type = "radio";
|
||||
this._auditPresentStateElement.checked = true;
|
||||
this._auditPresentStateLabelElement = document.createTextNode(WebInspector.UIString("Audit Present State"));
|
||||
labelElement.appendChild(this._auditPresentStateElement);
|
||||
labelElement.appendChild(this._auditPresentStateLabelElement);
|
||||
this._buttonContainerElement.appendChild(labelElement);
|
||||
|
||||
labelElement = document.createElement("label");
|
||||
this.auditReloadedStateElement = document.createElement("input");
|
||||
this.auditReloadedStateElement.name = "audit-mode";
|
||||
this.auditReloadedStateElement.type = "radio";
|
||||
labelElement.appendChild(this.auditReloadedStateElement);
|
||||
labelElement.appendChild(document.createTextNode("Reload Page and Audit on Load"));
|
||||
this._buttonContainerElement.appendChild(labelElement);
|
||||
|
||||
this._launchButton = document.createElement("button");
|
||||
this._launchButton.type = "button";
|
||||
this._launchButton.textContent = WebInspector.UIString("Run");
|
||||
this._launchButton.addEventListener("click", this._launchButtonClicked.bind(this), false);
|
||||
this._buttonContainerElement.appendChild(this._launchButton);
|
||||
|
||||
this._resourceProgressContainer = document.createElement("span");
|
||||
this._resourceProgressContainer.className = "resource-progress";
|
||||
var resourceProgressImage = document.createElement("img");
|
||||
this._resourceProgressContainer.appendChild(resourceProgressImage);
|
||||
this._resourceProgressTextElement = document.createElement("span");
|
||||
this._resourceProgressContainer.appendChild(this._resourceProgressTextElement);
|
||||
this._buttonContainerElement.appendChild(this._resourceProgressContainer);
|
||||
|
||||
this._contentElement.appendChild(this._buttonContainerElement);
|
||||
|
||||
this._selectAllClicked(this._selectAllCheckboxElement.checked);
|
||||
this._updateButton();
|
||||
this._updateResourceProgress();
|
||||
},
|
||||
|
||||
_updateResourceProgress: function()
|
||||
{
|
||||
if (!this._resourceProgressContainer)
|
||||
return;
|
||||
|
||||
if (!this._auditRunning) {
|
||||
this._resetResourceCount();
|
||||
this._resourceProgressContainer.addStyleClass("hidden");
|
||||
} else
|
||||
this._resourceProgressContainer.removeStyleClass("hidden");
|
||||
this._resourceProgressTextElement.textContent = WebInspector.UIString("Loading (%d of %d)", this._loadedResources, this._totalResources);
|
||||
},
|
||||
|
||||
_updateButton: function()
|
||||
{
|
||||
this._launchButton.disabled = !this._currentCategoriesCount || this._auditRunning;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditLauncherView.prototype.__proto__ = WebInspector.View.prototype;
|
114
node_modules/weinre/web/client/AuditResultView.js
generated
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.AuditResultView = function(categoryResults)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
this.element.className = "audit-result-view";
|
||||
|
||||
function categorySorter(a, b) {
|
||||
return (a.title || "").localeCompare(b.title || "");
|
||||
}
|
||||
categoryResults.sort(categorySorter);
|
||||
for (var i = 0; i < categoryResults.length; ++i)
|
||||
this.element.appendChild(new WebInspector.AuditCategoryResultPane(categoryResults[i]).element);
|
||||
}
|
||||
|
||||
WebInspector.AuditResultView.prototype.__proto__ = WebInspector.View.prototype;
|
||||
|
||||
|
||||
WebInspector.AuditCategoryResultPane = function(categoryResult)
|
||||
{
|
||||
WebInspector.SidebarPane.call(this, categoryResult.title);
|
||||
var treeOutlineElement = document.createElement("ol");
|
||||
this.bodyElement.addStyleClass("audit-result-tree");
|
||||
this.bodyElement.appendChild(treeOutlineElement);
|
||||
|
||||
this._treeOutline = new TreeOutline(treeOutlineElement);
|
||||
this._treeOutline.expandTreeElementsWhenArrowing = true;
|
||||
|
||||
function ruleSorter(a, b)
|
||||
{
|
||||
var result = WebInspector.AuditRule.SeverityOrder[a.severity || 0] - WebInspector.AuditRule.SeverityOrder[b.severity || 0];
|
||||
if (!result)
|
||||
result = (a.value || "").localeCompare(b.value || "");
|
||||
return result;
|
||||
}
|
||||
|
||||
categoryResult.ruleResults.sort(ruleSorter);
|
||||
|
||||
for (var i = 0; i < categoryResult.ruleResults.length; ++i) {
|
||||
var ruleResult = categoryResult.ruleResults[i];
|
||||
var treeElement = this._appendResult(this._treeOutline, ruleResult);
|
||||
treeElement.listItemElement.addStyleClass("audit-result");
|
||||
|
||||
if (ruleResult.severity) {
|
||||
var severityElement = document.createElement("img");
|
||||
severityElement.className = "severity-" + ruleResult.severity;
|
||||
treeElement.listItemElement.appendChild(severityElement);
|
||||
}
|
||||
}
|
||||
this.expand();
|
||||
}
|
||||
|
||||
WebInspector.AuditCategoryResultPane.prototype = {
|
||||
_appendResult: function(parentTreeElement, result)
|
||||
{
|
||||
var title = "";
|
||||
|
||||
if (typeof result.value === "string") {
|
||||
title = result.value;
|
||||
if (result.violationCount)
|
||||
title = String.sprintf("%s (%d)", title, result.violationCount);
|
||||
}
|
||||
|
||||
var treeElement = new TreeElement(null, null, !!result.children);
|
||||
treeElement.titleHTML = title;
|
||||
parentTreeElement.appendChild(treeElement);
|
||||
|
||||
if (result.className)
|
||||
treeElement.listItemElement.addStyleClass(result.className);
|
||||
if (typeof result.value !== "string")
|
||||
treeElement.listItemElement.appendChild(WebInspector.applyFormatters(result.value));
|
||||
|
||||
if (result.children) {
|
||||
for (var i = 0; i < result.children.length; ++i)
|
||||
this._appendResult(treeElement, result.children[i]);
|
||||
}
|
||||
if (result.expanded) {
|
||||
treeElement.listItemElement.removeStyleClass("parent");
|
||||
treeElement.listItemElement.addStyleClass("parent-expanded");
|
||||
treeElement.expand();
|
||||
}
|
||||
return treeElement;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditCategoryResultPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
|
1041
node_modules/weinre/web/client/AuditRules.js
generated
vendored
Normal file
474
node_modules/weinre/web/client/AuditsPanel.js
generated
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.AuditsPanel = function()
|
||||
{
|
||||
WebInspector.Panel.call(this, "audits");
|
||||
|
||||
this.createSidebar();
|
||||
this.auditsTreeElement = new WebInspector.SidebarSectionTreeElement("", {}, true);
|
||||
this.sidebarTree.appendChild(this.auditsTreeElement);
|
||||
this.auditsTreeElement.listItemElement.addStyleClass("hidden");
|
||||
this.auditsTreeElement.expand();
|
||||
|
||||
this.auditsItemTreeElement = new WebInspector.AuditsSidebarTreeElement();
|
||||
this.auditsTreeElement.appendChild(this.auditsItemTreeElement);
|
||||
|
||||
this.auditResultsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RESULTS"), {}, true);
|
||||
this.sidebarTree.appendChild(this.auditResultsTreeElement);
|
||||
this.auditResultsTreeElement.expand();
|
||||
|
||||
this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear audit results."), "clear-status-bar-item");
|
||||
this.clearResultsButton.addEventListener("click", this._clearButtonClicked.bind(this), false);
|
||||
|
||||
this.viewsContainerElement = document.createElement("div");
|
||||
this.viewsContainerElement.id = "audit-views";
|
||||
this.element.appendChild(this.viewsContainerElement);
|
||||
|
||||
this._constructCategories();
|
||||
|
||||
this._launcherView = new WebInspector.AuditLauncherView(this.initiateAudit.bind(this));
|
||||
for (id in this.categoriesById)
|
||||
this._launcherView.addCategory(this.categoriesById[id]);
|
||||
}
|
||||
|
||||
WebInspector.AuditsPanel.prototype = {
|
||||
get toolbarItemLabel()
|
||||
{
|
||||
return WebInspector.UIString("Audits");
|
||||
},
|
||||
|
||||
get statusBarItems()
|
||||
{
|
||||
return [this.clearResultsButton.element];
|
||||
},
|
||||
|
||||
get mainResourceLoadTime()
|
||||
{
|
||||
return this._mainResourceLoadTime;
|
||||
},
|
||||
|
||||
set mainResourceLoadTime(x)
|
||||
{
|
||||
this._mainResourceLoadTime = x;
|
||||
this._didMainResourceLoad();
|
||||
},
|
||||
|
||||
get mainResourceDOMContentTime()
|
||||
{
|
||||
return this._mainResourceDOMContentTime;
|
||||
},
|
||||
|
||||
set mainResourceDOMContentTime(x)
|
||||
{
|
||||
this._mainResourceDOMContentTime = x;
|
||||
},
|
||||
|
||||
get categoriesById()
|
||||
{
|
||||
return this._auditCategoriesById;
|
||||
},
|
||||
|
||||
addCategory: function(category)
|
||||
{
|
||||
this.categoriesById[category.id] = category;
|
||||
this._launcherView.addCategory(category);
|
||||
},
|
||||
|
||||
getCategory: function(id)
|
||||
{
|
||||
return this.categoriesById[id];
|
||||
},
|
||||
|
||||
_constructCategories: function()
|
||||
{
|
||||
this._auditCategoriesById = {};
|
||||
for (var categoryCtorID in WebInspector.AuditCategories) {
|
||||
var auditCategory = new WebInspector.AuditCategories[categoryCtorID]();
|
||||
auditCategory._id = categoryCtorID;
|
||||
this.categoriesById[categoryCtorID] = auditCategory;
|
||||
}
|
||||
},
|
||||
|
||||
_executeAudit: function(categories, resultCallback)
|
||||
{
|
||||
var resources = WebInspector.networkResources;
|
||||
|
||||
var rulesRemaining = 0;
|
||||
for (var i = 0; i < categories.length; ++i)
|
||||
rulesRemaining += categories[i].ruleCount;
|
||||
|
||||
var results = [];
|
||||
var mainResourceURL = WebInspector.mainResource.url;
|
||||
|
||||
function ruleResultReadyCallback(categoryResult, ruleResult)
|
||||
{
|
||||
if (ruleResult && ruleResult.children)
|
||||
categoryResult.addRuleResult(ruleResult);
|
||||
|
||||
--rulesRemaining;
|
||||
|
||||
if (!rulesRemaining && resultCallback)
|
||||
resultCallback(mainResourceURL, results);
|
||||
}
|
||||
|
||||
if (!rulesRemaining) {
|
||||
resultCallback(mainResourceURL, results);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < categories.length; ++i) {
|
||||
var category = categories[i];
|
||||
var result = new WebInspector.AuditCategoryResult(category);
|
||||
results.push(result);
|
||||
category.run(resources, ruleResultReadyCallback.bind(null, result));
|
||||
}
|
||||
},
|
||||
|
||||
_auditFinishedCallback: function(launcherCallback, mainResourceURL, results)
|
||||
{
|
||||
var children = this.auditResultsTreeElement.children;
|
||||
var ordinal = 1;
|
||||
for (var i = 0; i < children.length; ++i) {
|
||||
if (children[i].mainResourceURL === mainResourceURL)
|
||||
ordinal++;
|
||||
}
|
||||
|
||||
var resultTreeElement = new WebInspector.AuditResultSidebarTreeElement(results, mainResourceURL, ordinal);
|
||||
this.auditResultsTreeElement.appendChild(resultTreeElement);
|
||||
resultTreeElement.reveal();
|
||||
resultTreeElement.select();
|
||||
if (launcherCallback)
|
||||
launcherCallback();
|
||||
},
|
||||
|
||||
initiateAudit: function(categoryIds, runImmediately, launcherCallback)
|
||||
{
|
||||
if (!categoryIds || !categoryIds.length)
|
||||
return;
|
||||
|
||||
var categories = [];
|
||||
for (var i = 0; i < categoryIds.length; ++i)
|
||||
categories.push(this.categoriesById[categoryIds[i]]);
|
||||
|
||||
function initiateAuditCallback(categories, launcherCallback)
|
||||
{
|
||||
this._executeAudit(categories, this._auditFinishedCallback.bind(this, launcherCallback));
|
||||
}
|
||||
|
||||
if (runImmediately)
|
||||
initiateAuditCallback.call(this, categories, launcherCallback);
|
||||
else
|
||||
this._reloadResources(initiateAuditCallback.bind(this, categories, launcherCallback));
|
||||
},
|
||||
|
||||
_reloadResources: function(callback)
|
||||
{
|
||||
this._pageReloadCallback = callback;
|
||||
InspectorBackend.reloadPage(false);
|
||||
},
|
||||
|
||||
_didMainResourceLoad: function()
|
||||
{
|
||||
if (this._pageReloadCallback) {
|
||||
var callback = this._pageReloadCallback;
|
||||
delete this._pageReloadCallback;
|
||||
callback();
|
||||
}
|
||||
},
|
||||
|
||||
showResults: function(categoryResults)
|
||||
{
|
||||
if (!categoryResults._resultView)
|
||||
categoryResults._resultView = new WebInspector.AuditResultView(categoryResults);
|
||||
|
||||
this.visibleView = categoryResults._resultView;
|
||||
},
|
||||
|
||||
showLauncherView: function()
|
||||
{
|
||||
this.visibleView = this._launcherView;
|
||||
},
|
||||
|
||||
get visibleView()
|
||||
{
|
||||
return this._visibleView;
|
||||
},
|
||||
|
||||
set visibleView(x)
|
||||
{
|
||||
if (this._visibleView === x)
|
||||
return;
|
||||
|
||||
if (this._visibleView)
|
||||
this._visibleView.hide();
|
||||
|
||||
this._visibleView = x;
|
||||
|
||||
if (x)
|
||||
x.show(this.viewsContainerElement);
|
||||
},
|
||||
|
||||
attach: function()
|
||||
{
|
||||
WebInspector.Panel.prototype.attach.call(this);
|
||||
|
||||
this.auditsItemTreeElement.select();
|
||||
},
|
||||
|
||||
updateMainViewWidth: function(width)
|
||||
{
|
||||
this.viewsContainerElement.style.left = width + "px";
|
||||
},
|
||||
|
||||
_clearButtonClicked: function()
|
||||
{
|
||||
this.auditsItemTreeElement.reveal();
|
||||
this.auditsItemTreeElement.select();
|
||||
this.auditResultsTreeElement.removeChildren();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditsPanel.prototype.__proto__ = WebInspector.Panel.prototype;
|
||||
|
||||
|
||||
|
||||
WebInspector.AuditCategory = function(displayName)
|
||||
{
|
||||
this._displayName = displayName;
|
||||
this._rules = [];
|
||||
}
|
||||
|
||||
WebInspector.AuditCategory.prototype = {
|
||||
get id()
|
||||
{
|
||||
// this._id value is injected at construction time.
|
||||
return this._id;
|
||||
},
|
||||
|
||||
get displayName()
|
||||
{
|
||||
return this._displayName;
|
||||
},
|
||||
|
||||
get ruleCount()
|
||||
{
|
||||
this._ensureInitialized();
|
||||
return this._rules.length;
|
||||
},
|
||||
|
||||
addRule: function(rule, severity)
|
||||
{
|
||||
rule.severity = severity;
|
||||
this._rules.push(rule);
|
||||
},
|
||||
|
||||
run: function(resources, callback)
|
||||
{
|
||||
this._ensureInitialized();
|
||||
for (var i = 0; i < this._rules.length; ++i)
|
||||
this._rules[i].run(resources, callback);
|
||||
},
|
||||
|
||||
_ensureInitialized: function()
|
||||
{
|
||||
if (!this._initialized) {
|
||||
if ("initialize" in this)
|
||||
this.initialize();
|
||||
this._initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebInspector.AuditRule = function(id, displayName)
|
||||
{
|
||||
this._id = id;
|
||||
this._displayName = displayName;
|
||||
}
|
||||
|
||||
WebInspector.AuditRule.Severity = {
|
||||
Info: "info",
|
||||
Warning: "warning",
|
||||
Severe: "severe"
|
||||
}
|
||||
|
||||
WebInspector.AuditRule.SeverityOrder = {
|
||||
"info": 3,
|
||||
"warning": 2,
|
||||
"severe": 1
|
||||
}
|
||||
|
||||
WebInspector.AuditRule.prototype = {
|
||||
get id()
|
||||
{
|
||||
return this._id;
|
||||
},
|
||||
|
||||
get displayName()
|
||||
{
|
||||
return this._displayName;
|
||||
},
|
||||
|
||||
set severity(severity)
|
||||
{
|
||||
this._severity = severity;
|
||||
},
|
||||
|
||||
run: function(resources, callback)
|
||||
{
|
||||
var result = new WebInspector.AuditRuleResult(this.displayName);
|
||||
result.severity = this._severity;
|
||||
this.doRun(resources, result, callback);
|
||||
},
|
||||
|
||||
doRun: function(resources, result, callback)
|
||||
{
|
||||
throw new Error("doRun() not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditCategoryResult = function(category)
|
||||
{
|
||||
this.title = category.displayName;
|
||||
this.ruleResults = [];
|
||||
}
|
||||
|
||||
WebInspector.AuditCategoryResult.prototype = {
|
||||
addRuleResult: function(ruleResult)
|
||||
{
|
||||
this.ruleResults.push(ruleResult);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditRuleResult = function(value, expanded, className)
|
||||
{
|
||||
this.value = value;
|
||||
this.className = className;
|
||||
this.expanded = expanded;
|
||||
this.violationCount = 0;
|
||||
}
|
||||
|
||||
WebInspector.AuditRuleResult.linkifyDisplayName = function(url)
|
||||
{
|
||||
return WebInspector.linkifyURL(url, WebInspector.displayNameForURL(url));
|
||||
}
|
||||
|
||||
WebInspector.AuditRuleResult.resourceDomain = function(domain)
|
||||
{
|
||||
return domain || WebInspector.UIString("[empty domain]");
|
||||
}
|
||||
|
||||
WebInspector.AuditRuleResult.prototype = {
|
||||
addChild: function(value, expanded, className)
|
||||
{
|
||||
if (!this.children)
|
||||
this.children = [];
|
||||
var entry = new WebInspector.AuditRuleResult(value, expanded, className);
|
||||
this.children.push(entry);
|
||||
return entry;
|
||||
},
|
||||
|
||||
addURL: function(url)
|
||||
{
|
||||
return this.addChild(WebInspector.AuditRuleResult.linkifyDisplayName(url));
|
||||
},
|
||||
|
||||
addURLs: function(urls)
|
||||
{
|
||||
for (var i = 0; i < urls.length; ++i)
|
||||
this.addURL(urls[i]);
|
||||
},
|
||||
|
||||
addSnippet: function(snippet)
|
||||
{
|
||||
return this.addChild(snippet, false, "source-code");
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditsSidebarTreeElement = function()
|
||||
{
|
||||
this.small = false;
|
||||
|
||||
WebInspector.SidebarTreeElement.call(this, "audits-sidebar-tree-item", WebInspector.UIString("Audits"), "", null, false);
|
||||
}
|
||||
|
||||
WebInspector.AuditsSidebarTreeElement.prototype = {
|
||||
onattach: function()
|
||||
{
|
||||
WebInspector.SidebarTreeElement.prototype.onattach.call(this);
|
||||
},
|
||||
|
||||
onselect: function()
|
||||
{
|
||||
WebInspector.panels.audits.showLauncherView();
|
||||
},
|
||||
|
||||
get selectable()
|
||||
{
|
||||
return true;
|
||||
},
|
||||
|
||||
refresh: function()
|
||||
{
|
||||
this.refreshTitles();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditsSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype;
|
||||
|
||||
|
||||
WebInspector.AuditResultSidebarTreeElement = function(results, mainResourceURL, ordinal)
|
||||
{
|
||||
this.results = results;
|
||||
this.mainResourceURL = mainResourceURL;
|
||||
|
||||
WebInspector.SidebarTreeElement.call(this, "audit-result-sidebar-tree-item", String.sprintf("%s (%d)", mainResourceURL, ordinal), "", {}, false);
|
||||
}
|
||||
|
||||
WebInspector.AuditResultSidebarTreeElement.prototype = {
|
||||
onselect: function()
|
||||
{
|
||||
WebInspector.panels.audits.showResults(this.results);
|
||||
},
|
||||
|
||||
get selectable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.AuditResultSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype;
|
||||
|
||||
// Contributed audit rules should go into this namespace.
|
||||
WebInspector.AuditRules = {};
|
||||
|
||||
// Contributed audit categories should go into this namespace.
|
||||
WebInspector.AuditCategories = {};
|
264
node_modules/weinre/web/client/BottomUpProfileDataGridTree.js
generated
vendored
Normal file
@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (C) 2009 280 North 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.
|
||||
*/
|
||||
|
||||
// Bottom Up Profiling shows the entire callstack backwards:
|
||||
// The root node is a representation of each individual function called, and each child of that node represents
|
||||
// a reverse-callstack showing how many of those calls came from it. So, unlike top-down, the statistics in
|
||||
// each child still represent the root node. We have to be particularly careful of recursion with this mode
|
||||
// because a root node can represent itself AND an ancestor.
|
||||
|
||||
WebInspector.BottomUpProfileDataGridNode = function(/*ProfileView*/ profileView, /*ProfileNode*/ profileNode, /*BottomUpProfileDataGridTree*/ owningTree)
|
||||
{
|
||||
WebInspector.ProfileDataGridNode.call(this, profileView, profileNode, owningTree, this._willHaveChildren(profileNode));
|
||||
|
||||
this._remainingNodeInfos = [];
|
||||
}
|
||||
|
||||
WebInspector.BottomUpProfileDataGridNode.prototype = {
|
||||
_takePropertiesFromProfileDataGridNode: function(/*ProfileDataGridNode*/ profileDataGridNode)
|
||||
{
|
||||
this._save();
|
||||
|
||||
this.selfTime = profileDataGridNode.selfTime;
|
||||
this.totalTime = profileDataGridNode.totalTime;
|
||||
this.numberOfCalls = profileDataGridNode.numberOfCalls;
|
||||
},
|
||||
|
||||
// When focusing, we keep just the members of the callstack.
|
||||
_keepOnlyChild: function(/*ProfileDataGridNode*/ child)
|
||||
{
|
||||
this._save();
|
||||
|
||||
this.removeChildren();
|
||||
this.appendChild(child);
|
||||
},
|
||||
|
||||
_exclude: function(aCallUID)
|
||||
{
|
||||
if (this._remainingNodeInfos)
|
||||
this._populate();
|
||||
|
||||
this._save();
|
||||
|
||||
var children = this.children;
|
||||
var index = this.children.length;
|
||||
|
||||
while (index--)
|
||||
children[index]._exclude(aCallUID);
|
||||
|
||||
var child = this.childrenByCallUID[aCallUID];
|
||||
|
||||
if (child)
|
||||
this._merge(child, true);
|
||||
},
|
||||
|
||||
_restore: function()
|
||||
{
|
||||
WebInspector.ProfileDataGridNode.prototype._restore();
|
||||
|
||||
if (!this.children.length)
|
||||
this.hasChildren = this._willHaveChildren();
|
||||
},
|
||||
|
||||
_merge: function(/*ProfileDataGridNode*/ child, /*Boolean*/ shouldAbsorb)
|
||||
{
|
||||
this.selfTime -= child.selfTime;
|
||||
|
||||
WebInspector.ProfileDataGridNode.prototype._merge.call(this, child, shouldAbsorb);
|
||||
},
|
||||
|
||||
_sharedPopulate: function()
|
||||
{
|
||||
var remainingNodeInfos = this._remainingNodeInfos;
|
||||
var count = remainingNodeInfos.length;
|
||||
|
||||
for (var index = 0; index < count; ++index) {
|
||||
var nodeInfo = remainingNodeInfos[index];
|
||||
var ancestor = nodeInfo.ancestor;
|
||||
var focusNode = nodeInfo.focusNode;
|
||||
var child = this.findChild(ancestor);
|
||||
|
||||
// If we already have this child, then merge the data together.
|
||||
if (child) {
|
||||
var totalTimeAccountedFor = nodeInfo.totalTimeAccountedFor;
|
||||
|
||||
child.selfTime += focusNode.selfTime;
|
||||
child.numberOfCalls += focusNode.numberOfCalls;
|
||||
|
||||
if (!totalTimeAccountedFor)
|
||||
child.totalTime += focusNode.totalTime;
|
||||
} else {
|
||||
// If not, add it as a true ancestor.
|
||||
// In heavy mode, we take our visual identity from ancestor node...
|
||||
var child = new WebInspector.BottomUpProfileDataGridNode(this.profileView, ancestor, this.tree);
|
||||
|
||||
if (ancestor !== focusNode) {
|
||||
// but the actual statistics from the "root" node (bottom of the callstack).
|
||||
child.selfTime = focusNode.selfTime;
|
||||
child.totalTime = focusNode.totalTime;
|
||||
child.numberOfCalls = focusNode.numberOfCalls;
|
||||
}
|
||||
|
||||
this.appendChild(child);
|
||||
}
|
||||
|
||||
var parent = ancestor.parent;
|
||||
if (parent && parent.parent) {
|
||||
nodeInfo.ancestor = parent;
|
||||
child._remainingNodeInfos.push(nodeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
delete this._remainingNodeInfos;
|
||||
},
|
||||
|
||||
_willHaveChildren: function(profileNode)
|
||||
{
|
||||
profileNode = profileNode || this.profileNode;
|
||||
// In bottom up mode, our parents are our children since we display an inverted tree.
|
||||
// However, we don't want to show the very top parent since it is redundant.
|
||||
return !!(profileNode.parent && profileNode.parent.parent);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.BottomUpProfileDataGridNode.prototype.__proto__ = WebInspector.ProfileDataGridNode.prototype;
|
||||
|
||||
WebInspector.BottomUpProfileDataGridTree = function(/*ProfileView*/ aProfileView, /*ProfileNode*/ aProfileNode)
|
||||
{
|
||||
WebInspector.ProfileDataGridTree.call(this, aProfileView, aProfileNode);
|
||||
|
||||
// Iterate each node in pre-order.
|
||||
var profileNodeUIDs = 0;
|
||||
var profileNodeGroups = [[], [aProfileNode]];
|
||||
var visitedProfileNodesForCallUID = {};
|
||||
|
||||
this._remainingNodeInfos = [];
|
||||
|
||||
for (var profileNodeGroupIndex = 0; profileNodeGroupIndex < profileNodeGroups.length; ++profileNodeGroupIndex) {
|
||||
var parentProfileNodes = profileNodeGroups[profileNodeGroupIndex];
|
||||
var profileNodes = profileNodeGroups[++profileNodeGroupIndex];
|
||||
var count = profileNodes.length;
|
||||
|
||||
for (var index = 0; index < count; ++index) {
|
||||
var profileNode = profileNodes[index];
|
||||
|
||||
if (!profileNode.UID)
|
||||
profileNode.UID = ++profileNodeUIDs;
|
||||
|
||||
if (profileNode.head && profileNode !== profileNode.head) {
|
||||
// The total time of this ancestor is accounted for if we're in any form of recursive cycle.
|
||||
var visitedNodes = visitedProfileNodesForCallUID[profileNode.callUID];
|
||||
var totalTimeAccountedFor = false;
|
||||
|
||||
if (!visitedNodes) {
|
||||
visitedNodes = {}
|
||||
visitedProfileNodesForCallUID[profileNode.callUID] = visitedNodes;
|
||||
} else {
|
||||
// The total time for this node has already been accounted for iff one of it's parents has already been visited.
|
||||
// We can do this check in this style because we are traversing the tree in pre-order.
|
||||
var parentCount = parentProfileNodes.length;
|
||||
for (var parentIndex = 0; parentIndex < parentCount; ++parentIndex) {
|
||||
if (visitedNodes[parentProfileNodes[parentIndex].UID]) {
|
||||
totalTimeAccountedFor = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitedNodes[profileNode.UID] = true;
|
||||
|
||||
this._remainingNodeInfos.push({ ancestor:profileNode, focusNode:profileNode, totalTimeAccountedFor:totalTimeAccountedFor });
|
||||
}
|
||||
|
||||
var children = profileNode.children;
|
||||
if (children.length) {
|
||||
profileNodeGroups.push(parentProfileNodes.concat([profileNode]))
|
||||
profileNodeGroups.push(children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Populate the top level nodes.
|
||||
WebInspector.BottomUpProfileDataGridNode.prototype._populate.call(this);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
WebInspector.BottomUpProfileDataGridTree.prototype = {
|
||||
// When focusing, we keep the entire callstack up to this ancestor.
|
||||
focus: function(/*ProfileDataGridNode*/ profileDataGridNode)
|
||||
{
|
||||
if (!profileDataGridNode)
|
||||
return;
|
||||
|
||||
this._save();
|
||||
|
||||
var currentNode = profileDataGridNode;
|
||||
var focusNode = profileDataGridNode;
|
||||
|
||||
while (currentNode.parent && (currentNode instanceof WebInspector.ProfileDataGridNode)) {
|
||||
currentNode._takePropertiesFromProfileDataGridNode(profileDataGridNode);
|
||||
|
||||
focusNode = currentNode;
|
||||
currentNode = currentNode.parent;
|
||||
|
||||
if (currentNode instanceof WebInspector.ProfileDataGridNode)
|
||||
currentNode._keepOnlyChild(focusNode);
|
||||
}
|
||||
|
||||
this.children = [focusNode];
|
||||
this.totalTime = profileDataGridNode.totalTime;
|
||||
},
|
||||
|
||||
exclude: function(/*ProfileDataGridNode*/ profileDataGridNode)
|
||||
{
|
||||
if (!profileDataGridNode)
|
||||
return;
|
||||
|
||||
this._save();
|
||||
|
||||
var excludedCallUID = profileDataGridNode.callUID;
|
||||
var excludedTopLevelChild = this.childrenByCallUID[excludedCallUID];
|
||||
|
||||
// If we have a top level node that is excluded, get rid of it completely (not keeping children),
|
||||
// since bottom up data relies entirely on the root node.
|
||||
if (excludedTopLevelChild)
|
||||
this.children.remove(excludedTopLevelChild);
|
||||
|
||||
var children = this.children;
|
||||
var count = children.length;
|
||||
|
||||
for (var index = 0; index < count; ++index)
|
||||
children[index]._exclude(excludedCallUID);
|
||||
|
||||
if (this.lastComparator)
|
||||
this.sort(this.lastComparator, true);
|
||||
},
|
||||
|
||||
_sharedPopulate: WebInspector.BottomUpProfileDataGridNode.prototype._sharedPopulate
|
||||
}
|
||||
|
||||
WebInspector.BottomUpProfileDataGridTree.prototype.__proto__ = WebInspector.ProfileDataGridTree.prototype;
|
||||
|
49
node_modules/weinre/web/client/Breakpoint.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.Breakpoint = function(id, url, sourceID, lineNumber, columnNumber, condition, enabled)
|
||||
{
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.sourceID = sourceID;
|
||||
this.lineNumber = lineNumber;
|
||||
this.columnNumber = columnNumber;
|
||||
this.condition = condition;
|
||||
this.enabled = enabled;
|
||||
this.locations = [];
|
||||
}
|
||||
|
||||
WebInspector.Breakpoint.prototype = {
|
||||
addLocation: function(sourceID, lineNumber, columnNumber)
|
||||
{
|
||||
this.locations.push({ sourceID: sourceID, lineNumber: lineNumber, columnNumber: columnNumber });
|
||||
}
|
||||
}
|
624
node_modules/weinre/web/client/BreakpointManager.js
generated
vendored
Normal file
@ -0,0 +1,624 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.BreakpointManager = function()
|
||||
{
|
||||
this._stickyBreakpoints = {};
|
||||
var breakpoints = WebInspector.settings.findSettingForAllProjects("nativeBreakpoints");
|
||||
for (var projectId in breakpoints)
|
||||
this._stickyBreakpoints[projectId] = this._validateBreakpoints(breakpoints[projectId]);
|
||||
|
||||
this._breakpoints = {};
|
||||
this._domBreakpointsRestored = false;
|
||||
|
||||
WebInspector.settings.addEventListener(WebInspector.Settings.Events.ProjectChanged, this._projectChanged, this);
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
|
||||
}
|
||||
|
||||
WebInspector.BreakpointManager.BreakpointTypes = {
|
||||
DOM: "DOM",
|
||||
EventListener: "EventListener",
|
||||
XHR: "XHR"
|
||||
}
|
||||
|
||||
WebInspector.BreakpointManager.Events = {
|
||||
DOMBreakpointAdded: "dom-breakpoint-added",
|
||||
EventListenerBreakpointAdded: "event-listener-breakpoint-added",
|
||||
XHRBreakpointAdded: "xhr-breakpoint-added",
|
||||
ProjectChanged: "project-changed"
|
||||
}
|
||||
|
||||
WebInspector.BreakpointManager.prototype = {
|
||||
createDOMBreakpoint: function(nodeId, type)
|
||||
{
|
||||
this._createDOMBreakpoint(nodeId, type, true, false);
|
||||
},
|
||||
|
||||
_createDOMBreakpoint: function(nodeId, type, enabled, restored)
|
||||
{
|
||||
var node = WebInspector.domAgent.nodeForId(nodeId);
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
var breakpointId = this._createDOMBreakpointId(nodeId, type);
|
||||
if (breakpointId in this._breakpoints)
|
||||
return;
|
||||
|
||||
var breakpoint = new WebInspector.DOMBreakpoint(node, type);
|
||||
this._setBreakpoint(breakpointId, breakpoint, enabled, restored);
|
||||
if (enabled && restored)
|
||||
breakpoint._enable();
|
||||
|
||||
breakpoint.view = new WebInspector.DOMBreakpointView(this, breakpointId, enabled, node, type);
|
||||
this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.DOMBreakpointAdded, breakpoint.view);
|
||||
},
|
||||
|
||||
createEventListenerBreakpoint: function(eventName)
|
||||
{
|
||||
this._createEventListenerBreakpoint(eventName, true, false);
|
||||
},
|
||||
|
||||
_createEventListenerBreakpoint: function(eventName, enabled, restored)
|
||||
{
|
||||
var breakpointId = this._createEventListenerBreakpointId(eventName);
|
||||
if (breakpointId in this._breakpoints)
|
||||
return;
|
||||
|
||||
var breakpoint = new WebInspector.EventListenerBreakpoint(eventName);
|
||||
this._setBreakpoint(breakpointId, breakpoint, enabled, restored);
|
||||
|
||||
breakpoint.view = new WebInspector.EventListenerBreakpointView(this, breakpointId, enabled, eventName);
|
||||
this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.EventListenerBreakpointAdded, breakpoint.view);
|
||||
},
|
||||
|
||||
createXHRBreakpoint: function(url)
|
||||
{
|
||||
this._createXHRBreakpoint(url, true, false);
|
||||
},
|
||||
|
||||
_createXHRBreakpoint: function(url, enabled, restored)
|
||||
{
|
||||
var breakpointId = this._createXHRBreakpointId(url);
|
||||
if (breakpointId in this._breakpoints)
|
||||
return;
|
||||
|
||||
var breakpoint = new WebInspector.XHRBreakpoint(url);
|
||||
this._setBreakpoint(breakpointId, breakpoint, enabled, restored);
|
||||
|
||||
breakpoint.view = new WebInspector.XHRBreakpointView(this, breakpointId, enabled, url);
|
||||
this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.XHRBreakpointAdded, breakpoint.view);
|
||||
},
|
||||
|
||||
_setBreakpoint: function(breakpointId, breakpoint, enabled, restored)
|
||||
{
|
||||
this._breakpoints[breakpointId] = breakpoint;
|
||||
breakpoint.enabled = enabled;
|
||||
if (restored)
|
||||
return;
|
||||
if (enabled)
|
||||
breakpoint._enable();
|
||||
this._saveBreakpoints();
|
||||
},
|
||||
|
||||
_setBreakpointEnabled: function(breakpointId, enabled)
|
||||
{
|
||||
var breakpoint = this._breakpoints[breakpointId];
|
||||
if (breakpoint.enabled === enabled)
|
||||
return;
|
||||
if (enabled)
|
||||
breakpoint._enable();
|
||||
else
|
||||
breakpoint._disable();
|
||||
breakpoint.enabled = enabled;
|
||||
this._saveBreakpoints();
|
||||
},
|
||||
|
||||
_removeBreakpoint: function(breakpointId)
|
||||
{
|
||||
var breakpoint = this._breakpoints[breakpointId];
|
||||
if (breakpoint.enabled)
|
||||
breakpoint._disable();
|
||||
delete this._breakpoints[breakpointId];
|
||||
this._saveBreakpoints();
|
||||
},
|
||||
|
||||
breakpointViewForEventData: function(eventData)
|
||||
{
|
||||
var breakpointId;
|
||||
if (eventData.breakpointType === WebInspector.BreakpointManager.BreakpointTypes.DOM)
|
||||
breakpointId = this._createDOMBreakpointId(eventData.nodeId, eventData.type);
|
||||
else if (eventData.breakpointType === WebInspector.BreakpointManager.BreakpointTypes.EventListener)
|
||||
breakpointId = this._createEventListenerBreakpointId(eventData.eventName);
|
||||
else if (eventData.breakpointType === WebInspector.BreakpointManager.BreakpointTypes.XHR)
|
||||
breakpointId = this._createXHRBreakpointId(eventData.breakpointURL);
|
||||
else
|
||||
return;
|
||||
|
||||
var breakpoint = this._breakpoints[breakpointId];
|
||||
if (breakpoint)
|
||||
return breakpoint.view;
|
||||
},
|
||||
|
||||
_debuggerPaused: function(event)
|
||||
{
|
||||
var eventType = event.data.eventType;
|
||||
var eventData = event.data.eventData;
|
||||
|
||||
if (eventType !== WebInspector.DebuggerEventTypes.NativeBreakpoint)
|
||||
return;
|
||||
|
||||
var breakpointView = this.breakpointViewForEventData(eventData);
|
||||
if (!breakpointView)
|
||||
return;
|
||||
|
||||
breakpointView.hit = true;
|
||||
this._lastHitBreakpointView = breakpointView;
|
||||
},
|
||||
|
||||
_debuggerResumed: function(event)
|
||||
{
|
||||
if (!this._lastHitBreakpointView)
|
||||
return;
|
||||
this._lastHitBreakpointView.hit = false;
|
||||
delete this._lastHitBreakpointView;
|
||||
},
|
||||
|
||||
_projectChanged: function(event)
|
||||
{
|
||||
this._breakpoints = {};
|
||||
this._domBreakpointsRestored = false;
|
||||
this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.ProjectChanged);
|
||||
|
||||
var breakpoints = this._stickyBreakpoints[WebInspector.settings.projectId] || [];
|
||||
for (var i = 0; i < breakpoints.length; ++i) {
|
||||
var breakpoint = breakpoints[i];
|
||||
if (breakpoint.type === WebInspector.BreakpointManager.BreakpointTypes.EventListener)
|
||||
this._createEventListenerBreakpoint(breakpoint.condition.eventName, breakpoint.enabled, true);
|
||||
else if (breakpoint.type === WebInspector.BreakpointManager.BreakpointTypes.XHR)
|
||||
this._createXHRBreakpoint(breakpoint.condition.url, breakpoint.enabled, true);
|
||||
}
|
||||
|
||||
if (!this._breakpointsPushedToFrontend) {
|
||||
InspectorBackend.setAllBrowserBreakpoints(this._stickyBreakpoints);
|
||||
this._breakpointsPushedToFrontend = true;
|
||||
}
|
||||
},
|
||||
|
||||
restoreDOMBreakpoints: function()
|
||||
{
|
||||
function didPushNodeByPathToFrontend(path, nodeId)
|
||||
{
|
||||
pathToNodeId[path] = nodeId;
|
||||
pendingCalls -= 1;
|
||||
if (pendingCalls)
|
||||
return;
|
||||
for (var i = 0; i < breakpoints.length; ++i) {
|
||||
var breakpoint = breakpoints[i];
|
||||
if (breakpoint.type !== WebInspector.BreakpointManager.BreakpointTypes.DOM)
|
||||
continue;
|
||||
var nodeId = pathToNodeId[breakpoint.condition.path];
|
||||
if (nodeId)
|
||||
this._createDOMBreakpoint(nodeId, breakpoint.condition.type, breakpoint.enabled, true);
|
||||
}
|
||||
this._domBreakpointsRestored = true;
|
||||
this._saveBreakpoints();
|
||||
}
|
||||
|
||||
var breakpoints = this._stickyBreakpoints[WebInspector.settings.projectId] || [];
|
||||
var pathToNodeId = {};
|
||||
var pendingCalls = 0;
|
||||
for (var i = 0; i < breakpoints.length; ++i) {
|
||||
if (breakpoints[i].type !== WebInspector.BreakpointManager.BreakpointTypes.DOM)
|
||||
continue;
|
||||
var path = breakpoints[i].condition.path;
|
||||
if (path in pathToNodeId)
|
||||
continue;
|
||||
pathToNodeId[path] = 0;
|
||||
pendingCalls += 1;
|
||||
InspectorBackend.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path));
|
||||
}
|
||||
if (!pendingCalls)
|
||||
this._domBreakpointsRestored = true;
|
||||
},
|
||||
|
||||
_saveBreakpoints: function()
|
||||
{
|
||||
var breakpoints = [];
|
||||
for (var breakpointId in this._breakpoints) {
|
||||
var breakpoint = this._breakpoints[breakpointId];
|
||||
var persistentBreakpoint = breakpoint._serializeToJSON();
|
||||
persistentBreakpoint.enabled = breakpoint.enabled;
|
||||
breakpoints.push(persistentBreakpoint);
|
||||
}
|
||||
if (!this._domBreakpointsRestored) {
|
||||
var stickyBreakpoints = this._stickyBreakpoints[WebInspector.settings.projectId] || [];
|
||||
for (var i = 0; i < stickyBreakpoints.length; ++i) {
|
||||
if (stickyBreakpoints[i].type === WebInspector.BreakpointManager.BreakpointTypes.DOM)
|
||||
breakpoints.push(stickyBreakpoints[i]);
|
||||
}
|
||||
}
|
||||
WebInspector.settings.nativeBreakpoints = breakpoints;
|
||||
|
||||
this._stickyBreakpoints[WebInspector.settings.projectId] = breakpoints;
|
||||
InspectorBackend.setAllBrowserBreakpoints(this._stickyBreakpoints);
|
||||
},
|
||||
|
||||
_validateBreakpoints: function(persistentBreakpoints)
|
||||
{
|
||||
var breakpoints = [];
|
||||
var breakpointsSet = {};
|
||||
for (var i = 0; i < persistentBreakpoints.length; ++i) {
|
||||
var breakpoint = persistentBreakpoints[i];
|
||||
if (!("type" in breakpoint && "enabled" in breakpoint && "condition" in breakpoint))
|
||||
continue;
|
||||
var id = breakpoint.type + ":";
|
||||
var condition = breakpoint.condition;
|
||||
if (breakpoint.type === WebInspector.BreakpointManager.BreakpointTypes.DOM) {
|
||||
if (typeof condition.path !== "string" || typeof condition.type !== "number")
|
||||
continue;
|
||||
id += condition.path + ":" + condition.type;
|
||||
} else if (breakpoint.type === WebInspector.BreakpointManager.BreakpointTypes.EventListener) {
|
||||
if (typeof condition.eventName !== "string")
|
||||
continue;
|
||||
id += condition.eventName;
|
||||
} else if (breakpoint.type === WebInspector.BreakpointManager.BreakpointTypes.XHR) {
|
||||
if (typeof condition.url !== "string")
|
||||
continue;
|
||||
id += condition.url;
|
||||
} else
|
||||
continue;
|
||||
if (id in breakpointsSet)
|
||||
continue;
|
||||
breakpointsSet[id] = true;
|
||||
breakpoints.push(breakpoint);
|
||||
}
|
||||
return breakpoints;
|
||||
},
|
||||
|
||||
_createDOMBreakpointId: function(nodeId, type)
|
||||
{
|
||||
return "dom:" + nodeId + ":" + type;
|
||||
},
|
||||
|
||||
_createEventListenerBreakpointId: function(eventName)
|
||||
{
|
||||
return "eventListner:" + eventName;
|
||||
},
|
||||
|
||||
_createXHRBreakpointId: function(url)
|
||||
{
|
||||
return "xhr:" + url;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.BreakpointManager.prototype.__proto__ = WebInspector.Object.prototype;
|
||||
|
||||
WebInspector.DOMBreakpoint = function(node, type)
|
||||
{
|
||||
this._nodeId = node.id;
|
||||
this._path = node.path();
|
||||
this._type = type;
|
||||
}
|
||||
|
||||
WebInspector.DOMBreakpoint.prototype = {
|
||||
_enable: function()
|
||||
{
|
||||
InspectorBackend.setDOMBreakpoint(this._nodeId, this._type);
|
||||
},
|
||||
|
||||
_disable: function()
|
||||
{
|
||||
InspectorBackend.removeDOMBreakpoint(this._nodeId, this._type);
|
||||
},
|
||||
|
||||
_serializeToJSON: function()
|
||||
{
|
||||
var type = WebInspector.BreakpointManager.BreakpointTypes.DOM;
|
||||
return { type: type, condition: { path: this._path, type: this._type } };
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBreakpoint = function(eventName)
|
||||
{
|
||||
this._eventName = eventName;
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBreakpoint.prototype = {
|
||||
_enable: function()
|
||||
{
|
||||
InspectorBackend.setEventListenerBreakpoint(this._eventName);
|
||||
},
|
||||
|
||||
_disable: function()
|
||||
{
|
||||
InspectorBackend.removeEventListenerBreakpoint(this._eventName);
|
||||
},
|
||||
|
||||
_serializeToJSON: function()
|
||||
{
|
||||
var type = WebInspector.BreakpointManager.BreakpointTypes.EventListener;
|
||||
return { type: type, condition: { eventName: this._eventName } };
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.XHRBreakpoint = function(url)
|
||||
{
|
||||
this._url = url;
|
||||
}
|
||||
|
||||
WebInspector.XHRBreakpoint.prototype = {
|
||||
_enable: function()
|
||||
{
|
||||
InspectorBackend.setXHRBreakpoint(this._url);
|
||||
},
|
||||
|
||||
_disable: function()
|
||||
{
|
||||
InspectorBackend.removeXHRBreakpoint(this._url);
|
||||
},
|
||||
|
||||
_serializeToJSON: function()
|
||||
{
|
||||
var type = WebInspector.BreakpointManager.BreakpointTypes.XHR;
|
||||
return { type: type, condition: { url: this._url } };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
WebInspector.NativeBreakpointView = function(manager, id, enabled)
|
||||
{
|
||||
this._manager = manager;
|
||||
this._id = id;
|
||||
this._enabled = enabled;
|
||||
this._hit = false;
|
||||
}
|
||||
|
||||
WebInspector.NativeBreakpointView.prototype = {
|
||||
get enabled()
|
||||
{
|
||||
return this._enabled;
|
||||
},
|
||||
|
||||
set enabled(enabled)
|
||||
{
|
||||
this._manager._setBreakpointEnabled(this._id, enabled);
|
||||
this._enabled = enabled;
|
||||
this.dispatchEventToListeners("enable-changed");
|
||||
},
|
||||
|
||||
get hit()
|
||||
{
|
||||
return this._hit;
|
||||
},
|
||||
|
||||
set hit(hit)
|
||||
{
|
||||
this._hit = hit;
|
||||
this.dispatchEventToListeners("hit-state-changed");
|
||||
},
|
||||
|
||||
remove: function()
|
||||
{
|
||||
this._manager._removeBreakpoint(this._id);
|
||||
this._onRemove();
|
||||
this.dispatchEventToListeners("removed");
|
||||
},
|
||||
|
||||
_compare: function(x, y)
|
||||
{
|
||||
if (x !== y)
|
||||
return x < y ? -1 : 1;
|
||||
return 0;
|
||||
},
|
||||
|
||||
_onRemove: function()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.NativeBreakpointView.prototype.__proto__ = WebInspector.Object.prototype;
|
||||
|
||||
WebInspector.DOMBreakpointView = function(manager, id, enabled, node, type)
|
||||
{
|
||||
WebInspector.NativeBreakpointView.call(this, manager, id, enabled);
|
||||
this._node = node;
|
||||
this._nodeId = node.id;
|
||||
this._type = type;
|
||||
node.breakpoints[this._type] = this;
|
||||
}
|
||||
|
||||
WebInspector.DOMBreakpointView.prototype = {
|
||||
compareTo: function(other)
|
||||
{
|
||||
return this._compare(this._type, other._type);
|
||||
},
|
||||
|
||||
populateLabelElement: function(element)
|
||||
{
|
||||
// FIXME: this should belong to the view, not the manager.
|
||||
var linkifiedNode = WebInspector.panels.elements.linkifyNodeById(this._nodeId);
|
||||
linkifiedNode.addStyleClass("monospace");
|
||||
element.appendChild(linkifiedNode);
|
||||
var description = document.createElement("div");
|
||||
description.className = "source-text";
|
||||
description.textContent = WebInspector.domBreakpointTypeLabel(this._type);
|
||||
element.appendChild(description);
|
||||
},
|
||||
|
||||
populateStatusMessageElement: function(element, eventData)
|
||||
{
|
||||
var substitutions = [WebInspector.domBreakpointTypeLabel(this._type), WebInspector.panels.elements.linkifyNodeById(this._nodeId)];
|
||||
var formatters = {
|
||||
s: function(substitution)
|
||||
{
|
||||
return substitution;
|
||||
}
|
||||
};
|
||||
function append(a, b)
|
||||
{
|
||||
if (typeof b === "string")
|
||||
b = document.createTextNode(b);
|
||||
element.appendChild(b);
|
||||
}
|
||||
if (this._type === WebInspector.DOMBreakpointTypes.SubtreeModified) {
|
||||
var targetNode = WebInspector.panels.elements.linkifyNodeById(eventData.targetNodeId);
|
||||
if (eventData.insertion) {
|
||||
if (eventData.targetNodeId !== this._nodeId)
|
||||
WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to its descendant %s.", substitutions.concat(targetNode), formatters, "", append);
|
||||
else
|
||||
WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to that node.", substitutions, formatters, "", append);
|
||||
} else
|
||||
WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because its descendant %s was removed.", substitutions.concat(targetNode), formatters, "", append);
|
||||
} else
|
||||
WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s.", substitutions, formatters, "", append);
|
||||
},
|
||||
|
||||
_onRemove: function()
|
||||
{
|
||||
delete this._node.breakpoints[this._type];
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DOMBreakpointView.prototype.__proto__ = WebInspector.NativeBreakpointView.prototype;
|
||||
|
||||
WebInspector.EventListenerBreakpointView = function(manager, id, enabled, eventName)
|
||||
{
|
||||
WebInspector.NativeBreakpointView.call(this, manager, id, enabled);
|
||||
this._eventName = eventName;
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBreakpointView.eventNameForUI = function(eventName)
|
||||
{
|
||||
if (!WebInspector.EventListenerBreakpointView._eventNamesForUI) {
|
||||
WebInspector.EventListenerBreakpointView._eventNamesForUI = {
|
||||
"instrumentation:setTimer": WebInspector.UIString("Set Timer"),
|
||||
"instrumentation:clearTimer": WebInspector.UIString("Clear Timer"),
|
||||
"instrumentation:timerFired": WebInspector.UIString("Timer Fired")
|
||||
};
|
||||
}
|
||||
return WebInspector.EventListenerBreakpointView._eventNamesForUI[eventName] || eventName.substring(eventName.indexOf(":") + 1);
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBreakpointView.prototype = {
|
||||
get eventName()
|
||||
{
|
||||
return this._eventName;
|
||||
},
|
||||
|
||||
compareTo: function(other)
|
||||
{
|
||||
return this._compare(this._eventName, other._eventName);
|
||||
},
|
||||
|
||||
populateLabelElement: function(element)
|
||||
{
|
||||
element.appendChild(document.createTextNode(this._uiEventName()));
|
||||
},
|
||||
|
||||
populateStatusMessageElement: function(element, eventData)
|
||||
{
|
||||
var status = WebInspector.UIString("Paused on a \"%s\" Event Listener.", this._uiEventName());
|
||||
element.appendChild(document.createTextNode(status));
|
||||
},
|
||||
|
||||
_uiEventName: function()
|
||||
{
|
||||
return WebInspector.EventListenerBreakpointView.eventNameForUI(this._eventName);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBreakpointView.prototype.__proto__ = WebInspector.NativeBreakpointView.prototype;
|
||||
|
||||
WebInspector.XHRBreakpointView = function(manager, id, enabled, url)
|
||||
{
|
||||
WebInspector.NativeBreakpointView.call(this, manager, id, enabled);
|
||||
this._url = url;
|
||||
}
|
||||
|
||||
WebInspector.XHRBreakpointView.prototype = {
|
||||
compareTo: function(other)
|
||||
{
|
||||
return this._compare(this._url, other._url);
|
||||
},
|
||||
|
||||
populateEditElement: function(element)
|
||||
{
|
||||
element.textContent = this._url;
|
||||
},
|
||||
|
||||
populateLabelElement: function(element)
|
||||
{
|
||||
var label;
|
||||
if (!this._url.length)
|
||||
label = WebInspector.UIString("Any XHR");
|
||||
else
|
||||
label = WebInspector.UIString("URL contains \"%s\"", this._url);
|
||||
element.appendChild(document.createTextNode(label));
|
||||
element.addStyleClass("cursor-auto");
|
||||
},
|
||||
|
||||
populateStatusMessageElement: function(element)
|
||||
{
|
||||
var status = WebInspector.UIString("Paused on a XMLHttpRequest.");
|
||||
element.appendChild(document.createTextNode(status));
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.XHRBreakpointView.prototype.__proto__ = WebInspector.NativeBreakpointView.prototype;
|
||||
|
||||
WebInspector.DOMBreakpointTypes = {
|
||||
SubtreeModified: 0,
|
||||
AttributeModified: 1,
|
||||
NodeRemoved: 2
|
||||
};
|
||||
|
||||
WebInspector.domBreakpointTypeLabel = function(type)
|
||||
{
|
||||
if (!WebInspector._DOMBreakpointTypeLabels) {
|
||||
WebInspector._DOMBreakpointTypeLabels = {};
|
||||
WebInspector._DOMBreakpointTypeLabels[WebInspector.DOMBreakpointTypes.SubtreeModified] = WebInspector.UIString("Subtree Modified");
|
||||
WebInspector._DOMBreakpointTypeLabels[WebInspector.DOMBreakpointTypes.AttributeModified] = WebInspector.UIString("Attribute Modified");
|
||||
WebInspector._DOMBreakpointTypeLabels[WebInspector.DOMBreakpointTypes.NodeRemoved] = WebInspector.UIString("Node Removed");
|
||||
}
|
||||
return WebInspector._DOMBreakpointTypeLabels[type];
|
||||
}
|
||||
|
||||
WebInspector.domBreakpointTypeContextMenuLabel = function(type)
|
||||
{
|
||||
if (!WebInspector._DOMBreakpointTypeContextMenuLabels) {
|
||||
WebInspector._DOMBreakpointTypeContextMenuLabels = {};
|
||||
WebInspector._DOMBreakpointTypeContextMenuLabels[WebInspector.DOMBreakpointTypes.SubtreeModified] = WebInspector.UIString("Break on Subtree Modifications");
|
||||
WebInspector._DOMBreakpointTypeContextMenuLabels[WebInspector.DOMBreakpointTypes.AttributeModified] = WebInspector.UIString("Break on Attributes Modifications");
|
||||
WebInspector._DOMBreakpointTypeContextMenuLabels[WebInspector.DOMBreakpointTypes.NodeRemoved] = WebInspector.UIString("Break on Node Removal");
|
||||
}
|
||||
return WebInspector._DOMBreakpointTypeContextMenuLabels[type];
|
||||
}
|
623
node_modules/weinre/web/client/BreakpointsSidebarPane.js
generated
vendored
Normal file
@ -0,0 +1,623 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.JavaScriptBreakpointsSidebarPane = function(title)
|
||||
{
|
||||
WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints"));
|
||||
|
||||
this.listElement = document.createElement("ol");
|
||||
this.listElement.className = "breakpoint-list";
|
||||
|
||||
this.emptyElement = document.createElement("div");
|
||||
this.emptyElement.className = "info";
|
||||
this.emptyElement.textContent = WebInspector.UIString("No Breakpoints");
|
||||
|
||||
this.bodyElement.appendChild(this.emptyElement);
|
||||
|
||||
this._items = {};
|
||||
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this);
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointRemoved, this._breakpointRemoved, this);
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this);
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
|
||||
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
|
||||
WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.ProjectChanged, this._projectChanged, this);
|
||||
}
|
||||
|
||||
WebInspector.JavaScriptBreakpointsSidebarPane.prototype = {
|
||||
_breakpointAdded: function(event)
|
||||
{
|
||||
var breakpoint = event.data;
|
||||
var breakpointId = breakpoint.id;
|
||||
|
||||
if (breakpoint.url && !WebInspector.debuggerModel.scriptsForURL(breakpoint.url).length)
|
||||
return;
|
||||
|
||||
var element = document.createElement("li");
|
||||
|
||||
var checkbox = document.createElement("input");
|
||||
checkbox.className = "checkbox-elem";
|
||||
checkbox.type = "checkbox";
|
||||
checkbox.checked = breakpoint.enabled;
|
||||
checkbox.addEventListener("click", this._breakpointItemCheckboxClicked.bind(this, breakpointId), false);
|
||||
element.appendChild(checkbox);
|
||||
|
||||
var label = document.createElement("span");
|
||||
element.appendChild(label);
|
||||
|
||||
element._data = breakpoint;
|
||||
var currentElement = this.listElement.firstChild;
|
||||
while (currentElement) {
|
||||
if (currentElement._data && this._compareBreakpoints(currentElement._data, element._data) > 0)
|
||||
break;
|
||||
currentElement = currentElement.nextSibling;
|
||||
}
|
||||
this._addListElement(element, currentElement);
|
||||
|
||||
element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this, breakpointId), true);
|
||||
|
||||
this._setupBreakpointElement(breakpoint, element);
|
||||
|
||||
var breakpointItem = {};
|
||||
breakpointItem.element = element;
|
||||
breakpointItem.checkbox = checkbox;
|
||||
this._items[breakpointId] = breakpointItem;
|
||||
|
||||
if (!this.expanded)
|
||||
this.expanded = true;
|
||||
},
|
||||
|
||||
_breakpointRemoved: function(event)
|
||||
{
|
||||
var breakpointId = event.data;
|
||||
var breakpointItem = this._items[breakpointId];
|
||||
if (breakpointItem) {
|
||||
delete this._items[breakpointId];
|
||||
this._removeListElement(breakpointItem.element);
|
||||
}
|
||||
},
|
||||
|
||||
_breakpointResolved: function(event)
|
||||
{
|
||||
var breakpoint = event.data;
|
||||
this._breakpointRemoved({ data: breakpoint.id });
|
||||
this._breakpointAdded({ data: breakpoint });
|
||||
},
|
||||
|
||||
_parsedScriptSource: function(event)
|
||||
{
|
||||
var url = event.data.sourceURL;
|
||||
var breakpoints = WebInspector.debuggerModel.breakpoints;
|
||||
for (var id in breakpoints) {
|
||||
if (!(id in this._items))
|
||||
this._breakpointAdded({ data: breakpoints[id] });
|
||||
}
|
||||
},
|
||||
|
||||
_breakpointEnableChanged: function(enabled, event)
|
||||
{
|
||||
var breakpointId = event.data;
|
||||
var breakpointItem = this._items[breakpointId];
|
||||
if (breakpointItem)
|
||||
breakpointItem.checkbox.checked = enabled;
|
||||
},
|
||||
|
||||
_breakpointItemCheckboxClicked: function(breakpointId, event)
|
||||
{
|
||||
var breakpoint = WebInspector.debuggerModel.breakpointForId(breakpointId);
|
||||
WebInspector.debuggerModel.updateBreakpoint(breakpointId, breakpoint.condition, event.target.checked);
|
||||
|
||||
// Breakpoint element may have it's own click handler.
|
||||
event.stopPropagation();
|
||||
},
|
||||
|
||||
_contextMenuEventFired: function(breakpointId, event)
|
||||
{
|
||||
var contextMenu = new WebInspector.ContextMenu();
|
||||
contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), this._removeBreakpoint.bind(this, breakpointId));
|
||||
contextMenu.show(event);
|
||||
},
|
||||
|
||||
_debuggerPaused: function(event)
|
||||
{
|
||||
var breakpoint = event.data.breakpoint;
|
||||
if (!breakpoint)
|
||||
return;
|
||||
var breakpointItem = this._items[breakpoint.id];
|
||||
if (!breakpointItem)
|
||||
return;
|
||||
breakpointItem.element.addStyleClass("breakpoint-hit");
|
||||
this._lastHitBreakpointItem = breakpointItem;
|
||||
},
|
||||
|
||||
_debuggerResumed: function()
|
||||
{
|
||||
if (this._lastHitBreakpointItem) {
|
||||
this._lastHitBreakpointItem.element.removeStyleClass("breakpoint-hit");
|
||||
delete this._lastHitBreakpointItem;
|
||||
}
|
||||
},
|
||||
|
||||
_addListElement: function(element, beforeElement)
|
||||
{
|
||||
if (beforeElement)
|
||||
this.listElement.insertBefore(element, beforeElement);
|
||||
else {
|
||||
if (!this.listElement.firstChild) {
|
||||
this.bodyElement.removeChild(this.emptyElement);
|
||||
this.bodyElement.appendChild(this.listElement);
|
||||
}
|
||||
this.listElement.appendChild(element);
|
||||
}
|
||||
},
|
||||
|
||||
_removeListElement: function(element)
|
||||
{
|
||||
this.listElement.removeChild(element);
|
||||
if (!this.listElement.firstChild) {
|
||||
this.bodyElement.removeChild(this.listElement);
|
||||
this.bodyElement.appendChild(this.emptyElement);
|
||||
}
|
||||
},
|
||||
|
||||
_projectChanged: function()
|
||||
{
|
||||
this.listElement.removeChildren();
|
||||
if (this.listElement.parentElement) {
|
||||
this.bodyElement.removeChild(this.listElement);
|
||||
this.bodyElement.appendChild(this.emptyElement);
|
||||
}
|
||||
this._items = {};
|
||||
},
|
||||
|
||||
_compare: function(x, y)
|
||||
{
|
||||
if (x !== y)
|
||||
return x < y ? -1 : 1;
|
||||
return 0;
|
||||
},
|
||||
|
||||
_compareBreakpoints: function(b1, b2)
|
||||
{
|
||||
return this._compare(b1.url, b2.url) || this._compare(b1.lineNumber, b2.lineNumber);
|
||||
},
|
||||
|
||||
_setupBreakpointElement: function(data, element)
|
||||
{
|
||||
var sourceID;
|
||||
var lineNumber = data.lineNumber;
|
||||
if (data.locations.length) {
|
||||
sourceID = data.locations[0].sourceID;
|
||||
lineNumber = data.locations[0].lineNumber;
|
||||
}
|
||||
|
||||
var displayName = data.url ? WebInspector.displayNameForURL(data.url) : WebInspector.UIString("(program)");
|
||||
var labelElement = document.createTextNode(displayName + ":" + (lineNumber + 1));
|
||||
element.appendChild(labelElement);
|
||||
|
||||
var sourceTextElement = document.createElement("div");
|
||||
sourceTextElement.className = "source-text monospace";
|
||||
element.appendChild(sourceTextElement);
|
||||
|
||||
if (sourceID) {
|
||||
function didGetSourceLine(text)
|
||||
{
|
||||
sourceTextElement.textContent = text;
|
||||
}
|
||||
var script = WebInspector.debuggerModel.scriptForSourceID(sourceID);
|
||||
script.sourceLine(lineNumber, didGetSourceLine.bind(this));
|
||||
}
|
||||
|
||||
element.addStyleClass("cursor-pointer");
|
||||
var clickHandler = WebInspector.panels.scripts.showSourceLine.bind(WebInspector.panels.scripts, data.url, lineNumber + 1);
|
||||
element.addEventListener("click", clickHandler, false);
|
||||
},
|
||||
|
||||
_removeBreakpoint: function(breakpointId)
|
||||
{
|
||||
WebInspector.debuggerModel.removeBreakpoint(breakpointId);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.JavaScriptBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
|
||||
|
||||
WebInspector.NativeBreakpointsSidebarPane = function(title)
|
||||
{
|
||||
WebInspector.SidebarPane.call(this, title);
|
||||
|
||||
this.listElement = document.createElement("ol");
|
||||
this.listElement.className = "breakpoint-list";
|
||||
|
||||
this.emptyElement = document.createElement("div");
|
||||
this.emptyElement.className = "info";
|
||||
this.emptyElement.textContent = WebInspector.UIString("No Breakpoints");
|
||||
|
||||
this.bodyElement.appendChild(this.emptyElement);
|
||||
|
||||
WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.ProjectChanged, this._projectChanged, this);
|
||||
}
|
||||
|
||||
WebInspector.NativeBreakpointsSidebarPane.prototype = {
|
||||
addBreakpointItem: function(breakpointItem)
|
||||
{
|
||||
var element = breakpointItem.element;
|
||||
element._breakpointItem = breakpointItem;
|
||||
|
||||
breakpointItem.addEventListener("breakpoint-hit", this.expand, this);
|
||||
breakpointItem.addEventListener("removed", this._removeListElement.bind(this, element), this);
|
||||
|
||||
var currentElement = this.listElement.firstChild;
|
||||
while (currentElement) {
|
||||
if (currentElement._breakpointItem && currentElement._breakpointItem.compareTo(element._breakpointItem) > 0)
|
||||
break;
|
||||
currentElement = currentElement.nextSibling;
|
||||
}
|
||||
this._addListElement(element, currentElement);
|
||||
|
||||
if (breakpointItem.click) {
|
||||
element.addStyleClass("cursor-pointer");
|
||||
element.addEventListener("click", breakpointItem.click.bind(breakpointItem), false);
|
||||
}
|
||||
element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this, breakpointItem), true);
|
||||
},
|
||||
|
||||
_contextMenuEventFired: function(breakpointItem, event)
|
||||
{
|
||||
var contextMenu = new WebInspector.ContextMenu();
|
||||
contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), breakpointItem.remove.bind(breakpointItem));
|
||||
contextMenu.show(event);
|
||||
},
|
||||
|
||||
_addListElement: function(element, beforeElement)
|
||||
{
|
||||
if (beforeElement)
|
||||
this.listElement.insertBefore(element, beforeElement);
|
||||
else {
|
||||
if (!this.listElement.firstChild) {
|
||||
this.bodyElement.removeChild(this.emptyElement);
|
||||
this.bodyElement.appendChild(this.listElement);
|
||||
}
|
||||
this.listElement.appendChild(element);
|
||||
}
|
||||
},
|
||||
|
||||
_removeListElement: function(element)
|
||||
{
|
||||
this.listElement.removeChild(element);
|
||||
if (!this.listElement.firstChild) {
|
||||
this.bodyElement.removeChild(this.listElement);
|
||||
this.bodyElement.appendChild(this.emptyElement);
|
||||
}
|
||||
},
|
||||
|
||||
_projectChanged: function()
|
||||
{
|
||||
this.listElement.removeChildren();
|
||||
if (this.listElement.parentElement) {
|
||||
this.bodyElement.removeChild(this.listElement);
|
||||
this.bodyElement.appendChild(this.emptyElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.NativeBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
|
||||
|
||||
WebInspector.XHRBreakpointsSidebarPane = function()
|
||||
{
|
||||
WebInspector.NativeBreakpointsSidebarPane.call(this, WebInspector.UIString("XHR Breakpoints"));
|
||||
|
||||
function addButtonClicked(event)
|
||||
{
|
||||
event.stopPropagation();
|
||||
this._startEditingBreakpoint(null);
|
||||
}
|
||||
|
||||
var addButton = document.createElement("button");
|
||||
addButton.className = "add";
|
||||
addButton.addEventListener("click", addButtonClicked.bind(this), false);
|
||||
this.titleElement.appendChild(addButton);
|
||||
}
|
||||
|
||||
WebInspector.XHRBreakpointsSidebarPane.prototype = {
|
||||
addBreakpointItem: function(breakpointItem)
|
||||
{
|
||||
WebInspector.NativeBreakpointsSidebarPane.prototype.addBreakpointItem.call(this, breakpointItem);
|
||||
breakpointItem._labelElement.addEventListener("dblclick", this._startEditingBreakpoint.bind(this, breakpointItem), false);
|
||||
},
|
||||
|
||||
_startEditingBreakpoint: function(breakpointItem)
|
||||
{
|
||||
if (this._editingBreakpoint)
|
||||
return;
|
||||
this._editingBreakpoint = true;
|
||||
|
||||
if (!this.expanded)
|
||||
this.expanded = true;
|
||||
|
||||
var inputElement = document.createElement("span");
|
||||
inputElement.className = "breakpoint-condition editing";
|
||||
if (breakpointItem) {
|
||||
breakpointItem.populateEditElement(inputElement);
|
||||
this.listElement.insertBefore(inputElement, breakpointItem.element);
|
||||
breakpointItem.element.addStyleClass("hidden");
|
||||
} else
|
||||
this._addListElement(inputElement, this.listElement.firstChild);
|
||||
|
||||
var commitHandler = this._hideEditBreakpointDialog.bind(this, inputElement, true, breakpointItem);
|
||||
var cancelHandler = this._hideEditBreakpointDialog.bind(this, inputElement, false, breakpointItem);
|
||||
WebInspector.startEditing(inputElement, {
|
||||
commitHandler: commitHandler,
|
||||
cancelHandler: cancelHandler
|
||||
});
|
||||
},
|
||||
|
||||
_hideEditBreakpointDialog: function(inputElement, accept, breakpointItem)
|
||||
{
|
||||
this._removeListElement(inputElement);
|
||||
this._editingBreakpoint = false;
|
||||
if (accept) {
|
||||
if (breakpointItem)
|
||||
breakpointItem.remove();
|
||||
WebInspector.breakpointManager.createXHRBreakpoint(inputElement.textContent.toLowerCase());
|
||||
} else if (breakpointItem)
|
||||
breakpointItem.element.removeStyleClass("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.XHRBreakpointsSidebarPane.prototype.__proto__ = WebInspector.NativeBreakpointsSidebarPane.prototype;
|
||||
|
||||
WebInspector.BreakpointItem = function(breakpoint)
|
||||
{
|
||||
this._breakpoint = breakpoint;
|
||||
|
||||
this._element = document.createElement("li");
|
||||
|
||||
var checkboxElement = document.createElement("input");
|
||||
checkboxElement.className = "checkbox-elem";
|
||||
checkboxElement.type = "checkbox";
|
||||
checkboxElement.checked = this._breakpoint.enabled;
|
||||
checkboxElement.addEventListener("click", this._checkboxClicked.bind(this), false);
|
||||
this._element.appendChild(checkboxElement);
|
||||
|
||||
this._createLabelElement();
|
||||
|
||||
this._breakpoint.addEventListener("enable-changed", this._enableChanged, this);
|
||||
this._breakpoint.addEventListener("hit-state-changed", this._hitStateChanged, this);
|
||||
this._breakpoint.addEventListener("label-changed", this._labelChanged, this);
|
||||
this._breakpoint.addEventListener("removed", this.dispatchEventToListeners.bind(this, "removed"));
|
||||
if (breakpoint.click)
|
||||
this.click = breakpoint.click.bind(breakpoint);
|
||||
}
|
||||
|
||||
WebInspector.BreakpointItem.prototype = {
|
||||
get element()
|
||||
{
|
||||
return this._element;
|
||||
},
|
||||
|
||||
compareTo: function(other)
|
||||
{
|
||||
return this._breakpoint.compareTo(other._breakpoint);
|
||||
},
|
||||
|
||||
populateEditElement: function(element)
|
||||
{
|
||||
this._breakpoint.populateEditElement(element);
|
||||
},
|
||||
|
||||
remove: function()
|
||||
{
|
||||
this._breakpoint.remove();
|
||||
},
|
||||
|
||||
_checkboxClicked: function(event)
|
||||
{
|
||||
this._breakpoint.enabled = !this._breakpoint.enabled;
|
||||
|
||||
// Breakpoint element may have it's own click handler.
|
||||
event.stopPropagation();
|
||||
},
|
||||
|
||||
_enableChanged: function(event)
|
||||
{
|
||||
var checkbox = this._element.firstChild;
|
||||
checkbox.checked = this._breakpoint.enabled;
|
||||
},
|
||||
|
||||
_hitStateChanged: function(event)
|
||||
{
|
||||
if (event.target.hit) {
|
||||
this._element.addStyleClass("breakpoint-hit");
|
||||
this.dispatchEventToListeners("breakpoint-hit");
|
||||
} else
|
||||
this._element.removeStyleClass("breakpoint-hit");
|
||||
},
|
||||
|
||||
_labelChanged: function(event)
|
||||
{
|
||||
this._element.removeChild(this._labelElement);
|
||||
this._createLabelElement();
|
||||
},
|
||||
|
||||
_createLabelElement: function()
|
||||
{
|
||||
this._labelElement = document.createElement("span");
|
||||
this._breakpoint.populateLabelElement(this._labelElement);
|
||||
this._element.appendChild(this._labelElement);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.BreakpointItem.prototype.__proto__ = WebInspector.Object.prototype;
|
||||
|
||||
WebInspector.EventListenerBreakpointsSidebarPane = function()
|
||||
{
|
||||
WebInspector.SidebarPane.call(this, WebInspector.UIString("Event Listener Breakpoints"));
|
||||
|
||||
this.categoriesElement = document.createElement("ol");
|
||||
this.categoriesElement.tabIndex = 0;
|
||||
this.categoriesElement.addStyleClass("properties-tree event-listener-breakpoints");
|
||||
this.categoriesTreeOutline = new TreeOutline(this.categoriesElement);
|
||||
this.bodyElement.appendChild(this.categoriesElement);
|
||||
|
||||
WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.ProjectChanged, this._projectChanged, this);
|
||||
WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.EventListenerBreakpointAdded, this._breakpointAdded, this);
|
||||
|
||||
this._breakpointItems = {};
|
||||
this._createCategory(WebInspector.UIString("Keyboard"), "listener", ["keydown", "keyup", "keypress", "textInput"]);
|
||||
this._createCategory(WebInspector.UIString("Mouse"), "listener", ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"]);
|
||||
// FIXME: uncomment following once inspector stops being drop targer in major ports.
|
||||
// Otherwise, inspector page reacts on drop event and tries to load the event data.
|
||||
// this._createCategory(WebInspector.UIString("Drag"), "listener", ["drag", "drop", "dragstart", "dragend", "dragenter", "dragleave", "dragover"]);
|
||||
this._createCategory(WebInspector.UIString("Control"), "listener", ["resize", "scroll", "zoom", "focus", "blur", "select", "change", "submit", "reset"]);
|
||||
this._createCategory(WebInspector.UIString("Clipboard"), "listener", ["copy", "cut", "paste", "beforecopy", "beforecut", "beforepaste"]);
|
||||
this._createCategory(WebInspector.UIString("Load"), "listener", ["load", "unload", "abort", "error"]);
|
||||
this._createCategory(WebInspector.UIString("DOM Mutation"), "listener", ["DOMActivate", "DOMFocusIn", "DOMFocusOut", "DOMAttrModified", "DOMCharacterDataModified", "DOMNodeInserted", "DOMNodeInsertedIntoDocument", "DOMNodeRemoved", "DOMNodeRemovedFromDocument", "DOMSubtreeModified", "DOMContentLoaded"]);
|
||||
this._createCategory(WebInspector.UIString("Device"), "listener", ["deviceorientation", "devicemotion"]);
|
||||
this._createCategory(WebInspector.UIString("Timer"), "instrumentation", ["setTimer", "clearTimer", "timerFired"]);
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBreakpointsSidebarPane.prototype = {
|
||||
_createCategory: function(name, type, eventNames)
|
||||
{
|
||||
var categoryItem = {};
|
||||
categoryItem.element = new TreeElement(name);
|
||||
this.categoriesTreeOutline.appendChild(categoryItem.element);
|
||||
categoryItem.element.listItemElement.addStyleClass("event-category");
|
||||
categoryItem.element.selectable = true;
|
||||
|
||||
categoryItem.checkbox = this._createCheckbox(categoryItem.element);
|
||||
categoryItem.checkbox.addEventListener("click", this._categoryCheckboxClicked.bind(this, categoryItem), true);
|
||||
|
||||
categoryItem.children = {};
|
||||
for (var i = 0; i < eventNames.length; ++i) {
|
||||
var eventName = type + ":" + eventNames[i];
|
||||
|
||||
var breakpointItem = {};
|
||||
var title = WebInspector.EventListenerBreakpointView.eventNameForUI(eventName);
|
||||
breakpointItem.element = new TreeElement(title);
|
||||
categoryItem.element.appendChild(breakpointItem.element);
|
||||
var hitMarker = document.createElement("div");
|
||||
hitMarker.className = "breakpoint-hit-marker";
|
||||
breakpointItem.element.listItemElement.appendChild(hitMarker);
|
||||
breakpointItem.element.listItemElement.addStyleClass("source-code");
|
||||
breakpointItem.element.selectable = true;
|
||||
|
||||
breakpointItem.checkbox = this._createCheckbox(breakpointItem.element);
|
||||
breakpointItem.checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(this, breakpointItem), true);
|
||||
breakpointItem.parent = categoryItem;
|
||||
breakpointItem.eventName = eventName;
|
||||
|
||||
this._breakpointItems[eventName] = breakpointItem;
|
||||
categoryItem.children[eventName] = breakpointItem;
|
||||
}
|
||||
},
|
||||
|
||||
_createCheckbox: function(treeElement)
|
||||
{
|
||||
var checkbox = document.createElement("input");
|
||||
checkbox.className = "checkbox-elem";
|
||||
checkbox.type = "checkbox";
|
||||
treeElement.listItemElement.insertBefore(checkbox, treeElement.listItemElement.firstChild);
|
||||
return checkbox;
|
||||
},
|
||||
|
||||
_categoryCheckboxClicked: function(categoryItem)
|
||||
{
|
||||
var checked = categoryItem.checkbox.checked;
|
||||
for (var eventName in categoryItem.children) {
|
||||
var breakpointItem = categoryItem.children[eventName];
|
||||
if (breakpointItem.checkbox.checked !== checked) {
|
||||
breakpointItem.checkbox.checked = checked;
|
||||
this._breakpointCheckboxClicked(breakpointItem);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_breakpointCheckboxClicked: function(breakpointItem)
|
||||
{
|
||||
if (breakpointItem.checkbox.checked)
|
||||
WebInspector.breakpointManager.createEventListenerBreakpoint(breakpointItem.eventName);
|
||||
else
|
||||
breakpointItem.breakpoint.remove();
|
||||
},
|
||||
|
||||
_breakpointAdded: function(event)
|
||||
{
|
||||
var breakpoint = event.data;
|
||||
|
||||
var breakpointItem = this._breakpointItems[breakpoint.eventName];
|
||||
breakpointItem.breakpoint = breakpoint;
|
||||
breakpoint.addEventListener("hit-state-changed", this._breakpointHitStateChanged.bind(this, breakpointItem));
|
||||
breakpoint.addEventListener("removed", this._breakpointRemoved.bind(this, breakpointItem));
|
||||
breakpointItem.checkbox.checked = true;
|
||||
this._updateCategoryCheckbox(breakpointItem);
|
||||
},
|
||||
|
||||
_breakpointHitStateChanged: function(breakpointItem, event)
|
||||
{
|
||||
if (event.target.hit) {
|
||||
this.expanded = true;
|
||||
var categoryItem = breakpointItem.parent;
|
||||
categoryItem.element.expand();
|
||||
breakpointItem.element.listItemElement.addStyleClass("breakpoint-hit");
|
||||
} else
|
||||
breakpointItem.element.listItemElement.removeStyleClass("breakpoint-hit");
|
||||
},
|
||||
|
||||
_breakpointRemoved: function(breakpointItem)
|
||||
{
|
||||
breakpointItem.breakpoint = null;
|
||||
breakpointItem.checkbox.checked = false;
|
||||
this._updateCategoryCheckbox(breakpointItem);
|
||||
},
|
||||
|
||||
_updateCategoryCheckbox: function(breakpointItem)
|
||||
{
|
||||
var categoryItem = breakpointItem.parent;
|
||||
var hasEnabled = false, hasDisabled = false;
|
||||
for (var eventName in categoryItem.children) {
|
||||
var breakpointItem = categoryItem.children[eventName];
|
||||
if (breakpointItem.checkbox.checked)
|
||||
hasEnabled = true;
|
||||
else
|
||||
hasDisabled = true;
|
||||
}
|
||||
categoryItem.checkbox.checked = hasEnabled;
|
||||
categoryItem.checkbox.indeterminate = hasEnabled && hasDisabled;
|
||||
},
|
||||
|
||||
_projectChanged: function()
|
||||
{
|
||||
for (var eventName in this._breakpointItems) {
|
||||
var breakpointItem = this._breakpointItems[eventName];
|
||||
breakpointItem.breakpoint = null;
|
||||
breakpointItem.checkbox.checked = false;
|
||||
this._updateCategoryCheckbox(breakpointItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
|
125
node_modules/weinre/web/client/CSSCompletions.js
generated
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Nikita Vasilyev. All rights reserved.
|
||||
* Copyright (C) 2010 Joseph Pecoraro. All rights reserved.
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.CSSCompletions = function(values, acceptEmptyPrefix)
|
||||
{
|
||||
this._values = values.slice();
|
||||
this._values.sort();
|
||||
this._acceptEmptyPrefix = acceptEmptyPrefix;
|
||||
}
|
||||
|
||||
WebInspector.CSSCompletions.prototype = {
|
||||
startsWith: function(prefix)
|
||||
{
|
||||
var firstIndex = this._firstIndexOfPrefix(prefix);
|
||||
if (firstIndex === -1)
|
||||
return [];
|
||||
|
||||
var results = [];
|
||||
while (firstIndex < this._values.length && this._values[firstIndex].indexOf(prefix) === 0)
|
||||
results.push(this._values[firstIndex++]);
|
||||
return results;
|
||||
},
|
||||
|
||||
firstStartsWith: function(prefix)
|
||||
{
|
||||
var foundIndex = this._firstIndexOfPrefix(prefix);
|
||||
return (foundIndex === -1 ? "" : this._values[foundIndex]);
|
||||
},
|
||||
|
||||
_firstIndexOfPrefix: function(prefix)
|
||||
{
|
||||
if (!this._values.length)
|
||||
return -1;
|
||||
if (!prefix)
|
||||
return this._acceptEmptyPrefix ? 0 : -1;
|
||||
|
||||
var maxIndex = this._values.length - 1;
|
||||
var minIndex = 0;
|
||||
var foundIndex;
|
||||
|
||||
do {
|
||||
var middleIndex = (maxIndex + minIndex) >> 1;
|
||||
if (this._values[middleIndex].indexOf(prefix) === 0) {
|
||||
foundIndex = middleIndex;
|
||||
break;
|
||||
}
|
||||
if (this._values[middleIndex] < prefix)
|
||||
minIndex = middleIndex + 1;
|
||||
else
|
||||
maxIndex = middleIndex - 1;
|
||||
} while (minIndex <= maxIndex);
|
||||
|
||||
if (foundIndex === undefined)
|
||||
return -1;
|
||||
|
||||
while (foundIndex && this._values[foundIndex - 1].indexOf(prefix) === 0)
|
||||
foundIndex--;
|
||||
|
||||
return foundIndex;
|
||||
},
|
||||
|
||||
keySet: function()
|
||||
{
|
||||
return this._values.keySet();
|
||||
},
|
||||
|
||||
next: function(str, prefix)
|
||||
{
|
||||
return this._closest(str, prefix, 1);
|
||||
},
|
||||
|
||||
previous: function(str, prefix)
|
||||
{
|
||||
return this._closest(str, prefix, -1);
|
||||
},
|
||||
|
||||
_closest: function(str, prefix, shift)
|
||||
{
|
||||
if (!str)
|
||||
return "";
|
||||
|
||||
var index = this._values.indexOf(str);
|
||||
if (index === -1)
|
||||
return "";
|
||||
|
||||
if (!prefix) {
|
||||
index = (index + this._values.length + shift) % this._values.length;
|
||||
return this._values[index];
|
||||
}
|
||||
|
||||
var propertiesWithPrefix = this.startsWith(prefix);
|
||||
var j = propertiesWithPrefix.indexOf(str);
|
||||
j = (j + propertiesWithPrefix.length + shift) % propertiesWithPrefix.length;
|
||||
return propertiesWithPrefix[j];
|
||||
}
|
||||
}
|
438
node_modules/weinre/web/client/CSSKeywordCompletions.js
generated
vendored
Normal file
@ -0,0 +1,438 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.CSSKeywordCompletions = {
|
||||
forProperty: function(propertyName)
|
||||
{
|
||||
var acceptedKeywords = ["initial"];
|
||||
if (propertyName in this._propertyKeywordMap)
|
||||
acceptedKeywords = acceptedKeywords.concat(this._propertyKeywordMap[propertyName]);
|
||||
if (propertyName in this._colorAwareProperties)
|
||||
acceptedKeywords = acceptedKeywords.concat(WebInspector.CSSKeywordCompletions._colors);
|
||||
if (propertyName in WebInspector.StylesSidebarPane.InheritedProperties)
|
||||
acceptedKeywords.push("inherit");
|
||||
return new WebInspector.CSSCompletions(acceptedKeywords, true);
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.CSSKeywordCompletions._colors = [
|
||||
"aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red",
|
||||
"silver", "teal", "white", "yellow", "transparent", "currentcolor", "grey", "aliceblue", "antiquewhite",
|
||||
"aquamarine", "azure", "beige", "bisque", "blanchedalmond", "blueviolet", "brown", "burlywood", "cadetblue",
|
||||
"chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan",
|
||||
"darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange",
|
||||
"darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkslategrey",
|
||||
"darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick",
|
||||
"floralwhite", "forestgreen", "gainsboro", "ghostwhite", "gold", "goldenrod", "greenyellow", "honeydew", "hotpink",
|
||||
"indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
|
||||
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
|
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow",
|
||||
"limegreen", "linen", "magenta", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen",
|
||||
"mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream",
|
||||
"mistyrose", "moccasin", "navajowhite", "oldlace", "olivedrab", "orangered", "orchid", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "rosybrown",
|
||||
"royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "skyblue", "slateblue",
|
||||
"slategray", "slategrey", "snow", "springgreen", "steelblue", "tan", "thistle", "tomato", "turquoise", "violet",
|
||||
"wheat", "whitesmoke", "yellowgreen"
|
||||
],
|
||||
|
||||
WebInspector.CSSKeywordCompletions._colorAwareProperties = [
|
||||
"background", "background-color", "border", "border-color", "border-top", "border-right", "border-bottom",
|
||||
"border-left", "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", "color",
|
||||
"outline", "outline-color", "text-line-through", "text-line-through-color", "text-overline", "text-overline-color",
|
||||
"text-shadow", "text-underline", "text-underline-color", "-webkit-text-emphasis", "-webkit-text-emphasis-color"
|
||||
].keySet();
|
||||
|
||||
WebInspector.CSSKeywordCompletions._propertyKeywordMap = {
|
||||
"table-layout": [
|
||||
"auto", "fixed"
|
||||
],
|
||||
"visibility": [
|
||||
"hidden", "visible", "collapse"
|
||||
],
|
||||
"background-repeat": [
|
||||
"repeat", "repeat-x", "repeat-y", "no-repeat", "space", "round"
|
||||
],
|
||||
"text-underline": [
|
||||
"none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
|
||||
],
|
||||
"content": [
|
||||
"list-item", "close-quote", "no-close-quote", "no-open-quote", "open-quote"
|
||||
],
|
||||
"list-style-image": [
|
||||
"none"
|
||||
],
|
||||
"clear": [
|
||||
"none", "left", "right", "both"
|
||||
],
|
||||
"text-underline-mode": [
|
||||
"continuous", "skip-white-space"
|
||||
],
|
||||
"overflow-x": [
|
||||
"hidden", "auto", "visible", "overlay", "scroll"
|
||||
],
|
||||
"stroke-linejoin": [
|
||||
"round", "miter", "bevel"
|
||||
],
|
||||
"baseline-shift": [
|
||||
"baseline", "sub", "super"
|
||||
],
|
||||
"border-bottom-width": [
|
||||
"medium", "thick", "thin"
|
||||
],
|
||||
"marquee-speed": [
|
||||
"normal", "slow", "fast"
|
||||
],
|
||||
"margin-top-collapse": [
|
||||
"collapse", "separate", "discard"
|
||||
],
|
||||
"max-height": [
|
||||
"none"
|
||||
],
|
||||
"box-orient": [
|
||||
"horizontal", "vertical", "inline-axis", "block-axis"
|
||||
],
|
||||
"font-stretch": [
|
||||
"normal", "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
|
||||
"semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
|
||||
],
|
||||
"-webkit-color-correction": [
|
||||
"default", "srgb"
|
||||
],
|
||||
"text-underline-style": [
|
||||
"none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
|
||||
],
|
||||
"text-overline-mode": [
|
||||
"continuous", "skip-white-space"
|
||||
],
|
||||
"-webkit-background-composite": [
|
||||
"highlight", "clear", "copy", "source-over", "source-in", "source-out", "source-atop", "destination-over",
|
||||
"destination-in", "destination-out", "destination-atop", "xor", "plus-darker", "plus-lighter"
|
||||
],
|
||||
"border-left-width": [
|
||||
"medium", "thick", "thin"
|
||||
],
|
||||
"-webkit-writing-mode": [
|
||||
"lr", "rl", "tb", "lr-tb", "rl-tb", "tb-rl", "horizontal-tb", "vertical-rl", "vertical-lr", "horizontal-bt"
|
||||
],
|
||||
"text-line-through-mode": [
|
||||
"continuous", "skip-white-space"
|
||||
],
|
||||
"border-collapse": [
|
||||
"collapse", "separate"
|
||||
],
|
||||
"page-break-inside": [
|
||||
"auto", "avoid"
|
||||
],
|
||||
"border-top-width": [
|
||||
"medium", "thick", "thin"
|
||||
],
|
||||
"outline-color": [
|
||||
"invert"
|
||||
],
|
||||
"text-line-through-style": [
|
||||
"none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
|
||||
],
|
||||
"outline-style": [
|
||||
"none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
|
||||
],
|
||||
"cursor": [
|
||||
"none", "copy", "auto", "crosshair", "default", "pointer", "move", "vertical-text", "cell", "context-menu",
|
||||
"alias", "progress", "no-drop", "not-allowed", "-webkit-zoom-in", "-webkit-zoom-out", "e-resize", "ne-resize",
|
||||
"nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "ew-resize", "ns-resize",
|
||||
"nesw-resize", "nwse-resize", "col-resize", "row-resize", "text", "wait", "help", "all-scroll", "-webkit-grab",
|
||||
"-webkit-grabbing"
|
||||
],
|
||||
"border-width": [
|
||||
"medium", "thick", "thin"
|
||||
],
|
||||
"size": [
|
||||
"a3", "a4", "a5", "b4", "b5", "landscape", "ledger", "legal", "letter", "portrait"
|
||||
],
|
||||
"background-size": [
|
||||
"contain", "cover"
|
||||
],
|
||||
"direction": [
|
||||
"ltr", "rtl"
|
||||
],
|
||||
"marquee-direction": [
|
||||
"left", "right", "auto", "reverse", "forwards", "backwards", "ahead", "up", "down"
|
||||
],
|
||||
"enable-background": [
|
||||
"accumulate", "new"
|
||||
],
|
||||
"float": [
|
||||
"none", "left", "right"
|
||||
],
|
||||
"overflow-y": [
|
||||
"hidden", "auto", "visible", "overlay", "scroll"
|
||||
],
|
||||
"margin-bottom-collapse": [
|
||||
"collapse", "separate", "discard"
|
||||
],
|
||||
"box-reflect": [
|
||||
"left", "right", "above", "below"
|
||||
],
|
||||
"overflow": [
|
||||
"hidden", "auto", "visible", "overlay", "scroll"
|
||||
],
|
||||
"text-rendering": [
|
||||
"auto", "optimizespeed", "optimizelegibility", "geometricprecision"
|
||||
],
|
||||
"text-align": [
|
||||
"-webkit-auto", "left", "right", "center", "justify", "-webkit-left", "-webkit-right", "-webkit-center"
|
||||
],
|
||||
"list-style-position": [
|
||||
"outside", "inside"
|
||||
],
|
||||
"margin-bottom": [
|
||||
"auto"
|
||||
],
|
||||
"color-interpolation": [
|
||||
"linearrgb"
|
||||
],
|
||||
"background-origin": [
|
||||
"border-box", "content-box", "padding-box"
|
||||
],
|
||||
"word-wrap": [
|
||||
"normal", "break-word"
|
||||
],
|
||||
"font-weight": [
|
||||
"normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"
|
||||
],
|
||||
"margin-before-collapse": [
|
||||
"collapse", "separate", "discard"
|
||||
],
|
||||
"text-overline-width": [
|
||||
"normal", "medium", "auto", "thick", "thin"
|
||||
],
|
||||
"text-transform": [
|
||||
"none", "capitalize", "uppercase", "lowercase"
|
||||
],
|
||||
"border-right-style": [
|
||||
"none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
|
||||
],
|
||||
"border-left-style": [
|
||||
"none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
|
||||
],
|
||||
"-webkit-text-emphasis": [
|
||||
"circle", "filled", "open", "dot", "double-circle", "triangle", "sesame"
|
||||
],
|
||||
"font-style": [
|
||||
"italic", "oblique", "normal"
|
||||
],
|
||||
"speak": [
|
||||
"none", "normal", "spell-out", "digits", "literal-punctuation", "no-punctuation"
|
||||
],
|
||||
"text-line-through": [
|
||||
"none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave", "continuous",
|
||||
"skip-white-space"
|
||||
],
|
||||
"color-rendering": [
|
||||
"auto", "optimizespeed", "optimizequality"
|
||||
],
|
||||
"list-style-type": [
|
||||
"none", "disc", "circle", "square", "decimal", "decimal-leading-zero", "arabic-indic", "binary", "bengali",
|
||||
"cambodian", "khmer", "devanagari", "gujarati", "gurmukhi", "kannada", "lower-hexadecimal", "lao", "malayalam",
|
||||
"mongolian", "myanmar", "octal", "oriya", "persian", "urdu", "telugu", "tibetan", "thai", "upper-hexadecimal",
|
||||
"lower-roman", "upper-roman", "lower-greek", "lower-alpha", "lower-latin", "upper-alpha", "upper-latin", "afar",
|
||||
"ethiopic-halehame-aa-et", "ethiopic-halehame-aa-er", "amharic", "ethiopic-halehame-am-et", "amharic-abegede",
|
||||
"ethiopic-abegede-am-et", "cjk-earthly-branch", "cjk-heavenly-stem", "ethiopic", "ethiopic-halehame-gez",
|
||||
"ethiopic-abegede", "ethiopic-abegede-gez", "hangul-consonant", "hangul", "lower-norwegian", "oromo",
|
||||
"ethiopic-halehame-om-et", "sidama", "ethiopic-halehame-sid-et", "somali", "ethiopic-halehame-so-et", "tigre",
|
||||
"ethiopic-halehame-tig", "tigrinya-er", "ethiopic-halehame-ti-er", "tigrinya-er-abegede",
|
||||
"ethiopic-abegede-ti-er", "tigrinya-et", "ethiopic-halehame-ti-et", "tigrinya-et-abegede",
|
||||
"ethiopic-abegede-ti-et", "upper-greek", "upper-norwegian", "asterisks", "footnotes", "hebrew", "armenian",
|
||||
"lower-armenian", "upper-armenian", "georgian", "cjk-ideographic", "hiragana", "katakana", "hiragana-iroha",
|
||||
"katakana-iroha"
|
||||
],
|
||||
"-webkit-text-combine": [
|
||||
"none", "horizontal"
|
||||
],
|
||||
"outline": [
|
||||
"none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
|
||||
],
|
||||
"font": [
|
||||
"caption", "icon", "menu", "message-box", "small-caption", "-webkit-mini-control", "-webkit-small-control",
|
||||
"-webkit-control", "status-bar", "italic", "oblique", "small-caps", "normal", "bold", "bolder", "lighter",
|
||||
"100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium",
|
||||
"large", "x-large", "xx-large", "-webkit-xxx-large", "smaller", "larger", "serif", "sans-serif", "cursive",
|
||||
"fantasy", "monospace", "-webkit-body"
|
||||
],
|
||||
"dominant-baseline": [
|
||||
"middle", "auto", "central", "text-before-edge", "text-after-edge", "ideographic", "alphabetic", "hanging",
|
||||
"mathematical", "use-script", "no-change", "reset-size"
|
||||
],
|
||||
"display": [
|
||||
"none", "inline", "block", "list-item", "run-in", "compact", "inline-block", "table", "inline-table",
|
||||
"table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group",
|
||||
"table-column", "table-cell", "table-caption", "-webkit-box", "-webkit-inline-box", "-wap-marquee"
|
||||
],
|
||||
"-webkit-text-emphasis-position": [
|
||||
"over", "under"
|
||||
],
|
||||
"image-rendering": [
|
||||
"auto", "optimizespeed", "optimizequality"
|
||||
],
|
||||
"alignment-baseline": [
|
||||
"baseline", "middle", "auto", "before-edge", "after-edge", "central", "text-before-edge", "text-after-edge",
|
||||
"ideographic", "alphabetic", "hanging", "mathematical"
|
||||
],
|
||||
"outline-width": [
|
||||
"medium", "thick", "thin"
|
||||
],
|
||||
"text-line-through-width": [
|
||||
"normal", "medium", "auto", "thick", "thin"
|
||||
],
|
||||
"box-align": [
|
||||
"baseline", "center", "stretch", "start", "end"
|
||||
],
|
||||
"border-right-width": [
|
||||
"medium", "thick", "thin"
|
||||
],
|
||||
"border-top-style": [
|
||||
"none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
|
||||
],
|
||||
"line-height": [
|
||||
"normal"
|
||||
],
|
||||
"text-overflow": [
|
||||
"clip", "ellipsis"
|
||||
],
|
||||
"box-direction": [
|
||||
"normal", "reverse"
|
||||
],
|
||||
"margin-after-collapse": [
|
||||
"collapse", "separate", "discard"
|
||||
],
|
||||
"page-break-before": [
|
||||
"left", "right", "auto", "always", "avoid"
|
||||
],
|
||||
"-webkit-hyphens": [
|
||||
"none", "auto", "manual"
|
||||
],
|
||||
"border-image": [
|
||||
"repeat", "stretch"
|
||||
],
|
||||
"text-decoration": [
|
||||
"blink", "line-through", "overline", "underline"
|
||||
],
|
||||
"position": [
|
||||
"absolute", "fixed", "relative", "static"
|
||||
],
|
||||
"font-family": [
|
||||
"serif", "sans-serif", "cursive", "fantasy", "monospace", "-webkit-body"
|
||||
],
|
||||
"text-overflow-mode": [
|
||||
"clip", "ellipsis"
|
||||
],
|
||||
"border-bottom-style": [
|
||||
"none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
|
||||
],
|
||||
"unicode-bidi": [
|
||||
"normal", "bidi-override", "embed"
|
||||
],
|
||||
"clip-rule": [
|
||||
"nonzero", "evenodd"
|
||||
],
|
||||
"margin-left": [
|
||||
"auto"
|
||||
],
|
||||
"margin-top": [
|
||||
"auto"
|
||||
],
|
||||
"zoom": [
|
||||
"document", "reset"
|
||||
],
|
||||
"text-overline-style": [
|
||||
"none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
|
||||
],
|
||||
"max-width": [
|
||||
"none"
|
||||
],
|
||||
"empty-cells": [
|
||||
"hide", "show"
|
||||
],
|
||||
"pointer-events": [
|
||||
"none", "all", "auto", "visible", "visiblepainted", "visiblefill", "visiblestroke", "painted", "fill", "stroke"
|
||||
],
|
||||
"letter-spacing": [
|
||||
"normal"
|
||||
],
|
||||
"background-clip": [
|
||||
"border-box", "content-box", "padding-box"
|
||||
],
|
||||
"-webkit-font-smoothing": [
|
||||
"none", "auto", "antialiased", "subpixel-antialiased"
|
||||
],
|
||||
"border": [
|
||||
"none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
|
||||
],
|
||||
"font-size": [
|
||||
"xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "-webkit-xxx-large", "smaller",
|
||||
"larger"
|
||||
],
|
||||
"font-variant": [
|
||||
"small-caps", "normal"
|
||||
],
|
||||
"vertical-align": [
|
||||
"baseline", "middle", "sub", "super", "text-top", "text-bottom", "top", "bottom", "-webkit-baseline-middle"
|
||||
],
|
||||
"marquee-style": [
|
||||
"none", "scroll", "slide", "alternate"
|
||||
],
|
||||
"white-space": [
|
||||
"normal", "nowrap", "pre", "pre-line", "pre-wrap"
|
||||
],
|
||||
"text-underline-width": [
|
||||
"normal", "medium", "auto", "thick", "thin"
|
||||
],
|
||||
"box-lines": [
|
||||
"single", "multiple"
|
||||
],
|
||||
"page-break-after": [
|
||||
"left", "right", "auto", "always", "avoid"
|
||||
],
|
||||
"clip-path": [
|
||||
"none"
|
||||
],
|
||||
"margin": [
|
||||
"auto"
|
||||
],
|
||||
"marquee-repetition": [
|
||||
"infinite"
|
||||
],
|
||||
"margin-right": [
|
||||
"auto"
|
||||
],
|
||||
"-webkit-text-emphasis-style": [
|
||||
"circle", "filled", "open", "dot", "double-circle", "triangle", "sesame"
|
||||
]
|
||||
}
|
574
node_modules/weinre/web/client/CSSStyleModel.js
generated
vendored
Normal file
@ -0,0 +1,574 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.CSSStyleModel = function()
|
||||
{
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleModel.parseRuleArrayPayload = function(ruleArray)
|
||||
{
|
||||
var result = [];
|
||||
for (var i = 0; i < ruleArray.length; ++i)
|
||||
result.push(WebInspector.CSSRule.parsePayload(ruleArray[i]));
|
||||
return result;
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleModel.prototype = {
|
||||
getStylesAsync: function(nodeId, userCallback)
|
||||
{
|
||||
function callback(userCallback, payload)
|
||||
{
|
||||
if (!payload) {
|
||||
if (userCallback)
|
||||
userCallback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = {};
|
||||
if ("inlineStyle" in payload)
|
||||
result.inlineStyle = WebInspector.CSSStyleDeclaration.parsePayload(payload.inlineStyle);
|
||||
|
||||
result.computedStyle = WebInspector.CSSStyleDeclaration.parsePayload(payload.computedStyle);
|
||||
result.matchedCSSRules = WebInspector.CSSStyleModel.parseRuleArrayPayload(payload.matchedCSSRules);
|
||||
|
||||
result.styleAttributes = {};
|
||||
for (var name in payload.styleAttributes)
|
||||
result.styleAttributes[name] = WebInspector.CSSStyleDeclaration.parsePayload(payload.styleAttributes[name]);
|
||||
|
||||
result.pseudoElements = [];
|
||||
for (var i = 0; i < payload.pseudoElements.length; ++i) {
|
||||
var entryPayload = payload.pseudoElements[i];
|
||||
result.pseudoElements.push({ pseudoId: entryPayload.pseudoId, rules: WebInspector.CSSStyleModel.parseRuleArrayPayload(entryPayload.rules) });
|
||||
}
|
||||
|
||||
result.inherited = [];
|
||||
for (var i = 0; i < payload.inherited.length; ++i) {
|
||||
var entryPayload = payload.inherited[i];
|
||||
var entry = {};
|
||||
if ("inlineStyle" in entryPayload)
|
||||
entry.inlineStyle = WebInspector.CSSStyleDeclaration.parsePayload(entryPayload.inlineStyle);
|
||||
if ("matchedCSSRules" in entryPayload)
|
||||
entry.matchedCSSRules = WebInspector.CSSStyleModel.parseRuleArrayPayload(entryPayload.matchedCSSRules);
|
||||
result.inherited.push(entry);
|
||||
}
|
||||
|
||||
if (userCallback)
|
||||
userCallback(result);
|
||||
}
|
||||
|
||||
InspectorBackend.getStylesForNode(nodeId, callback.bind(null, userCallback));
|
||||
},
|
||||
|
||||
getComputedStyleAsync: function(nodeId, userCallback)
|
||||
{
|
||||
function callback(userCallback, stylePayload)
|
||||
{
|
||||
if (!stylePayload)
|
||||
userCallback(null);
|
||||
else
|
||||
userCallback(WebInspector.CSSStyleDeclaration.parsePayload(stylePayload));
|
||||
}
|
||||
|
||||
InspectorBackend.getComputedStyleForNode(nodeId, callback.bind(null, userCallback));
|
||||
},
|
||||
|
||||
getInlineStyleAsync: function(nodeId, userCallback)
|
||||
{
|
||||
function callback(userCallback, stylePayload)
|
||||
{
|
||||
if (!stylePayload)
|
||||
userCallback(null);
|
||||
else
|
||||
userCallback(WebInspector.CSSStyleDeclaration.parsePayload(stylePayload));
|
||||
}
|
||||
|
||||
InspectorBackend.getInlineStyleForNode(nodeId, callback.bind(null, userCallback));
|
||||
},
|
||||
|
||||
setRuleSelector: function(ruleId, nodeId, newSelector, successCallback, failureCallback)
|
||||
{
|
||||
function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
|
||||
{
|
||||
var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
|
||||
var rule = WebInspector.CSSRule.parsePayload(rulePayload);
|
||||
successCallback(rule, doesAffectSelectedNode);
|
||||
this._styleSheetChanged(rule.id.styleSheetId, true);
|
||||
}
|
||||
|
||||
function callback(nodeId, successCallback, failureCallback, newSelector, rulePayload)
|
||||
{
|
||||
if (!rulePayload)
|
||||
failureCallback();
|
||||
else
|
||||
InspectorBackend.querySelectorAll(nodeId, newSelector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
|
||||
}
|
||||
|
||||
InspectorBackend.setRuleSelector(ruleId, newSelector, callback.bind(this, nodeId, successCallback, failureCallback));
|
||||
},
|
||||
|
||||
addRule: function(nodeId, selector, successCallback, failureCallback)
|
||||
{
|
||||
function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
|
||||
{
|
||||
var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
|
||||
var rule = WebInspector.CSSRule.parsePayload(rulePayload);
|
||||
successCallback(rule, doesAffectSelectedNode);
|
||||
this._styleSheetChanged(rule.id.styleSheetId, true);
|
||||
}
|
||||
|
||||
function callback(successCallback, failureCallback, selector, rulePayload)
|
||||
{
|
||||
if (!rulePayload) {
|
||||
// Invalid syntax for a selector
|
||||
failureCallback();
|
||||
} else
|
||||
InspectorBackend.querySelectorAll(nodeId, selector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
|
||||
}
|
||||
|
||||
InspectorBackend.addRule(nodeId, selector, callback.bind(this, successCallback, failureCallback, selector));
|
||||
},
|
||||
|
||||
_styleSheetChanged: function(styleSheetId, majorChange)
|
||||
{
|
||||
if (!majorChange || !styleSheetId)
|
||||
return;
|
||||
|
||||
function callback(href, content)
|
||||
{
|
||||
var resource = WebInspector.resourceForURL(href);
|
||||
if (resource && resource.type === WebInspector.Resource.Type.Stylesheet)
|
||||
resource.setContent(content, this._onRevert.bind(this, styleSheetId));
|
||||
}
|
||||
InspectorBackend.getStyleSheetText(styleSheetId, callback.bind(this));
|
||||
},
|
||||
|
||||
_onRevert: function(styleSheetId, contentToRevertTo)
|
||||
{
|
||||
function callback(success)
|
||||
{
|
||||
this._styleSheetChanged(styleSheetId, true);
|
||||
this.dispatchEventToListeners("stylesheet changed");
|
||||
}
|
||||
InspectorBackend.setStyleSheetText(styleSheetId, contentToRevertTo, callback.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleModel.prototype.__proto__ = WebInspector.Object.prototype;
|
||||
|
||||
WebInspector.CSSStyleDeclaration = function(payload)
|
||||
{
|
||||
this.id = payload.styleId;
|
||||
this.properties = payload.properties;
|
||||
this._shorthandValues = payload.shorthandValues;
|
||||
this._livePropertyMap = {}; // LIVE properties (source-based or style-based) : { name -> CSSProperty }
|
||||
this._allProperties = []; // ALL properties: [ CSSProperty ]
|
||||
this._longhandProperties = {}; // shorthandName -> [ CSSProperty ]
|
||||
this.__disabledProperties = {}; // DISABLED properties: { index -> CSSProperty }
|
||||
var payloadPropertyCount = payload.cssProperties.length;
|
||||
|
||||
var propertyIndex = 0;
|
||||
for (var i = 0; i < payloadPropertyCount; ++i) {
|
||||
var property = new WebInspector.CSSProperty.parsePayload(this, i, payload.cssProperties[i]);
|
||||
this._allProperties.push(property);
|
||||
if (property.disabled)
|
||||
this.__disabledProperties[i] = property;
|
||||
if (!property.active && !property.styleBased)
|
||||
continue;
|
||||
var name = property.name;
|
||||
this[propertyIndex] = name;
|
||||
this._livePropertyMap[name] = property;
|
||||
|
||||
// Index longhand properties.
|
||||
if (property.shorthand) { // only for parsed
|
||||
var longhands = this._longhandProperties[property.shorthand];
|
||||
if (!longhands) {
|
||||
longhands = [];
|
||||
this._longhandProperties[property.shorthand] = longhands;
|
||||
}
|
||||
longhands.push(property);
|
||||
}
|
||||
++propertyIndex;
|
||||
}
|
||||
this.length = propertyIndex;
|
||||
if ("cssText" in payload)
|
||||
this.cssText = payload.cssText;
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleDeclaration.parsePayload = function(payload)
|
||||
{
|
||||
return new WebInspector.CSSStyleDeclaration(payload);
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleDeclaration.prototype = {
|
||||
get allProperties()
|
||||
{
|
||||
return this._allProperties;
|
||||
},
|
||||
|
||||
getLiveProperty: function(name)
|
||||
{
|
||||
return this._livePropertyMap[name];
|
||||
},
|
||||
|
||||
getPropertyValue: function(name)
|
||||
{
|
||||
var property = this._livePropertyMap[name];
|
||||
return property ? property.value : "";
|
||||
},
|
||||
|
||||
getPropertyPriority: function(name)
|
||||
{
|
||||
var property = this._livePropertyMap[name];
|
||||
return property ? property.priority : "";
|
||||
},
|
||||
|
||||
getPropertyShorthand: function(name)
|
||||
{
|
||||
var property = this._livePropertyMap[name];
|
||||
return property ? property.shorthand : "";
|
||||
},
|
||||
|
||||
isPropertyImplicit: function(name)
|
||||
{
|
||||
var property = this._livePropertyMap[name];
|
||||
return property ? property.implicit : "";
|
||||
},
|
||||
|
||||
styleTextWithShorthands: function()
|
||||
{
|
||||
var cssText = "";
|
||||
var foundProperties = {};
|
||||
for (var i = 0; i < this.length; ++i) {
|
||||
var individualProperty = this[i];
|
||||
var shorthandProperty = this.getPropertyShorthand(individualProperty);
|
||||
var propertyName = (shorthandProperty || individualProperty);
|
||||
|
||||
if (propertyName in foundProperties)
|
||||
continue;
|
||||
|
||||
if (shorthandProperty) {
|
||||
var value = this.getShorthandValue(shorthandProperty);
|
||||
var priority = this.getShorthandPriority(shorthandProperty);
|
||||
} else {
|
||||
var value = this.getPropertyValue(individualProperty);
|
||||
var priority = this.getPropertyPriority(individualProperty);
|
||||
}
|
||||
|
||||
foundProperties[propertyName] = true;
|
||||
|
||||
cssText += propertyName + ": " + value;
|
||||
if (priority)
|
||||
cssText += " !" + priority;
|
||||
cssText += "; ";
|
||||
}
|
||||
|
||||
return cssText;
|
||||
},
|
||||
|
||||
getLonghandProperties: function(name)
|
||||
{
|
||||
return this._longhandProperties[name] || [];
|
||||
},
|
||||
|
||||
getShorthandValue: function(shorthandProperty)
|
||||
{
|
||||
var property = this.getLiveProperty(shorthandProperty);
|
||||
return property ? property.value : this._shorthandValues[shorthandProperty];
|
||||
},
|
||||
|
||||
getShorthandPriority: function(shorthandProperty)
|
||||
{
|
||||
var priority = this.getPropertyPriority(shorthandProperty);
|
||||
if (priority)
|
||||
return priority;
|
||||
|
||||
var longhands = this._longhandProperties[shorthandProperty];
|
||||
return longhands ? this.getPropertyPriority(longhands[0]) : null;
|
||||
},
|
||||
|
||||
propertyAt: function(index)
|
||||
{
|
||||
return (index < this.allProperties.length) ? this.allProperties[index] : null;
|
||||
},
|
||||
|
||||
pastLastSourcePropertyIndex: function()
|
||||
{
|
||||
for (var i = this.allProperties.length - 1; i >= 0; --i) {
|
||||
var property = this.allProperties[i];
|
||||
if (property.active || property.disabled)
|
||||
return i + 1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
|
||||
newBlankProperty: function()
|
||||
{
|
||||
return new WebInspector.CSSProperty(this, this.pastLastSourcePropertyIndex(), "", "", "", "active", true, false, false, "");
|
||||
},
|
||||
|
||||
insertPropertyAt: function(index, name, value, userCallback)
|
||||
{
|
||||
function callback(userCallback, payload)
|
||||
{
|
||||
if (!userCallback)
|
||||
return;
|
||||
|
||||
if (!payload)
|
||||
userCallback(null);
|
||||
else {
|
||||
userCallback(WebInspector.CSSStyleDeclaration.parsePayload(payload));
|
||||
WebInspector.cssModel._styleSheetChanged(this.id.styleSheetId, true);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorBackend.setPropertyText(this.id, index, name + ": " + value + ";", false, callback.bind(null, userCallback));
|
||||
},
|
||||
|
||||
appendProperty: function(name, value, userCallback)
|
||||
{
|
||||
this.insertPropertyAt(this.allProperties.length, name, value, userCallback);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.CSSRule = function(payload)
|
||||
{
|
||||
this.id = payload.ruleId;
|
||||
this.selectorText = payload.selectorText;
|
||||
this.sourceLine = payload.sourceLine;
|
||||
this.sourceURL = payload.sourceURL;
|
||||
this.origin = payload.origin;
|
||||
this.style = WebInspector.CSSStyleDeclaration.parsePayload(payload.style);
|
||||
this.style.parentRule = this;
|
||||
this.selectorRange = payload.selectorRange;
|
||||
}
|
||||
|
||||
WebInspector.CSSRule.parsePayload = function(payload)
|
||||
{
|
||||
return new WebInspector.CSSRule(payload);
|
||||
}
|
||||
|
||||
WebInspector.CSSRule.prototype = {
|
||||
get isUserAgent()
|
||||
{
|
||||
return this.origin === "user-agent";
|
||||
},
|
||||
|
||||
get isUser()
|
||||
{
|
||||
return this.origin === "user";
|
||||
},
|
||||
|
||||
get isViaInspector()
|
||||
{
|
||||
return this.origin === "inspector";
|
||||
},
|
||||
|
||||
get isRegular()
|
||||
{
|
||||
return this.origin === "";
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.CSSProperty = function(ownerStyle, index, name, value, priority, status, parsedOk, implicit, shorthand, text)
|
||||
{
|
||||
this.ownerStyle = ownerStyle;
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.priority = priority;
|
||||
this.status = status;
|
||||
this.parsedOk = parsedOk;
|
||||
this.implicit = implicit;
|
||||
this.shorthand = shorthand;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
WebInspector.CSSProperty.parsePayload = function(ownerStyle, index, payload)
|
||||
{
|
||||
var result = new WebInspector.CSSProperty(
|
||||
ownerStyle, index, payload.name, payload.value, payload.priority, payload.status, payload.parsedOk, payload.implicit, payload.shorthandName, payload.text);
|
||||
return result;
|
||||
}
|
||||
|
||||
WebInspector.CSSProperty.prototype = {
|
||||
get propertyText()
|
||||
{
|
||||
if (this.text !== undefined)
|
||||
return this.text;
|
||||
|
||||
if (this.name === "")
|
||||
return "";
|
||||
return this.name + ": " + this.value + (this.priority ? " !" + this.priority : "") + ";";
|
||||
},
|
||||
|
||||
get isLive()
|
||||
{
|
||||
return this.active || this.styleBased;
|
||||
},
|
||||
|
||||
get active()
|
||||
{
|
||||
return this.status === "active";
|
||||
},
|
||||
|
||||
get styleBased()
|
||||
{
|
||||
return this.status === "style";
|
||||
},
|
||||
|
||||
get inactive()
|
||||
{
|
||||
return this.status === "inactive";
|
||||
},
|
||||
|
||||
get disabled()
|
||||
{
|
||||
return this.status === "disabled";
|
||||
},
|
||||
|
||||
// Replaces "propertyName: propertyValue [!important];" in the stylesheet by an arbitrary propertyText.
|
||||
setText: function(propertyText, majorChange, userCallback)
|
||||
{
|
||||
function enabledCallback(style)
|
||||
{
|
||||
if (style)
|
||||
WebInspector.cssModel._styleSheetChanged(style.id.styleSheetId, majorChange);
|
||||
if (userCallback)
|
||||
userCallback(style);
|
||||
}
|
||||
|
||||
function callback(stylePayload)
|
||||
{
|
||||
if (stylePayload) {
|
||||
this.text = propertyText;
|
||||
var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
|
||||
var newProperty = style.allProperties[this.index];
|
||||
|
||||
if (newProperty && this.disabled && !propertyText.match(/^\s*$/)) {
|
||||
newProperty.setDisabled(false, enabledCallback);
|
||||
return;
|
||||
} else
|
||||
WebInspector.cssModel._styleSheetChanged(style.id.styleSheetId, majorChange);
|
||||
if (userCallback)
|
||||
userCallback(style);
|
||||
} else {
|
||||
if (userCallback)
|
||||
userCallback(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.ownerStyle)
|
||||
throw "No ownerStyle for property";
|
||||
|
||||
// An index past all the properties adds a new property to the style.
|
||||
InspectorBackend.setPropertyText(this.ownerStyle.id, this.index, propertyText, this.index < this.ownerStyle.pastLastSourcePropertyIndex(), callback.bind(this));
|
||||
},
|
||||
|
||||
setValue: function(newValue, userCallback)
|
||||
{
|
||||
var text = this.name + ": " + newValue + (this.priority ? " !" + this.priority : "") + ";"
|
||||
this.setText(text, userCallback);
|
||||
},
|
||||
|
||||
setDisabled: function(disabled, userCallback)
|
||||
{
|
||||
if (!this.ownerStyle && userCallback)
|
||||
userCallback(null);
|
||||
if (disabled === this.disabled && userCallback)
|
||||
userCallback(this.ownerStyle);
|
||||
|
||||
function callback(stylePayload)
|
||||
{
|
||||
if (!userCallback)
|
||||
return;
|
||||
if (!stylePayload)
|
||||
userCallback(null);
|
||||
else {
|
||||
var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
|
||||
userCallback(style);
|
||||
WebInspector.cssModel._styleSheetChanged(this.ownerStyle.id.styleSheetId, false);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorBackend.toggleProperty(this.ownerStyle.id, this.index, disabled, callback.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleSheet = function(payload)
|
||||
{
|
||||
this.id = payload.styleSheetId;
|
||||
this.sourceURL = payload.sourceURL;
|
||||
this.title = payload.title;
|
||||
this.disabled = payload.disabled;
|
||||
this.rules = [];
|
||||
this.styles = {};
|
||||
for (var i = 0; i < payload.rules.length; ++i) {
|
||||
var rule = WebInspector.CSSRule.parsePayload(payload.rules[i]);
|
||||
this.rules.push(rule);
|
||||
if (rule.style)
|
||||
this.styles[rule.style.id] = rule.style;
|
||||
}
|
||||
if ("text" in payload)
|
||||
this._text = payload.text;
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleSheet.createForId = function(styleSheetId, userCallback)
|
||||
{
|
||||
function callback(styleSheetPayload)
|
||||
{
|
||||
if (!styleSheetPayload)
|
||||
userCallback(null);
|
||||
else
|
||||
userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload));
|
||||
}
|
||||
InspectorBackend.getStyleSheet(styleSheetId, callback.bind(this));
|
||||
}
|
||||
|
||||
WebInspector.CSSStyleSheet.prototype = {
|
||||
getText: function()
|
||||
{
|
||||
return this._text;
|
||||
},
|
||||
|
||||
setText: function(newText, userCallback)
|
||||
{
|
||||
function callback(styleSheetPayload)
|
||||
{
|
||||
if (!styleSheetPayload)
|
||||
userCallback(null);
|
||||
else {
|
||||
userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload));
|
||||
WebInspector.cssModel._styleSheetChanged(this.id, true);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorBackend.setStyleSheetText(this.id, newText, callback.bind(this));
|
||||
}
|
||||
}
|
196
node_modules/weinre/web/client/CallStackSidebarPane.js
generated
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.CallStackSidebarPane = function()
|
||||
{
|
||||
WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack"));
|
||||
}
|
||||
|
||||
WebInspector.CallStackSidebarPane.prototype = {
|
||||
update: function(details)
|
||||
{
|
||||
this.bodyElement.removeChildren();
|
||||
|
||||
this.placards = [];
|
||||
delete this._selectedCallFrame;
|
||||
|
||||
if (!details) {
|
||||
var infoElement = document.createElement("div");
|
||||
infoElement.className = "info";
|
||||
infoElement.textContent = WebInspector.UIString("Not Paused");
|
||||
this.bodyElement.appendChild(infoElement);
|
||||
return;
|
||||
}
|
||||
|
||||
var callFrames = details.callFrames;
|
||||
var title;
|
||||
var subtitle;
|
||||
var script;
|
||||
|
||||
for (var i = 0; i < callFrames.length; ++i) {
|
||||
var callFrame = callFrames[i];
|
||||
switch (callFrame.type) {
|
||||
case "function":
|
||||
title = callFrame.functionName || WebInspector.UIString("(anonymous function)");
|
||||
break;
|
||||
case "program":
|
||||
title = WebInspector.UIString("(program)");
|
||||
break;
|
||||
}
|
||||
|
||||
script = WebInspector.debuggerModel.scriptForSourceID(callFrame.sourceID);
|
||||
if (script)
|
||||
subtitle = WebInspector.displayNameForURL(script.sourceURL);
|
||||
else
|
||||
subtitle = WebInspector.UIString("(internal script)");
|
||||
|
||||
if (callFrame.line > 0) {
|
||||
if (subtitle)
|
||||
subtitle += ":" + callFrame.line;
|
||||
else
|
||||
subtitle = WebInspector.UIString("line %d", callFrame.line);
|
||||
}
|
||||
|
||||
var placard = new WebInspector.Placard(title, subtitle);
|
||||
placard.callFrame = callFrame;
|
||||
|
||||
placard.element.addEventListener("click", this._placardSelected.bind(this), false);
|
||||
|
||||
this.placards.push(placard);
|
||||
this.bodyElement.appendChild(placard.element);
|
||||
}
|
||||
|
||||
if (details.breakpoint)
|
||||
this._scriptBreakpointHit();
|
||||
else if (details.eventType === WebInspector.DebuggerEventTypes.NativeBreakpoint)
|
||||
this._nativeBreakpointHit(details.eventData);
|
||||
},
|
||||
|
||||
get selectedCallFrame()
|
||||
{
|
||||
return this._selectedCallFrame;
|
||||
},
|
||||
|
||||
set selectedCallFrame(x)
|
||||
{
|
||||
this._selectedCallFrame = x;
|
||||
|
||||
for (var i = 0; i < this.placards.length; ++i) {
|
||||
var placard = this.placards[i];
|
||||
placard.selected = (placard.callFrame === this._selectedCallFrame);
|
||||
}
|
||||
|
||||
this.dispatchEventToListeners("call frame selected");
|
||||
},
|
||||
|
||||
handleShortcut: function(event)
|
||||
{
|
||||
var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
|
||||
var handler = this._shortcuts[shortcut];
|
||||
if (handler) {
|
||||
handler(event);
|
||||
event.handled = true;
|
||||
}
|
||||
},
|
||||
|
||||
_selectNextCallFrameOnStack: function()
|
||||
{
|
||||
var index = this._selectedCallFrameIndex();
|
||||
if (index == -1)
|
||||
return;
|
||||
this._selectedPlacardByIndex(index + 1);
|
||||
},
|
||||
|
||||
_selectPreviousCallFrameOnStack: function()
|
||||
{
|
||||
var index = this._selectedCallFrameIndex();
|
||||
if (index == -1)
|
||||
return;
|
||||
this._selectedPlacardByIndex(index - 1);
|
||||
},
|
||||
|
||||
_selectedPlacardByIndex: function(index)
|
||||
{
|
||||
if (index < 0 || index >= this.placards.length)
|
||||
return;
|
||||
var placard = this.placards[index];
|
||||
this.selectedCallFrame = placard.callFrame
|
||||
},
|
||||
|
||||
_selectedCallFrameIndex: function()
|
||||
{
|
||||
if (!this._selectedCallFrame)
|
||||
return -1;
|
||||
for (var i = 0; i < this.placards.length; ++i) {
|
||||
var placard = this.placards[i];
|
||||
if (placard.callFrame === this._selectedCallFrame)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
_placardSelected: function(event)
|
||||
{
|
||||
var placardElement = event.target.enclosingNodeOrSelfWithClass("placard");
|
||||
this.selectedCallFrame = placardElement.placard.callFrame;
|
||||
},
|
||||
|
||||
registerShortcuts: function(section)
|
||||
{
|
||||
this._shortcuts = {};
|
||||
|
||||
var nextCallFrame = WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Period,
|
||||
WebInspector.KeyboardShortcut.Modifiers.Ctrl);
|
||||
this._shortcuts[nextCallFrame.key] = this._selectNextCallFrameOnStack.bind(this);
|
||||
|
||||
var prevCallFrame = WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Comma,
|
||||
WebInspector.KeyboardShortcut.Modifiers.Ctrl);
|
||||
this._shortcuts[prevCallFrame.key] = this._selectPreviousCallFrameOnStack.bind(this);
|
||||
|
||||
section.addRelatedKeys([ nextCallFrame.name, prevCallFrame.name ], WebInspector.UIString("Next/previous call frame"));
|
||||
},
|
||||
|
||||
_scriptBreakpointHit: function()
|
||||
{
|
||||
var statusMessageElement = document.createElement("div");
|
||||
statusMessageElement.className = "info";
|
||||
statusMessageElement.appendChild(document.createTextNode(WebInspector.UIString("Paused on a JavaScript breakpoint.")));
|
||||
this.bodyElement.appendChild(statusMessageElement);
|
||||
},
|
||||
|
||||
_nativeBreakpointHit: function(eventData)
|
||||
{
|
||||
var breakpoint = WebInspector.breakpointManager.breakpointViewForEventData(eventData);
|
||||
if (!breakpoint)
|
||||
return;
|
||||
|
||||
var statusMessageElement = document.createElement("div");
|
||||
statusMessageElement.className = "info";
|
||||
breakpoint.populateStatusMessageElement(statusMessageElement, eventData);
|
||||
this.bodyElement.appendChild(statusMessageElement);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.CallStackSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
|
63
node_modules/weinre/web/client/Checkbox.js
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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.Checkbox = function(label, className, tooltip)
|
||||
{
|
||||
this.element = document.createElement('label');
|
||||
this._inputElement = document.createElement('input');
|
||||
this._inputElement.type = "checkbox";
|
||||
|
||||
this.element.className = className;
|
||||
this.element.appendChild(this._inputElement);
|
||||
this.element.appendChild(document.createTextNode(label));
|
||||
if (tooltip)
|
||||
this.element.title = tooltip;
|
||||
}
|
||||
|
||||
WebInspector.Checkbox.prototype = {
|
||||
set checked(checked)
|
||||
{
|
||||
this._inputElement.checked = checked;
|
||||
},
|
||||
|
||||
get checked()
|
||||
{
|
||||
return this._inputElement.checked;
|
||||
},
|
||||
|
||||
addEventListener: function(listener)
|
||||
{
|
||||
function listenerWrapper(event)
|
||||
{
|
||||
if (listener)
|
||||
listener(event);
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
|
||||
this._inputElement.addEventListener("click", listenerWrapper, false);
|
||||
this.element.addEventListener("click", listenerWrapper, false);
|
||||
}
|
||||
}
|
663
node_modules/weinre/web/client/Color.js
generated
vendored
Normal file
@ -0,0 +1,663 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009 Joseph Pecoraro
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.Color = function(str)
|
||||
{
|
||||
this.value = str;
|
||||
this._parse();
|
||||
}
|
||||
|
||||
WebInspector.Color.prototype = {
|
||||
get shorthex()
|
||||
{
|
||||
if ("_short" in this)
|
||||
return this._short;
|
||||
|
||||
if (!this.simple)
|
||||
return null;
|
||||
|
||||
var hex = this.hex;
|
||||
if (hex.charAt(0) === hex.charAt(1) && hex.charAt(2) === hex.charAt(3) && hex.charAt(4) === hex.charAt(5))
|
||||
this._short = hex.charAt(0) + hex.charAt(2) + hex.charAt(4);
|
||||
else
|
||||
this._short = hex;
|
||||
|
||||
return this._short;
|
||||
},
|
||||
|
||||
get hex()
|
||||
{
|
||||
if (!this.simple)
|
||||
return null;
|
||||
|
||||
return this._hex;
|
||||
},
|
||||
|
||||
set hex(x)
|
||||
{
|
||||
this._hex = x;
|
||||
},
|
||||
|
||||
get rgb()
|
||||
{
|
||||
if ("_rgb" in this)
|
||||
return this._rgb;
|
||||
|
||||
if (this.simple)
|
||||
this._rgb = this._hexToRGB(this.hex);
|
||||
else {
|
||||
var rgba = this.rgba;
|
||||
this._rgb = [rgba[0], rgba[1], rgba[2]];
|
||||
}
|
||||
|
||||
return this._rgb;
|
||||
},
|
||||
|
||||
set rgb(x)
|
||||
{
|
||||
this._rgb = x;
|
||||
},
|
||||
|
||||
get hsl()
|
||||
{
|
||||
if ("_hsl" in this)
|
||||
return this._hsl;
|
||||
|
||||
this._hsl = this._rgbToHSL(this.rgb);
|
||||
return this._hsl;
|
||||
},
|
||||
|
||||
set hsl(x)
|
||||
{
|
||||
this._hsl = x;
|
||||
},
|
||||
|
||||
get nickname()
|
||||
{
|
||||
if (typeof this._nickname !== "undefined") // would be set on parse if there was a nickname
|
||||
return this._nickname;
|
||||
else
|
||||
return null;
|
||||
},
|
||||
|
||||
set nickname(x)
|
||||
{
|
||||
this._nickname = x;
|
||||
},
|
||||
|
||||
get rgba()
|
||||
{
|
||||
return this._rgba;
|
||||
},
|
||||
|
||||
set rgba(x)
|
||||
{
|
||||
this._rgba = x;
|
||||
},
|
||||
|
||||
get hsla()
|
||||
{
|
||||
return this._hsla;
|
||||
},
|
||||
|
||||
set hsla(x)
|
||||
{
|
||||
this._hsla = x;
|
||||
},
|
||||
|
||||
hasShortHex: function()
|
||||
{
|
||||
var shorthex = this.shorthex;
|
||||
return (shorthex && shorthex.length === 3);
|
||||
},
|
||||
|
||||
toString: function(format)
|
||||
{
|
||||
if (!format)
|
||||
format = this.format;
|
||||
|
||||
switch (format) {
|
||||
case "original":
|
||||
return this.value;
|
||||
case "rgb":
|
||||
return "rgb(" + this.rgb.join(", ") + ")";
|
||||
case "rgba":
|
||||
return "rgba(" + this.rgba.join(", ") + ")";
|
||||
case "hsl":
|
||||
var hsl = this.hsl;
|
||||
return "hsl(" + hsl[0] + ", " + hsl[1] + "%, " + hsl[2] + "%)";
|
||||
case "hsla":
|
||||
var hsla = this.hsla;
|
||||
return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
|
||||
case "hex":
|
||||
return "#" + this.hex;
|
||||
case "shorthex":
|
||||
return "#" + this.shorthex;
|
||||
case "nickname":
|
||||
return this.nickname;
|
||||
}
|
||||
|
||||
throw "invalid color format";
|
||||
},
|
||||
|
||||
_rgbToHex: function(rgb)
|
||||
{
|
||||
var r = parseInt(rgb[0]).toString(16);
|
||||
var g = parseInt(rgb[1]).toString(16);
|
||||
var b = parseInt(rgb[2]).toString(16);
|
||||
if (r.length === 1)
|
||||
r = "0" + r;
|
||||
if (g.length === 1)
|
||||
g = "0" + g;
|
||||
if (b.length === 1)
|
||||
b = "0" + b;
|
||||
|
||||
return (r + g + b).toUpperCase();
|
||||
},
|
||||
|
||||
_hexToRGB: function(hex)
|
||||
{
|
||||
var r = parseInt(hex.substring(0,2), 16);
|
||||
var g = parseInt(hex.substring(2,4), 16);
|
||||
var b = parseInt(hex.substring(4,6), 16);
|
||||
|
||||
return [r, g, b];
|
||||
},
|
||||
|
||||
_rgbToHSL: function(rgb)
|
||||
{
|
||||
var r = parseInt(rgb[0]) / 255;
|
||||
var g = parseInt(rgb[1]) / 255;
|
||||
var b = parseInt(rgb[2]) / 255;
|
||||
var max = Math.max(r, g, b);
|
||||
var min = Math.min(r, g, b);
|
||||
var diff = max - min;
|
||||
var add = max + min;
|
||||
|
||||
if (min === max)
|
||||
var h = 0;
|
||||
else if (r === max)
|
||||
var h = ((60 * (g - b) / diff) + 360) % 360;
|
||||
else if (g === max)
|
||||
var h = (60 * (b - r) / diff) + 120;
|
||||
else
|
||||
var h = (60 * (r - g) / diff) + 240;
|
||||
|
||||
var l = 0.5 * add;
|
||||
|
||||
if (l === 0)
|
||||
var s = 0;
|
||||
else if (l === 1)
|
||||
var s = 1;
|
||||
else if (l <= 0.5)
|
||||
var s = diff / add;
|
||||
else
|
||||
var s = diff / (2 - add);
|
||||
|
||||
h = Math.round(h);
|
||||
s = Math.round(s*100);
|
||||
l = Math.round(l*100);
|
||||
|
||||
return [h, s, l];
|
||||
},
|
||||
|
||||
_hslToRGB: function(hsl)
|
||||
{
|
||||
var h = parseFloat(hsl[0]) / 360;
|
||||
var s = parseFloat(hsl[1]) / 100;
|
||||
var l = parseFloat(hsl[2]) / 100;
|
||||
|
||||
if (l <= 0.5)
|
||||
var q = l * (1 + s);
|
||||
else
|
||||
var q = l + s - (l * s);
|
||||
|
||||
var p = 2 * l - q;
|
||||
|
||||
var tr = h + (1 / 3);
|
||||
var tg = h;
|
||||
var tb = h - (1 / 3);
|
||||
|
||||
var r = Math.round(hueToRGB(p, q, tr) * 255);
|
||||
var g = Math.round(hueToRGB(p, q, tg) * 255);
|
||||
var b = Math.round(hueToRGB(p, q, tb) * 255);
|
||||
return [r, g, b];
|
||||
|
||||
function hueToRGB(p, q, h) {
|
||||
if (h < 0)
|
||||
h += 1;
|
||||
else if (h > 1)
|
||||
h -= 1;
|
||||
|
||||
if ((h * 6) < 1)
|
||||
return p + (q - p) * h * 6;
|
||||
else if ((h * 2) < 1)
|
||||
return q;
|
||||
else if ((h * 3) < 2)
|
||||
return p + (q - p) * ((2 / 3) - h) * 6;
|
||||
else
|
||||
return p;
|
||||
}
|
||||
},
|
||||
|
||||
_rgbaToHSLA: function(rgba)
|
||||
{
|
||||
var alpha = rgba[3];
|
||||
var hsl = this._rgbToHSL(rgba)
|
||||
hsl.push(alpha);
|
||||
return hsl;
|
||||
},
|
||||
|
||||
_hslaToRGBA: function(hsla)
|
||||
{
|
||||
var alpha = hsla[3];
|
||||
var rgb = this._hslToRGB(hsla);
|
||||
rgb.push(alpha);
|
||||
return rgb;
|
||||
},
|
||||
|
||||
_parse: function()
|
||||
{
|
||||
// Special Values - Advanced but Must Be Parsed First - transparent
|
||||
var value = this.value.toLowerCase().replace(/%|\s+/g, "");
|
||||
if (value in WebInspector.Color.AdvancedNickNames) {
|
||||
this.format = "nickname";
|
||||
var set = WebInspector.Color.AdvancedNickNames[value];
|
||||
this.simple = false;
|
||||
this.rgba = set[0];
|
||||
this.hsla = set[1];
|
||||
this.nickname = set[2];
|
||||
this.alpha = set[0][3];
|
||||
return;
|
||||
}
|
||||
|
||||
// Simple - #hex, rgb(), nickname, hsl()
|
||||
var simple = /^(?:#([0-9a-f]{3,6})|rgb\(([^)]+)\)|(\w+)|hsl\(([^)]+)\))$/i;
|
||||
var match = this.value.match(simple);
|
||||
if (match) {
|
||||
this.simple = true;
|
||||
|
||||
if (match[1]) { // hex
|
||||
var hex = match[1].toUpperCase();
|
||||
if (hex.length === 3) {
|
||||
this.format = "shorthex";
|
||||
this.hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2);
|
||||
} else {
|
||||
this.format = "hex";
|
||||
this.hex = hex;
|
||||
}
|
||||
} else if (match[2]) { // rgb
|
||||
this.format = "rgb";
|
||||
var rgb = match[2].split(/\s*,\s*/);
|
||||
this.rgb = rgb;
|
||||
this.hex = this._rgbToHex(rgb);
|
||||
} else if (match[3]) { // nickname
|
||||
var nickname = match[3].toLowerCase();
|
||||
if (nickname in WebInspector.Color.Nicknames) {
|
||||
this.format = "nickname";
|
||||
this.hex = WebInspector.Color.Nicknames[nickname];
|
||||
} else // unknown name
|
||||
throw "unknown color name";
|
||||
} else if (match[4]) { // hsl
|
||||
this.format = "hsl";
|
||||
var hsl = match[4].replace(/%/g, "").split(/\s*,\s*/);
|
||||
this.hsl = hsl;
|
||||
this.rgb = this._hslToRGB(hsl);
|
||||
this.hex = this._rgbToHex(this.rgb);
|
||||
}
|
||||
|
||||
// Fill in the values if this is a known hex color
|
||||
var hex = this.hex;
|
||||
if (hex && hex in WebInspector.Color.HexTable) {
|
||||
var set = WebInspector.Color.HexTable[hex];
|
||||
this.rgb = set[0];
|
||||
this.hsl = set[1];
|
||||
this.nickname = set[2];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Advanced - rgba(), hsla()
|
||||
var advanced = /^(?:rgba\(([^)]+)\)|hsla\(([^)]+)\))$/;
|
||||
match = this.value.match(advanced);
|
||||
if (match) {
|
||||
this.simple = false;
|
||||
if (match[1]) { // rgba
|
||||
this.format = "rgba";
|
||||
this.rgba = match[1].split(/\s*,\s*/);
|
||||
this.hsla = this._rgbaToHSLA(this.rgba);
|
||||
this.alpha = this.rgba[3];
|
||||
} else if (match[2]) { // hsla
|
||||
this.format = "hsla";
|
||||
this.hsla = match[2].replace(/%/g, "").split(/\s*,\s*/);
|
||||
this.rgba = this._hslaToRGBA(this.hsla);
|
||||
this.alpha = this.hsla[3];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Could not parse as a valid color
|
||||
throw "could not parse color";
|
||||
}
|
||||
}
|
||||
|
||||
// Simple Values: [rgb, hsl, nickname]
|
||||
WebInspector.Color.HexTable = {
|
||||
"000000": [[0, 0, 0], [0, 0, 0], "black"],
|
||||
"000080": [[0, 0, 128], [240, 100, 25], "navy"],
|
||||
"00008B": [[0, 0, 139], [240, 100, 27], "darkBlue"],
|
||||
"0000CD": [[0, 0, 205], [240, 100, 40], "mediumBlue"],
|
||||
"0000FF": [[0, 0, 255], [240, 100, 50], "blue"],
|
||||
"006400": [[0, 100, 0], [120, 100, 20], "darkGreen"],
|
||||
"008000": [[0, 128, 0], [120, 100, 25], "green"],
|
||||
"008080": [[0, 128, 128], [180, 100, 25], "teal"],
|
||||
"008B8B": [[0, 139, 139], [180, 100, 27], "darkCyan"],
|
||||
"00BFFF": [[0, 191, 255], [195, 100, 50], "deepSkyBlue"],
|
||||
"00CED1": [[0, 206, 209], [181, 100, 41], "darkTurquoise"],
|
||||
"00FA9A": [[0, 250, 154], [157, 100, 49], "mediumSpringGreen"],
|
||||
"00FF00": [[0, 255, 0], [120, 100, 50], "lime"],
|
||||
"00FF7F": [[0, 255, 127], [150, 100, 50], "springGreen"],
|
||||
"00FFFF": [[0, 255, 255], [180, 100, 50], "cyan"],
|
||||
"191970": [[25, 25, 112], [240, 64, 27], "midnightBlue"],
|
||||
"1E90FF": [[30, 144, 255], [210, 100, 56], "dodgerBlue"],
|
||||
"20B2AA": [[32, 178, 170], [177, 70, 41], "lightSeaGreen"],
|
||||
"228B22": [[34, 139, 34], [120, 61, 34], "forestGreen"],
|
||||
"2E8B57": [[46, 139, 87], [146, 50, 36], "seaGreen"],
|
||||
"2F4F4F": [[47, 79, 79], [180, 25, 25], "darkSlateGray"],
|
||||
"32CD32": [[50, 205, 50], [120, 61, 50], "limeGreen"],
|
||||
"3CB371": [[60, 179, 113], [147, 50, 47], "mediumSeaGreen"],
|
||||
"40E0D0": [[64, 224, 208], [174, 72, 56], "turquoise"],
|
||||
"4169E1": [[65, 105, 225], [225, 73, 57], "royalBlue"],
|
||||
"4682B4": [[70, 130, 180], [207, 44, 49], "steelBlue"],
|
||||
"483D8B": [[72, 61, 139], [248, 39, 39], "darkSlateBlue"],
|
||||
"48D1CC": [[72, 209, 204], [178, 60, 55], "mediumTurquoise"],
|
||||
"4B0082": [[75, 0, 130], [275, 100, 25], "indigo"],
|
||||
"556B2F": [[85, 107, 47], [82, 39, 30], "darkOliveGreen"],
|
||||
"5F9EA0": [[95, 158, 160], [182, 25, 50], "cadetBlue"],
|
||||
"6495ED": [[100, 149, 237], [219, 79, 66], "cornflowerBlue"],
|
||||
"66CDAA": [[102, 205, 170], [160, 51, 60], "mediumAquaMarine"],
|
||||
"696969": [[105, 105, 105], [0, 0, 41], "dimGray"],
|
||||
"6A5ACD": [[106, 90, 205], [248, 53, 58], "slateBlue"],
|
||||
"6B8E23": [[107, 142, 35], [80, 60, 35], "oliveDrab"],
|
||||
"708090": [[112, 128, 144], [210, 13, 50], "slateGray"],
|
||||
"778899": [[119, 136, 153], [210, 14, 53], "lightSlateGray"],
|
||||
"7B68EE": [[123, 104, 238], [249, 80, 67], "mediumSlateBlue"],
|
||||
"7CFC00": [[124, 252, 0], [90, 100, 49], "lawnGreen"],
|
||||
"7FFF00": [[127, 255, 0], [90, 100, 50], "chartreuse"],
|
||||
"7FFFD4": [[127, 255, 212], [160, 100, 75], "aquamarine"],
|
||||
"800000": [[128, 0, 0], [0, 100, 25], "maroon"],
|
||||
"800080": [[128, 0, 128], [300, 100, 25], "purple"],
|
||||
"808000": [[128, 128, 0], [60, 100, 25], "olive"],
|
||||
"808080": [[128, 128, 128], [0, 0, 50], "gray"],
|
||||
"87CEEB": [[135, 206, 235], [197, 71, 73], "skyBlue"],
|
||||
"87CEFA": [[135, 206, 250], [203, 92, 75], "lightSkyBlue"],
|
||||
"8A2BE2": [[138, 43, 226], [271, 76, 53], "blueViolet"],
|
||||
"8B0000": [[139, 0, 0], [0, 100, 27], "darkRed"],
|
||||
"8B008B": [[139, 0, 139], [300, 100, 27], "darkMagenta"],
|
||||
"8B4513": [[139, 69, 19], [25, 76, 31], "saddleBrown"],
|
||||
"8FBC8F": [[143, 188, 143], [120, 25, 65], "darkSeaGreen"],
|
||||
"90EE90": [[144, 238, 144], [120, 73, 75], "lightGreen"],
|
||||
"9370D8": [[147, 112, 219], [260, 60, 65], "mediumPurple"],
|
||||
"9400D3": [[148, 0, 211], [282, 100, 41], "darkViolet"],
|
||||
"98FB98": [[152, 251, 152], [120, 93, 79], "paleGreen"],
|
||||
"9932CC": [[153, 50, 204], [280, 61, 50], "darkOrchid"],
|
||||
"9ACD32": [[154, 205, 50], [80, 61, 50], "yellowGreen"],
|
||||
"A0522D": [[160, 82, 45], [19, 56, 40], "sienna"],
|
||||
"A52A2A": [[165, 42, 42], [0, 59, 41], "brown"],
|
||||
"A9A9A9": [[169, 169, 169], [0, 0, 66], "darkGray"],
|
||||
"ADD8E6": [[173, 216, 230], [195, 53, 79], "lightBlue"],
|
||||
"ADFF2F": [[173, 255, 47], [84, 100, 59], "greenYellow"],
|
||||
"AFEEEE": [[175, 238, 238], [180, 65, 81], "paleTurquoise"],
|
||||
"B0C4DE": [[176, 196, 222], [214, 41, 78], "lightSteelBlue"],
|
||||
"B0E0E6": [[176, 224, 230], [187, 52, 80], "powderBlue"],
|
||||
"B22222": [[178, 34, 34], [0, 68, 42], "fireBrick"],
|
||||
"B8860B": [[184, 134, 11], [43, 89, 38], "darkGoldenrod"],
|
||||
"BA55D3": [[186, 85, 211], [288, 59, 58], "mediumOrchid"],
|
||||
"BC8F8F": [[188, 143, 143], [0, 25, 65], "rosyBrown"],
|
||||
"BDB76B": [[189, 183, 107], [56, 38, 58], "darkKhaki"],
|
||||
"C0C0C0": [[192, 192, 192], [0, 0, 75], "silver"],
|
||||
"C71585": [[199, 21, 133], [322, 81, 43], "mediumVioletRed"],
|
||||
"CD5C5C": [[205, 92, 92], [0, 53, 58], "indianRed"],
|
||||
"CD853F": [[205, 133, 63], [30, 59, 53], "peru"],
|
||||
"D2691E": [[210, 105, 30], [25, 75, 47], "chocolate"],
|
||||
"D2B48C": [[210, 180, 140], [34, 44, 69], "tan"],
|
||||
"D3D3D3": [[211, 211, 211], [0, 0, 83], "lightGrey"],
|
||||
"D87093": [[219, 112, 147], [340, 60, 65], "paleVioletRed"],
|
||||
"D8BFD8": [[216, 191, 216], [300, 24, 80], "thistle"],
|
||||
"DA70D6": [[218, 112, 214], [302, 59, 65], "orchid"],
|
||||
"DAA520": [[218, 165, 32], [43, 74, 49], "goldenrod"],
|
||||
"DC143C": [[237, 164, 61], [35, 83, 58], "crimson"],
|
||||
"DCDCDC": [[220, 220, 220], [0, 0, 86], "gainsboro"],
|
||||
"DDA0DD": [[221, 160, 221], [300, 47, 75], "plum"],
|
||||
"DEB887": [[222, 184, 135], [34, 57, 70], "burlyWood"],
|
||||
"E0FFFF": [[224, 255, 255], [180, 100, 94], "lightCyan"],
|
||||
"E6E6FA": [[230, 230, 250], [240, 67, 94], "lavender"],
|
||||
"E9967A": [[233, 150, 122], [15, 72, 70], "darkSalmon"],
|
||||
"EE82EE": [[238, 130, 238], [300, 76, 72], "violet"],
|
||||
"EEE8AA": [[238, 232, 170], [55, 67, 80], "paleGoldenrod"],
|
||||
"F08080": [[240, 128, 128], [0, 79, 72], "lightCoral"],
|
||||
"F0E68C": [[240, 230, 140], [54, 77, 75], "khaki"],
|
||||
"F0F8FF": [[240, 248, 255], [208, 100, 97], "aliceBlue"],
|
||||
"F0FFF0": [[240, 255, 240], [120, 100, 97], "honeyDew"],
|
||||
"F0FFFF": [[240, 255, 255], [180, 100, 97], "azure"],
|
||||
"F4A460": [[244, 164, 96], [28, 87, 67], "sandyBrown"],
|
||||
"F5DEB3": [[245, 222, 179], [39, 77, 83], "wheat"],
|
||||
"F5F5DC": [[245, 245, 220], [60, 56, 91], "beige"],
|
||||
"F5F5F5": [[245, 245, 245], [0, 0, 96], "whiteSmoke"],
|
||||
"F5FFFA": [[245, 255, 250], [150, 100, 98], "mintCream"],
|
||||
"F8F8FF": [[248, 248, 255], [240, 100, 99], "ghostWhite"],
|
||||
"FA8072": [[250, 128, 114], [6, 93, 71], "salmon"],
|
||||
"FAEBD7": [[250, 235, 215], [34, 78, 91], "antiqueWhite"],
|
||||
"FAF0E6": [[250, 240, 230], [30, 67, 94], "linen"],
|
||||
"FAFAD2": [[250, 250, 210], [60, 80, 90], "lightGoldenrodYellow"],
|
||||
"FDF5E6": [[253, 245, 230], [39, 85, 95], "oldLace"],
|
||||
"FF0000": [[255, 0, 0], [0, 100, 50], "red"],
|
||||
"FF00FF": [[255, 0, 255], [300, 100, 50], "magenta"],
|
||||
"FF1493": [[255, 20, 147], [328, 100, 54], "deepPink"],
|
||||
"FF4500": [[255, 69, 0], [16, 100, 50], "orangeRed"],
|
||||
"FF6347": [[255, 99, 71], [9, 100, 64], "tomato"],
|
||||
"FF69B4": [[255, 105, 180], [330, 100, 71], "hotPink"],
|
||||
"FF7F50": [[255, 127, 80], [16, 100, 66], "coral"],
|
||||
"FF8C00": [[255, 140, 0], [33, 100, 50], "darkOrange"],
|
||||
"FFA07A": [[255, 160, 122], [17, 100, 74], "lightSalmon"],
|
||||
"FFA500": [[255, 165, 0], [39, 100, 50], "orange"],
|
||||
"FFB6C1": [[255, 182, 193], [351, 100, 86], "lightPink"],
|
||||
"FFC0CB": [[255, 192, 203], [350, 100, 88], "pink"],
|
||||
"FFD700": [[255, 215, 0], [51, 100, 50], "gold"],
|
||||
"FFDAB9": [[255, 218, 185], [28, 100, 86], "peachPuff"],
|
||||
"FFDEAD": [[255, 222, 173], [36, 100, 84], "navajoWhite"],
|
||||
"FFE4B5": [[255, 228, 181], [38, 100, 85], "moccasin"],
|
||||
"FFE4C4": [[255, 228, 196], [33, 100, 88], "bisque"],
|
||||
"FFE4E1": [[255, 228, 225], [6, 100, 94], "mistyRose"],
|
||||
"FFEBCD": [[255, 235, 205], [36, 100, 90], "blanchedAlmond"],
|
||||
"FFEFD5": [[255, 239, 213], [37, 100, 92], "papayaWhip"],
|
||||
"FFF0F5": [[255, 240, 245], [340, 100, 97], "lavenderBlush"],
|
||||
"FFF5EE": [[255, 245, 238], [25, 100, 97], "seaShell"],
|
||||
"FFF8DC": [[255, 248, 220], [48, 100, 93], "cornsilk"],
|
||||
"FFFACD": [[255, 250, 205], [54, 100, 90], "lemonChiffon"],
|
||||
"FFFAF0": [[255, 250, 240], [40, 100, 97], "floralWhite"],
|
||||
"FFFAFA": [[255, 250, 250], [0, 100, 99], "snow"],
|
||||
"FFFF00": [[255, 255, 0], [60, 100, 50], "yellow"],
|
||||
"FFFFE0": [[255, 255, 224], [60, 100, 94], "lightYellow"],
|
||||
"FFFFF0": [[255, 255, 240], [60, 100, 97], "ivory"],
|
||||
"FFFFFF": [[255, 255, 255], [0, 100, 100], "white"]
|
||||
};
|
||||
|
||||
// Simple Values
|
||||
WebInspector.Color.Nicknames = {
|
||||
"aliceblue": "F0F8FF",
|
||||
"antiquewhite": "FAEBD7",
|
||||
"aqua": "00FFFF",
|
||||
"aquamarine": "7FFFD4",
|
||||
"azure": "F0FFFF",
|
||||
"beige": "F5F5DC",
|
||||
"bisque": "FFE4C4",
|
||||
"black": "000000",
|
||||
"blanchedalmond": "FFEBCD",
|
||||
"blue": "0000FF",
|
||||
"blueviolet": "8A2BE2",
|
||||
"brown": "A52A2A",
|
||||
"burlywood": "DEB887",
|
||||
"cadetblue": "5F9EA0",
|
||||
"chartreuse": "7FFF00",
|
||||
"chocolate": "D2691E",
|
||||
"coral": "FF7F50",
|
||||
"cornflowerblue": "6495ED",
|
||||
"cornsilk": "FFF8DC",
|
||||
"crimson": "DC143C",
|
||||
"cyan": "00FFFF",
|
||||
"darkblue": "00008B",
|
||||
"darkcyan": "008B8B",
|
||||
"darkgoldenrod": "B8860B",
|
||||
"darkgray": "A9A9A9",
|
||||
"darkgreen": "006400",
|
||||
"darkkhaki": "BDB76B",
|
||||
"darkmagenta": "8B008B",
|
||||
"darkolivegreen": "556B2F",
|
||||
"darkorange": "FF8C00",
|
||||
"darkorchid": "9932CC",
|
||||
"darkred": "8B0000",
|
||||
"darksalmon": "E9967A",
|
||||
"darkseagreen": "8FBC8F",
|
||||
"darkslateblue": "483D8B",
|
||||
"darkslategray": "2F4F4F",
|
||||
"darkturquoise": "00CED1",
|
||||
"darkviolet": "9400D3",
|
||||
"deeppink": "FF1493",
|
||||
"deepskyblue": "00BFFF",
|
||||
"dimgray": "696969",
|
||||
"dodgerblue": "1E90FF",
|
||||
"firebrick": "B22222",
|
||||
"floralwhite": "FFFAF0",
|
||||
"forestgreen": "228B22",
|
||||
"fuchsia": "FF00FF",
|
||||
"gainsboro": "DCDCDC",
|
||||
"ghostwhite": "F8F8FF",
|
||||
"gold": "FFD700",
|
||||
"goldenrod": "DAA520",
|
||||
"gray": "808080",
|
||||
"green": "008000",
|
||||
"greenyellow": "ADFF2F",
|
||||
"honeydew": "F0FFF0",
|
||||
"hotpink": "FF69B4",
|
||||
"indianred": "CD5C5C",
|
||||
"indigo": "4B0082",
|
||||
"ivory": "FFFFF0",
|
||||
"khaki": "F0E68C",
|
||||
"lavender": "E6E6FA",
|
||||
"lavenderblush": "FFF0F5",
|
||||
"lawngreen": "7CFC00",
|
||||
"lemonchiffon": "FFFACD",
|
||||
"lightblue": "ADD8E6",
|
||||
"lightcoral": "F08080",
|
||||
"lightcyan": "E0FFFF",
|
||||
"lightgoldenrodyellow": "FAFAD2",
|
||||
"lightgreen": "90EE90",
|
||||
"lightgrey": "D3D3D3",
|
||||
"lightpink": "FFB6C1",
|
||||
"lightsalmon": "FFA07A",
|
||||
"lightseagreen": "20B2AA",
|
||||
"lightskyblue": "87CEFA",
|
||||
"lightslategray": "778899",
|
||||
"lightsteelblue": "B0C4DE",
|
||||
"lightyellow": "FFFFE0",
|
||||
"lime": "00FF00",
|
||||
"limegreen": "32CD32",
|
||||
"linen": "FAF0E6",
|
||||
"magenta": "FF00FF",
|
||||
"maroon": "800000",
|
||||
"mediumaquamarine": "66CDAA",
|
||||
"mediumblue": "0000CD",
|
||||
"mediumorchid": "BA55D3",
|
||||
"mediumpurple": "9370D8",
|
||||
"mediumseagreen": "3CB371",
|
||||
"mediumslateblue": "7B68EE",
|
||||
"mediumspringgreen": "00FA9A",
|
||||
"mediumturquoise": "48D1CC",
|
||||
"mediumvioletred": "C71585",
|
||||
"midnightblue": "191970",
|
||||
"mintcream": "F5FFFA",
|
||||
"mistyrose": "FFE4E1",
|
||||
"moccasin": "FFE4B5",
|
||||
"navajowhite": "FFDEAD",
|
||||
"navy": "000080",
|
||||
"oldlace": "FDF5E6",
|
||||
"olive": "808000",
|
||||
"olivedrab": "6B8E23",
|
||||
"orange": "FFA500",
|
||||
"orangered": "FF4500",
|
||||
"orchid": "DA70D6",
|
||||
"palegoldenrod": "EEE8AA",
|
||||
"palegreen": "98FB98",
|
||||
"paleturquoise": "AFEEEE",
|
||||
"palevioletred": "D87093",
|
||||
"papayawhip": "FFEFD5",
|
||||
"peachpuff": "FFDAB9",
|
||||
"peru": "CD853F",
|
||||
"pink": "FFC0CB",
|
||||
"plum": "DDA0DD",
|
||||
"powderblue": "B0E0E6",
|
||||
"purple": "800080",
|
||||
"red": "FF0000",
|
||||
"rosybrown": "BC8F8F",
|
||||
"royalblue": "4169E1",
|
||||
"saddlebrown": "8B4513",
|
||||
"salmon": "FA8072",
|
||||
"sandybrown": "F4A460",
|
||||
"seagreen": "2E8B57",
|
||||
"seashell": "FFF5EE",
|
||||
"sienna": "A0522D",
|
||||
"silver": "C0C0C0",
|
||||
"skyblue": "87CEEB",
|
||||
"slateblue": "6A5ACD",
|
||||
"slategray": "708090",
|
||||
"snow": "FFFAFA",
|
||||
"springgreen": "00FF7F",
|
||||
"steelblue": "4682B4",
|
||||
"tan": "D2B48C",
|
||||
"teal": "008080",
|
||||
"thistle": "D8BFD8",
|
||||
"tomato": "FF6347",
|
||||
"turquoise": "40E0D0",
|
||||
"violet": "EE82EE",
|
||||
"wheat": "F5DEB3",
|
||||
"white": "FFFFFF",
|
||||
"whitesmoke": "F5F5F5",
|
||||
"yellow": "FFFF00",
|
||||
"yellowgreen": "9ACD32"
|
||||
};
|
||||
|
||||
// Advanced Values [rgba, hsla, nickname]
|
||||
WebInspector.Color.AdvancedNickNames = {
|
||||
"transparent": [[0, 0, 0, 0], [0, 0, 0, 0], "transparent"],
|
||||
"rgba(0,0,0,0)": [[0, 0, 0, 0], [0, 0, 0, 0], "transparent"],
|
||||
"hsla(0,0,0,0)": [[0, 0, 0, 0], [0, 0, 0, 0], "transparent"],
|
||||
};
|
86
node_modules/weinre/web/client/ConsolePanel.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Joseph Pecoraro
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.ConsolePanel = function()
|
||||
{
|
||||
WebInspector.Panel.call(this, "console");
|
||||
}
|
||||
|
||||
WebInspector.ConsolePanel.prototype = {
|
||||
get toolbarItemLabel()
|
||||
{
|
||||
return WebInspector.UIString("Console");
|
||||
},
|
||||
|
||||
show: function()
|
||||
{
|
||||
WebInspector.Panel.prototype.show.call(this);
|
||||
|
||||
this._previousConsoleState = WebInspector.drawer.state;
|
||||
WebInspector.drawer.enterPanelMode();
|
||||
WebInspector.showConsole();
|
||||
|
||||
// Move the scope bar to the top of the messages, like the resources filter.
|
||||
var scopeBar = document.getElementById("console-filter");
|
||||
var consoleMessages = document.getElementById("console-messages");
|
||||
|
||||
scopeBar.parentNode.removeChild(scopeBar);
|
||||
document.getElementById("console-view").insertBefore(scopeBar, consoleMessages);
|
||||
|
||||
// Update styles, and give console-messages a top margin so it doesn't overwrite the scope bar.
|
||||
scopeBar.addStyleClass("console-filter-top");
|
||||
scopeBar.removeStyleClass("status-bar-item");
|
||||
|
||||
consoleMessages.addStyleClass("console-filter-top");
|
||||
},
|
||||
|
||||
hide: function()
|
||||
{
|
||||
WebInspector.Panel.prototype.hide.call(this);
|
||||
|
||||
if (this._previousConsoleState === WebInspector.Drawer.State.Hidden)
|
||||
WebInspector.drawer.immediatelyExitPanelMode();
|
||||
else
|
||||
WebInspector.drawer.exitPanelMode();
|
||||
delete this._previousConsoleState;
|
||||
|
||||
// Move the scope bar back to the bottom bar, next to Clear Console.
|
||||
var scopeBar = document.getElementById("console-filter");
|
||||
|
||||
scopeBar.parentNode.removeChild(scopeBar);
|
||||
document.getElementById("other-drawer-status-bar-items").appendChild(scopeBar);
|
||||
|
||||
// Update styles, and remove the top margin on console-messages.
|
||||
scopeBar.removeStyleClass("console-filter-top");
|
||||
scopeBar.addStyleClass("status-bar-item");
|
||||
|
||||
document.getElementById("console-messages").removeStyleClass("console-filter-top");
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ConsolePanel.prototype.__proto__ = WebInspector.Panel.prototype;
|
1156
node_modules/weinre/web/client/ConsoleView.js
generated
vendored
Normal file
91
node_modules/weinre/web/client/ContextMenu.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.ContextMenu = function() {
|
||||
this._items = [];
|
||||
this._handlers = {};
|
||||
}
|
||||
|
||||
WebInspector.ContextMenu.prototype = {
|
||||
show: function(event)
|
||||
{
|
||||
// Remove trailing separator.
|
||||
while (this._items.length > 0 && !("id" in this._items[this._items.length - 1]))
|
||||
this._items.splice(this._items.length - 1, 1);
|
||||
|
||||
if (this._items.length) {
|
||||
WebInspector._contextMenu = this;
|
||||
InspectorFrontendHost.showContextMenu(event, this._items);
|
||||
}
|
||||
event.stopPropagation();
|
||||
},
|
||||
|
||||
appendItem: function(label, handler, disabled)
|
||||
{
|
||||
var id = this._items.length;
|
||||
this._items.push({type: "item", id: id, label: label, enabled: !disabled});
|
||||
this._handlers[id] = handler;
|
||||
},
|
||||
|
||||
appendCheckboxItem: function(label, handler, checked, disabled)
|
||||
{
|
||||
var id = this._items.length;
|
||||
this._items.push({type: "checkbox", id: id, label: label, checked: !!checked, enabled: !disabled});
|
||||
this._handlers[id] = handler;
|
||||
},
|
||||
|
||||
appendSeparator: function()
|
||||
{
|
||||
// No separator dupes allowed.
|
||||
if (this._items.length === 0)
|
||||
return;
|
||||
if (!("id" in this._items[this._items.length - 1]))
|
||||
return;
|
||||
this._items.push({type: "separator"});
|
||||
},
|
||||
|
||||
_itemSelected: function(id)
|
||||
{
|
||||
if (this._handlers[id])
|
||||
this._handlers[id].call(this);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.contextMenuItemSelected = function(id)
|
||||
{
|
||||
if (WebInspector._contextMenu)
|
||||
WebInspector._contextMenu._itemSelected(id);
|
||||
}
|
||||
|
||||
WebInspector.contextMenuCleared = function()
|
||||
{
|
||||
// FIXME: Unfortunately, contextMenuCleared is invoked between show and item selected
|
||||
// so we can't delete last menu object from WebInspector. Fix the contract.
|
||||
}
|
201
node_modules/weinre/web/client/CookieItemsView.js
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009 Joseph Pecoraro
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.CookieItemsView = function(treeElement, cookieDomain)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
|
||||
this.element.addStyleClass("storage-view");
|
||||
|
||||
this._deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString("Delete"), "delete-storage-status-bar-item");
|
||||
this._deleteButton.visible = false;
|
||||
this._deleteButton.addEventListener("click", this._deleteButtonClicked.bind(this), false);
|
||||
|
||||
this._refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
|
||||
this._refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
|
||||
|
||||
this._treeElement = treeElement;
|
||||
this._cookieDomain = cookieDomain;
|
||||
|
||||
this._emptyMsgElement = document.createElement("div");
|
||||
this._emptyMsgElement.className = "storage-empty-view";
|
||||
this._emptyMsgElement.textContent = WebInspector.UIString("This site has no cookies.");
|
||||
this.element.appendChild(this._emptyMsgElement);
|
||||
}
|
||||
|
||||
WebInspector.CookieItemsView.prototype = {
|
||||
get statusBarItems()
|
||||
{
|
||||
return [this._refreshButton.element, this._deleteButton.element];
|
||||
},
|
||||
|
||||
show: function(parentElement)
|
||||
{
|
||||
WebInspector.View.prototype.show.call(this, parentElement);
|
||||
this._update();
|
||||
},
|
||||
|
||||
hide: function()
|
||||
{
|
||||
WebInspector.View.prototype.hide.call(this);
|
||||
this._deleteButton.visible = false;
|
||||
},
|
||||
|
||||
resize: function()
|
||||
{
|
||||
if (this._cookiesTable)
|
||||
this._cookiesTable.updateWidths();
|
||||
},
|
||||
|
||||
_update: function()
|
||||
{
|
||||
WebInspector.Cookies.getCookiesAsync(this._updateWithCookies.bind(this));
|
||||
},
|
||||
|
||||
_updateWithCookies: function(allCookies, isAdvanced)
|
||||
{
|
||||
this._cookies = isAdvanced ? this._filterCookiesForDomain(allCookies) : allCookies;
|
||||
|
||||
if (!this._cookies.length) {
|
||||
// Nothing to show.
|
||||
this._emptyMsgElement.removeStyleClass("hidden");
|
||||
this._deleteButton.visible = false;
|
||||
if (this._cookiesTable)
|
||||
this._cookiesTable.element.addStyleClass("hidden");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._cookiesTable) {
|
||||
this._cookiesTable = isAdvanced ? new WebInspector.CookiesTable(this._cookieDomain, false, this._deleteCookie.bind(this)) : new WebInspector.SimpleCookiesTable();
|
||||
this.element.appendChild(this._cookiesTable.element);
|
||||
}
|
||||
|
||||
this._cookiesTable.setCookies(this._cookies);
|
||||
this._cookiesTable.element.removeStyleClass("hidden");
|
||||
this._emptyMsgElement.addStyleClass("hidden");
|
||||
if (isAdvanced) {
|
||||
this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), this._cookies.length,
|
||||
Number.bytesToString(this._totalSize));
|
||||
this._deleteButton.visible = true;
|
||||
}
|
||||
this._cookiesTable.updateWidths();
|
||||
},
|
||||
|
||||
_filterCookiesForDomain: function(allCookies)
|
||||
{
|
||||
var cookies = [];
|
||||
var resourceURLsForDocumentURL = [];
|
||||
this._totalSize = 0;
|
||||
|
||||
function populateResourcesForDocuments(resource)
|
||||
{
|
||||
var url = resource.documentURL.asParsedURL();
|
||||
if (url && url.host == this._cookieDomain)
|
||||
resourceURLsForDocumentURL.push(resource.url);
|
||||
}
|
||||
WebInspector.forAllResources(populateResourcesForDocuments.bind(this));
|
||||
|
||||
for (var i = 0; i < allCookies.length; ++i) {
|
||||
var pushed = false;
|
||||
var size = allCookies[i].size;
|
||||
for (var j = 0; j < resourceURLsForDocumentURL.length; ++j) {
|
||||
var resourceURL = resourceURLsForDocumentURL[j];
|
||||
if (WebInspector.Cookies.cookieMatchesResourceURL(allCookies[i], resourceURL)) {
|
||||
this._totalSize += size;
|
||||
if (!pushed) {
|
||||
pushed = true;
|
||||
cookies.push(allCookies[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookies;
|
||||
},
|
||||
|
||||
_deleteCookie: function(cookie)
|
||||
{
|
||||
InspectorBackend.deleteCookie(cookie.name, this._cookieDomain);
|
||||
this._update();
|
||||
},
|
||||
|
||||
_deleteButtonClicked: function()
|
||||
{
|
||||
if (this._cookiesTable.selectedCookie)
|
||||
this._deleteCookie(this._cookiesTable.selectedCookie);
|
||||
},
|
||||
|
||||
_refreshButtonClicked: function(event)
|
||||
{
|
||||
this._update();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.CookieItemsView.prototype.__proto__ = WebInspector.View.prototype;
|
||||
|
||||
WebInspector.SimpleCookiesTable = function()
|
||||
{
|
||||
this.element = document.createElement("div");
|
||||
var columns = {};
|
||||
columns[0] = {};
|
||||
columns[1] = {};
|
||||
columns[0].title = WebInspector.UIString("Name");
|
||||
columns[1].title = WebInspector.UIString("Value");
|
||||
|
||||
this._dataGrid = new WebInspector.DataGrid(columns);
|
||||
this._dataGrid.autoSizeColumns(20, 80);
|
||||
this.element.appendChild(this._dataGrid.element);
|
||||
this._dataGrid.updateWidths();
|
||||
}
|
||||
|
||||
WebInspector.SimpleCookiesTable.prototype = {
|
||||
setCookies: function(cookies)
|
||||
{
|
||||
this._dataGrid.removeChildren();
|
||||
var addedCookies = {};
|
||||
for (var i = 0; i < cookies.length; ++i) {
|
||||
if (addedCookies[cookies[i].name])
|
||||
continue;
|
||||
addedCookies[cookies[i].name] = true;
|
||||
var data = {};
|
||||
data[0] = cookies[i].name;
|
||||
data[1] = cookies[i].value;
|
||||
|
||||
var node = new WebInspector.DataGridNode(data, false);
|
||||
node.selectable = true;
|
||||
this._dataGrid.appendChild(node);
|
||||
}
|
||||
this._dataGrid.children[0].selected = true;
|
||||
},
|
||||
|
||||
resize: function()
|
||||
{
|
||||
if (this._dataGrid)
|
||||
this._dataGrid.updateWidths();
|
||||
}
|
||||
}
|
210
node_modules/weinre/web/client/CookieParser.js
generated
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
// Ideally, we would rely on platform support for parsing a cookie, since
|
||||
// this would save us from any potential inconsistency. However, exposing
|
||||
// platform cookie parsing logic would require quite a bit of additional
|
||||
// plumbing, and at least some platforms lack support for parsing Cookie,
|
||||
// which is in a format slightly different from Set-Cookie and is normally
|
||||
// only required on the server side.
|
||||
|
||||
WebInspector.CookieParser = function()
|
||||
{
|
||||
}
|
||||
|
||||
WebInspector.CookieParser.prototype = {
|
||||
get cookies()
|
||||
{
|
||||
return this._cookies;
|
||||
},
|
||||
|
||||
parseCookie: function(cookieHeader)
|
||||
{
|
||||
if (!this._initialize(cookieHeader))
|
||||
return;
|
||||
|
||||
for (var kv = this._extractKeyValue(); kv; kv = this._extractKeyValue()) {
|
||||
if (kv.key.charAt(0) === "$" && this._lastCookie)
|
||||
this._lastCookie.addAttribute(kv.key.slice(1), kv.value);
|
||||
else if (kv.key.toLowerCase() !== "$version" && typeof kv.value === "string")
|
||||
this._addCookie(kv, WebInspector.Cookie.Type.Request);
|
||||
this._advanceAndCheckCookieDelimiter();
|
||||
}
|
||||
this._flushCookie();
|
||||
return this._cookies;
|
||||
},
|
||||
|
||||
parseSetCookie: function(setCookieHeader)
|
||||
{
|
||||
if (!this._initialize(setCookieHeader))
|
||||
return;
|
||||
for (var kv = this._extractKeyValue(); kv; kv = this._extractKeyValue()) {
|
||||
if (this._lastCookie)
|
||||
this._lastCookie.addAttribute(kv.key, kv.value);
|
||||
else
|
||||
this._addCookie(kv, WebInspector.Cookie.Type.Response);
|
||||
if (this._advanceAndCheckCookieDelimiter())
|
||||
this._flushCookie();
|
||||
}
|
||||
this._flushCookie();
|
||||
return this._cookies;
|
||||
},
|
||||
|
||||
_initialize: function(headerValue)
|
||||
{
|
||||
this._input = headerValue;
|
||||
if (typeof headerValue !== "string")
|
||||
return false;
|
||||
this._cookies = [];
|
||||
this._lastCookie = null;
|
||||
this._originalInputLength = this._input.length;
|
||||
return true;
|
||||
},
|
||||
|
||||
_flushCookie: function()
|
||||
{
|
||||
if (this._lastCookie)
|
||||
this._lastCookie.size = this._originalInputLength - this._input.length - this._lastCookiePosition;
|
||||
this._lastCookie = null;
|
||||
},
|
||||
|
||||
_extractKeyValue: function()
|
||||
{
|
||||
if (!this._input || !this._input.length)
|
||||
return null;
|
||||
// Note: RFCs offer an option for quoted values that may contain commas and semicolons.
|
||||
// Many browsers/platforms do not support this, however (see http://webkit.org/b/16699
|
||||
// and http://crbug.com/12361). The logic below matches latest versions of IE, Firefox,
|
||||
// Chrome and Safari on some old platforms. The latest version of Safari supports quoted
|
||||
// cookie values, though.
|
||||
var keyValueMatch = /^[ \t]*([^\s=;]+)[ \t]*(?:=[ \t]*([^;\n]*))?/.exec(this._input);
|
||||
if (!keyValueMatch) {
|
||||
console.log("Failed parsing cookie header before: " + this._input);
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = {
|
||||
key: keyValueMatch[1],
|
||||
value: keyValueMatch[2] && keyValueMatch[2].trim(),
|
||||
position: this._originalInputLength - this._input.length
|
||||
};
|
||||
this._input = this._input.slice(keyValueMatch[0].length);
|
||||
return result;
|
||||
},
|
||||
|
||||
_advanceAndCheckCookieDelimiter: function()
|
||||
{
|
||||
var match = /^\s*[\n;]\s*/.exec(this._input);
|
||||
if (!match)
|
||||
return false;
|
||||
this._input = this._input.slice(match[0].length);
|
||||
return match[0].match("\n") !== null;
|
||||
},
|
||||
|
||||
_addCookie: function(keyValue, type)
|
||||
{
|
||||
if (this._lastCookie)
|
||||
this._lastCookie.size = keyValue.position - this._lastCookiePosition;
|
||||
// Mozilla bug 169091: Mozilla, IE and Chrome treat single token (w/o "=") as
|
||||
// specifying a value for a cookie with empty name.
|
||||
this._lastCookie = keyValue.value ? new WebInspector.Cookie(keyValue.key, keyValue.value, type) :
|
||||
new WebInspector.Cookie("", keyValue.key, type);
|
||||
this._lastCookiePosition = keyValue.position;
|
||||
this._cookies.push(this._lastCookie);
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.CookieParser.parseCookie = function(header)
|
||||
{
|
||||
return (new WebInspector.CookieParser()).parseCookie(header);
|
||||
}
|
||||
|
||||
WebInspector.CookieParser.parseSetCookie = function(header)
|
||||
{
|
||||
return (new WebInspector.CookieParser()).parseSetCookie(header);
|
||||
}
|
||||
|
||||
WebInspector.Cookie = function(name, value, type)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this._attributes = {};
|
||||
}
|
||||
|
||||
WebInspector.Cookie.prototype = {
|
||||
get httpOnly()
|
||||
{
|
||||
return "httponly" in this._attributes;
|
||||
},
|
||||
|
||||
get secure()
|
||||
{
|
||||
return "secure" in this._attributes;
|
||||
},
|
||||
|
||||
get session()
|
||||
{
|
||||
// RFC 2965 suggests using Discard attribute to mark session cookies, but this does not seem to be widely used.
|
||||
// Check for absence of explicity max-age or expiry date instead.
|
||||
return !("expries" in this._attributes || "max-age" in this._attributes);
|
||||
},
|
||||
|
||||
get path()
|
||||
{
|
||||
return this._attributes.path;
|
||||
},
|
||||
|
||||
get domain()
|
||||
{
|
||||
return this._attributes.domain;
|
||||
},
|
||||
|
||||
expires: function(requestDate)
|
||||
{
|
||||
return this._attributes.expires ? new Date(this._attributes.expires) :
|
||||
(this._attributes["max-age"] ? new Date(requestDate.getTime() + 1000 * this._attributes["max-age"]) : null);
|
||||
},
|
||||
|
||||
get attributes()
|
||||
{
|
||||
return this._attributes;
|
||||
},
|
||||
|
||||
addAttribute: function(key, value)
|
||||
{
|
||||
this._attributes[key.toLowerCase()] = value;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.Cookie.Type = {
|
||||
Request: 0,
|
||||
Response: 1
|
||||
};
|
205
node_modules/weinre/web/client/CookiesTable.js
generated
vendored
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009 Joseph Pecoraro
|
||||
* Copyright (C) 2010 Google 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.CookiesTable = function(cookieDomain, expandable, deleteCallback)
|
||||
{
|
||||
this._cookieDomain = cookieDomain;
|
||||
|
||||
var columns = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {} };
|
||||
columns[0].title = WebInspector.UIString("Name");
|
||||
columns[0].sortable = true;
|
||||
columns[0].disclosure = expandable;
|
||||
columns[0].width = "24%";
|
||||
columns[1].title = WebInspector.UIString("Value");
|
||||
columns[1].sortable = true;
|
||||
columns[1].width = "34%";
|
||||
columns[2].title = WebInspector.UIString("Domain");
|
||||
columns[2].sortable = true;
|
||||
columns[2].width = "7%";
|
||||
columns[3].title = WebInspector.UIString("Path");
|
||||
columns[3].sortable = true;
|
||||
columns[3].width = "7%";
|
||||
columns[4].title = WebInspector.UIString("Expires");
|
||||
columns[4].sortable = true;
|
||||
columns[4].width = "7%";
|
||||
columns[5].title = WebInspector.UIString("Size");
|
||||
columns[5].aligned = "right";
|
||||
columns[5].sortable = true;
|
||||
columns[5].width = "7%";
|
||||
columns[6].title = WebInspector.UIString("HTTP");
|
||||
columns[6].aligned = "centered";
|
||||
columns[6].sortable = true;
|
||||
columns[6].width = "7%";
|
||||
columns[7].title = WebInspector.UIString("Secure");
|
||||
columns[7].aligned = "centered";
|
||||
columns[7].sortable = true;
|
||||
columns[7].width = "7%";
|
||||
|
||||
this._dataGrid = new WebInspector.DataGrid(columns, null, deleteCallback ? this._onDeleteFromGrid.bind(this) : null);
|
||||
this._dataGrid.addEventListener("sorting changed", this._rebuildTable, this);
|
||||
|
||||
this.element = this._dataGrid.element;
|
||||
this._data = [];
|
||||
this._deleteCallback = deleteCallback;
|
||||
}
|
||||
|
||||
WebInspector.CookiesTable.prototype = {
|
||||
updateWidths: function()
|
||||
{
|
||||
if (this._dataGrid)
|
||||
this._dataGrid.updateWidths();
|
||||
},
|
||||
|
||||
setCookies: function(cookies)
|
||||
{
|
||||
this._data = [{cookies: cookies}];
|
||||
this._rebuildTable();
|
||||
},
|
||||
|
||||
addCookiesFolder: function(folderName, cookies)
|
||||
{
|
||||
this._data.push({cookies: cookies, folderName: folderName});
|
||||
this._rebuildTable();
|
||||
},
|
||||
|
||||
get selectedCookie()
|
||||
{
|
||||
var node = this._dataGrid.selectedNode;
|
||||
return node ? node.cookie : null;
|
||||
},
|
||||
|
||||
_rebuildTable: function()
|
||||
{
|
||||
this._dataGrid.removeChildren();
|
||||
for (var i = 0; i < this._data.length; ++i) {
|
||||
var item = this._data[i];
|
||||
if (item.folderName) {
|
||||
var groupData = [ item.folderName, "", "", "", "", this._totalSize(item.cookies), "", "" ];
|
||||
var groupNode = new WebInspector.DataGridNode(groupData);
|
||||
groupNode.selectable = true;
|
||||
this._dataGrid.appendChild(groupNode);
|
||||
groupNode.element.addStyleClass("row-group");
|
||||
this._populateNode(groupNode, item.cookies);
|
||||
groupNode.expand();
|
||||
} else
|
||||
this._populateNode(this._dataGrid, item.cookies);
|
||||
}
|
||||
},
|
||||
|
||||
_populateNode: function(parentNode, cookies)
|
||||
{
|
||||
var selectedCookie = this.selectedCookie;
|
||||
parentNode.removeChildren();
|
||||
if (!cookies)
|
||||
return;
|
||||
|
||||
this._sortCookies(cookies);
|
||||
for (var i = 0; i < cookies.length; ++i) {
|
||||
var cookieNode = this._createGridNode(cookies[i]);
|
||||
parentNode.appendChild(cookieNode);
|
||||
if (selectedCookie === cookies[i])
|
||||
cookieNode.selected = true;
|
||||
}
|
||||
},
|
||||
|
||||
_totalSize: function(cookies)
|
||||
{
|
||||
var totalSize = 0;
|
||||
for (var i = 0; cookies && i < cookies.length; ++i)
|
||||
totalSize += cookies[i].size;
|
||||
return totalSize;
|
||||
},
|
||||
|
||||
_sortCookies: function(cookies)
|
||||
{
|
||||
var sortDirection = this._dataGrid.sortOrder === "ascending" ? 1 : -1;
|
||||
|
||||
function localeCompare(field, cookie1, cookie2)
|
||||
{
|
||||
return sortDirection * (cookie1[field] + "").localeCompare(cookie2[field] + "")
|
||||
}
|
||||
|
||||
function numberCompare(field, cookie1, cookie2)
|
||||
{
|
||||
return sortDirection * (cookie1[field] - cookie2[field]);
|
||||
}
|
||||
|
||||
function expiresCompare(cookie1, cookie2)
|
||||
{
|
||||
if (cookie1.session !== cookie2.session)
|
||||
return sortDirection * (cookie1.session ? 1 : -1);
|
||||
|
||||
if (cookie1.session)
|
||||
return 0;
|
||||
|
||||
return sortDirection * (cookie1.expires - cookie2.expires);
|
||||
}
|
||||
|
||||
var comparator;
|
||||
switch (parseInt(this._dataGrid.sortColumnIdentifier)) {
|
||||
case 0: comparator = localeCompare.bind(this, "name"); break;
|
||||
case 1: comparator = localeCompare.bind(this, "value"); break;
|
||||
case 2: comparator = localeCompare.bind(this, "domain"); break;
|
||||
case 3: comparator = localeCompare.bind(this, "path"); break;
|
||||
case 4: comparator = expiresCompare; break;
|
||||
case 5: comparator = numberCompare.bind(this, "size"); break;
|
||||
case 6: comparator = localeCompare.bind(this, "httpOnly"); break;
|
||||
case 7: comparator = localeCompare.bind(this, "secure"); break;
|
||||
default: localeCompare.bind(this, "name");
|
||||
}
|
||||
|
||||
cookies.sort(comparator);
|
||||
},
|
||||
|
||||
_createGridNode: function(cookie)
|
||||
{
|
||||
var data = {};
|
||||
data[0] = cookie.name;
|
||||
data[1] = cookie.value;
|
||||
data[2] = cookie.domain || "";
|
||||
data[3] = cookie.path || "";
|
||||
data[4] = cookie.type === WebInspector.Cookie.Type.Request ? "" :
|
||||
(cookie.session ? WebInspector.UIString("Session") : new Date(cookie.expires).toGMTString());
|
||||
data[5] = cookie.size;
|
||||
var checkmark = "\u2713";
|
||||
data[6] = (cookie.httpOnly ? checkmark : "");
|
||||
data[7] = (cookie.secure ? checkmark : "");
|
||||
|
||||
var node = new WebInspector.DataGridNode(data);
|
||||
node.cookie = cookie;
|
||||
node.selectable = true;
|
||||
return node;
|
||||
},
|
||||
|
||||
_onDeleteFromGrid: function(node)
|
||||
{
|
||||
this._deleteCallback(node.cookie);
|
||||
}
|
||||
}
|
589
node_modules/weinre/web/client/DOMAgent.js
generated
vendored
Normal file
@ -0,0 +1,589 @@
|
||||
/*
|
||||
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
|
||||
* Copyright (C) 2009 Joseph Pecoraro
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.DOMNode = function(doc, payload) {
|
||||
this.ownerDocument = doc;
|
||||
|
||||
this.id = payload.id;
|
||||
this.nodeType = payload.nodeType;
|
||||
this.nodeName = payload.nodeName;
|
||||
this.localName = payload.localName;
|
||||
this._nodeValue = payload.nodeValue;
|
||||
this.textContent = this.nodeValue;
|
||||
|
||||
this.attributes = [];
|
||||
this._attributesMap = {};
|
||||
if (payload.attributes)
|
||||
this._setAttributesPayload(payload.attributes);
|
||||
|
||||
this._childNodeCount = payload.childNodeCount;
|
||||
this.children = null;
|
||||
|
||||
this.nextSibling = null;
|
||||
this.prevSibling = null;
|
||||
this.firstChild = null;
|
||||
this.lastChild = null;
|
||||
this.parentNode = null;
|
||||
|
||||
if (payload.children)
|
||||
this._setChildrenPayload(payload.children);
|
||||
|
||||
this._computedStyle = null;
|
||||
this.style = null;
|
||||
this._matchedCSSRules = [];
|
||||
|
||||
this.breakpoints = {};
|
||||
|
||||
if (this.nodeType === Node.ELEMENT_NODE) {
|
||||
// HTML and BODY from internal iframes should not overwrite top-level ones.
|
||||
if (!this.ownerDocument.documentElement && this.nodeName === "HTML")
|
||||
this.ownerDocument.documentElement = this;
|
||||
if (!this.ownerDocument.body && this.nodeName === "BODY")
|
||||
this.ownerDocument.body = this;
|
||||
if (payload.documentURL)
|
||||
this.documentURL = payload.documentURL;
|
||||
} else if (this.nodeType === Node.DOCUMENT_TYPE_NODE) {
|
||||
this.publicId = payload.publicId;
|
||||
this.systemId = payload.systemId;
|
||||
this.internalSubset = payload.internalSubset;
|
||||
} else if (this.nodeType === Node.DOCUMENT_NODE) {
|
||||
this.documentURL = payload.documentURL;
|
||||
} else if (this.nodeType === Node.ATTRIBUTE_NODE) {
|
||||
this.name = payload.name;
|
||||
this.value = payload.value;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DOMNode.prototype = {
|
||||
hasAttributes: function()
|
||||
{
|
||||
return this.attributes.length > 0;
|
||||
},
|
||||
|
||||
hasChildNodes: function()
|
||||
{
|
||||
return this._childNodeCount > 0;
|
||||
},
|
||||
|
||||
get nodeValue() {
|
||||
return this._nodeValue;
|
||||
},
|
||||
|
||||
set nodeValue(value) {
|
||||
if (this.nodeType != Node.TEXT_NODE)
|
||||
return;
|
||||
this.ownerDocument._domAgent.setTextNodeValueAsync(this, value, function() {});
|
||||
},
|
||||
|
||||
getAttribute: function(name)
|
||||
{
|
||||
var attr = this._attributesMap[name];
|
||||
return attr ? attr.value : undefined;
|
||||
},
|
||||
|
||||
setAttribute: function(name, value)
|
||||
{
|
||||
var self = this;
|
||||
var callback = function()
|
||||
{
|
||||
var attr = self._attributesMap[name];
|
||||
if (attr)
|
||||
attr.value = value;
|
||||
else
|
||||
attr = self._addAttribute(name, value);
|
||||
};
|
||||
this.ownerDocument._domAgent.setAttributeAsync(this, name, value, callback);
|
||||
},
|
||||
|
||||
removeAttribute: function(name)
|
||||
{
|
||||
var self = this;
|
||||
var callback = function()
|
||||
{
|
||||
delete self._attributesMap[name];
|
||||
for (var i = 0; i < self.attributes.length; ++i) {
|
||||
if (self.attributes[i].name == name) {
|
||||
self.attributes.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.ownerDocument._domAgent.removeAttributeAsync(this, name, callback);
|
||||
},
|
||||
|
||||
path: function()
|
||||
{
|
||||
var path = [];
|
||||
var node = this;
|
||||
while (node && "index" in node && node.nodeName.length) {
|
||||
path.push([node.index, node.nodeName]);
|
||||
node = node.parentNode;
|
||||
}
|
||||
path.reverse();
|
||||
return path.join(",");
|
||||
},
|
||||
|
||||
_setAttributesPayload: function(attrs)
|
||||
{
|
||||
this.attributes = [];
|
||||
this._attributesMap = {};
|
||||
for (var i = 0; i < attrs.length; i += 2)
|
||||
this._addAttribute(attrs[i], attrs[i + 1]);
|
||||
},
|
||||
|
||||
_insertChild: function(prev, payload)
|
||||
{
|
||||
var node = new WebInspector.DOMNode(this.ownerDocument, payload);
|
||||
if (!prev) {
|
||||
if (!this.children) {
|
||||
// First node
|
||||
this.children = [ node ];
|
||||
} else
|
||||
this.children.unshift(node);
|
||||
} else
|
||||
this.children.splice(this.children.indexOf(prev) + 1, 0, node);
|
||||
this._renumber();
|
||||
return node;
|
||||
},
|
||||
|
||||
removeChild_: function(node)
|
||||
{
|
||||
this.children.splice(this.children.indexOf(node), 1);
|
||||
node.parentNode = null;
|
||||
this._renumber();
|
||||
},
|
||||
|
||||
_setChildrenPayload: function(payloads)
|
||||
{
|
||||
this.children = [];
|
||||
for (var i = 0; i < payloads.length; ++i) {
|
||||
var payload = payloads[i];
|
||||
var node = new WebInspector.DOMNode(this.ownerDocument, payload);
|
||||
this.children.push(node);
|
||||
}
|
||||
this._renumber();
|
||||
},
|
||||
|
||||
_renumber: function()
|
||||
{
|
||||
this._childNodeCount = this.children.length;
|
||||
if (this._childNodeCount == 0) {
|
||||
this.firstChild = null;
|
||||
this.lastChild = null;
|
||||
return;
|
||||
}
|
||||
this.firstChild = this.children[0];
|
||||
this.lastChild = this.children[this._childNodeCount - 1];
|
||||
for (var i = 0; i < this._childNodeCount; ++i) {
|
||||
var child = this.children[i];
|
||||
child.index = i;
|
||||
child.nextSibling = i + 1 < this._childNodeCount ? this.children[i + 1] : null;
|
||||
child.prevSibling = i - 1 >= 0 ? this.children[i - 1] : null;
|
||||
child.parentNode = this;
|
||||
}
|
||||
},
|
||||
|
||||
_addAttribute: function(name, value)
|
||||
{
|
||||
var attr = {
|
||||
"name": name,
|
||||
"value": value,
|
||||
"_node": this
|
||||
};
|
||||
this._attributesMap[name] = attr;
|
||||
this.attributes.push(attr);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DOMDocument = function(domAgent, defaultView, payload)
|
||||
{
|
||||
WebInspector.DOMNode.call(this, this, payload);
|
||||
this._listeners = {};
|
||||
this._domAgent = domAgent;
|
||||
this.defaultView = defaultView;
|
||||
}
|
||||
|
||||
WebInspector.DOMDocument.prototype = {
|
||||
|
||||
addEventListener: function(name, callback)
|
||||
{
|
||||
var listeners = this._listeners[name];
|
||||
if (!listeners) {
|
||||
listeners = [];
|
||||
this._listeners[name] = listeners;
|
||||
}
|
||||
listeners.push(callback);
|
||||
},
|
||||
|
||||
removeEventListener: function(name, callback)
|
||||
{
|
||||
var listeners = this._listeners[name];
|
||||
if (!listeners)
|
||||
return;
|
||||
|
||||
var index = listeners.indexOf(callback);
|
||||
if (index != -1)
|
||||
listeners.splice(index, 1);
|
||||
},
|
||||
|
||||
_fireDomEvent: function(name, event)
|
||||
{
|
||||
var listeners = this._listeners[name];
|
||||
if (!listeners)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < listeners.length; ++i) {
|
||||
var listener = listeners[i];
|
||||
listener.call(this, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DOMDocument.prototype.__proto__ = WebInspector.DOMNode.prototype;
|
||||
|
||||
|
||||
WebInspector.DOMWindow = function(domAgent)
|
||||
{
|
||||
this._domAgent = domAgent;
|
||||
}
|
||||
|
||||
WebInspector.DOMWindow.prototype = {
|
||||
get document()
|
||||
{
|
||||
return this._domAgent.document;
|
||||
},
|
||||
|
||||
get Node()
|
||||
{
|
||||
return WebInspector.DOMNode;
|
||||
},
|
||||
|
||||
get Element()
|
||||
{
|
||||
return WebInspector.DOMNode;
|
||||
},
|
||||
|
||||
Object: function()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DOMAgent = function() {
|
||||
this._window = new WebInspector.DOMWindow(this);
|
||||
this._idToDOMNode = null;
|
||||
this.document = null;
|
||||
InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatcher(this));
|
||||
}
|
||||
|
||||
WebInspector.DOMAgent.prototype = {
|
||||
get domWindow()
|
||||
{
|
||||
return this._window;
|
||||
},
|
||||
|
||||
getChildNodesAsync: function(parent, callback)
|
||||
{
|
||||
var children = parent.children;
|
||||
if (children) {
|
||||
callback(children);
|
||||
return;
|
||||
}
|
||||
function mycallback() {
|
||||
callback(parent.children);
|
||||
}
|
||||
InspectorBackend.getChildNodes(parent.id, mycallback);
|
||||
},
|
||||
|
||||
setAttributeAsync: function(node, name, value, callback)
|
||||
{
|
||||
var mycallback = this._didApplyDomChange.bind(this, node, callback);
|
||||
InspectorBackend.setAttribute(node.id, name, value, mycallback);
|
||||
},
|
||||
|
||||
removeAttributeAsync: function(node, name, callback)
|
||||
{
|
||||
var mycallback = this._didApplyDomChange.bind(this, node, callback);
|
||||
InspectorBackend.removeAttribute(node.id, name, mycallback);
|
||||
},
|
||||
|
||||
setTextNodeValueAsync: function(node, text, callback)
|
||||
{
|
||||
var mycallback = this._didApplyDomChange.bind(this, node, callback);
|
||||
InspectorBackend.setTextNodeValue(node.id, text, mycallback);
|
||||
},
|
||||
|
||||
_didApplyDomChange: function(node, callback, success)
|
||||
{
|
||||
if (!success)
|
||||
return;
|
||||
callback();
|
||||
// TODO(pfeldman): Fix this hack.
|
||||
var elem = WebInspector.panels.elements.treeOutline.findTreeElement(node);
|
||||
if (elem)
|
||||
elem.updateTitle();
|
||||
},
|
||||
|
||||
_attributesUpdated: function(nodeId, attrsArray)
|
||||
{
|
||||
var node = this._idToDOMNode[nodeId];
|
||||
node._setAttributesPayload(attrsArray);
|
||||
var event = {target: node};
|
||||
this.document._fireDomEvent("DOMAttrModified", event);
|
||||
},
|
||||
|
||||
_characterDataModified: function(nodeId, newValue)
|
||||
{
|
||||
var node = this._idToDOMNode[nodeId];
|
||||
node._nodeValue = newValue;
|
||||
node.textContent = newValue;
|
||||
var event = { target : node };
|
||||
this.document._fireDomEvent("DOMCharacterDataModified", event);
|
||||
},
|
||||
|
||||
nodeForId: function(nodeId)
|
||||
{
|
||||
return this._idToDOMNode[nodeId];
|
||||
},
|
||||
|
||||
_setDocument: function(payload)
|
||||
{
|
||||
this._idToDOMNode = {};
|
||||
if (payload && "id" in payload) {
|
||||
this.document = new WebInspector.DOMDocument(this, this._window, payload);
|
||||
this._idToDOMNode[payload.id] = this.document;
|
||||
this._bindNodes(this.document.children);
|
||||
WebInspector.breakpointManager.restoreDOMBreakpoints();
|
||||
} else
|
||||
this.document = null;
|
||||
WebInspector.panels.elements.setDocument(this.document);
|
||||
},
|
||||
|
||||
_setDetachedRoot: function(payload)
|
||||
{
|
||||
var root = new WebInspector.DOMNode(this.document, payload);
|
||||
this._idToDOMNode[payload.id] = root;
|
||||
},
|
||||
|
||||
_setChildNodes: function(parentId, payloads)
|
||||
{
|
||||
var parent = this._idToDOMNode[parentId];
|
||||
parent._setChildrenPayload(payloads);
|
||||
this._bindNodes(parent.children);
|
||||
},
|
||||
|
||||
_bindNodes: function(children)
|
||||
{
|
||||
for (var i = 0; i < children.length; ++i) {
|
||||
var child = children[i];
|
||||
this._idToDOMNode[child.id] = child;
|
||||
if (child.children)
|
||||
this._bindNodes(child.children);
|
||||
}
|
||||
},
|
||||
|
||||
_childNodeCountUpdated: function(nodeId, newValue)
|
||||
{
|
||||
var node = this._idToDOMNode[nodeId];
|
||||
node._childNodeCount = newValue;
|
||||
var outline = WebInspector.panels.elements.treeOutline;
|
||||
var treeElement = outline.findTreeElement(node);
|
||||
if (treeElement)
|
||||
treeElement.hasChildren = newValue;
|
||||
},
|
||||
|
||||
_childNodeInserted: function(parentId, prevId, payload)
|
||||
{
|
||||
var parent = this._idToDOMNode[parentId];
|
||||
var prev = this._idToDOMNode[prevId];
|
||||
var node = parent._insertChild(prev, payload);
|
||||
this._idToDOMNode[node.id] = node;
|
||||
var event = { target : node, relatedNode : parent };
|
||||
this.document._fireDomEvent("DOMNodeInserted", event);
|
||||
},
|
||||
|
||||
_childNodeRemoved: function(parentId, nodeId)
|
||||
{
|
||||
var parent = this._idToDOMNode[parentId];
|
||||
var node = this._idToDOMNode[nodeId];
|
||||
parent.removeChild_(node);
|
||||
var event = { target : node, relatedNode : parent };
|
||||
this.document._fireDomEvent("DOMNodeRemoved", event);
|
||||
delete this._idToDOMNode[nodeId];
|
||||
this._removeBreakpoints(node);
|
||||
},
|
||||
|
||||
_removeBreakpoints: function(node)
|
||||
{
|
||||
for (var type in node.breakpoints)
|
||||
node.breakpoints[type].remove();
|
||||
if (!node.children)
|
||||
return;
|
||||
for (var i = 0; i < node.children.length; ++i)
|
||||
this._removeBreakpoints(node.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DOMDispatcher = function(domAgent)
|
||||
{
|
||||
this._domAgent = domAgent;
|
||||
}
|
||||
|
||||
WebInspector.DOMDispatcher.prototype = {
|
||||
setDocument: function(payload)
|
||||
{
|
||||
this._domAgent._setDocument(payload);
|
||||
},
|
||||
|
||||
attributesUpdated: function(nodeId, attrsArray)
|
||||
{
|
||||
this._domAgent._attributesUpdated(nodeId, attrsArray);
|
||||
},
|
||||
|
||||
characterDataModified: function(nodeId, newValue)
|
||||
{
|
||||
this._domAgent._characterDataModified(nodeId, newValue);
|
||||
},
|
||||
|
||||
setChildNodes: function(parentId, payloads)
|
||||
{
|
||||
this._domAgent._setChildNodes(parentId, payloads);
|
||||
},
|
||||
|
||||
setDetachedRoot: function(payload)
|
||||
{
|
||||
this._domAgent._setDetachedRoot(payload);
|
||||
},
|
||||
|
||||
childNodeCountUpdated: function(nodeId, newValue)
|
||||
{
|
||||
this._domAgent._childNodeCountUpdated(nodeId, newValue);
|
||||
},
|
||||
|
||||
childNodeInserted: function(parentId, prevId, payload)
|
||||
{
|
||||
this._domAgent._childNodeInserted(parentId, prevId, payload);
|
||||
},
|
||||
|
||||
childNodeRemoved: function(parentId, nodeId)
|
||||
{
|
||||
this._domAgent._childNodeRemoved(parentId, nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ApplicationCacheDispatcher = function()
|
||||
{
|
||||
}
|
||||
|
||||
WebInspector.ApplicationCacheDispatcher.getApplicationCachesAsync = function(callback)
|
||||
{
|
||||
function mycallback(applicationCaches)
|
||||
{
|
||||
// FIXME: Currently, this list only returns a single application cache.
|
||||
if (applicationCaches)
|
||||
callback(applicationCaches);
|
||||
}
|
||||
|
||||
InspectorBackend.getApplicationCaches(mycallback);
|
||||
}
|
||||
|
||||
WebInspector.ApplicationCacheDispatcher.prototype = {
|
||||
updateApplicationCacheStatus: function(status)
|
||||
{
|
||||
WebInspector.panels.resources.updateApplicationCacheStatus(status);
|
||||
},
|
||||
|
||||
updateNetworkState: function(isNowOnline)
|
||||
{
|
||||
WebInspector.panels.resources.updateNetworkState(isNowOnline);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorBackend.registerDomainDispatcher("ApplicationCache", new WebInspector.ApplicationCacheDispatcher());
|
||||
|
||||
WebInspector.Cookies = {}
|
||||
|
||||
WebInspector.Cookies.getCookiesAsync = function(callback)
|
||||
{
|
||||
function mycallback(cookies, cookiesString)
|
||||
{
|
||||
if (cookiesString)
|
||||
callback(WebInspector.Cookies.buildCookiesFromString(cookiesString), false);
|
||||
else
|
||||
callback(cookies, true);
|
||||
}
|
||||
|
||||
InspectorBackend.getCookies(mycallback);
|
||||
}
|
||||
|
||||
WebInspector.Cookies.buildCookiesFromString = function(rawCookieString)
|
||||
{
|
||||
var rawCookies = rawCookieString.split(/;\s*/);
|
||||
var cookies = [];
|
||||
|
||||
if (!(/^\s*$/.test(rawCookieString))) {
|
||||
for (var i = 0; i < rawCookies.length; ++i) {
|
||||
var cookie = rawCookies[i];
|
||||
var delimIndex = cookie.indexOf("=");
|
||||
var name = cookie.substring(0, delimIndex);
|
||||
var value = cookie.substring(delimIndex + 1);
|
||||
var size = name.length + value.length;
|
||||
cookies.push({ name: name, value: value, size: size });
|
||||
}
|
||||
}
|
||||
|
||||
return cookies;
|
||||
}
|
||||
|
||||
WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL)
|
||||
{
|
||||
var url = resourceURL.asParsedURL();
|
||||
if (!url || !this.cookieDomainMatchesResourceDomain(cookie.domain, url.host))
|
||||
return false;
|
||||
return (url.path.indexOf(cookie.path) === 0
|
||||
&& (!cookie.port || url.port == cookie.port)
|
||||
&& (!cookie.secure || url.scheme === "https"));
|
||||
}
|
||||
|
||||
WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceDomain)
|
||||
{
|
||||
if (cookieDomain.charAt(0) !== '.')
|
||||
return resourceDomain === cookieDomain;
|
||||
return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)?" + cookieDomain.substring(1).escapeForRegExp() + "$"), "i");
|
||||
}
|
||||
|
||||
WebInspector.EventListeners = {}
|
||||
|
||||
WebInspector.EventListeners.getEventListenersForNodeAsync = function(node, callback)
|
||||
{
|
||||
if (!node)
|
||||
return;
|
||||
InspectorBackend.getEventListenersForNode(node.id, callback);
|
||||
}
|
97
node_modules/weinre/web/client/DOMStorage.js
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Nokia 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "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 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.DOMStorage = function(id, domain, isLocalStorage)
|
||||
{
|
||||
this._id = id;
|
||||
this._domain = domain;
|
||||
this._isLocalStorage = isLocalStorage;
|
||||
}
|
||||
|
||||
WebInspector.DOMStorage.prototype = {
|
||||
get id()
|
||||
{
|
||||
return this._id;
|
||||
},
|
||||
|
||||
get domain()
|
||||
{
|
||||
return this._domain;
|
||||
},
|
||||
|
||||
get isLocalStorage()
|
||||
{
|
||||
return this._isLocalStorage;
|
||||
},
|
||||
|
||||
getEntries: function(callback)
|
||||
{
|
||||
InspectorBackend.getDOMStorageEntries(this._id, callback);
|
||||
},
|
||||
|
||||
setItem: function(key, value, callback)
|
||||
{
|
||||
InspectorBackend.setDOMStorageItem(this._id, key, value, callback);
|
||||
},
|
||||
|
||||
removeItem: function(key, callback)
|
||||
{
|
||||
InspectorBackend.removeDOMStorageItem(this._id, key, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebInspector.DOMStorageDispatcher = function()
|
||||
{
|
||||
}
|
||||
|
||||
WebInspector.DOMStorageDispatcher.prototype = {
|
||||
addDOMStorage: function(payload)
|
||||
{
|
||||
if (!WebInspector.panels.resources)
|
||||
return;
|
||||
var domStorage = new WebInspector.DOMStorage(
|
||||
payload.id,
|
||||
payload.host,
|
||||
payload.isLocalStorage);
|
||||
WebInspector.panels.resources.addDOMStorage(domStorage);
|
||||
},
|
||||
|
||||
selectDOMStorage: function(o)
|
||||
{
|
||||
WebInspector.showPanel("resources");
|
||||
WebInspector.panels.resources.selectDOMStorage(o);
|
||||
},
|
||||
|
||||
updateDOMStorage: function(storageId)
|
||||
{
|
||||
WebInspector.panels.resources.updateDOMStorage(storageId);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorBackend.registerDomainDispatcher("DOMStorage", new WebInspector.DOMStorageDispatcher());
|
157
node_modules/weinre/web/client/DOMStorageItemsView.js
generated
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Nokia 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 ``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.DOMStorageItemsView = function(domStorage)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
|
||||
this.domStorage = domStorage;
|
||||
|
||||
this.element.addStyleClass("storage-view");
|
||||
this.element.addStyleClass("table");
|
||||
|
||||
this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString("Delete"), "delete-storage-status-bar-item");
|
||||
this.deleteButton.visible = false;
|
||||
this.deleteButton.addEventListener("click", this._deleteButtonClicked.bind(this), false);
|
||||
|
||||
this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
|
||||
this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
|
||||
}
|
||||
|
||||
WebInspector.DOMStorageItemsView.prototype = {
|
||||
get statusBarItems()
|
||||
{
|
||||
return [this.refreshButton.element, this.deleteButton.element];
|
||||
},
|
||||
|
||||
show: function(parentElement)
|
||||
{
|
||||
WebInspector.View.prototype.show.call(this, parentElement);
|
||||
this.update();
|
||||
},
|
||||
|
||||
hide: function()
|
||||
{
|
||||
WebInspector.View.prototype.hide.call(this);
|
||||
this.deleteButton.visible = false;
|
||||
},
|
||||
|
||||
update: function()
|
||||
{
|
||||
this.element.removeChildren();
|
||||
var callback = this._showDOMStorageEntries.bind(this);
|
||||
this.domStorage.getEntries(callback);
|
||||
},
|
||||
|
||||
_showDOMStorageEntries: function(entries)
|
||||
{
|
||||
this._dataGrid = this._dataGridForDOMStorageEntries(entries);
|
||||
this.element.appendChild(this._dataGrid.element);
|
||||
this._dataGrid.autoSizeColumns(10);
|
||||
this.deleteButton.visible = true;
|
||||
},
|
||||
|
||||
resize: function()
|
||||
{
|
||||
if (this._dataGrid)
|
||||
this._dataGrid.updateWidths();
|
||||
},
|
||||
|
||||
_dataGridForDOMStorageEntries: function(entries)
|
||||
{
|
||||
var columns = {};
|
||||
columns[0] = {};
|
||||
columns[1] = {};
|
||||
columns[0].title = WebInspector.UIString("Key");
|
||||
columns[1].title = WebInspector.UIString("Value");
|
||||
|
||||
var nodes = [];
|
||||
|
||||
var keys = [];
|
||||
var length = entries.length;
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var data = {};
|
||||
|
||||
var key = entries[i][0];
|
||||
data[0] = key;
|
||||
var value = entries[i][1];
|
||||
data[1] = value;
|
||||
var node = new WebInspector.DataGridNode(data, false);
|
||||
node.selectable = true;
|
||||
nodes.push(node);
|
||||
keys.push(key);
|
||||
}
|
||||
|
||||
var dataGrid = new WebInspector.DataGrid(columns, this._editingCallback.bind(this), this._deleteCallback.bind(this));
|
||||
var length = nodes.length;
|
||||
for (var i = 0; i < length; ++i)
|
||||
dataGrid.appendChild(nodes[i]);
|
||||
dataGrid.addCreationNode(false);
|
||||
if (length > 0)
|
||||
nodes[0].selected = true;
|
||||
return dataGrid;
|
||||
},
|
||||
|
||||
_deleteButtonClicked: function(event)
|
||||
{
|
||||
if (!this._dataGrid || !this._dataGrid.selectedNode)
|
||||
return;
|
||||
|
||||
this._deleteCallback(this._dataGrid.selectedNode);
|
||||
},
|
||||
|
||||
_refreshButtonClicked: function(event)
|
||||
{
|
||||
this.update();
|
||||
},
|
||||
|
||||
_editingCallback: function(editingNode, columnIdentifier, oldText, newText)
|
||||
{
|
||||
var domStorage = this.domStorage;
|
||||
if (columnIdentifier === 0) {
|
||||
if (oldText)
|
||||
domStorage.removeItem(oldText);
|
||||
|
||||
domStorage.setItem(newText, editingNode.data[1]);
|
||||
} else {
|
||||
domStorage.setItem(editingNode.data[0], newText);
|
||||
}
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
_deleteCallback: function(node)
|
||||
{
|
||||
if (!node || node.isCreationNode)
|
||||
return;
|
||||
|
||||
if (this.domStorage)
|
||||
this.domStorage.removeItem(node.data[0]);
|
||||
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DOMStorageItemsView.prototype.__proto__ = WebInspector.View.prototype;
|
79
node_modules/weinre/web/client/DOMSyntaxHighlighter.js
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.DOMSyntaxHighlighter = function(mimeType)
|
||||
{
|
||||
this._tokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer(mimeType);
|
||||
}
|
||||
|
||||
WebInspector.DOMSyntaxHighlighter.prototype = {
|
||||
createSpan: function(content, className)
|
||||
{
|
||||
var span = document.createElement("span");
|
||||
span.className = "webkit-" + className;
|
||||
span.appendChild(document.createTextNode(content));
|
||||
return span;
|
||||
},
|
||||
|
||||
syntaxHighlightNode: function(node)
|
||||
{
|
||||
this._tokenizer.condition = this._tokenizer.initialCondition;
|
||||
var lines = node.textContent.split("\n");
|
||||
node.removeChildren();
|
||||
|
||||
for (var i = lines[0].length ? 0 : 1; i < lines.length; ++i) {
|
||||
var line = lines[i];
|
||||
var plainTextStart = 0;
|
||||
this._tokenizer.line = line;
|
||||
var column = 0;
|
||||
do {
|
||||
var newColumn = this._tokenizer.nextToken(column);
|
||||
var tokenType = this._tokenizer.tokenType;
|
||||
if (tokenType) {
|
||||
if (column > plainTextStart) {
|
||||
var plainText = line.substring(plainTextStart, column);
|
||||
node.appendChild(document.createTextNode(plainText));
|
||||
}
|
||||
var token = line.substring(column, newColumn);
|
||||
node.appendChild(this.createSpan(token, tokenType));
|
||||
plainTextStart = newColumn;
|
||||
}
|
||||
column = newColumn;
|
||||
} while (column < line.length)
|
||||
|
||||
if (plainTextStart < line.length) {
|
||||
var plainText = line.substring(plainTextStart, line.length);
|
||||
node.appendChild(document.createTextNode(plainText));
|
||||
}
|
||||
if (i < lines.length - 1)
|
||||
node.appendChild(document.createElement("br"));
|
||||
}
|
||||
}
|
||||
}
|
1478
node_modules/weinre/web/client/DataGrid.js
generated
vendored
Normal file
147
node_modules/weinre/web/client/Database.js
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (C) 2007, 2008 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.Database = function(id, domain, name, version)
|
||||
{
|
||||
this._id = id;
|
||||
this._domain = domain;
|
||||
this._name = name;
|
||||
this._version = version;
|
||||
}
|
||||
|
||||
WebInspector.Database.prototype = {
|
||||
get id()
|
||||
{
|
||||
return this._id;
|
||||
},
|
||||
|
||||
get name()
|
||||
{
|
||||
return this._name;
|
||||
},
|
||||
|
||||
set name(x)
|
||||
{
|
||||
this._name = x;
|
||||
},
|
||||
|
||||
get version()
|
||||
{
|
||||
return this._version;
|
||||
},
|
||||
|
||||
set version(x)
|
||||
{
|
||||
this._version = x;
|
||||
},
|
||||
|
||||
get domain()
|
||||
{
|
||||
return this._domain;
|
||||
},
|
||||
|
||||
set domain(x)
|
||||
{
|
||||
this._domain = x;
|
||||
},
|
||||
|
||||
get displayDomain()
|
||||
{
|
||||
return WebInspector.Resource.prototype.__lookupGetter__("displayDomain").call(this);
|
||||
},
|
||||
|
||||
getTableNames: function(callback)
|
||||
{
|
||||
function sortingCallback(names)
|
||||
{
|
||||
callback(names.sort());
|
||||
}
|
||||
InspectorBackend.getDatabaseTableNames(this._id, sortingCallback);
|
||||
},
|
||||
|
||||
executeSql: function(query, onSuccess, onError)
|
||||
{
|
||||
function callback(success, transactionId)
|
||||
{
|
||||
if (!success) {
|
||||
onError(WebInspector.UIString("Database not found."));
|
||||
return;
|
||||
}
|
||||
WebInspector.DatabaseDispatcher._callbacks[transactionId] = {"onSuccess": onSuccess, "onError": onError};
|
||||
}
|
||||
InspectorBackend.executeSQL(this._id, query, callback);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DatabaseDispatcher = function()
|
||||
{
|
||||
}
|
||||
|
||||
WebInspector.DatabaseDispatcher._callbacks = {};
|
||||
|
||||
WebInspector.DatabaseDispatcher.prototype = {
|
||||
addDatabase: function(payload)
|
||||
{
|
||||
var database = new WebInspector.Database(
|
||||
payload.id,
|
||||
payload.domain,
|
||||
payload.name,
|
||||
payload.version);
|
||||
WebInspector.panels.resources.addDatabase(database);
|
||||
},
|
||||
|
||||
selectDatabase: function(o)
|
||||
{
|
||||
WebInspector.showPanel("resources");
|
||||
WebInspector.panels.resources.selectDatabase(o);
|
||||
},
|
||||
|
||||
sqlTransactionSucceeded: function(transactionId, columnNames, values)
|
||||
{
|
||||
if (!WebInspector.DatabaseDispatcher._callbacks[transactionId])
|
||||
return;
|
||||
|
||||
var callback = WebInspector.DatabaseDispatcher._callbacks[transactionId].onSuccess;
|
||||
delete WebInspector.DatabaseDispatcher._callbacks[transactionId];
|
||||
if (callback)
|
||||
callback(columnNames, values);
|
||||
},
|
||||
|
||||
sqlTransactionFailed: function(transactionId, errorObj)
|
||||
{
|
||||
if (!WebInspector.DatabaseDispatcher._callbacks[transactionId])
|
||||
return;
|
||||
|
||||
var callback = WebInspector.DatabaseDispatcher._callbacks[transactionId].onError;
|
||||
delete WebInspector.DatabaseDispatcher._callbacks[transactionId];
|
||||
if (callback)
|
||||
callback(errorObj);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorBackend.registerDomainDispatcher("Database", new WebInspector.DatabaseDispatcher());
|
196
node_modules/weinre/web/client/DatabaseQueryView.js
generated
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.DatabaseQueryView = function(database)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
|
||||
this.database = database;
|
||||
|
||||
this.element.addStyleClass("storage-view");
|
||||
this.element.addStyleClass("query");
|
||||
this.element.addStyleClass("monospace");
|
||||
this.element.tabIndex = 0;
|
||||
|
||||
this.element.addEventListener("selectstart", this._selectStart.bind(this), false);
|
||||
|
||||
this.promptElement = document.createElement("div");
|
||||
this.promptElement.className = "database-query-prompt";
|
||||
this.promptElement.appendChild(document.createElement("br"));
|
||||
this.promptElement.addEventListener("keydown", this._promptKeyDown.bind(this), true);
|
||||
this.element.appendChild(this.promptElement);
|
||||
|
||||
this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), " ");
|
||||
}
|
||||
|
||||
WebInspector.DatabaseQueryView.prototype = {
|
||||
show: function(parentElement)
|
||||
{
|
||||
WebInspector.View.prototype.show.call(this, parentElement);
|
||||
|
||||
function moveBackIfOutside()
|
||||
{
|
||||
if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCollapsed)
|
||||
this.prompt.moveCaretToEndOfPrompt();
|
||||
}
|
||||
|
||||
setTimeout(moveBackIfOutside.bind(this), 0);
|
||||
},
|
||||
|
||||
completions: function(wordRange, bestMatchOnly, completionsReadyCallback)
|
||||
{
|
||||
var prefix = wordRange.toString().toLowerCase();
|
||||
if (!prefix.length)
|
||||
return;
|
||||
|
||||
var results = [];
|
||||
|
||||
function accumulateMatches(textArray)
|
||||
{
|
||||
if (bestMatchOnly && results.length)
|
||||
return;
|
||||
for (var i = 0; i < textArray.length; ++i) {
|
||||
var text = textArray[i].toLowerCase();
|
||||
if (text.length < prefix.length)
|
||||
continue;
|
||||
if (text.indexOf(prefix) !== 0)
|
||||
continue;
|
||||
results.push(textArray[i]);
|
||||
if (bestMatchOnly)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function tableNamesCallback(tableNames)
|
||||
{
|
||||
accumulateMatches(tableNames.map(function(name) { return name + " " }));
|
||||
accumulateMatches(["SELECT ", "FROM ", "WHERE ", "LIMIT ", "DELETE FROM ", "CREATE ", "DROP ", "TABLE ", "INDEX ", "UPDATE ", "INSERT INTO ", "VALUES ("]);
|
||||
|
||||
completionsReadyCallback(results);
|
||||
}
|
||||
this.database.getTableNames(tableNamesCallback);
|
||||
},
|
||||
|
||||
_promptKeyDown: function(event)
|
||||
{
|
||||
if (isEnterKey(event)) {
|
||||
this._enterKeyPressed(event);
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
_selectStart: function(event)
|
||||
{
|
||||
if (this._selectionTimeout)
|
||||
clearTimeout(this._selectionTimeout);
|
||||
|
||||
this.prompt.clearAutoComplete();
|
||||
|
||||
function moveBackIfOutside()
|
||||
{
|
||||
delete this._selectionTimeout;
|
||||
if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCollapsed)
|
||||
this.prompt.moveCaretToEndOfPrompt();
|
||||
this.prompt.autoCompleteSoon();
|
||||
}
|
||||
|
||||
this._selectionTimeout = setTimeout(moveBackIfOutside.bind(this), 100);
|
||||
},
|
||||
|
||||
_enterKeyPressed: function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
this.prompt.clearAutoComplete(true);
|
||||
|
||||
var query = this.prompt.text;
|
||||
if (!query.length)
|
||||
return;
|
||||
|
||||
this.prompt.history.push(query);
|
||||
this.prompt.historyOffset = 0;
|
||||
this.prompt.text = "";
|
||||
|
||||
this.database.executeSql(query, this._queryFinished.bind(this, query), this._queryError.bind(this, query));
|
||||
},
|
||||
|
||||
_queryFinished: function(query, columnNames, values)
|
||||
{
|
||||
var dataGrid = WebInspector.panels.resources.dataGridForResult(columnNames, values);
|
||||
var trimmedQuery = query.trim();
|
||||
|
||||
if (dataGrid) {
|
||||
dataGrid.element.addStyleClass("inline");
|
||||
this._appendQueryResult(trimmedQuery, dataGrid.element);
|
||||
dataGrid.autoSizeColumns(5);
|
||||
}
|
||||
|
||||
if (trimmedQuery.match(/^create /i) || trimmedQuery.match(/^drop table /i))
|
||||
WebInspector.panels.resources.updateDatabaseTables(this.database);
|
||||
},
|
||||
|
||||
_queryError: function(query, error)
|
||||
{
|
||||
if (error.message)
|
||||
var message = error.message;
|
||||
else if (error.code == 2)
|
||||
var message = WebInspector.UIString("Database no longer has expected version.");
|
||||
else
|
||||
var message = WebInspector.UIString("An unexpected error %s occurred.", error.code);
|
||||
|
||||
this._appendQueryResult(query, message, "error");
|
||||
},
|
||||
|
||||
_appendQueryResult: function(query, result, resultClassName)
|
||||
{
|
||||
var element = document.createElement("div");
|
||||
element.className = "database-user-query";
|
||||
|
||||
var commandTextElement = document.createElement("span");
|
||||
commandTextElement.className = "database-query-text";
|
||||
commandTextElement.textContent = query;
|
||||
element.appendChild(commandTextElement);
|
||||
|
||||
var resultElement = document.createElement("div");
|
||||
resultElement.className = "database-query-result";
|
||||
|
||||
if (resultClassName)
|
||||
resultElement.addStyleClass(resultClassName);
|
||||
|
||||
if (typeof result === "string" || result instanceof String)
|
||||
resultElement.textContent = result;
|
||||
else if (result && result.nodeName)
|
||||
resultElement.appendChild(result);
|
||||
|
||||
if (resultElement.childNodes.length)
|
||||
element.appendChild(resultElement);
|
||||
|
||||
this.element.insertBefore(element, this.promptElement);
|
||||
this.promptElement.scrollIntoView(false);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DatabaseQueryView.prototype.__proto__ = WebInspector.View.prototype;
|
90
node_modules/weinre/web/client/DatabaseTableView.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.DatabaseTableView = function(database, tableName)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
|
||||
this.database = database;
|
||||
this.tableName = tableName;
|
||||
|
||||
this.element.addStyleClass("storage-view");
|
||||
this.element.addStyleClass("table");
|
||||
|
||||
this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
|
||||
this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
|
||||
}
|
||||
|
||||
WebInspector.DatabaseTableView.prototype = {
|
||||
show: function(parentElement)
|
||||
{
|
||||
WebInspector.View.prototype.show.call(this, parentElement);
|
||||
this.update();
|
||||
},
|
||||
|
||||
get statusBarItems()
|
||||
{
|
||||
return [this.refreshButton.element];
|
||||
},
|
||||
|
||||
update: function()
|
||||
{
|
||||
this.database.executeSql("SELECT * FROM " + this.tableName, this._queryFinished.bind(this), this._queryError.bind(this));
|
||||
},
|
||||
|
||||
_queryFinished: function(columnNames, values)
|
||||
{
|
||||
this.element.removeChildren();
|
||||
|
||||
var dataGrid = WebInspector.panels.resources.dataGridForResult(columnNames, values);
|
||||
if (!dataGrid) {
|
||||
var emptyMsgElement = document.createElement("div");
|
||||
emptyMsgElement.className = "storage-empty-view";
|
||||
emptyMsgElement.textContent = WebInspector.UIString("The “%s”\ntable is empty.", this.tableName);
|
||||
this.element.appendChild(emptyMsgElement);
|
||||
return;
|
||||
}
|
||||
|
||||
this.element.appendChild(dataGrid.element);
|
||||
dataGrid.autoSizeColumns(5);
|
||||
},
|
||||
|
||||
_queryError: function(error)
|
||||
{
|
||||
this.element.removeChildren();
|
||||
|
||||
var errorMsgElement = document.createElement("div");
|
||||
errorMsgElement.className = "storage-table-error";
|
||||
errorMsgElement.textContent = WebInspector.UIString("An error occurred trying to\nread the “%s” table.", this.tableName);
|
||||
this.element.appendChild(errorMsgElement);
|
||||
},
|
||||
|
||||
_refreshButtonClicked: function(event)
|
||||
{
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DatabaseTableView.prototype.__proto__ = WebInspector.View.prototype;
|
380
node_modules/weinre/web/client/DebuggerModel.js
generated
vendored
Normal file
@ -0,0 +1,380 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.DebuggerModel = function()
|
||||
{
|
||||
this._paused = false;
|
||||
this._callFrames = [];
|
||||
this._breakpoints = {};
|
||||
this._scripts = {};
|
||||
|
||||
InspectorBackend.registerDomainDispatcher("Debugger", new WebInspector.DebuggerDispatcher(this));
|
||||
}
|
||||
|
||||
WebInspector.DebuggerModel.Events = {
|
||||
DebuggerPaused: "debugger-paused",
|
||||
DebuggerResumed: "debugger-resumed",
|
||||
ParsedScriptSource: "parsed-script-source",
|
||||
FailedToParseScriptSource: "failed-to-parse-script-source",
|
||||
ScriptSourceChanged: "script-source-changed",
|
||||
BreakpointAdded: "breakpoint-added",
|
||||
BreakpointRemoved: "breakpoint-removed",
|
||||
BreakpointResolved: "breakpoint-resolved"
|
||||
}
|
||||
|
||||
WebInspector.DebuggerModel.prototype = {
|
||||
enableDebugger: function()
|
||||
{
|
||||
InspectorBackend.enableDebugger();
|
||||
if (this._breakpointsPushedToBackend)
|
||||
return;
|
||||
var breakpoints = WebInspector.settings.breakpoints;
|
||||
for (var i = 0; i < breakpoints.length; ++i) {
|
||||
var breakpoint = breakpoints[i];
|
||||
if (typeof breakpoint.url !== "string" || typeof breakpoint.lineNumber !== "number" || typeof breakpoint.columnNumber !== "number" ||
|
||||
typeof breakpoint.condition !== "string" || typeof breakpoint.enabled !== "boolean")
|
||||
continue;
|
||||
this.setBreakpoint(breakpoint.url, breakpoint.lineNumber, breakpoint.columnNumber, breakpoint.condition, breakpoint.enabled);
|
||||
}
|
||||
this._breakpointsPushedToBackend = true;
|
||||
},
|
||||
|
||||
disableDebugger: function()
|
||||
{
|
||||
InspectorBackend.disableDebugger();
|
||||
},
|
||||
|
||||
continueToLocation: function(sourceID, lineNumber, columnNumber)
|
||||
{
|
||||
InspectorBackend.continueToLocation(sourceID, lineNumber, columnNumber);
|
||||
},
|
||||
|
||||
setBreakpoint: function(url, lineNumber, columnNumber, condition, enabled)
|
||||
{
|
||||
function didSetBreakpoint(breakpointsPushedToBackend, breakpointId, locations)
|
||||
{
|
||||
if (!breakpointId)
|
||||
return;
|
||||
var breakpoint = new WebInspector.Breakpoint(breakpointId, url, "", lineNumber, columnNumber, condition, enabled);
|
||||
breakpoint.locations = locations;
|
||||
this._breakpoints[breakpointId] = breakpoint;
|
||||
if (breakpointsPushedToBackend)
|
||||
this._saveBreakpoints();
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointAdded, breakpoint);
|
||||
}
|
||||
InspectorBackend.setJavaScriptBreakpoint(url, lineNumber, columnNumber, condition, enabled, didSetBreakpoint.bind(this, this._breakpointsPushedToBackend));
|
||||
},
|
||||
|
||||
setBreakpointBySourceId: function(sourceID, lineNumber, columnNumber, condition, enabled)
|
||||
{
|
||||
function didSetBreakpoint(breakpointId, actualLineNumber, actualColumnNumber)
|
||||
{
|
||||
if (!breakpointId)
|
||||
return;
|
||||
var breakpoint = new WebInspector.Breakpoint(breakpointId, "", sourceID, lineNumber, columnNumber, condition, enabled);
|
||||
breakpoint.addLocation(sourceID, actualLineNumber, actualColumnNumber);
|
||||
this._breakpoints[breakpointId] = breakpoint;
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointAdded, breakpoint);
|
||||
}
|
||||
InspectorBackend.setJavaScriptBreakpointBySourceId(sourceID, lineNumber, columnNumber, condition, enabled, didSetBreakpoint.bind(this));
|
||||
},
|
||||
|
||||
removeBreakpoint: function(breakpointId)
|
||||
{
|
||||
InspectorBackend.removeJavaScriptBreakpoint(breakpointId);
|
||||
var breakpoint = this._breakpoints[breakpointId];
|
||||
delete this._breakpoints[breakpointId];
|
||||
this._saveBreakpoints();
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointRemoved, breakpointId);
|
||||
},
|
||||
|
||||
updateBreakpoint: function(breakpointId, condition, enabled)
|
||||
{
|
||||
var breakpoint = this._breakpoints[breakpointId];
|
||||
this.removeBreakpoint(breakpointId);
|
||||
if (breakpoint.url)
|
||||
this.setBreakpoint(breakpoint.url, breakpoint.lineNumber, breakpoint.columnNumber, condition, enabled);
|
||||
else
|
||||
this.setBreakpointBySourceId(breakpoint.sourceID, breakpoint.lineNumber, breakpoint.columnNumber, condition, enabled);
|
||||
},
|
||||
|
||||
_breakpointResolved: function(breakpointId, sourceID, lineNumber, columnNumber)
|
||||
{
|
||||
var breakpoint = this._breakpoints[breakpointId];
|
||||
if (!breakpoint)
|
||||
return;
|
||||
breakpoint.addLocation(sourceID, lineNumber, columnNumber);
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, breakpoint);
|
||||
},
|
||||
|
||||
_saveBreakpoints: function()
|
||||
{
|
||||
var serializedBreakpoints = [];
|
||||
for (var id in this._breakpoints) {
|
||||
var breakpoint = this._breakpoints[id];
|
||||
if (!breakpoint.url)
|
||||
continue;
|
||||
var serializedBreakpoint = {};
|
||||
serializedBreakpoint.url = breakpoint.url;
|
||||
serializedBreakpoint.lineNumber = breakpoint.lineNumber;
|
||||
serializedBreakpoint.columnNumber = breakpoint.columnNumber;
|
||||
serializedBreakpoint.condition = breakpoint.condition;
|
||||
serializedBreakpoint.enabled = breakpoint.enabled;
|
||||
serializedBreakpoints.push(serializedBreakpoint);
|
||||
}
|
||||
WebInspector.settings.breakpoints = serializedBreakpoints;
|
||||
},
|
||||
|
||||
get breakpoints()
|
||||
{
|
||||
return this._breakpoints;
|
||||
},
|
||||
|
||||
breakpointForId: function(breakpointId)
|
||||
{
|
||||
return this._breakpoints[breakpointId];
|
||||
},
|
||||
|
||||
queryBreakpoints: function(filter)
|
||||
{
|
||||
var breakpoints = [];
|
||||
for (var id in this._breakpoints) {
|
||||
var breakpoint = this._breakpoints[id];
|
||||
if (filter(breakpoint))
|
||||
breakpoints.push(breakpoint);
|
||||
}
|
||||
return breakpoints;
|
||||
},
|
||||
|
||||
reset: function()
|
||||
{
|
||||
this._paused = false;
|
||||
this._callFrames = [];
|
||||
for (var id in this._breakpoints) {
|
||||
var breakpoint = this._breakpoints[id];
|
||||
if (!breakpoint.url)
|
||||
this.removeBreakpoint(id);
|
||||
else
|
||||
breakpoint.locations = [];
|
||||
}
|
||||
this._scripts = {};
|
||||
},
|
||||
|
||||
scriptForSourceID: function(sourceID)
|
||||
{
|
||||
return this._scripts[sourceID];
|
||||
},
|
||||
|
||||
scriptsForURL: function(url)
|
||||
{
|
||||
return this.queryScripts(function(s) { return s.sourceURL === url; });
|
||||
},
|
||||
|
||||
queryScripts: function(filter)
|
||||
{
|
||||
var scripts = [];
|
||||
for (var sourceID in this._scripts) {
|
||||
var script = this._scripts[sourceID];
|
||||
if (filter(script))
|
||||
scripts.push(script);
|
||||
}
|
||||
return scripts;
|
||||
},
|
||||
|
||||
editScriptSource: function(sourceID, scriptSource)
|
||||
{
|
||||
function didEditScriptSource(success, newBodyOrErrorMessage, callFrames)
|
||||
{
|
||||
if (success) {
|
||||
if (callFrames && callFrames.length)
|
||||
this._callFrames = callFrames;
|
||||
this._updateScriptSource(sourceID, newBodyOrErrorMessage);
|
||||
} else
|
||||
WebInspector.log(newBodyOrErrorMessage, WebInspector.ConsoleMessage.MessageLevel.Warning);
|
||||
}
|
||||
InspectorBackend.editScriptSource(sourceID, scriptSource, didEditScriptSource.bind(this));
|
||||
},
|
||||
|
||||
_updateScriptSource: function(sourceID, scriptSource)
|
||||
{
|
||||
var script = this._scripts[sourceID];
|
||||
var oldSource = script.source;
|
||||
script.source = scriptSource;
|
||||
|
||||
// Clear and re-create breakpoints according to text diff.
|
||||
var diff = Array.diff(oldSource.split("\n"), script.source.split("\n"));
|
||||
for (var id in this._breakpoints) {
|
||||
var breakpoint = this._breakpoints[id];
|
||||
if (breakpoint.url) {
|
||||
if (breakpoint.url !== script.sourceURL)
|
||||
continue;
|
||||
} else {
|
||||
if (breakpoint.sourceID !== sourceID)
|
||||
continue;
|
||||
}
|
||||
this.removeBreakpoint(breakpoint.id);
|
||||
var lineNumber = breakpoint.lineNumber;
|
||||
var newLineNumber = diff.left[lineNumber].row;
|
||||
if (newLineNumber === undefined) {
|
||||
for (var i = lineNumber - 1; i >= 0; --i) {
|
||||
if (diff.left[i].row === undefined)
|
||||
continue;
|
||||
var shiftedLineNumber = diff.left[i].row + lineNumber - i;
|
||||
if (shiftedLineNumber < diff.right.length) {
|
||||
var originalLineNumber = diff.right[shiftedLineNumber].row;
|
||||
if (originalLineNumber === lineNumber || originalLineNumber === undefined)
|
||||
newLineNumber = shiftedLineNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newLineNumber === undefined)
|
||||
continue;
|
||||
if (breakpoint.url)
|
||||
this.setBreakpoint(breakpoint.url, newLineNumber, breakpoint.columnNumber, breakpoint.condition, breakpoint.enabled);
|
||||
else
|
||||
this.setBreakpointBySourceId(sourceID, newLineNumber, breakpoint.columnNumber, breakpoint.condition, breakpoint.enabled);
|
||||
}
|
||||
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ScriptSourceChanged, { sourceID: sourceID, oldSource: oldSource });
|
||||
},
|
||||
|
||||
get callFrames()
|
||||
{
|
||||
return this._callFrames;
|
||||
},
|
||||
|
||||
_pausedScript: function(details)
|
||||
{
|
||||
this._paused = true;
|
||||
this._callFrames = details.callFrames;
|
||||
details.breakpoint = this._breakpointForCallFrame(details.callFrames[0]);
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerPaused, details);
|
||||
},
|
||||
|
||||
_resumedScript: function()
|
||||
{
|
||||
this._paused = false;
|
||||
this._callFrames = [];
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerResumed);
|
||||
},
|
||||
|
||||
_breakpointForCallFrame: function(callFrame)
|
||||
{
|
||||
function match(location)
|
||||
{
|
||||
if (location.sourceID != callFrame.sourceID)
|
||||
return false;
|
||||
return location.lineNumber === callFrame.line && location.columnNumber === callFrame.column;
|
||||
}
|
||||
for (var id in this._breakpoints) {
|
||||
var breakpoint = this._breakpoints[id];
|
||||
for (var i = 0; i < breakpoint.locations.length; ++i) {
|
||||
if (match(breakpoint.locations[i]))
|
||||
return breakpoint;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, length, scriptWorldType)
|
||||
{
|
||||
var script = new WebInspector.Script(sourceID, sourceURL, "", lineOffset, columnOffset, length, undefined, undefined, scriptWorldType);
|
||||
this._scripts[sourceID] = script;
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script);
|
||||
},
|
||||
|
||||
_failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage)
|
||||
{
|
||||
var script = new WebInspector.Script(null, sourceURL, source, startingLine, errorLine, errorMessage, undefined);
|
||||
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DebuggerModel.prototype.__proto__ = WebInspector.Object.prototype;
|
||||
|
||||
WebInspector.DebuggerEventTypes = {
|
||||
JavaScriptPause: 0,
|
||||
JavaScriptBreakpoint: 1,
|
||||
NativeBreakpoint: 2
|
||||
};
|
||||
|
||||
WebInspector.DebuggerDispatcher = function(debuggerModel)
|
||||
{
|
||||
this._debuggerModel = debuggerModel;
|
||||
}
|
||||
|
||||
WebInspector.DebuggerDispatcher.prototype = {
|
||||
pausedScript: function(details)
|
||||
{
|
||||
this._debuggerModel._pausedScript(details);
|
||||
},
|
||||
|
||||
resumedScript: function()
|
||||
{
|
||||
this._debuggerModel._resumedScript();
|
||||
},
|
||||
|
||||
debuggerWasEnabled: function()
|
||||
{
|
||||
WebInspector.panels.scripts.debuggerWasEnabled();
|
||||
},
|
||||
|
||||
debuggerWasDisabled: function()
|
||||
{
|
||||
WebInspector.panels.scripts.debuggerWasDisabled();
|
||||
},
|
||||
|
||||
parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, length, scriptWorldType)
|
||||
{
|
||||
this._debuggerModel._parsedScriptSource(sourceID, sourceURL, lineOffset, columnOffset, length, scriptWorldType);
|
||||
},
|
||||
|
||||
failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage)
|
||||
{
|
||||
this._debuggerModel._failedToParseScriptSource(sourceURL, source, startingLine, errorLine, errorMessage);
|
||||
},
|
||||
|
||||
breakpointResolved: function(breakpointId, sourceID, lineNumber, columnNumber)
|
||||
{
|
||||
this._debuggerModel._breakpointResolved(breakpointId, sourceID, lineNumber, columnNumber);
|
||||
},
|
||||
|
||||
didCreateWorker: function()
|
||||
{
|
||||
var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
|
||||
workersPane.addWorker.apply(workersPane, arguments);
|
||||
},
|
||||
|
||||
didDestroyWorker: function()
|
||||
{
|
||||
var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
|
||||
workersPane.removeWorker.apply(workersPane, arguments);
|
||||
}
|
||||
}
|
92
node_modules/weinre/web/client/DetailedHeapshotView.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.DetailedHeapshotView = function(parent, profile)
|
||||
{
|
||||
WebInspector.View.call(this);
|
||||
|
||||
this.element.addStyleClass("heap-snapshot-view");
|
||||
|
||||
this.parent = parent;
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
WebInspector.DetailedHeapshotView.prototype = {
|
||||
get profile()
|
||||
{
|
||||
return this._profile;
|
||||
},
|
||||
|
||||
set profile(profile)
|
||||
{
|
||||
this._profile = profile;
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.DetailedHeapshotView.prototype.__proto__ = WebInspector.View.prototype;
|
||||
|
||||
WebInspector.DetailedHeapshotProfileType = function()
|
||||
{
|
||||
WebInspector.ProfileType.call(this, WebInspector.HeapSnapshotProfileType.TypeId, WebInspector.UIString("HEAP SNAPSHOTS"));
|
||||
}
|
||||
|
||||
WebInspector.DetailedHeapshotProfileType.prototype = {
|
||||
get buttonTooltip()
|
||||
{
|
||||
return WebInspector.UIString("Take heap snapshot.");
|
||||
},
|
||||
|
||||
get buttonStyle()
|
||||
{
|
||||
return "heap-snapshot-status-bar-item status-bar-item";
|
||||
},
|
||||
|
||||
buttonClicked: function()
|
||||
{
|
||||
WebInspector.panels.profiles.takeHeapSnapshot(true);
|
||||
},
|
||||
|
||||
get welcomeMessage()
|
||||
{
|
||||
return WebInspector.UIString("Get a heap snapshot by pressing the %s button on the status bar.");
|
||||
},
|
||||
|
||||
createSidebarTreeElementForProfile: function(profile)
|
||||
{
|
||||
return new WebInspector.ProfileSidebarTreeElement(profile, WebInspector.UIString("Snapshot %d"), "heap-snapshot-sidebar-tree-item");
|
||||
},
|
||||
|
||||
createView: function(profile)
|
||||
{
|
||||
return new WebInspector.DetailedHeapshotView(WebInspector.panels.profiles, profile);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.DetailedHeapshotProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype;
|
362
node_modules/weinre/web/client/Drawer.js
generated
vendored
Normal file
@ -0,0 +1,362 @@
|
||||
/*
|
||||
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009 Joseph Pecoraro
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.Drawer = function()
|
||||
{
|
||||
WebInspector.View.call(this, document.getElementById("drawer"));
|
||||
|
||||
this._savedHeight = 200; // Default.
|
||||
this.state = WebInspector.Drawer.State.Hidden;
|
||||
this.fullPanel = false;
|
||||
|
||||
this._mainElement = document.getElementById("main");
|
||||
this._toolbarElement = document.getElementById("toolbar");
|
||||
this._mainStatusBar = document.getElementById("main-status-bar");
|
||||
this._mainStatusBar.addEventListener("mousedown", this._startStatusBarDragging.bind(this), true);
|
||||
this._viewStatusBar = document.getElementById("other-drawer-status-bar-items");
|
||||
this._counters = document.getElementById("counters");
|
||||
this._drawerStatusBar = document.getElementById("drawer-status-bar");
|
||||
}
|
||||
|
||||
WebInspector.Drawer.prototype = {
|
||||
get visibleView()
|
||||
{
|
||||
return this._visibleView;
|
||||
},
|
||||
|
||||
set visibleView(x)
|
||||
{
|
||||
if (this._visibleView === x) {
|
||||
if (this.visible && this.fullPanel)
|
||||
return;
|
||||
this.visible = !this.visible;
|
||||
return;
|
||||
}
|
||||
|
||||
var firstTime = !this._visibleView;
|
||||
if (this._visibleView)
|
||||
this._visibleView.hide();
|
||||
|
||||
this._visibleView = x;
|
||||
|
||||
if (x && !firstTime) {
|
||||
this._safelyRemoveChildren();
|
||||
this._viewStatusBar.removeChildren(); // optimize this? call old.detach()
|
||||
x.attach(this.element, this._viewStatusBar);
|
||||
x.show();
|
||||
this.visible = true;
|
||||
}
|
||||
},
|
||||
|
||||
get savedHeight()
|
||||
{
|
||||
var height = this._savedHeight || this.element.offsetHeight;
|
||||
return Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop - Preferences.minConsoleHeight);
|
||||
},
|
||||
|
||||
showView: function(view)
|
||||
{
|
||||
if (!this.visible || this.visibleView !== view)
|
||||
this.visibleView = view;
|
||||
},
|
||||
|
||||
show: function()
|
||||
{
|
||||
if (this._animating || this.visible)
|
||||
return;
|
||||
|
||||
if (this.visibleView)
|
||||
this.visibleView.show();
|
||||
|
||||
WebInspector.View.prototype.show.call(this);
|
||||
|
||||
this._animating = true;
|
||||
|
||||
document.body.addStyleClass("drawer-visible");
|
||||
|
||||
var anchoredItems = document.getElementById("anchored-status-bar-items");
|
||||
var height = (this.fullPanel ? window.innerHeight - this._toolbarElement.offsetHeight : this.savedHeight);
|
||||
var animations = [
|
||||
{element: this.element, end: {height: height}},
|
||||
{element: this._mainElement, end: {bottom: height}},
|
||||
{element: this._mainStatusBar, start: {"padding-left": anchoredItems.offsetWidth - 1}, end: {"padding-left": 0}},
|
||||
{element: this._viewStatusBar, start: {opacity: 0}, end: {opacity: 1}}
|
||||
];
|
||||
|
||||
this._drawerStatusBar.insertBefore(anchoredItems, this._drawerStatusBar.firstChild);
|
||||
|
||||
if (this._currentPanelCounters) {
|
||||
var oldRight = this._drawerStatusBar.clientWidth - (this._counters.offsetLeft + this._currentPanelCounters.offsetWidth);
|
||||
var newRight = WebInspector.Panel.counterRightMargin;
|
||||
var rightPadding = (oldRight - newRight);
|
||||
animations.push({element: this._currentPanelCounters, start: {"padding-right": rightPadding}, end: {"padding-right": 0}});
|
||||
this._currentPanelCounters.parentNode.removeChild(this._currentPanelCounters);
|
||||
this._mainStatusBar.appendChild(this._currentPanelCounters);
|
||||
}
|
||||
|
||||
function animationFinished()
|
||||
{
|
||||
if ("updateStatusBarItems" in WebInspector.currentPanel)
|
||||
WebInspector.currentPanel.updateStatusBarItems();
|
||||
if (this.visibleView.afterShow)
|
||||
this.visibleView.afterShow();
|
||||
delete this._animating;
|
||||
delete this._currentAnimation;
|
||||
this.state = (this.fullPanel ? WebInspector.Drawer.State.Full : WebInspector.Drawer.State.Variable);
|
||||
if (this._currentPanelCounters)
|
||||
this._currentPanelCounters.removeAttribute("style");
|
||||
}
|
||||
|
||||
this._currentAnimation = WebInspector.animateStyle(animations, this._animationDuration(), animationFinished.bind(this));
|
||||
},
|
||||
|
||||
hide: function()
|
||||
{
|
||||
if (this._animating || !this.visible)
|
||||
return;
|
||||
|
||||
WebInspector.View.prototype.hide.call(this);
|
||||
|
||||
if (this.visibleView)
|
||||
this.visibleView.hide();
|
||||
|
||||
this._animating = true;
|
||||
|
||||
if (!this.fullPanel)
|
||||
this._savedHeight = this.element.offsetHeight;
|
||||
|
||||
if (this.element === WebInspector.currentFocusElement || this.element.isAncestor(WebInspector.currentFocusElement))
|
||||
WebInspector.currentFocusElement = WebInspector.previousFocusElement;
|
||||
|
||||
var anchoredItems = document.getElementById("anchored-status-bar-items");
|
||||
|
||||
// Temporarily set properties and classes to mimic the post-animation values so panels
|
||||
// like Elements in their updateStatusBarItems call will size things to fit the final location.
|
||||
this._mainStatusBar.style.setProperty("padding-left", (anchoredItems.offsetWidth - 1) + "px");
|
||||
document.body.removeStyleClass("drawer-visible");
|
||||
if ("updateStatusBarItems" in WebInspector.currentPanel)
|
||||
WebInspector.currentPanel.updateStatusBarItems();
|
||||
document.body.addStyleClass("drawer-visible");
|
||||
|
||||
var animations = [
|
||||
{element: this._mainElement, end: {bottom: 0}},
|
||||
{element: this._mainStatusBar, start: {"padding-left": 0}, end: {"padding-left": anchoredItems.offsetWidth - 1}},
|
||||
{element: this._viewStatusBar, start: {opacity: 1}, end: {opacity: 0}}
|
||||
];
|
||||
|
||||
if (this._currentPanelCounters) {
|
||||
var newRight = this._drawerStatusBar.clientWidth - this._counters.offsetLeft;
|
||||
var oldRight = this._mainStatusBar.clientWidth - (this._currentPanelCounters.offsetLeft + this._currentPanelCounters.offsetWidth);
|
||||
var rightPadding = (newRight - oldRight);
|
||||
animations.push({element: this._currentPanelCounters, start: {"padding-right": 0}, end: {"padding-right": rightPadding}});
|
||||
}
|
||||
|
||||
function animationFinished()
|
||||
{
|
||||
WebInspector.currentPanel.resize();
|
||||
this._mainStatusBar.insertBefore(anchoredItems, this._mainStatusBar.firstChild);
|
||||
this._mainStatusBar.style.removeProperty("padding-left");
|
||||
|
||||
if (this._currentPanelCounters) {
|
||||
this._currentPanelCounters.setAttribute("style", null);
|
||||
this._currentPanelCounters.parentNode.removeChild(this._currentPanelCounters);
|
||||
this._counters.insertBefore(this._currentPanelCounters, this._counters.firstChild);
|
||||
}
|
||||
|
||||
document.body.removeStyleClass("drawer-visible");
|
||||
delete this._animating;
|
||||
delete this._currentAnimation;
|
||||
this.state = WebInspector.Drawer.State.Hidden;
|
||||
}
|
||||
|
||||
this._currentAnimation = WebInspector.animateStyle(animations, this._animationDuration(), animationFinished.bind(this));
|
||||
},
|
||||
|
||||
resize: function()
|
||||
{
|
||||
if (this.state === WebInspector.Drawer.State.Hidden)
|
||||
return;
|
||||
|
||||
var height;
|
||||
if (this.state === WebInspector.Drawer.State.Variable) {
|
||||
height = parseInt(this.element.style.height);
|
||||
height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop - Preferences.minConsoleHeight);
|
||||
} else
|
||||
height = window.innerHeight - this._toolbarElement.offsetHeight;
|
||||
|
||||
this._mainElement.style.bottom = height + "px";
|
||||
this.element.style.height = height + "px";
|
||||
},
|
||||
|
||||
enterPanelMode: function()
|
||||
{
|
||||
this._cancelAnimationIfNeeded();
|
||||
this.fullPanel = true;
|
||||
|
||||
if (this.visible) {
|
||||
this._savedHeight = this.element.offsetHeight;
|
||||
var height = window.innerHeight - this._toolbarElement.offsetHeight;
|
||||
this._animateDrawerHeight(height, WebInspector.Drawer.State.Full);
|
||||
}
|
||||
},
|
||||
|
||||
exitPanelMode: function()
|
||||
{
|
||||
this._cancelAnimationIfNeeded();
|
||||
this.fullPanel = false;
|
||||
|
||||
if (this.visible) {
|
||||
// If this animation gets cancelled, we want the state of the drawer to be Variable,
|
||||
// so that the new animation can't do an immediate transition between Hidden/Full states.
|
||||
this.state = WebInspector.Drawer.State.Variable;
|
||||
var height = this.savedHeight;
|
||||
this._animateDrawerHeight(height, WebInspector.Drawer.State.Variable);
|
||||
}
|
||||
},
|
||||
|
||||
immediatelyExitPanelMode: function()
|
||||
{
|
||||
this.visible = false;
|
||||
this.fullPanel = false;
|
||||
},
|
||||
|
||||
immediatelyFinishAnimation: function()
|
||||
{
|
||||
if (this._currentAnimation)
|
||||
this._currentAnimation.forceComplete();
|
||||
},
|
||||
|
||||
set currentPanelCounters(x)
|
||||
{
|
||||
if (!x) {
|
||||
if (this._currentPanelCounters)
|
||||
this._currentPanelCounters.parentElement.removeChild(this._currentPanelCounters);
|
||||
delete this._currentPanelCounters;
|
||||
return;
|
||||
}
|
||||
|
||||
this._currentPanelCounters = x;
|
||||
if (this.visible)
|
||||
this._mainStatusBar.appendChild(x);
|
||||
else
|
||||
this._counters.insertBefore(x, this._counters.firstChild);
|
||||
},
|
||||
|
||||
_cancelAnimationIfNeeded: function()
|
||||
{
|
||||
if (this._animating) {
|
||||
if (this._currentAnimation)
|
||||
this._currentAnimation.cancel();
|
||||
delete this._animating;
|
||||
delete this._currentAnimation;
|
||||
}
|
||||
},
|
||||
|
||||
_animateDrawerHeight: function(height, finalState)
|
||||
{
|
||||
this._animating = true;
|
||||
var animations = [
|
||||
{element: this.element, end: {height: height}},
|
||||
{element: this._mainElement, end: {bottom: height}}
|
||||
];
|
||||
|
||||
function animationFinished()
|
||||
{
|
||||
delete this._animating;
|
||||
delete this._currentAnimation;
|
||||
this.state = finalState;
|
||||
}
|
||||
|
||||
this._currentAnimation = WebInspector.animateStyle(animations, this._animationDuration(), animationFinished.bind(this));
|
||||
},
|
||||
|
||||
_animationDuration: function()
|
||||
{
|
||||
// Immediate if going between Hidden and Full in full panel mode
|
||||
if (this.fullPanel && (this.state === WebInspector.Drawer.State.Hidden || this.state === WebInspector.Drawer.State.Full))
|
||||
return 0;
|
||||
|
||||
return (window.event && window.event.shiftKey ? 2000 : 250);
|
||||
},
|
||||
|
||||
_safelyRemoveChildren: function()
|
||||
{
|
||||
var child = this.element.firstChild;
|
||||
while (child) {
|
||||
if (child.id !== "drawer-status-bar") {
|
||||
var moveTo = child.nextSibling;
|
||||
this.element.removeChild(child);
|
||||
child = moveTo;
|
||||
} else
|
||||
child = child.nextSibling;
|
||||
}
|
||||
},
|
||||
|
||||
_startStatusBarDragging: function(event)
|
||||
{
|
||||
if (!this.visible || event.target !== this._mainStatusBar)
|
||||
return;
|
||||
|
||||
WebInspector.elementDragStart(this._mainStatusBar, this._statusBarDragging.bind(this), this._endStatusBarDragging.bind(this), event, "row-resize");
|
||||
|
||||
this._statusBarDragOffset = event.pageY - this.element.totalOffsetTop;
|
||||
|
||||
event.stopPropagation();
|
||||
},
|
||||
|
||||
_statusBarDragging: function(event)
|
||||
{
|
||||
var height = window.innerHeight - event.pageY + this._statusBarDragOffset;
|
||||
height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop - Preferences.minConsoleHeight);
|
||||
|
||||
this._mainElement.style.bottom = height + "px";
|
||||
this.element.style.height = height + "px";
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
},
|
||||
|
||||
_endStatusBarDragging: function(event)
|
||||
{
|
||||
WebInspector.elementDragEnd(event);
|
||||
|
||||
this._savedHeight = this.element.offsetHeight;
|
||||
delete this._statusBarDragOffset;
|
||||
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.Drawer.prototype.__proto__ = WebInspector.View.prototype;
|
||||
|
||||
WebInspector.Drawer.State = {
|
||||
Hidden: 0,
|
||||
Variable: 1,
|
||||
Full: 2
|
||||
};
|
1087
node_modules/weinre/web/client/ElementsPanel.js
generated
vendored
Normal file
1444
node_modules/weinre/web/client/ElementsTreeOutline.js
generated
vendored
Normal file
235
node_modules/weinre/web/client/EventListenersSidebarPane.js
generated
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (C) 2007 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2009 Joseph Pecoraro
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.EventListenersSidebarPane = function()
|
||||
{
|
||||
WebInspector.SidebarPane.call(this, WebInspector.UIString("Event Listeners"));
|
||||
this.bodyElement.addStyleClass("events-pane");
|
||||
|
||||
this.sections = [];
|
||||
|
||||
this.settingsSelectElement = document.createElement("select");
|
||||
|
||||
var option = document.createElement("option");
|
||||
option.value = "all";
|
||||
option.label = WebInspector.UIString("All Nodes");
|
||||
this.settingsSelectElement.appendChild(option);
|
||||
|
||||
option = document.createElement("option");
|
||||
option.value = "selected";
|
||||
option.label = WebInspector.UIString("Selected Node Only");
|
||||
this.settingsSelectElement.appendChild(option);
|
||||
|
||||
var filter = WebInspector.settings.eventListenersFilter;
|
||||
if (filter === "all")
|
||||
this.settingsSelectElement[0].selected = true;
|
||||
else if (filter === "selected")
|
||||
this.settingsSelectElement[1].selected = true;
|
||||
this.settingsSelectElement.addEventListener("click", function(event) { event.stopPropagation() }, false);
|
||||
this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false);
|
||||
|
||||
this.titleElement.appendChild(this.settingsSelectElement);
|
||||
}
|
||||
|
||||
WebInspector.EventListenersSidebarPane.prototype = {
|
||||
update: function(node)
|
||||
{
|
||||
var body = this.bodyElement;
|
||||
body.removeChildren();
|
||||
this.sections = [];
|
||||
|
||||
var self = this;
|
||||
function callback(nodeId, eventListeners) {
|
||||
var sectionNames = [];
|
||||
var sectionMap = {};
|
||||
for (var i = 0; i < eventListeners.length; ++i) {
|
||||
var eventListener = eventListeners[i];
|
||||
eventListener.node = WebInspector.domAgent.nodeForId(eventListener.nodeId);
|
||||
delete eventListener.nodeId; // no longer needed
|
||||
if (/^function _inspectorCommandLineAPI_logEvent\(/.test(eventListener.listenerBody.toString()))
|
||||
continue; // ignore event listeners generated by monitorEvent
|
||||
var type = eventListener.type;
|
||||
var section = sectionMap[type];
|
||||
if (!section) {
|
||||
section = new WebInspector.EventListenersSection(type, nodeId);
|
||||
sectionMap[type] = section;
|
||||
sectionNames.push(type);
|
||||
self.sections.push(section);
|
||||
}
|
||||
section.addListener(eventListener);
|
||||
}
|
||||
|
||||
if (sectionNames.length === 0) {
|
||||
var div = document.createElement("div");
|
||||
div.className = "info";
|
||||
div.textContent = WebInspector.UIString("No Event Listeners");
|
||||
body.appendChild(div);
|
||||
return;
|
||||
}
|
||||
|
||||
sectionNames.sort();
|
||||
for (var i = 0; i < sectionNames.length; ++i) {
|
||||
var section = sectionMap[sectionNames[i]];
|
||||
section.update();
|
||||
body.appendChild(section.element);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.EventListeners.getEventListenersForNodeAsync(node, callback);
|
||||
},
|
||||
|
||||
_changeSetting: function(event)
|
||||
{
|
||||
var selectedOption = this.settingsSelectElement[this.settingsSelectElement.selectedIndex];
|
||||
WebInspector.settings.eventListenersFilter = selectedOption.value;
|
||||
|
||||
for (var i = 0; i < this.sections.length; ++i)
|
||||
this.sections[i].update();
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.EventListenersSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
|
||||
|
||||
WebInspector.EventListenersSection = function(title, nodeId)
|
||||
{
|
||||
this.eventListeners = [];
|
||||
this._nodeId = nodeId;
|
||||
WebInspector.PropertiesSection.call(this, title);
|
||||
|
||||
// Changed from a Properties List
|
||||
this.propertiesElement.parentNode.removeChild(this.propertiesElement);
|
||||
delete this.propertiesElement;
|
||||
delete this.propertiesTreeOutline;
|
||||
|
||||
this.eventBars = document.createElement("div");
|
||||
this.eventBars.className = "event-bars";
|
||||
this.element.appendChild(this.eventBars);
|
||||
}
|
||||
|
||||
WebInspector.EventListenersSection.prototype = {
|
||||
update: function()
|
||||
{
|
||||
// A Filtered Array simplifies when to create connectors
|
||||
var filteredEventListeners = this.eventListeners;
|
||||
if (WebInspector.settings.eventListenersFilter === "selected") {
|
||||
filteredEventListeners = [];
|
||||
for (var i = 0; i < this.eventListeners.length; ++i) {
|
||||
var eventListener = this.eventListeners[i];
|
||||
if (eventListener.node.id === this._nodeId)
|
||||
filteredEventListeners.push(eventListener);
|
||||
}
|
||||
}
|
||||
|
||||
this.eventBars.removeChildren();
|
||||
var length = filteredEventListeners.length;
|
||||
for (var i = 0; i < length; ++i) {
|
||||
var eventListener = filteredEventListeners[i];
|
||||
var eventListenerBar = new WebInspector.EventListenerBar(eventListener, this._nodeId);
|
||||
this.eventBars.appendChild(eventListenerBar.element);
|
||||
}
|
||||
},
|
||||
|
||||
addListener: function(eventListener)
|
||||
{
|
||||
this.eventListeners.push(eventListener);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.EventListenersSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype;
|
||||
|
||||
WebInspector.EventListenerBar = function(eventListener, nodeId)
|
||||
{
|
||||
this.eventListener = eventListener;
|
||||
this._nodeId = nodeId;
|
||||
WebInspector.ObjectPropertiesSection.call(this);
|
||||
this._setNodeTitle();
|
||||
this._setFunctionSubtitle();
|
||||
this.editable = false;
|
||||
this.element.className = "event-bar"; /* Changed from "section" */
|
||||
this.headerElement.addStyleClass("source-code");
|
||||
this.propertiesElement.className = "event-properties properties-tree source-code"; /* Changed from "properties" */
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBar.prototype = {
|
||||
update: function()
|
||||
{
|
||||
function updateWithNodeObject(nodeObject)
|
||||
{
|
||||
var properties = [];
|
||||
if (nodeObject)
|
||||
properties.push(new WebInspector.RemoteObjectProperty("node", nodeObject));
|
||||
|
||||
for (var propertyName in this.eventListener) {
|
||||
var value = WebInspector.RemoteObject.fromPrimitiveValue(this.eventListener[propertyName]);
|
||||
properties.push(new WebInspector.RemoteObjectProperty(propertyName, value));
|
||||
}
|
||||
this.updateProperties(properties);
|
||||
}
|
||||
var node = this.eventListener.node;
|
||||
delete this.eventListener.node;
|
||||
WebInspector.RemoteObject.resolveNode(node, updateWithNodeObject.bind(this));
|
||||
},
|
||||
|
||||
_setNodeTitle: function()
|
||||
{
|
||||
var node = this.eventListener.node;
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
if (node.nodeType === Node.DOCUMENT_NODE) {
|
||||
this.titleElement.textContent = "document";
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.id === this._nodeId) {
|
||||
this.titleElement.textContent = appropriateSelectorForNode(node);
|
||||
return;
|
||||
}
|
||||
|
||||
this.titleElement.removeChildren();
|
||||
this.titleElement.appendChild(WebInspector.panels.elements.linkifyNodeReference(this.eventListener.node));
|
||||
},
|
||||
|
||||
_setFunctionSubtitle: function()
|
||||
{
|
||||
// Requires that Function.toString() return at least the function's signature.
|
||||
if (this.eventListener.sourceName) {
|
||||
this.subtitleElement.removeChildren();
|
||||
this.subtitleElement.appendChild(WebInspector.linkifyResourceAsNode(this.eventListener.sourceName, "scripts", this.eventListener.lineNumber));
|
||||
} else {
|
||||
var match = this.eventListener.listenerBody.match(/function ([^\(]+?)\(/);
|
||||
if (match)
|
||||
this.subtitleElement.textContent = match[1];
|
||||
else
|
||||
this.subtitleElement.textContent = WebInspector.UIString("(anonymous function)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.EventListenerBar.prototype.__proto__ = WebInspector.ObjectPropertiesSection.prototype;
|
520
node_modules/weinre/web/client/ExtensionAPI.js
generated
vendored
Normal file
@ -0,0 +1,520 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.injectedExtensionAPI = function(InjectedScriptHost, inspectedWindow, injectedScriptId)
|
||||
{
|
||||
|
||||
// Here and below, all constructors are private to API implementation.
|
||||
// For a public type Foo, if internal fields are present, these are on
|
||||
// a private FooImpl type, an instance of FooImpl is used in a closure
|
||||
// by Foo consutrctor to re-bind publicly exported members to an instance
|
||||
// of Foo.
|
||||
|
||||
function EventSinkImpl(type, customDispatch)
|
||||
{
|
||||
this._type = type;
|
||||
this._listeners = [];
|
||||
this._customDispatch = customDispatch;
|
||||
}
|
||||
|
||||
EventSinkImpl.prototype = {
|
||||
addListener: function(callback)
|
||||
{
|
||||
if (typeof callback != "function")
|
||||
throw new "addListener: callback is not a function";
|
||||
if (this._listeners.length === 0)
|
||||
extensionServer.sendRequest({ command: "subscribe", type: this._type });
|
||||
this._listeners.push(callback);
|
||||
extensionServer.registerHandler("notify-" + this._type, bind(this._dispatch, this));
|
||||
},
|
||||
|
||||
removeListener: function(callback)
|
||||
{
|
||||
var listeners = this._listeners;
|
||||
|
||||
for (var i = 0; i < listeners.length; ++i) {
|
||||
if (listeners[i] === callback) {
|
||||
listeners.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this._listeners.length === 0)
|
||||
extensionServer.sendRequest({ command: "unsubscribe", type: this._type });
|
||||
},
|
||||
|
||||
_fire: function()
|
||||
{
|
||||
var listeners = this._listeners.slice();
|
||||
for (var i = 0; i < listeners.length; ++i)
|
||||
listeners[i].apply(null, arguments);
|
||||
},
|
||||
|
||||
_dispatch: function(request)
|
||||
{
|
||||
if (this._customDispatch)
|
||||
this._customDispatch.call(this, request);
|
||||
else
|
||||
this._fire.apply(this, request.arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function InspectorExtensionAPI()
|
||||
{
|
||||
this.audits = new Audits();
|
||||
this.inspectedWindow = new InspectedWindow();
|
||||
this.panels = new Panels();
|
||||
this.resources = new Resources();
|
||||
|
||||
this.onReset = new EventSink("reset");
|
||||
}
|
||||
|
||||
InspectorExtensionAPI.prototype = {
|
||||
log: function(message)
|
||||
{
|
||||
extensionServer.sendRequest({ command: "log", message: message });
|
||||
}
|
||||
}
|
||||
|
||||
function Resources()
|
||||
{
|
||||
function resourceDispatch(request)
|
||||
{
|
||||
var resource = request.arguments[1];
|
||||
resource.__proto__ = new Resource(request.arguments[0]);
|
||||
this._fire(resource);
|
||||
}
|
||||
this.onFinished = new EventSink("resource-finished", resourceDispatch);
|
||||
}
|
||||
|
||||
Resources.prototype = {
|
||||
getHAR: function(callback)
|
||||
{
|
||||
function callbackWrapper(result)
|
||||
{
|
||||
var entries = (result && result.entries) || [];
|
||||
for (var i = 0; i < entries.length; ++i) {
|
||||
entries[i].__proto__ = new Resource(entries[i]._resourceId);
|
||||
delete entries[i]._resourceId;
|
||||
}
|
||||
callback(result);
|
||||
}
|
||||
return extensionServer.sendRequest({ command: "getHAR" }, callback && callbackWrapper);
|
||||
},
|
||||
|
||||
addRequestHeaders: function(headers)
|
||||
{
|
||||
return extensionServer.sendRequest({ command: "addRequestHeaders", headers: headers, extensionId: location.hostname });
|
||||
}
|
||||
}
|
||||
|
||||
function ResourceImpl(id)
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
ResourceImpl.prototype = {
|
||||
getContent: function(callback)
|
||||
{
|
||||
function callbackWrapper(response)
|
||||
{
|
||||
callback(response.content, response.encoding);
|
||||
}
|
||||
extensionServer.sendRequest({ command: "getResourceContent", id: this._id }, callback && callbackWrapper);
|
||||
}
|
||||
};
|
||||
|
||||
function Panels()
|
||||
{
|
||||
var panels = {
|
||||
elements: new ElementsPanel()
|
||||
};
|
||||
|
||||
function panelGetter(name)
|
||||
{
|
||||
return panels[name];
|
||||
}
|
||||
for (var panel in panels)
|
||||
this.__defineGetter__(panel, bind(panelGetter, null, panel));
|
||||
}
|
||||
|
||||
Panels.prototype = {
|
||||
create: function(title, iconURL, pageURL, callback)
|
||||
{
|
||||
var id = "extension-panel-" + extensionServer.nextObjectId();
|
||||
var request = {
|
||||
command: "createPanel",
|
||||
id: id,
|
||||
title: title,
|
||||
icon: expandURL(iconURL),
|
||||
url: expandURL(pageURL)
|
||||
};
|
||||
extensionServer.sendRequest(request, callback && bind(callback, this, new ExtensionPanel(id)));
|
||||
}
|
||||
}
|
||||
|
||||
function PanelImpl(id)
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
function PanelWithSidebarImpl(id)
|
||||
{
|
||||
PanelImpl.call(this, id);
|
||||
}
|
||||
|
||||
PanelWithSidebarImpl.prototype = {
|
||||
createSidebarPane: function(title, url, callback)
|
||||
{
|
||||
var id = "extension-sidebar-" + extensionServer.nextObjectId();
|
||||
var request = {
|
||||
command: "createSidebarPane",
|
||||
panel: this._id,
|
||||
id: id,
|
||||
title: title,
|
||||
url: expandURL(url)
|
||||
};
|
||||
function callbackWrapper()
|
||||
{
|
||||
callback(new ExtensionSidebarPane(id));
|
||||
}
|
||||
extensionServer.sendRequest(request, callback && callbackWrapper);
|
||||
},
|
||||
|
||||
createWatchExpressionSidebarPane: function(title, callback)
|
||||
{
|
||||
var id = "watch-sidebar-" + extensionServer.nextObjectId();
|
||||
var request = {
|
||||
command: "createWatchExpressionSidebarPane",
|
||||
panel: this._id,
|
||||
id: id,
|
||||
title: title
|
||||
};
|
||||
function callbackWrapper()
|
||||
{
|
||||
callback(new WatchExpressionSidebarPane(id));
|
||||
}
|
||||
extensionServer.sendRequest(request, callback && callbackWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
PanelWithSidebarImpl.prototype.__proto__ = PanelImpl.prototype;
|
||||
|
||||
function ElementsPanel()
|
||||
{
|
||||
var id = "elements";
|
||||
PanelWithSidebar.call(this, id);
|
||||
this.onSelectionChanged = new EventSink("panel-objectSelected-" + id);
|
||||
}
|
||||
|
||||
function ExtensionPanel(id)
|
||||
{
|
||||
Panel.call(this, id);
|
||||
this.onSearch = new EventSink("panel-search-" + id);
|
||||
}
|
||||
|
||||
function ExtensionSidebarPaneImpl(id)
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
ExtensionSidebarPaneImpl.prototype = {
|
||||
setHeight: function(height)
|
||||
{
|
||||
extensionServer.sendRequest({ command: "setSidebarHeight", id: this._id, height: height });
|
||||
}
|
||||
}
|
||||
|
||||
function WatchExpressionSidebarPaneImpl(id)
|
||||
{
|
||||
ExtensionSidebarPaneImpl.call(this, id);
|
||||
this.onUpdated = new EventSink("watch-sidebar-updated-" + id);
|
||||
}
|
||||
|
||||
WatchExpressionSidebarPaneImpl.prototype = {
|
||||
setExpression: function(expression, rootTitle)
|
||||
{
|
||||
extensionServer.sendRequest({ command: "setWatchSidebarContent", id: this._id, expression: expression, rootTitle: rootTitle, evaluateOnPage: true });
|
||||
},
|
||||
|
||||
setObject: function(jsonObject, rootTitle)
|
||||
{
|
||||
extensionServer.sendRequest({ command: "setWatchSidebarContent", id: this._id, expression: jsonObject, rootTitle: rootTitle });
|
||||
}
|
||||
}
|
||||
|
||||
WatchExpressionSidebarPaneImpl.prototype.__proto__ = ExtensionSidebarPaneImpl.prototype;
|
||||
|
||||
function WatchExpressionSidebarPane(id)
|
||||
{
|
||||
var impl = new WatchExpressionSidebarPaneImpl(id);
|
||||
ExtensionSidebarPane.call(this, id, impl);
|
||||
}
|
||||
|
||||
function Audits()
|
||||
{
|
||||
}
|
||||
|
||||
Audits.prototype = {
|
||||
addCategory: function(displayName, resultCount)
|
||||
{
|
||||
var id = "extension-audit-category-" + extensionServer.nextObjectId();
|
||||
extensionServer.sendRequest({ command: "addAuditCategory", id: id, displayName: displayName, resultCount: resultCount });
|
||||
return new AuditCategory(id);
|
||||
}
|
||||
}
|
||||
|
||||
function AuditCategoryImpl(id)
|
||||
{
|
||||
function auditResultDispatch(request)
|
||||
{
|
||||
var auditResult = new AuditResult(request.arguments[0]);
|
||||
try {
|
||||
this._fire(auditResult);
|
||||
} catch (e) {
|
||||
console.error("Uncaught exception in extension audit event handler: " + e);
|
||||
auditResult.done();
|
||||
}
|
||||
}
|
||||
this._id = id;
|
||||
this.onAuditStarted = new EventSink("audit-started-" + id, auditResultDispatch);
|
||||
}
|
||||
|
||||
function AuditResultImpl(id)
|
||||
{
|
||||
this._id = id;
|
||||
|
||||
var formatterTypes = [
|
||||
"url",
|
||||
"snippet",
|
||||
"text"
|
||||
];
|
||||
for (var i = 0; i < formatterTypes.length; ++i)
|
||||
this[formatterTypes[i]] = bind(this._nodeFactory, null, formatterTypes[i]);
|
||||
}
|
||||
|
||||
AuditResultImpl.prototype = {
|
||||
addResult: function(displayName, description, severity, details)
|
||||
{
|
||||
// shorthand for specifying details directly in addResult().
|
||||
if (details && !(details instanceof AuditResultNode))
|
||||
details = details instanceof Array ? this.createNode.apply(this, details) : this.createNode(details);
|
||||
|
||||
var request = {
|
||||
command: "addAuditResult",
|
||||
resultId: this._id,
|
||||
displayName: displayName,
|
||||
description: description,
|
||||
severity: severity,
|
||||
details: details
|
||||
};
|
||||
extensionServer.sendRequest(request);
|
||||
},
|
||||
|
||||
createResult: function()
|
||||
{
|
||||
var node = new AuditResultNode();
|
||||
node.contents = Array.prototype.slice.call(arguments);
|
||||
return node;
|
||||
},
|
||||
|
||||
done: function()
|
||||
{
|
||||
extensionServer.sendRequest({ command: "stopAuditCategoryRun", resultId: this._id });
|
||||
},
|
||||
|
||||
get Severity()
|
||||
{
|
||||
return apiPrivate.audits.Severity;
|
||||
},
|
||||
|
||||
_nodeFactory: function(type)
|
||||
{
|
||||
return {
|
||||
type: type,
|
||||
arguments: Array.prototype.slice.call(arguments, 1)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function AuditResultNode(contents)
|
||||
{
|
||||
this.contents = contents;
|
||||
this.children = [];
|
||||
this.expanded = false;
|
||||
}
|
||||
|
||||
AuditResultNode.prototype = {
|
||||
addChild: function()
|
||||
{
|
||||
var node = AuditResultImpl.prototype.createResult.apply(null, arguments);
|
||||
this.children.push(node);
|
||||
return node;
|
||||
}
|
||||
};
|
||||
|
||||
function InspectedWindow()
|
||||
{
|
||||
this.onDOMContentLoaded = new EventSink("inspectedPageDOMContentLoaded");
|
||||
this.onLoaded = new EventSink("inspectedPageLoaded");
|
||||
this.onNavigated = new EventSink("inspectedURLChanged");
|
||||
}
|
||||
|
||||
InspectedWindow.prototype = {
|
||||
reload: function(userAgent)
|
||||
{
|
||||
return extensionServer.sendRequest({ command: "reload", userAgent: userAgent });
|
||||
},
|
||||
|
||||
eval: function(expression, callback)
|
||||
{
|
||||
function callbackWrapper(result)
|
||||
{
|
||||
var value = result.value;
|
||||
if (!result.isException)
|
||||
value = value === "undefined" ? undefined : JSON.parse(value);
|
||||
callback(value, result.isException);
|
||||
}
|
||||
return extensionServer.sendRequest({ command: "evaluateOnInspectedPage", expression: expression }, callback && callbackWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
function ExtensionServerClient()
|
||||
{
|
||||
this._callbacks = {};
|
||||
this._handlers = {};
|
||||
this._lastRequestId = 0;
|
||||
this._lastObjectId = 0;
|
||||
|
||||
this.registerHandler("callback", bind(this._onCallback, this));
|
||||
|
||||
var channel = new MessageChannel();
|
||||
this._port = channel.port1;
|
||||
this._port.addEventListener("message", bind(this._onMessage, this), false);
|
||||
this._port.start();
|
||||
|
||||
top.postMessage("registerExtension", [ channel.port2 ], "*");
|
||||
}
|
||||
|
||||
ExtensionServerClient.prototype = {
|
||||
sendRequest: function(message, callback)
|
||||
{
|
||||
if (typeof callback === "function")
|
||||
message.requestId = this._registerCallback(callback);
|
||||
return this._port.postMessage(message);
|
||||
},
|
||||
|
||||
registerHandler: function(command, handler)
|
||||
{
|
||||
this._handlers[command] = handler;
|
||||
},
|
||||
|
||||
nextObjectId: function()
|
||||
{
|
||||
return injectedScriptId + "_" + ++this._lastObjectId;
|
||||
},
|
||||
|
||||
_registerCallback: function(callback)
|
||||
{
|
||||
var id = ++this._lastRequestId;
|
||||
this._callbacks[id] = callback;
|
||||
return id;
|
||||
},
|
||||
|
||||
_onCallback: function(request)
|
||||
{
|
||||
if (request.requestId in this._callbacks) {
|
||||
var callback = this._callbacks[request.requestId];
|
||||
delete this._callbacks[request.requestId];
|
||||
callback(request.result);
|
||||
}
|
||||
},
|
||||
|
||||
_onMessage: function(event)
|
||||
{
|
||||
var request = event.data;
|
||||
var handler = this._handlers[request.command];
|
||||
if (handler)
|
||||
handler.call(this, request);
|
||||
}
|
||||
}
|
||||
|
||||
function expandURL(url)
|
||||
{
|
||||
if (!url)
|
||||
return url;
|
||||
if (/^[^/]+:/.exec(url)) // See if url has schema.
|
||||
return url;
|
||||
var baseURL = location.protocol + "//" + location.hostname + location.port;
|
||||
if (/^\//.exec(url))
|
||||
return baseURL + url;
|
||||
return baseURL + location.pathname.replace(/\/[^/]*$/,"/") + url;
|
||||
}
|
||||
|
||||
function bind(func, thisObject)
|
||||
{
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
return function() { return func.apply(thisObject, args.concat(Array.prototype.slice.call(arguments, 0))); };
|
||||
}
|
||||
|
||||
function populateInterfaceClass(interface, implementation)
|
||||
{
|
||||
for (var member in implementation) {
|
||||
if (member.charAt(0) === "_")
|
||||
continue;
|
||||
var value = implementation[member];
|
||||
interface[member] = typeof value === "function" ? bind(value, implementation)
|
||||
: interface[member] = implementation[member];
|
||||
}
|
||||
}
|
||||
|
||||
function declareInterfaceClass(implConstructor)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
var impl = { __proto__: implConstructor.prototype };
|
||||
implConstructor.apply(impl, arguments);
|
||||
populateInterfaceClass(this, impl);
|
||||
}
|
||||
}
|
||||
|
||||
var AuditCategory = declareInterfaceClass(AuditCategoryImpl);
|
||||
var AuditResult = declareInterfaceClass(AuditResultImpl);
|
||||
var EventSink = declareInterfaceClass(EventSinkImpl);
|
||||
var ExtensionSidebarPane = declareInterfaceClass(ExtensionSidebarPaneImpl);
|
||||
var Panel = declareInterfaceClass(PanelImpl);
|
||||
var PanelWithSidebar = declareInterfaceClass(PanelWithSidebarImpl);
|
||||
var Resource = declareInterfaceClass(ResourceImpl);
|
||||
var WatchExpressionSidebarPane = declareInterfaceClass(WatchExpressionSidebarPaneImpl);
|
||||
|
||||
var extensionServer = new ExtensionServerClient();
|
||||
|
||||
webInspector = new InspectorExtensionAPI();
|
||||
|
||||
}
|
513
node_modules/weinre/web/client/ExtensionAPISchema.json
generated
vendored
Normal file
@ -0,0 +1,513 @@
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.webInspector.inspectedWindow",
|
||||
"description": "Provides access to the window being inspected.",
|
||||
"functions": [
|
||||
{
|
||||
"name": "eval",
|
||||
"type": "function",
|
||||
"description": "Evaluates a JavaScript expression in the context of inspected page (NOTE: the expression must evaluate to a JSON-compliant object, otherwise the exception is thrown)",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "expression",
|
||||
"type": "string",
|
||||
"description": "An expression to evaluate."
|
||||
},
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "function",
|
||||
"description": "A function called when evaluation completes.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "result",
|
||||
"type": "object",
|
||||
"description": "The result of evaluation"
|
||||
},
|
||||
{
|
||||
"name": "isException",
|
||||
"type": "boolean",
|
||||
"description": "Set if an exception was caught while evaluating the expression"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "onDOMContentLoaded",
|
||||
"type": "function",
|
||||
"description": "Fired after DOMContentLoaded event on inspected page is fired."
|
||||
},
|
||||
{
|
||||
"name": "onLoaded",
|
||||
"type": "function",
|
||||
"description": "Fired after load event on inspected page is fired."
|
||||
},
|
||||
{
|
||||
"name": "onNavigated",
|
||||
"type": "function",
|
||||
"description": "Fired when navigation occurs in the window being inspected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"namespace": "experimental.webInspector.panels",
|
||||
"types": [
|
||||
{
|
||||
"id": "PanelWithSidebars",
|
||||
"type": "object",
|
||||
"isInstanceOf": "Panel",
|
||||
"description": "A panel within Web Inspector UI that has sidebars.",
|
||||
"functions": [
|
||||
{
|
||||
"name": "createSidebarPane",
|
||||
"type": "function",
|
||||
"description": "Creates a pane within panel's sidebar.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "title",
|
||||
"type": "string",
|
||||
"description": "A text that is displayed in sidebar caption."
|
||||
},
|
||||
{
|
||||
"name": "url",
|
||||
"type": "string",
|
||||
"description": "An URL of the page that represents the sidebar."
|
||||
},
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "function",
|
||||
"description": "A callback invoked when sidebar is created",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "result",
|
||||
"description": "An ExtensionSidebarPane object for created sidebar pane",
|
||||
"$ref": "ExtensionSidebarPane"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "createWatchExpressionSidebarPane",
|
||||
"type": "function",
|
||||
"description": "Creates a pane with an object property tree (similar to a watch sidebar pane).",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "title",
|
||||
"type": "string",
|
||||
"description": "A text that is displayed in sidebar caption."
|
||||
},
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "function",
|
||||
"description": "A callback invoked when sidebar is created",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "result",
|
||||
"description": "A WatchExpressionSidebarPane object for created sidebar pane",
|
||||
"$ref": "WatchExpressionSidebarPane"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "ElementsPanel",
|
||||
"type": "object",
|
||||
"isInstanceOf": "PanelWithSidebars",
|
||||
"description": "Represents Elements panel",
|
||||
"events": [
|
||||
{
|
||||
"name": "onSelectionChanged",
|
||||
"description": "Fired when an objects is selected in the panel."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "ExtensionPanel",
|
||||
"type": "object",
|
||||
"isInstanceOf": "Panel",
|
||||
"description": "Represents a panel created by extension",
|
||||
"events": [
|
||||
{
|
||||
"name": "onSearch",
|
||||
"description": "Fired upon a search action (start of a new search, search result navigation or search being canceled).",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "action",
|
||||
"type": "string",
|
||||
"description": "Type of search action being performed."
|
||||
},
|
||||
{
|
||||
"name": "queryString",
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"description": "Query string (only for 'performSearch')"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "ExtensionSidebarPane",
|
||||
"type": "object",
|
||||
"description": "A sidebar created by the extension.",
|
||||
"functions": [
|
||||
{
|
||||
"name": "setHeight",
|
||||
"type": "function",
|
||||
"description": "Sets the height of the sidebar.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "height",
|
||||
"type": "string",
|
||||
"description": "A CSS-like size specification, e.g. '10px' or '12pt'"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "WatchExpressionSidebarPane",
|
||||
"type": "object",
|
||||
"description": "A sidebar created by the extension.",
|
||||
"functions": [
|
||||
{
|
||||
"name": "setHeight",
|
||||
"type": "function",
|
||||
"description": "Sets the height of the sidebar.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "height",
|
||||
"type": "string",
|
||||
"description": "A CSS-like size specification, e.g. '10px' or '12pt'"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "setExpression",
|
||||
"type": "function",
|
||||
"description": "Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "expression",
|
||||
"type": "string",
|
||||
"description": "An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch."
|
||||
},
|
||||
{
|
||||
"name": "rootTitle",
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"description": "An optional title for the root of the expression tree."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "setObject",
|
||||
"type": "function",
|
||||
"description": "Sets a JSON-compliant object to be displayed in the sidebar pane.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "jsonObject",
|
||||
"type": "string",
|
||||
"description": "An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client)."
|
||||
},
|
||||
{
|
||||
"name": "rootTitle",
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"description": "An optional title for the root of the expression tree."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"scripts": {
|
||||
"$ref": "ScriptsPanel",
|
||||
"description": "Scripts panel"
|
||||
}
|
||||
},
|
||||
"functions": [
|
||||
{
|
||||
"name": "create",
|
||||
"type": "function",
|
||||
"description": "Creates an extension panel.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "title",
|
||||
"type": "string",
|
||||
"description": "Title that is displayed under the extension icon in the toolbar."
|
||||
},
|
||||
{
|
||||
"name": "iconURL",
|
||||
"type": "string",
|
||||
"description": "An URL of the toolbar icon."
|
||||
},
|
||||
{
|
||||
"name": "pageURL",
|
||||
"type": "string",
|
||||
"description": "An URL of the page that represents this panel."
|
||||
}
|
||||
],
|
||||
"returns" : {
|
||||
"$ref": "ExtensionPanel",
|
||||
"description": "A panel that was created."
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"namespace": "experimental.webInspector.resources",
|
||||
"types": [
|
||||
{
|
||||
"id": "Resource",
|
||||
"type": "object",
|
||||
"description": "Represents a resource (document, script, image etc). See HAR Specification for reference.",
|
||||
"functions": [
|
||||
{
|
||||
"name": "getContent",
|
||||
"type": "function",
|
||||
"description": "Returns resource content.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "function",
|
||||
"description": "A function that is called upon request completion.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "content",
|
||||
"type": "string",
|
||||
"description": "Resource content (potentially encoded)."
|
||||
},
|
||||
{
|
||||
"name": "encoding",
|
||||
"type": "string",
|
||||
"description": "Empty if content is not encoded, encoding name otherwise. Currently, only base64 supported."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"name": "getHAR",
|
||||
"type": "function",
|
||||
"description": "Returns HAR archive that contains all known resource objects.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "function",
|
||||
"description": "A function that is called upon request completion.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "har",
|
||||
"type": "object",
|
||||
"description": "A HAR archieve. See HAR specification for details."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "onFinished",
|
||||
"type": "function",
|
||||
"description": "Fired when a resource request is finished and all resource data are available.",
|
||||
"parameters": [
|
||||
{ "name": "resource", "$ref": "Resource" }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"namespace": "experimental.webInspector.audits",
|
||||
"functions": [
|
||||
{
|
||||
"name": "addCategory",
|
||||
"type": "function",
|
||||
"description": "Adds an audit category.",
|
||||
"parameters": [
|
||||
{ "name": "displayName", "type": "string", "description": "A display name for the category" },
|
||||
{ "name": "resultCount", "type": "number", "description": "The expected number of audit results in the category." }
|
||||
],
|
||||
"returns": {
|
||||
"$ref": "AuditCategory"
|
||||
}
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": "AuditCategory",
|
||||
"type": "object",
|
||||
"description": "A set of audit rules",
|
||||
"events": [
|
||||
{
|
||||
"name": "onAuditStarted",
|
||||
"type": "function",
|
||||
"description": "Fired when the audit is started, if the category is enabled -- the extension is expected to begin executing audit rules.",
|
||||
"parameters": [
|
||||
{ "name": "results", "$ref": "AuditResults" }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "FormattedValue",
|
||||
"type": "object",
|
||||
"description": "A value returned from one of the formatters (an URL, code snippet etc), to be passed to createResult or addChild"
|
||||
},
|
||||
{
|
||||
"id": "AuditResults",
|
||||
"type": "object",
|
||||
"description": "A collection of audit results for current run of the audit category",
|
||||
"functions": [
|
||||
{
|
||||
"name": "addResult",
|
||||
"type": "function",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "displayName",
|
||||
"type": "string",
|
||||
"description": "A concise, high-level description of audit rule result"
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"type": "string",
|
||||
"description": "A detailed description of what the displayName means"
|
||||
},
|
||||
{
|
||||
"name": "severity",
|
||||
"$ref": "AuditResultSeverety"
|
||||
},
|
||||
{
|
||||
"name": "details",
|
||||
"$ref": "AuditResultNode",
|
||||
"optional": true,
|
||||
"description": "A subtree that appears under added result that may provide additional details on the violations found"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "createResult",
|
||||
"type": "function",
|
||||
"description": "Creates a result node that may be user as details parameters to addResult",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "content ...",
|
||||
"choices": [
|
||||
{ "type": "string" },
|
||||
{ "$ref": "FormattedValue" }
|
||||
],
|
||||
"description": "Either string or formatted values returned by one of AuditResult formatters (url, snippet etc)"
|
||||
}
|
||||
],
|
||||
"returns": {
|
||||
"$ref": "AuditResultNode"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "done",
|
||||
"type": "function",
|
||||
"description": "Signals the WebInspector Audits panel that the run of this category is over. Normally the run completes automatically when a number of added top-level results is equal to that declared when AuditCategory was created."
|
||||
},
|
||||
{
|
||||
"name": "url",
|
||||
"type": "function",
|
||||
"description": "Render passed value as an URL in the Audits panel",
|
||||
"parameters": [
|
||||
{ "name": "href", "type": "string", "description": "An URL that will appear as href value on resulting link" },
|
||||
{ "name": "displayText", "type": "string", "description": "A text that will appear to user", "optional": true }
|
||||
],
|
||||
"returns": { "$ref": "FormattedValue" }
|
||||
},
|
||||
{
|
||||
"name": "snippet",
|
||||
"type": "function",
|
||||
"description": "Render passed text as a code snippet in the Audits panel",
|
||||
"parameters": [
|
||||
{ "name": "text", "type": "string", "description": "Snippet text" }
|
||||
],
|
||||
"returns": { "$ref": "FormattedValue" }
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Severity": {
|
||||
"$ref": "AuditResultSeverity",
|
||||
"description": "A class that contains possible values for audit result severities."
|
||||
},
|
||||
"text": {
|
||||
"type": "string",
|
||||
"description": "The contents of the node."
|
||||
},
|
||||
"children": {
|
||||
"optional": true,
|
||||
"type": "array",
|
||||
"items": { "$ref": "AuditResultNode" },
|
||||
"description": "Children of this node."
|
||||
},
|
||||
"expanded": {
|
||||
"optional": "true",
|
||||
"type": "boolean",
|
||||
"description": "Whether the node is expanded by default."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "AuditResultNode",
|
||||
"type": "object",
|
||||
"description": "A node in the audit result trees. Displays some content and optionally has children node",
|
||||
"functions": [
|
||||
{
|
||||
"name": "addChild",
|
||||
"description": "Adds another child node to this node",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "content ...",
|
||||
"choices": [
|
||||
{ "type": "string" },
|
||||
{ "$ref": "FormattedValue" }
|
||||
],
|
||||
"description": "Either string or formatted values returned by one of AuditResult formatters (url, snippet etc)"
|
||||
}
|
||||
],
|
||||
"returns": {
|
||||
"$ref": "AuditResultNode"
|
||||
}
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"expanded": {
|
||||
"type": "boolean",
|
||||
"description": "If set, the subtree will always be expanded"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "AuditResultSeverity",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Info": {
|
||||
"type": "string"
|
||||
},
|
||||
"Warning": {
|
||||
"type": "string"
|
||||
},
|
||||
"Severe": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
111
node_modules/weinre/web/client/ExtensionAuditCategory.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.ExtensionAuditCategory = function(id, displayName, ruleCount)
|
||||
{
|
||||
this._id = id;
|
||||
this._displayName = displayName;
|
||||
this._ruleCount = ruleCount;
|
||||
}
|
||||
|
||||
WebInspector.ExtensionAuditCategory.prototype = {
|
||||
// AuditCategory interface
|
||||
get id()
|
||||
{
|
||||
return this._id;
|
||||
},
|
||||
|
||||
get displayName()
|
||||
{
|
||||
return this._displayName;
|
||||
},
|
||||
|
||||
get ruleCount()
|
||||
{
|
||||
return this._ruleCount;
|
||||
},
|
||||
|
||||
run: function(resources, callback)
|
||||
{
|
||||
new WebInspector.ExtensionAuditCategoryResults(this, callback);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ExtensionAuditCategoryResults = function(category, callback)
|
||||
{
|
||||
this._category = category;
|
||||
this._pendingRules = category.ruleCount;
|
||||
this._ruleCompletionCallback = callback;
|
||||
|
||||
this.id = category.id + "-" + ++WebInspector.ExtensionAuditCategoryResults._lastId;
|
||||
WebInspector.extensionServer.startAuditRun(category, this);
|
||||
}
|
||||
|
||||
WebInspector.ExtensionAuditCategoryResults.prototype = {
|
||||
get complete()
|
||||
{
|
||||
return !this._pendingRules;
|
||||
},
|
||||
|
||||
cancel: function()
|
||||
{
|
||||
while (!this.complete)
|
||||
this._addResult(null);
|
||||
},
|
||||
|
||||
addResult: function(displayName, description, severity, details)
|
||||
{
|
||||
var result = new WebInspector.AuditRuleResult(displayName);
|
||||
result.addChild(description);
|
||||
result.severity = severity;
|
||||
if (details)
|
||||
this._addNode(result, details);
|
||||
this._addResult(result);
|
||||
},
|
||||
|
||||
_addNode: function(parent, node)
|
||||
{
|
||||
var addedNode = parent.addChild(node.contents, node.expanded);
|
||||
if (node.children) {
|
||||
for (var i = 0; i < node.children.length; ++i)
|
||||
this._addNode(addedNode, node.children[i]);
|
||||
}
|
||||
},
|
||||
|
||||
_addResult: function(result)
|
||||
{
|
||||
this._ruleCompletionCallback(result);
|
||||
this._pendingRules--;
|
||||
if (!this._pendingRules)
|
||||
WebInspector.extensionServer.stopAuditRun(this);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ExtensionAuditCategoryResults._lastId = 0;
|
46
node_modules/weinre/web/client/ExtensionCommon.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.commonExtensionSymbols = function(apiPrivate)
|
||||
{
|
||||
|
||||
if (!apiPrivate.audits)
|
||||
apiPrivate.audits = {};
|
||||
|
||||
apiPrivate.audits.Severity = {
|
||||
Info: "info",
|
||||
Warning: "warning",
|
||||
Severe: "severe"
|
||||
};
|
||||
}
|
||||
|
||||
WebInspector.extensionAPI = {};
|
||||
|
||||
WebInspector.commonExtensionSymbols(WebInspector.extensionAPI);
|
118
node_modules/weinre/web/client/ExtensionPanel.js
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.ExtensionPanel = function(id, label, iconURL, options)
|
||||
{
|
||||
this.toolbarItemLabel = label;
|
||||
this._addStyleRule(".toolbar-item." + id + " .toolbar-icon", "background-image: url(" + iconURL + ");");
|
||||
WebInspector.Panel.call(this, id);
|
||||
}
|
||||
|
||||
WebInspector.ExtensionPanel.prototype = {
|
||||
get defaultFocusedElement()
|
||||
{
|
||||
return this.sidebarTreeElement || this.element;
|
||||
},
|
||||
|
||||
updateMainViewWidth: function(width)
|
||||
{
|
||||
this.bodyElement.style.left = width + "px";
|
||||
this.resize();
|
||||
},
|
||||
|
||||
searchCanceled: function(startingNewSearch)
|
||||
{
|
||||
WebInspector.extensionServer.notifySearchAction(this._id, "cancelSearch");
|
||||
WebInspector.Panel.prototype.searchCanceled.apply(this, arguments);
|
||||
},
|
||||
|
||||
performSearch: function(query)
|
||||
{
|
||||
WebInspector.extensionServer.notifySearchAction(this._id, "performSearch", query);
|
||||
WebInspector.Panel.prototype.performSearch.apply(this, arguments);
|
||||
},
|
||||
|
||||
jumpToNextSearchResult: function()
|
||||
{
|
||||
WebInspector.extensionServer.notifySearchAction(this._id, "nextSearchResult");
|
||||
WebInspector.Panel.prototype.jumpToNextSearchResult.call(this);
|
||||
},
|
||||
|
||||
jumpToPreviousSearchResult: function()
|
||||
{
|
||||
WebInspector.extensionServer.notifySearchAction(this._id, "previousSearchResult");
|
||||
WebInspector.Panel.prototype.jumpToPreviousSearchResult.call(this);
|
||||
},
|
||||
|
||||
_addStyleRule: function(selector, body)
|
||||
{
|
||||
var style = document.createElement("style");
|
||||
style.textContent = selector + " { " + body + " }";
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ExtensionPanel.prototype.__proto__ = WebInspector.Panel.prototype;
|
||||
|
||||
WebInspector.ExtensionWatchSidebarPane = function(title, id)
|
||||
{
|
||||
WebInspector.SidebarPane.call(this, title);
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
WebInspector.ExtensionWatchSidebarPane.prototype = {
|
||||
setObject: function(object, title)
|
||||
{
|
||||
this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title);
|
||||
},
|
||||
|
||||
setExpression: function(expression, title)
|
||||
{
|
||||
InspectorBackend.evaluate(expression, "extension-watch", false, this._onEvaluate.bind(this, title));
|
||||
},
|
||||
|
||||
_onEvaluate: function(title, result)
|
||||
{
|
||||
this._setObject(WebInspector.RemoteObject.fromPayload(result), title);
|
||||
},
|
||||
|
||||
_setObject: function(object, title)
|
||||
{
|
||||
this.bodyElement.removeChildren();
|
||||
var section = new WebInspector.ObjectPropertiesSection(object, title, null, true);
|
||||
if (!title)
|
||||
section.headerElement.addStyleClass("hidden");
|
||||
section.expanded = true;
|
||||
this.bodyElement.appendChild(section.element);
|
||||
WebInspector.extensionServer.notifyExtensionWatchSidebarUpdated(this._id);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ExtensionWatchSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
|
23
node_modules/weinre/web/client/ExtensionRegistryStub.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var ExtensionRegistryImpl = modjewel.require("weinre/client/ExtensionRegistryImpl")
|
||||
window.InspectorExtensionRegistry = new ExtensionRegistryImpl()
|
||||
})()
|
465
node_modules/weinre/web/client/ExtensionServer.js
generated
vendored
Normal file
@ -0,0 +1,465 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.ExtensionServer = function()
|
||||
{
|
||||
this._clientObjects = {};
|
||||
this._handlers = {};
|
||||
this._subscribers = {};
|
||||
this._extraHeaders = {};
|
||||
this._status = new WebInspector.ExtensionStatus();
|
||||
|
||||
this._registerHandler("addRequestHeaders", this._onAddRequestHeaders.bind(this));
|
||||
this._registerHandler("addAuditCategory", this._onAddAuditCategory.bind(this));
|
||||
this._registerHandler("addAuditResult", this._onAddAuditResult.bind(this));
|
||||
this._registerHandler("createPanel", this._onCreatePanel.bind(this));
|
||||
this._registerHandler("createSidebarPane", this._onCreateSidebar.bind(this));
|
||||
this._registerHandler("createWatchExpressionSidebarPane", this._onCreateWatchExpressionSidebarPane.bind(this));
|
||||
this._registerHandler("evaluateOnInspectedPage", this._onEvaluateOnInspectedPage.bind(this));
|
||||
this._registerHandler("getHAR", this._onGetHAR.bind(this));
|
||||
this._registerHandler("getResourceContent", this._onGetResourceContent.bind(this));
|
||||
this._registerHandler("log", this._onLog.bind(this));
|
||||
this._registerHandler("reload", this._onReload.bind(this));
|
||||
this._registerHandler("setSidebarHeight", this._onSetSidebarHeight.bind(this));
|
||||
this._registerHandler("setWatchSidebarContent", this._onSetWatchSidebarContent.bind(this));
|
||||
this._registerHandler("stopAuditCategoryRun", this._onStopAuditCategoryRun.bind(this));
|
||||
this._registerHandler("subscribe", this._onSubscribe.bind(this));
|
||||
this._registerHandler("unsubscribe", this._onUnsubscribe.bind(this));
|
||||
|
||||
window.addEventListener("message", this._onWindowMessage.bind(this), false);
|
||||
}
|
||||
|
||||
WebInspector.ExtensionServer.prototype = {
|
||||
notifyPanelShown: function(panelName)
|
||||
{
|
||||
this._postNotification("panel-shown-" + panelName);
|
||||
},
|
||||
|
||||
notifyObjectSelected: function(panelId, objectId)
|
||||
{
|
||||
this._postNotification("panel-objectSelected-" + panelId, objectId);
|
||||
},
|
||||
|
||||
notifySearchAction: function(panelId, action, searchString)
|
||||
{
|
||||
this._postNotification("panel-search-" + panelId, action, searchString);
|
||||
},
|
||||
|
||||
notifyPageLoaded: function(milliseconds)
|
||||
{
|
||||
this._postNotification("inspectedPageLoaded", milliseconds);
|
||||
},
|
||||
|
||||
notifyPageDOMContentLoaded: function(milliseconds)
|
||||
{
|
||||
this._postNotification("inspectedPageDOMContentLoaded", milliseconds);
|
||||
},
|
||||
|
||||
notifyInspectedURLChanged: function()
|
||||
{
|
||||
this._postNotification("inspectedURLChanged");
|
||||
},
|
||||
|
||||
notifyInspectorReset: function()
|
||||
{
|
||||
this._postNotification("reset");
|
||||
},
|
||||
|
||||
notifyExtensionWatchSidebarUpdated: function(id)
|
||||
{
|
||||
this._postNotification("watch-sidebar-updated-" + id);
|
||||
},
|
||||
|
||||
startAuditRun: function(category, auditRun)
|
||||
{
|
||||
this._clientObjects[auditRun.id] = auditRun;
|
||||
this._postNotification("audit-started-" + category.id, auditRun.id);
|
||||
},
|
||||
|
||||
stopAuditRun: function(auditRun)
|
||||
{
|
||||
delete this._clientObjects[auditRun.id];
|
||||
},
|
||||
|
||||
_notifyResourceFinished: function(event)
|
||||
{
|
||||
var resource = event.data;
|
||||
this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build());
|
||||
},
|
||||
|
||||
_postNotification: function(type, details)
|
||||
{
|
||||
var subscribers = this._subscribers[type];
|
||||
if (!subscribers)
|
||||
return;
|
||||
var message = {
|
||||
command: "notify-" + type,
|
||||
arguments: Array.prototype.slice.call(arguments, 1)
|
||||
};
|
||||
for (var i = 0; i < subscribers.length; ++i)
|
||||
subscribers[i].postMessage(message);
|
||||
},
|
||||
|
||||
_onSubscribe: function(message, port)
|
||||
{
|
||||
var subscribers = this._subscribers[message.type];
|
||||
if (subscribers)
|
||||
subscribers.push(port);
|
||||
else
|
||||
this._subscribers[message.type] = [ port ];
|
||||
},
|
||||
|
||||
_onUnsubscribe: function(message, port)
|
||||
{
|
||||
var subscribers = this._subscribers[message.type];
|
||||
if (!subscribers)
|
||||
return;
|
||||
subscribers.remove(port);
|
||||
if (!subscribers.length)
|
||||
delete this._subscribers[message.type];
|
||||
},
|
||||
|
||||
_onAddRequestHeaders: function(message)
|
||||
{
|
||||
var id = message.extensionId;
|
||||
if (typeof id !== "string")
|
||||
return this._status.E_BADARGTYPE("extensionId", typeof id, "string");
|
||||
var extensionHeaders = this._extraHeaders[id];
|
||||
if (!extensionHeaders) {
|
||||
extensionHeaders = {};
|
||||
this._extraHeaders[id] = extensionHeaders;
|
||||
}
|
||||
for (name in message.headers)
|
||||
extensionHeaders[name] = message.headers[name];
|
||||
var allHeaders = {};
|
||||
for (extension in this._extraHeaders) {
|
||||
var headers = this._extraHeaders[extension];
|
||||
for (name in headers) {
|
||||
if (typeof headers[name] === "string")
|
||||
allHeaders[name] = headers[name];
|
||||
}
|
||||
}
|
||||
InspectorBackend.setExtraHeaders(allHeaders);
|
||||
},
|
||||
|
||||
_onCreatePanel: function(message, port)
|
||||
{
|
||||
var id = message.id;
|
||||
// The ids are generated on the client API side and must be unique, so the check below
|
||||
// shouldn't be hit unless someone is bypassing the API.
|
||||
if (id in this._clientObjects || id in WebInspector.panels)
|
||||
return this._status.E_EXISTS(id);
|
||||
var panel = new WebInspector.ExtensionPanel(id, message.title, message.icon);
|
||||
this._clientObjects[id] = panel;
|
||||
|
||||
var toolbarElement = document.getElementById("toolbar");
|
||||
var lastToolbarItem = WebInspector.panelOrder[WebInspector.panelOrder.length - 1].toolbarItem;
|
||||
WebInspector.addPanelToolbarIcon(toolbarElement, panel, lastToolbarItem);
|
||||
WebInspector.panels[id] = panel;
|
||||
var iframe = this._createClientIframe(panel.element, message.url);
|
||||
iframe.style.height = "100%";
|
||||
return this._status.OK();
|
||||
},
|
||||
|
||||
_onCreateSidebar: function(message)
|
||||
{
|
||||
var sidebar = this._createSidebar(message, WebInspector.SidebarPane);
|
||||
if (sidebar.isError)
|
||||
return sidebar;
|
||||
this._createClientIframe(sidebar.bodyElement, message.url);
|
||||
return this._status.OK();
|
||||
},
|
||||
|
||||
_onCreateWatchExpressionSidebarPane: function(message)
|
||||
{
|
||||
var sidebar = this._createSidebar(message, WebInspector.ExtensionWatchSidebarPane);
|
||||
return sidebar.isError ? sidebar : this._status.OK();
|
||||
},
|
||||
|
||||
_createSidebar: function(message, constructor)
|
||||
{
|
||||
var panel = WebInspector.panels[message.panel];
|
||||
if (!panel)
|
||||
return this._status.E_NOTFOUND(message.panel);
|
||||
if (!panel.sidebarElement || !panel.sidebarPanes)
|
||||
return this._status.E_NOTSUPPORTED();
|
||||
var id = message.id;
|
||||
var sidebar = new constructor(message.title, message.id);
|
||||
this._clientObjects[id] = sidebar;
|
||||
panel.sidebarPanes[id] = sidebar;
|
||||
panel.sidebarElement.appendChild(sidebar.element);
|
||||
|
||||
return sidebar;
|
||||
},
|
||||
|
||||
_createClientIframe: function(parent, url, requestId, port)
|
||||
{
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = url;
|
||||
iframe.style.width = "100%";
|
||||
parent.appendChild(iframe);
|
||||
return iframe;
|
||||
},
|
||||
|
||||
_onSetSidebarHeight: function(message)
|
||||
{
|
||||
var sidebar = this._clientObjects[message.id];
|
||||
if (!sidebar)
|
||||
return this._status.E_NOTFOUND(message.id);
|
||||
sidebar.bodyElement.firstChild.style.height = message.height;
|
||||
},
|
||||
|
||||
_onSetWatchSidebarContent: function(message)
|
||||
{
|
||||
var sidebar = this._clientObjects[message.id];
|
||||
if (!sidebar)
|
||||
return this._status.E_NOTFOUND(message.id);
|
||||
if (message.evaluateOnPage)
|
||||
sidebar.setExpression(message.expression, message.rootTitle);
|
||||
else
|
||||
sidebar.setObject(message.expression, message.rootTitle);
|
||||
},
|
||||
|
||||
_onLog: function(message)
|
||||
{
|
||||
WebInspector.log(message.message);
|
||||
},
|
||||
|
||||
_onReload: function(message)
|
||||
{
|
||||
if (typeof message.userAgent === "string")
|
||||
InspectorBackend.setUserAgentOverride(message.userAgent);
|
||||
|
||||
InspectorBackend.reloadPage(false);
|
||||
return this._status.OK();
|
||||
},
|
||||
|
||||
_onEvaluateOnInspectedPage: function(message, port)
|
||||
{
|
||||
function callback(resultPayload)
|
||||
{
|
||||
var resultObject = WebInspector.RemoteObject.fromPayload(resultPayload);
|
||||
var result = {};
|
||||
if (resultObject.isError())
|
||||
result.isException = true;
|
||||
result.value = resultObject.description;
|
||||
this._dispatchCallback(message.requestId, port, result);
|
||||
}
|
||||
var evalExpression = "JSON.stringify(eval(unescape('" + escape(message.expression) + "')));";
|
||||
InspectorBackend.evaluate(evalExpression, "none", true, callback.bind(this));
|
||||
},
|
||||
|
||||
_onRevealAndSelect: function(message)
|
||||
{
|
||||
if (message.panelId === "resources" && type === "resource")
|
||||
return this._onRevealAndSelectResource(message);
|
||||
else
|
||||
return this._status.E_NOTSUPPORTED(message.panelId, message.type);
|
||||
},
|
||||
|
||||
_onRevealAndSelectResource: function(message)
|
||||
{
|
||||
var id = message.id;
|
||||
var resource = null;
|
||||
|
||||
resource = WebInspector.networkResourceById(id) || WebInspector.resourceForURL(id);
|
||||
if (!resource)
|
||||
return this._status.E_NOTFOUND(typeof id + ": " + id);
|
||||
|
||||
WebInspector.panels.resources.showResource(resource, message.line);
|
||||
WebInspector.showPanel("resources");
|
||||
},
|
||||
|
||||
_dispatchCallback: function(requestId, port, result)
|
||||
{
|
||||
port.postMessage({ command: "callback", requestId: requestId, result: result });
|
||||
},
|
||||
|
||||
_onGetHAR: function(request)
|
||||
{
|
||||
var harLog = new WebInspector.HARLog();
|
||||
harLog.includeResourceIds = true;
|
||||
return harLog.build();
|
||||
},
|
||||
|
||||
_onGetResourceContent: function(message, port)
|
||||
{
|
||||
function onContentAvailable(content, encoded)
|
||||
{
|
||||
var response = {
|
||||
encoding: encoded ? "base64" : "",
|
||||
content: content
|
||||
};
|
||||
this._dispatchCallback(message.requestId, port, response);
|
||||
}
|
||||
var resource = WebInspector.networkResourceById(message.id);
|
||||
if (!resource)
|
||||
return this._status.E_NOTFOUND(message.id);
|
||||
resource.requestContent(onContentAvailable.bind(this));
|
||||
},
|
||||
|
||||
_onAddAuditCategory: function(request)
|
||||
{
|
||||
var category = new WebInspector.ExtensionAuditCategory(request.id, request.displayName, request.resultCount);
|
||||
if (WebInspector.panels.audits.getCategory(category.id))
|
||||
return this._status.E_EXISTS(category.id);
|
||||
this._clientObjects[request.id] = category;
|
||||
WebInspector.panels.audits.addCategory(category);
|
||||
},
|
||||
|
||||
_onAddAuditResult: function(request)
|
||||
{
|
||||
var auditResult = this._clientObjects[request.resultId];
|
||||
if (!auditResult)
|
||||
return this._status.E_NOTFOUND(request.resultId);
|
||||
try {
|
||||
auditResult.addResult(request.displayName, request.description, request.severity, request.details);
|
||||
} catch (e) {
|
||||
return e;
|
||||
}
|
||||
return this._status.OK();
|
||||
},
|
||||
|
||||
_onStopAuditCategoryRun: function(request)
|
||||
{
|
||||
var auditRun = this._clientObjects[request.resultId];
|
||||
if (!auditRun)
|
||||
return this._status.E_NOTFOUND(request.resultId);
|
||||
auditRun.cancel();
|
||||
},
|
||||
|
||||
initExtensions: function()
|
||||
{
|
||||
// The networkManager is normally created after the ExtensionServer is constructed, but before initExtensions() is called.
|
||||
WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._notifyResourceFinished, this);
|
||||
|
||||
InspectorExtensionRegistry.getExtensionsAsync();
|
||||
},
|
||||
|
||||
_addExtensions: function(extensions)
|
||||
{
|
||||
// See ExtensionAPI.js and ExtensionCommon.js for details.
|
||||
InspectorFrontendHost.setExtensionAPI(this._buildExtensionAPIInjectedScript());
|
||||
for (var i = 0; i < extensions.length; ++i) {
|
||||
var extension = extensions[i];
|
||||
try {
|
||||
if (!extension.startPage)
|
||||
return;
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = extension.startPage;
|
||||
iframe.style.display = "none";
|
||||
document.body.appendChild(iframe);
|
||||
} catch (e) {
|
||||
console.error("Failed to initialize extension " + extension.startPage + ":" + e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_buildExtensionAPIInjectedScript: function()
|
||||
{
|
||||
var resourceTypes = {};
|
||||
var resourceTypeProperties = Object.getOwnPropertyNames(WebInspector.Resource.Type);
|
||||
for (var i = 0; i < resourceTypeProperties.length; ++i) {
|
||||
var propName = resourceTypeProperties[i];
|
||||
var propValue = WebInspector.Resource.Type[propName];
|
||||
if (typeof propValue === "number")
|
||||
resourceTypes[propName] = WebInspector.Resource.Type.toString(propValue);
|
||||
}
|
||||
var platformAPI = WebInspector.buildPlatformExtensionAPI ? WebInspector.buildPlatformExtensionAPI() : "";
|
||||
return "(function(){ " +
|
||||
"var apiPrivate = {};" +
|
||||
"(" + WebInspector.commonExtensionSymbols.toString() + ")(apiPrivate);" +
|
||||
"(" + WebInspector.injectedExtensionAPI.toString() + ").apply(this, arguments);" +
|
||||
platformAPI +
|
||||
"})";
|
||||
},
|
||||
|
||||
_onWindowMessage: function(event)
|
||||
{
|
||||
if (event.data !== "registerExtension")
|
||||
return;
|
||||
var port = event.ports[0];
|
||||
port.addEventListener("message", this._onmessage.bind(this), false);
|
||||
port.start();
|
||||
},
|
||||
|
||||
_onmessage: function(event)
|
||||
{
|
||||
var request = event.data;
|
||||
var result;
|
||||
|
||||
if (request.command in this._handlers)
|
||||
result = this._handlers[request.command](request, event.target);
|
||||
else
|
||||
result = this._status.E_NOTSUPPORTED(request.command);
|
||||
|
||||
if (result && request.requestId)
|
||||
this._dispatchCallback(request.requestId, event.target, result);
|
||||
},
|
||||
|
||||
_registerHandler: function(command, callback)
|
||||
{
|
||||
this._handlers[command] = callback;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ExtensionServer._statuses =
|
||||
{
|
||||
OK: "",
|
||||
E_EXISTS: "Object already exists: %s",
|
||||
E_BADARG: "Invalid argument %s: %s",
|
||||
E_BADARGTYPE: "Invalid type for argument %s: got %s, expected %s",
|
||||
E_NOTFOUND: "Object not found: %s",
|
||||
E_NOTSUPPORTED: "Object does not support requested operation: %s",
|
||||
}
|
||||
|
||||
WebInspector.ExtensionStatus = function()
|
||||
{
|
||||
function makeStatus(code)
|
||||
{
|
||||
var description = WebInspector.ExtensionServer._statuses[code] || code;
|
||||
var details = Array.prototype.slice.call(arguments, 1);
|
||||
var status = { code: code, description: description, details: details };
|
||||
if (code !== "OK") {
|
||||
status.isError = true;
|
||||
console.log("Extension server error: " + String.vsprintf(description, details));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
for (status in WebInspector.ExtensionServer._statuses)
|
||||
this[status] = makeStatus.bind(null, status);
|
||||
}
|
||||
|
||||
WebInspector.addExtensions = function(extensions)
|
||||
{
|
||||
WebInspector.extensionServer._addExtensions(extensions);
|
||||
}
|
||||
|
||||
WebInspector.extensionServer = new WebInspector.ExtensionServer();
|
109
node_modules/weinre/web/client/FontView.js
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2007, 2008 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.FontView = function(resource)
|
||||
{
|
||||
WebInspector.ResourceView.call(this, resource);
|
||||
|
||||
this.element.addStyleClass("font");
|
||||
}
|
||||
|
||||
WebInspector.FontView.prototype = {
|
||||
hasContent: function()
|
||||
{
|
||||
return true;
|
||||
},
|
||||
|
||||
_createContentIfNeeded: function()
|
||||
{
|
||||
if (this.fontPreviewElement)
|
||||
return;
|
||||
|
||||
var uniqueFontName = "WebInspectorFontPreview" + this.resource.identifier;
|
||||
|
||||
this.fontStyleElement = document.createElement("style");
|
||||
this.fontStyleElement.textContent = "@font-face { font-family: \"" + uniqueFontName + "\"; src: url(" + this.resource.url + "); }";
|
||||
document.head.appendChild(this.fontStyleElement);
|
||||
|
||||
this.fontPreviewElement = document.createElement("div");
|
||||
this.element.appendChild(this.fontPreviewElement);
|
||||
|
||||
this.fontPreviewElement.style.setProperty("font-family", uniqueFontName, null);
|
||||
this.fontPreviewElement.innerHTML = "ABCDEFGHIJKLM<br>NOPQRSTUVWXYZ<br>abcdefghijklm<br>nopqrstuvwxyz<br>1234567890";
|
||||
this._lineCount = this.fontPreviewElement.getElementsByTagName("br").length + 1;
|
||||
|
||||
this.updateFontPreviewSize();
|
||||
},
|
||||
|
||||
show: function(parentElement)
|
||||
{
|
||||
WebInspector.ResourceView.prototype.show.call(this, parentElement);
|
||||
this._createContentIfNeeded();
|
||||
this.updateFontPreviewSize();
|
||||
},
|
||||
|
||||
resize: function()
|
||||
{
|
||||
this.updateFontPreviewSize();
|
||||
WebInspector.ResourceView.prototype.resize.call(this);
|
||||
},
|
||||
|
||||
updateFontPreviewSize: function()
|
||||
{
|
||||
if (!this.fontPreviewElement || !this.visible)
|
||||
return;
|
||||
|
||||
var measureFontSize = 50;
|
||||
this.fontPreviewElement.style.setProperty("font-size", measureFontSize + "px", null);
|
||||
this.fontPreviewElement.style.setProperty("position", "absolute", null);
|
||||
this.fontPreviewElement.style.removeProperty("height");
|
||||
|
||||
var height = this.fontPreviewElement.offsetHeight;
|
||||
var width = this.fontPreviewElement.offsetWidth;
|
||||
|
||||
// Subtract some padding. This should match the padding in the CSS plus room for the scrollbar.
|
||||
var containerWidth = this.element.offsetWidth - 50;
|
||||
|
||||
if (!height || !width || !containerWidth) {
|
||||
this.fontPreviewElement.style.removeProperty("font-size");
|
||||
this.fontPreviewElement.style.removeProperty("position");
|
||||
return;
|
||||
}
|
||||
|
||||
var realLineHeight = Math.floor(height / this._lineCount);
|
||||
var fontSizeLineRatio = measureFontSize / realLineHeight;
|
||||
var widthRatio = containerWidth / width;
|
||||
var finalFontSize = Math.floor(realLineHeight * widthRatio * fontSizeLineRatio) - 2;
|
||||
|
||||
this.fontPreviewElement.style.setProperty("font-size", finalFontSize + "px", null);
|
||||
this.fontPreviewElement.style.setProperty("height", this.fontPreviewElement.offsetHeight + "px", null);
|
||||
this.fontPreviewElement.style.removeProperty("position");
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.FontView.prototype.__proto__ = WebInspector.ResourceView.prototype;
|
127
node_modules/weinre/web/client/GoToLineDialog.js
generated
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.GoToLineDialog = function(view)
|
||||
{
|
||||
this._element = document.createElement("div");
|
||||
this._element.className = "go-to-line-dialog";
|
||||
this._element.addEventListener("keydown", this._onKeyDown.bind(this), false);
|
||||
this._closeKeys = [
|
||||
WebInspector.KeyboardShortcut.Keys.Enter.code,
|
||||
WebInspector.KeyboardShortcut.Keys.Esc.code,
|
||||
];
|
||||
|
||||
var dialogWindow = this._element;
|
||||
|
||||
dialogWindow.createChild("label").innerText = WebInspector.UIString("Go to line: ");
|
||||
|
||||
this._input = dialogWindow.createChild("input");
|
||||
this._input.setAttribute("type", "text");
|
||||
this._input.setAttribute("size", 6);
|
||||
var linesCount = view.textModel.linesCount;
|
||||
if (linesCount)
|
||||
this._input.setAttribute("title", WebInspector.UIString("1 - %d", linesCount));
|
||||
var blurHandler = this._onBlur.bind(this);
|
||||
this._input.addEventListener("blur", blurHandler, false);
|
||||
|
||||
|
||||
var go = dialogWindow.createChild("button");
|
||||
go.innerText = WebInspector.UIString("Go");
|
||||
go.addEventListener("click", this._onClick.bind(this), false);
|
||||
go.addEventListener("mousedown", function(e) {
|
||||
// Ok button click will close the dialog, removing onBlur listener
|
||||
// to let click event be handled.
|
||||
this._input.removeEventListener("blur", blurHandler, false);
|
||||
}.bind(this), false);
|
||||
|
||||
this._view = view;
|
||||
view.element.appendChild(this._element);
|
||||
|
||||
this._previousFocusElement = WebInspector.currentFocusElement;
|
||||
WebInspector.currentFocusElement = this._input;
|
||||
this._input.select();
|
||||
}
|
||||
|
||||
WebInspector.GoToLineDialog.show = function(sourceView)
|
||||
{
|
||||
if (this._instance)
|
||||
return;
|
||||
this._instance = new WebInspector.GoToLineDialog(sourceView);
|
||||
}
|
||||
|
||||
WebInspector.GoToLineDialog.prototype = {
|
||||
_hide: function()
|
||||
{
|
||||
if (this._isHiding)
|
||||
return;
|
||||
this._isHiding = true;
|
||||
|
||||
WebInspector.currentFocusElement = this._previousFocusElement;
|
||||
WebInspector.GoToLineDialog._instance = null;
|
||||
this._element.parentElement.removeChild(this._element);
|
||||
},
|
||||
|
||||
_onBlur: function(event)
|
||||
{
|
||||
this._hide();
|
||||
},
|
||||
|
||||
_onKeyDown: function(event)
|
||||
{
|
||||
if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Tab.code) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code)
|
||||
this._highlightSelectedLine();
|
||||
|
||||
if (this._closeKeys.indexOf(event.keyCode) >= 0) {
|
||||
this._hide();
|
||||
event.stopPropagation();
|
||||
}
|
||||
},
|
||||
|
||||
_onClick: function(event)
|
||||
{
|
||||
this._highlightSelectedLine();
|
||||
this._hide();
|
||||
},
|
||||
|
||||
_highlightSelectedLine: function()
|
||||
{
|
||||
var value = this._input.value;
|
||||
var lineNumber = parseInt(value, 10);
|
||||
if (!isNaN(lineNumber) && lineNumber > 0) {
|
||||
lineNumber = Math.min(lineNumber, this._view.textModel.linesCount);
|
||||
this._view.highlightLine(lineNumber);
|
||||
}
|
||||
}
|
||||
};
|
246
node_modules/weinre/web/client/HAREntry.js
generated
vendored
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
// See http://groups.google.com/group/http-archive-specification/web/har-1-2-spec
|
||||
// for HAR specification.
|
||||
|
||||
WebInspector.HAREntry = function(resource)
|
||||
{
|
||||
this._resource = resource;
|
||||
}
|
||||
|
||||
WebInspector.HAREntry.prototype = {
|
||||
build: function()
|
||||
{
|
||||
return {
|
||||
pageref: this._resource.documentURL,
|
||||
startedDateTime: new Date(this._resource.startTime * 1000),
|
||||
time: WebInspector.HAREntry._toMilliseconds(this._resource.duration),
|
||||
request: this._buildRequest(),
|
||||
response: this._buildResponse(),
|
||||
// cache: {...}, -- Not supproted yet.
|
||||
timings: this._buildTimings()
|
||||
};
|
||||
},
|
||||
|
||||
_buildRequest: function()
|
||||
{
|
||||
var res = {
|
||||
method: this._resource.requestMethod,
|
||||
url: this._resource.url,
|
||||
// httpVersion: "HTTP/1.1" -- Not available.
|
||||
headers: this._buildHeaders(this._resource.requestHeaders),
|
||||
headersSize: -1, // Not available.
|
||||
bodySize: -1 // Not available.
|
||||
};
|
||||
if (this._resource.queryParameters)
|
||||
res.queryString = this._buildParameters(this._resource.queryParameters);
|
||||
if (this._resource.requestFormData)
|
||||
res.postData = this._buildPostData();
|
||||
if (this._resource.requestCookies)
|
||||
res.cookies = this._buildCookies(this._resource.requestCookies);
|
||||
return res;
|
||||
},
|
||||
|
||||
_buildResponse: function()
|
||||
{
|
||||
var res = {
|
||||
status: this._resource.statusCode,
|
||||
statusText: this._resource.statusText,
|
||||
// "httpVersion": "HTTP/1.1" -- Not available.
|
||||
headers: this._buildHeaders(this._resource.responseHeaders),
|
||||
content: this._buildContent(),
|
||||
redirectURL: this._resource.responseHeaderValue("Location") || "",
|
||||
headersSize: -1, // Not available.
|
||||
bodySize: this._resource.resourceSize
|
||||
};
|
||||
if (this._resource.responseCookies)
|
||||
res.cookies = this._buildCookies(this._resource.responseCookies);
|
||||
return res;
|
||||
},
|
||||
|
||||
_buildContent: function()
|
||||
{
|
||||
return {
|
||||
size: this._resource.resourceSize,
|
||||
// compression: 0, -- Not available.
|
||||
mimeType: this._resource.mimeType,
|
||||
// text: -- Not available.
|
||||
};
|
||||
},
|
||||
|
||||
_buildTimings: function()
|
||||
{
|
||||
var waitForConnection = this._interval("connectStart", "connectEnd");
|
||||
var blocked;
|
||||
var connect;
|
||||
var dns = this._interval("dnsStart", "dnsEnd");
|
||||
var send = this._interval("sendStart", "sendEnd");
|
||||
var ssl = this._interval("sslStart", "sslEnd");
|
||||
|
||||
if (ssl !== -1 && send !== -1)
|
||||
send -= ssl;
|
||||
|
||||
if (this._resource.connectionReused) {
|
||||
connect = -1;
|
||||
blocked = waitForConnection;
|
||||
} else {
|
||||
blocked = 0;
|
||||
connect = waitForConnection;
|
||||
if (dns !== -1)
|
||||
connect -= dns;
|
||||
}
|
||||
|
||||
return {
|
||||
blocked: blocked,
|
||||
dns: dns,
|
||||
connect: connect,
|
||||
send: send,
|
||||
wait: this._interval("sendEnd", "receiveHeadersEnd"),
|
||||
receive: WebInspector.HAREntry._toMilliseconds(this._resource.receiveDuration),
|
||||
ssl: ssl
|
||||
};
|
||||
},
|
||||
|
||||
_buildHeaders: function(headers)
|
||||
{
|
||||
var result = [];
|
||||
for (var name in headers)
|
||||
result.push({ name: name, value: headers[name] });
|
||||
return result;
|
||||
},
|
||||
|
||||
_buildPostData: function()
|
||||
{
|
||||
var res = {
|
||||
mimeType: this._resource.requestHeaderValue("Content-Type"),
|
||||
text: this._resource.requestFormData
|
||||
};
|
||||
if (this._resource.formParameters)
|
||||
res.params = this._buildParameters(this._resource.formParameters);
|
||||
return res;
|
||||
},
|
||||
|
||||
_buildParameters: function(parameters)
|
||||
{
|
||||
return parameters.slice();
|
||||
},
|
||||
|
||||
_buildCookies: function(cookies)
|
||||
{
|
||||
return cookies.map(this._buildCookie.bind(this));
|
||||
},
|
||||
|
||||
_buildCookie: function(cookie)
|
||||
{
|
||||
|
||||
return {
|
||||
name: cookie.name,
|
||||
value: cookie.value,
|
||||
path: cookie.path,
|
||||
domain: cookie.domain,
|
||||
expires: cookie.expires(new Date(this._resource.startTime * 1000)),
|
||||
httpOnly: cookie.httpOnly,
|
||||
secure: cookie.secure
|
||||
};
|
||||
},
|
||||
|
||||
_interval: function(start, end)
|
||||
{
|
||||
var timing = this._resource.timing;
|
||||
if (!timing)
|
||||
return -1;
|
||||
var startTime = timing[start];
|
||||
return typeof startTime !== "number" || startTime === -1 ? -1 : Math.round(timing[end] - startTime);
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.HAREntry._toMilliseconds = function(time)
|
||||
{
|
||||
return time === -1 ? -1 : Math.round(time * 1000);
|
||||
}
|
||||
|
||||
WebInspector.HARLog = function()
|
||||
{
|
||||
this.includeResourceIds = false;
|
||||
}
|
||||
|
||||
WebInspector.HARLog.prototype = {
|
||||
build: function()
|
||||
{
|
||||
var webKitVersion = /AppleWebKit\/([^ ]+)/.exec(window.navigator.userAgent);
|
||||
|
||||
return {
|
||||
version: "1.2",
|
||||
creator: {
|
||||
name: "WebInspector",
|
||||
version: webKitVersion ? webKitVersion[1] : "n/a"
|
||||
},
|
||||
pages: this._buildPages(),
|
||||
entries: WebInspector.networkResources.map(this._convertResource.bind(this))
|
||||
}
|
||||
},
|
||||
|
||||
_buildPages: function()
|
||||
{
|
||||
return [
|
||||
{
|
||||
startedDateTime: new Date(WebInspector.mainResource.startTime * 1000),
|
||||
id: WebInspector.mainResource.documentURL,
|
||||
title: "",
|
||||
pageTimings: this.buildMainResourceTimings()
|
||||
}
|
||||
];
|
||||
},
|
||||
|
||||
buildMainResourceTimings: function()
|
||||
{
|
||||
return {
|
||||
onContentLoad: this._pageEventTime(WebInspector.mainResourceDOMContentTime),
|
||||
onLoad: this._pageEventTime(WebInspector.mainResourceLoadTime),
|
||||
}
|
||||
},
|
||||
|
||||
_convertResource: function(resource)
|
||||
{
|
||||
var entry = (new WebInspector.HAREntry(resource)).build();
|
||||
if (this.includeResourceIds)
|
||||
entry._resourceId = resource.identifier;
|
||||
return entry;
|
||||
},
|
||||
|
||||
_pageEventTime: function(time)
|
||||
{
|
||||
var startTime = WebInspector.mainResource.startTime;
|
||||
if (time === -1 || startTime === -1)
|
||||
return -1;
|
||||
return WebInspector.HAREntry._toMilliseconds(time - startTime);
|
||||
}
|
||||
}
|
909
node_modules/weinre/web/client/HeapSnapshot.js
generated
vendored
Normal file
@ -0,0 +1,909 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.HeapSnapshotArraySlice = function(snapshot, arrayName, start, end)
|
||||
{
|
||||
// Note: we don't reference snapshot contents directly to avoid
|
||||
// holding references to big chunks of data.
|
||||
this._snapshot = snapshot;
|
||||
this._arrayName = arrayName;
|
||||
this._start = start;
|
||||
this.length = end - start;
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotArraySlice.prototype = {
|
||||
item: function(index)
|
||||
{
|
||||
return this._snapshot[this._arrayName][this._start + index];
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex)
|
||||
{
|
||||
this._snapshot = snapshot;
|
||||
this._edges = edges;
|
||||
this.edgeIndex = edgeIndex || 0;
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotEdge.prototype = {
|
||||
clone: function()
|
||||
{
|
||||
return new WebInspector.HeapSnapshotEdge(this._snapshot, this._edges, this.edgeIndex);
|
||||
},
|
||||
|
||||
get hasStringName()
|
||||
{
|
||||
if (!this.isShortcut)
|
||||
return this._hasStringName;
|
||||
return isNaN(parseInt(this._name, 10));
|
||||
},
|
||||
|
||||
get isElement()
|
||||
{
|
||||
return this._type() === this._snapshot._edgeElementType;
|
||||
},
|
||||
|
||||
get isHidden()
|
||||
{
|
||||
return this._type() === this._snapshot._edgeHiddenType;
|
||||
},
|
||||
|
||||
get isInternal()
|
||||
{
|
||||
return this._type() === this._snapshot._edgeInternalType;
|
||||
},
|
||||
|
||||
get isShortcut()
|
||||
{
|
||||
return this._type() === this._snapshot._edgeShortcutType;
|
||||
},
|
||||
|
||||
get name()
|
||||
{
|
||||
if (!this.isShortcut)
|
||||
return this._name;
|
||||
var numName = parseInt(this._name, 10);
|
||||
return isNaN(numName) ? this._name : numName;
|
||||
},
|
||||
|
||||
get node()
|
||||
{
|
||||
return new WebInspector.HeapSnapshotNode(this._snapshot, this.nodeIndex);
|
||||
},
|
||||
|
||||
get nodeIndex()
|
||||
{
|
||||
return this._edges.item(this.edgeIndex + this._snapshot._edgeToNodeOffset);
|
||||
},
|
||||
|
||||
get rawEdges()
|
||||
{
|
||||
return this._edges;
|
||||
},
|
||||
|
||||
toString: function()
|
||||
{
|
||||
switch (this.type) {
|
||||
case "context": return "->" + this.name;
|
||||
case "element": return "[" + this.name + "]";
|
||||
case "property":
|
||||
return this.name.indexOf(" ") === -1 ? "." + this.name : "[\"" + this.name + "\"]";
|
||||
case "shortcut":
|
||||
var name = this.name;
|
||||
if (typeof name === "string")
|
||||
return this.name.indexOf(" ") === -1 ? "." + this.name : "[\"" + this.name + "\"]";
|
||||
else
|
||||
return "[" + this.name + "]";
|
||||
case "internal":
|
||||
case "hidden":
|
||||
return "{" + this.name + "}";
|
||||
};
|
||||
return "?" + this.name + "?";
|
||||
},
|
||||
|
||||
get type()
|
||||
{
|
||||
return this._snapshot._edgeTypes[this._type()];
|
||||
},
|
||||
|
||||
get _hasStringName()
|
||||
{
|
||||
return !this.isElement && !this.isHidden;
|
||||
},
|
||||
|
||||
get _name()
|
||||
{
|
||||
return this._hasStringName ? this._snapshot._strings[this._nameOrIndex] : this._nameOrIndex;
|
||||
},
|
||||
|
||||
get _nameOrIndex()
|
||||
{
|
||||
return this._edges.item(this.edgeIndex + this._snapshot._edgeNameOffset);
|
||||
},
|
||||
|
||||
_type: function()
|
||||
{
|
||||
return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset);
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.HeapSnapshotEdgeIterator = function(edge)
|
||||
{
|
||||
this.edge = edge;
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotEdgeIterator.prototype = {
|
||||
first: function()
|
||||
{
|
||||
this.edge.edgeIndex = 0;
|
||||
},
|
||||
|
||||
hasNext: function()
|
||||
{
|
||||
return this.edge.edgeIndex < this.edge._edges.length;
|
||||
},
|
||||
|
||||
get index()
|
||||
{
|
||||
return this.edge.edgeIndex;
|
||||
},
|
||||
|
||||
set index(newIndex)
|
||||
{
|
||||
this.edge.edgeIndex = newIndex;
|
||||
},
|
||||
|
||||
get item()
|
||||
{
|
||||
return this.edge;
|
||||
},
|
||||
|
||||
next: function()
|
||||
{
|
||||
this.edge.edgeIndex += this.edge._snapshot._edgeFieldsCount;
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex)
|
||||
{
|
||||
this._snapshot = snapshot;
|
||||
this._firstNodeIndex = nodeIndex;
|
||||
this.nodeIndex = nodeIndex;
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotNode.prototype = {
|
||||
get className()
|
||||
{
|
||||
switch (this.type) {
|
||||
case "hidden":
|
||||
return WebInspector.UIString("(system)");
|
||||
case "object":
|
||||
return this.name;
|
||||
case "code":
|
||||
return WebInspector.UIString("(compiled code)");
|
||||
default:
|
||||
return "(" + this.type + ")";
|
||||
}
|
||||
},
|
||||
|
||||
dominatorIndex: function()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._dominatorOffset];
|
||||
},
|
||||
|
||||
get edges()
|
||||
{
|
||||
return new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(this._snapshot, this.rawEdges));
|
||||
},
|
||||
|
||||
get edgesCount()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._edgesCountOffset];
|
||||
},
|
||||
|
||||
get id()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._nodeIdOffset];
|
||||
},
|
||||
|
||||
get instancesCount()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._nodeInstancesCountOffset];
|
||||
},
|
||||
|
||||
get isHidden()
|
||||
{
|
||||
return this._type() === this._snapshot._nodeHiddenType;
|
||||
},
|
||||
|
||||
get isRoot()
|
||||
{
|
||||
return this.nodeIndex === this._snapshot._rootNodeIndex;
|
||||
},
|
||||
|
||||
get name()
|
||||
{
|
||||
return this._snapshot._strings[this._name()];
|
||||
},
|
||||
|
||||
get rawEdges()
|
||||
{
|
||||
var firstEdgeIndex = this._firstEdgeIndex();
|
||||
return new WebInspector.HeapSnapshotArraySlice(this._snapshot, "_nodes", firstEdgeIndex, firstEdgeIndex + this.edgesCount * this._snapshot._edgeFieldsCount);
|
||||
},
|
||||
|
||||
get retainedSize()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._nodeRetainedSizeOffset];
|
||||
},
|
||||
|
||||
get retainers()
|
||||
{
|
||||
return new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(this._snapshot, this._snapshot.retainers(this)));
|
||||
},
|
||||
|
||||
get selfSize()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._nodeSelfSizeOffset];
|
||||
},
|
||||
|
||||
get type()
|
||||
{
|
||||
return this._snapshot._nodeTypes[this._type()];
|
||||
},
|
||||
|
||||
_name: function()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._nodeNameOffset];
|
||||
},
|
||||
|
||||
get _nodes()
|
||||
{
|
||||
return this._snapshot._nodes;
|
||||
},
|
||||
|
||||
_firstEdgeIndex: function()
|
||||
{
|
||||
return this.nodeIndex + this._snapshot._firstEdgeOffset;
|
||||
},
|
||||
|
||||
get _nextNodeIndex()
|
||||
{
|
||||
return this._firstEdgeIndex() + this.edgesCount * this._snapshot._edgeFieldsCount;
|
||||
},
|
||||
|
||||
_type: function()
|
||||
{
|
||||
return this._nodes[this.nodeIndex + this._snapshot._nodeTypeOffset];
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.HeapSnapshotNodeIterator = function(node)
|
||||
{
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotNodeIterator.prototype = {
|
||||
first: function()
|
||||
{
|
||||
this.node.nodeIndex = this.node._firstNodeIndex;
|
||||
},
|
||||
|
||||
hasNext: function()
|
||||
{
|
||||
return this.node.nodeIndex < this.node._nodes.length;
|
||||
},
|
||||
|
||||
get index()
|
||||
{
|
||||
return this.node.nodeIndex;
|
||||
},
|
||||
|
||||
set index(newIndex)
|
||||
{
|
||||
this.node.nodeIndex = newIndex;
|
||||
},
|
||||
|
||||
get item()
|
||||
{
|
||||
return this.node;
|
||||
},
|
||||
|
||||
next: function()
|
||||
{
|
||||
this.node.nodeIndex = this.node._nextNodeIndex;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshot = function(profile)
|
||||
{
|
||||
this._nodes = profile.nodes;
|
||||
this._strings = profile.strings;
|
||||
|
||||
this._init();
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshot.prototype = {
|
||||
_init: function()
|
||||
{
|
||||
this._metaNodeIndex = 0;
|
||||
this._rootNodeIndex = 1;
|
||||
var meta = this._nodes[this._metaNodeIndex];
|
||||
this._nodeTypeOffset = meta.fields.indexOf("type");
|
||||
this._nodeNameOffset = meta.fields.indexOf("name");
|
||||
this._nodeIdOffset = meta.fields.indexOf("id");
|
||||
this._nodeInstancesCountOffset = this._nodeIdOffset;
|
||||
this._nodeSelfSizeOffset = meta.fields.indexOf("self_size");
|
||||
this._nodeRetainedSizeOffset = meta.fields.indexOf("retained_size");
|
||||
this._dominatorOffset = meta.fields.indexOf("dominator");
|
||||
this._edgesCountOffset = meta.fields.indexOf("children_count");
|
||||
this._firstEdgeOffset = meta.fields.indexOf("children");
|
||||
this._nodeTypes = meta.types[this._nodeTypeOffset];
|
||||
this._nodeHiddenType = this._nodeTypes.indexOf("hidden");
|
||||
var edgesMeta = meta.types[this._firstEdgeOffset];
|
||||
this._edgeFieldsCount = edgesMeta.fields.length;
|
||||
this._edgeTypeOffset = edgesMeta.fields.indexOf("type");
|
||||
this._edgeNameOffset = edgesMeta.fields.indexOf("name_or_index");
|
||||
this._edgeToNodeOffset = edgesMeta.fields.indexOf("to_node");
|
||||
this._edgeTypes = edgesMeta.types[this._edgeTypeOffset];
|
||||
this._edgeElementType = this._edgeTypes.indexOf("element");
|
||||
this._edgeHiddenType = this._edgeTypes.indexOf("hidden");
|
||||
this._edgeInternalType = this._edgeTypes.indexOf("internal");
|
||||
this._edgeShortcutType = this._edgeTypes.indexOf("shortcut");
|
||||
},
|
||||
|
||||
dispose: function()
|
||||
{
|
||||
delete this._nodes;
|
||||
delete this._strings;
|
||||
if (this._idsMap)
|
||||
delete this._idsMap;
|
||||
if (this._retainers) {
|
||||
delete this._retainers;
|
||||
delete this._nodesToRetainers;
|
||||
}
|
||||
if (this._aggregates) {
|
||||
delete this._aggregates;
|
||||
this._aggregatesWithIndexes = false;
|
||||
}
|
||||
},
|
||||
|
||||
get allNodes()
|
||||
{
|
||||
return new WebInspector.HeapSnapshotNodeIterator(this.rootNode);
|
||||
},
|
||||
|
||||
get nodesCount()
|
||||
{
|
||||
if (this._nodesCount)
|
||||
return this._nodesCount;
|
||||
|
||||
this._nodesCount = 0;
|
||||
for (var iter = this.allNodes; iter.hasNext(); iter.next())
|
||||
++this._nodesCount;
|
||||
return this._nodesCount;
|
||||
},
|
||||
|
||||
restore: function(profile)
|
||||
{
|
||||
this._nodes = profile.nodes;
|
||||
this._strings = profile.strings;
|
||||
},
|
||||
|
||||
get rootNode()
|
||||
{
|
||||
return new WebInspector.HeapSnapshotNode(this, this._rootNodeIndex);
|
||||
},
|
||||
|
||||
get totalSize()
|
||||
{
|
||||
return this.rootNode.retainedSize;
|
||||
},
|
||||
|
||||
get idsMap()
|
||||
{
|
||||
if (this._idsMap)
|
||||
return this._idsMap;
|
||||
|
||||
this._idsMap = [];
|
||||
for (var iter = this.allNodes; iter.hasNext(); iter.next()) {
|
||||
this._idsMap[iter.node.id] = true;
|
||||
}
|
||||
return this._idsMap;
|
||||
},
|
||||
|
||||
retainers: function(node)
|
||||
{
|
||||
if (!this._retainers)
|
||||
this._buildRetainers();
|
||||
|
||||
var retIndexFrom = this._nodesToRetainers[node.nodeIndex];
|
||||
var retIndexTo = this._nodesToRetainers[node._nextNodeIndex];
|
||||
return new WebInspector.HeapSnapshotArraySlice(this, "_retainers", retIndexFrom, retIndexTo);
|
||||
},
|
||||
|
||||
aggregates: function(withNodeIndexes)
|
||||
{
|
||||
if (!this._aggregates)
|
||||
this._buildAggregates();
|
||||
if (withNodeIndexes && !this._aggregatesWithIndexes)
|
||||
this._buildAggregatesIndexes();
|
||||
return this._aggregates;
|
||||
},
|
||||
|
||||
_buildRetainers: function()
|
||||
{
|
||||
this._nodesToRetainers = [];
|
||||
for (var nodesIter = this.allNodes; nodesIter.hasNext(); nodesIter.next()) {
|
||||
var node = nodesIter.node;
|
||||
if (!(node.nodeIndex in this._nodesToRetainers))
|
||||
this._nodesToRetainers[node.nodeIndex] = 0;
|
||||
for (var edgesIter = node.edges; edgesIter.hasNext(); edgesIter.next()) {
|
||||
var edge = edgesIter.edge;
|
||||
var nodeIndex = edge.nodeIndex;
|
||||
if (!(nodeIndex in this._nodesToRetainers))
|
||||
this._nodesToRetainers[nodeIndex] = 0;
|
||||
this._nodesToRetainers[nodeIndex] += this._edgeFieldsCount;
|
||||
}
|
||||
}
|
||||
nodesIter = this.allNodes;
|
||||
var node = nodesIter.node;
|
||||
var prevIndex = this._nodesToRetainers[node.nodeIndex] = 0;
|
||||
var prevRetsCount = this._nodesToRetainers[node.nodeIndex];
|
||||
nodesIter.next();
|
||||
for (; nodesIter.hasNext(); nodesIter.next()) {
|
||||
node = nodesIter.node;
|
||||
var savedRefsCount = this._nodesToRetainers[node.nodeIndex];
|
||||
this._nodesToRetainers[node.nodeIndex] = prevIndex + prevRetsCount;
|
||||
prevIndex = this._nodesToRetainers[node.nodeIndex];
|
||||
prevRetsCount = savedRefsCount;
|
||||
}
|
||||
this._retainers = new Array(prevIndex + prevRetsCount);
|
||||
this._nodesToRetainers[this._nodes.length] = this._retainers.length;
|
||||
for (nodesIter = this.allNodes; nodesIter.hasNext(); nodesIter.next()) {
|
||||
node = nodesIter.node;
|
||||
var retsCount = this._nodesToRetainers[node._nextNodeIndex] - this._nodesToRetainers[node.nodeIndex];
|
||||
if (retsCount > 0) {
|
||||
this._retainers[this._nodesToRetainers[node.nodeIndex]] = retsCount;
|
||||
}
|
||||
}
|
||||
for (nodesIter = this.allNodes; nodesIter.hasNext(); nodesIter.next()) {
|
||||
node = nodesIter.node;
|
||||
for (var edgesIter = node.edges; edgesIter.hasNext(); edgesIter.next()) {
|
||||
var edge = edgesIter.edge;
|
||||
var nodeIndex = edge.nodeIndex;
|
||||
var retIndex = this._nodesToRetainers[nodeIndex];
|
||||
this._retainers[retIndex] -= this._edgeFieldsCount;
|
||||
var idx = retIndex + this._retainers[retIndex];
|
||||
this._retainers[idx + this._edgeTypeOffset] = edge._type();
|
||||
this._retainers[idx + this._edgeNameOffset] = edge._nameOrIndex;
|
||||
this._retainers[idx + this._edgeToNodeOffset] = node.nodeIndex;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_buildAggregates: function()
|
||||
{
|
||||
this._aggregates = {};
|
||||
for (var iter = this.allNodes; iter.hasNext(); iter.next()) {
|
||||
var node = iter.node;
|
||||
var className = node.className;
|
||||
var nameMatters = node.type === "object";
|
||||
if (node.selfSize === 0)
|
||||
continue;
|
||||
if (!(className in this._aggregates))
|
||||
this._aggregates[className] = { count: 0, self: 0, maxRet: 0, type: node.type, name: nameMatters ? node.name : null, idxs: [] };
|
||||
var clss = this._aggregates[className];
|
||||
++clss.count;
|
||||
clss.self += node.selfSize;
|
||||
if (node.retainedSize > clss.maxRet)
|
||||
clss.maxRet = node.retainedSize;
|
||||
}
|
||||
},
|
||||
|
||||
_buildAggregatesIndexes: function()
|
||||
{
|
||||
for (var iter = this.allNodes; iter.hasNext(); iter.next()) {
|
||||
var node = iter.node;
|
||||
var className = node.className;
|
||||
var clss = this._aggregates[className];
|
||||
if (clss)
|
||||
clss.idxs.push(node.nodeIndex);
|
||||
}
|
||||
|
||||
var nodeA = new WebInspector.HeapSnapshotNode(this);
|
||||
var nodeB = new WebInspector.HeapSnapshotNode(this);
|
||||
for (var clss in this._aggregates)
|
||||
this._aggregates[clss].idxs.sort(
|
||||
function(idxA, idxB) {
|
||||
nodeA.nodeIndex = idxA;
|
||||
nodeB.nodeIndex = idxB;
|
||||
return nodeA.id < nodeB.id ? -1 : 1;
|
||||
});
|
||||
|
||||
this._aggregatesWithIndexes = true;
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.HeapSnapshotFilteredOrderedIterator = function(snapshot, iterator, filter)
|
||||
{
|
||||
this._snapshot = snapshot;
|
||||
this._filter = filter;
|
||||
this._iterator = iterator;
|
||||
this._iterationOrder = null;
|
||||
this._position = 0;
|
||||
this._lastComparator = null;
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
|
||||
_createIterationOrder: function()
|
||||
{
|
||||
this._iterationOrder = [];
|
||||
var iterator = this._iterator;
|
||||
if (!this._filter) {
|
||||
for (iterator.first(); iterator.hasNext(); iterator.next())
|
||||
this._iterationOrder.push(iterator.index);
|
||||
} else {
|
||||
for (iterator.first(); iterator.hasNext(); iterator.next()) {
|
||||
if (this._filter(iterator.item))
|
||||
this._iterationOrder.push(iterator.index);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
first: function()
|
||||
{
|
||||
this._position = 0;
|
||||
},
|
||||
|
||||
hasNext: function()
|
||||
{
|
||||
return this._position < this._iterationOrder.length;
|
||||
},
|
||||
|
||||
get isEmpty()
|
||||
{
|
||||
if (this._iterationOrder)
|
||||
return !this._iterationOrder.length;
|
||||
var iterator = this._iterator;
|
||||
if (!this._filter) {
|
||||
iterator.first();
|
||||
return !iterator.hasNext();
|
||||
}
|
||||
for (iterator.first(); iterator.hasNext(); iterator.next())
|
||||
if (this._filter(iterator.item)) return false;
|
||||
return true;
|
||||
},
|
||||
|
||||
get item()
|
||||
{
|
||||
this._iterator.index = this._iterationOrder[this._position];
|
||||
return this._iterator.item;
|
||||
},
|
||||
|
||||
get lastComparator()
|
||||
{
|
||||
return this._lastComparator;
|
||||
},
|
||||
|
||||
get length()
|
||||
{
|
||||
if (!this._iterationOrder)
|
||||
this._createIterationOrder();
|
||||
return this._iterationOrder.length;
|
||||
},
|
||||
|
||||
next: function()
|
||||
{
|
||||
++this._position;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator = function(fieldNames)
|
||||
{
|
||||
return {fieldName1:fieldNames[0], ascending1:fieldNames[1], fieldName2:fieldNames[2], ascending2:fieldNames[3]};
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotEdgesProvider = function(snapshot, rawEdges, filter)
|
||||
{
|
||||
WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot, new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(snapshot, rawEdges)), filter);
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotEdgesProvider.prototype = {
|
||||
sort: function(comparator)
|
||||
{
|
||||
if (this._lastComparator === comparator)
|
||||
return false;
|
||||
this._lastComparator = comparator;
|
||||
var fieldName1 = comparator.fieldName1;
|
||||
var fieldName2 = comparator.fieldName2;
|
||||
var ascending1 = comparator.ascending1;
|
||||
var ascending2 = comparator.ascending2;
|
||||
|
||||
var edgeA = this._iterator.item.clone();
|
||||
var edgeB = edgeA.clone();
|
||||
var nodeA = new WebInspector.HeapSnapshotNode(this._snapshot);
|
||||
var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot);
|
||||
|
||||
function sortByEdgeFieldName(ascending, indexA, indexB)
|
||||
{
|
||||
edgeA.edgeIndex = indexA;
|
||||
edgeB.edgeIndex = indexB;
|
||||
if (edgeB.name === "__proto__") return -1;
|
||||
if (edgeA.name === "__proto__") return 1;
|
||||
var result =
|
||||
edgeA.hasStringName === edgeB.hasStringName ?
|
||||
(edgeA.name < edgeB.name ? -1 : (edgeA.name > edgeB.name ? 1 : 0)) :
|
||||
(edgeA.hasStringName ? -1 : 1);
|
||||
return ascending ? result : -result;
|
||||
}
|
||||
|
||||
function sortByNodeField(fieldName, ascending, indexA, indexB)
|
||||
{
|
||||
edgeA.edgeIndex = indexA;
|
||||
edgeB.edgeIndex = indexB;
|
||||
nodeA.nodeIndex = edgeA.nodeIndex;
|
||||
nodeB.nodeIndex = edgeB.nodeIndex;
|
||||
var valueA = nodeA[fieldName];
|
||||
var valueB = nodeB[fieldName];
|
||||
var result = valueA < valueB ? -1 : (valueA > valueB ? 1 : 0);
|
||||
return ascending ? result : -result;
|
||||
}
|
||||
|
||||
if (!this._iterationOrder)
|
||||
this._createIterationOrder();
|
||||
|
||||
function sortByEdgeAndNode(indexA, indexB) {
|
||||
var result = sortByEdgeFieldName(ascending1, indexA, indexB);
|
||||
if (result === 0)
|
||||
result = sortByNodeField(fieldName2, ascending2, indexA, indexB);
|
||||
return result;
|
||||
}
|
||||
|
||||
function sortByNodeAndEdge(indexA, indexB) {
|
||||
var result = sortByNodeField(fieldName1, ascending1, indexA, indexB);
|
||||
if (result === 0)
|
||||
result = sortByEdgeFieldName(ascending2, indexA, indexB);
|
||||
return result;
|
||||
}
|
||||
|
||||
function sortByNodeAndNode(indexA, indexB) {
|
||||
var result = sortByNodeField(fieldName1, ascending1, indexA, indexB);
|
||||
if (result === 0)
|
||||
result = sortByNodeField(fieldName2, ascending2, indexA, indexB);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (fieldName1 === "!edgeName")
|
||||
this._iterationOrder.sort(sortByEdgeAndNode);
|
||||
else if (fieldName2 === "!edgeName")
|
||||
this._iterationOrder.sort(sortByNodeAndEdge);
|
||||
else
|
||||
this._iterationOrder.sort(sortByNodeAndNode);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.HeapSnapshotEdgesProvider.prototype.__proto__ = WebInspector.HeapSnapshotFilteredOrderedIterator.prototype;
|
||||
|
||||
WebInspector.HeapSnapshotNodesProvider = function(snapshot, nodes, filter)
|
||||
{
|
||||
WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot, nodes, filter);
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotNodesProvider.prototype = {
|
||||
sort: function(comparator)
|
||||
{
|
||||
if (this._lastComparator === comparator)
|
||||
return false;
|
||||
this._lastComparator = comparator;
|
||||
var fieldName1 = comparator.fieldName1;
|
||||
var fieldName2 = comparator.fieldName2;
|
||||
var ascending1 = comparator.ascending1;
|
||||
var ascending2 = comparator.ascending2;
|
||||
|
||||
var nodeA = new WebInspector.HeapSnapshotNode(this._snapshot);
|
||||
var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot);
|
||||
|
||||
function sortByNodeField(fieldName, ascending, indexA, indexB)
|
||||
{
|
||||
nodeA.nodeIndex = indexA;
|
||||
nodeB.nodeIndex = indexB;
|
||||
var valueA = nodeA[fieldName];
|
||||
var valueB = nodeB[fieldName];
|
||||
var result = valueA < valueB ? -1 : (valueA > valueB ? 1 : 0);
|
||||
return ascending ? result : -result;
|
||||
}
|
||||
|
||||
if (!this._iterationOrder)
|
||||
this._createIterationOrder();
|
||||
|
||||
function sortByComparator(indexA, indexB) {
|
||||
var result = sortByNodeField(fieldName1, ascending1, indexA, indexB);
|
||||
if (result === 0)
|
||||
result = sortByNodeField(fieldName2, ascending2, indexA, indexB);
|
||||
return result;
|
||||
}
|
||||
|
||||
this._iterationOrder.sort(sortByComparator);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
WebInspector.HeapSnapshotNodesProvider.prototype.__proto__ = WebInspector.HeapSnapshotFilteredOrderedIterator.prototype;
|
||||
|
||||
WebInspector.HeapSnapshotPathFinder = function(snapshot, targetNodeIndex)
|
||||
{
|
||||
this._snapshot = snapshot;
|
||||
this._maxLength = 1;
|
||||
this._lengthLimit = 15;
|
||||
this._targetNodeIndex = targetNodeIndex;
|
||||
this._currentPath = null;
|
||||
this._skipHidden = !WebInspector.DetailedHeapshotView.prototype.showHiddenData;
|
||||
this._rootChildren = this._fillRootChildren();
|
||||
}
|
||||
|
||||
WebInspector.HeapSnapshotPathFinder.prototype = {
|
||||
findNext: function()
|
||||
{
|
||||
for (var i = 0; i < 100000; ++i) {
|
||||
if (!this._buildNextPath()) {
|
||||
if (++this._maxLength >= this._lengthLimit)
|
||||
return null;
|
||||
this._currentPath = null;
|
||||
if (!this._buildNextPath())
|
||||
return null;
|
||||
}
|
||||
if (this._isPathFound())
|
||||
return {path:this._pathToString(this._currentPath), len:this._currentPath.length};
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_fillRootChildren: function()
|
||||
{
|
||||
var result = [];
|
||||
for (var iter = this._snapshot.rootNode.edges; iter.hasNext(); iter.next())
|
||||
result[iter.edge.nodeIndex] = true;
|
||||
return result;
|
||||
},
|
||||
|
||||
_appendToCurrentPath: function(iter)
|
||||
{
|
||||
this._currentPath._cache[this._lastEdge.nodeIndex] = true;
|
||||
this._currentPath.push(iter);
|
||||
},
|
||||
|
||||
_removeLastFromCurrentPath: function()
|
||||
{
|
||||
this._currentPath.pop();
|
||||
delete this._currentPath._cache[this._lastEdge.nodeIndex];
|
||||
},
|
||||
|
||||
_hasInPath: function(nodeIndex)
|
||||
{
|
||||
return this._targetNodeIndex === nodeIndex
|
||||
|| !!this._currentPath._cache[nodeIndex];
|
||||
},
|
||||
|
||||
_isPathFound: function()
|
||||
{
|
||||
return this._currentPath.length === this._maxLength
|
||||
&& this._lastEdge.nodeIndex in this._rootChildren;
|
||||
},
|
||||
|
||||
get _lastEdgeIter()
|
||||
{
|
||||
return this._currentPath[this._currentPath.length - 1];
|
||||
},
|
||||
|
||||
get _lastEdge()
|
||||
{
|
||||
return this._lastEdgeIter.edge;
|
||||
},
|
||||
|
||||
_skipEdge: function(edge)
|
||||
{
|
||||
return (this._skipHidden && (edge.isHidden || edge.node.isHidden))
|
||||
|| this._hasInPath(edge.nodeIndex);
|
||||
},
|
||||
|
||||
_nextEdgeIter: function()
|
||||
{
|
||||
var iter = this._lastEdgeIter;
|
||||
while (this._skipEdge(iter.edge) && iter.hasNext())
|
||||
iter.next();
|
||||
return iter;
|
||||
},
|
||||
|
||||
_buildNextPath: function()
|
||||
{
|
||||
if (this._currentPath !== null) {
|
||||
var iter = this._lastEdgeIter;
|
||||
while (true) {
|
||||
iter.next();
|
||||
if (iter.hasNext())
|
||||
return true;
|
||||
while (true) {
|
||||
if (this._currentPath.length > 1) {
|
||||
this._removeLastFromCurrentPath();
|
||||
iter = this._lastEdgeIter;
|
||||
iter.next();
|
||||
iter = this._nextEdgeIter();
|
||||
if (iter.hasNext()) {
|
||||
while (this._currentPath.length < this._maxLength) {
|
||||
iter = this._nextEdgeIter();
|
||||
if (iter.hasNext())
|
||||
this._appendToCurrentPath(iter.edge.node.retainers);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var node = new WebInspector.HeapSnapshotNode(this._snapshot, this._targetNodeIndex);
|
||||
this._currentPath = [node.retainers];
|
||||
this._currentPath._cache = {};
|
||||
while (this._currentPath.length < this._maxLength) {
|
||||
var iter = this._nextEdgeIter();
|
||||
if (iter.hasNext())
|
||||
this._appendToCurrentPath(iter.edge.node.retainers);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
_nodeToString: function(node)
|
||||
{
|
||||
if (node.id === 1)
|
||||
return node.name;
|
||||
else
|
||||
return node.name + "@" + node.id;
|
||||
},
|
||||
|
||||
_pathToString: function(path)
|
||||
{
|
||||
if (!path)
|
||||
return "";
|
||||
var sPath = [];
|
||||
for (var j = 0; j < path.length; ++j)
|
||||
sPath.push(path[j].edge.toString());
|
||||
sPath.push(this._nodeToString(path[path.length - 1].edge.node));
|
||||
sPath.reverse();
|
||||
return sPath.join("");
|
||||
}
|
||||
};
|
1032
node_modules/weinre/web/client/HeapSnapshotView.js
generated
vendored
Normal file
88
node_modules/weinre/web/client/HelpScreen.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Google 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:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
|
||||
* OWNER 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.HelpScreen = function(title)
|
||||
{
|
||||
this._element = document.createElement("div");
|
||||
this._element.className = "help-window-outer";
|
||||
this._element.addEventListener("keydown", this._onKeyDown.bind(this), false);
|
||||
|
||||
var mainWindow = this._element.createChild("div", "help-window-main");
|
||||
var captionWindow = mainWindow.createChild("div", "help-window-caption");
|
||||
var closeButton = captionWindow.createChild("button", "help-close-button");
|
||||
this.contentElement = mainWindow.createChild("div", "help-content");
|
||||
this.contentElement.tabIndex = 0;
|
||||
this.contentElement.addEventListener("blur", this._onBlur.bind(this), false);
|
||||
captionWindow.createChild("h1", "help-window-title").innerText = title;
|
||||
|
||||
closeButton.innerText = "\u2716"; // Code stands for HEAVY MULTIPLICATION X.
|
||||
closeButton.addEventListener("click", this._hide.bind(this), false);
|
||||
this._closeKeys = [
|
||||
WebInspector.KeyboardShortcut.Keys.Enter.code,
|
||||
WebInspector.KeyboardShortcut.Keys.Esc.code,
|
||||
WebInspector.KeyboardShortcut.Keys.Space.code,
|
||||
];
|
||||
document.body.appendChild(this._element);
|
||||
}
|
||||
|
||||
WebInspector.HelpScreen.prototype = {
|
||||
show: function()
|
||||
{
|
||||
if (this._isShown)
|
||||
return;
|
||||
|
||||
this._element.style.visibility = "visible";
|
||||
this._isShown = true;
|
||||
this._previousFocusElement = WebInspector.currentFocusElement;
|
||||
WebInspector.currentFocusElement = this.contentElement;
|
||||
},
|
||||
|
||||
_hide: function()
|
||||
{
|
||||
this._isShown = false;
|
||||
this._element.style.visibility = "hidden";
|
||||
WebInspector.currentFocusElement = this._previousFocusElement;
|
||||
},
|
||||
|
||||
_onKeyDown: function(event)
|
||||
{
|
||||
if (this._isShown && this._closeKeys.indexOf(event.keyCode) >= 0) {
|
||||
this._hide();
|
||||
event.stopPropagation();
|
||||
}
|
||||
},
|
||||
|
||||
_onBlur: function()
|
||||
{
|
||||
// Pretend we're modal, grab focus back if we're still shown.
|
||||
if (this._isShown)
|
||||
WebInspector.currentFocusElement = this.contentElement;
|
||||
}
|
||||
}
|
123
node_modules/weinre/web/client/ImageView.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2007, 2008 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.
|
||||
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.ImageView = function(resource)
|
||||
{
|
||||
WebInspector.ResourceView.call(this, resource);
|
||||
|
||||
this.element.addStyleClass("image");
|
||||
}
|
||||
|
||||
WebInspector.ImageView.prototype = {
|
||||
hasContent: function()
|
||||
{
|
||||
return true;
|
||||
},
|
||||
|
||||
show: function(parentElement)
|
||||
{
|
||||
WebInspector.ResourceView.prototype.show.call(this, parentElement);
|
||||
this._createContentIfNeeded();
|
||||
},
|
||||
|
||||
_createContentIfNeeded: function()
|
||||
{
|
||||
if (this._container)
|
||||
return;
|
||||
|
||||
var imageContainer = document.createElement("div");
|
||||
imageContainer.className = "image";
|
||||
this.element.appendChild(imageContainer);
|
||||
|
||||
var imagePreviewElement = document.createElement("img");
|
||||
imagePreviewElement.addStyleClass("resource-image-view");
|
||||
imageContainer.appendChild(imagePreviewElement);
|
||||
|
||||
this._container = document.createElement("div");
|
||||
this._container.className = "info";
|
||||
this.element.appendChild(this._container);
|
||||
|
||||
var imageNameElement = document.createElement("h1");
|
||||
imageNameElement.className = "title";
|
||||
imageNameElement.textContent = this.resource.displayName;
|
||||
this._container.appendChild(imageNameElement);
|
||||
|
||||
var infoListElement = document.createElement("dl");
|
||||
infoListElement.className = "infoList";
|
||||
|
||||
this.resource.populateImageSource(imagePreviewElement);
|
||||
|
||||
function onImageLoad()
|
||||
{
|
||||
var content = this.resource.content;
|
||||
if (content)
|
||||
var resourceSize = this._base64ToSize(content);
|
||||
else
|
||||
var resourceSize = this.resource.resourceSize;
|
||||
|
||||
var imageProperties = [
|
||||
{ name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.naturalHeight) },
|
||||
{ name: WebInspector.UIString("File size"), value: Number.bytesToString(resourceSize) },
|
||||
{ name: WebInspector.UIString("MIME type"), value: this.resource.mimeType }
|
||||
];
|
||||
|
||||
infoListElement.removeChildren();
|
||||
for (var i = 0; i < imageProperties.length; ++i) {
|
||||
var dt = document.createElement("dt");
|
||||
dt.textContent = imageProperties[i].name;
|
||||
infoListElement.appendChild(dt);
|
||||
var dd = document.createElement("dd");
|
||||
dd.textContent = imageProperties[i].value;
|
||||
infoListElement.appendChild(dd);
|
||||
}
|
||||
var dt = document.createElement("dt");
|
||||
dt.textContent = WebInspector.UIString("URL");
|
||||
infoListElement.appendChild(dt);
|
||||
var dd = document.createElement("dd");
|
||||
dd.appendChild(WebInspector.linkifyURLAsNode(this.resource.url));
|
||||
infoListElement.appendChild(dd);
|
||||
|
||||
this._container.appendChild(infoListElement);
|
||||
}
|
||||
imagePreviewElement.addEventListener("load", onImageLoad.bind(this), false);
|
||||
},
|
||||
|
||||
_base64ToSize: function(content)
|
||||
{
|
||||
if (!content.length)
|
||||
return 0;
|
||||
var size = (content.length || 0) * 3 / 4;
|
||||
if (content.length > 0 && content[content.length - 1] === "=")
|
||||
size--;
|
||||
if (content.length > 1 && content[content.length - 2] === "=")
|
||||
size--;
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
WebInspector.ImageView.prototype.__proto__ = WebInspector.ResourceView.prototype;
|
BIN
node_modules/weinre/web/client/Images/applicationCache.png
generated
vendored
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
node_modules/weinre/web/client/Images/auditsIcon.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
node_modules/weinre/web/client/Images/back.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
node_modules/weinre/web/client/Images/breakpointBorder.png
generated
vendored
Normal file
After Width: | Height: | Size: 377 B |
BIN
node_modules/weinre/web/client/Images/breakpointConditionalBorder.png
generated
vendored
Normal file
After Width: | Height: | Size: 379 B |
BIN
node_modules/weinre/web/client/Images/breakpointConditionalCounterBorder.png
generated
vendored
Normal file
After Width: | Height: | Size: 529 B |
BIN
node_modules/weinre/web/client/Images/breakpointCounterBorder.png
generated
vendored
Normal file
After Width: | Height: | Size: 526 B |
BIN
node_modules/weinre/web/client/Images/breakpointsActivateButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 250 B |
BIN
node_modules/weinre/web/client/Images/breakpointsDeactivateButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 426 B |
BIN
node_modules/weinre/web/client/Images/checker.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
node_modules/weinre/web/client/Images/clearConsoleButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 396 B |
BIN
node_modules/weinre/web/client/Images/closeButtons.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
node_modules/weinre/web/client/Images/consoleButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 183 B |
BIN
node_modules/weinre/web/client/Images/consoleIcon.png
generated
vendored
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
node_modules/weinre/web/client/Images/cookie.png
generated
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
node_modules/weinre/web/client/Images/database.png
generated
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
node_modules/weinre/web/client/Images/databaseTable.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
node_modules/weinre/web/client/Images/debuggerContinue.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
node_modules/weinre/web/client/Images/debuggerPause.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
node_modules/weinre/web/client/Images/debuggerStepInto.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
node_modules/weinre/web/client/Images/debuggerStepOut.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
node_modules/weinre/web/client/Images/debuggerStepOver.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallDown.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallDownBlack.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallDownWhite.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallRight.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallRightBlack.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallRightDown.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallRightDownBlack.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallRightDownWhite.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/disclosureTriangleSmallRightWhite.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/dockButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 164 B |
BIN
node_modules/weinre/web/client/Images/elementsIcon.png
generated
vendored
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
node_modules/weinre/web/client/Images/enableOutlineButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 363 B |
BIN
node_modules/weinre/web/client/Images/enableSolidButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 302 B |
BIN
node_modules/weinre/web/client/Images/errorIcon.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
node_modules/weinre/web/client/Images/errorMediumIcon.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
node_modules/weinre/web/client/Images/errorRedDot.png
generated
vendored
Normal file
After Width: | Height: | Size: 549 B |
BIN
node_modules/weinre/web/client/Images/excludeButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 212 B |
BIN
node_modules/weinre/web/client/Images/focusButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 285 B |
BIN
node_modules/weinre/web/client/Images/forward.png
generated
vendored
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
node_modules/weinre/web/client/Images/frame.png
generated
vendored
Normal file
After Width: | Height: | Size: 448 B |
BIN
node_modules/weinre/web/client/Images/gearButtonGlyph.png
generated
vendored
Normal file
After Width: | Height: | Size: 323 B |
BIN
node_modules/weinre/web/client/Images/glossyHeader.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
node_modules/weinre/web/client/Images/glossyHeaderPressed.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
node_modules/weinre/web/client/Images/glossyHeaderSelected.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/glossyHeaderSelectedPressed.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
node_modules/weinre/web/client/Images/goArrow.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
node_modules/weinre/web/client/Images/graphLabelCalloutLeft.png
generated
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |