You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pm...@apache.org on 2012/02/15 18:42:37 UTC
[19/51] [partial] Apache-ization, port to node.js
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Panel.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Panel.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Panel.js
new file mode 100644
index 0000000..4c42a60
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Panel.js
@@ -0,0 +1,438 @@
+/*
+ * 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.Panel = function(name)
+{
+ WebInspector.View.call(this);
+
+ this.element.addStyleClass("panel");
+ this.element.addStyleClass(name);
+ this._panelName = name;
+
+ WebInspector.settings.installApplicationSetting(this._sidebarWidthSettingName(), undefined);
+}
+
+// Should by in sync with style declarations.
+WebInspector.Panel.counterRightMargin = 25;
+
+WebInspector.Panel.prototype = {
+ get toolbarItem()
+ {
+ if (this._toolbarItem)
+ return this._toolbarItem;
+
+ // Sample toolbar item as markup:
+ // <button class="toolbar-item resources toggleable">
+ // <div class="toolbar-icon"></div>
+ // <div class="toolbar-label">Resources</div>
+ // </button>
+
+ this._toolbarItem = document.createElement("button");
+ this._toolbarItem.className = "toolbar-item toggleable";
+ this._toolbarItem.panel = this;
+
+ this._toolbarItem.addStyleClass(this._panelName);
+
+ var iconElement = document.createElement("div");
+ iconElement.className = "toolbar-icon";
+ this._toolbarItem.appendChild(iconElement);
+
+ if ("toolbarItemLabel" in this) {
+ var labelElement = document.createElement("div");
+ labelElement.className = "toolbar-label";
+ labelElement.textContent = this.toolbarItemLabel;
+ this._toolbarItem.appendChild(labelElement);
+ }
+
+ return this._toolbarItem;
+ },
+
+ get name()
+ {
+ return this._panelName;
+ },
+
+ show: function()
+ {
+ WebInspector.View.prototype.show.call(this);
+
+ var statusBarItems = this.statusBarItems;
+ if (statusBarItems) {
+ this._statusBarItemContainer = document.createElement("div");
+ for (var i = 0; i < statusBarItems.length; ++i)
+ this._statusBarItemContainer.appendChild(statusBarItems[i]);
+ document.getElementById("main-status-bar").appendChild(this._statusBarItemContainer);
+ }
+
+ if ("_toolbarItem" in this)
+ this._toolbarItem.addStyleClass("toggled-on");
+
+ WebInspector.currentFocusElement = this.defaultFocusedElement;
+
+ this.restoreSidebarWidth();
+ this._restoreScrollPositions();
+ },
+
+ hide: function()
+ {
+ this._storeScrollPositions();
+ WebInspector.View.prototype.hide.call(this);
+
+ if (this._statusBarItemContainer && this._statusBarItemContainer.parentNode)
+ this._statusBarItemContainer.parentNode.removeChild(this._statusBarItemContainer);
+ delete this._statusBarItemContainer;
+ if ("_toolbarItem" in this)
+ this._toolbarItem.removeStyleClass("toggled-on");
+ },
+
+ get defaultFocusedElement()
+ {
+ return this.sidebarTreeElement || this.element;
+ },
+
+ attach: function()
+ {
+ if (!this.element.parentNode)
+ document.getElementById("main-panels").appendChild(this.element);
+ },
+
+ searchCanceled: function()
+ {
+ if (this._searchResults) {
+ for (var i = 0; i < this._searchResults.length; ++i) {
+ var view = this._searchResults[i];
+ if (view.searchCanceled)
+ view.searchCanceled();
+ delete view.currentQuery;
+ }
+ }
+
+ WebInspector.updateSearchMatchesCount(0, this);
+
+ if (this._currentSearchChunkIntervalIdentifier) {
+ clearInterval(this._currentSearchChunkIntervalIdentifier);
+ delete this._currentSearchChunkIntervalIdentifier;
+ }
+
+ this._totalSearchMatches = 0;
+ this._currentSearchResultIndex = 0;
+ this._searchResults = [];
+ },
+
+ performSearch: function(query)
+ {
+ // Call searchCanceled since it will reset everything we need before doing a new search.
+ this.searchCanceled(true);
+
+ var searchableViews = this.searchableViews;
+ if (!searchableViews || !searchableViews.length)
+ return;
+
+ var parentElement = this.viewsContainerElement;
+ var visibleView = this.visibleView;
+ var sortFuction = this.searchResultsSortFunction;
+
+ var matchesCountUpdateTimeout = null;
+
+ function updateMatchesCount()
+ {
+ WebInspector.updateSearchMatchesCount(this._totalSearchMatches, this);
+ matchesCountUpdateTimeout = null;
+ }
+
+ function updateMatchesCountSoon()
+ {
+ if (matchesCountUpdateTimeout)
+ return;
+ // Update the matches count every half-second so it doesn't feel twitchy.
+ matchesCountUpdateTimeout = setTimeout(updateMatchesCount.bind(this), 500);
+ }
+
+ function finishedCallback(view, searchMatches)
+ {
+ if (!searchMatches)
+ return;
+
+ this._totalSearchMatches += searchMatches;
+ this._searchResults.push(view);
+
+ if (sortFuction)
+ this._searchResults.sort(sortFuction);
+
+ if (this.searchMatchFound)
+ this.searchMatchFound(view, searchMatches);
+
+ updateMatchesCountSoon.call(this);
+
+ if (view === visibleView)
+ view.jumpToFirstSearchResult();
+ }
+
+ var i = 0;
+ var panel = this;
+ var boundFinishedCallback = finishedCallback.bind(this);
+ var chunkIntervalIdentifier = null;
+
+ // Split up the work into chunks so we don't block the
+ // UI thread while processing.
+
+ function processChunk()
+ {
+ var view = searchableViews[i];
+
+ if (++i >= searchableViews.length) {
+ if (panel._currentSearchChunkIntervalIdentifier === chunkIntervalIdentifier)
+ delete panel._currentSearchChunkIntervalIdentifier;
+ clearInterval(chunkIntervalIdentifier);
+ }
+
+ if (!view)
+ return;
+
+ if (view.element.parentNode !== parentElement && view.element.parentNode && parentElement)
+ view.detach();
+
+ view.currentQuery = query;
+ view.performSearch(query, boundFinishedCallback);
+ }
+
+ processChunk();
+
+ chunkIntervalIdentifier = setInterval(processChunk, 25);
+ this._currentSearchChunkIntervalIdentifier = chunkIntervalIdentifier;
+ },
+
+ jumpToNextSearchResult: function()
+ {
+ if (!this.showView || !this._searchResults || !this._searchResults.length)
+ return;
+
+ var showFirstResult = false;
+
+ this._currentSearchResultIndex = this._searchResults.indexOf(this.visibleView);
+ if (this._currentSearchResultIndex === -1) {
+ this._currentSearchResultIndex = 0;
+ showFirstResult = true;
+ }
+
+ var currentView = this._searchResults[this._currentSearchResultIndex];
+
+ if (currentView.showingLastSearchResult()) {
+ if (++this._currentSearchResultIndex >= this._searchResults.length)
+ this._currentSearchResultIndex = 0;
+ currentView = this._searchResults[this._currentSearchResultIndex];
+ showFirstResult = true;
+ }
+
+ if (currentView !== this.visibleView) {
+ this.showView(currentView);
+ WebInspector.focusSearchField();
+ }
+
+ if (showFirstResult)
+ currentView.jumpToFirstSearchResult();
+ else
+ currentView.jumpToNextSearchResult();
+ },
+
+ jumpToPreviousSearchResult: function()
+ {
+ if (!this.showView || !this._searchResults || !this._searchResults.length)
+ return;
+
+ var showLastResult = false;
+
+ this._currentSearchResultIndex = this._searchResults.indexOf(this.visibleView);
+ if (this._currentSearchResultIndex === -1) {
+ this._currentSearchResultIndex = 0;
+ showLastResult = true;
+ }
+
+ var currentView = this._searchResults[this._currentSearchResultIndex];
+
+ if (currentView.showingFirstSearchResult()) {
+ if (--this._currentSearchResultIndex < 0)
+ this._currentSearchResultIndex = (this._searchResults.length - 1);
+ currentView = this._searchResults[this._currentSearchResultIndex];
+ showLastResult = true;
+ }
+
+ if (currentView !== this.visibleView) {
+ this.showView(currentView);
+ WebInspector.focusSearchField();
+ }
+
+ if (showLastResult)
+ currentView.jumpToLastSearchResult();
+ else
+ currentView.jumpToPreviousSearchResult();
+ },
+
+ createSidebar: function(parentElement, resizerParentElement)
+ {
+ if (this.sidebarElement)
+ return;
+
+ if (!parentElement)
+ parentElement = this.element;
+
+ if (!resizerParentElement)
+ resizerParentElement = parentElement;
+
+ this.sidebarElement = document.createElement("div");
+ this.sidebarElement.className = "sidebar";
+ parentElement.appendChild(this.sidebarElement);
+
+ this.sidebarResizeElement = document.createElement("div");
+ this.sidebarResizeElement.className = "sidebar-resizer-vertical";
+ this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false);
+ resizerParentElement.appendChild(this.sidebarResizeElement);
+
+ this.sidebarTreeElement = document.createElement("ol");
+ this.sidebarTreeElement.className = "sidebar-tree";
+ this.sidebarElement.appendChild(this.sidebarTreeElement);
+
+ this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
+ this.sidebarTree.panel = this;
+ },
+
+ _sidebarWidthSettingName: function()
+ {
+ return this._panelName + "SidebarWidth";
+ },
+
+ _startSidebarDragging: function(event)
+ {
+ WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize");
+ },
+
+ _sidebarDragging: function(event)
+ {
+ this.updateSidebarWidth(event.pageX);
+
+ event.preventDefault();
+ },
+
+ _endSidebarDragging: function(event)
+ {
+ WebInspector.elementDragEnd(event);
+ this.saveSidebarWidth();
+ },
+
+ updateSidebarWidth: function(width)
+ {
+ if (!this.sidebarElement)
+ return;
+
+ if (this.sidebarElement.offsetWidth <= 0) {
+ // The stylesheet hasn't loaded yet or the window is closed,
+ // so we can't calculate what is need. Return early.
+ return;
+ }
+
+ if (!("_currentSidebarWidth" in this))
+ this._currentSidebarWidth = this.sidebarElement.offsetWidth;
+
+ if (typeof width === "undefined")
+ width = this._currentSidebarWidth;
+
+ width = Number.constrain(width, Preferences.minSidebarWidth, window.innerWidth / 2);
+
+ this._currentSidebarWidth = width;
+ this.setSidebarWidth(width);
+
+ this.updateMainViewWidth(width);
+ },
+
+ setSidebarWidth: function(width)
+ {
+ this.sidebarElement.style.width = width + "px";
+ this.sidebarResizeElement.style.left = (width - 3) + "px";
+ },
+
+ restoreSidebarWidth: function()
+ {
+ var sidebarWidth = WebInspector.settings[this._sidebarWidthSettingName()];
+ this.updateSidebarWidth(sidebarWidth);
+ },
+
+ saveSidebarWidth: function()
+ {
+ if (!this.sidebarElement)
+ return;
+ WebInspector.settings[this._sidebarWidthSettingName()] = this.sidebarElement.offsetWidth;
+ },
+
+ updateMainViewWidth: function(width)
+ {
+ // Should be implemented by ancestors.
+ },
+
+ resize: function()
+ {
+ var visibleView = this.visibleView;
+ if (visibleView && "resize" in visibleView)
+ visibleView.resize();
+ },
+
+ canShowSourceLine: function(url, line)
+ {
+ return false;
+ },
+
+ showSourceLine: function(url, line)
+ {
+ return false;
+ },
+
+ elementsToRestoreScrollPositionsFor: function()
+ {
+ return [];
+ },
+
+ _storeScrollPositions: function()
+ {
+ var elements = this.elementsToRestoreScrollPositionsFor();
+ for (var i = 0; i < elements.length; ++i) {
+ var container = elements[i];
+ container._scrollTop = container.scrollTop;
+ }
+ },
+
+ _restoreScrollPositions: function()
+ {
+ var elements = this.elementsToRestoreScrollPositionsFor();
+ for (var i = 0; i < elements.length; ++i) {
+ var container = elements[i];
+ if (container._scrollTop)
+ container.scrollTop = container._scrollTop;
+ }
+ }
+}
+
+WebInspector.Panel.prototype.__proto__ = WebInspector.View.prototype;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/PanelEnablerView.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/PanelEnablerView.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/PanelEnablerView.js
new file mode 100644
index 0000000..5c26604
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/PanelEnablerView.js
@@ -0,0 +1,102 @@
+/*
+ * 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.PanelEnablerView = function(identifier, headingText, disclaimerText, buttonTitle)
+{
+ WebInspector.View.call(this);
+
+ this.element.addStyleClass("panel-enabler-view");
+ this.element.addStyleClass(identifier);
+
+ this.contentElement = document.createElement("div");
+ this.contentElement.className = "panel-enabler-view-content";
+ this.element.appendChild(this.contentElement);
+
+ this.imageElement = document.createElement("img");
+ this.contentElement.appendChild(this.imageElement);
+
+ this.choicesForm = document.createElement("form");
+ this.contentElement.appendChild(this.choicesForm);
+
+ this.headerElement = document.createElement("h1");
+ this.headerElement.textContent = headingText;
+ this.choicesForm.appendChild(this.headerElement);
+
+ var self = this;
+ function enableOption(text, checked) {
+ var label = document.createElement("label");
+ var option = document.createElement("input");
+ option.type = "radio";
+ option.name = "enable-option";
+ if (checked)
+ option.checked = true;
+ label.appendChild(option);
+ label.appendChild(document.createTextNode(text));
+ self.choicesForm.appendChild(label);
+ return option;
+ };
+
+ this.enabledForSession = enableOption(WebInspector.UIString("Only enable for this session"), true);
+ this.enabledAlways = enableOption(WebInspector.UIString("Always enable"));
+
+ this.disclaimerElement = document.createElement("div");
+ this.disclaimerElement.className = "panel-enabler-disclaimer";
+ this.disclaimerElement.textContent = disclaimerText;
+ this.choicesForm.appendChild(this.disclaimerElement);
+
+ this.enableButton = document.createElement("button");
+ this.enableButton.setAttribute("type", "button");
+ this.enableButton.textContent = buttonTitle;
+ this.enableButton.addEventListener("click", this._enableButtonCicked.bind(this), false);
+ this.choicesForm.appendChild(this.enableButton);
+}
+
+WebInspector.PanelEnablerView.prototype = {
+ _enableButtonCicked: function()
+ {
+ this.dispatchEventToListeners("enable clicked");
+ },
+
+ show: function(parentElement)
+ {
+ WebInspector.View.prototype.show.call(this, parentElement);
+
+ setTimeout(this.resize.bind(this), 0);
+ },
+
+ resize: function()
+ {
+ this.imageElement.removeStyleClass("hidden");
+
+ if (this.element.offsetWidth < (this.choicesForm.offsetWidth + this.imageElement.offsetWidth))
+ this.imageElement.addStyleClass("hidden");
+ },
+
+ get alwaysEnabled() {
+ return this.enabledAlways.checked;
+ }
+}
+
+WebInspector.PanelEnablerView.prototype.__proto__ = WebInspector.View.prototype;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Placard.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Placard.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Placard.js
new file mode 100644
index 0000000..9a415c4
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Placard.js
@@ -0,0 +1,106 @@
+/*
+ * 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.Placard = function(title, subtitle)
+{
+ this.element = document.createElement("div");
+ this.element.className = "placard";
+ this.element.placard = this;
+
+ this.titleElement = document.createElement("div");
+ this.titleElement.className = "title";
+
+ this.subtitleElement = document.createElement("div");
+ this.subtitleElement.className = "subtitle";
+
+ this.element.appendChild(this.subtitleElement);
+ this.element.appendChild(this.titleElement);
+
+ this.title = title;
+ this.subtitle = subtitle;
+ this.selected = false;
+}
+
+WebInspector.Placard.prototype = {
+ get title()
+ {
+ return this._title;
+ },
+
+ set title(x)
+ {
+ if (this._title === x)
+ return;
+ this._title = x;
+ this.titleElement.textContent = x;
+ },
+
+ get subtitle()
+ {
+ return this._subtitle;
+ },
+
+ set subtitle(x)
+ {
+ if (this._subtitle === x)
+ return;
+ this._subtitle = x;
+ this.subtitleElement.textContent = x;
+ },
+
+ get selected()
+ {
+ return this._selected;
+ },
+
+ set selected(x)
+ {
+ if (x)
+ this.select();
+ else
+ this.deselect();
+ },
+
+ select: function()
+ {
+ if (this._selected)
+ return;
+ this._selected = true;
+ this.element.addStyleClass("selected");
+ },
+
+ deselect: function()
+ {
+ if (!this._selected)
+ return;
+ this._selected = false;
+ this.element.removeStyleClass("selected");
+ },
+
+ toggleSelected: function()
+ {
+ this.selected = !this.selected;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/PleaseWaitMessage.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/PleaseWaitMessage.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/PleaseWaitMessage.js
new file mode 100644
index 0000000..54d805d
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/PleaseWaitMessage.js
@@ -0,0 +1,107 @@
+/*
+ * 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.PleaseWaitMessage = function()
+{
+ this.element = document.createElement("div");
+ this.element.className = "please-wait-msg";
+ this.element.textContent = WebInspector.UIString("Please wait\u2026");
+
+ this.cancelButton = document.createElement("button");
+ this.cancelButton.textContent = WebInspector.UIString("Cancel");
+ this.cancelButton.addEventListener("click", this._cancelClicked.bind(this), false);
+}
+
+WebInspector.PleaseWaitMessage.prototype = {
+ _cancelClicked: function()
+ {
+ if (this._cancelCallback) {
+ var cancelCallback = this._cancelCallback;
+ delete this._cancelCallback;
+ cancelCallback();
+ }
+ },
+
+ hide: function()
+ {
+ var instance = WebInspector.PleaseWaitMessage.prototype.instance;
+ var message = instance.element;
+ if (message.parentNode)
+ message.parentNode.removeChild(message);
+ },
+
+ get instance()
+ {
+ if (!"_instance" in WebInspector.PleaseWaitMessage.prototype)
+ WebInspector.PleaseWaitMessage.prototype._instance = new WebInspector.PleaseWaitMessage();
+ return WebInspector.PleaseWaitMessage.prototype._instance;
+ },
+
+ show: function(element, cancelCallback)
+ {
+ var instance = WebInspector.PleaseWaitMessage.prototype.instance;
+ var message = instance.element;
+ if (message.parentNode === element)
+ return;
+ else if (message.parentNode)
+ message.parentNode.removeChild(message);
+ if (message.childNodes.length > 1)
+ message.removeChild(instance.cancelButton);
+ if (cancelCallback) {
+ message.appendChild(instance.cancelButton);
+ instance._cancelCallback = cancelCallback;
+ }
+ element.appendChild(message);
+ },
+
+ startAction: function(element, actionCallback, cancelCallback)
+ {
+ var instance = WebInspector.PleaseWaitMessage.prototype.instance;
+ var message = instance.element;
+ if (message.parentNode === element) {
+ actionCallback();
+ return;
+ }
+
+ function doAction()
+ {
+ try {
+ actionCallback();
+ } finally {
+ if (message.parentNode)
+ message.parentNode.removeChild(message);
+ }
+ }
+
+ WebInspector.PleaseWaitMessage.prototype.show(element, cancelCallback);
+ setTimeout(doAction, 0);
+ }
+};
+
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Popover.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Popover.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Popover.js
new file mode 100644
index 0000000..32535e9
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Popover.js
@@ -0,0 +1,251 @@
+/*
+ * 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.Popover = function(contentElement)
+{
+ this.element = document.createElement("div");
+ this.element.className = "popover";
+
+ this._popupArrowElement = document.createElement("div");
+ this._popupArrowElement.className = "arrow";
+ this.element.appendChild(this._popupArrowElement);
+
+ this.contentElement = contentElement;
+ this._contentDiv = document.createElement("div");
+ this._contentDiv.className = "content";
+}
+
+WebInspector.Popover.prototype = {
+ show: function(anchor, preferredWidth, preferredHeight)
+ {
+ // This should not happen, but we hide previous popup to be on the safe side.
+ if (WebInspector.Popover._popoverElement)
+ document.body.removeChild(WebInspector.Popover._popoverElement);
+ WebInspector.Popover._popoverElement = this.element;
+
+ // Temporarily attach in order to measure preferred dimensions.
+ this.contentElement.positionAt(0, 0);
+ document.body.appendChild(this.contentElement);
+ var preferredWidth = preferredWidth || this.contentElement.offsetWidth;
+ var preferredHeight = preferredHeight || this.contentElement.offsetHeight;
+
+ this._contentDiv.appendChild(this.contentElement);
+ this.element.appendChild(this._contentDiv);
+ document.body.appendChild(this.element);
+ this._positionElement(anchor, preferredWidth, preferredHeight);
+ },
+
+ hide: function()
+ {
+ if (WebInspector.Popover._popoverElement) {
+ delete WebInspector.Popover._popoverElement;
+ document.body.removeChild(this.element);
+ }
+ },
+
+ _positionElement: function(anchorElement, preferredWidth, preferredHeight)
+ {
+ const borderWidth = 25;
+ const scrollerWidth = 11;
+ const arrowHeight = 15;
+ const arrowOffset = 10;
+ const borderRadius = 10;
+
+ // Skinny tooltips are not pretty, their arrow location is not nice.
+ preferredWidth = Math.max(preferredWidth, 50);
+ const totalWidth = window.innerWidth;
+ const totalHeight = window.innerHeight;
+
+ var anchorBox = {x: anchorElement.totalOffsetLeft, y: anchorElement.totalOffsetTop, width: anchorElement.offsetWidth, height: anchorElement.offsetHeight};
+ while (anchorElement !== document.body) {
+ if (anchorElement.scrollLeft)
+ anchorBox.x -= anchorElement.scrollLeft;
+ if (anchorElement.scrollTop)
+ anchorBox.y -= anchorElement.scrollTop;
+ anchorElement = anchorElement.parentElement;
+ }
+
+ var newElementPosition = { x: 0, y: 0, width: preferredWidth + scrollerWidth, height: preferredHeight };
+
+ var verticalAlignment;
+ var roomAbove = anchorBox.y;
+ var roomBelow = totalHeight - anchorBox.y - anchorBox.height;
+
+ if (roomAbove > roomBelow) {
+ // Positioning above the anchor.
+ if (anchorBox.y > newElementPosition.height + arrowHeight + borderRadius)
+ newElementPosition.y = anchorBox.y - newElementPosition.height - arrowHeight;
+ else {
+ newElementPosition.y = borderRadius * 2;
+ newElementPosition.height = anchorBox.y - borderRadius * 2 - arrowHeight;
+ }
+ verticalAlignment = "bottom";
+ } else {
+ // Positioning below the anchor.
+ newElementPosition.y = anchorBox.y + anchorBox.height + arrowHeight;
+ if (newElementPosition.y + newElementPosition.height + arrowHeight - borderWidth >= totalHeight)
+ newElementPosition.height = totalHeight - anchorBox.y - anchorBox.height - borderRadius * 2 - arrowHeight;
+ // Align arrow.
+ verticalAlignment = "top";
+ }
+
+ var horizontalAlignment;
+ if (anchorBox.x + newElementPosition.width < totalWidth) {
+ newElementPosition.x = Math.max(borderRadius, anchorBox.x - borderRadius - arrowOffset);
+ horizontalAlignment = "left";
+ } else if (newElementPosition.width + borderRadius * 2 < totalWidth) {
+ newElementPosition.x = totalWidth - newElementPosition.width - borderRadius;
+ horizontalAlignment = "right";
+ // Position arrow accurately.
+ var arrowRightPosition = Math.max(0, totalWidth - anchorBox.x - anchorBox.width - borderRadius - arrowOffset);
+ arrowRightPosition += anchorBox.width / 2;
+ this._popupArrowElement.style.right = arrowRightPosition + "px";
+ } else {
+ newElementPosition.x = borderRadius;
+ newElementPosition.width = totalWidth - borderRadius * 2;
+ newElementPosition.height += scrollerWidth;
+ horizontalAlignment = "left";
+ if (verticalAlignment === "bottom")
+ newElementPosition.y -= scrollerWidth;
+ // Position arrow accurately.
+ this._popupArrowElement.style.left = Math.max(0, anchorBox.x - borderRadius * 2 - arrowOffset) + "px";
+ this._popupArrowElement.style.left += anchorBox.width / 2;
+ }
+
+ this.element.className = "popover " + verticalAlignment + "-" + horizontalAlignment + "-arrow";
+ this.element.positionAt(newElementPosition.x - borderWidth, newElementPosition.y - borderWidth);
+ this.element.style.width = newElementPosition.width + borderWidth * 2 + "px";
+ this.element.style.height = newElementPosition.height + borderWidth * 2 + "px";
+ }
+}
+
+WebInspector.PopoverHelper = function(panelElement, getAnchor, showPopup, showOnClick, onHide)
+{
+ this._panelElement = panelElement;
+ this._getAnchor = getAnchor;
+ this._showPopup = showPopup;
+ this._showOnClick = showOnClick;
+ this._onHide = onHide;
+ panelElement.addEventListener("mousedown", this._mouseDown.bind(this), false);
+ panelElement.addEventListener("mousemove", this._mouseMove.bind(this), false);
+ this.setTimeout(1000);
+}
+
+WebInspector.PopoverHelper.prototype = {
+ setTimeout: function(timeout)
+ {
+ this._timeout = timeout;
+ },
+
+ _mouseDown: function(event)
+ {
+ this._killHidePopupTimer();
+ this._handleMouseAction(event, true);
+ },
+
+ _mouseMove: function(event)
+ {
+ // Pretend that nothing has happened.
+ if (this._hoverElement === event.target || (this._hoverElement && this._hoverElement.isAncestor(event.target)))
+ return;
+
+ // User has 500ms (this._timeout / 2) to reach the popup.
+ if (this._popup && !this._hidePopupTimer) {
+ var self = this;
+ function doHide()
+ {
+ self._hidePopup();
+ delete self._hidePopupTimer;
+ }
+ this._hidePopupTimer = setTimeout(doHide, this._timeout / 2);
+ }
+
+ this._handleMouseAction(event);
+ },
+
+ _handleMouseAction: function(event, isMouseDown)
+ {
+ this._resetHoverTimer();
+
+ this._hoverElement = this._getAnchor(event.target);
+ if (!this._hoverElement)
+ return;
+
+ const toolTipDelay = isMouseDown ? 0 : (this._popup ? this._timeout * 0.6 : this._timeout);
+ this._hoverTimer = setTimeout(this._mouseHover.bind(this, this._hoverElement), toolTipDelay);
+ },
+
+ _resetHoverTimer: function()
+ {
+ if (this._hoverTimer) {
+ clearTimeout(this._hoverTimer);
+ delete this._hoverTimer;
+ }
+ },
+
+ hidePopup: function()
+ {
+ this._resetHoverTimer();
+ this._hidePopup();
+ },
+
+ _hidePopup: function()
+ {
+ if (!this._popup)
+ return;
+
+ if (this._onHide)
+ this._onHide();
+
+ this._popup.hide();
+ delete this._popup;
+ },
+
+ _mouseHover: function(element)
+ {
+ delete this._hoverTimer;
+
+ this._popup = this._showPopup(element);
+ if (this._popup)
+ this._popup.contentElement.addEventListener("mousemove", this._killHidePopupTimer.bind(this), true);
+ },
+
+ _killHidePopupTimer: function()
+ {
+ if (this._hidePopupTimer) {
+ clearTimeout(this._hidePopupTimer);
+ delete this._hidePopupTimer;
+
+ // We know that we reached the popup, but we might have moved over other elements.
+ // Discard pending command.
+ this._resetHoverTimer();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js
new file mode 100644
index 0000000..7988674
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js
@@ -0,0 +1,399 @@
+/*
+ * 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.
+ */
+
+WebInspector.ProfileDataGridNode = function(profileView, profileNode, owningTree, hasChildren)
+{
+ this.profileView = profileView;
+ this.profileNode = profileNode;
+
+ WebInspector.DataGridNode.call(this, null, hasChildren);
+
+ this.addEventListener("populate", this._populate, this);
+
+ this.tree = owningTree;
+
+ this.childrenByCallUID = {};
+ this.lastComparator = null;
+
+ this.callUID = profileNode.callUID;
+ this.selfTime = profileNode.selfTime;
+ this.totalTime = profileNode.totalTime;
+ this.functionName = profileNode.functionName;
+ this.numberOfCalls = profileNode.numberOfCalls;
+ this.url = profileNode.url;
+}
+
+WebInspector.ProfileDataGridNode.prototype = {
+ get data()
+ {
+ function formatMilliseconds(time)
+ {
+ return Number.secondsToString(time / 1000, !Preferences.samplingCPUProfiler);
+ }
+
+ var data = {};
+
+ data["function"] = this.functionName;
+ data["calls"] = this.numberOfCalls;
+
+ if (this.profileView.showSelfTimeAsPercent)
+ data["self"] = WebInspector.UIString("%.2f%%", this.selfPercent);
+ else
+ data["self"] = formatMilliseconds(this.selfTime);
+
+ if (this.profileView.showTotalTimeAsPercent)
+ data["total"] = WebInspector.UIString("%.2f%%", this.totalPercent);
+ else
+ data["total"] = formatMilliseconds(this.totalTime);
+
+ if (this.profileView.showAverageTimeAsPercent)
+ data["average"] = WebInspector.UIString("%.2f%%", this.averagePercent);
+ else
+ data["average"] = formatMilliseconds(this.averageTime);
+
+ return data;
+ },
+
+ createCell: function(columnIdentifier)
+ {
+ var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
+
+ if (columnIdentifier === "self" && this._searchMatchedSelfColumn)
+ cell.addStyleClass("highlight");
+ else if (columnIdentifier === "total" && this._searchMatchedTotalColumn)
+ cell.addStyleClass("highlight");
+ else if (columnIdentifier === "average" && this._searchMatchedAverageColumn)
+ cell.addStyleClass("highlight");
+ else if (columnIdentifier === "calls" && this._searchMatchedCallsColumn)
+ cell.addStyleClass("highlight");
+
+ if (columnIdentifier !== "function")
+ return cell;
+
+ if (this.profileNode._searchMatchedFunctionColumn)
+ cell.addStyleClass("highlight");
+
+ if (this.profileNode.url) {
+ var lineNumber;
+ if (this.profileNode.lineNumber > 0)
+ lineNumber = this.profileNode.lineNumber;
+ var urlElement = WebInspector.linkifyResourceAsNode(this.profileNode.url, "scripts", lineNumber, "profile-node-file");
+ cell.insertBefore(urlElement, cell.firstChild);
+ }
+
+ return cell;
+ },
+
+ select: function(supressSelectedEvent)
+ {
+ WebInspector.DataGridNode.prototype.select.call(this, supressSelectedEvent);
+ this.profileView._dataGridNodeSelected(this);
+ },
+
+ deselect: function(supressDeselectedEvent)
+ {
+ WebInspector.DataGridNode.prototype.deselect.call(this, supressDeselectedEvent);
+ this.profileView._dataGridNodeDeselected(this);
+ },
+
+ sort: function(/*Function*/ comparator, /*Boolean*/ force)
+ {
+ var gridNodeGroups = [[this]];
+
+ for (var gridNodeGroupIndex = 0; gridNodeGroupIndex < gridNodeGroups.length; ++gridNodeGroupIndex) {
+ var gridNodes = gridNodeGroups[gridNodeGroupIndex];
+ var count = gridNodes.length;
+
+ for (var index = 0; index < count; ++index) {
+ var gridNode = gridNodes[index];
+
+ // If the grid node is collapsed, then don't sort children (save operation for later).
+ // If the grid node has the same sorting as previously, then there is no point in sorting it again.
+ if (!force && (!gridNode.expanded || gridNode.lastComparator === comparator)) {
+ if (gridNode.children.length)
+ gridNode.shouldRefreshChildren = true;
+ continue;
+ }
+
+ gridNode.lastComparator = comparator;
+
+ var children = gridNode.children;
+ var childCount = children.length;
+
+ if (childCount) {
+ children.sort(comparator);
+
+ for (var childIndex = 0; childIndex < childCount; ++childIndex)
+ children[childIndex]._recalculateSiblings(childIndex);
+
+ gridNodeGroups.push(children);
+ }
+ }
+ }
+ },
+
+ insertChild: function(/*ProfileDataGridNode*/ profileDataGridNode, index)
+ {
+ WebInspector.DataGridNode.prototype.insertChild.call(this, profileDataGridNode, index);
+
+ this.childrenByCallUID[profileDataGridNode.callUID] = profileDataGridNode;
+ },
+
+ removeChild: function(/*ProfileDataGridNode*/ profileDataGridNode)
+ {
+ WebInspector.DataGridNode.prototype.removeChild.call(this, profileDataGridNode);
+
+ delete this.childrenByCallUID[profileDataGridNode.callUID];
+ },
+
+ removeChildren: function(/*ProfileDataGridNode*/ profileDataGridNode)
+ {
+ WebInspector.DataGridNode.prototype.removeChildren.call(this);
+
+ this.childrenByCallUID = {};
+ },
+
+ findChild: function(/*Node*/ node)
+ {
+ if (!node)
+ return null;
+ return this.childrenByCallUID[node.callUID];
+ },
+
+ get averageTime()
+ {
+ return this.selfTime / Math.max(1, this.numberOfCalls);
+ },
+
+ get averagePercent()
+ {
+ return this.averageTime / this.tree.totalTime * 100.0;
+ },
+
+ get selfPercent()
+ {
+ return this.selfTime / this.tree.totalTime * 100.0;
+ },
+
+ get totalPercent()
+ {
+ return this.totalTime / this.tree.totalTime * 100.0;
+ },
+
+ get _parent()
+ {
+ return this.parent !== this.dataGrid ? this.parent : this.tree;
+ },
+
+ _populate: function(event)
+ {
+ this._sharedPopulate();
+
+ if (this._parent) {
+ var currentComparator = this._parent.lastComparator;
+
+ if (currentComparator)
+ this.sort(currentComparator, true);
+ }
+
+ if (this.removeEventListener)
+ this.removeEventListener("populate", this._populate, this);
+ },
+
+ // When focusing and collapsing we modify lots of nodes in the tree.
+ // This allows us to restore them all to their original state when we revert.
+ _save: function()
+ {
+ if (this._savedChildren)
+ return;
+
+ this._savedSelfTime = this.selfTime;
+ this._savedTotalTime = this.totalTime;
+ this._savedNumberOfCalls = this.numberOfCalls;
+
+ this._savedChildren = this.children.slice();
+ },
+
+ // When focusing and collapsing we modify lots of nodes in the tree.
+ // This allows us to restore them all to their original state when we revert.
+ _restore: function()
+ {
+ if (!this._savedChildren)
+ return;
+
+ this.selfTime = this._savedSelfTime;
+ this.totalTime = this._savedTotalTime;
+ this.numberOfCalls = this._savedNumberOfCalls;
+
+ this.removeChildren();
+
+ var children = this._savedChildren;
+ var count = children.length;
+
+ for (var index = 0; index < count; ++index) {
+ children[index]._restore();
+ this.appendChild(children[index]);
+ }
+ },
+
+ _merge: function(child, shouldAbsorb)
+ {
+ this.selfTime += child.selfTime;
+
+ if (!shouldAbsorb) {
+ this.totalTime += child.totalTime;
+ this.numberOfCalls += child.numberOfCalls;
+ }
+
+ var children = this.children.slice();
+
+ this.removeChildren();
+
+ var count = children.length;
+
+ for (var index = 0; index < count; ++index) {
+ if (!shouldAbsorb || children[index] !== child)
+ this.appendChild(children[index]);
+ }
+
+ children = child.children.slice();
+ count = children.length;
+
+ for (var index = 0; index < count; ++index) {
+ var orphanedChild = children[index],
+ existingChild = this.childrenByCallUID[orphanedChild.callUID];
+
+ if (existingChild)
+ existingChild._merge(orphanedChild, false);
+ else
+ this.appendChild(orphanedChild);
+ }
+ }
+}
+
+WebInspector.ProfileDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype;
+
+WebInspector.ProfileDataGridTree = function(profileView, profileNode)
+{
+ this.tree = this;
+ this.children = [];
+
+ this.profileView = profileView;
+
+ this.totalTime = profileNode.totalTime;
+ this.lastComparator = null;
+
+ this.childrenByCallUID = {};
+}
+
+WebInspector.ProfileDataGridTree.prototype = {
+ get expanded()
+ {
+ return true;
+ },
+
+ appendChild: function(child)
+ {
+ this.insertChild(child, this.children.length);
+ },
+
+ insertChild: function(child, index)
+ {
+ this.children.splice(index, 0, child);
+ this.childrenByCallUID[child.callUID] = child;
+ },
+
+ removeChildren: function()
+ {
+ this.children = [];
+ this.childrenByCallUID = {};
+ },
+
+ findChild: WebInspector.ProfileDataGridNode.prototype.findChild,
+ sort: WebInspector.ProfileDataGridNode.prototype.sort,
+
+ _save: function()
+ {
+ if (this._savedChildren)
+ return;
+
+ this._savedTotalTime = this.totalTime;
+ this._savedChildren = this.children.slice();
+ },
+
+ restore: function()
+ {
+ if (!this._savedChildren)
+ return;
+
+ this.children = this._savedChildren;
+ this.totalTime = this._savedTotalTime;
+
+ var children = this.children;
+ var count = children.length;
+
+ for (var index = 0; index < count; ++index)
+ children[index]._restore();
+
+ this._savedChildren = null;
+ }
+}
+
+WebInspector.ProfileDataGridTree.propertyComparators = [{}, {}];
+
+WebInspector.ProfileDataGridTree.propertyComparator = function(/*String*/ property, /*Boolean*/ isAscending)
+{
+ var comparator = this.propertyComparators[(isAscending ? 1 : 0)][property];
+
+ if (!comparator) {
+ if (isAscending) {
+ comparator = function(lhs, rhs)
+ {
+ if (lhs[property] < rhs[property])
+ return -1;
+
+ if (lhs[property] > rhs[property])
+ return 1;
+
+ return 0;
+ }
+ } else {
+ comparator = function(lhs, rhs)
+ {
+ if (lhs[property] > rhs[property])
+ return -1;
+
+ if (lhs[property] < rhs[property])
+ return 1;
+
+ return 0;
+ }
+ }
+
+ this.propertyComparators[(isAscending ? 1 : 0)][property] = comparator;
+ }
+
+ return comparator;
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileView.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileView.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileView.js
new file mode 100644
index 0000000..c325bf7
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/ProfileView.js
@@ -0,0 +1,622 @@
+/*
+ * 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.
+ */
+
+// FIXME: Rename the file.
+
+WebInspector.CPUProfileView = function(profile)
+{
+ WebInspector.View.call(this);
+
+ this.element.addStyleClass("profile-view");
+
+ this.showSelfTimeAsPercent = true;
+ this.showTotalTimeAsPercent = true;
+ this.showAverageTimeAsPercent = true;
+
+ var columns = { "self": { title: WebInspector.UIString("Self"), width: "72px", sort: "descending", sortable: true },
+ "total": { title: WebInspector.UIString("Total"), width: "72px", sortable: true },
+ "average": { title: WebInspector.UIString("Average"), width: "72px", sortable: true },
+ "calls": { title: WebInspector.UIString("Calls"), width: "54px", sortable: true },
+ "function": { title: WebInspector.UIString("Function"), disclosure: true, sortable: true } };
+
+ if (Preferences.samplingCPUProfiler) {
+ delete columns.average;
+ delete columns.calls;
+ }
+
+ this.dataGrid = new WebInspector.DataGrid(columns);
+ this.dataGrid.addEventListener("sorting changed", this._sortData, this);
+ this.dataGrid.element.addEventListener("mousedown", this._mouseDownInDataGrid.bind(this), true);
+ this.element.appendChild(this.dataGrid.element);
+
+ this.viewSelectElement = document.createElement("select");
+ this.viewSelectElement.className = "status-bar-item";
+ this.viewSelectElement.addEventListener("change", this._changeView.bind(this), false);
+ this.view = "Heavy";
+
+ var heavyViewOption = document.createElement("option");
+ heavyViewOption.label = WebInspector.UIString("Heavy (Bottom Up)");
+ var treeViewOption = document.createElement("option");
+ treeViewOption.label = WebInspector.UIString("Tree (Top Down)");
+ this.viewSelectElement.appendChild(heavyViewOption);
+ this.viewSelectElement.appendChild(treeViewOption);
+
+ this.percentButton = new WebInspector.StatusBarButton("", "percent-time-status-bar-item");
+ this.percentButton.addEventListener("click", this._percentClicked.bind(this), false);
+
+ this.focusButton = new WebInspector.StatusBarButton(WebInspector.UIString("Focus selected function."), "focus-profile-node-status-bar-item");
+ this.focusButton.disabled = true;
+ this.focusButton.addEventListener("click", this._focusClicked.bind(this), false);
+
+ this.excludeButton = new WebInspector.StatusBarButton(WebInspector.UIString("Exclude selected function."), "exclude-profile-node-status-bar-item");
+ this.excludeButton.disabled = true;
+ this.excludeButton.addEventListener("click", this._excludeClicked.bind(this), false);
+
+ this.resetButton = new WebInspector.StatusBarButton(WebInspector.UIString("Restore all functions."), "reset-profile-status-bar-item");
+ this.resetButton.visible = false;
+ this.resetButton.addEventListener("click", this._resetClicked.bind(this), false);
+
+ this.profile = profile;
+
+ var self = this;
+ function profileCallback(profile)
+ {
+ self.profile.head = profile.head;
+ self._assignParentsInProfile();
+
+ self.profileDataGridTree = self.bottomUpProfileDataGridTree;
+ self.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyComparator("selfTime", false));
+
+ self.refresh();
+
+ self._updatePercentButton();
+ }
+
+ InspectorBackend.getProfile(this.profile.typeId, this.profile.uid, profileCallback);
+}
+
+WebInspector.CPUProfileView.prototype = {
+ get statusBarItems()
+ {
+ return [this.viewSelectElement, this.percentButton.element, this.focusButton.element, this.excludeButton.element, this.resetButton.element];
+ },
+
+ get profile()
+ {
+ return this._profile;
+ },
+
+ set profile(profile)
+ {
+ this._profile = profile;
+ },
+
+ get bottomUpProfileDataGridTree()
+ {
+ if (!this._bottomUpProfileDataGridTree)
+ this._bottomUpProfileDataGridTree = new WebInspector.BottomUpProfileDataGridTree(this, this.profile.head);
+ return this._bottomUpProfileDataGridTree;
+ },
+
+ get topDownProfileDataGridTree()
+ {
+ if (!this._topDownProfileDataGridTree)
+ this._topDownProfileDataGridTree = new WebInspector.TopDownProfileDataGridTree(this, this.profile.head);
+ return this._topDownProfileDataGridTree;
+ },
+
+ get currentTree()
+ {
+ return this._currentTree;
+ },
+
+ set currentTree(tree)
+ {
+ this._currentTree = tree;
+ this.refresh();
+ },
+
+ get topDownTree()
+ {
+ if (!this._topDownTree) {
+ this._topDownTree = WebInspector.TopDownTreeFactory.create(this.profile.head);
+ this._sortProfile(this._topDownTree);
+ }
+
+ return this._topDownTree;
+ },
+
+ get bottomUpTree()
+ {
+ if (!this._bottomUpTree) {
+ this._bottomUpTree = WebInspector.BottomUpTreeFactory.create(this.profile.head);
+ this._sortProfile(this._bottomUpTree);
+ }
+
+ return this._bottomUpTree;
+ },
+
+ show: function(parentElement)
+ {
+ WebInspector.View.prototype.show.call(this, parentElement);
+ this.dataGrid.updateWidths();
+ },
+
+ hide: function()
+ {
+ WebInspector.View.prototype.hide.call(this);
+ this._currentSearchResultIndex = -1;
+ },
+
+ resize: function()
+ {
+ if (this.dataGrid)
+ this.dataGrid.updateWidths();
+ },
+
+ refresh: function()
+ {
+ var selectedProfileNode = this.dataGrid.selectedNode ? this.dataGrid.selectedNode.profileNode : null;
+
+ this.dataGrid.removeChildren();
+
+ var children = this.profileDataGridTree.children;
+ var count = children.length;
+
+ for (var index = 0; index < count; ++index)
+ this.dataGrid.appendChild(children[index]);
+
+ if (selectedProfileNode)
+ selectedProfileNode.selected = true;
+ },
+
+ refreshVisibleData: function()
+ {
+ var child = this.dataGrid.children[0];
+ while (child) {
+ child.refresh();
+ child = child.traverseNextNode(false, null, true);
+ }
+ },
+
+ refreshShowAsPercents: function()
+ {
+ this._updatePercentButton();
+ this.refreshVisibleData();
+ },
+
+ searchCanceled: function()
+ {
+ if (this._searchResults) {
+ for (var i = 0; i < this._searchResults.length; ++i) {
+ var profileNode = this._searchResults[i].profileNode;
+
+ delete profileNode._searchMatchedSelfColumn;
+ delete profileNode._searchMatchedTotalColumn;
+ delete profileNode._searchMatchedCallsColumn;
+ delete profileNode._searchMatchedFunctionColumn;
+
+ profileNode.refresh();
+ }
+ }
+
+ delete this._searchFinishedCallback;
+ this._currentSearchResultIndex = -1;
+ this._searchResults = [];
+ },
+
+ performSearch: function(query, finishedCallback)
+ {
+ // Call searchCanceled since it will reset everything we need before doing a new search.
+ this.searchCanceled();
+
+ query = query.trim();
+
+ if (!query.length)
+ return;
+
+ this._searchFinishedCallback = finishedCallback;
+
+ var greaterThan = (query.indexOf(">") === 0);
+ var lessThan = (query.indexOf("<") === 0);
+ var equalTo = (query.indexOf("=") === 0 || ((greaterThan || lessThan) && query.indexOf("=") === 1));
+ var percentUnits = (query.lastIndexOf("%") === (query.length - 1));
+ var millisecondsUnits = (query.length > 2 && query.lastIndexOf("ms") === (query.length - 2));
+ var secondsUnits = (!millisecondsUnits && query.lastIndexOf("s") === (query.length - 1));
+
+ var queryNumber = parseFloat(query);
+ if (greaterThan || lessThan || equalTo) {
+ if (equalTo && (greaterThan || lessThan))
+ queryNumber = parseFloat(query.substring(2));
+ else
+ queryNumber = parseFloat(query.substring(1));
+ }
+
+ var queryNumberMilliseconds = (secondsUnits ? (queryNumber * 1000) : queryNumber);
+
+ // Make equalTo implicitly true if it wasn't specified there is no other operator.
+ if (!isNaN(queryNumber) && !(greaterThan || lessThan))
+ equalTo = true;
+
+ function matchesQuery(/*ProfileDataGridNode*/ profileDataGridNode)
+ {
+ delete profileDataGridNode._searchMatchedSelfColumn;
+ delete profileDataGridNode._searchMatchedTotalColumn;
+ delete profileDataGridNode._searchMatchedAverageColumn;
+ delete profileDataGridNode._searchMatchedCallsColumn;
+ delete profileDataGridNode._searchMatchedFunctionColumn;
+
+ if (percentUnits) {
+ if (lessThan) {
+ if (profileDataGridNode.selfPercent < queryNumber)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalPercent < queryNumber)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ if (profileDataGridNode.averagePercent < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedAverageColumn = true;
+ } else if (greaterThan) {
+ if (profileDataGridNode.selfPercent > queryNumber)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalPercent > queryNumber)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ if (profileDataGridNode.averagePercent < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedAverageColumn = true;
+ }
+
+ if (equalTo) {
+ if (profileDataGridNode.selfPercent == queryNumber)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalPercent == queryNumber)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ if (profileDataGridNode.averagePercent < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedAverageColumn = true;
+ }
+ } else if (millisecondsUnits || secondsUnits) {
+ if (lessThan) {
+ if (profileDataGridNode.selfTime < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalTime < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ if (profileDataGridNode.averageTime < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedAverageColumn = true;
+ } else if (greaterThan) {
+ if (profileDataGridNode.selfTime > queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalTime > queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ if (profileDataGridNode.averageTime > queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedAverageColumn = true;
+ }
+
+ if (equalTo) {
+ if (profileDataGridNode.selfTime == queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalTime == queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ if (profileDataGridNode.averageTime == queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedAverageColumn = true;
+ }
+ } else {
+ if (equalTo && profileDataGridNode.numberOfCalls == queryNumber)
+ profileDataGridNode._searchMatchedCallsColumn = true;
+ if (greaterThan && profileDataGridNode.numberOfCalls > queryNumber)
+ profileDataGridNode._searchMatchedCallsColumn = true;
+ if (lessThan && profileDataGridNode.numberOfCalls < queryNumber)
+ profileDataGridNode._searchMatchedCallsColumn = true;
+ }
+
+ if (profileDataGridNode.functionName.hasSubstring(query, true) || profileDataGridNode.url.hasSubstring(query, true))
+ profileDataGridNode._searchMatchedFunctionColumn = true;
+
+ if (profileDataGridNode._searchMatchedSelfColumn ||
+ profileDataGridNode._searchMatchedTotalColumn ||
+ profileDataGridNode._searchMatchedAverageColumn ||
+ profileDataGridNode._searchMatchedCallsColumn ||
+ profileDataGridNode._searchMatchedFunctionColumn)
+ {
+ profileDataGridNode.refresh();
+ return true;
+ }
+
+ return false;
+ }
+
+ var current = this.profileDataGridTree.children[0];
+
+ while (current) {
+ if (matchesQuery(current)) {
+ this._searchResults.push({ profileNode: current });
+ }
+
+ current = current.traverseNextNode(false, null, false);
+ }
+
+ finishedCallback(this, this._searchResults.length);
+ },
+
+ jumpToFirstSearchResult: function()
+ {
+ if (!this._searchResults || !this._searchResults.length)
+ return;
+ this._currentSearchResultIndex = 0;
+ this._jumpToSearchResult(this._currentSearchResultIndex);
+ },
+
+ jumpToLastSearchResult: function()
+ {
+ if (!this._searchResults || !this._searchResults.length)
+ return;
+ this._currentSearchResultIndex = (this._searchResults.length - 1);
+ this._jumpToSearchResult(this._currentSearchResultIndex);
+ },
+
+ jumpToNextSearchResult: function()
+ {
+ if (!this._searchResults || !this._searchResults.length)
+ return;
+ if (++this._currentSearchResultIndex >= this._searchResults.length)
+ this._currentSearchResultIndex = 0;
+ this._jumpToSearchResult(this._currentSearchResultIndex);
+ },
+
+ jumpToPreviousSearchResult: function()
+ {
+ if (!this._searchResults || !this._searchResults.length)
+ return;
+ if (--this._currentSearchResultIndex < 0)
+ this._currentSearchResultIndex = (this._searchResults.length - 1);
+ this._jumpToSearchResult(this._currentSearchResultIndex);
+ },
+
+ showingFirstSearchResult: function()
+ {
+ return (this._currentSearchResultIndex === 0);
+ },
+
+ showingLastSearchResult: function()
+ {
+ return (this._searchResults && this._currentSearchResultIndex === (this._searchResults.length - 1));
+ },
+
+ _jumpToSearchResult: function(index)
+ {
+ var searchResult = this._searchResults[index];
+ if (!searchResult)
+ return;
+
+ var profileNode = searchResult.profileNode;
+ profileNode.reveal();
+ profileNode.select();
+ },
+
+ _changeView: function(event)
+ {
+ if (!event || !this.profile)
+ return;
+
+ if (event.target.selectedIndex == 1 && this.view == "Heavy") {
+ this.profileDataGridTree = this.topDownProfileDataGridTree;
+ this._sortProfile();
+ this.view = "Tree";
+ } else if (event.target.selectedIndex == 0 && this.view == "Tree") {
+ this.profileDataGridTree = this.bottomUpProfileDataGridTree;
+ this._sortProfile();
+ this.view = "Heavy";
+ }
+
+ if (!this.currentQuery || !this._searchFinishedCallback || !this._searchResults)
+ return;
+
+ // The current search needs to be performed again. First negate out previous match
+ // count by calling the search finished callback with a negative number of matches.
+ // Then perform the search again the with same query and callback.
+ this._searchFinishedCallback(this, -this._searchResults.length);
+ this.performSearch(this.currentQuery, this._searchFinishedCallback);
+ },
+
+ _percentClicked: function(event)
+ {
+ var currentState = this.showSelfTimeAsPercent && this.showTotalTimeAsPercent && this.showAverageTimeAsPercent;
+ this.showSelfTimeAsPercent = !currentState;
+ this.showTotalTimeAsPercent = !currentState;
+ this.showAverageTimeAsPercent = !currentState;
+ this.refreshShowAsPercents();
+ },
+
+ _updatePercentButton: function()
+ {
+ if (this.showSelfTimeAsPercent && this.showTotalTimeAsPercent && this.showAverageTimeAsPercent) {
+ this.percentButton.title = WebInspector.UIString("Show absolute total and self times.");
+ this.percentButton.toggled = true;
+ } else {
+ this.percentButton.title = WebInspector.UIString("Show total and self times as percentages.");
+ this.percentButton.toggled = false;
+ }
+ },
+
+ _focusClicked: function(event)
+ {
+ if (!this.dataGrid.selectedNode)
+ return;
+
+ this.resetButton.visible = true;
+ this.profileDataGridTree.focus(this.dataGrid.selectedNode);
+ this.refresh();
+ this.refreshVisibleData();
+ },
+
+ _excludeClicked: function(event)
+ {
+ var selectedNode = this.dataGrid.selectedNode
+
+ if (!selectedNode)
+ return;
+
+ selectedNode.deselect();
+
+ this.resetButton.visible = true;
+ this.profileDataGridTree.exclude(selectedNode);
+ this.refresh();
+ this.refreshVisibleData();
+ },
+
+ _resetClicked: function(event)
+ {
+ this.resetButton.visible = false;
+ this.profileDataGridTree.restore();
+ this.refresh();
+ this.refreshVisibleData();
+ },
+
+ _dataGridNodeSelected: function(node)
+ {
+ this.focusButton.disabled = false;
+ this.excludeButton.disabled = false;
+ },
+
+ _dataGridNodeDeselected: function(node)
+ {
+ this.focusButton.disabled = true;
+ this.excludeButton.disabled = true;
+ },
+
+ _sortData: function(event)
+ {
+ this._sortProfile(this.profile);
+ },
+
+ _sortProfile: function()
+ {
+ var sortAscending = this.dataGrid.sortOrder === "ascending";
+ var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
+ var sortProperty = {
+ "average": "averageTime",
+ "self": "selfTime",
+ "total": "totalTime",
+ "calls": "numberOfCalls",
+ "function": "functionName"
+ }[sortColumnIdentifier];
+
+ this.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyComparator(sortProperty, sortAscending));
+
+ this.refresh();
+ },
+
+ _mouseDownInDataGrid: function(event)
+ {
+ if (event.detail < 2)
+ return;
+
+ var cell = event.target.enclosingNodeOrSelfWithNodeName("td");
+ if (!cell || (!cell.hasStyleClass("total-column") && !cell.hasStyleClass("self-column") && !cell.hasStyleClass("average-column")))
+ return;
+
+ if (cell.hasStyleClass("total-column"))
+ this.showTotalTimeAsPercent = !this.showTotalTimeAsPercent;
+ else if (cell.hasStyleClass("self-column"))
+ this.showSelfTimeAsPercent = !this.showSelfTimeAsPercent;
+ else if (cell.hasStyleClass("average-column"))
+ this.showAverageTimeAsPercent = !this.showAverageTimeAsPercent;
+
+ this.refreshShowAsPercents();
+
+ event.preventDefault();
+ event.stopPropagation();
+ },
+
+ _assignParentsInProfile: function()
+ {
+ var head = this.profile.head;
+ head.parent = null;
+ head.head = null;
+ var nodesToTraverse = [ { parent: head, children: head.children } ];
+ while (nodesToTraverse.length > 0) {
+ var pair = nodesToTraverse.shift();
+ var parent = pair.parent;
+ var children = pair.children;
+ var length = children.length;
+ for (var i = 0; i < length; ++i) {
+ children[i].head = head;
+ children[i].parent = parent;
+ if (children[i].children.length > 0)
+ nodesToTraverse.push({ parent: children[i], children: children[i].children });
+ }
+ }
+ }
+}
+
+WebInspector.CPUProfileView.prototype.__proto__ = WebInspector.View.prototype;
+
+WebInspector.CPUProfileType = function()
+{
+ WebInspector.ProfileType.call(this, WebInspector.CPUProfileType.TypeId, WebInspector.UIString("CPU PROFILES"));
+ this._recording = false;
+}
+
+WebInspector.CPUProfileType.TypeId = "CPU";
+
+WebInspector.CPUProfileType.prototype = {
+ get buttonTooltip()
+ {
+ return this._recording ? WebInspector.UIString("Stop profiling.") : WebInspector.UIString("Start profiling.");
+ },
+
+ get buttonStyle()
+ {
+ return this._recording ? "record-profile-status-bar-item status-bar-item toggled-on" : "record-profile-status-bar-item status-bar-item";
+ },
+
+ buttonClicked: function()
+ {
+ this._recording = !this._recording;
+
+ if (this._recording)
+ InspectorBackend.startProfiling();
+ else
+ InspectorBackend.stopProfiling();
+ },
+
+ get welcomeMessage()
+ {
+ return WebInspector.UIString("Control CPU profiling by pressing the %s button on the status bar.");
+ },
+
+ setRecordingProfile: function(isProfiling)
+ {
+ this._recording = isProfiling;
+ },
+
+ createSidebarTreeElementForProfile: function(profile)
+ {
+ return new WebInspector.ProfileSidebarTreeElement(profile, WebInspector.UIString("Profile %d"), "profile-sidebar-tree-item");
+ },
+
+ createView: function(profile)
+ {
+ return new WebInspector.CPUProfileView(profile);
+ }
+}
+
+WebInspector.CPUProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype;