Skip to content
Permalink
Browse files
Web Inspector: Prepare utilities.js for compilation.
https://bugs.webkit.org/show_bug.cgi?id=66656

Removes "this" usage in functions, does not define getters for offsets.

Reviewed by Tony Gentilcore.

* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleMessage.prototype._format):
(WebInspector.ConsoleMessage.prototype._formatWithSubstitutionString.valueFormatter):
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMNode.prototype.appropriateSelectorFor):
(WebInspector.DOMNode.prototype.isAncestor):
(WebInspector.DOMNode.prototype.isDescendant):
(WebInspector.DOMNode.prototype.isWhitespace):
* inspector/front-end/DataGrid.js:
(WebInspector.DataGrid.prototype._resizerDragging):
(WebInspector.DataGridNode.prototype.isEventWithinDisclosureTriangle):
* inspector/front-end/Drawer.js:
(WebInspector.Drawer.prototype.get savedHeight):
(WebInspector.Drawer.prototype.onResize):
(WebInspector.Drawer.prototype._startStatusBarDragging):
(WebInspector.Drawer.prototype._statusBarDragging):
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype.updateModifiedNodes):
(WebInspector.ElementsPanel.prototype.updateBreadcrumb):
(WebInspector.ElementsPanel.prototype.updateBreadcrumbSizes.crumbsAreSmallerThanContainer):
* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeOutline.prototype.findTreeElement):
(WebInspector.ElementsTreeOutline.prototype._treeElementFromEvent):
():
* inspector/front-end/RemoteObject.js:
(WebInspector.RemoteObject):
* inspector/front-end/ResourceTimingView.js:
(WebInspector.ResourceTimingView.createTimingTable):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.BaseStorageTreeElement.prototype.isEventWithinDisclosureTriangle):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._startSidebarResizeDrag):
* inspector/front-end/SoftContextMenu.js:
(.WebInspector.SoftContextMenu.prototype.show):
* inspector/front-end/Toolbar.js:
(WebInspector.ToolbarDropdown.prototype.show):
* inspector/front-end/WatchExpressionsSidebarPane.js:
(WebInspector.WatchExpressionsSection.prototype._updateHoveredElement):
* inspector/front-end/inspector.js:
(Number.secondsToString):
(Number.bytesToString):
* inspector/front-end/treeoutline.js:
(TreeElement.prototype.isEventWithinDisclosureTriangle):
* inspector/front-end/utilities.js:
(setupPrototypeUtilities.Element.prototype.totalOffsetLeft):
(setupPrototypeUtilities.Element.prototype.totalOffsetTop):
(setupPrototypeUtilities.Element.prototype.offsetRelativeToWindow):
(setupPrototypeUtilities):
(setupPrototypeUtilities.):
():

Canonical link: https://commits.webkit.org/82561@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
pavelfeldman committed Aug 23, 2011
1 parent 263054b commit dbdf9f66b1058013fd71529ade6f73cf3d4310b8
Showing 17 changed files with 288 additions and 268 deletions.
@@ -1,3 +1,63 @@
2011-08-22 Pavel Feldman <pfeldman@google.com>

Web Inspector: Prepare utilities.js for compilation.
https://bugs.webkit.org/show_bug.cgi?id=66656

Removes "this" usage in functions, does not define getters for offsets.

Reviewed by Tony Gentilcore.

* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleMessage.prototype._format):
(WebInspector.ConsoleMessage.prototype._formatWithSubstitutionString.valueFormatter):
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMNode.prototype.appropriateSelectorFor):
(WebInspector.DOMNode.prototype.isAncestor):
(WebInspector.DOMNode.prototype.isDescendant):
(WebInspector.DOMNode.prototype.isWhitespace):
* inspector/front-end/DataGrid.js:
(WebInspector.DataGrid.prototype._resizerDragging):
(WebInspector.DataGridNode.prototype.isEventWithinDisclosureTriangle):
* inspector/front-end/Drawer.js:
(WebInspector.Drawer.prototype.get savedHeight):
(WebInspector.Drawer.prototype.onResize):
(WebInspector.Drawer.prototype._startStatusBarDragging):
(WebInspector.Drawer.prototype._statusBarDragging):
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype.updateModifiedNodes):
(WebInspector.ElementsPanel.prototype.updateBreadcrumb):
(WebInspector.ElementsPanel.prototype.updateBreadcrumbSizes.crumbsAreSmallerThanContainer):
* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeOutline.prototype.findTreeElement):
(WebInspector.ElementsTreeOutline.prototype._treeElementFromEvent):
():
* inspector/front-end/RemoteObject.js:
(WebInspector.RemoteObject):
* inspector/front-end/ResourceTimingView.js:
(WebInspector.ResourceTimingView.createTimingTable):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.BaseStorageTreeElement.prototype.isEventWithinDisclosureTriangle):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._startSidebarResizeDrag):
* inspector/front-end/SoftContextMenu.js:
(.WebInspector.SoftContextMenu.prototype.show):
* inspector/front-end/Toolbar.js:
(WebInspector.ToolbarDropdown.prototype.show):
* inspector/front-end/WatchExpressionsSidebarPane.js:
(WebInspector.WatchExpressionsSection.prototype._updateHoveredElement):
* inspector/front-end/inspector.js:
(Number.secondsToString):
(Number.bytesToString):
* inspector/front-end/treeoutline.js:
(TreeElement.prototype.isEventWithinDisclosureTriangle):
* inspector/front-end/utilities.js:
(setupPrototypeUtilities.Element.prototype.totalOffsetLeft):
(setupPrototypeUtilities.Element.prototype.totalOffsetTop):
(setupPrototypeUtilities.Element.prototype.offsetRelativeToWindow):
(setupPrototypeUtilities):
(setupPrototypeUtilities.):
():

2011-08-22 John Bates <jbates@google.com>

Implemented skia support for caching resizes of cropped images.
@@ -980,8 +980,6 @@ WebInspector.ConsoleMessage.prototype = {
_formatWithSubstitutionString: function(parameters, formattedResult)
{
var formatters = {}
for (var i in String.standardFormatters)
formatters[i] = String.standardFormatters[i];

function consoleFormatWrapper(force)
{
@@ -990,10 +988,19 @@ WebInspector.ConsoleMessage.prototype = {
};
}

function valueFormatter(obj)
{
return obj.description;
}

// Firebug uses %o for formatting objects.
formatters.o = consoleFormatWrapper();
formatters.s = valueFormatter;
formatters.f = valueFormatter;
// Firebug allows both %i and %d for formatting integers.
formatters.i = formatters.d;
formatters.i = valueFormatter;
formatters.d = valueFormatter;

// Support %O to force object formatting, instead of the type-based %o formatting.
formatters.O = consoleFormatWrapper(true);

@@ -216,7 +216,7 @@ WebInspector.DOMNode.prototype = {

appropriateSelectorFor: function(justSelector)
{
var lowerCaseName = this.localName() || node.nodeName().toLowerCase();
var lowerCaseName = this.localName() || this.nodeName().toLowerCase();

var id = this.getAttribute("id");
if (id) {
@@ -236,6 +236,34 @@ WebInspector.DOMNode.prototype = {
return lowerCaseName;
},

isAncestor: function(node)
{
if (!node)
return false;

var currentNode = node.parentNode;
while (currentNode) {
if (this === currentNode)
return true;
currentNode = currentNode.parentNode;
}
return false;
},

isDescendant: function(descendant)
{
return descendant !== null && descendant.isAncestor(this);
},

isWhitespace: function()
{
if (this.nodeType !== Node.TEXT_NODE)
return false;
if (!this.nodeValue.length)
return true;
return this.nodeValue.match(/^[\s\xA0]+$/);
},

_setAttributesPayload: function(attrs)
{
this._attributes = [];
@@ -965,7 +965,7 @@ WebInspector.DataGrid.prototype = {

// Constrain the dragpoint to be within the containing div of the
// datagrid.
var dragPoint = event.clientX - this.element.totalOffsetLeft;
var dragPoint = event.clientX - this.element.totalOffsetLeft();
// Constrain the dragpoint to be within the space made up by the
// column directly to the left and the column directly to the right.
var leftCellIndex = resizer.leftNeighboringColumnID;
@@ -1445,7 +1445,7 @@ WebInspector.DataGridNode.prototype = {
if (!cell.hasStyleClass("disclosure"))
return false;
var computedLeftPadding = window.getComputedStyle(cell).getPropertyCSSValue("padding-left").getFloatValue(CSSPrimitiveValue.CSS_PX);
var left = cell.totalOffsetLeft + computedLeftPadding;
var left = cell.totalOffsetLeft() + computedLeftPadding;
return event.pageX >= left && event.pageX <= left + this.disclosureToggleWidth;
},

@@ -77,7 +77,7 @@ WebInspector.Drawer.prototype = {
get savedHeight()
{
var height = this._savedHeight || this.element.offsetHeight;
return Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop - Preferences.minConsoleHeight);
return Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop() - Preferences.minConsoleHeight);
},

showView: function(view)
@@ -206,7 +206,7 @@ WebInspector.Drawer.prototype = {
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);
height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop() - Preferences.minConsoleHeight);
} else
height = window.innerHeight - this._toolbarElement.offsetHeight;

@@ -331,15 +331,15 @@ WebInspector.Drawer.prototype = {

WebInspector.elementDragStart(this._mainStatusBar, this._statusBarDragging.bind(this), this._endStatusBarDragging.bind(this), event, "row-resize");

this._statusBarDragOffset = event.pageY - this.element.totalOffsetTop;
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);
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";
@@ -479,7 +479,7 @@ WebInspector.ElementsPanel.prototype = {
updatedParentTreeElements.push(parentNodeItem);
}

if (!updateBreadcrumbs && (this.selectedDOMNode() === parent || isAncestorNode(this.selectedDOMNode(), parent)))
if (!updateBreadcrumbs && (this.selectedDOMNode() === parent || (this.selectedDOMNode() && this.selectedDOMNode().isAncestor(parent))))
updateBreadcrumbs = true;
}

@@ -621,7 +621,7 @@ WebInspector.ElementsPanel.prototype = {
break;

case Node.TEXT_NODE:
if (isNodeWhitespace.call(current))
if (current.isWhitespace())
crumbTitle = WebInspector.UIString("(whitespace)");
else
crumbTitle = WebInspector.UIString("(text)");
@@ -783,7 +783,7 @@ WebInspector.ElementsPanel.prototype = {
var errorWarningElement = document.getElementById("error-warning-count");
if (!WebInspector.drawer.visible && errorWarningElement)
rightPadding += errorWarningElement.offsetWidth;
return ((crumbs.totalOffsetLeft + crumbs.offsetWidth + rightPadding) < window.innerWidth);
return ((crumbs.totalOffsetLeft() + crumbs.offsetWidth + rightPadding) < window.innerWidth);
}

if (crumbsAreSmallerThanContainer())
@@ -146,6 +146,10 @@ WebInspector.ElementsTreeOutline.prototype = {

findTreeElement: function(node)
{
function isAncestorNode(ancestor, node)
{
return ancestor.isAncestor(node);
}
var treeElement = TreeOutline.prototype.findTreeElement.call(this, node, isAncestorNode, parentNode);
if (!treeElement && node.nodeType() === Node.TEXT_NODE) {
// The text node might have been inlined if it was short, so try to find the parent element.
@@ -197,7 +201,7 @@ WebInspector.ElementsTreeOutline.prototype = {
// items extend at least to the right edge of the outer <ol> container.
// In the no-word-wrap mode the outer <ol> may be wider than the tree container
// (and partially hidden), in which case we are left to use only its right boundary.
var x = scrollContainer.totalOffsetLeft + scrollContainer.offsetWidth - 36;
var x = scrollContainer.totalOffsetLeft() + scrollContainer.offsetWidth - 36;

var y = event.pageY;

@@ -1466,7 +1470,7 @@ WebInspector.ElementsTreeElement.prototype = {
break;

case Node.TEXT_NODE:
if (isNodeWhitespace.call(node))
if (node.isWhitespace())
info.titleDOM.appendChild(document.createTextNode("(whitespace)"));
else {
if (node.parentNode && node.parentNode.nodeName().toLowerCase() === "script") {
@@ -42,6 +42,7 @@ WebInspector.RemoteObject = function(objectId, type, subtype, value, description
console.assert(type !== "object" || value === null);
this._description = description || (value + "");
this._hasChildren = false;
this.value = value;
}
}

@@ -148,7 +148,7 @@ WebInspector.ResourceTimingView.createTimingTable = function(resource)
title.style.right = (scale * (total - rows[i].end) + 3) + "px";
else
title.style.left = (scale * rows[i].start + 3) + "px";
title.textContent = Number.millisToString(rows[i].end - rows[i].start);
title.textContent = Number.secondsToString((rows[i].end - rows[i].start) / 1000);
row.appendChild(title);

tr.appendChild(td);
@@ -972,7 +972,7 @@ WebInspector.BaseStorageTreeElement.prototype = {
// Hence we need to take padding into consideration. This all is needed for leading
// icons in the tree.
const paddingLeft = 14;
var left = this.listItemElement.totalOffsetLeft + paddingLeft;
var left = this.listItemElement.totalOffsetLeft() + paddingLeft;
return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren;
}
}
@@ -764,7 +764,7 @@ WebInspector.ScriptsPanel.prototype = {
WebInspector.elementDragStart(this.sidebarElement, this._sidebarResizeDrag.bind(this), this._endSidebarResizeDrag.bind(this), event, "ew-resize");

if (event.target === this.sidebarResizeWidgetElement)
this._dragOffset = (event.target.offsetWidth - (event.pageX - event.target.totalOffsetLeft));
this._dragOffset = (event.target.offsetWidth - (event.pageX - event.target.totalOffsetLeft()));
else
this._dragOffset = 0;
},
@@ -43,8 +43,8 @@ WebInspector.SoftContextMenu.prototype = {
var targetElement = event.target;
while (targetElement && window !== targetElement.ownerDocument.defaultView) {
var frameElement = targetElement.ownerDocument.defaultView.frameElement;
absoluteY += frameElement.totalOffsetTop;
absoluteX += frameElement.totalOffsetLeft;
absoluteY += frameElement.totalOffsetTop();
absoluteX += frameElement.totalOffsetLeft();
targetElement = frameElement;
}

@@ -187,10 +187,10 @@ WebInspector.ToolbarDropdown.prototype = {
return;
var style = this.element.style;
this._populate();
var top = this._arrow.totalOffsetTop + this._arrow.clientHeight;
var top = this._arrow.totalOffsetTop() + this._arrow.clientHeight;
this._arrow.addStyleClass("dropdown-visible");
this.element.style.top = top + "px";
this.element.style.left = this._arrow.totalOffsetLeft + "px";
this.element.style.left = this._arrow.totalOffsetLeft() + "px";
this._contentElement.style.maxHeight = window.innerHeight - top - 20 + "px";
this._toolbar.appendChild(this.element);
WebInspector.currentFocusElement = this.contentElement;
@@ -259,7 +259,7 @@ WebInspector.WatchExpressionsSection.prototype = {
var next = this._hoveredElement.nextSibling;
while(next && !next.clientHeight)
next = next.nextSibling;
if (!next || next.totalOffsetTop > pageY)
if (!next || next.totalOffsetTop() > pageY)
break;
this._hoveredElement = next;
}
@@ -1716,3 +1716,50 @@ WebInspector.PanelHistory.prototype = {
this._historyIterator = this._history.length - 1;
}
}

Number.secondsToString = function(seconds, higherResolution)
{
if (seconds === 0)
return "0";

var ms = seconds * 1000;
if (higherResolution && ms < 1000)
return WebInspector.UIString("%.3fms", ms);
else if (ms < 1000)
return WebInspector.UIString("%.0fms", ms);

if (seconds < 60)
return WebInspector.UIString("%.2fs", seconds);

var minutes = seconds / 60;
if (minutes < 60)
return WebInspector.UIString("%.1fmin", minutes);

var hours = minutes / 60;
if (hours < 24)
return WebInspector.UIString("%.1fhrs", hours);

var days = hours / 24;
return WebInspector.UIString("%.1f days", days);
}

Number.bytesToString = function(bytes, higherResolution)
{
if (typeof higherResolution === "undefined")
higherResolution = true;

if (bytes < 1024)
return WebInspector.UIString("%.0fB", bytes);

var kilobytes = bytes / 1024;
if (higherResolution && kilobytes < 1024)
return WebInspector.UIString("%.2fKB", kilobytes);
else if (kilobytes < 1024)
return WebInspector.UIString("%.0fKB", kilobytes);

var megabytes = kilobytes / 1024;
if (higherResolution)
return WebInspector.UIString("%.2fMB", megabytes);
else
return WebInspector.UIString("%.0fMB", megabytes);
}

0 comments on commit dbdf9f6

Please sign in to comment.