Changeset 93584 in webkit
- Timestamp:
- Aug 23, 2011 2:23:31 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93580 r93584 1 2011-08-22 Pavel Feldman <pfeldman@google.com> 2 3 Web Inspector: Prepare utilities.js for compilation. 4 https://bugs.webkit.org/show_bug.cgi?id=66656 5 6 Removes "this" usage in functions, does not define getters for offsets. 7 8 Reviewed by Tony Gentilcore. 9 10 * inspector/front-end/ConsoleView.js: 11 (WebInspector.ConsoleMessage.prototype._format): 12 (WebInspector.ConsoleMessage.prototype._formatWithSubstitutionString.valueFormatter): 13 * inspector/front-end/DOMAgent.js: 14 (WebInspector.DOMNode.prototype.appropriateSelectorFor): 15 (WebInspector.DOMNode.prototype.isAncestor): 16 (WebInspector.DOMNode.prototype.isDescendant): 17 (WebInspector.DOMNode.prototype.isWhitespace): 18 * inspector/front-end/DataGrid.js: 19 (WebInspector.DataGrid.prototype._resizerDragging): 20 (WebInspector.DataGridNode.prototype.isEventWithinDisclosureTriangle): 21 * inspector/front-end/Drawer.js: 22 (WebInspector.Drawer.prototype.get savedHeight): 23 (WebInspector.Drawer.prototype.onResize): 24 (WebInspector.Drawer.prototype._startStatusBarDragging): 25 (WebInspector.Drawer.prototype._statusBarDragging): 26 * inspector/front-end/ElementsPanel.js: 27 (WebInspector.ElementsPanel.prototype.updateModifiedNodes): 28 (WebInspector.ElementsPanel.prototype.updateBreadcrumb): 29 (WebInspector.ElementsPanel.prototype.updateBreadcrumbSizes.crumbsAreSmallerThanContainer): 30 * inspector/front-end/ElementsTreeOutline.js: 31 (WebInspector.ElementsTreeOutline.prototype.findTreeElement): 32 (WebInspector.ElementsTreeOutline.prototype._treeElementFromEvent): 33 (): 34 * inspector/front-end/RemoteObject.js: 35 (WebInspector.RemoteObject): 36 * inspector/front-end/ResourceTimingView.js: 37 (WebInspector.ResourceTimingView.createTimingTable): 38 * inspector/front-end/ResourcesPanel.js: 39 (WebInspector.BaseStorageTreeElement.prototype.isEventWithinDisclosureTriangle): 40 * inspector/front-end/ScriptsPanel.js: 41 (WebInspector.ScriptsPanel.prototype._startSidebarResizeDrag): 42 * inspector/front-end/SoftContextMenu.js: 43 (.WebInspector.SoftContextMenu.prototype.show): 44 * inspector/front-end/Toolbar.js: 45 (WebInspector.ToolbarDropdown.prototype.show): 46 * inspector/front-end/WatchExpressionsSidebarPane.js: 47 (WebInspector.WatchExpressionsSection.prototype._updateHoveredElement): 48 * inspector/front-end/inspector.js: 49 (Number.secondsToString): 50 (Number.bytesToString): 51 * inspector/front-end/treeoutline.js: 52 (TreeElement.prototype.isEventWithinDisclosureTriangle): 53 * inspector/front-end/utilities.js: 54 (setupPrototypeUtilities.Element.prototype.totalOffsetLeft): 55 (setupPrototypeUtilities.Element.prototype.totalOffsetTop): 56 (setupPrototypeUtilities.Element.prototype.offsetRelativeToWindow): 57 (setupPrototypeUtilities): 58 (setupPrototypeUtilities.): 59 (): 60 1 61 2011-08-22 John Bates <jbates@google.com> 2 62 -
trunk/Source/WebCore/inspector/front-end/ConsoleView.js
r93510 r93584 981 981 { 982 982 var formatters = {} 983 for (var i in String.standardFormatters)984 formatters[i] = String.standardFormatters[i];985 983 986 984 function consoleFormatWrapper(force) … … 991 989 } 992 990 991 function valueFormatter(obj) 992 { 993 return obj.description; 994 } 995 993 996 // Firebug uses %o for formatting objects. 994 997 formatters.o = consoleFormatWrapper(); 998 formatters.s = valueFormatter; 999 formatters.f = valueFormatter; 995 1000 // Firebug allows both %i and %d for formatting integers. 996 formatters.i = formatters.d; 1001 formatters.i = valueFormatter; 1002 formatters.d = valueFormatter; 1003 997 1004 // Support %O to force object formatting, instead of the type-based %o formatting. 998 1005 formatters.O = consoleFormatWrapper(true); -
trunk/Source/WebCore/inspector/front-end/DOMAgent.js
r93510 r93584 217 217 appropriateSelectorFor: function(justSelector) 218 218 { 219 var lowerCaseName = this.localName() || node.nodeName().toLowerCase();219 var lowerCaseName = this.localName() || this.nodeName().toLowerCase(); 220 220 221 221 var id = this.getAttribute("id"); … … 235 235 236 236 return lowerCaseName; 237 }, 238 239 isAncestor: function(node) 240 { 241 if (!node) 242 return false; 243 244 var currentNode = node.parentNode; 245 while (currentNode) { 246 if (this === currentNode) 247 return true; 248 currentNode = currentNode.parentNode; 249 } 250 return false; 251 }, 252 253 isDescendant: function(descendant) 254 { 255 return descendant !== null && descendant.isAncestor(this); 256 }, 257 258 isWhitespace: function() 259 { 260 if (this.nodeType !== Node.TEXT_NODE) 261 return false; 262 if (!this.nodeValue.length) 263 return true; 264 return this.nodeValue.match(/^[\s\xA0]+$/); 237 265 }, 238 266 -
trunk/Source/WebCore/inspector/front-end/DataGrid.js
r92956 r93584 966 966 // Constrain the dragpoint to be within the containing div of the 967 967 // datagrid. 968 var dragPoint = event.clientX - this.element.totalOffsetLeft ;968 var dragPoint = event.clientX - this.element.totalOffsetLeft(); 969 969 // Constrain the dragpoint to be within the space made up by the 970 970 // column directly to the left and the column directly to the right. … … 1446 1446 return false; 1447 1447 var computedLeftPadding = window.getComputedStyle(cell).getPropertyCSSValue("padding-left").getFloatValue(CSSPrimitiveValue.CSS_PX); 1448 var left = cell.totalOffsetLeft + computedLeftPadding;1448 var left = cell.totalOffsetLeft() + computedLeftPadding; 1449 1449 return event.pageX >= left && event.pageX <= left + this.disclosureToggleWidth; 1450 1450 }, -
trunk/Source/WebCore/inspector/front-end/Drawer.js
r93196 r93584 78 78 { 79 79 var height = this._savedHeight || this.element.offsetHeight; 80 return Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop - Preferences.minConsoleHeight);80 return Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop() - Preferences.minConsoleHeight); 81 81 }, 82 82 … … 207 207 if (this.state === WebInspector.Drawer.State.Variable) { 208 208 height = parseInt(this.element.style.height); 209 height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop - Preferences.minConsoleHeight);209 height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop() - Preferences.minConsoleHeight); 210 210 } else 211 211 height = window.innerHeight - this._toolbarElement.offsetHeight; … … 332 332 WebInspector.elementDragStart(this._mainStatusBar, this._statusBarDragging.bind(this), this._endStatusBarDragging.bind(this), event, "row-resize"); 333 333 334 this._statusBarDragOffset = event.pageY - this.element.totalOffsetTop ;334 this._statusBarDragOffset = event.pageY - this.element.totalOffsetTop(); 335 335 336 336 event.stopPropagation(); … … 340 340 { 341 341 var height = window.innerHeight - event.pageY + this._statusBarDragOffset; 342 height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop - Preferences.minConsoleHeight);342 height = Number.constrain(height, Preferences.minConsoleHeight, window.innerHeight - this._mainElement.totalOffsetTop() - Preferences.minConsoleHeight); 343 343 344 344 this._mainElement.style.bottom = height + "px"; -
trunk/Source/WebCore/inspector/front-end/ElementsPanel.js
r93196 r93584 480 480 } 481 481 482 if (!updateBreadcrumbs && (this.selectedDOMNode() === parent || isAncestorNode(this.selectedDOMNode(), parent)))482 if (!updateBreadcrumbs && (this.selectedDOMNode() === parent || (this.selectedDOMNode() && this.selectedDOMNode().isAncestor(parent)))) 483 483 updateBreadcrumbs = true; 484 484 } … … 622 622 623 623 case Node.TEXT_NODE: 624 if ( isNodeWhitespace.call(current))624 if (current.isWhitespace()) 625 625 crumbTitle = WebInspector.UIString("(whitespace)"); 626 626 else … … 784 784 if (!WebInspector.drawer.visible && errorWarningElement) 785 785 rightPadding += errorWarningElement.offsetWidth; 786 return ((crumbs.totalOffsetLeft + crumbs.offsetWidth + rightPadding) < window.innerWidth);786 return ((crumbs.totalOffsetLeft() + crumbs.offsetWidth + rightPadding) < window.innerWidth); 787 787 } 788 788 -
trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js
r93035 r93584 147 147 findTreeElement: function(node) 148 148 { 149 function isAncestorNode(ancestor, node) 150 { 151 return ancestor.isAncestor(node); 152 } 149 153 var treeElement = TreeOutline.prototype.findTreeElement.call(this, node, isAncestorNode, parentNode); 150 154 if (!treeElement && node.nodeType() === Node.TEXT_NODE) { … … 198 202 // In the no-word-wrap mode the outer <ol> may be wider than the tree container 199 203 // (and partially hidden), in which case we are left to use only its right boundary. 200 var x = scrollContainer.totalOffsetLeft + scrollContainer.offsetWidth - 36;204 var x = scrollContainer.totalOffsetLeft() + scrollContainer.offsetWidth - 36; 201 205 202 206 var y = event.pageY; … … 1467 1471 1468 1472 case Node.TEXT_NODE: 1469 if ( isNodeWhitespace.call(node))1473 if (node.isWhitespace()) 1470 1474 info.titleDOM.appendChild(document.createTextNode("(whitespace)")); 1471 1475 else { -
trunk/Source/WebCore/inspector/front-end/RemoteObject.js
r93389 r93584 43 43 this._description = description || (value + ""); 44 44 this._hasChildren = false; 45 this.value = value; 45 46 } 46 47 } -
trunk/Source/WebCore/inspector/front-end/ResourceTimingView.js
r93196 r93584 149 149 else 150 150 title.style.left = (scale * rows[i].start + 3) + "px"; 151 title.textContent = Number. millisToString(rows[i].end - rows[i].start);151 title.textContent = Number.secondsToString((rows[i].end - rows[i].start) / 1000); 152 152 row.appendChild(title); 153 153 -
trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js
r93196 r93584 973 973 // icons in the tree. 974 974 const paddingLeft = 14; 975 var left = this.listItemElement.totalOffsetLeft + paddingLeft;975 var left = this.listItemElement.totalOffsetLeft() + paddingLeft; 976 976 return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren; 977 977 } -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r93419 r93584 765 765 766 766 if (event.target === this.sidebarResizeWidgetElement) 767 this._dragOffset = (event.target.offsetWidth - (event.pageX - event.target.totalOffsetLeft ));767 this._dragOffset = (event.target.offsetWidth - (event.pageX - event.target.totalOffsetLeft())); 768 768 else 769 769 this._dragOffset = 0; -
trunk/Source/WebCore/inspector/front-end/SoftContextMenu.js
r93034 r93584 44 44 while (targetElement && window !== targetElement.ownerDocument.defaultView) { 45 45 var frameElement = targetElement.ownerDocument.defaultView.frameElement; 46 absoluteY += frameElement.totalOffsetTop ;47 absoluteX += frameElement.totalOffsetLeft ;46 absoluteY += frameElement.totalOffsetTop(); 47 absoluteX += frameElement.totalOffsetLeft(); 48 48 targetElement = frameElement; 49 49 } -
trunk/Source/WebCore/inspector/front-end/Toolbar.js
r87894 r93584 188 188 var style = this.element.style; 189 189 this._populate(); 190 var top = this._arrow.totalOffsetTop + this._arrow.clientHeight;190 var top = this._arrow.totalOffsetTop() + this._arrow.clientHeight; 191 191 this._arrow.addStyleClass("dropdown-visible"); 192 192 this.element.style.top = top + "px"; 193 this.element.style.left = this._arrow.totalOffsetLeft + "px";193 this.element.style.left = this._arrow.totalOffsetLeft() + "px"; 194 194 this._contentElement.style.maxHeight = window.innerHeight - top - 20 + "px"; 195 195 this._toolbar.appendChild(this.element); -
trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js
r92827 r93584 260 260 while(next && !next.clientHeight) 261 261 next = next.nextSibling; 262 if (!next || next.totalOffsetTop > pageY)262 if (!next || next.totalOffsetTop() > pageY) 263 263 break; 264 264 this._hoveredElement = next; -
trunk/Source/WebCore/inspector/front-end/inspector.js
r93510 r93584 1717 1717 } 1718 1718 } 1719 1720 Number.secondsToString = function(seconds, higherResolution) 1721 { 1722 if (seconds === 0) 1723 return "0"; 1724 1725 var ms = seconds * 1000; 1726 if (higherResolution && ms < 1000) 1727 return WebInspector.UIString("%.3fms", ms); 1728 else if (ms < 1000) 1729 return WebInspector.UIString("%.0fms", ms); 1730 1731 if (seconds < 60) 1732 return WebInspector.UIString("%.2fs", seconds); 1733 1734 var minutes = seconds / 60; 1735 if (minutes < 60) 1736 return WebInspector.UIString("%.1fmin", minutes); 1737 1738 var hours = minutes / 60; 1739 if (hours < 24) 1740 return WebInspector.UIString("%.1fhrs", hours); 1741 1742 var days = hours / 24; 1743 return WebInspector.UIString("%.1f days", days); 1744 } 1745 1746 Number.bytesToString = function(bytes, higherResolution) 1747 { 1748 if (typeof higherResolution === "undefined") 1749 higherResolution = true; 1750 1751 if (bytes < 1024) 1752 return WebInspector.UIString("%.0fB", bytes); 1753 1754 var kilobytes = bytes / 1024; 1755 if (higherResolution && kilobytes < 1024) 1756 return WebInspector.UIString("%.2fKB", kilobytes); 1757 else if (kilobytes < 1024) 1758 return WebInspector.UIString("%.0fKB", kilobytes); 1759 1760 var megabytes = kilobytes / 1024; 1761 if (higherResolution) 1762 return WebInspector.UIString("%.2fMB", megabytes); 1763 else 1764 return WebInspector.UIString("%.0fMB", megabytes); 1765 } -
trunk/Source/WebCore/inspector/front-end/treeoutline.js
r92956 r93584 27 27 */ 28 28 29 /** 30 * @constructor 31 */ 29 32 function TreeOutline(listNode) 30 33 { 34 /** 35 * @type {Array.<TreeElement>} 36 */ 31 37 this.children = []; 32 38 this.selectedTreeElement = null; … … 48 54 TreeOutline._knownTreeElementNextIdentifier = 1; 49 55 50 TreeOutline. _appendChild = function(child)56 TreeOutline.prototype.appendChild = function(child) 51 57 { 52 58 if (!child) … … 89 95 } 90 96 91 TreeOutline. _insertChild = function(child, index)97 TreeOutline.prototype.insertChild = function(child, index) 92 98 { 93 99 if (!child) … … 137 143 } 138 144 139 TreeOutline. _removeChildAtIndex = function(childIndex)145 TreeOutline.prototype.removeChildAtIndex = function(childIndex) 140 146 { 141 147 if (childIndex < 0 || childIndex >= this.children.length) … … 172 178 } 173 179 174 TreeOutline. _removeChild = function(child)180 TreeOutline.prototype.removeChild = function(child) 175 181 { 176 182 if (!child) … … 181 187 throw("child not found in this node's children"); 182 188 183 TreeOutline._removeChildAtIndex.call(this, childIndex);184 } 185 186 TreeOutline. _removeChildren = function()189 this.removeChildAtIndex.call(this, childIndex); 190 } 191 192 TreeOutline.prototype.removeChildren = function() 187 193 { 188 194 for (var i = 0; i < this.children.length; ++i) { … … 205 211 } 206 212 207 TreeOutline. _removeChildrenRecursive = function()213 TreeOutline.prototype.removeChildrenRecursive = function() 208 214 { 209 215 var childrenToRemove = this.children; … … 217 223 218 224 for (var i = 0; i < childrenToRemove.length; ++i) { 219 varchild = childrenToRemove[i];225 child = childrenToRemove[i]; 220 226 child.deselect(); 221 227 if (child.treeOutline) … … 323 329 // ancestor exists in the tree. 324 330 item = this.findTreeElement(ancestors[i], isAncestor, getParent); 325 if (item && item.onpopulate)326 item.onpopulate( item);331 if (item) 332 item.onpopulate(); 327 333 } 328 334 … … 393 399 } 394 400 } 395 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code || event.keyCode === WebInspector.KeyboardShortcut.Keys.Delete.code) {401 } else if (event.keyCode === 27 /* Esc */ || event.keyCode === 46 /* Delete */) { 396 402 if (this.selectedTreeElement.ondelete) 397 403 handled = this.selectedTreeElement.ondelete(); … … 442 448 } 443 449 444 TreeOutline.prototype.appendChild = TreeOutline._appendChild; 445 TreeOutline.prototype.insertChild = TreeOutline._insertChild; 446 TreeOutline.prototype.removeChild = TreeOutline._removeChild; 447 TreeOutline.prototype.removeChildAtIndex = TreeOutline._removeChildAtIndex; 448 TreeOutline.prototype.removeChildren = TreeOutline._removeChildren; 449 TreeOutline.prototype.removeChildrenRecursive = TreeOutline._removeChildrenRecursive; 450 450 /** 451 * @constructor 452 */ 451 453 function TreeElement(title, representedObject, hasChildren) 452 454 { … … 587 589 } 588 590 589 TreeElement.prototype.appendChild = TreeOutline. _appendChild;590 TreeElement.prototype.insertChild = TreeOutline. _insertChild;591 TreeElement.prototype.removeChild = TreeOutline. _removeChild;592 TreeElement.prototype.removeChildAtIndex = TreeOutline. _removeChildAtIndex;593 TreeElement.prototype.removeChildren = TreeOutline. _removeChildren;594 TreeElement.prototype.removeChildrenRecursive = TreeOutline. _removeChildrenRecursive;591 TreeElement.prototype.appendChild = TreeOutline.prototype.appendChild; 592 TreeElement.prototype.insertChild = TreeOutline.prototype.insertChild; 593 TreeElement.prototype.removeChild = TreeOutline.prototype.removeChild; 594 TreeElement.prototype.removeChildAtIndex = TreeOutline.prototype.removeChildAtIndex; 595 TreeElement.prototype.removeChildren = TreeOutline.prototype.removeChildren; 596 TreeElement.prototype.removeChildrenRecursive = TreeOutline.prototype.removeChildrenRecursive; 595 597 596 598 TreeElement.prototype._attach = function() … … 732 734 this._childrenListNode.addStyleClass("hidden"); 733 735 734 if (this.onpopulate) 735 this.onpopulate(this); 736 this.onpopulate(); 736 737 737 738 for (var i = 0; i < this.children.length; ++i) … … 822 823 } 823 824 825 /** 826 * @param {boolean=} omitFocus 827 * @param {boolean=} selectedByUser 828 */ 824 829 TreeElement.prototype.select = function(omitFocus, selectedByUser) 825 830 { … … 852 857 } 853 858 859 /** 860 * @param {boolean=} supressOnDeselect 861 */ 854 862 TreeElement.prototype.deselect = function(supressOnDeselect) 855 863 { … … 867 875 } 868 876 877 TreeElement.prototype.onpopulate = function() 878 { 879 // Overriden by subclasses. 880 } 881 869 882 TreeElement.prototype.traverseNextTreeElement = function(skipHidden, stayWithin, dontPopulate, info) 870 883 { 871 if (!dontPopulate && this.hasChildren && this.onpopulate)872 this.onpopulate( this);884 if (!dontPopulate && this.hasChildren) 885 this.onpopulate(); 873 886 874 887 if (info) … … 905 918 { 906 919 var element = skipHidden ? (this.revealed() ? this.previousSibling : null) : this.previousSibling; 907 if (!dontPopulate && element && element.hasChildren && element.onpopulate)908 element.onpopulate( element);920 if (!dontPopulate && element && element.hasChildren) 921 element.onpopulate(); 909 922 910 923 while (element && (skipHidden ? (element.revealed() && element.expanded ? element.children[element.children.length - 1] : null) : element.children[element.children.length - 1])) { 911 if (!dontPopulate && element.hasChildren && element.onpopulate)912 element.onpopulate( element);924 if (!dontPopulate && element.hasChildren) 925 element.onpopulate(); 913 926 element = (skipHidden ? (element.revealed() && element.expanded ? element.children[element.children.length - 1] : null) : element.children[element.children.length - 1]); 914 927 } … … 925 938 TreeElement.prototype.isEventWithinDisclosureTriangle = function(event) 926 939 { 927 var left = this._listItemNode.totalOffsetLeft ;940 var left = this._listItemNode.totalOffsetLeft(); 928 941 return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren; 929 942 } -
trunk/Source/WebCore/inspector/front-end/utilities.js
r91359 r93584 262 262 DocumentFragment.prototype.createChild = Element.prototype.createChild; 263 263 264 Element.prototype. __defineGetter__("totalOffsetLeft",function()264 Element.prototype.totalOffsetLeft = function() 265 265 { 266 266 var total = 0; … … 268 268 total += element.offsetLeft + (this !== element ? element.clientLeft : 0); 269 269 return total; 270 } );271 272 Element.prototype. __defineGetter__("totalOffsetTop",function()270 } 271 272 Element.prototype.totalOffsetTop = function() 273 273 { 274 274 var total = 0; … … 276 276 total += element.offsetTop + (this !== element ? element.clientTop : 0); 277 277 return total; 278 } );278 } 279 279 280 280 Element.prototype.offsetRelativeToWindow = function(targetWindow) … … 284 284 var curWindow = this.ownerDocument.defaultView; 285 285 while (curWindow && curElement) { 286 elementOffset.x += curElement.totalOffsetLeft ;287 elementOffset.y += curElement.totalOffsetTop ;286 elementOffset.x += curElement.totalOffsetLeft(); 287 elementOffset.y += curElement.totalOffsetTop(); 288 288 if (curWindow === targetWindow) 289 289 break; … … 469 469 } 470 470 471 window.isNodeWhitespace = function() 472 { 473 if (!this || this.nodeType !== Node.TEXT_NODE) 474 return false; 475 if (!this.nodeValue.length) 476 return true; 477 return this.nodeValue.match(/^[\s\xA0]+$/); 478 } 479 480 function nodeDisplayName() 481 { 482 if (!this) 483 return ""; 484 485 switch (this.nodeType) { 486 case Node.DOCUMENT_NODE: 487 return "Document"; 488 489 case Node.ELEMENT_NODE: 490 var name = "<" + this.nodeName.toLowerCase(); 491 492 if (this.hasAttributes()) { 493 var value = this.getAttribute("id"); 494 if (value) 495 name += " id=\"" + value + "\""; 496 value = this.getAttribute("class"); 497 if (value) 498 name += " class=\"" + value + "\""; 499 if (this.nodeName.toLowerCase() === "a") { 500 value = this.getAttribute("name"); 501 if (value) 502 name += " name=\"" + value + "\""; 503 value = this.getAttribute("href"); 504 if (value) 505 name += " href=\"" + value + "\""; 506 } else if (this.nodeName.toLowerCase() === "img") { 507 value = this.getAttribute("src"); 508 if (value) 509 name += " src=\"" + value + "\""; 510 } else if (this.nodeName.toLowerCase() === "iframe") { 511 value = this.getAttribute("src"); 512 if (value) 513 name += " src=\"" + value + "\""; 514 } else if (this.nodeName.toLowerCase() === "input") { 515 value = this.getAttribute("name"); 516 if (value) 517 name += " name=\"" + value + "\""; 518 value = this.getAttribute("type"); 519 if (value) 520 name += " type=\"" + value + "\""; 521 } else if (this.nodeName.toLowerCase() === "form") { 522 value = this.getAttribute("action"); 523 if (value) 524 name += " action=\"" + value + "\""; 525 } 526 } 527 528 return name + ">"; 529 530 case Node.TEXT_NODE: 531 if (isNodeWhitespace.call(this)) 532 return "(whitespace)"; 533 return "\"" + this.nodeValue + "\""; 534 535 case Node.COMMENT_NODE: 536 return "<!--" + this.nodeValue + "-->"; 537 538 case Node.DOCUMENT_TYPE_NODE: 539 var docType = "<!DOCTYPE " + this.nodeName; 540 if (this.publicId) { 541 docType += " PUBLIC \"" + this.publicId + "\""; 542 if (this.systemId) 543 docType += " \"" + this.systemId + "\""; 544 } else if (this.systemId) 545 docType += " SYSTEM \"" + this.systemId + "\""; 546 if (this.internalSubset) 547 docType += " [" + this.internalSubset + "]"; 548 return docType + ">"; 549 } 550 551 return this.nodeName.toLowerCase().collapseWhitespace(); 552 } 553 554 window.isAncestorNode = function(ancestor, node) 555 { 556 if (!node || !ancestor) 471 Node.prototype.isAncestor = function(node) 472 { 473 if (!node) 557 474 return false; 558 475 559 476 var currentNode = node.parentNode; 560 477 while (currentNode) { 561 if ( ancestor=== currentNode)478 if (this === currentNode) 562 479 return true; 563 480 currentNode = currentNode.parentNode; … … 566 483 } 567 484 568 window.isDescendantNode = function(descendant) 569 { 570 return isAncestorNode(descendant, this); 571 } 572 573 function traverseNextNode(stayWithin) 574 { 575 if (!this) 576 return; 577 485 Node.prototype.isDescendant = function(descendant) 486 { 487 return !!descendant && descendant.isAncestor(this); 488 } 489 490 Node.prototype.traverseNextNode = function(stayWithin) 491 { 578 492 var node = this.firstChild; 579 493 if (node) … … 596 510 } 597 511 598 function traversePreviousNode(stayWithin) 599 { 600 if (!this) 601 return; 512 Node.prototype.traversePreviousNode = function(stayWithin) 513 { 602 514 if (stayWithin && this === stayWithin) 603 515 return null; … … 613 525 { 614 526 return node.parentNode; 615 }616 617 Node.prototype.isWhitespace = isNodeWhitespace;618 Node.prototype.displayName = nodeDisplayName;619 Node.prototype.isAncestor = function(node)620 {621 return isAncestorNode(this, node);622 };623 Node.prototype.isDescendant = isDescendantNode;624 Node.prototype.traverseNextNode = traverseNextNode;625 Node.prototype.traversePreviousNode = traversePreviousNode;626 627 Number.millisToString = function(ms, higherResolution)628 {629 return Number.secondsToString(ms / 1000, higherResolution);630 }631 632 Number.secondsToString = function(seconds, higherResolution)633 {634 if (seconds === 0)635 return "0";636 637 var ms = seconds * 1000;638 if (higherResolution && ms < 1000)639 return WebInspector.UIString("%.3fms", ms);640 else if (ms < 1000)641 return WebInspector.UIString("%.0fms", ms);642 643 if (seconds < 60)644 return WebInspector.UIString("%.2fs", seconds);645 646 var minutes = seconds / 60;647 if (minutes < 60)648 return WebInspector.UIString("%.1fmin", minutes);649 650 var hours = minutes / 60;651 if (hours < 24)652 return WebInspector.UIString("%.1fhrs", hours);653 654 var days = hours / 24;655 return WebInspector.UIString("%.1f days", days);656 }657 658 Number.bytesToString = function(bytes, higherResolution)659 {660 if (typeof higherResolution === "undefined")661 higherResolution = true;662 663 if (bytes < 1024)664 return WebInspector.UIString("%.0fB", bytes);665 666 var kilobytes = bytes / 1024;667 if (higherResolution && kilobytes < 1024)668 return WebInspector.UIString("%.2fKB", kilobytes);669 else if (kilobytes < 1024)670 return WebInspector.UIString("%.0fKB", kilobytes);671 672 var megabytes = kilobytes / 1024;673 if (higherResolution)674 return WebInspector.UIString("%.2fMB", megabytes);675 else676 return WebInspector.UIString("%.0fMB", megabytes);677 527 } 678 528 … … 709 559 } 710 560 711 Object.defineProperty(Array.prototype, "remove", { value: function(value, onlyFirst) 712 { 713 if (onlyFirst) { 714 var index = this.indexOf(value); 715 if (index !== -1) 716 this.splice(index, 1); 717 return; 718 } 719 720 var length = this.length; 721 for (var i = 0; i < length; ++i) { 722 if (this[i] === value) 723 this.splice(i, 1); 724 } 725 }}); 726 727 Object.defineProperty(Array.prototype, "keySet", { value: function() 728 { 729 var keys = {}; 730 for (var i = 0; i < this.length; ++i) 731 keys[this[i]] = true; 732 return keys; 733 }}); 734 735 Object.defineProperty(Array.prototype, "upperBound", { value: function(value) 736 { 737 var first = 0; 738 var count = this.length; 739 while (count > 0) { 740 var step = count >> 1; 741 var middle = first + step; 742 if (value >= this[middle]) { 743 first = middle + 1; 744 count -= step + 1; 745 } else 746 count = step; 747 } 748 return first; 749 }}); 561 Object.defineProperty(Array.prototype, "remove", 562 { 563 /** 564 * @this {Array.<*>} 565 */ 566 value: function(value, onlyFirst) 567 { 568 if (onlyFirst) { 569 var index = this.indexOf(value); 570 if (index !== -1) 571 this.splice(index, 1); 572 return; 573 } 574 575 var length = this.length; 576 for (var i = 0; i < length; ++i) { 577 if (this[i] === value) 578 this.splice(i, 1); 579 } 580 } 581 }); 582 583 Object.defineProperty(Array.prototype, "keySet", 584 { 585 /** 586 * @this {Array.<*>} 587 */ 588 value: function() 589 { 590 var keys = {}; 591 for (var i = 0; i < this.length; ++i) 592 keys[this[i]] = true; 593 return keys; 594 } 595 }); 596 597 Object.defineProperty(Array.prototype, "upperBound", 598 { 599 /** 600 * @this {Array.<number>} 601 */ 602 value: function(value) 603 { 604 var first = 0; 605 var count = this.length; 606 while (count > 0) { 607 var step = count >> 1; 608 var middle = first + step; 609 if (value >= this[middle]) { 610 first = middle + 1; 611 count -= step + 1; 612 } else 613 count = step; 614 } 615 return first; 616 } 617 }); 750 618 751 619 Array.diff = function(left, right) … … 833 701 if (!isNaN(format[index])) { 834 702 // The first character is a number, it might be a substitution index. 835 var number = parseInt(format.substring(index) );703 var number = parseInt(format.substring(index), 10); 836 704 while (!isNaN(format[index])) 837 705 ++index; … … 849 717 // then the precision should be zero. 850 718 ++index; 851 precision = parseInt(format.substring(index) );719 precision = parseInt(format.substring(index), 10); 852 720 if (isNaN(precision)) 853 721 precision = 0; … … 870 738 d: function(substitution) 871 739 { 872 if (typeof substitution == "object" && WebInspector.RemoteObject.type(substitution) === "number")873 substitution = substitution.description;874 substitution = parseInt(substitution);875 740 return !isNaN(substitution) ? substitution : 0; 876 741 }, … … 878 743 f: function(substitution, token) 879 744 { 880 if (typeof substitution == "object" && WebInspector.RemoteObject.type(substitution) === "number")881 substitution = substitution.description;882 substitution = parseFloat(substitution);883 745 if (substitution && token.precision > -1) 884 746 substitution = substitution.toFixed(token.precision); … … 888 750 s: function(substitution) 889 751 { 890 if (typeof substitution == "object" && WebInspector.RemoteObject.type(substitution) !== "null")891 substitution = substitution.description;892 752 return substitution; 893 } ,894 } ;753 } 754 } 895 755 896 756 String.vsprintf = function(format, substitutions) … … 1049 909 textNode = textNodeSnapshot.snapshotItem(currentSnapshotItem++); 1050 910 snapshotNodeOffset += textNode.nodeValue.length; 1051 vartext = textNode.textContent;911 text = textNode.textContent; 1052 912 if (length < text.length) { 1053 913 textNode.textContent = text.substring(length); … … 1103 963 { 1104 964 // This should be kept the same as the one in InspectorPageAgent.cpp. 1105 regexSpecialCharacters = "[](){}+-*.,?\\^$|";965 var regexSpecialCharacters = "[](){}+-*.,?\\^$|"; 1106 966 var regex = ""; 1107 967 for (var i = 0; i < query.length; ++i) { 1108 var c har= query.charAt(i);1109 if (regexSpecialCharacters.indexOf(c har) != -1)968 var c = query.charAt(i); 969 if (regexSpecialCharacters.indexOf(c) != -1) 1110 970 regex += "\\"; 1111 regex += c har;971 regex += c; 1112 972 } 1113 973 return new RegExp(regex, "i" + (extraFlags || ""));
Note: See TracChangeset
for help on using the changeset viewer.