Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ³ ].A ^. _.ä4 `.kï a.È! b.–K" c.º·" d.ZÌ" e.–Þ" f.J# g.z# h.0# i.*?# j.KL# k.·# l.öœ# m.â°# n.™Â# o.cÎ# p.9ð# q. $ r.Ó$ s.,$ t.ñ4$ u.©F$ v.õ$ w.¼†$ x.”‡$ y.™ˆ$ z.Ÿ‰$ {.E‹$ |.ãŒ$ }.5$ ~.¦Ž$ .3—$ €.èœ$ .ž$ ‚.çž$ ƒ._Ÿ$ „.\ $ ….R¡$ †.Š¢$ ‡.8£$ ˆ.#¤$ ‰.¤$ Š.>¥$ ‹.¦$ Œ.“¦$ .™§$ Ž.9¨$ .â¨$ .i©$ ‘. ¬$ ’.€$ “.°$ ”.¾±$ •.”²$ –.v´$ —.Ý´$ ˜.Dµ$ ™.½µ$ š.6¶$ ›.ȶ$ œ.h·$ . ¸$ ž.î¿$ Ÿ.Ä$ .ÖÇ$ ¡.óË$ ¢.Í$ £.Î$ ¤.ûÐ$ ¥.PÑ$ ¦.¥Ñ$ §.úÞ$ ¨.¼í$ ©.î$ ª.êò$ «.L÷$ ¬.nù$ .%% ®.ó% ¯.
- % °.:% ±.³% ².Ø´% ³.¸µ% ´.Ù¹% µ.¬½% ¶.J¾% ·.¥Á% ¸.Ã% ¹.¡Ã% º. Ê% ».œÏ% ¼.x& ½.9y& ¾.iz& ¿.q{& À.J|& Á.s}& Â. ~& Ã.@& Ä.Ñ& Å.& Æ.‘& Ç.¾…& È.RŒ& É.Ú˜& Ê.b¥& Ë.ê±& Ì.r¾& Í./¿& Î.¿& Ï.zÏ& Ð./ß& Ñ.Äø& Ò.œù& Ó.äú& Ô.ü& Õ.eü& Ö.Áü& ×.þ& Ø.D' Ù.{' Ú.' Û.¯' Ü.ä
- ' Ý.
- ' Þ.S' ß._%' à.ª1' á.¹=' â.J' ã.AV' ä.rb' å.Fo' æ.<x' ç.Ù…' è.S“' é.ë ' ê.ƒ®' ë.¼' ì.µÉ' í.E×' î.ä' ï.‹ñ' ð.¡þ' ñ.º( ò.á( ó.ï%( ô.ö2( õ.Õ«( ö.÷) ÷. ) ø.) ù.H
- ) ú.î
- ) û.‚) ü.) ý.«) þ._) ÿ.) /¾) /`) /=) /N) /ž) /‚) /ª) /^0) /{@) /‹P)
- /r`) /ˆp) /)
- /¢‘) /{¢) /U´) Å) <!--
- Copyright (C) 2006, 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.
- -->
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="devTools.css">
- <script type="text/javascript" src="DevTools.js"></script>
- </head>
- <body class="detached" id="-webkit-web-inspector">
- <div id="toolbar">
- <div class="toolbar-item close-left"><button id="close-button-left"></button></div>
- <div id="toolbar-controls">
- <div class="toolbar-item"><button id="toolbar-dropdown-arrow" class="toolbar-label">»</button></div>
- <div class="toolbar-item hidden" id="search-results-matches"></div>
- <div class="toolbar-item toolbar-search-item"><input id="search" type="search" incremental results="0"><div id="search-toolbar-label" class="toolbar-label"></div></div>
- <div class="toolbar-item close-right"><button id="close-button-right"></button></div>
- </div>
- </div>
- <div id="main">
- <div id="main-status-bar" class="status-bar"><div id="anchored-status-bar-items"><div id="counters"><div id="error-warning-count" class="hidden"></div></div></div></div>
- </div>
- <div id="drawer"></div>
- </body>
- </html>
- Node.prototype.rangeOfWord = function(offset, stopCharacters, stayWithinNode, direction)
- {
- var startNode;
- var startOffset = 0;
- var endNode;
- var endOffset = 0;
- if (!stayWithinNode)
- stayWithinNode = this;
- if (!direction || direction === "backward" || direction === "both") {
- var node = this;
- while (node) {
- if (node === stayWithinNode) {
- if (!startNode)
- startNode = stayWithinNode;
- break;
- }
- if (node.nodeType === Node.TEXT_NODE) {
- var start = (node === this ? (offset - 1) : (node.nodeValue.length - 1));
- for (var i = start; i >= 0; --i) {
- if (stopCharacters.indexOf(node.nodeValue[i]) !== -1) {
- startNode = node;
- startOffset = i + 1;
- break;
- }
- }
- }
- if (startNode)
- break;
- node = node.traversePreviousNode(stayWithinNode);
- }
- if (!startNode) {
- startNode = stayWithinNode;
- startOffset = 0;
- }
- } else {
- startNode = this;
- startOffset = offset;
- }
- if (!direction || direction === "forward" || direction === "both") {
- node = this;
- while (node) {
- if (node === stayWithinNode) {
- if (!endNode)
- endNode = stayWithinNode;
- break;
- }
- if (node.nodeType === Node.TEXT_NODE) {
- var start = (node === this ? offset : 0);
- for (var i = start; i < node.nodeValue.length; ++i) {
- if (stopCharacters.indexOf(node.nodeValue[i]) !== -1) {
- endNode = node;
- endOffset = i;
- break;
- }
- }
- }
- if (endNode)
- break;
- node = node.traverseNextNode(stayWithinNode);
- }
- if (!endNode) {
- endNode = stayWithinNode;
- endOffset = stayWithinNode.nodeType === Node.TEXT_NODE ? stayWithinNode.nodeValue.length : stayWithinNode.childNodes.length;
- }
- } else {
- endNode = this;
- endOffset = offset;
- }
- var result = this.ownerDocument.createRange();
- result.setStart(startNode, startOffset);
- result.setEnd(endNode, endOffset);
- return result;
- }
- Node.prototype.traverseNextTextNode = function(stayWithin)
- {
- var node = this.traverseNextNode(stayWithin);
- if (!node)
- return;
- while (node && node.nodeType !== Node.TEXT_NODE)
- node = node.traverseNextNode(stayWithin);
- return node;
- }
- Node.prototype.rangeBoundaryForOffset = function(offset)
- {
- var node = this.traverseNextTextNode(this);
- while (node && offset > node.nodeValue.length) {
- offset -= node.nodeValue.length;
- node = node.traverseNextTextNode(this);
- }
- if (!node)
- return { container: this, offset: 0 };
- return { container: node, offset: offset };
- }
- Element.prototype.removeStyleClass = function(className)
- {
- this.classList.remove(className);
- }
- Element.prototype.removeMatchingStyleClasses = function(classNameRegex)
- {
- var regex = new RegExp("(^|\\s+)" + classNameRegex + "($|\\s+)");
- if (regex.test(this.className))
- this.className = this.className.replace(regex, " ");
- }
- Element.prototype.addStyleClass = function(className)
- {
- this.classList.add(className);
- }
- Element.prototype.hasStyleClass = function(className)
- {
- return this.classList.contains(className);
- }
- Element.prototype.positionAt = function(x, y)
- {
- this.style.left = x + "px";
- this.style.top = y + "px";
- }
- Element.prototype.pruneEmptyTextNodes = function()
- {
- var sibling = this.firstChild;
- while (sibling) {
- var nextSibling = sibling.nextSibling;
- if (sibling.nodeType === this.TEXT_NODE && sibling.nodeValue === "")
- this.removeChild(sibling);
- sibling = nextSibling;
- }
- }
- Element.prototype.isScrolledToBottom = function()
- {
- return this.scrollTop + this.clientHeight === this.scrollHeight;
- }
- Node.prototype.enclosingNodeOrSelfWithNodeNameInArray = function(nameArray)
- {
- for (var node = this; node && node !== this.ownerDocument; node = node.parentNode)
- for (var i = 0; i < nameArray.length; ++i)
- if (node.nodeName.toLowerCase() === nameArray[i].toLowerCase())
- return node;
- return null;
- }
- Node.prototype.enclosingNodeOrSelfWithNodeName = function(nodeName)
- {
- return this.enclosingNodeOrSelfWithNodeNameInArray([nodeName]);
- }
- Node.prototype.enclosingNodeOrSelfWithClass = function(className)
- {
- for (var node = this; node && node !== this.ownerDocument; node = node.parentNode)
- if (node.nodeType === Node.ELEMENT_NODE && node.hasStyleClass(className))
- return node;
- return null;
- }
- Node.prototype.enclosingNodeWithClass = function(className)
- {
- if (!this.parentNode)
- return null;
- return this.parentNode.enclosingNodeOrSelfWithClass(className);
- }
- Element.prototype.query = function(query)
- {
- return this.ownerDocument.evaluate(query, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
- }
- Element.prototype.removeChildren = function()
- {
- if (this.firstChild)
- this.textContent = "";
- }
- Element.prototype.isInsertionCaretInside = function()
- {
- var selection = window.getSelection();
- if (!selection.rangeCount || !selection.isCollapsed)
- return false;
- var selectionRange = selection.getRangeAt(0);
- return selectionRange.startContainer.isSelfOrDescendant(this);
- }
- Element.prototype.createChild = function(elementName, className)
- {
- var element = this.ownerDocument.createElement(elementName);
- if (className)
- element.className = className;
- this.appendChild(element);
- return element;
- }
- DocumentFragment.prototype.createChild = Element.prototype.createChild;
- Element.prototype.totalOffsetLeft = function()
- {
- return this.totalOffset().left;
- }
- Element.prototype.totalOffsetTop = function()
- {
- return this.totalOffset().top;
- }
- Element.prototype.totalOffset = function()
- {
- var totalLeft = 0;
- var totalTop = 0;
- for (var element = this; element; element = element.offsetParent) {
- totalLeft += element.offsetLeft;
- totalTop += element.offsetTop;
- if (this !== element) {
- totalLeft += element.clientLeft - element.scrollLeft;
- totalTop += element.clientTop - element.scrollTop;
- }
- }
- return { left: totalLeft, top: totalTop };
- }
- Element.prototype.scrollOffset = function()
- {
- var curLeft = 0;
- var curTop = 0;
- for (var element = this; element; element = element.scrollParent) {
- curLeft += element.scrollLeft;
- curTop += element.scrollTop;
- }
- return { left: curLeft, top: curTop };
- }
- function AnchorBox(x, y, width, height)
- {
- this.x = x || 0;
- this.y = y || 0;
- this.width = width || 0;
- this.height = height || 0;
- }
- Element.prototype.offsetRelativeToWindow = function(targetWindow)
- {
- var elementOffset = new AnchorBox();
- var curElement = this;
- var curWindow = this.ownerDocument.defaultView;
- while (curWindow && curElement) {
- elementOffset.x += curElement.totalOffsetLeft();
- elementOffset.y += curElement.totalOffsetTop();
- if (curWindow === targetWindow)
- break;
- curElement = curWindow.frameElement;
- curWindow = curWindow.parent;
- }
- return elementOffset;
- }
- Element.prototype.boxInWindow = function(targetWindow)
- {
- targetWindow = targetWindow || this.ownerDocument.defaultView;
- var anchorBox = this.offsetRelativeToWindow(window);
- anchorBox.width = Math.min(this.offsetWidth, window.innerWidth - anchorBox.x);
- anchorBox.height = Math.min(this.offsetHeight, window.innerHeight - anchorBox.y);
- return anchorBox;
- }
- Element.prototype.setTextAndTitle = function(text)
- {
- this.textContent = text;
- this.title = text;
- }
- KeyboardEvent.prototype.__defineGetter__("data", function()
- {
- switch (this.type) {
- case "keypress":
- if (!this.ctrlKey && !this.metaKey)
- return String.fromCharCode(this.charCode);
- else
- return "";
- case "keydown":
- case "keyup":
- if (!this.ctrlKey && !this.metaKey && !this.altKey)
- return String.fromCharCode(this.which);
- else
- return "";
- }
- });
- Event.prototype.consume = function(preventDefault)
- {
- this.stopImmediatePropagation();
- if (preventDefault)
- this.preventDefault();
- this.handled = true;
- }
- Text.prototype.select = function(start, end)
- {
- start = start || 0;
- end = end || this.textContent.length;
- if (start < 0)
- start = end + start;
- var selection = this.ownerDocument.defaultView.getSelection();
- selection.removeAllRanges();
- var range = this.ownerDocument.createRange();
- range.setStart(this, start);
- range.setEnd(this, end);
- selection.addRange(range);
- return this;
- }
- Element.prototype.selectionLeftOffset = function()
- {
- var selection = window.getSelection();
- if (!selection.containsNode(this, true))
- return null;
- var leftOffset = selection.anchorOffset;
- var node = selection.anchorNode;
- while (node !== this) {
- while (node.previousSibling) {
- node = node.previousSibling;
- leftOffset += node.textContent.length;
- }
- node = node.parentNode;
- }
- return leftOffset;
- }
- String.prototype.hasSubstring = function(string, caseInsensitive)
- {
- if (!caseInsensitive)
- return this.indexOf(string) !== -1;
- return this.match(new RegExp(string.escapeForRegExp(), "i"));
- }
- String.prototype.findAll = function(string)
- {
- var matches = [];
- var i = this.indexOf(string);
- while (i !== -1) {
- matches.push(i);
- i = this.indexOf(string, i + string.length);
- }
- return matches;
- }
- String.prototype.lineEndings = function()
- {
- if (!this._lineEndings) {
- this._lineEndings = this.findAll("\n");
- this._lineEndings.push(this.length);
- }
- return this._lineEndings;
- }
- String.prototype.asParsedURL = function()
- {
- var match = this.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
- if (!match) {
- if (this == "about:blank") {
- return { scheme: "about",
- host: "blank",
- path: "/",
- lastPathComponent: ""};
- }
- return null;
- }
- var result = {};
- result.scheme = match[1].toLowerCase();
- result.host = match[2];
- result.port = match[3];
- result.path = match[4] || "/";
- result.fragment = match[5];
- result.lastPathComponent = "";
- if (result.path) {
- var path = result.path;
- var indexOfQuery = path.indexOf("?");
- if (indexOfQuery !== -1)
- path = path.substring(0, indexOfQuery);
- var lastSlashIndex = path.lastIndexOf("/");
- if (lastSlashIndex !== -1) {
- result.firstPathComponents = path.substring(0, lastSlashIndex + 1);
- result.lastPathComponent = path.substring(lastSlashIndex + 1);
- }
- }
- return result;
- }
- String.prototype.escapeCharacters = function(chars)
- {
- var foundChar = false;
- for (var i = 0; i < chars.length; ++i) {
- if (this.indexOf(chars.charAt(i)) !== -1) {
- foundChar = true;
- break;
- }
- }
- if (!foundChar)
- return this;
- var result = "";
- for (var i = 0; i < this.length; ++i) {
- if (chars.indexOf(this.charAt(i)) !== -1)
- result += "\\";
- result += this.charAt(i);
- }
- return result;
- }
- String.prototype.escapeForRegExp = function()
- {
- return this.escapeCharacters("^[]{}()\\.$*+?|");
- }
- String.prototype.escapeHTML = function()
- {
- return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
- }
- String.prototype.collapseWhitespace = function()
- {
- return this.replace(/[\s\xA0]+/g, " ");
- }
- String.prototype.trimMiddle = function(maxLength)
- {
- if (this.length <= maxLength)
- return this;
- var leftHalf = maxLength >> 1;
- var rightHalf = maxLength - leftHalf - 1;
- return this.substr(0, leftHalf) + "\u2026" + this.substr(this.length - rightHalf, rightHalf);
- }
- String.prototype.trimEnd = function(maxLength)
- {
- if (this.length <= maxLength)
- return this;
- return this.substr(0, maxLength - 1) + "\u2026";
- }
- String.prototype.trimURL = function(baseURLDomain)
- {
- var result = this.replace(/^(https|http|file):\/\//i, "");
- if (baseURLDomain)
- result = result.replace(new RegExp("^" + baseURLDomain.escapeForRegExp(), "i"), "");
- return result;
- }
- String.prototype.removeURLFragment = function()
- {
- var fragmentIndex = this.indexOf("#");
- if (fragmentIndex == -1)
- fragmentIndex = this.length;
- return this.substring(0, fragmentIndex);
- }
- Node.prototype.isAncestor = function(node)
- {
- if (!node)
- return false;
- var currentNode = node.parentNode;
- while (currentNode) {
- if (this === currentNode)
- return true;
- currentNode = currentNode.parentNode;
- }
- return false;
- }
- Node.prototype.isDescendant = function(descendant)
- {
- return !!descendant && descendant.isAncestor(this);
- }
- Node.prototype.isSelfOrAncestor = function(node)
- {
- return !!node && (node === this || this.isAncestor(node));
- }
- Node.prototype.isSelfOrDescendant = function(node)
- {
- return !!node && (node === this || this.isDescendant(node));
- }
- Node.prototype.traverseNextNode = function(stayWithin)
- {
- var node = this.firstChild;
- if (node)
- return node;
- if (stayWithin && this === stayWithin)
- return null;
- node = this.nextSibling;
- if (node)
- return node;
- node = this;
- while (node && !node.nextSibling && (!stayWithin || !node.parentNode || node.parentNode !== stayWithin))
- node = node.parentNode;
- if (!node)
- return null;
- return node.nextSibling;
- }
- Node.prototype.traversePreviousNode = function(stayWithin)
- {
- if (stayWithin && this === stayWithin)
- return null;
- var node = this.previousSibling;
- while (node && node.lastChild)
- node = node.lastChild;
- if (node)
- return node;
- return this.parentNode;
- }
- Number.constrain = function(num, min, max)
- {
- if (num < min)
- num = min;
- else if (num > max)
- num = max;
- return num;
- }
- Date.prototype.toISO8601Compact = function()
- {
- function leadZero(x)
- {
- return x > 9 ? '' + x : '0' + x
- }
- return this.getFullYear() +
- leadZero(this.getMonth() + 1) +
- leadZero(this.getDate()) + 'T' +
- leadZero(this.getHours()) +
- leadZero(this.getMinutes()) +
- leadZero(this.getSeconds());
- }
- HTMLTextAreaElement.prototype.moveCursorToEnd = function()
- {
- var length = this.value.length;
- this.setSelectionRange(length, length);
- }
- Object.defineProperty(Array.prototype, "remove",
- {
- value: function(value, onlyFirst)
- {
- if (onlyFirst) {
- var index = this.indexOf(value);
- if (index !== -1)
- this.splice(index, 1);
- return;
- }
- var length = this.length;
- for (var i = 0; i < length; ++i) {
- if (this[i] === value)
- this.splice(i, 1);
- }
- }
- });
- Object.defineProperty(Array.prototype, "keySet",
- {
- value: function()
- {
- var keys = {};
- for (var i = 0; i < this.length; ++i)
- keys[this[i]] = true;
- return keys;
- }
- });
- Object.defineProperty(Array.prototype, "upperBound",
- {
- value: function(value)
- {
- var first = 0;
- var count = this.length;
- while (count > 0) {
- var step = count >> 1;
- var middle = first + step;
- if (value >= this[middle]) {
- first = middle + 1;
- count -= step + 1;
- } else
- count = step;
- }
- return first;
- }
- });
- Array.diff = function(left, right)
- {
- var o = left;
- var n = right;
- var ns = {};
- var os = {};
- for (var i = 0; i < n.length; i++) {
- if (ns[n[i]] == null)
- ns[n[i]] = { rows: [], o: null };
- ns[n[i]].rows.push(i);
- }
- for (var i = 0; i < o.length; i++) {
- if (os[o[i]] == null)
- os[o[i]] = { rows: [], n: null };
- os[o[i]].rows.push(i);
- }
- for (var i in ns) {
- if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
- n[ns[i].rows[0]] = { text: n[ns[i].rows[0]], row: os[i].rows[0] };
- o[os[i].rows[0]] = { text: o[os[i].rows[0]], row: ns[i].rows[0] };
- }
- }
- for (var i = 0; i < n.length - 1; i++) {
- if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null && n[i + 1] == o[n[i].row + 1]) {
- n[i + 1] = { text: n[i + 1], row: n[i].row + 1 };
- o[n[i].row + 1] = { text: o[n[i].row + 1], row: i + 1 };
- }
- }
- for (var i = n.length - 1; i > 0; i--) {
- if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&
- n[i - 1] == o[n[i].row - 1]) {
- n[i - 1] = { text: n[i - 1], row: n[i].row - 1 };
- o[n[i].row - 1] = { text: o[n[i].row - 1], row: i - 1 };
- }
- }
- return { left: o, right: n };
- }
- Array.convert = function(list)
- {
- return Array.prototype.slice.call(list);
- }
- String.sprintf = function(format, var_arg)
- {
- return String.vsprintf(format, Array.prototype.slice.call(arguments, 1));
- }
- String.tokenizeFormatString = function(format, formatters)
- {
- var tokens = [];
- var substitutionIndex = 0;
- function addStringToken(str)
- {
- tokens.push({ type: "string", value: str });
- }
- function addSpecifierToken(specifier, precision, substitutionIndex)
- {
- tokens.push({ type: "specifier", specifier: specifier, precision: precision, substitutionIndex: substitutionIndex });
- }
- function isDigit(c)
- {
- return !!/[0-9]/.exec(c);
- }
- var index = 0;
- for (var precentIndex = format.indexOf("%", index); precentIndex !== -1; precentIndex = format.indexOf("%", index)) {
- addStringToken(format.substring(index, precentIndex));
- index = precentIndex + 1;
- if (isDigit(format[index])) {
- var number = parseInt(format.substring(index), 10);
- while (isDigit(format[index]))
- ++index;
- if (number > 0 && format[index] === "$") {
- substitutionIndex = (number - 1);
- ++index;
- }
- }
- var precision = -1;
- if (format[index] === ".") {
- ++index;
- precision = parseInt(format.substring(index), 10);
- if (isNaN(precision))
- precision = 0;
- while (isDigit(format[index]))
- ++index;
- }
- if (!(format[index] in formatters)) {
- addStringToken(format.substring(precentIndex, index + 1));
- ++index;
- continue;
- }
- addSpecifierToken(format[index], precision, substitutionIndex);
- ++substitutionIndex;
- ++index;
- }
- addStringToken(format.substring(index));
- return tokens;
- }
- String.standardFormatters = {
- d: function(substitution)
- {
- return !isNaN(substitution) ? substitution : 0;
- },
- f: function(substitution, token)
- {
- if (substitution && token.precision > -1)
- substitution = substitution.toFixed(token.precision);
- return !isNaN(substitution) ? substitution : (token.precision > -1 ? Number(0).toFixed(token.precision) : 0);
- },
- s: function(substitution)
- {
- return substitution;
- }
- }
- String.vsprintf = function(format, substitutions)
- {
- return String.format(format, substitutions, String.standardFormatters, "", function(a, b) { return a + b; }).formattedResult;
- }
- String.format = function(format, substitutions, formatters, initialValue, append)
- {
- if (!format || !substitutions || !substitutions.length)
- return { formattedResult: append(initialValue, format), unusedSubstitutions: substitutions };
- function prettyFunctionName()
- {
- return "String.format(\"" + format + "\", \"" + substitutions.join("\", \"") + "\")";
- }
- function warn(msg)
- {
- console.warn(prettyFunctionName() + ": " + msg);
- }
- function error(msg)
- {
- console.error(prettyFunctionName() + ": " + msg);
- }
- var result = initialValue;
- var tokens = String.tokenizeFormatString(format, formatters);
- var usedSubstitutionIndexes = {};
- for (var i = 0; i < tokens.length; ++i) {
- var token = tokens[i];
- if (token.type === "string") {
- result = append(result, token.value);
- continue;
- }
- if (token.type !== "specifier") {
- error("Unknown token type \"" + token.type + "\" found.");
- continue;
- }
- if (token.substitutionIndex >= substitutions.length) {
- error("not enough substitution arguments. Had " + substitutions.length + " but needed " + (token.substitutionIndex + 1) + ", so substitution was skipped.");
- result = append(result, "%" + (token.precision > -1 ? token.precision : "") + token.specifier);
- continue;
- }
- usedSubstitutionIndexes[token.substitutionIndex] = true;
- if (!(token.specifier in formatters)) {
- warn("unsupported format character \u201C" + token.specifier + "\u201D. Treating as a string.");
- result = append(result, substitutions[token.substitutionIndex]);
- continue;
- }
- result = append(result, formatters[token.specifier](substitutions[token.substitutionIndex], token));
- }
- var unusedSubstitutions = [];
- for (var i = 0; i < substitutions.length; ++i) {
- if (i in usedSubstitutionIndexes)
- continue;
- unusedSubstitutions.push(substitutions[i]);
- }
- return { formattedResult: result, unusedSubstitutions: unusedSubstitutions };
- }
- function isEnterKey(event) {
- return event.keyCode !== 229 && event.keyIdentifier === "Enter";
- }
- function consumeEvent(e)
- {
- e.consume();
- }
- function highlightSearchResult(element, offset, length, domChanges)
- {
- var result = highlightSearchResults(element, [{offset: offset, length: length }], domChanges);
- return result.length ? result[0] : null;
- }
- function highlightSearchResults(element, resultRanges, changes)
- {
- return highlightRangesWithStyleClass(element, resultRanges, "webkit-search-result", changes);
- }
- function highlightRangesWithStyleClass(element, resultRanges, styleClass, changes)
- {
- changes = changes || [];
- var highlightNodes = [];
- var lineText = element.textContent;
- var ownerDocument = element.ownerDocument;
- var textNodeSnapshot = ownerDocument.evaluate(".//text()", element, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
- var snapshotLength = textNodeSnapshot.snapshotLength;
- if (snapshotLength === 0)
- return highlightNodes;
- var nodeRanges = [];
- var rangeEndOffset = 0;
- for (var i = 0; i < snapshotLength; ++i) {
- var range = {};
- range.offset = rangeEndOffset;
- range.length = textNodeSnapshot.snapshotItem(i).textContent.length;
- rangeEndOffset = range.offset + range.length;
- nodeRanges.push(range);
- }
- var startIndex = 0;
- for (var i = 0; i < resultRanges.length; ++i) {
- var startOffset = resultRanges[i].offset;
- var endOffset = startOffset + resultRanges[i].length;
- while (startIndex < snapshotLength && nodeRanges[startIndex].offset + nodeRanges[startIndex].length <= startOffset)
- startIndex++;
- var endIndex = startIndex;
- while (endIndex < snapshotLength && nodeRanges[endIndex].offset + nodeRanges[endIndex].length < endOffset)
- endIndex++;
- if (endIndex === snapshotLength)
- break;
- var highlightNode = ownerDocument.createElement("span");
- highlightNode.className = styleClass;
- highlightNode.textContent = lineText.substring(startOffset, endOffset);
- var lastTextNode = textNodeSnapshot.snapshotItem(endIndex);
- var lastText = lastTextNode.textContent;
- lastTextNode.textContent = lastText.substring(endOffset - nodeRanges[endIndex].offset);
- changes.push({ node: lastTextNode, type: "changed", oldText: lastText, newText: lastTextNode.textContent });
- if (startIndex === endIndex) {
- lastTextNode.parentElement.insertBefore(highlightNode, lastTextNode);
- changes.push({ node: highlightNode, type: "added", nextSibling: lastTextNode, parent: lastTextNode.parentElement });
- highlightNodes.push(highlightNode);
- var prefixNode = ownerDocument.createTextNode(lastText.substring(0, startOffset - nodeRanges[startIndex].offset));
- lastTextNode.parentElement.insertBefore(prefixNode, highlightNode);
- changes.push({ node: prefixNode, type: "added", nextSibling: highlightNode, parent: lastTextNode.parentElement });
- } else {
- var firstTextNode = textNodeSnapshot.snapshotItem(startIndex);
- var firstText = firstTextNode.textContent;
- var anchorElement = firstTextNode.nextSibling;
- firstTextNode.parentElement.insertBefore(highlightNode, anchorElement);
- changes.push({ node: highlightNode, type: "added", nextSibling: anchorElement, parent: firstTextNode.parentElement });
- highlightNodes.push(highlightNode);
- firstTextNode.textContent = firstText.substring(0, startOffset - nodeRanges[startIndex].offset);
- changes.push({ node: firstTextNode, type: "changed", oldText: firstText, newText: firstTextNode.textContent });
- for (var j = startIndex + 1; j < endIndex; j++) {
- var textNode = textNodeSnapshot.snapshotItem(j);
- var text = textNode.textContent;
- textNode.textContent = "";
- changes.push({ node: textNode, type: "changed", oldText: text, newText: textNode.textContent });
- }
- }
- startIndex = endIndex;
- nodeRanges[startIndex].offset = endOffset;
- nodeRanges[startIndex].length = lastTextNode.textContent.length;
- }
- return highlightNodes;
- }
- function applyDomChanges(domChanges)
- {
- for (var i = 0, size = domChanges.length; i < size; ++i) {
- var entry = domChanges[i];
- switch (entry.type) {
- case "added":
- entry.parent.insertBefore(entry.node, entry.nextSibling);
- break;
- case "changed":
- entry.node.textContent = entry.newText;
- break;
- }
- }
- }
- function revertDomChanges(domChanges)
- {
- for (var i = domChanges.length - 1; i >= 0; --i) {
- var entry = domChanges[i];
- switch (entry.type) {
- case "added":
- if (entry.node.parentElement)
- entry.node.parentElement.removeChild(entry.node);
- break;
- case "changed":
- entry.node.textContent = entry.oldText;
- break;
- }
- }
- }
- function createSearchRegex(query, caseSensitive, isRegex)
- {
- var regexFlags = caseSensitive ? "g" : "gi";
- var regexObject;
- if (isRegex) {
- try {
- regexObject = new RegExp(query, regexFlags);
- } catch (e) {
- }
- }
- if (!regexObject)
- regexObject = createPlainTextSearchRegex(query, regexFlags);
- return regexObject;
- }
- function createPlainTextSearchRegex(query, flags)
- {
- var regexSpecialCharacters = "[](){}+-*.,?\\^$|";
- var regex = "";
- for (var i = 0; i < query.length; ++i) {
- var c = query.charAt(i);
- if (regexSpecialCharacters.indexOf(c) != -1)
- regex += "\\";
- regex += c;
- }
- return new RegExp(regex, flags || "");
- }
- function countRegexMatches(regex, content)
- {
- var text = content;
- var result = 0;
- var match;
- while (text && (match = regex.exec(text))) {
- if (match[0].length > 0)
- ++result;
- text = text.substring(match.index + 1);
- }
- return result;
- }
- function numberToStringWithSpacesPadding(value, symbolsCount)
- {
- var numberString = value.toString();
- var paddingLength = Math.max(0, symbolsCount - numberString.length);
- var paddingString = Array(paddingLength + 1).join("\u00a0");
- return paddingString + numberString;
- }
- function TextDiff()
- {
- this.added = [];
- this.removed = [];
- this.changed = [];
- }
- TextDiff.compute = function(baseContent, newContent)
- {
- var oldLines = baseContent.split(/\r?\n/);
- var newLines = newContent.split(/\r?\n/);
- var diff = Array.diff(oldLines, newLines);
- var diffData = new TextDiff();
- var offset = 0;
- var right = diff.right;
- for (var i = 0; i < right.length; ++i) {
- if (typeof right[i] === "string") {
- if (right.length > i + 1 && right[i + 1].row === i + 1 - offset)
- diffData.changed.push(i);
- else {
- diffData.added.push(i);
- offset++;
- }
- } else
- offset = i - right[i].row;
- }
- return diffData;
- }
- var Map = function()
- {
- this._map = {};
- }
- Map._lastObjectIdentifier = 0;
- Map.prototype = {
- put: function(key, value)
- {
- var objectIdentifier = key.__identifier;
- if (!objectIdentifier) {
- objectIdentifier = ++Map._lastObjectIdentifier;
- key.__identifier = objectIdentifier;
- }
- this._map[objectIdentifier] = value;
- },
- remove: function(key)
- {
- delete this._map[key.__identifier];
- },
- values: function()
- {
- var result = [];
- for (var objectIdentifier in this._map)
- result.push(this._map[objectIdentifier]);
- return result;
- },
- get: function(key)
- {
- return this._map[key.__identifier];
- },
- clear: function()
- {
- this._map = {};
- }
- }
- function binarySearch(object, array, comparator)
- {
- var first = 0;
- var last = array.length - 1;
- while (first <= last) {
- var mid = (first + last) >> 1;
- var c = comparator(object, array[mid]);
- if (c > 0)
- first = mid + 1;
- else if (c < 0)
- last = mid - 1;
- else
- return mid;
- }
- return -(first + 1);
- }
- Object.defineProperty(Array.prototype, "binaryIndexOf", { value: function(value, comparator)
- {
- var result = binarySearch(value, this, comparator);
- return result >= 0 ? result : -1;
- }});
- function insertionIndexForObjectInListSortedByFunction(anObject, aList, aFunction)
- {
- var index = binarySearch(anObject, aList, aFunction);
- if (index < 0)
- return -index - 1;
- else {
- while (index > 0 && aFunction(anObject, aList[index - 1]) === 0)
- index--;
- return index;
- }
- }
- function TreeOutline(listNode, nonFocusable)
- {
- this.children = [];
- this.selectedTreeElement = null;
- this._childrenListNode = listNode;
- this.childrenListElement = this._childrenListNode;
- this._childrenListNode.removeChildren();
- this.expandTreeElementsWhenArrowing = false;
- this.root = true;
- this.hasChildren = false;
- this.expanded = true;
- this.selected = false;
- this.treeOutline = this;
- this.comparator = null;
- this.searchable = false;
- this.searchInputElement = null;
- this.setFocusable(!nonFocusable);
- this._childrenListNode.addEventListener("keydown", this._treeKeyDown.bind(this), true);
- this._childrenListNode.addEventListener("keypress", this._treeKeyPress.bind(this), true);
- this._treeElementsMap = new Map();
- this._expandedStateMap = new Map();
- }
- TreeOutline.prototype.setFocusable = function(focusable)
- {
- if (focusable)
- this._childrenListNode.setAttribute("tabIndex", 0);
- else
- this._childrenListNode.removeAttribute("tabIndex");
- }
- TreeOutline.prototype.appendChild = function(child)
- {
- var insertionIndex;
- if (this.treeOutline.comparator)
- insertionIndex = insertionIndexForObjectInListSortedByFunction(child, this.children, this.treeOutline.comparator);
- else
- insertionIndex = this.children.length;
- this.insertChild(child, insertionIndex);
- }
- TreeOutline.prototype.insertChild = function(child, index)
- {
- if (!child)
- throw("child can't be undefined or null");
- var previousChild = (index > 0 ? this.children[index - 1] : null);
- if (previousChild) {
- previousChild.nextSibling = child;
- child.previousSibling = previousChild;
- } else {
- child.previousSibling = null;
- }
- var nextChild = this.children[index];
- if (nextChild) {
- nextChild.previousSibling = child;
- child.nextSibling = nextChild;
- } else {
- child.nextSibling = null;
- }
- this.children.splice(index, 0, child);
- this.hasChildren = true;
- child.parent = this;
- child.treeOutline = this.treeOutline;
- child.treeOutline._rememberTreeElement(child);
- var current = child.children[0];
- while (current) {
- current.treeOutline = this.treeOutline;
- current.treeOutline._rememberTreeElement(current);
- current = current.traverseNextTreeElement(false, child, true);
- }
- if (child.hasChildren && typeof(child.treeOutline._expandedStateMap.get(child.representedObject)) !== "undefined")
- child.expanded = child.treeOutline._expandedStateMap.get(child.representedObject);
- if (!this._childrenListNode) {
- this._childrenListNode = this.treeOutline._childrenListNode.ownerDocument.createElement("ol");
- this._childrenListNode.parentTreeElement = this;
- this._childrenListNode.classList.add("children");
- if (this.hidden)
- this._childrenListNode.classList.add("hidden");
- }
- child._attach();
- if (this.treeOutline.onadd)
- this.treeOutline.onadd(child);
- }
- TreeOutline.prototype.removeChildAtIndex = function(childIndex)
- {
- if (childIndex < 0 || childIndex >= this.children.length)
- throw("childIndex out of range");
- var child = this.children[childIndex];
- this.children.splice(childIndex, 1);
- var parent = child.parent;
- if (child.deselect()) {
- if (child.previousSibling)
- child.previousSibling.select();
- else if (child.nextSibling)
- child.nextSibling.select();
- else
- parent.select();
- }
- if (child.previousSibling)
- child.previousSibling.nextSibling = child.nextSibling;
- if (child.nextSibling)
- child.nextSibling.previousSibling = child.previousSibling;
- if (child.treeOutline) {
- child.treeOutline._forgetTreeElement(child);
- child.treeOutline._forgetChildrenRecursive(child);
- }
- child._detach();
- child.treeOutline = null;
- child.parent = null;
- child.nextSibling = null;
- child.previousSibling = null;
- }
- TreeOutline.prototype.removeChild = function(child)
- {
- if (!child)
- throw("child can't be undefined or null");
- var childIndex = this.children.indexOf(child);
- if (childIndex === -1)
- throw("child not found in this node's children");
- this.removeChildAtIndex.call(this, childIndex);
- }
- TreeOutline.prototype.removeChildren = function()
- {
- for (var i = 0; i < this.children.length; ++i) {
- var child = this.children[i];
- child.deselect();
- if (child.treeOutline) {
- child.treeOutline._forgetTreeElement(child);
- child.treeOutline._forgetChildrenRecursive(child);
- }
- child._detach();
- child.treeOutline = null;
- child.parent = null;
- child.nextSibling = null;
- child.previousSibling = null;
- }
- this.children = [];
- }
- TreeOutline.prototype.removeChildrenRecursive = function()
- {
- var childrenToRemove = this.children;
- var child = this.children[0];
- while (child) {
- if (child.children.length)
- childrenToRemove = childrenToRemove.concat(child.children);
- child = child.traverseNextTreeElement(false, this, true);
- }
- for (var i = 0; i < childrenToRemove.length; ++i) {
- child = childrenToRemove[i];
- child.deselect();
- if (child.treeOutline)
- child.treeOutline._forgetTreeElement(child);
- child._detach();
- child.children = [];
- child.treeOutline = null;
- child.parent = null;
- child.nextSibling = null;
- child.previousSibling = null;
- }
- this.children = [];
- }
- TreeOutline.prototype._rememberTreeElement = function(element)
- {
- if (!this._treeElementsMap.get(element.representedObject))
- this._treeElementsMap.put(element.representedObject, []);
- var elements = this._treeElementsMap.get(element.representedObject);
- if (elements.indexOf(element) !== -1)
- return;
- elements.push(element);
- }
- TreeOutline.prototype._forgetTreeElement = function(element)
- {
- if (this._treeElementsMap.get(element.representedObject))
- this._treeElementsMap.get(element.representedObject).remove(element, true);
- }
- TreeOutline.prototype._forgetChildrenRecursive = function(parentElement)
- {
- var child = parentElement.children[0];
- while (child) {
- this._forgetTreeElement(child);
- child = child.traverseNextTreeElement(false, parentElement, true);
- }
- }
- TreeOutline.prototype.getCachedTreeElement = function(representedObject)
- {
- if (!representedObject)
- return null;
- var elements = this._treeElementsMap.get(representedObject);
- if (elements && elements.length)
- return elements[0];
- return null;
- }
- TreeOutline.prototype.findTreeElement = function(representedObject, isAncestor, getParent)
- {
- if (!representedObject)
- return null;
- var cachedElement = this.getCachedTreeElement(representedObject);
- if (cachedElement)
- return cachedElement;
- var item;
- var found = false;
- for (var i = 0; i < this.children.length; ++i) {
- item = this.children[i];
- if (item.representedObject === representedObject || isAncestor(item.representedObject, representedObject)) {
- found = true;
- break;
- }
- }
- if (!found)
- return null;
- var ancestors = [];
- var currentObject = representedObject;
- while (currentObject) {
- ancestors.unshift(currentObject);
- if (currentObject === item.representedObject)
- break;
- currentObject = getParent(currentObject);
- }
- for (var i = 0; i < ancestors.length; ++i) {
- if (ancestors[i] === representedObject)
- continue;
- item = this.findTreeElement(ancestors[i], isAncestor, getParent);
- if (item)
- item.onpopulate();
- }
- return this.getCachedTreeElement(representedObject);
- }
- TreeOutline.prototype._treeElementDidChange = function(treeElement)
- {
- if (treeElement.treeOutline !== this)
- return;
- if (this.onchange)
- this.onchange(treeElement);
- }
- TreeOutline.prototype.treeElementFromPoint = function(x, y)
- {
- var node = this._childrenListNode.ownerDocument.elementFromPoint(x, y);
- if (!node)
- return null;
- var listNode = node.enclosingNodeOrSelfWithNodeNameInArray(["ol", "li"]);
- if (listNode)
- return listNode.parentTreeElement || listNode.treeElement;
- return null;
- }
- TreeOutline.prototype._treeKeyPress = function(event)
- {
- if (!this.searchable || WebInspector.isBeingEdited(this._childrenListNode))
- return;
- var searchText = String.fromCharCode(event.charCode);
- if (searchText.trim() !== searchText)
- return;
- this._startSearch(searchText);
- event.consume(true);
- }
- TreeOutline.prototype._treeKeyDown = function(event)
- {
- if (event.target !== this._childrenListNode)
- return;
- if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ctrlKey)
- return;
- var handled = false;
- var nextSelectedElement;
- if (event.keyIdentifier === "Up" && !event.altKey) {
- nextSelectedElement = this.selectedTreeElement.traversePreviousTreeElement(true);
- while (nextSelectedElement && !nextSelectedElement.selectable)
- nextSelectedElement = nextSelectedElement.traversePreviousTreeElement(!this.expandTreeElementsWhenArrowing);
- handled = nextSelectedElement ? true : false;
- } else if (event.keyIdentifier === "Down" && !event.altKey) {
- nextSelectedElement = this.selectedTreeElement.traverseNextTreeElement(true);
- while (nextSelectedElement && !nextSelectedElement.selectable)
- nextSelectedElement = nextSelectedElement.traverseNextTreeElement(!this.expandTreeElementsWhenArrowing);
- handled = nextSelectedElement ? true : false;
- } else if (event.keyIdentifier === "Left") {
- if (this.selectedTreeElement.expanded) {
- if (event.altKey)
- this.selectedTreeElement.collapseRecursively();
- else
- this.selectedTreeElement.collapse();
- handled = true;
- } else if (this.selectedTreeElement.parent && !this.selectedTreeElement.parent.root) {
- handled = true;
- if (this.selectedTreeElement.parent.selectable) {
- nextSelectedElement = this.selectedTreeElement.parent;
- while (nextSelectedElement && !nextSelectedElement.selectable)
- nextSelectedElement = nextSelectedElement.parent;
- handled = nextSelectedElement ? true : false;
- } else if (this.selectedTreeElement.parent)
- this.selectedTreeElement.parent.collapse();
- }
- } else if (event.keyIdentifier === "Right") {
- if (!this.selectedTreeElement.revealed()) {
- this.selectedTreeElement.reveal();
- handled = true;
- } else if (this.selectedTreeElement.hasChildren) {
- handled = true;
- if (this.selectedTreeElement.expanded) {
- nextSelectedElement = this.selectedTreeElement.children[0];
- while (nextSelectedElement && !nextSelectedElement.selectable)
- nextSelectedElement = nextSelectedElement.nextSibling;
- handled = nextSelectedElement ? true : false;
- } else {
- if (event.altKey)
- this.selectedTreeElement.expandRecursively();
- else
- this.selectedTreeElement.expand();
- }
- }
- } else if (event.keyCode === 8 || event.keyCode === 46 ) {
- if (this.selectedTreeElement.ondelete)
- handled = this.selectedTreeElement.ondelete();
- } else if (isEnterKey(event)) {
- if (this.selectedTreeElement.onenter)
- handled = this.selectedTreeElement.onenter();
- } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code) {
- if (this.selectedTreeElement.onspace)
- handled = this.selectedTreeElement.onspace();
- }
- if (nextSelectedElement) {
- nextSelectedElement.reveal();
- nextSelectedElement.select(false, true);
- }
- if (handled)
- event.consume(true);
- }
- TreeOutline.prototype.expand = function()
- {
- }
- TreeOutline.prototype.collapse = function()
- {
- }
- TreeOutline.prototype.revealed = function()
- {
- return true;
- }
- TreeOutline.prototype.reveal = function()
- {
- }
- TreeOutline.prototype.select = function()
- {
- }
- TreeOutline.prototype.revealAndSelect = function(omitFocus)
- {
- }
- TreeOutline.prototype._startSearch = function(searchText)
- {
- if (!this.searchInputElement || !this.searchable)
- return;
- this._searching = true;
- if (this.searchStarted)
- this.searchStarted();
- this.searchInputElement.value = searchText;
- function focusSearchInput()
- {
- this.searchInputElement.focus();
- }
- window.setTimeout(focusSearchInput.bind(this), 0);
- this._searchTextChanged();
- this._boundSearchTextChanged = this._searchTextChanged.bind(this);
- this.searchInputElement.addEventListener("paste", this._boundSearchTextChanged);
- this.searchInputElement.addEventListener("cut", this._boundSearchTextChanged);
- this.searchInputElement.addEventListener("keypress", this._boundSearchTextChanged);
- this._boundSearchInputKeyDown = this._searchInputKeyDown.bind(this);
- this.searchInputElement.addEventListener("keydown", this._boundSearchInputKeyDown);
- this._boundSearchInputBlur = this._searchInputBlur.bind(this);
- this.searchInputElement.addEventListener("blur", this._boundSearchInputBlur);
- }
- TreeOutline.prototype._searchTextChanged = function()
- {
- function updateSearch()
- {
- var nextSelectedElement = this._nextSearchMatch(this.searchInputElement.value, this.selectedTreeElement, false);
- if (!nextSelectedElement)
- nextSelectedElement = this._nextSearchMatch(this.searchInputElement.value, this.children[0], false);
- this._showSearchMatchElement(nextSelectedElement);
- }
- window.setTimeout(updateSearch.bind(this), 0);
- }
- TreeOutline.prototype._showSearchMatchElement = function(treeElement)
- {
- this._currentSearchMatchElement = treeElement;
- if (treeElement) {
- this._childrenListNode.classList.add("search-match-found");
- this._childrenListNode.classList.remove("search-match-not-found");
- treeElement.revealAndSelect(true);
- } else {
- this._childrenListNode.classList.remove("search-match-found");
- this._childrenListNode.classList.add("search-match-not-found");
- }
- }
- TreeOutline.prototype._searchInputKeyDown = function(event)
- {
- if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey)
- return;
- var handled = false;
- var nextSelectedElement;
- if (event.keyIdentifier === "Down") {
- nextSelectedElement = this._nextSearchMatch(this.searchInputElement.value, this.selectedTreeElement, true);
- handled = true;
- } else if (event.keyIdentifier === "Up") {
- nextSelectedElement = this._previousSearchMatch(this.searchInputElement.value, this.selectedTreeElement);
- handled = true;
- } else if (event.keyCode === 27 ) {
- this._searchFinished();
- handled = true;
- } else if (isEnterKey(event)) {
- var lastSearchMatchElement = this._currentSearchMatchElement;
- this._searchFinished();
- if (lastSearchMatchElement && lastSearchMatchElement.onenter)
- lastSearchMatchElement.onenter();
- handled = true;
- }
- if (nextSelectedElement)
- this._showSearchMatchElement(nextSelectedElement);
- if (handled)
- event.consume(true);
- else
- window.setTimeout(this._boundSearchTextChanged, 0);
- }
- TreeOutline.prototype._nextSearchMatch = function(searchText, startTreeElement, skipStartTreeElement)
- {
- var currentTreeElement = startTreeElement;
- var skipCurrentTreeElement = skipStartTreeElement;
- while (currentTreeElement && (skipCurrentTreeElement || !currentTreeElement.matchesSearchText || !currentTreeElement.matchesSearchText(searchText))) {
- currentTreeElement = currentTreeElement.traverseNextTreeElement(true, null, true);
- skipCurrentTreeElement = false;
- }
- return currentTreeElement;
- }
- TreeOutline.prototype._previousSearchMatch = function(searchText, startTreeElement)
- {
- var currentTreeElement = startTreeElement;
- var skipCurrentTreeElement = true;
- while (currentTreeElement && (skipCurrentTreeElement || !currentTreeElement.matchesSearchText || !currentTreeElement.matchesSearchText(searchText))) {
- currentTreeElement = currentTreeElement.traversePreviousTreeElement(true, true);
- skipCurrentTreeElement = false;
- }
- return currentTreeElement;
- }
- TreeOutline.prototype._searchInputBlur = function(event)
- {
- this._searchFinished();
- }
- TreeOutline.prototype._searchFinished = function()
- {
- if (!this._searching)
- return;
- delete this._searching;
- this._childrenListNode.classList.remove("search-match-found");
- this._childrenListNode.classList.remove("search-match-not-found");
- delete this._currentSearchMatchElement;
- this.searchInputElement.value = "";
- this.searchInputElement.removeEventListener("paste", this._boundSearchTextChanged);
- this.searchInputElement.removeEventListener("cut", this._boundSearchTextChanged);
- delete this._boundSearchTextChanged;
- this.searchInputElement.removeEventListener("keydown", this._boundSearchInputKeyDown);
- delete this._boundSearchInputKeyDown;
- this.searchInputElement.removeEventListener("blur", this._boundSearchInputBlur);
- delete this._boundSearchInputBlur;
- if (this.searchFinished)
- this.searchFinished();
- this.treeOutline._childrenListNode.focus();
- }
- TreeOutline.prototype.stopSearch = function()
- {
- this._searchFinished();
- }
- function TreeElement(title, representedObject, hasChildren)
- {
- this._title = title;
- this.representedObject = (representedObject || {});
- this._hidden = false;
- this._selectable = true;
- this.expanded = false;
- this.selected = false;
- this.hasChildren = hasChildren;
- this.children = [];
- this.treeOutline = null;
- this.parent = null;
- this.previousSibling = null;
- this.nextSibling = null;
- this._listItemNode = null;
- }
- TreeElement.prototype = {
- arrowToggleWidth: 10,
- get selectable() {
- if (this._hidden)
- return false;
- return this._selectable;
- },
- set selectable(x) {
- this._selectable = x;
- },
- get listItemElement() {
- return this._listItemNode;
- },
- get childrenListElement() {
- return this._childrenListNode;
- },
- get title() {
- return this._title;
- },
- set title(x) {
- this._title = x;
- this._setListItemNodeContent();
- this.didChange();
- },
- get tooltip() {
- return this._tooltip;
- },
- set tooltip(x) {
- this._tooltip = x;
- if (this._listItemNode)
- this._listItemNode.title = x ? x : "";
- this.didChange();
- },
- get hasChildren() {
- return this._hasChildren;
- },
- set hasChildren(x) {
- if (this._hasChildren === x)
- return;
- this._hasChildren = x;
- if (!this._listItemNode)
- return;
- if (x)
- this._listItemNode.classList.add("parent");
- else {
- this._listItemNode.classList.remove("parent");
- this.collapse();
- }
- this.didChange();
- },
- get hidden() {
- return this._hidden;
- },
- set hidden(x) {
- if (this._hidden === x)
- return;
- this._hidden = x;
- if (x) {
- if (this._listItemNode)
- this._listItemNode.classList.add("hidden");
- if (this._childrenListNode)
- this._childrenListNode.classList.add("hidden");
- } else {
- if (this._listItemNode)
- this._listItemNode.classList.remove("hidden");
- if (this._childrenListNode)
- this._childrenListNode.classList.remove("hidden");
- }
- },
- get shouldRefreshChildren() {
- return this._shouldRefreshChildren;
- },
- set shouldRefreshChildren(x) {
- this._shouldRefreshChildren = x;
- if (x && this.expanded)
- this.expand();
- },
- _fireDidChange: function()
- {
- delete this._didChangeTimeoutIdentifier;
- if (this.treeOutline)
- this.treeOutline._treeElementDidChange(this);
- },
- didChange: function()
- {
- if (!this.treeOutline)
- return;
- if (!this._didChangeTimeoutIdentifier)
- this._didChangeTimeoutIdentifier = setTimeout(this._fireDidChange.bind(this), 0);
- },
- _setListItemNodeContent: function()
- {
- if (!this._listItemNode)
- return;
- if (typeof this._title === "string")
- this._listItemNode.textContent = this._title;
- else {
- this._listItemNode.removeChildren();
- if (this._title)
- this._listItemNode.appendChild(this._title);
- }
- }
- }
- TreeElement.prototype.appendChild = TreeOutline.prototype.appendChild;
- TreeElement.prototype.insertChild = TreeOutline.prototype.insertChild;
- TreeElement.prototype.removeChild = TreeOutline.prototype.removeChild;
- TreeElement.prototype.removeChildAtIndex = TreeOutline.prototype.removeChildAtIndex;
- TreeElement.prototype.removeChildren = TreeOutline.prototype.removeChildren;
- TreeElement.prototype.removeChildrenRecursive = TreeOutline.prototype.removeChildrenRecursive;
- TreeElement.prototype._attach = function()
- {
- if (!this._listItemNode || this.parent._shouldRefreshChildren) {
- if (this._listItemNode && this._listItemNode.parentNode)
- this._listItemNode.parentNode.removeChild(this._listItemNode);
- this._listItemNode = this.treeOutline._childrenListNode.ownerDocument.createElement("li");
- this._listItemNode.treeElement = this;
- this._setListItemNodeContent();
- this._listItemNode.title = this._tooltip ? this._tooltip : "";
- if (this.hidden)
- this._listItemNode.classList.add("hidden");
- if (this.hasChildren)
- this._listItemNode.classList.add("parent");
- if (this.expanded)
- this._listItemNode.classList.add("expanded");
- if (this.selected)
- this._listItemNode.classList.add("selected");
- this._listItemNode.addEventListener("mousedown", TreeElement.treeElementMouseDown, false);
- this._listItemNode.addEventListener("click", TreeElement.treeElementToggled, false);
- this._listItemNode.addEventListener("dblclick", TreeElement.treeElementDoubleClicked, false);
- if (this.onattach)
- this.onattach(this);
- }
- var nextSibling = null;
- if (this.nextSibling && this.nextSibling._listItemNode && this.nextSibling._listItemNode.parentNode === this.parent._childrenListNode)
- nextSibling = this.nextSibling._listItemNode;
- this.parent._childrenListNode.insertBefore(this._listItemNode, nextSibling);
- if (this._childrenListNode)
- this.parent._childrenListNode.insertBefore(this._childrenListNode, this._listItemNode.nextSibling);
- if (this.selected)
- this.select();
- if (this.expanded)
- this.expand();
- }
- TreeElement.prototype._detach = function()
- {
- if (this._listItemNode && this._listItemNode.parentNode)
- this._listItemNode.parentNode.removeChild(this._listItemNode);
- if (this._childrenListNode && this._childrenListNode.parentNode)
- this._childrenListNode.parentNode.removeChild(this._childrenListNode);
- }
- TreeElement.treeElementMouseDown = function(event)
- {
- var element = event.currentTarget;
- if (!element || !element.treeElement || !element.treeElement.selectable)
- return;
- if (element.treeElement.isEventWithinDisclosureTriangle(event))
- return;
- element.treeElement.selectOnMouseDown(event);
- }
- TreeElement.treeElementToggled = function(event)
- {
- var element = event.currentTarget;
- if (!element || !element.treeElement)
- return;
- var toggleOnClick = element.treeElement.toggleOnClick && !element.treeElement.selectable;
- var isInTriangle = element.treeElement.isEventWithinDisclosureTriangle(event);
- if (!toggleOnClick && !isInTriangle)
- return;
- if (element.treeElement.expanded) {
- if (event.altKey)
- element.treeElement.collapseRecursively();
- else
- element.treeElement.collapse();
- } else {
- if (event.altKey)
- element.treeElement.expandRecursively();
- else
- element.treeElement.expand();
- }
- event.consume();
- }
- TreeElement.treeElementDoubleClicked = function(event)
- {
- var element = event.currentTarget;
- if (!element || !element.treeElement)
- return;
- if (element.treeElement.ondblclick) {
- var handled = element.treeElement.ondblclick.call(element.treeElement, event);
- if (handled)
- return;
- } else if (element.treeElement.hasChildren && !element.treeElement.expanded)
- element.treeElement.expand();
- }
- TreeElement.prototype.collapse = function()
- {
- if (this._listItemNode)
- this._listItemNode.classList.remove("expanded");
- if (this._childrenListNode)
- this._childrenListNode.classList.remove("expanded");
- this.expanded = false;
- if (this.treeOutline)
- this.treeOutline._expandedStateMap.put(this.representedObject, false);
- if (this.oncollapse)
- this.oncollapse(this);
- }
- TreeElement.prototype.collapseRecursively = function()
- {
- var item = this;
- while (item) {
- if (item.expanded)
- item.collapse();
- item = item.traverseNextTreeElement(false, this, true);
- }
- }
- TreeElement.prototype.expand = function()
- {
- if (!this.hasChildren || (this.expanded && !this._shouldRefreshChildren && this._childrenListNode))
- return;
- this.expanded = true;
- if (this.treeOutline)
- this.treeOutline._expandedStateMap.put(this.representedObject, true);
- if (this.treeOutline && (!this._childrenListNode || this._shouldRefreshChildren)) {
- if (this._childrenListNode && this._childrenListNode.parentNode)
- this._childrenListNode.parentNode.removeChild(this._childrenListNode);
- this._childrenListNode = this.treeOutline._childrenListNode.ownerDocument.createElement("ol");
- this._childrenListNode.parentTreeElement = this;
- this._childrenListNode.classList.add("children");
- if (this.hidden)
- this._childrenListNode.classList.add("hidden");
- this.onpopulate();
- for (var i = 0; i < this.children.length; ++i)
- this.children[i]._attach();
- delete this._shouldRefreshChildren;
- }
- if (this._listItemNode) {
- this._listItemNode.classList.add("expanded");
- if (this._childrenListNode && this._childrenListNode.parentNode != this._listItemNode.parentNode)
- this.parent._childrenListNode.insertBefore(this._childrenListNode, this._listItemNode.nextSibling);
- }
- if (this._childrenListNode)
- this._childrenListNode.classList.add("expanded");
- if (this.onexpand)
- this.onexpand(this);
- }
- TreeElement.prototype.expandRecursively = function(maxDepth)
- {
- var item = this;
- var info = {};
- var depth = 0;
- if (typeof maxDepth === "undefined" || typeof maxDepth === "null")
- maxDepth = 3;
- while (item) {
- if (depth < maxDepth)
- item.expand();
- item = item.traverseNextTreeElement(false, this, (depth >= maxDepth), info);
- depth += info.depthChange;
- }
- }
- TreeElement.prototype.hasAncestor = function(ancestor) {
- if (!ancestor)
- return false;
- var currentNode = this.parent;
- while (currentNode) {
- if (ancestor === currentNode)
- return true;
- currentNode = currentNode.parent;
- }
- return false;
- }
- TreeElement.prototype.reveal = function()
- {
- var currentAncestor = this.parent;
- while (currentAncestor && !currentAncestor.root) {
- if (!currentAncestor.expanded)
- currentAncestor.expand();
- currentAncestor = currentAncestor.parent;
- }
- if (this.onreveal)
- this.onreveal(this);
- }
- TreeElement.prototype.revealed = function()
- {
- var currentAncestor = this.parent;
- while (currentAncestor && !currentAncestor.root) {
- if (!currentAncestor.expanded)
- return false;
- currentAncestor = currentAncestor.parent;
- }
- return true;
- }
- TreeElement.prototype.selectOnMouseDown = function(event)
- {
- if (this.select(false, true))
- event.consume(true);
- }
- TreeElement.prototype.select = function(omitFocus, selectedByUser)
- {
- if (!this.treeOutline || !this.selectable || this.selected)
- return false;
- if (this.treeOutline.selectedTreeElement)
- this.treeOutline.selectedTreeElement.deselect();
- this.selected = true;
- if(!omitFocus)
- this.treeOutline._childrenListNode.focus();
- if (!this.treeOutline)
- return false;
- this.treeOutline.selectedTreeElement = this;
- if (this._listItemNode)
- this._listItemNode.classList.add("selected");
- if (this.onselect)
- return this.onselect(this, selectedByUser);
- return false;
- }
- TreeElement.prototype.revealAndSelect = function(omitFocus)
- {
- this.reveal();
- this.select(omitFocus);
- }
- TreeElement.prototype.deselect = function(supressOnDeselect)
- {
- if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this || !this.selected)
- return false;
- this.selected = false;
- this.treeOutline.selectedTreeElement = null;
- if (this._listItemNode)
- this._listItemNode.classList.remove("selected");
- if (this.ondeselect && !supressOnDeselect)
- this.ondeselect(this);
- return true;
- }
- TreeElement.prototype.onpopulate = function()
- {
- }
- TreeElement.prototype.traverseNextTreeElement = function(skipUnrevealed, stayWithin, dontPopulate, info)
- {
- if (!dontPopulate && this.hasChildren)
- this.onpopulate();
- if (info)
- info.depthChange = 0;
- var element = skipUnrevealed ? (this.revealed() ? this.children[0] : null) : this.children[0];
- if (element && (!skipUnrevealed || (skipUnrevealed && this.expanded))) {
- if (info)
- info.depthChange = 1;
- return element;
- }
- if (this === stayWithin)
- return null;
- element = skipUnrevealed ? (this.revealed() ? this.nextSibling : null) : this.nextSibling;
- if (element)
- return element;
- element = this;
- while (element && !element.root && !(skipUnrevealed ? (element.revealed() ? element.nextSibling : null) : element.nextSibling) && element.parent !== stayWithin) {
- if (info)
- info.depthChange -= 1;
- element = element.parent;
- }
- if (!element)
- return null;
- return (skipUnrevealed ? (element.revealed() ? element.nextSibling : null) : element.nextSibling);
- }
- TreeElement.prototype.traversePreviousTreeElement = function(skipUnrevealed, dontPopulate)
- {
- var element = skipUnrevealed ? (this.revealed() ? this.previousSibling : null) : this.previousSibling;
- if (!dontPopulate && element && element.hasChildren)
- element.onpopulate();
- while (element && (skipUnrevealed ? (element.revealed() && element.expanded ? element.children[element.children.length - 1] : null) : element.children[element.children.length - 1])) {
- if (!dontPopulate && element.hasChildren)
- element.onpopulate();
- element = (skipUnrevealed ? (element.revealed() && element.expanded ? element.children[element.children.length - 1] : null) : element.children[element.children.length - 1]);
- }
- if (element)
- return element;
- if (!this.parent || this.parent.root)
- return null;
- return this.parent;
- }
- TreeElement.prototype.isEventWithinDisclosureTriangle = function(event)
- {
- var computedLeftPadding = window.getComputedStyle(this._listItemNode).getPropertyCSSValue("padding-left").getFloatValue(CSSPrimitiveValue.CSS_PX);
- var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding;
- return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren;
- }
- var WebInspector = {
- _createPanels: function()
- {
- this.panels = {};
- WebInspector.inspectorView = new WebInspector.InspectorView();
- var parentElement = document.getElementById("main");
- WebInspector.inspectorView.show(parentElement);
- WebInspector.inspectorView.addEventListener(WebInspector.InspectorView.Events.PanelSelected, this._panelSelected, this);
- if (WebInspector.WorkerManager.isWorkerFrontend()) {
- this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel);
- this.panels.timeline = new WebInspector.TimelinePanel();
- this.panels.profiles = new WebInspector.ProfilesPanel();
- this.panels.console = new WebInspector.ConsolePanel();
- return;
- }
- var hiddenPanels = (InspectorFrontendHost.hiddenPanels() || "").split(',');
- if (hiddenPanels.indexOf("elements") === -1)
- this.panels.elements = new WebInspector.ElementsPanel();
- if (hiddenPanels.indexOf("resources") === -1)
- this.panels.resources = new WebInspector.ResourcesPanel();
- if (hiddenPanels.indexOf("network") === -1)
- this.panels.network = new WebInspector.NetworkPanel();
- if (hiddenPanels.indexOf("scripts") === -1)
- this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel);
- if (hiddenPanels.indexOf("timeline") === -1)
- this.panels.timeline = new WebInspector.TimelinePanel();
- if (hiddenPanels.indexOf("profiles") === -1)
- this.panels.profiles = new WebInspector.ProfilesPanel();
- if (hiddenPanels.indexOf("audits") === -1)
- this.panels.audits = new WebInspector.AuditsPanel();
- if (hiddenPanels.indexOf("console") === -1)
- this.panels.console = new WebInspector.ConsolePanel();
- },
- _panelSelected: function()
- {
- this._toggleConsoleButton.disabled = WebInspector.inspectorView.currentPanel() === WebInspector.panels.console;
- },
- _createGlobalStatusBarItems: function()
- {
- this._dockToggleButton = new WebInspector.StatusBarButton(this._dockButtonTitle(), "dock-status-bar-item");
- this._dockToggleButton.addEventListener("click", this._toggleAttach.bind(this), false);
- this._dockToggleButton.toggled = !this.attached;
- WebInspector.updateDockToggleButton();
- this._settingsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Settings"), "settings-status-bar-item");
- this._settingsButton.addEventListener("click", this._toggleSettings.bind(this), false);
- var anchoredStatusBar = document.getElementById("anchored-status-bar-items");
- anchoredStatusBar.appendChild(this._dockToggleButton.element);
- this._toggleConsoleButton = new WebInspector.StatusBarButton(WebInspector.UIString("Show console."), "console-status-bar-item");
- this._toggleConsoleButton.addEventListener("click", this._toggleConsoleButtonClicked.bind(this), false);
- anchoredStatusBar.appendChild(this._toggleConsoleButton.element);
- if (this.panels.elements)
- anchoredStatusBar.appendChild(this.panels.elements.nodeSearchButton.element);
- anchoredStatusBar.appendChild(this._settingsButton.element);
- },
- _dockButtonTitle: function()
- {
- return this.attached ? WebInspector.UIString("Undock into separate window.") : WebInspector.UIString("Dock to main window.");
- },
- _toggleAttach: function()
- {
- if (!this._attached) {
- InspectorFrontendHost.requestAttachWindow();
- WebInspector.userMetrics.WindowDocked.record();
- } else {
- InspectorFrontendHost.requestDetachWindow();
- WebInspector.userMetrics.WindowUndocked.record();
- }
- },
- _toggleConsoleButtonClicked: function()
- {
- if (this._toggleConsoleButton.disabled)
- return;
- this._toggleConsoleButton.toggled = !this._toggleConsoleButton.toggled;
- var animationType = window.event && window.event.shiftKey ? WebInspector.Drawer.AnimationType.Slow : WebInspector.Drawer.AnimationType.Normal;
- if (this._toggleConsoleButton.toggled) {
- this._toggleConsoleButton.title = WebInspector.UIString("Hide console.");
- this.drawer.show(this.consoleView, animationType);
- this._consoleWasShown = true;
- } else {
- this._toggleConsoleButton.title = WebInspector.UIString("Show console.");
- this.drawer.hide(animationType);
- delete this._consoleWasShown;
- }
- },
- closeDrawerView: function()
- {
- if (!this._consoleWasShown)
- this.drawer.hide(WebInspector.Drawer.AnimationType.Immediately);
- else
- this._toggleConsoleButtonClicked();
- },
- showViewInDrawer: function(view)
- {
- this._toggleConsoleButton.title = WebInspector.UIString("Hide console.");
- this._toggleConsoleButton.toggled = false;
- this.drawer.show(view, WebInspector.Drawer.AnimationType.Immediately);
- },
- _toggleSettings: function()
- {
- this._settingsButton.toggled = !this._settingsButton.toggled;
- if (this._settingsButton.toggled)
- this._showSettingsScreen();
- else
- this._hideSettingsScreen();
- },
- _showSettingsScreen: function()
- {
- function onhide()
- {
- this._settingsButton.toggled = false;
- delete this._settingsScreen;
- }
- if (!this._settingsScreen) {
- this._settingsScreen = new WebInspector.SettingsScreen();
- this._settingsScreen.show(onhide.bind(this));
- }
- },
- _hideSettingsScreen: function()
- {
- if (this._settingsScreen)
- this._settingsScreen.hide();
- },
- get attached()
- {
- return this._attached;
- },
- set attached(x)
- {
- if (this._attached === x)
- return;
- this._attached = x;
- if (this._dockToggleButton) {
- this._dockToggleButton.title = this._dockButtonTitle();
- this._dockToggleButton.toggled = !x;
- }
- if (x)
- document.body.removeStyleClass("detached");
- else
- document.body.addStyleClass("detached");
- this._setCompactMode(x && !WebInspector.settings.dockToRight.get());
- },
- isCompactMode: function()
- {
- return this.attached && !WebInspector.settings.dockToRight.get();
- },
- _setCompactMode: function(x)
- {
- var body = document.body;
- if (x)
- body.addStyleClass("compact");
- else
- body.removeStyleClass("compact");
- if (WebInspector.toolbar)
- WebInspector.toolbar.compact = x;
- if (WebInspector.searchController)
- WebInspector.searchController.updateSearchLabel();
- if (WebInspector.drawer)
- WebInspector.drawer.resize();
- },
- _updateErrorAndWarningCounts: function()
- {
- var errorWarningElement = document.getElementById("error-warning-count");
- if (!errorWarningElement)
- return;
- var errors = WebInspector.console.errors;
- var warnings = WebInspector.console.warnings;
- if (!errors && !warnings) {
- errorWarningElement.addStyleClass("hidden");
- return;
- }
- errorWarningElement.removeStyleClass("hidden");
- errorWarningElement.removeChildren();
- if (errors) {
- var errorImageElement = document.createElement("img");
- errorImageElement.id = "error-count-img";
- errorWarningElement.appendChild(errorImageElement);
- var errorElement = document.createElement("span");
- errorElement.id = "error-count";
- errorElement.textContent = errors;
- errorWarningElement.appendChild(errorElement);
- }
- if (warnings) {
- var warningsImageElement = document.createElement("img");
- warningsImageElement.id = "warning-count-img";
- errorWarningElement.appendChild(warningsImageElement);
- var warningsElement = document.createElement("span");
- warningsElement.id = "warning-count";
- warningsElement.textContent = warnings;
- errorWarningElement.appendChild(warningsElement);
- }
- if (errors) {
- if (warnings) {
- if (errors == 1) {
- if (warnings == 1)
- errorWarningElement.title = WebInspector.UIString("%d error, %d warning", errors, warnings);
- else
- errorWarningElement.title = WebInspector.UIString("%d error, %d warnings", errors, warnings);
- } else if (warnings == 1)
- errorWarningElement.title = WebInspector.UIString("%d errors, %d warning", errors, warnings);
- else
- errorWarningElement.title = WebInspector.UIString("%d errors, %d warnings", errors, warnings);
- } else if (errors == 1)
- errorWarningElement.title = WebInspector.UIString("%d error", errors);
- else
- errorWarningElement.title = WebInspector.UIString("%d errors", errors);
- } else if (warnings == 1)
- errorWarningElement.title = WebInspector.UIString("%d warning", warnings);
- else if (warnings)
- errorWarningElement.title = WebInspector.UIString("%d warnings", warnings);
- else
- errorWarningElement.title = null;
- },
- networkResourceById: function(id)
- {
- return this.panels.network.resourceById(id);
- },
- get inspectedPageDomain()
- {
- var parsedURL = WebInspector.inspectedPageURL && WebInspector.inspectedPageURL.asParsedURL();
- return parsedURL ? parsedURL.host : "";
- },
- _initializeCapability: function(name, callback, error, result)
- {
- Capabilities[name] = result;
- if (callback)
- callback();
- },
- _zoomIn: function()
- {
- ++this._zoomLevel;
- this._requestZoom();
- },
- _zoomOut: function()
- {
- --this._zoomLevel;
- this._requestZoom();
- },
- _resetZoom: function()
- {
- this._zoomLevel = 0;
- this._requestZoom();
- },
- _requestZoom: function()
- {
- WebInspector.settings.zoomLevel.set(this._zoomLevel);
- InspectorFrontendHost.setZoomFactor(Math.pow(1.2, this._zoomLevel));
- }
- }
- WebInspector.Events = {
- InspectorClosing: "InspectorClosing"
- }
- {(function parseQueryParameters()
- {
- WebInspector.queryParamsObject = {};
- var queryParams = window.location.search;
- if (!queryParams)
- return;
- var params = queryParams.substring(1).split("&");
- for (var i = 0; i < params.length; ++i) {
- var pair = params[i].split("=");
- WebInspector.queryParamsObject[pair[0]] = pair[1];
- }
- })();}
- WebInspector.loaded = function()
- {
- InspectorBackend.loadFromJSONIfNeeded();
- if ("page" in WebInspector.queryParamsObject) {
- var page = WebInspector.queryParamsObject.page;
- var host = "host" in WebInspector.queryParamsObject ? WebInspector.queryParamsObject.host : window.location.host;
- WebInspector.socket = new WebSocket("ws://" + host + "/devtools/page/" + page);
- WebInspector.socket.onmessage = function(message) { InspectorBackend.dispatch(message.data); }
- WebInspector.socket.onerror = function(error) { console.error(error); }
- WebInspector.socket.onopen = function() {
- InspectorFrontendHost.sendMessageToBackend = WebInspector.socket.send.bind(WebInspector.socket);
- WebInspector.doLoadedDone();
- }
- return;
- }
- WebInspector.doLoadedDone();
- }
- WebInspector.doLoadedDone = function()
- {
- WebInspector.installPortStyles();
- if (WebInspector.socket)
- document.body.addStyleClass("remote");
- if (WebInspector.queryParamsObject.toolbarColor && WebInspector.queryParamsObject.textColor)
- WebInspector.setToolbarColors(WebInspector.queryParamsObject.toolbarColor, WebInspector.queryParamsObject.textColor);
- InspectorFrontendHost.loaded();
- WebInspector.WorkerManager.loaded();
- DebuggerAgent.causesRecompilation(WebInspector._initializeCapability.bind(WebInspector, "debuggerCausesRecompilation", null));
- DebuggerAgent.supportsNativeBreakpoints(WebInspector._initializeCapability.bind(WebInspector, "nativeInstrumentationEnabled", null));
- ProfilerAgent.causesRecompilation(WebInspector._initializeCapability.bind(WebInspector, "profilerCausesRecompilation", null));
- ProfilerAgent.isSampling(WebInspector._initializeCapability.bind(WebInspector, "samplingCPUProfiler", null));
- ProfilerAgent.hasHeapProfiler(WebInspector._initializeCapability.bind(WebInspector, "heapProfilerPresent", null));
- PageAgent.canOverrideDeviceMetrics(WebInspector._initializeCapability.bind(WebInspector, "canOverrideDeviceMetrics", WebInspector._doLoadedDoneWithCapabilities.bind(WebInspector)));
- }
- WebInspector._doLoadedDoneWithCapabilities = function()
- {
- WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen();
- this._registerShortcuts();
- WebInspector.shortcutsScreen.section(WebInspector.UIString("Console"));
- WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Panel"));
- this.console = new WebInspector.ConsoleModel();
- this.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._updateErrorAndWarningCounts, this);
- this.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._updateErrorAndWarningCounts, this);
- this.console.addEventListener(WebInspector.ConsoleModel.Events.RepeatCountUpdated, this._updateErrorAndWarningCounts, this);
- this.debuggerModel = new WebInspector.DebuggerModel();
- this.snippetsModel = new WebInspector.SnippetsModel();
- this.debuggerPresentationModel = new WebInspector.DebuggerPresentationModel();
- this.drawer = new WebInspector.Drawer();
- this.consoleView = new WebInspector.ConsoleView(WebInspector.WorkerManager.isWorkerFrontend());
- this.networkManager = new WebInspector.NetworkManager();
- this.resourceTreeModel = new WebInspector.ResourceTreeModel(this.networkManager);
- this.networkLog = new WebInspector.NetworkLog();
- this.domAgent = new WebInspector.DOMAgent();
- new WebInspector.JavaScriptContextManager(this.resourceTreeModel, this.consoleView);
- InspectorBackend.registerInspectorDispatcher(this);
- this.cssModel = new WebInspector.CSSStyleModel();
- this.timelineManager = new WebInspector.TimelineManager();
- this.userAgentSupport = new WebInspector.UserAgentSupport();
- InspectorBackend.registerDatabaseDispatcher(new WebInspector.DatabaseDispatcher());
- InspectorBackend.registerDOMStorageDispatcher(new WebInspector.DOMStorageDispatcher());
- this.searchController = new WebInspector.SearchController();
- this.advancedSearchController = new WebInspector.AdvancedSearchController();
- if (Capabilities.nativeInstrumentationEnabled)
- this.domBreakpointsSidebarPane = new WebInspector.DOMBreakpointsSidebarPane();
- this._zoomLevel = WebInspector.settings.zoomLevel.get();
- if (this._zoomLevel)
- this._requestZoom();
- this._createPanels();
- this._createGlobalStatusBarItems();
- this.toolbar = new WebInspector.Toolbar();
- WebInspector._installDockToRight();
- for (var panelName in this.panels)
- this.addPanel(this.panels[panelName]);
- this.addMainEventListeners(document);
- window.addEventListener("resize", this.windowResize.bind(this), true);
- var errorWarningCount = document.getElementById("error-warning-count");
- errorWarningCount.addEventListener("click", this.showConsole.bind(this), false);
- this._updateErrorAndWarningCounts();
- var autoselectPanel = WebInspector.UIString("a panel chosen automatically");
- var openAnchorLocationSetting = WebInspector.settings.createSetting("openLinkHandler", autoselectPanel);
- this.openAnchorLocationRegistry = new WebInspector.HandlerRegistry(openAnchorLocationSetting);
- this.openAnchorLocationRegistry.registerHandler(autoselectPanel, function() { return false; });
- this.extensionServer.initExtensions();
- this.console.enableAgent();
- function showInitialPanel()
- {
- if (!WebInspector.inspectorView.currentPanel())
- WebInspector.showPanel(WebInspector.settings.lastActivePanel.get());
- }
- InspectorAgent.enable(showInitialPanel);
- DatabaseAgent.enable();
- DOMStorageAgent.enable();
- if (WebInspector.settings.showPaintRects.get())
- PageAgent.setShowPaintRects(true);
- WebInspector.CSSCompletions.requestCSSNameCompletions();
- WebInspector.WorkerManager.loadCompleted();
- InspectorFrontendAPI.loadCompleted();
- }
- WebInspector._installDockToRight = function()
- {
- WebInspector.settings.dockToRight.set(WebInspector.queryParamsObject.dockSide === "right");
- if (WebInspector.settings.dockToRight.get())
- document.body.addStyleClass("dock-to-right");
- if (WebInspector.attached)
- WebInspector._setCompactMode(!WebInspector.settings.dockToRight.get());
- WebInspector.settings.dockToRight.addChangeListener(listener.bind(this));
- function listener(event)
- {
- var value = WebInspector.settings.dockToRight.get();
- if (value) {
- InspectorFrontendHost.requestSetDockSide("right");
- document.body.addStyleClass("dock-to-right");
- } else {
- InspectorFrontendHost.requestSetDockSide("bottom");
- document.body.removeStyleClass("dock-to-right");
- }
- if (WebInspector.attached)
- WebInspector._setCompactMode(!value);
- }
- }
- WebInspector.addPanel = function(panel)
- {
- WebInspector.inspectorView.addPanel(panel);
- }
- var windowLoaded = function()
- {
- var localizedStringsURL = InspectorFrontendHost.localizedStringsURL();
- if (localizedStringsURL) {
- var localizedStringsScriptElement = document.createElement("script");
- localizedStringsScriptElement.addEventListener("load", WebInspector.loaded.bind(WebInspector), false);
- localizedStringsScriptElement.type = "text/javascript";
- localizedStringsScriptElement.src = localizedStringsURL;
- document.head.appendChild(localizedStringsScriptElement);
- } else
- WebInspector.loaded();
- WebInspector.setAttachedWindow(WebInspector.queryParamsObject.docked === "true");
- window.removeEventListener("DOMContentLoaded", windowLoaded, false);
- delete windowLoaded;
- };
- window.addEventListener("DOMContentLoaded", windowLoaded, false);
- var messagesToDispatch = [];
- WebInspector.dispatchQueueIsEmpty = function() {
- return messagesToDispatch.length == 0;
- }
- WebInspector.dispatch = function(message) {
- messagesToDispatch.push(message);
- setTimeout(function() {
- InspectorBackend.dispatch(messagesToDispatch.shift());
- }, 0);
- }
- WebInspector.dispatchMessageFromBackend = function(messageObject)
- {
- WebInspector.dispatch(messageObject);
- }
- WebInspector.windowResize = function(event)
- {
- WebInspector.inspectorView.doResize();
- WebInspector.drawer.resize();
- WebInspector.toolbar.resize();
- }
- WebInspector.setAttachedWindow = function(attached)
- {
- this.attached = attached;
- WebInspector.updateDockToggleButton();
- }
- WebInspector.setDockingUnavailable = function(unavailable)
- {
- this._isDockingUnavailable = unavailable;
- WebInspector.updateDockToggleButton();
- }
- WebInspector.updateDockToggleButton = function()
- {
- if (!this._dockToggleButton)
- return;
- this._dockToggleButton.disabled = this.attached ? false : this._isDockingUnavailable;
- }
- WebInspector.close = function(event)
- {
- if (this._isClosing)
- return;
- this._isClosing = true;
- this.notifications.dispatchEventToListeners(WebInspector.Events.InspectorClosing);
- InspectorFrontendHost.closeWindow();
- }
- WebInspector.documentClick = function(event)
- {
- var anchor = event.target.enclosingNodeOrSelfWithNodeName("a");
- if (!anchor || anchor.target === "_blank")
- return;
- event.consume(true);
- function followLink()
- {
- if (WebInspector.isBeingEdited(event.target) || WebInspector._showAnchorLocation(anchor))
- return;
- const profileMatch = WebInspector.ProfileType.URLRegExp.exec(anchor.href);
- if (profileMatch) {
- WebInspector.showProfileForURL(anchor.href);
- return;
- }
- var parsedURL = anchor.href.asParsedURL();
- if (parsedURL && parsedURL.scheme === "webkit-link-action") {
- if (parsedURL.host === "show-panel") {
- var panel = parsedURL.path.substring(1);
- if (WebInspector.panels[panel])
- WebInspector.showPanel(panel);
- }
- return;
- }
- WebInspector.showPanel("resources");
- }
- if (WebInspector.followLinkTimeout)
- clearTimeout(WebInspector.followLinkTimeout);
- if (anchor.preventFollowOnDoubleClick) {
- if (event.detail === 1)
- WebInspector.followLinkTimeout = setTimeout(followLink, 333);
- return;
- }
- followLink();
- }
- WebInspector.openResource = function(resourceURL, inResourcesPanel)
- {
- var resource = WebInspector.resourceForURL(resourceURL);
- if (inResourcesPanel && resource) {
- WebInspector.showPanel("resources");
- WebInspector.panels.resources.showResource(resource);
- } else
- InspectorFrontendHost.openInNewTab(resourceURL);
- }
- WebInspector.openRequestInNetworkPanel = function(resource)
- {
- WebInspector.showPanel("network");
- WebInspector.panels.network.revealAndHighlightResource(resource);
- }
- WebInspector._registerShortcuts = function()
- {
- var shortcut = WebInspector.KeyboardShortcut;
- var section = WebInspector.shortcutsScreen.section(WebInspector.UIString("All Panels"));
- var keys = [
- shortcut.shortcutToString("]", shortcut.Modifiers.CtrlOrMeta),
- shortcut.shortcutToString("[", shortcut.Modifiers.CtrlOrMeta)
- ];
- section.addRelatedKeys(keys, WebInspector.UIString("Go to the panel to the left/right"));
- var keys = [
- shortcut.shortcutToString("[", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Alt),
- shortcut.shortcutToString("]", shortcut.Modifiers.CtrlOrMeta | shortcut.Modifiers.Alt)
- ];
- section.addRelatedKeys(keys, WebInspector.UIString("Go back/forward in panel history"));
- section.addKey(shortcut.shortcutToString(shortcut.Keys.Esc), WebInspector.UIString("Toggle console"));
- section.addKey(shortcut.shortcutToString("f", shortcut.Modifiers.CtrlOrMeta), WebInspector.UIString("Search"));
- var advancedSearchShortcut = WebInspector.AdvancedSearchController.createShortcut();
- section.addKey(advancedSearchShortcut.name, WebInspector.UIString("Search across all scripts"));
- if (WebInspector.isMac()) {
- keys = [
- shortcut.shortcutToString("g", shortcut.Modifiers.Meta),
- shortcut.shortcutToString("g", shortcut.Modifiers.Meta | shortcut.Modifiers.Shift)
- ];
- section.addRelatedKeys(keys, WebInspector.UIString("Find next/previous"));
- }
- var goToShortcut = WebInspector.GoToLineDialog.createShortcut();
- section.addKey(goToShortcut.name, WebInspector.UIString("Go to line"));
- }
- WebInspector.documentKeyDown = function(event)
- {
- const helpKey = WebInspector.isMac() ? "U+003F" : "U+00BF";
- if (event.keyIdentifier === "F1" ||
- (event.keyIdentifier === helpKey && event.shiftKey && (!WebInspector.isBeingEdited(event.target) || event.metaKey))) {
- WebInspector.shortcutsScreen.show();
- event.consume(true);
- return;
- }
- if (WebInspector.currentFocusElement() && WebInspector.currentFocusElement().handleKeyEvent) {
- WebInspector.currentFocusElement().handleKeyEvent(event);
- if (event.handled) {
- event.consume(true);
- return;
- }
- }
- if (WebInspector.inspectorView.currentPanel()) {
- WebInspector.inspectorView.currentPanel().handleShortcut(event);
- if (event.handled) {
- event.consume(true);
- return;
- }
- }
- WebInspector.searchController.handleShortcut(event);
- WebInspector.advancedSearchController.handleShortcut(event);
- if (event.handled) {
- event.consume(true);
- return;
- }
- var isMac = WebInspector.isMac();
- switch (event.keyIdentifier) {
- case "U+0052":
- if ((event.metaKey && isMac) || (event.ctrlKey && !isMac)) {
- PageAgent.reload(event.shiftKey);
- event.consume(true);
- }
- break;
- case "F5":
- if (!isMac) {
- PageAgent.reload(event.ctrlKey || event.shiftKey);
- event.consume(true);
- }
- break;
- }
- var isValidZoomShortcut = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) &&
- !event.shiftKey &&
- !event.altKey &&
- !InspectorFrontendHost.isStub;
- switch (event.keyCode) {
- case 107:
- case 187:
- if (isValidZoomShortcut) {
- WebInspector._zoomIn();
- event.consume(true);
- }
- break;
- case 109:
- case 189:
- if (isValidZoomShortcut) {
- WebInspector._zoomOut();
- event.consume(true);
- }
- break;
- case 48:
- if (isValidZoomShortcut) {
- WebInspector._resetZoom();
- event.consume(true);
- }
- break;
- }
- }
- WebInspector.postDocumentKeyDown = function(event)
- {
- if (event.handled)
- return;
- if (event.keyIdentifier === "U+001B") {
- if (!this._toggleConsoleButton.toggled && WebInspector.drawer.visible)
- this.closeDrawerView();
- else
- this._toggleConsoleButtonClicked();
- }
- }
- WebInspector.documentCanCopy = function(event)
- {
- if (WebInspector.inspectorView.currentPanel() && WebInspector.inspectorView.currentPanel().handleCopyEvent)
- event.preventDefault();
- }
- WebInspector.documentCopy = function(event)
- {
- if (WebInspector.inspectorView.currentPanel() && WebInspector.inspectorView.currentPanel().handleCopyEvent)
- WebInspector.inspectorView.currentPanel().handleCopyEvent(event);
- }
- WebInspector.contextMenuEventFired = function(event)
- {
- if (event.handled || event.target.hasStyleClass("popup-glasspane"))
- event.preventDefault();
- }
- WebInspector.toggleSearchingForNode = function()
- {
- if (this.panels.elements) {
- this.showPanel("elements");
- this.panels.elements.toggleSearchingForNode();
- }
- }
- WebInspector.showConsole = function()
- {
- if (WebInspector._toggleConsoleButton && !WebInspector._toggleConsoleButton.toggled)
- WebInspector._toggleConsoleButtonClicked();
- }
- WebInspector.showPanel = function(panel)
- {
- if (!(panel in this.panels)) {
- if (WebInspector.WorkerManager.isWorkerFrontend())
- panel = "scripts";
- else
- panel = "elements";
- }
- WebInspector.inspectorView.setCurrentPanel(this.panels[panel]);
- }
- WebInspector.bringToFront = function()
- {
- InspectorFrontendHost.bringToFront();
- }
- WebInspector.didCreateWorker = function()
- {
- var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
- if (workersPane)
- workersPane.addWorker.apply(workersPane, arguments);
- }
- WebInspector.didDestroyWorker = function()
- {
- var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
- if (workersPane)
- workersPane.removeWorker.apply(workersPane, arguments);
- }
- WebInspector.log = function(message, messageLevel, showConsole)
- {
- var self = this;
- function isLogAvailable()
- {
- return WebInspector.ConsoleMessage && WebInspector.RemoteObject && self.console;
- }
- function flushQueue()
- {
- var queued = WebInspector.log.queued;
- if (!queued)
- return;
- for (var i = 0; i < queued.length; ++i)
- logMessage(queued[i]);
- delete WebInspector.log.queued;
- }
- function flushQueueIfAvailable()
- {
- if (!isLogAvailable())
- return;
- clearInterval(WebInspector.log.interval);
- delete WebInspector.log.interval;
- flushQueue();
- }
- function logMessage(message)
- {
- var msg = WebInspector.ConsoleMessage.create(
- WebInspector.ConsoleMessage.MessageSource.Other,
- messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug,
- message);
- self.console.addMessage(msg);
- if (showConsole)
- WebInspector.showConsole();
- }
- if (!isLogAvailable()) {
- if (!WebInspector.log.queued)
- WebInspector.log.queued = [];
- WebInspector.log.queued.push(message);
- if (!WebInspector.log.interval)
- WebInspector.log.interval = setInterval(flushQueueIfAvailable, 1000);
- return;
- }
- flushQueue();
- logMessage(message);
- }
- WebInspector.inspect = function(payload, hints)
- {
- var object = WebInspector.RemoteObject.fromPayload(payload);
- if (object.subtype === "node") {
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
- object.pushNodeToFrontend(WebInspector.updateFocusedNode.bind(WebInspector), object.release.bind(object));
- return;
- }
- if (hints.databaseId) {
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
- WebInspector.panels.resources.selectDatabase(hints.databaseId);
- } else if (hints.domStorageId) {
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
- WebInspector.panels.resources.selectDOMStorage(hints.domStorageId);
- }
- object.release();
- }
- WebInspector.updateFocusedNode = function(nodeId)
- {
- this.panels.elements.revealAndSelectNode(nodeId);
- }
- WebInspector.populateResourceContextMenu = function(contextMenu, url, preferredLineNumber)
- {
- var registry = WebInspector.openAnchorLocationRegistry;
- for (var i = 1; i < registry.handlerNames.length; ++i) {
- var handler = registry.handlerNames[i];
- contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Open using %s" : "Open Using %s", handler),
- registry.dispatchToHandler.bind(registry, handler, { url: url, preferredLineNumber: preferredLineNumber }));
- }
- }
- WebInspector._showAnchorLocation = function(anchor)
- {
- if (WebInspector.openAnchorLocationRegistry.dispatch({ url: anchor.href, lineNumber: anchor.lineNumber}))
- return true;
- var preferedPanel = this.panels[anchor.preferredPanel || "resources"];
- if (WebInspector._showAnchorLocationInPanel(anchor, preferedPanel))
- return true;
- if (preferedPanel !== this.panels.resources && WebInspector._showAnchorLocationInPanel(anchor, this.panels.resources))
- return true;
- return false;
- }
- WebInspector._showAnchorLocationInPanel = function(anchor, panel)
- {
- if (!panel.canShowAnchorLocation(anchor))
- return false;
- if (anchor.hasStyleClass("webkit-html-external-link")) {
- anchor.removeStyleClass("webkit-html-external-link");
- anchor.addStyleClass("webkit-html-resource-link");
- }
- this.showPanelForAnchorNavigation(panel);
- panel.showAnchorLocation(anchor);
- return true;
- }
- WebInspector.showPanelForAnchorNavigation = function(panel)
- {
- WebInspector.searchController.disableSearchUntilExplicitAction();
- WebInspector.inspectorView.setCurrentPanel(panel);
- }
- WebInspector.showProfileForURL = function(url)
- {
- WebInspector.showPanel("profiles");
- WebInspector.panels.profiles.showProfileForURL(url);
- }
- WebInspector.evaluateInConsole = function(expression, showResultOnly)
- {
- this.showConsole();
- this.consoleView.evaluateUsingTextPrompt(expression, showResultOnly);
- }
- WebInspector.addMainEventListeners = function(doc)
- {
- doc.addEventListener("keydown", this.documentKeyDown.bind(this), true);
- doc.addEventListener("keydown", this.postDocumentKeyDown.bind(this), false);
- doc.addEventListener("beforecopy", this.documentCanCopy.bind(this), true);
- doc.addEventListener("copy", this.documentCopy.bind(this), true);
- doc.addEventListener("contextmenu", this.contextMenuEventFired.bind(this), true);
- doc.addEventListener("click", this.documentClick.bind(this), true);
- }
- WebInspector.frontendReused = function()
- {
- this.resourceTreeModel.frontendReused();
- }
- WebInspector._toolbarItemClicked = function(event)
- {
- var toolbarItem = event.currentTarget;
- WebInspector.inspectorView.setCurrentPanel(toolbarItem.panel);
- }
- WebInspector.elementDragStart = function(element, dividerDrag, elementDragEnd, event, cursor)
- {
- if (WebInspector._elementDraggingEventListener || WebInspector._elementEndDraggingEventListener)
- WebInspector.elementDragEnd(event);
- if (element) {
- if (WebInspector._elementDraggingGlassPane)
- WebInspector._elementDraggingGlassPane.parentElement.removeChild(WebInspector._elementDraggingGlassPane);
- var glassPane = document.createElement("div");
- glassPane.style.cssText = "position:absolute;top:0;bottom:0;left:0;right:0;opacity:0;z-index:1";
- glassPane.id = "glass-pane-for-drag";
- element.ownerDocument.body.appendChild(glassPane);
- WebInspector._elementDraggingGlassPane = glassPane;
- }
- WebInspector._elementDraggingEventListener = dividerDrag;
- WebInspector._elementEndDraggingEventListener = elementDragEnd;
- var targetDocument = event.target.ownerDocument;
- targetDocument.addEventListener("mousemove", dividerDrag, true);
- targetDocument.addEventListener("mouseup", elementDragEnd, true);
- targetDocument.body.style.cursor = cursor;
- event.preventDefault();
- }
- WebInspector.elementDragEnd = function(event)
- {
- var targetDocument = event.target.ownerDocument;
- targetDocument.removeEventListener("mousemove", WebInspector._elementDraggingEventListener, true);
- targetDocument.removeEventListener("mouseup", WebInspector._elementEndDraggingEventListener, true);
- targetDocument.body.style.removeProperty("cursor");
- if (WebInspector._elementDraggingGlassPane)
- WebInspector._elementDraggingGlassPane.parentElement.removeChild(WebInspector._elementDraggingGlassPane);
- delete WebInspector._elementDraggingGlassPane;
- delete WebInspector._elementDraggingEventListener;
- delete WebInspector._elementEndDraggingEventListener;
- event.preventDefault();
- }
- WebInspector.animateStyle = function(animations, duration, callback)
- {
- var interval;
- var complete = 0;
- var hasCompleted = false;
- const intervalDuration = (1000 / 30);
- const animationsLength = animations.length;
- const propertyUnit = {opacity: ""};
- const defaultUnit = "px";
- function cubicInOut(t, b, c, d)
- {
- if ((t/=d/2) < 1) return c/2*t*t*t + b;
- return c/2*((t-=2)*t*t + 2) + b;
- }
- for (var i = 0; i < animationsLength; ++i) {
- var animation = animations[i];
- var element = null, start = null, end = null, key = null;
- for (key in animation) {
- if (key === "element")
- element = animation[key];
- else if (key === "start")
- start = animation[key];
- else if (key === "end")
- end = animation[key];
- }
- if (!element || !end)
- continue;
- if (!start) {
- var computedStyle = element.ownerDocument.defaultView.getComputedStyle(element);
- start = {};
- for (key in end)
- start[key] = parseInt(computedStyle.getPropertyValue(key), 10);
- animation.start = start;
- } else
- for (key in start)
- element.style.setProperty(key, start[key] + (key in propertyUnit ? propertyUnit[key] : defaultUnit));
- }
- function animateLoop()
- {
- if (hasCompleted)
- return;
- complete += intervalDuration;
- var next = complete + intervalDuration;
- for (var i = 0; i < animationsLength; ++i) {
- var animation = animations[i];
- var element = animation.element;
- var start = animation.start;
- var end = animation.end;
- if (!element || !end)
- continue;
- var style = element.style;
- for (key in end) {
- var endValue = end[key];
- if (next < duration) {
- var startValue = start[key];
- var newValue = cubicInOut(complete, startValue, endValue - startValue, duration);
- style.setProperty(key, newValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit));
- } else
- style.setProperty(key, endValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit));
- }
- }
- if (complete >= duration) {
- hasCompleted = true;
- clearInterval(interval);
- if (callback)
- callback();
- }
- }
- function forceComplete()
- {
- if (hasCompleted)
- return;
- complete = duration;
- animateLoop();
- }
- function cancel()
- {
- hasCompleted = true;
- clearInterval(interval);
- }
- interval = setInterval(animateLoop, intervalDuration);
- return {
- cancel: cancel,
- forceComplete: forceComplete
- };
- }
- WebInspector.isBeingEdited = function(element)
- {
- if (element.hasStyleClass("text-prompt") || element.nodeName === "INPUT")
- return true;
- if (!WebInspector.__editingCount)
- return false;
- while (element) {
- if (element.__editing)
- return true;
- element = element.parentElement;
- }
- return false;
- }
- WebInspector.markBeingEdited = function(element, value)
- {
- if (value) {
- if (element.__editing)
- return false;
- element.__editing = true;
- WebInspector.__editingCount = (WebInspector.__editingCount || 0) + 1;
- } else {
- if (!element.__editing)
- return false;
- delete element.__editing;
- --WebInspector.__editingCount;
- }
- return true;
- }
- WebInspector.EditingConfig = function(commitHandler, cancelHandler, context)
- {
- this.commitHandler = commitHandler;
- this.cancelHandler = cancelHandler
- this.context = context;
- this.pasteHandler;
- this.multiline;
- this.customFinishHandler;
- }
- WebInspector.EditingConfig.prototype = {
- setPasteHandler: function(pasteHandler)
- {
- this.pasteHandler = pasteHandler;
- },
- setMultiline: function(multiline)
- {
- this.multiline = multiline;
- },
- setCustomFinishHandler: function(customFinishHandler)
- {
- this.customFinishHandler = customFinishHandler;
- }
- }
- WebInspector.startEditing = function(element, config)
- {
- if (!WebInspector.markBeingEdited(element, true))
- return null;
- config = config || new WebInspector.EditingConfig(function() {}, function() {});
- var committedCallback = config.commitHandler;
- var cancelledCallback = config.cancelHandler;
- var pasteCallback = config.pasteHandler;
- var context = config.context;
- var oldText = getContent(element);
- var moveDirection = "";
- element.addStyleClass("editing");
- var oldTabIndex = element.getAttribute("tabIndex");
- if (typeof oldTabIndex !== "number" || oldTabIndex < 0)
- element.tabIndex = 0;
- function blurEventListener() {
- editingCommitted.call(element);
- }
- function getContent(element) {
- if (element.tagName === "INPUT" && element.type === "text")
- return element.value;
- else
- return element.textContent;
- }
- function cleanUpAfterEditing()
- {
- WebInspector.markBeingEdited(element, false);
- this.removeStyleClass("editing");
- if (typeof oldTabIndex !== "number")
- element.removeAttribute("tabIndex");
- else
- this.tabIndex = oldTabIndex;
- this.scrollTop = 0;
- this.scrollLeft = 0;
- element.removeEventListener("blur", blurEventListener, false);
- element.removeEventListener("keydown", keyDownEventListener, true);
- if (pasteCallback)
- element.removeEventListener("paste", pasteEventListener, true);
- WebInspector.restoreFocusFromElement(element);
- }
- function editingCancelled()
- {
- if (this.tagName === "INPUT" && this.type === "text")
- this.value = oldText;
- else
- this.textContent = oldText;
- cleanUpAfterEditing.call(this);
- cancelledCallback(this, context);
- }
- function editingCommitted()
- {
- cleanUpAfterEditing.call(this);
- committedCallback(this, getContent(this), oldText, context, moveDirection);
- }
- function defaultFinishHandler(event)
- {
- var isMetaOrCtrl = WebInspector.isMac() ?
- event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey :
- event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey;
- if (isEnterKey(event) && (event.isMetaOrCtrlForTest || !config.multiline || isMetaOrCtrl))
- return "commit";
- else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code || event.keyIdentifier === "U+001B")
- return "cancel";
- else if (event.keyIdentifier === "U+0009")
- return "move-" + (event.shiftKey ? "backward" : "forward");
- }
- function handleEditingResult(result, event)
- {
- if (result === "commit") {
- editingCommitted.call(element);
- event.consume(true);
- } else if (result === "cancel") {
- editingCancelled.call(element);
- event.consume(true);
- } else if (result && result.indexOf("move-") === 0) {
- moveDirection = result.substring(5);
- if (event.keyIdentifier !== "U+0009")
- blurEventListener();
- }
- }
- function pasteEventListener(event)
- {
- var result = pasteCallback(event);
- handleEditingResult(result, event);
- }
- function keyDownEventListener(event)
- {
- var handler = config.customFinishHandler || defaultFinishHandler;
- var result = handler(event);
- handleEditingResult(result, event);
- }
- element.addEventListener("blur", blurEventListener, false);
- element.addEventListener("keydown", keyDownEventListener, true);
- if (pasteCallback)
- element.addEventListener("paste", pasteEventListener, true);
- WebInspector.setCurrentFocusElement(element);
- return {
- cancel: editingCancelled.bind(element),
- commit: editingCommitted.bind(element)
- };
- }
- 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);
- }
- Number.withThousandsSeparator = function(num)
- {
- var str = num + "";
- var re = /(\d+)(\d{3})/;
- while (str.match(re))
- str = str.replace(re, "$1\u2009$2");
- return str;
- }
- WebInspector._missingLocalizedStrings = {};
- WebInspector.UIString = function(string, vararg)
- {
- if (Preferences.localizeUI) {
- if (window.localizedStrings && string in window.localizedStrings)
- string = window.localizedStrings[string];
- else {
- if (!(string in WebInspector._missingLocalizedStrings)) {
- console.warn("Localized string \"" + string + "\" not found.");
- WebInspector._missingLocalizedStrings[string] = true;
- }
- if (Preferences.showMissingLocalizedStrings)
- string += " (not localized)";
- }
- }
- return String.vsprintf(string, Array.prototype.slice.call(arguments, 1));
- }
- WebInspector.useLowerCaseMenuTitles = function()
- {
- return WebInspector.platform() === "windows" && Preferences.useLowerCaseMenuTitlesOnWindows;
- }
- WebInspector.formatLocalized = function(format, substitutions, formatters, initialValue, append)
- {
- return String.format(WebInspector.UIString(format), substitutions, formatters, initialValue, append);
- }
- WebInspector.openLinkExternallyLabel = function()
- {
- return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Open link in new tab" : "Open Link in New Tab");
- }
- WebInspector.openInNetworkPanelLabel = function()
- {
- return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Open in network panel" : "Open in Network Panel");
- }
- WebInspector.copyLinkAddressLabel = function()
- {
- return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Copy link address" : "Copy Link Address");
- }
- WebInspector.platform = function()
- {
- if (!WebInspector._platform)
- WebInspector._platform = InspectorFrontendHost.platform();
- return WebInspector._platform;
- }
- WebInspector.isMac = function()
- {
- if (typeof WebInspector._isMac === "undefined")
- WebInspector._isMac = WebInspector.platform() === "mac";
- return WebInspector._isMac;
- }
- WebInspector.PlatformFlavor = {
- WindowsVista: "windows-vista",
- MacTiger: "mac-tiger",
- MacLeopard: "mac-leopard",
- MacSnowLeopard: "mac-snowleopard"
- }
- WebInspector.platformFlavor = function()
- {
- function detectFlavor()
- {
- const userAgent = navigator.userAgent;
- if (WebInspector.platform() === "windows") {
- var match = userAgent.match(/Windows NT (\d+)\.(?:\d+)/);
- if (match && match[1] >= 6)
- return WebInspector.PlatformFlavor.WindowsVista;
- return null;
- } else if (WebInspector.platform() === "mac") {
- var match = userAgent.match(/Mac OS X\s*(?:(\d+)_(\d+))?/);
- if (!match || match[1] != 10)
- return WebInspector.PlatformFlavor.MacSnowLeopard;
- switch (Number(match[2])) {
- case 4:
- return WebInspector.PlatformFlavor.MacTiger;
- case 5:
- return WebInspector.PlatformFlavor.MacLeopard;
- case 6:
- default:
- return WebInspector.PlatformFlavor.MacSnowLeopard;
- }
- }
- }
- if (!WebInspector._platformFlavor)
- WebInspector._platformFlavor = detectFlavor();
- return WebInspector._platformFlavor;
- }
- WebInspector.port = function()
- {
- if (!WebInspector._port)
- WebInspector._port = InspectorFrontendHost.port();
- return WebInspector._port;
- }
- WebInspector.installPortStyles = function()
- {
- var platform = WebInspector.platform();
- document.body.addStyleClass("platform-" + platform);
- var flavor = WebInspector.platformFlavor();
- if (flavor)
- document.body.addStyleClass("platform-" + flavor);
- var port = WebInspector.port();
- document.body.addStyleClass("port-" + port);
- }
- WebInspector._windowFocused = function(event)
- {
- if (event.target.document.nodeType === Node.DOCUMENT_NODE)
- document.body.removeStyleClass("inactive");
- }
- WebInspector._windowBlurred = function(event)
- {
- if (event.target.document.nodeType === Node.DOCUMENT_NODE)
- document.body.addStyleClass("inactive");
- }
- WebInspector.previousFocusElement = function()
- {
- return WebInspector._previousFocusElement;
- }
- WebInspector.currentFocusElement = function()
- {
- return WebInspector._currentFocusElement;
- }
- WebInspector._focusChanged = function(event)
- {
- WebInspector.setCurrentFocusElement(event.target);
- }
- WebInspector._textInputTypes = ["text", "search", "tel", "url", "email", "password"].keySet();
- WebInspector._isTextEditingElement = function(element)
- {
- if (element instanceof HTMLInputElement)
- return element.type in WebInspector._textInputTypes;
- if (element instanceof HTMLTextAreaElement)
- return true;
- return false;
- }
- WebInspector.setCurrentFocusElement = function(x)
- {
- if (WebInspector._currentFocusElement !== x)
- WebInspector._previousFocusElement = WebInspector._currentFocusElement;
- WebInspector._currentFocusElement = x;
- if (WebInspector._currentFocusElement) {
- WebInspector._currentFocusElement.focus();
- var selection = window.getSelection();
- if (!WebInspector._isTextEditingElement(WebInspector._currentFocusElement) && selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCaretInside()) {
- var selectionRange = WebInspector._currentFocusElement.ownerDocument.createRange();
- selectionRange.setStart(WebInspector._currentFocusElement, 0);
- selectionRange.setEnd(WebInspector._currentFocusElement, 0);
- selection.removeAllRanges();
- selection.addRange(selectionRange);
- }
- } else if (WebInspector._previousFocusElement)
- WebInspector._previousFocusElement.blur();
- }
- WebInspector.restoreFocusFromElement = function(element)
- {
- if (element && element.isSelfOrAncestor(WebInspector.currentFocusElement()))
- WebInspector.setCurrentFocusElement(WebInspector.previousFocusElement());
- }
- WebInspector.setToolbarColors = function(backgroundColor, color)
- {
- if (!WebInspector._themeStyleElement) {
- WebInspector._themeStyleElement = document.createElement("style");
- document.head.appendChild(WebInspector._themeStyleElement);
- }
- WebInspector._themeStyleElement.textContent =
- "#toolbar {\
- background-image: none !important;\
- background-color: " + backgroundColor + " !important;\
- }\
- \
- .toolbar-label {\
- color: " + color + " !important;\
- text-shadow: none;\
- }";
- }
- WebInspector.resetToolbarColors = function()
- {
- if (WebInspector._themeStyleElement)
- WebInspector._themeStyleElement.textContent = "";
- }
- WebInspector.populateHrefContextMenu = function(contextMenu, contextNode, event)
- {
- var anchorElement = event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link") || event.target.enclosingNodeOrSelfWithClass("webkit-html-external-link");
- if (!anchorElement)
- return false;
- var resourceURL = WebInspector.resourceURLForRelatedNode(contextNode, anchorElement.href);
- if (!resourceURL)
- return false;
- contextMenu.appendItem(WebInspector.openLinkExternallyLabel(), WebInspector.openResource.bind(WebInspector, resourceURL, false));
- if (WebInspector.resourceForURL(resourceURL))
- contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Open link in Resources panel" : "Open Link in Resources Panel"), WebInspector.openResource.bind(null, resourceURL, true));
- contextMenu.appendItem(WebInspector.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(InspectorFrontendHost, resourceURL));
- return true;
- }
- ;(function() {
- function windowLoaded()
- {
- window.addEventListener("focus", WebInspector._windowFocused, false);
- window.addEventListener("blur", WebInspector._windowBlurred, false);
- document.addEventListener("focus", WebInspector._focusChanged.bind(this), true);
- window.removeEventListener("DOMContentLoaded", windowLoaded, false);
- }
- window.addEventListener("DOMContentLoaded", windowLoaded, false);
- })();
- function InspectorBackendClass()
- {
- this._lastCallbackId = 1;
- this._pendingResponsesCount = 0;
- this._callbacks = {};
- this._domainDispatchers = {};
- this._eventArgs = {};
- this._replyArgs = {};
- this.dumpInspectorTimeStats = false;
- this.dumpInspectorProtocolMessages = false;
- this._initialized = false;
- }
- InspectorBackendClass.prototype = {
- _wrap: function(callback, method)
- {
- var callbackId = this._lastCallbackId++;
- if (!callback)
- callback = function() {};
- this._callbacks[callbackId] = callback;
- callback.methodName = method;
- if (this.dumpInspectorTimeStats)
- callback.sendRequestTime = Date.now();
- return callbackId;
- },
- registerCommand: function(method, signature, replyArgs)
- {
- var domainAndMethod = method.split(".");
- var agentName = domainAndMethod[0] + "Agent";
- if (!window[agentName])
- window[agentName] = {};
- window[agentName][domainAndMethod[1]] = this._sendMessageToBackend.bind(this, method, signature);
- window[agentName][domainAndMethod[1]]["invoke"] = this._invoke.bind(this, method, signature);
- this._replyArgs[method] = replyArgs;
- this._initialized = true;
- },
- registerEvent: function(eventName, params)
- {
- this._eventArgs[eventName] = params;
- this._initialized = true;
- },
- _invoke: function(method, signature, args, callback)
- {
- this._wrapCallbackAndSendMessageObject(method, args, callback);
- },
- _sendMessageToBackend: function(method, signature, vararg)
- {
- var args = Array.prototype.slice.call(arguments, 2);
- var callback = (args.length && typeof args[args.length - 1] === "function") ? args.pop() : null;
- var params = {};
- var hasParams = false;
- for (var i = 0; i < signature.length; ++i) {
- var param = signature[i];
- var paramName = param["name"];
- var typeName = param["type"];
- var optionalFlag = param["optional"];
- if (!args.length && !optionalFlag) {
- console.error("Protocol Error: Invalid number of arguments for method '" + method + "' call. It must have the following arguments '" + JSON.stringify(signature) + "'.");
- return;
- }
- var value = args.shift();
- if (optionalFlag && typeof value === "undefined") {
- continue;
- }
- if (typeof value !== typeName) {
- console.error("Protocol Error: Invalid type of argument '" + paramName + "' for method '" + method + "' call. It must be '" + typeName + "' but it is '" + typeof value + "'.");
- return;
- }
- params[paramName] = value;
- hasParams = true;
- }
- if (args.length === 1 && !callback) {
- if (typeof args[0] !== "undefined") {
- console.error("Protocol Error: Optional callback argument for method '" + method + "' call must be a function but its type is '" + typeof args[0] + "'.");
- return;
- }
- }
- this._wrapCallbackAndSendMessageObject(method, hasParams ? params : null, callback);
- },
- _wrapCallbackAndSendMessageObject: function(method, params, callback)
- {
- var messageObject = {};
- messageObject.method = method;
- if (params)
- messageObject.params = params;
- messageObject.id = this._wrap(callback, method);
- if (this.dumpInspectorProtocolMessages)
- console.log("frontend: " + JSON.stringify(messageObject));
- ++this._pendingResponsesCount;
- this.sendMessageObjectToBackend(messageObject);
- },
- sendMessageObjectToBackend: function(messageObject)
- {
- var message = JSON.stringify(messageObject);
- InspectorFrontendHost.sendMessageToBackend(message);
- },
- registerDomainDispatcher: function(domain, dispatcher)
- {
- this._domainDispatchers[domain] = dispatcher;
- },
- dispatch: function(message)
- {
- if (this.dumpInspectorProtocolMessages)
- console.log("backend: " + ((typeof message === "string") ? message : JSON.stringify(message)));
- var messageObject = (typeof message === "string") ? JSON.parse(message) : message;
- if ("id" in messageObject) {
- if (messageObject.error) {
- messageObject.error.__proto__ = {
- getDescription: function()
- {
- switch(this.code) {
- case -32700: return "Parse error";
- case -32600: return "Invalid Request";
- case -32601: return "Method not found";
- case -32602: return "Invalid params";
- case -32603: return "Internal error";;
- case -32000: return "Server error";
- }
- },
- toString: function()
- {
- var description ="Unknown error code";
- return this.getDescription() + "(" + this.code + "): " + this.message + "." + (this.data ? " " + this.data.join(" ") : "");
- },
- getMessage: function()
- {
- return this.message;
- }
- }
- if (messageObject.error.code !== -32000)
- this.reportProtocolError(messageObject);
- }
- var callback = this._callbacks[messageObject.id];
- if (callback) {
- var argumentsArray = [];
- if (messageObject.result) {
- var paramNames = this._replyArgs[callback.methodName];
- if (paramNames) {
- for (var i = 0; i < paramNames.length; ++i)
- argumentsArray.push(messageObject.result[paramNames[i]]);
- }
- }
- var processingStartTime;
- if (this.dumpInspectorTimeStats && callback.methodName)
- processingStartTime = Date.now();
- argumentsArray.unshift(messageObject.error);
- callback.apply(null, argumentsArray);
- --this._pendingResponsesCount;
- delete this._callbacks[messageObject.id];
- if (this.dumpInspectorTimeStats && callback.methodName)
- console.log("time-stats: " + callback.methodName + " = " + (processingStartTime - callback.sendRequestTime) + " + " + (Date.now() - processingStartTime));
- }
- if (this._scripts && !this._pendingResponsesCount)
- this.runAfterPendingDispatches();
- return;
- } else {
- var method = messageObject.method.split(".");
- var domainName = method[0];
- var functionName = method[1];
- if (!(domainName in this._domainDispatchers)) {
- console.error("Protocol Error: the message is for non-existing domain '" + domainName + "'");
- return;
- }
- var dispatcher = this._domainDispatchers[domainName];
- if (!(functionName in dispatcher)) {
- console.error("Protocol Error: Attempted to dispatch an unimplemented method '" + messageObject.method + "'");
- return;
- }
- if (!this._eventArgs[messageObject.method]) {
- console.error("Protocol Error: Attempted to dispatch an unspecified method '" + messageObject.method + "'");
- return;
- }
- var params = [];
- if (messageObject.params) {
- var paramNames = this._eventArgs[messageObject.method];
- for (var i = 0; i < paramNames.length; ++i)
- params.push(messageObject.params[paramNames[i]]);
- }
- var processingStartTime;
- if (this.dumpInspectorTimeStats)
- processingStartTime = Date.now();
- dispatcher[functionName].apply(dispatcher, params);
- if (this.dumpInspectorTimeStats)
- console.log("time-stats: " + messageObject.method + " = " + (Date.now() - processingStartTime));
- }
- },
- reportProtocolError: function(messageObject)
- {
- console.error("Request with id = " + messageObject.id + " failed. " + messageObject.error);
- },
- runAfterPendingDispatches: function(script)
- {
- if (!this._scripts)
- this._scripts = [];
- if (script)
- this._scripts.push(script);
- if (!this._pendingResponsesCount) {
- var scripts = this._scripts;
- this._scripts = []
- for (var id = 0; id < scripts.length; ++id)
- scripts[id].call(this);
- }
- },
- loadFromJSONIfNeeded: function()
- {
- if (this._initialized)
- return;
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "../Inspector.json", false);
- xhr.send(null);
- var schema = JSON.parse(xhr.responseText);
- var jsTypes = { integer: "number", array: "object" };
- var rawTypes = {};
- var domains = schema["domains"];
- for (var i = 0; i < domains.length; ++i) {
- var domain = domains[i];
- for (var j = 0; domain.types && j < domain.types.length; ++j) {
- var type = domain.types[j];
- rawTypes[domain.domain + "." + type.id] = jsTypes[type.type] || type.type;
- }
- }
- var result = [];
- for (var i = 0; i < domains.length; ++i) {
- var domain = domains[i];
- var commands = domain["commands"] || [];
- for (var j = 0; j < commands.length; ++j) {
- var command = commands[j];
- var parameters = command["parameters"];
- var paramsText = [];
- for (var k = 0; parameters && k < parameters.length; ++k) {
- var parameter = parameters[k];
- var type;
- if (parameter.type)
- type = jsTypes[parameter.type] || parameter.type;
- else {
- var ref = parameter["$ref"];
- if (ref.indexOf(".") !== -1)
- type = rawTypes[ref];
- else
- type = rawTypes[domain.domain + "." + ref];
- }
- var text = "{\"name\": \"" + parameter.name + "\", \"type\": \"" + type + "\", \"optional\": " + (parameter.optional ? "true" : "false") + "}";
- paramsText.push(text);
- }
- var returnsText = [];
- var returns = command["returns"] || [];
- for (var k = 0; k < returns.length; ++k) {
- var parameter = returns[k];
- returnsText.push("\"" + parameter.name + "\"");
- }
- result.push("InspectorBackend.registerCommand(\"" + domain.domain + "." + command.name + "\", [" + paramsText.join(", ") + "], [" + returnsText.join(", ") + "]);");
- }
- for (var j = 0; domain.events && j < domain.events.length; ++j) {
- var event = domain.events[j];
- var paramsText = [];
- for (var k = 0; event.parameters && k < event.parameters.length; ++k) {
- var parameter = event.parameters[k];
- paramsText.push("\"" + parameter.name + "\"");
- }
- result.push("InspectorBackend.registerEvent(\"" + domain.domain + "." + event.name + "\", [" + paramsText.join(", ") + "]);");
- }
- result.push("InspectorBackend.register" + domain.domain + "Dispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, \"" + domain.domain + "\");");
- }
- eval(result.join("\n"));
- }
- }
- InspectorBackend = new InspectorBackendClass();
- InspectorBackend.registerInspectorDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Inspector");
- InspectorBackend.registerEvent("Inspector.evaluateForTestInFrontend", ["testCallId", "script"]);
- InspectorBackend.registerEvent("Inspector.inspect", ["object", "hints"]);
- InspectorBackend.registerEvent("Inspector.didCreateWorker", ["id", "url", "isShared"]);
- InspectorBackend.registerEvent("Inspector.didDestroyWorker", ["id"]);
- InspectorBackend.registerCommand("Inspector.enable", [], []);
- InspectorBackend.registerCommand("Inspector.disable", [], []);
- InspectorBackend.registerMemoryDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Memory");
- InspectorBackend.registerCommand("Memory.getDOMNodeCount", [], ["domGroups", "strings"]);
- InspectorBackend.registerPageDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Page");
- InspectorBackend.registerEvent("Page.domContentEventFired", ["timestamp"]);
- InspectorBackend.registerEvent("Page.loadEventFired", ["timestamp"]);
- InspectorBackend.registerEvent("Page.frameNavigated", ["frame"]);
- InspectorBackend.registerEvent("Page.frameDetached", ["frameId"]);
- InspectorBackend.registerCommand("Page.enable", [], []);
- InspectorBackend.registerCommand("Page.disable", [], []);
- InspectorBackend.registerCommand("Page.addScriptToEvaluateOnLoad", [{"name": "scriptSource", "type": "string", "optional": false}], ["identifier"]);
- InspectorBackend.registerCommand("Page.removeScriptToEvaluateOnLoad", [{"name": "identifier", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Page.reload", [{"name": "ignoreCache", "type": "boolean", "optional": true}, {"name": "scriptToEvaluateOnLoad", "type": "string", "optional": true}], []);
- InspectorBackend.registerCommand("Page.navigate", [{"name": "url", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Page.getCookies", [], ["cookies", "cookiesString"]);
- InspectorBackend.registerCommand("Page.deleteCookie", [{"name": "cookieName", "type": "string", "optional": false}, {"name": "domain", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Page.getResourceTree", [], ["frameTree"]);
- InspectorBackend.registerCommand("Page.getResourceContent", [{"name": "frameId", "type": "string", "optional": false}, {"name": "url", "type": "string", "optional": false}], ["content", "base64Encoded"]);
- InspectorBackend.registerCommand("Page.searchInResource", [{"name": "frameId", "type": "string", "optional": false}, {"name": "url", "type": "string", "optional": false}, {"name": "query", "type": "string", "optional": false}, {"name": "caseSensitive", "type": "boolean", "optional": true}, {"name": "isRegex", "type": "boolean", "optional": true}], ["result"]);
- InspectorBackend.registerCommand("Page.searchInResources", [{"name": "text", "type": "string", "optional": false}, {"name": "caseSensitive", "type": "boolean", "optional": true}, {"name": "isRegex", "type": "boolean", "optional": true}], ["result"]);
- InspectorBackend.registerCommand("Page.setDocumentContent", [{"name": "frameId", "type": "string", "optional": false}, {"name": "html", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Page.canOverrideDeviceMetrics", [], ["result"]);
- InspectorBackend.registerCommand("Page.setDeviceMetricsOverride", [{"name": "width", "type": "number", "optional": false}, {"name": "height", "type": "number", "optional": false}, {"name": "fontScaleFactor", "type": "number", "optional": false}], []);
- InspectorBackend.registerCommand("Page.setShowPaintRects", [{"name": "result", "type": "boolean", "optional": false}], []);
- InspectorBackend.registerCommand("Runtime.evaluate", [{"name": "expression", "type": "string", "optional": false}, {"name": "objectGroup", "type": "string", "optional": true}, {"name": "includeCommandLineAPI", "type": "boolean", "optional": true}, {"name": "doNotPauseOnExceptions", "type": "boolean", "optional": true}, {"name": "frameId", "type": "string", "optional": true}, {"name": "returnByValue", "type": "boolean", "optional": true}], ["result", "wasThrown"]);
- InspectorBackend.registerCommand("Runtime.callFunctionOn", [{"name": "objectId", "type": "string", "optional": false}, {"name": "functionDeclaration", "type": "string", "optional": false}, {"name": "arguments", "type": "object", "optional": true}, {"name": "returnByValue", "type": "boolean", "optional": true}], ["result", "wasThrown"]);
- InspectorBackend.registerCommand("Runtime.getProperties", [{"name": "objectId", "type": "string", "optional": false}, {"name": "ownProperties", "type": "boolean", "optional": true}], ["result"]);
- InspectorBackend.registerCommand("Runtime.releaseObject", [{"name": "objectId", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Runtime.releaseObjectGroup", [{"name": "objectGroup", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Runtime.run", [], []);
- InspectorBackend.registerConsoleDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Console");
- InspectorBackend.registerEvent("Console.messageAdded", ["message"]);
- InspectorBackend.registerEvent("Console.messageRepeatCountUpdated", ["count"]);
- InspectorBackend.registerEvent("Console.messagesCleared", []);
- InspectorBackend.registerCommand("Console.enable", [], []);
- InspectorBackend.registerCommand("Console.disable", [], []);
- InspectorBackend.registerCommand("Console.clearMessages", [], []);
- InspectorBackend.registerCommand("Console.setMonitoringXHREnabled", [{"name": "enabled", "type": "boolean", "optional": false}], []);
- InspectorBackend.registerCommand("Console.addInspectedNode", [{"name": "nodeId", "type": "number", "optional": false}], []);
- InspectorBackend.registerCommand("Console.addInspectedHeapObject", [{"name": "heapObjectId", "type": "number", "optional": false}], []);
- InspectorBackend.registerNetworkDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Network");
- InspectorBackend.registerEvent("Network.requestWillBeSent", ["requestId", "frameId", "loaderId", "documentURL", "request", "timestamp", "initiator", "stackTrace", "redirectResponse"]);
- InspectorBackend.registerEvent("Network.requestServedFromCache", ["requestId"]);
- InspectorBackend.registerEvent("Network.responseReceived", ["requestId", "frameId", "loaderId", "timestamp", "type", "response"]);
- InspectorBackend.registerEvent("Network.dataReceived", ["requestId", "timestamp", "dataLength", "encodedDataLength"]);
- InspectorBackend.registerEvent("Network.loadingFinished", ["requestId", "timestamp"]);
- InspectorBackend.registerEvent("Network.loadingFailed", ["requestId", "timestamp", "errorText", "canceled"]);
- InspectorBackend.registerEvent("Network.requestServedFromMemoryCache", ["requestId", "frameId", "loaderId", "documentURL", "timestamp", "initiator", "resource"]);
- InspectorBackend.registerEvent("Network.webSocketWillSendHandshakeRequest", ["requestId", "timestamp", "request"]);
- InspectorBackend.registerEvent("Network.webSocketHandshakeResponseReceived", ["requestId", "timestamp", "response"]);
- InspectorBackend.registerEvent("Network.webSocketCreated", ["requestId", "url"]);
- InspectorBackend.registerEvent("Network.webSocketClosed", ["requestId", "timestamp"]);
- InspectorBackend.registerCommand("Network.enable", [], []);
- InspectorBackend.registerCommand("Network.disable", [], []);
- InspectorBackend.registerCommand("Network.setUserAgentOverride", [{"name": "userAgent", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Network.setExtraHTTPHeaders", [{"name": "headers", "type": "object", "optional": false}], []);
- InspectorBackend.registerCommand("Network.getResponseBody", [{"name": "requestId", "type": "string", "optional": false}], ["body", "base64Encoded"]);
- InspectorBackend.registerCommand("Network.canClearBrowserCache", [], ["result"]);
- InspectorBackend.registerCommand("Network.clearBrowserCache", [], []);
- InspectorBackend.registerCommand("Network.canClearBrowserCookies", [], ["result"]);
- InspectorBackend.registerCommand("Network.clearBrowserCookies", [], []);
- InspectorBackend.registerCommand("Network.setCacheDisabled", [{"name": "cacheDisabled", "type": "boolean", "optional": false}], []);
- InspectorBackend.registerDatabaseDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Database");
- InspectorBackend.registerEvent("Database.addDatabase", ["database"]);
- InspectorBackend.registerEvent("Database.sqlTransactionSucceeded", ["transactionId", "columnNames", "values"]);
- InspectorBackend.registerEvent("Database.sqlTransactionFailed", ["transactionId", "sqlError"]);
- InspectorBackend.registerCommand("Database.enable", [], []);
- InspectorBackend.registerCommand("Database.disable", [], []);
- InspectorBackend.registerCommand("Database.getDatabaseTableNames", [{"name": "databaseId", "type": "string", "optional": false}], ["tableNames"]);
- InspectorBackend.registerCommand("Database.executeSQL", [{"name": "databaseId", "type": "string", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["success", "transactionId"]);
- InspectorBackend.registerIndexedDBDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "IndexedDB");
- InspectorBackend.registerEvent("IndexedDB.databaseNamesLoaded", ["requestId", "securityOriginWithDatabaseNames"]);
- InspectorBackend.registerEvent("IndexedDB.databaseLoaded", ["requestId", "databaseWithObjectStores"]);
- InspectorBackend.registerEvent("IndexedDB.objectStoreDataLoaded", ["requestId", "objectStoreDataEntries", "hasMore"]);
- InspectorBackend.registerEvent("IndexedDB.indexDataLoaded", ["requestId", "indexDataEntries", "hasMore"]);
- InspectorBackend.registerCommand("IndexedDB.enable", [], []);
- InspectorBackend.registerCommand("IndexedDB.disable", [], []);
- InspectorBackend.registerCommand("IndexedDB.requestDatabaseNamesForFrame", [{"name": "requestId", "type": "number", "optional": false}, {"name": "frameId", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("IndexedDB.requestDatabase", [{"name": "requestId", "type": "number", "optional": false}, {"name": "frameId", "type": "string", "optional": false}, {"name": "databaseName", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("IndexedDB.requestData", [{"name": "requestId", "type": "number", "optional": false}, {"name": "frameId", "type": "string", "optional": false}, {"name": "databaseName", "type": "string", "optional": false}, {"name": "objectStoreName", "type": "string", "optional": false}, {"name": "indexName", "type": "string", "optional": false}, {"name": "skipCount", "type": "number", "optional": false}, {"name": "pageSize", "type": "number", "optional": false}, {"name": "keyRange", "type": "object", "optional": true}], []);
- InspectorBackend.registerDOMStorageDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "DOMStorage");
- InspectorBackend.registerEvent("DOMStorage.addDOMStorage", ["storage"]);
- InspectorBackend.registerEvent("DOMStorage.updateDOMStorage", ["storageId"]);
- InspectorBackend.registerCommand("DOMStorage.enable", [], []);
- InspectorBackend.registerCommand("DOMStorage.disable", [], []);
- InspectorBackend.registerCommand("DOMStorage.getDOMStorageEntries", [{"name": "storageId", "type": "string", "optional": false}], ["entries"]);
- InspectorBackend.registerCommand("DOMStorage.setDOMStorageItem", [{"name": "storageId", "type": "string", "optional": false}, {"name": "key", "type": "string", "optional": false}, {"name": "value", "type": "string", "optional": false}], ["success"]);
- InspectorBackend.registerCommand("DOMStorage.removeDOMStorageItem", [{"name": "storageId", "type": "string", "optional": false}, {"name": "key", "type": "string", "optional": false}], ["success"]);
- InspectorBackend.registerApplicationCacheDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "ApplicationCache");
- InspectorBackend.registerEvent("ApplicationCache.applicationCacheStatusUpdated", ["frameId", "manifestURL", "status"]);
- InspectorBackend.registerEvent("ApplicationCache.networkStateUpdated", ["isNowOnline"]);
- InspectorBackend.registerCommand("ApplicationCache.getFramesWithManifests", [], ["frameIds"]);
- InspectorBackend.registerCommand("ApplicationCache.enable", [], []);
- InspectorBackend.registerCommand("ApplicationCache.getManifestForFrame", [{"name": "frameId", "type": "string", "optional": false}], ["manifestURL"]);
- InspectorBackend.registerCommand("ApplicationCache.getApplicationCacheForFrame", [{"name": "frameId", "type": "string", "optional": false}], ["applicationCache"]);
- InspectorBackend.registerFileSystemDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "FileSystem");
- InspectorBackend.registerCommand("FileSystem.enable", [], []);
- InspectorBackend.registerCommand("FileSystem.disable", [], []);
- InspectorBackend.registerDOMDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "DOM");
- InspectorBackend.registerEvent("DOM.documentUpdated", []);
- InspectorBackend.registerEvent("DOM.setChildNodes", ["parentId", "nodes"]);
- InspectorBackend.registerEvent("DOM.attributeModified", ["nodeId", "name", "value"]);
- InspectorBackend.registerEvent("DOM.attributeRemoved", ["nodeId", "name"]);
- InspectorBackend.registerEvent("DOM.inlineStyleInvalidated", ["nodeIds"]);
- InspectorBackend.registerEvent("DOM.characterDataModified", ["nodeId", "characterData"]);
- InspectorBackend.registerEvent("DOM.childNodeCountUpdated", ["nodeId", "childNodeCount"]);
- InspectorBackend.registerEvent("DOM.childNodeInserted", ["parentNodeId", "previousNodeId", "node"]);
- InspectorBackend.registerEvent("DOM.childNodeRemoved", ["parentNodeId", "nodeId"]);
- InspectorBackend.registerEvent("DOM.shadowRootPushed", ["hostId", "root"]);
- InspectorBackend.registerEvent("DOM.shadowRootPopped", ["hostId", "rootId"]);
- InspectorBackend.registerCommand("DOM.getDocument", [], ["root"]);
- InspectorBackend.registerCommand("DOM.requestChildNodes", [{"name": "nodeId", "type": "number", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.querySelector", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "selector", "type": "string", "optional": false}], ["nodeId"]);
- InspectorBackend.registerCommand("DOM.querySelectorAll", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "selector", "type": "string", "optional": false}], ["nodeIds"]);
- InspectorBackend.registerCommand("DOM.setNodeName", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "name", "type": "string", "optional": false}], ["nodeId"]);
- InspectorBackend.registerCommand("DOM.setNodeValue", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "value", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.removeNode", [{"name": "nodeId", "type": "number", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.setAttributeValue", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "name", "type": "string", "optional": false}, {"name": "value", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.setAttributesAsText", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "text", "type": "string", "optional": false}, {"name": "name", "type": "string", "optional": true}], []);
- InspectorBackend.registerCommand("DOM.removeAttribute", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "name", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.getEventListenersForNode", [{"name": "nodeId", "type": "number", "optional": false}], ["listeners"]);
- InspectorBackend.registerCommand("DOM.getOuterHTML", [{"name": "nodeId", "type": "number", "optional": false}], ["outerHTML"]);
- InspectorBackend.registerCommand("DOM.setOuterHTML", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "outerHTML", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.performSearch", [{"name": "query", "type": "string", "optional": false}], ["searchId", "resultCount"]);
- InspectorBackend.registerCommand("DOM.getSearchResults", [{"name": "searchId", "type": "string", "optional": false}, {"name": "fromIndex", "type": "number", "optional": false}, {"name": "toIndex", "type": "number", "optional": false}], ["nodeIds"]);
- InspectorBackend.registerCommand("DOM.discardSearchResults", [{"name": "searchId", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.requestNode", [{"name": "objectId", "type": "string", "optional": false}], ["nodeId"]);
- InspectorBackend.registerCommand("DOM.setInspectModeEnabled", [{"name": "enabled", "type": "boolean", "optional": false}, {"name": "highlightConfig", "type": "object", "optional": true}], []);
- InspectorBackend.registerCommand("DOM.highlightRect", [{"name": "x", "type": "number", "optional": false}, {"name": "y", "type": "number", "optional": false}, {"name": "width", "type": "number", "optional": false}, {"name": "height", "type": "number", "optional": false}, {"name": "color", "type": "object", "optional": true}, {"name": "outlineColor", "type": "object", "optional": true}], []);
- InspectorBackend.registerCommand("DOM.highlightNode", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "highlightConfig", "type": "object", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.hideHighlight", [], []);
- InspectorBackend.registerCommand("DOM.highlightFrame", [{"name": "frameId", "type": "string", "optional": false}, {"name": "contentColor", "type": "object", "optional": true}, {"name": "contentOutlineColor", "type": "object", "optional": true}], []);
- InspectorBackend.registerCommand("DOM.pushNodeByPathToFrontend", [{"name": "path", "type": "string", "optional": false}], ["nodeId"]);
- InspectorBackend.registerCommand("DOM.resolveNode", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "objectGroup", "type": "string", "optional": true}], ["object"]);
- InspectorBackend.registerCommand("DOM.getAttributes", [{"name": "nodeId", "type": "number", "optional": false}], ["attributes"]);
- InspectorBackend.registerCommand("DOM.moveTo", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "targetNodeId", "type": "number", "optional": false}, {"name": "insertBeforeNodeId", "type": "number", "optional": true}], ["nodeId"]);
- InspectorBackend.registerCommand("DOM.setTouchEmulationEnabled", [{"name": "enabled", "type": "boolean", "optional": false}], []);
- InspectorBackend.registerCommand("DOM.undo", [], []);
- InspectorBackend.registerCommand("DOM.redo", [], []);
- InspectorBackend.registerCommand("DOM.markUndoableState", [], []);
- InspectorBackend.registerCSSDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "CSS");
- InspectorBackend.registerEvent("CSS.mediaQueryResultChanged", []);
- InspectorBackend.registerEvent("CSS.styleSheetChanged", ["styleSheetId"]);
- InspectorBackend.registerCommand("CSS.enable", [], []);
- InspectorBackend.registerCommand("CSS.disable", [], []);
- InspectorBackend.registerCommand("CSS.getMatchedStylesForNode", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "forcedPseudoClasses", "type": "object", "optional": true}, {"name": "includePseudo", "type": "boolean", "optional": true}, {"name": "includeInherited", "type": "boolean", "optional": true}], ["matchedCSSRules", "pseudoElements", "inherited"]);
- InspectorBackend.registerCommand("CSS.getInlineStylesForNode", [{"name": "nodeId", "type": "number", "optional": false}], ["inlineStyle", "attributesStyle"]);
- InspectorBackend.registerCommand("CSS.getComputedStyleForNode", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "forcedPseudoClasses", "type": "object", "optional": true}], ["computedStyle"]);
- InspectorBackend.registerCommand("CSS.getAllStyleSheets", [], ["headers"]);
- InspectorBackend.registerCommand("CSS.getStyleSheet", [{"name": "styleSheetId", "type": "string", "optional": false}], ["styleSheet"]);
- InspectorBackend.registerCommand("CSS.getStyleSheetText", [{"name": "styleSheetId", "type": "string", "optional": false}], ["text"]);
- InspectorBackend.registerCommand("CSS.setStyleSheetText", [{"name": "styleSheetId", "type": "string", "optional": false}, {"name": "text", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("CSS.setPropertyText", [{"name": "styleId", "type": "object", "optional": false}, {"name": "propertyIndex", "type": "number", "optional": false}, {"name": "text", "type": "string", "optional": false}, {"name": "overwrite", "type": "boolean", "optional": false}], ["style"]);
- InspectorBackend.registerCommand("CSS.toggleProperty", [{"name": "styleId", "type": "object", "optional": false}, {"name": "propertyIndex", "type": "number", "optional": false}, {"name": "disable", "type": "boolean", "optional": false}], ["style"]);
- InspectorBackend.registerCommand("CSS.setRuleSelector", [{"name": "ruleId", "type": "object", "optional": false}, {"name": "selector", "type": "string", "optional": false}], ["rule"]);
- InspectorBackend.registerCommand("CSS.addRule", [{"name": "contextNodeId", "type": "number", "optional": false}, {"name": "selector", "type": "string", "optional": false}], ["rule"]);
- InspectorBackend.registerCommand("CSS.getSupportedCSSProperties", [], ["cssProperties"]);
- InspectorBackend.registerCommand("CSS.startSelectorProfiler", [], []);
- InspectorBackend.registerCommand("CSS.stopSelectorProfiler", [], ["profile"]);
- InspectorBackend.registerTimelineDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Timeline");
- InspectorBackend.registerEvent("Timeline.eventRecorded", ["record"]);
- InspectorBackend.registerCommand("Timeline.start", [{"name": "maxCallStackDepth", "type": "number", "optional": true}], []);
- InspectorBackend.registerCommand("Timeline.stop", [], []);
- InspectorBackend.registerCommand("Timeline.setIncludeMemoryDetails", [{"name": "enabled", "type": "boolean", "optional": false}], []);
- InspectorBackend.registerDebuggerDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Debugger");
- InspectorBackend.registerEvent("Debugger.globalObjectCleared", []);
- InspectorBackend.registerEvent("Debugger.scriptParsed", ["scriptId", "url", "startLine", "startColumn", "endLine", "endColumn", "isContentScript", "sourceMapURL"]);
- InspectorBackend.registerEvent("Debugger.scriptFailedToParse", ["url", "scriptSource", "startLine", "errorLine", "errorMessage"]);
- InspectorBackend.registerEvent("Debugger.breakpointResolved", ["breakpointId", "location"]);
- InspectorBackend.registerEvent("Debugger.paused", ["callFrames", "reason", "data"]);
- InspectorBackend.registerEvent("Debugger.resumed", []);
- InspectorBackend.registerCommand("Debugger.causesRecompilation", [], ["result"]);
- InspectorBackend.registerCommand("Debugger.supportsNativeBreakpoints", [], ["result"]);
- InspectorBackend.registerCommand("Debugger.enable", [], []);
- InspectorBackend.registerCommand("Debugger.disable", [], []);
- InspectorBackend.registerCommand("Debugger.setBreakpointsActive", [{"name": "active", "type": "boolean", "optional": false}], []);
- InspectorBackend.registerCommand("Debugger.setBreakpointByUrl", [{"name": "lineNumber", "type": "number", "optional": false}, {"name": "url", "type": "string", "optional": true}, {"name": "urlRegex", "type": "string", "optional": true}, {"name": "columnNumber", "type": "number", "optional": true}, {"name": "condition", "type": "string", "optional": true}], ["breakpointId", "locations"]);
- InspectorBackend.registerCommand("Debugger.setBreakpoint", [{"name": "location", "type": "object", "optional": false}, {"name": "condition", "type": "string", "optional": true}], ["breakpointId", "actualLocation"]);
- InspectorBackend.registerCommand("Debugger.removeBreakpoint", [{"name": "breakpointId", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Debugger.continueToLocation", [{"name": "location", "type": "object", "optional": false}], []);
- InspectorBackend.registerCommand("Debugger.stepOver", [], []);
- InspectorBackend.registerCommand("Debugger.stepInto", [], []);
- InspectorBackend.registerCommand("Debugger.stepOut", [], []);
- InspectorBackend.registerCommand("Debugger.pause", [], []);
- InspectorBackend.registerCommand("Debugger.resume", [], []);
- InspectorBackend.registerCommand("Debugger.searchInContent", [{"name": "scriptId", "type": "string", "optional": false}, {"name": "query", "type": "string", "optional": false}, {"name": "caseSensitive", "type": "boolean", "optional": true}, {"name": "isRegex", "type": "boolean", "optional": true}], ["result"]);
- InspectorBackend.registerCommand("Debugger.canSetScriptSource", [], ["result"]);
- InspectorBackend.registerCommand("Debugger.setScriptSource", [{"name": "scriptId", "type": "string", "optional": false}, {"name": "scriptSource", "type": "string", "optional": false}, {"name": "preview", "type": "boolean", "optional": true}], ["callFrames", "result"]);
- InspectorBackend.registerCommand("Debugger.getScriptSource", [{"name": "scriptId", "type": "string", "optional": false}], ["scriptSource"]);
- InspectorBackend.registerCommand("Debugger.getFunctionDetails", [{"name": "functionId", "type": "string", "optional": false}], ["details"]);
- InspectorBackend.registerCommand("Debugger.setPauseOnExceptions", [{"name": "state", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("Debugger.evaluateOnCallFrame", [{"name": "callFrameId", "type": "string", "optional": false}, {"name": "expression", "type": "string", "optional": false}, {"name": "objectGroup", "type": "string", "optional": true}, {"name": "includeCommandLineAPI", "type": "boolean", "optional": true}, {"name": "returnByValue", "type": "boolean", "optional": true}], ["result", "wasThrown"]);
- InspectorBackend.registerCommand("DOMDebugger.setDOMBreakpoint", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "type", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOMDebugger.removeDOMBreakpoint", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "type", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOMDebugger.setEventListenerBreakpoint", [{"name": "eventName", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOMDebugger.removeEventListenerBreakpoint", [{"name": "eventName", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOMDebugger.setInstrumentationBreakpoint", [{"name": "eventName", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOMDebugger.removeInstrumentationBreakpoint", [{"name": "eventName", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOMDebugger.setXHRBreakpoint", [{"name": "url", "type": "string", "optional": false}], []);
- InspectorBackend.registerCommand("DOMDebugger.removeXHRBreakpoint", [{"name": "url", "type": "string", "optional": false}], []);
- InspectorBackend.registerProfilerDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Profiler");
- InspectorBackend.registerEvent("Profiler.addProfileHeader", ["header"]);
- InspectorBackend.registerEvent("Profiler.addHeapSnapshotChunk", ["uid", "chunk"]);
- InspectorBackend.registerEvent("Profiler.finishHeapSnapshot", ["uid"]);
- InspectorBackend.registerEvent("Profiler.setRecordingProfile", ["isProfiling"]);
- InspectorBackend.registerEvent("Profiler.resetProfiles", []);
- InspectorBackend.registerEvent("Profiler.reportHeapSnapshotProgress", ["done", "total"]);
- InspectorBackend.registerCommand("Profiler.causesRecompilation", [], ["result"]);
- InspectorBackend.registerCommand("Profiler.isSampling", [], ["result"]);
- InspectorBackend.registerCommand("Profiler.hasHeapProfiler", [], ["result"]);
- InspectorBackend.registerCommand("Profiler.enable", [], []);
- InspectorBackend.registerCommand("Profiler.disable", [], []);
- InspectorBackend.registerCommand("Profiler.start", [], []);
- InspectorBackend.registerCommand("Profiler.stop", [], []);
- InspectorBackend.registerCommand("Profiler.getProfileHeaders", [], ["headers"]);
- InspectorBackend.registerCommand("Profiler.getProfile", [{"name": "type", "type": "string", "optional": false}, {"name": "uid", "type": "number", "optional": false}], ["profile"]);
- InspectorBackend.registerCommand("Profiler.removeProfile", [{"name": "type", "type": "string", "optional": false}, {"name": "uid", "type": "number", "optional": false}], []);
- InspectorBackend.registerCommand("Profiler.clearProfiles", [], []);
- InspectorBackend.registerCommand("Profiler.takeHeapSnapshot", [], []);
- InspectorBackend.registerCommand("Profiler.collectGarbage", [], []);
- InspectorBackend.registerCommand("Profiler.getObjectByHeapObjectId", [{"name": "objectId", "type": "number", "optional": false}, {"name": "objectGroup", "type": "string", "optional": true}], ["result"]);
- InspectorBackend.registerWorkerDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Worker");
- InspectorBackend.registerEvent("Worker.workerCreated", ["workerId", "url", "inspectorConnected"]);
- InspectorBackend.registerEvent("Worker.workerTerminated", ["workerId"]);
- InspectorBackend.registerEvent("Worker.dispatchMessageFromWorker", ["workerId", "message"]);
- InspectorBackend.registerEvent("Worker.disconnectedFromWorker", []);
- InspectorBackend.registerCommand("Worker.setWorkerInspectionEnabled", [{"name": "value", "type": "boolean", "optional": false}], []);
- InspectorBackend.registerCommand("Worker.sendMessageToWorker", [{"name": "workerId", "type": "number", "optional": false}, {"name": "message", "type": "object", "optional": false}], []);
- InspectorBackend.registerCommand("Worker.connectToWorker", [{"name": "workerId", "type": "number", "optional": false}], []);
- InspectorBackend.registerCommand("Worker.disconnectFromWorker", [{"name": "workerId", "type": "number", "optional": false}], []);
- InspectorBackend.registerCommand("Worker.setAutoconnectToWorkers", [{"name": "value", "type": "boolean", "optional": false}], []);
- if (!window.InspectorExtensionRegistry) {
- WebInspector.InspectorExtensionRegistryStub = function()
- {
- }
- WebInspector.InspectorExtensionRegistryStub.prototype = {
- getExtensionsAsync: function()
- {
- }
- }
- var InspectorExtensionRegistry = new WebInspector.InspectorExtensionRegistryStub();
- }
- InspectorFrontendAPI = {
- _pendingCommands: [],
- isDebuggingEnabled: function()
- {
- return WebInspector.panels.scripts.debuggingEnabled;
- },
- setDebuggingEnabled: function(enabled)
- {
- if (enabled) {
- WebInspector.panels.scripts.enableDebugging();
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.scripts);
- } else
- WebInspector.panels.scripts.disableDebugging();
- },
- isTimelineProfilingEnabled: function()
- {
- return WebInspector.panels.timeline.timelineProfilingEnabled;
- },
- setTimelineProfilingEnabled: function(enabled)
- {
- WebInspector.panels.timeline.setTimelineProfilingEnabled(enabled);
- },
- isProfilingJavaScript: function()
- {
- return WebInspector.CPUProfileType.instance && WebInspector.CPUProfileType.instance.isRecordingProfile();
- },
- startProfilingJavaScript: function()
- {
- WebInspector.panels.profiles.enableProfiler();
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.profiles);
- if (WebInspector.CPUProfileType.instance)
- WebInspector.CPUProfileType.instance.startRecordingProfile();
- },
- stopProfilingJavaScript: function()
- {
- if (WebInspector.CPUProfileType.instance)
- WebInspector.CPUProfileType.instance.stopRecordingProfile();
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.profiles);
- },
- setAttachedWindow: function(attached)
- {
- WebInspector.attached = attached;
- },
- showConsole: function()
- {
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.console);
- },
- showMainResourceForFrame: function(frameId)
- {
- },
- showResources: function()
- {
- WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
- },
- setDockingUnavailable: function(unavailable)
- {
- WebInspector.setDockingUnavailable(unavailable);
- },
- dispatch: function(signature)
- {
- if (WebInspector.panels) {
- var methodName = signature.shift();
- return InspectorFrontendAPI[methodName].apply(InspectorFrontendAPI, signature);
- }
- InspectorFrontendAPI._pendingCommands.push(signature);
- },
- loadCompleted: function()
- {
- for (var i = 0; i < InspectorFrontendAPI._pendingCommands.length; ++i)
- InspectorFrontendAPI.dispatch(InspectorFrontendAPI._pendingCommands[i]);
- InspectorFrontendAPI._pendingCommands = [];
- }
- }
- WebInspector.Object = function() {
- }
- WebInspector.Object.prototype = {
- addEventListener: function(eventType, listener, thisObject)
- {
- console.assert(listener);
- if (!this._listeners)
- this._listeners = {};
- if (!this._listeners[eventType])
- this._listeners[eventType] = [];
- this._listeners[eventType].push({ thisObject: thisObject, listener: listener });
- },
- removeEventListener: function(eventType, listener, thisObject)
- {
- console.assert(listener);
- if (!this._listeners || !this._listeners[eventType])
- return;
- var listeners = this._listeners[eventType];
- for (var i = 0; i < listeners.length; ++i) {
- if (listener && listeners[i].listener === listener && listeners[i].thisObject === thisObject)
- listeners.splice(i, 1);
- else if (!listener && thisObject && listeners[i].thisObject === thisObject)
- listeners.splice(i, 1);
- }
- if (!listeners.length)
- delete this._listeners[eventType];
- },
- removeAllListeners: function()
- {
- delete this._listeners;
- },
- hasEventListeners: function(eventType)
- {
- if (!this._listeners || !this._listeners[eventType])
- return false;
- return true;
- },
- dispatchEventToListeners: function(eventType, eventData)
- {
- if (!this._listeners || !this._listeners[eventType])
- return false;
- var event = new WebInspector.Event(this, eventType, eventData);
- var listeners = this._listeners[eventType].slice(0);
- for (var i = 0; i < listeners.length; ++i) {
- listeners[i].listener.call(listeners[i].thisObject, event);
- if (event._stoppedPropagation)
- break;
- }
- return event.defaultPrevented;
- }
- }
- WebInspector.Event = function(target, type, data)
- {
- this.target = target;
- this.type = type;
- this.data = data;
- this.defaultPrevented = false;
- this._stoppedPropagation = false;
- }
- WebInspector.Event.prototype = {
- stopPropagation: function()
- {
- this._stoppedPropagation = true;
- },
- preventDefault: function()
- {
- this.defaultPrevented = true;
- },
- consume: function(preventDefault)
- {
- this.stopPropagation();
- if (preventDefault)
- this.preventDefault();
- }
- }
- WebInspector.notifications = new WebInspector.Object();
- var Preferences = {
- maxInlineTextChildLength: 80,
- minConsoleHeight: 75,
- minSidebarWidth: 100,
- minElementsSidebarWidth: 200,
- minScriptsSidebarWidth: 200,
- styleRulesExpandedState: {},
- showMissingLocalizedStrings: false,
- useLowerCaseMenuTitlesOnWindows: false,
- sharedWorkersDebugNote: undefined,
- localizeUI: true,
- exposeDisableCache: false,
- exposeWorkersInspection: false,
- applicationTitle: "Web Inspector - %s",
- showHeapSnapshotObjectsHiddenProperties: false,
- showDockToRight: false
- }
- var Capabilities = {
- samplingCPUProfiler: false,
- debuggerCausesRecompilation: true,
- profilerCausesRecompilation: true,
- nativeInstrumentationEnabled: false,
- heapProfilerPresent: false,
- canOverrideDeviceMetrics: false
- }
- WebInspector.Settings = function()
- {
- this._eventSupport = new WebInspector.Object();
- this.colorFormat = this.createSetting("colorFormat", "hex");
- this.consoleHistory = this.createSetting("consoleHistory", []);
- this.debuggerEnabled = this.createSetting("debuggerEnabled", false);
- this.domWordWrap = this.createSetting("domWordWrap", true);
- this.profilerEnabled = this.createSetting("profilerEnabled", false);
- this.eventListenersFilter = this.createSetting("eventListenersFilter", "all");
- this.lastActivePanel = this.createSetting("lastActivePanel", "elements");
- this.lastViewedScriptFile = this.createSetting("lastViewedScriptFile", "application");
- this.monitoringXHREnabled = this.createSetting("monitoringXHREnabled", false);
- this.preserveConsoleLog = this.createSetting("preserveConsoleLog", false);
- this.resourcesLargeRows = this.createSetting("resourcesLargeRows", true);
- this.resourcesSortOptions = this.createSetting("resourcesSortOptions", {timeOption: "responseTime", sizeOption: "transferSize"});
- this.resourceViewTab = this.createSetting("resourceViewTab", "preview");
- this.showInheritedComputedStyleProperties = this.createSetting("showInheritedComputedStyleProperties", false);
- this.showUserAgentStyles = this.createSetting("showUserAgentStyles", true);
- this.watchExpressions = this.createSetting("watchExpressions", []);
- this.breakpoints = this.createSetting("breakpoints", []);
- this.eventListenerBreakpoints = this.createSetting("eventListenerBreakpoints", []);
- this.domBreakpoints = this.createSetting("domBreakpoints", []);
- this.xhrBreakpoints = this.createSetting("xhrBreakpoints", []);
- this.sourceMapsEnabled = this.createSetting("sourceMapsEnabled", false);
- this.cacheDisabled = this.createSetting("cacheDisabled", false);
- this.overrideUserAgent = this.createSetting("overrideUserAgent", "");
- this.userAgent = this.createSetting("userAgent", "");
- this.deviceMetrics = this.createSetting("deviceMetrics", "");
- this.showScriptFolders = this.createSetting("showScriptFolders", true);
- this.dockToRight = this.createSetting("dockToRight", false);
- this.emulateTouchEvents = this.createSetting("emulateTouchEvents", false);
- this.showPaintRects = this.createSetting("showPaintRects", false);
- this.zoomLevel = this.createSetting("zoomLevel", 0);
- if (this.breakpoints.get().length > 500000)
- this.breakpoints.set([]);
- }
- WebInspector.Settings.prototype = {
- createSetting: function(key, defaultValue)
- {
- return new WebInspector.Setting(key, defaultValue, this._eventSupport);
- }
- }
- WebInspector.Setting = function(name, defaultValue, eventSupport)
- {
- this._name = name;
- this._defaultValue = defaultValue;
- this._eventSupport = eventSupport;
- }
- WebInspector.Setting.prototype = {
- addChangeListener: function(listener, thisObject)
- {
- this._eventSupport.addEventListener(this._name, listener, thisObject);
- },
- removeChangeListener: function(listener, thisObject)
- {
- this._eventSupport.removeEventListener(this._name, listener, thisObject);
- },
- get name()
- {
- return this._name;
- },
- get: function()
- {
- if (typeof this._value !== "undefined")
- return this._value;
- this._value = this._defaultValue;
- if (window.localStorage != null && this._name in window.localStorage) {
- try {
- this._value = JSON.parse(window.localStorage[this._name]);
- } catch(e) {
- window.localStorage.removeItem(this._name);
- }
- }
- return this._value;
- },
- set: function(value)
- {
- this._value = value;
- if (window.localStorage != null) {
- try {
- window.localStorage[this._name] = JSON.stringify(value);
- } catch(e) {
- console.error("Error saving setting with name:" + this._name);
- }
- }
- this._eventSupport.dispatchEventToListeners(this._name, value);
- }
- }
- WebInspector.ExperimentsSettings = function()
- {
- this._setting = WebInspector.settings.createSetting("experiments", {});
- this._experiments = [];
- this._enabledForTest = {};
- this.timelineVerticalOverview = this._createExperiment("timelineStartAtZero", "Enable vertical overview mode in the Timeline panel");
- this.showShadowDOM = this._createExperiment("showShadowDOM", "Show shadow DOM");
- this.snippetsSupport = this._createExperiment("snippetsSupport", "Snippets support");
- this._cleanUpSetting();
- }
- WebInspector.ExperimentsSettings.prototype = {
- get experiments()
- {
- return this._experiments.slice();
- },
- get experimentsEnabled()
- {
- return "experiments" in WebInspector.queryParamsObject;
- },
- _createExperiment: function(experimentName, experimentTitle)
- {
- var experiment = new WebInspector.Experiment(this, experimentName, experimentTitle);
- this._experiments.push(experiment);
- return experiment;
- },
- isEnabled: function(experimentName)
- {
- if (this._enabledForTest[experimentName])
- return true;
- if (!this.experimentsEnabled)
- return false;
- var experimentsSetting = this._setting.get();
- return experimentsSetting[experimentName];
- },
- setEnabled: function(experimentName, enabled)
- {
- var experimentsSetting = this._setting.get();
- experimentsSetting[experimentName] = enabled;
- this._setting.set(experimentsSetting);
- },
- _enableForTest: function(experimentName)
- {
- this._enabledForTest[experimentName] = true;
- },
- _cleanUpSetting: function()
- {
- var experimentsSetting = this._setting.get();
- var cleanedUpExperimentSetting = {};
- for (var i = 0; i < this._experiments.length; ++i) {
- var experimentName = this._experiments[i].name;
- if (experimentsSetting[experimentName])
- cleanedUpExperimentSetting[experimentName] = true;
- }
- this._setting.set(cleanedUpExperimentSetting);
- }
- }
- WebInspector.Experiment = function(experimentsSettings, name, title)
- {
- this._name = name;
- this._title = title;
- this._experimentsSettings = experimentsSettings;
- }
- WebInspector.Experiment.prototype = {
- get name()
- {
- return this._name;
- },
- get title()
- {
- return this._title;
- },
- isEnabled: function()
- {
- return this._experimentsSettings.isEnabled(this._name);
- },
- setEnabled: function(enabled)
- {
- return this._experimentsSettings.setEnabled(this._name, enabled);
- },
- enableForTest: function()
- {
- this._experimentsSettings._enableForTest(this._name);
- }
- }
- WebInspector.settings = new WebInspector.Settings();
- WebInspector.experimentsSettings = new WebInspector.ExperimentsSettings();
- if (!window.InspectorFrontendHost) {
- WebInspector.InspectorFrontendHostStub = function()
- {
- this._attachedWindowHeight = 0;
- this.isStub = true;
- }
- WebInspector.InspectorFrontendHostStub.prototype = {
- platform: function()
- {
- var match = navigator.userAgent.match(/Windows NT/);
- if (match)
- return "windows";
- match = navigator.userAgent.match(/Mac OS X/);
- if (match)
- return "mac";
- return "linux";
- },
- port: function()
- {
- return "unknown";
- },
- bringToFront: function()
- {
- this._windowVisible = true;
- },
- closeWindow: function()
- {
- this._windowVisible = false;
- },
- requestAttachWindow: function()
- {
- },
- requestDetachWindow: function()
- {
- },
- requestSetDockSide: function()
- {
- },
- setAttachedWindowHeight: function(height)
- {
- },
- moveWindowBy: function(x, y)
- {
- },
- setInjectedScriptForOrigin: function(origin, script)
- {
- },
- loaded: function()
- {
- },
- localizedStringsURL: function()
- {
- return undefined;
- },
- hiddenPanels: function()
- {
- return "";
- },
- inspectedURLChanged: function(url)
- {
- document.title = WebInspector.UIString(Preferences.applicationTitle, url);
- },
- copyText: function()
- {
- },
- openInNewTab: function(url)
- {
- window.open(url, "_blank");
- },
- canSaveAs: function(fileName, content)
- {
- return true;
- },
- saveAs: function(fileName, content)
- {
- var builder = new WebKitBlobBuilder();
- builder.append(content);
- var blob = builder.getBlob("application/octet-stream");
- var fr = new FileReader();
- fr.onload = function(e) {
- window.location = this.result;
- }
- fr.readAsDataURL(blob);
- },
- sendMessageToBackend: function(message)
- {
- },
- recordActionTaken: function(actionCode)
- {
- },
- recordPanelShown: function(panelCode)
- {
- },
- recordSettingChanged: function(settingCode)
- {
- },
- loadResourceSynchronously: function(url)
- {
- return "";
- },
- setZoomFactor: function(zoom)
- {
- }
- }
- var InspectorFrontendHost = new WebInspector.InspectorFrontendHostStub();
- Preferences.localizeUI = false;
- }
- WebInspector.Checkbox = function(label, className, tooltip)
- {
- this.element = document.createElement('label');
- this._inputElement = document.createElement('input');
- this._inputElement.type = "checkbox";
- this.element.className = className;
- this.element.appendChild(this._inputElement);
- this.element.appendChild(document.createTextNode(label));
- if (tooltip)
- this.element.title = tooltip;
- }
- WebInspector.Checkbox.prototype = {
- set checked(checked)
- {
- this._inputElement.checked = checked;
- },
- get checked()
- {
- return this._inputElement.checked;
- },
- addEventListener: function(listener)
- {
- function listenerWrapper(event)
- {
- if (listener)
- listener(event);
- event.consume();
- return true;
- }
- this._inputElement.addEventListener("click", listenerWrapper, false);
- this.element.addEventListener("click", listenerWrapper, false);
- }
- }
- WebInspector.ContextMenu = function() {
- this._items = [];
- this._handlers = {};
- }
- WebInspector.ContextMenu.prototype = {
- show: function(event)
- {
- while (this._items.length > 0 && !("id" in this._items[this._items.length - 1]))
- this._items.splice(this._items.length - 1, 1);
- if (this._items.length) {
- WebInspector._contextMenu = this;
- InspectorFrontendHost.showContextMenu(event, this._items);
- }
- event.consume();
- },
- appendItem: function(label, handler, disabled)
- {
- var id = this._items.length;
- this._items.push({type: "item", id: id, label: label, enabled: !disabled});
- this._handlers[id] = handler;
- },
- appendCheckboxItem: function(label, handler, checked, disabled)
- {
- var id = this._items.length;
- this._items.push({type: "checkbox", id: id, label: label, checked: !!checked, enabled: !disabled});
- this._handlers[id] = handler;
- },
- appendSeparator: function()
- {
- if (this._items.length === 0)
- return;
- if (!("id" in this._items[this._items.length - 1]))
- return;
- this._items.push({type: "separator"});
- },
- _itemSelected: function(id)
- {
- if (this._handlers[id])
- this._handlers[id].call(this);
- }
- }
- WebInspector.contextMenuItemSelected = function(id)
- {
- if (WebInspector._contextMenu)
- WebInspector._contextMenu._itemSelected(id);
- }
- WebInspector.contextMenuCleared = function()
- {
- }
- if (!InspectorFrontendHost.showContextMenu) {
- WebInspector.SoftContextMenu = function(items)
- {
- this._items = items;
- }
- WebInspector.SoftContextMenu.prototype = {
- show: function(event)
- {
- this._x = event.x;
- this._y = event.y;
- this._time = new Date().getTime();
- var absoluteX = event.pageX;
- var absoluteY = event.pageY;
- var targetElement = event.target;
- while (targetElement && window !== targetElement.ownerDocument.defaultView) {
- var frameElement = targetElement.ownerDocument.defaultView.frameElement;
- absoluteY += frameElement.totalOffsetTop();
- absoluteX += frameElement.totalOffsetLeft();
- targetElement = frameElement;
- }
- this._glassPaneElement = document.createElement("div");
- this._glassPaneElement.className = "soft-context-menu-glass-pane";
- this._glassPaneElement.tabIndex = 0;
- this._glassPaneElement.addEventListener("mouseup", this._glassPaneMouseUp.bind(this), false);
- this._contextMenuElement = document.createElement("div");
- this._contextMenuElement.className = "soft-context-menu";
- this._contextMenuElement.tabIndex = 0;
- this._contextMenuElement.style.top = absoluteY + "px";
- this._contextMenuElement.style.left = absoluteX + "px";
- this._contextMenuElement.addEventListener("mousedown", this._discardMenu.bind(this), false);
- this._contextMenuElement.addEventListener("keydown", this._menuKeyDown.bind(this), false);
- this._contextMenuElement.addEventListener("blur", this._discardMenu.bind(this), false);
- for (var i = 0; i < this._items.length; ++i)
- this._contextMenuElement.appendChild(this._createMenuItem(this._items[i]));
- this._glassPaneElement.appendChild(this._contextMenuElement);
- document.body.appendChild(this._glassPaneElement);
- this._contextMenuElement.focus();
- if (document.body.offsetWidth < this._contextMenuElement.offsetLeft + this._contextMenuElement.offsetWidth)
- this._contextMenuElement.style.left = (absoluteX - this._contextMenuElement.offsetWidth) + "px";
- if (document.body.offsetHeight < this._contextMenuElement.offsetTop + this._contextMenuElement.offsetHeight)
- this._contextMenuElement.style.top = (document.body.offsetHeight - this._contextMenuElement.offsetHeight) + "px";
- event.consume(true);
- },
- _createMenuItem: function(item)
- {
- if (item.type === "separator")
- return this._createSeparator();
- var menuItemElement = document.createElement("div");
- menuItemElement.className = "soft-context-menu-item";
- var checkMarkElement = document.createElement("span");
- checkMarkElement.textContent = "\u2713 ";
- checkMarkElement.className = "soft-context-menu-item-checkmark";
- if (!item.checked)
- checkMarkElement.style.opacity = "0";
- menuItemElement.appendChild(checkMarkElement);
- menuItemElement.appendChild(document.createTextNode(item.label));
- menuItemElement.addEventListener("mousedown", this._menuItemMouseDown.bind(this), false);
- menuItemElement.addEventListener("mouseup", this._menuItemMouseUp.bind(this), false);
- menuItemElement.addEventListener("mouseover", this._menuItemMouseOver.bind(this), false);
- menuItemElement.addEventListener("mouseout", this._menuItemMouseOut.bind(this), false);
- menuItemElement._actionId = item.id;
- return menuItemElement;
- },
- _createSeparator: function()
- {
- var separatorElement = document.createElement("div");
- separatorElement.className = "soft-context-menu-separator";
- separatorElement._isSeparator = true;
- return separatorElement;
- },
- _menuItemMouseDown: function(event)
- {
- event.consume(true);
- },
- _menuItemMouseUp: function(event)
- {
- this._triggerAction(event.target, event);
- },
- _triggerAction: function(menuItemElement, event)
- {
- this._discardMenu(event);
- if (typeof menuItemElement._actionId !== "undefined") {
- WebInspector.contextMenuItemSelected(menuItemElement._actionId);
- delete menuItemElement._actionId;
- }
- },
- _menuItemMouseOver: function(event)
- {
- this._highlightMenuItem(event.target);
- },
- _menuItemMouseOut: function(event)
- {
- this._highlightMenuItem(null);
- },
- _highlightMenuItem: function(menuItemElement)
- {
- if (this._highlightedMenuItemElement)
- this._highlightedMenuItemElement.removeStyleClass("soft-context-menu-item-mouse-over");
- this._highlightedMenuItemElement = menuItemElement;
- if (this._highlightedMenuItemElement)
- this._highlightedMenuItemElement.addStyleClass("soft-context-menu-item-mouse-over");
- },
- _highlightPrevious: function()
- {
- var menuItemElement = this._highlightedMenuItemElement ? this._highlightedMenuItemElement.previousSibling : this._contextMenuElement.lastChild;
- while (menuItemElement && menuItemElement._isSeparator)
- menuItemElement = menuItemElement.previousSibling;
- if (menuItemElement)
- this._highlightMenuItem(menuItemElement);
- },
- _highlightNext: function()
- {
- var menuItemElement = this._highlightedMenuItemElement ? this._highlightedMenuItemElement.nextSibling : this._contextMenuElement.firstChild;
- while (menuItemElement && menuItemElement._isSeparator)
- menuItemElement = menuItemElement.nextSibling;
- if (menuItemElement)
- this._highlightMenuItem(menuItemElement);
- },
- _menuKeyDown: function(event)
- {
- switch (event.keyIdentifier) {
- case "Up":
- this._highlightPrevious(); break;
- case "Down":
- this._highlightNext(); break;
- case "U+001B":
- this._discardMenu(event); break;
- case "Enter":
- if (!isEnterKey(event))
- break;
- case "U+0020":
- if (this._highlightedMenuItemElement)
- this._triggerAction(this._highlightedMenuItemElement, event);
- break;
- }
- event.consume(true);
- },
- _glassPaneMouseUp: function(event)
- {
- if (event.x === this._x && event.y === this._y && new Date().getTime() - this._time < 300)
- return;
- this._discardMenu(event);
- },
- _discardMenu: function(event)
- {
- if (this._glassPaneElement) {
- var glassPane = this._glassPaneElement;
- delete this._glassPaneElement;
- document.body.removeChild(glassPane);
- event.consume(true);
- }
- }
- }
- InspectorFrontendHost.showContextMenu = function(event, items)
- {
- new WebInspector.SoftContextMenu(items).show(event);
- }
- }
- WebInspector.KeyboardShortcut = function()
- {
- }
- WebInspector.KeyboardShortcut.Modifiers = {
- None: 0,
- Shift: 1,
- Ctrl: 2,
- Alt: 4,
- Meta: 8,
- get CtrlOrMeta()
- {
- return WebInspector.isMac() ? this.Meta : this.Ctrl;
- }
- };
- WebInspector.KeyboardShortcut.Keys = {
- Backspace: { code: 8, name: "\u21a4" },
- Tab: { code: 9, name: { mac: "\u21e5", other: "<Tab>" } },
- Enter: { code: 13, name: { mac: "\u21a9", other: "<Enter>" } },
- Esc: { code: 27, name: { mac: "\u238b", other: "<Esc>" } },
- Space: { code: 32, name: "<Space>" },
- PageUp: { code: 33, name: { mac: "\u21de", other: "<PageUp>" } },
- PageDown: { code: 34, name: { mac: "\u21df", other: "<PageDown>" } },
- End: { code: 35, name: { mac: "\u2197", other: "<End>" } },
- Home: { code: 36, name: { mac: "\u2196", other: "<Home>" } },
- Left: { code: 37, name: "\u2190" },
- Up: { code: 38, name: "\u2191" },
- Right: { code: 39, name: "\u2192" },
- Down: { code: 40, name: "\u2193" },
- Delete: { code: 46, name: "<Del>" },
- Zero: { code: 48, name: "0" },
- F1: { code: 112, name: "F1" },
- F2: { code: 113, name: "F2" },
- F3: { code: 114, name: "F3" },
- F4: { code: 115, name: "F4" },
- F5: { code: 116, name: "F5" },
- F6: { code: 117, name: "F6" },
- F7: { code: 118, name: "F7" },
- F8: { code: 119, name: "F8" },
- F9: { code: 120, name: "F9" },
- F10: { code: 121, name: "F10" },
- F11: { code: 122, name: "F11" },
- F12: { code: 123, name: "F12" },
- Semicolon: { code: 186, name: ";" },
- Plus: { code: 187, name: "+" },
- Comma: { code: 188, name: "," },
- Minus: { code: 189, name: "-" },
- Period: { code: 190, name: "." },
- Slash: { code: 191, name: "/" },
- Apostrophe: { code: 192, name: "`" },
- SingleQuote: { code: 222, name: "\'" }
- };
- WebInspector.KeyboardShortcut.makeKey = function(keyCode, modifiers)
- {
- if (typeof keyCode === "string")
- keyCode = keyCode.charCodeAt(0) - 32;
- modifiers = modifiers || WebInspector.KeyboardShortcut.Modifiers.None;
- return WebInspector.KeyboardShortcut._makeKeyFromCodeAndModifiers(keyCode, modifiers);
- }
- WebInspector.KeyboardShortcut.makeKeyFromEvent = function(keyboardEvent)
- {
- var modifiers = WebInspector.KeyboardShortcut.Modifiers.None;
- if (keyboardEvent.shiftKey)
- modifiers |= WebInspector.KeyboardShortcut.Modifiers.Shift;
- if (keyboardEvent.ctrlKey)
- modifiers |= WebInspector.KeyboardShortcut.Modifiers.Ctrl;
- if (keyboardEvent.altKey)
- modifiers |= WebInspector.KeyboardShortcut.Modifiers.Alt;
- if (keyboardEvent.metaKey)
- modifiers |= WebInspector.KeyboardShortcut.Modifiers.Meta;
- return WebInspector.KeyboardShortcut._makeKeyFromCodeAndModifiers(keyboardEvent.keyCode, modifiers);
- }
- WebInspector.KeyboardShortcut.eventHasCtrlOrMeta = function(event)
- {
- return WebInspector.isMac() ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
- }
- WebInspector.KeyboardShortcut.makeDescriptor = function(key, modifiers)
- {
- return {
- key: WebInspector.KeyboardShortcut.makeKey(typeof key === "string" ? key : key.code, modifiers),
- name: WebInspector.KeyboardShortcut.shortcutToString(key, modifiers)
- };
- }
- WebInspector.KeyboardShortcut.shortcutToString = function(key, modifiers)
- {
- return WebInspector.KeyboardShortcut._modifiersToString(modifiers) + WebInspector.KeyboardShortcut._keyName(key);
- }
- WebInspector.KeyboardShortcut._keyName = function(key)
- {
- if (typeof key === "string")
- return key.toUpperCase();
- if (typeof key.name === "string")
- return key.name;
- return key.name[WebInspector.platform()] || key.name.other;
- }
- WebInspector.KeyboardShortcut._makeKeyFromCodeAndModifiers = function(keyCode, modifiers)
- {
- return (keyCode & 255) | (modifiers << 8);
- };
- WebInspector.KeyboardShortcut._modifiersToString = function(modifiers)
- {
- const cmdKey = "\u2318";
- const optKey = "\u2325";
- const shiftKey = "\u21e7";
- const ctrlKey = "\u2303";
- var isMac = WebInspector.isMac();
- var res = "";
- if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Ctrl)
- res += isMac ? ctrlKey : "<Ctrl> + ";
- if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Alt)
- res += isMac ? optKey : "<Alt> + ";
- if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Shift)
- res += isMac ? shiftKey : "<Shift> + ";
- if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Meta)
- res += isMac ? cmdKey : "<Win> + ";
- return res;
- };
- WebInspector.TextPrompt = function(completions, stopCharacters)
- {
- this._proxyElement;
- this._proxyElementDisplay = "inline-block";
- this._loadCompletions = completions;
- this._completionStopCharacters = stopCharacters;
- this._suggestForceable = true;
- }
- WebInspector.TextPrompt.Events = {
- ItemApplied: "text-prompt-item-applied",
- ItemAccepted: "text-prompt-item-accepted"
- };
- WebInspector.TextPrompt.prototype = {
- get proxyElement()
- {
- return this._proxyElement;
- },
- setSuggestForceable: function(x)
- {
- this._suggestForceable = x;
- },
- setSuggestBoxEnabled: function(className)
- {
- this._suggestBoxClassName = className;
- },
- renderAsBlock: function()
- {
- this._proxyElementDisplay = "block";
- },
- attach: function(element)
- {
- return this._attachInternal(element);
- },
- attachAndStartEditing: function(element, blurListener)
- {
- this._attachInternal(element);
- this._startEditing(blurListener);
- return this.proxyElement;
- },
- _attachInternal: function(element)
- {
- if (this.proxyElement)
- throw "Cannot attach an attached TextPrompt";
- this._element = element;
- this._boundOnKeyDown = this.onKeyDown.bind(this);
- this._boundSelectStart = this._selectStart.bind(this);
- this._proxyElement = element.ownerDocument.createElement("span");
- this._proxyElement.style.display = this._proxyElementDisplay;
- element.parentElement.insertBefore(this.proxyElement, element);
- this.proxyElement.appendChild(element);
- this._element.addStyleClass("text-prompt");
- this._element.addEventListener("keydown", this._boundOnKeyDown, false);
- this._element.addEventListener("selectstart", this._selectStart.bind(this), false);
- if (typeof this._suggestBoxClassName === "string")
- this._suggestBox = new WebInspector.TextPrompt.SuggestBox(this, this._element, this._suggestBoxClassName);
- return this.proxyElement;
- },
- detach: function()
- {
- this._removeFromElement();
- this.proxyElement.parentElement.insertBefore(this._element, this.proxyElement);
- this.proxyElement.parentElement.removeChild(this.proxyElement);
- delete this._proxyElement;
- WebInspector.restoreFocusFromElement(this._element);
- },
- get text()
- {
- return this._element.textContent;
- },
- set text(x)
- {
- this._removeSuggestionAids();
- if (!x) {
- this._element.removeChildren();
- this._element.appendChild(document.createElement("br"));
- } else
- this._element.textContent = x;
- this.moveCaretToEndOfPrompt();
- this._element.scrollIntoView();
- },
- _removeFromElement: function()
- {
- this.clearAutoComplete(true);
- this._element.removeEventListener("keydown", this._boundOnKeyDown, false);
- this._element.removeEventListener("selectstart", this._boundSelectStart, false);
- if (this._isEditing)
- this._stopEditing();
- if (this._suggestBox)
- this._suggestBox.removeFromElement();
- },
- _startEditing: function(blurListener)
- {
- this._isEditing = true;
- this._element.addStyleClass("editing");
- if (blurListener) {
- this._blurListener = blurListener;
- this._element.addEventListener("blur", this._blurListener, false);
- }
- this._oldTabIndex = this._element.tabIndex;
- if (this._element.tabIndex < 0)
- this._element.tabIndex = 0;
- WebInspector.setCurrentFocusElement(this._element);
- },
- _stopEditing: function()
- {
- this._element.tabIndex = this._oldTabIndex;
- if (this._blurListener)
- this._element.removeEventListener("blur", this._blurListener, false);
- this._element.removeStyleClass("editing");
- delete this._isEditing;
- },
- _removeSuggestionAids: function()
- {
- this.clearAutoComplete();
- this.hideSuggestBox();
- },
- _selectStart: function(event)
- {
- if (this._selectionTimeout)
- clearTimeout(this._selectionTimeout);
- this._removeSuggestionAids();
- function moveBackIfOutside()
- {
- delete this._selectionTimeout;
- if (!this.isCaretInsidePrompt() && window.getSelection().isCollapsed) {
- this.moveCaretToEndOfPrompt();
- this.autoCompleteSoon();
- }
- }
- this._selectionTimeout = setTimeout(moveBackIfOutside.bind(this), 100);
- },
- defaultKeyHandler: function(event, force)
- {
- this.clearAutoComplete();
- this.autoCompleteSoon(force);
- return false;
- },
- onKeyDown: function(event)
- {
- var handled = false;
- var invokeDefault = true;
- switch (event.keyIdentifier) {
- case "Up":
- handled = this.upKeyPressed(event);
- break;
- case "Down":
- handled = this.downKeyPressed(event);
- break;
- case "PageUp":
- handled = this.pageUpKeyPressed(event);
- break;
- case "PageDown":
- handled = this.pageDownKeyPressed(event);
- break;
- case "U+0009":
- handled = this.tabKeyPressed(event);
- break;
- case "Enter":
- handled = this.enterKeyPressed(event);
- break;
- case "Left":
- case "Home":
- this._removeSuggestionAids();
- invokeDefault = false;
- break;
- case "Right":
- case "End":
- if (this.isCaretAtEndOfPrompt())
- handled = this.acceptAutoComplete();
- else
- this._removeSuggestionAids();
- invokeDefault = false;
- break;
- case "U+001B":
- if (this.isSuggestBoxVisible()) {
- this._suggestBox.hide();
- handled = true;
- }
- break;
- case "U+0020":
- if (this._suggestForceable && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
- this.defaultKeyHandler(event, true);
- handled = true;
- }
- break;
- case "Alt":
- case "Meta":
- case "Shift":
- case "Control":
- invokeDefault = false;
- break;
- }
- if (!handled && invokeDefault)
- handled = this.defaultKeyHandler(event);
- if (handled)
- event.consume(true);
- return handled;
- },
- acceptAutoComplete: function()
- {
- var result = false;
- if (this.isSuggestBoxVisible())
- result = this._suggestBox.acceptSuggestion();
- if (!result)
- result = this.acceptSuggestion();
- return result;
- },
- clearAutoComplete: function(includeTimeout)
- {
- if (includeTimeout && this._completeTimeout) {
- clearTimeout(this._completeTimeout);
- delete this._completeTimeout;
- }
- if (!this.autoCompleteElement)
- return;
- if (this.autoCompleteElement.parentNode)
- this.autoCompleteElement.parentNode.removeChild(this.autoCompleteElement);
- delete this.autoCompleteElement;
- if (!this._userEnteredRange || !this._userEnteredText)
- return;
- this._userEnteredRange.deleteContents();
- this._element.pruneEmptyTextNodes();
- var userTextNode = document.createTextNode(this._userEnteredText);
- this._userEnteredRange.insertNode(userTextNode);
- var selectionRange = document.createRange();
- selectionRange.setStart(userTextNode, this._userEnteredText.length);
- selectionRange.setEnd(userTextNode, this._userEnteredText.length);
- var selection = window.getSelection();
- selection.removeAllRanges();
- selection.addRange(selectionRange);
- delete this._userEnteredRange;
- delete this._userEnteredText;
- },
- autoCompleteSoon: function(force)
- {
- var immediately = this.isSuggestBoxVisible() || force;
- if (!this._completeTimeout)
- this._completeTimeout = setTimeout(this.complete.bind(this, true, force), immediately ? 0 : 250);
- },
- complete: function(auto, force, reverse)
- {
- this.clearAutoComplete(true);
- var selection = window.getSelection();
- if (!selection.rangeCount)
- return;
- var selectionRange = selection.getRangeAt(0);
- var isEmptyInput = selectionRange.commonAncestorContainer === this._element;
- var shouldExit;
- if (auto && isEmptyInput && !force)
- shouldExit = true;
- else if (!auto && !isEmptyInput && !selectionRange.commonAncestorContainer.isDescendant(this._element))
- shouldExit = true;
- else if (auto && !force && !this.isCaretAtEndOfPrompt() && !this.isSuggestBoxVisible())
- shouldExit = true;
- else if (!selection.isCollapsed)
- shouldExit = true;
- else if (!force) {
- var wordSuffixRange = selectionRange.startContainer.rangeOfWord(selectionRange.endOffset, this._completionStopCharacters, this._element, "forward");
- if (wordSuffixRange.toString().length)
- shouldExit = true;
- }
- if (shouldExit) {
- this.hideSuggestBox();
- return;
- }
- var wordPrefixRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, this._completionStopCharacters, this._element, "backward");
- this._loadCompletions(this, wordPrefixRange, force, this._completionsReady.bind(this, selection, auto, wordPrefixRange, !!reverse));
- },
- _boxForAnchorAtStart: function(selection, textRange)
- {
- var rangeCopy = selection.getRangeAt(0).cloneRange();
- var anchorElement = document.createElement("span");
- anchorElement.textContent = "\u200B";
- textRange.insertNode(anchorElement);
- var box = anchorElement.boxInWindow(window);
- anchorElement.parentElement.removeChild(anchorElement);
- selection.removeAllRanges();
- selection.addRange(rangeCopy);
- return box;
- },
- _buildCommonPrefix: function(completions, wordPrefixLength)
- {
- var commonPrefix = completions[0];
- for (var i = 0; i < completions.length; ++i) {
- var completion = completions[i];
- var lastIndex = Math.min(commonPrefix.length, completion.length);
- for (var j = wordPrefixLength; j < lastIndex; ++j) {
- if (commonPrefix[j] !== completion[j]) {
- commonPrefix = commonPrefix.substr(0, j);
- break;
- }
- }
- }
- return commonPrefix;
- },
- _completionsReady: function(selection, auto, originalWordPrefixRange, reverse, completions)
- {
- if (!completions || !completions.length) {
- this.hideSuggestBox();
- return;
- }
- var selectionRange = selection.getRangeAt(0);
- var fullWordRange = document.createRange();
- fullWordRange.setStart(originalWordPrefixRange.startContainer, originalWordPrefixRange.startOffset);
- fullWordRange.setEnd(selectionRange.endContainer, selectionRange.endOffset);
- if (originalWordPrefixRange.toString() + selectionRange.toString() != fullWordRange.toString())
- return;
- this._userEnteredRange = fullWordRange;
- this._userEnteredText = fullWordRange.toString();
- if (this._suggestBox)
- this._suggestBox.updateSuggestions(this._boxForAnchorAtStart(selection, fullWordRange), completions, !this.isCaretAtEndOfPrompt());
- var wordPrefixLength = originalWordPrefixRange.toString().length;
- if (auto) {
- var completionText = completions[0];
- var commonPrefix = this._buildCommonPrefix(completions, wordPrefixLength);
- this._commonPrefix = commonPrefix;
- } else {
- if (completions.length === 1) {
- var completionText = completions[0];
- wordPrefixLength = completionText.length;
- } else {
- var commonPrefix = this._buildCommonPrefix(completions, wordPrefixLength);
- wordPrefixLength = commonPrefix.length;
- if (selection.isCollapsed)
- var completionText = completions[0];
- else {
- var currentText = fullWordRange.toString();
- var foundIndex = null;
- for (var i = 0; i < completions.length; ++i) {
- if (completions[i] === currentText)
- foundIndex = i;
- }
- var nextIndex = foundIndex + (reverse ? -1 : 1);
- if (foundIndex === null || nextIndex >= completions.length)
- var completionText = completions[0];
- else if (nextIndex < 0)
- var completionText = completions[completions.length - 1];
- else
- var completionText = completions[nextIndex];
- }
- }
- }
- if (auto) {
- if (this.isCaretAtEndOfPrompt()) {
- this._userEnteredRange.deleteContents();
- this._element.pruneEmptyTextNodes();
- var finalSelectionRange = document.createRange();
- var prefixText = completionText.substring(0, wordPrefixLength);
- var suffixText = completionText.substring(wordPrefixLength);
- var prefixTextNode = document.createTextNode(prefixText);
- fullWordRange.insertNode(prefixTextNode);
- this.autoCompleteElement = document.createElement("span");
- this.autoCompleteElement.className = "auto-complete-text";
- this.autoCompleteElement.textContent = suffixText;
- prefixTextNode.parentNode.insertBefore(this.autoCompleteElement, prefixTextNode.nextSibling);
- finalSelectionRange.setStart(prefixTextNode, wordPrefixLength);
- finalSelectionRange.setEnd(prefixTextNode, wordPrefixLength);
- selection.removeAllRanges();
- selection.addRange(finalSelectionRange);
- }
- } else
- this.applySuggestion(completionText, completions.length > 1, originalWordPrefixRange);
- },
- _completeCommonPrefix: function()
- {
- if (!this.autoCompleteElement || !this._commonPrefix || !this._userEnteredText || this._commonPrefix.indexOf(this._userEnteredText) !== 0)
- return;
- if (!this.isSuggestBoxVisible()) {
- this.acceptAutoComplete();
- return;
- }
- this.autoCompleteElement.textContent = this._commonPrefix.substring(this._userEnteredText.length);
- this.acceptSuggestion(true)
- },
- applySuggestion: function(completionText, isIntermediateSuggestion, originalPrefixRange)
- {
- var wordPrefixLength;
- if (originalPrefixRange)
- wordPrefixLength = originalPrefixRange.toString().length;
- else
- wordPrefixLength = this._userEnteredText ? this._userEnteredText.length : 0;
- this._userEnteredRange.deleteContents();
- this._element.pruneEmptyTextNodes();
- var finalSelectionRange = document.createRange();
- var completionTextNode = document.createTextNode(completionText);
- this._userEnteredRange.insertNode(completionTextNode);
- if (this.autoCompleteElement && this.autoCompleteElement.parentNode) {
- this.autoCompleteElement.parentNode.removeChild(this.autoCompleteElement);
- delete this.autoCompleteElement;
- }
- if (isIntermediateSuggestion)
- finalSelectionRange.setStart(completionTextNode, wordPrefixLength);
- else
- finalSelectionRange.setStart(completionTextNode, completionText.length);
- finalSelectionRange.setEnd(completionTextNode, completionText.length);
- var selection = window.getSelection();
- selection.removeAllRanges();
- selection.addRange(finalSelectionRange);
- if (isIntermediateSuggestion)
- this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemApplied, { itemText: completionText });
- },
- acceptSuggestion: function(prefixAccepted)
- {
- if (this._isAcceptingSuggestion)
- return false;
- if (!this.autoCompleteElement || !this.autoCompleteElement.parentNode)
- return false;
- var text = this.autoCompleteElement.textContent;
- var textNode = document.createTextNode(text);
- this.autoCompleteElement.parentNode.replaceChild(textNode, this.autoCompleteElement);
- delete this.autoCompleteElement;
- var finalSelectionRange = document.createRange();
- finalSelectionRange.setStart(textNode, text.length);
- finalSelectionRange.setEnd(textNode, text.length);
- var selection = window.getSelection();
- selection.removeAllRanges();
- selection.addRange(finalSelectionRange);
- if (!prefixAccepted) {
- this.hideSuggestBox();
- this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemAccepted);
- } else
- this.autoCompleteSoon(true);
- return true;
- },
- hideSuggestBox: function()
- {
- if (this.isSuggestBoxVisible())
- this._suggestBox.hide();
- },
- isSuggestBoxVisible: function()
- {
- return this._suggestBox && this._suggestBox.visible;
- },
- isCaretInsidePrompt: function()
- {
- return this._element.isInsertionCaretInside();
- },
- isCaretAtEndOfPrompt: function()
- {
- var selection = window.getSelection();
- if (!selection.rangeCount || !selection.isCollapsed)
- return false;
- var selectionRange = selection.getRangeAt(0);
- var node = selectionRange.startContainer;
- if (!node.isSelfOrDescendant(this._element))
- return false;
- if (node.nodeType === Node.TEXT_NODE && selectionRange.startOffset < node.nodeValue.length)
- return false;
- var foundNextText = false;
- while (node) {
- if (node.nodeType === Node.TEXT_NODE && node.nodeValue.length) {
- if (foundNextText && (!this.autoCompleteElement || !this.autoCompleteElement.isAncestor(node)))
- return false;
- foundNextText = true;
- }
- node = node.traverseNextNode(this._element);
- }
- return true;
- },
- isCaretOnFirstLine: function()
- {
- var selection = window.getSelection();
- var focusNode = selection.focusNode;
- if (!focusNode || focusNode.nodeType !== Node.TEXT_NODE || focusNode.parentNode !== this._element)
- return true;
- if (focusNode.textContent.substring(0, selection.focusOffset).indexOf("\n") !== -1)
- return false;
- focusNode = focusNode.previousSibling;
- while (focusNode) {
- if (focusNode.nodeType !== Node.TEXT_NODE)
- return true;
- if (focusNode.textContent.indexOf("\n") !== -1)
- return false;
- focusNode = focusNode.previousSibling;
- }
- return true;
- },
- isCaretOnLastLine: function()
- {
- var selection = window.getSelection();
- var focusNode = selection.focusNode;
- if (!focusNode || focusNode.nodeType !== Node.TEXT_NODE || focusNode.parentNode !== this._element)
- return true;
- if (focusNode.textContent.substring(selection.focusOffset).indexOf("\n") !== -1)
- return false;
- focusNode = focusNode.nextSibling;
- while (focusNode) {
- if (focusNode.nodeType !== Node.TEXT_NODE)
- return true;
- if (focusNode.textContent.indexOf("\n") !== -1)
- return false;
- focusNode = focusNode.nextSibling;
- }
- return true;
- },
- moveCaretToEndOfPrompt: function()
- {
- var selection = window.getSelection();
- var selectionRange = document.createRange();
- var offset = this._element.childNodes.length;
- selectionRange.setStart(this._element, offset);
- selectionRange.setEnd(this._element, offset);
- selection.removeAllRanges();
- selection.addRange(selectionRange);
- },
- tabKeyPressed: function(event)
- {
- this._completeCommonPrefix();
- return true;
- },
- enterKeyPressed: function(event)
- {
- if (this.isSuggestBoxVisible())
- return this._suggestBox.enterKeyPressed(event);
- return false;
- },
- upKeyPressed: function(event)
- {
- if (this.isSuggestBoxVisible())
- return this._suggestBox.upKeyPressed(event);
- return false;
- },
- downKeyPressed: function(event)
- {
- if (this.isSuggestBoxVisible())
- return this._suggestBox.downKeyPressed(event);
- return false;
- },
- pageUpKeyPressed: function(event)
- {
- if (this.isSuggestBoxVisible())
- return this._suggestBox.pageUpKeyPressed(event);
- return false;
- },
- pageDownKeyPressed: function(event)
- {
- if (this.isSuggestBoxVisible())
- return this._suggestBox.pageDownKeyPressed(event);
- return false;
- },
- }
- WebInspector.TextPrompt.prototype.__proto__ = WebInspector.Object.prototype;
- WebInspector.TextPromptWithHistory = function(completions, stopCharacters)
- {
- WebInspector.TextPrompt.call(this, completions, stopCharacters);
- this._data = [];
- this._historyOffset = 1;
- this._coalesceHistoryDupes = true;
- }
- WebInspector.TextPromptWithHistory.prototype = {
- get historyData()
- {
- return this._data;
- },
- setCoalesceHistoryDupes: function(x)
- {
- this._coalesceHistoryDupes = x;
- },
- setHistoryData: function(data)
- {
- this._data = [].concat(data);
- this._historyOffset = 1;
- },
- pushHistoryItem: function(text)
- {
- if (this._uncommittedIsTop) {
- this._data.pop();
- delete this._uncommittedIsTop;
- }
- this._historyOffset = 1;
- if (this._coalesceHistoryDupes && text === this._currentHistoryItem())
- return;
- this._data.push(text);
- },
- _pushCurrentText: function()
- {
- if (this._uncommittedIsTop)
- this._data.pop();
- this._uncommittedIsTop = true;
- this.clearAutoComplete(true);
- this._data.push(this.text);
- },
- _previous: function()
- {
- if (this._historyOffset > this._data.length)
- return undefined;
- if (this._historyOffset === 1)
- this._pushCurrentText();
- ++this._historyOffset;
- return this._currentHistoryItem();
- },
- _next: function()
- {
- if (this._historyOffset === 1)
- return undefined;
- --this._historyOffset;
- return this._currentHistoryItem();
- },
- _currentHistoryItem: function()
- {
- return this._data[this._data.length - this._historyOffset];
- },
- defaultKeyHandler: function(event, force)
- {
- var newText;
- var isPrevious;
- switch (event.keyIdentifier) {
- case "Up":
- if (!this.isCaretOnFirstLine())
- break;
- newText = this._previous();
- isPrevious = true;
- break;
- case "Down":
- if (!this.isCaretOnLastLine())
- break;
- newText = this._next();
- break;
- case "U+0050":
- if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
- newText = this._previous();
- isPrevious = true;
- }
- break;
- case "U+004E":
- if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey)
- newText = this._next();
- break;
- }
- if (newText !== undefined) {
- event.consume(true);
- this.text = newText;
- if (isPrevious) {
- var firstNewlineIndex = this.text.indexOf("\n");
- if (firstNewlineIndex === -1)
- this.moveCaretToEndOfPrompt();
- else {
- var selection = window.getSelection();
- var selectionRange = document.createRange();
- selectionRange.setStart(this._element.firstChild, firstNewlineIndex);
- selectionRange.setEnd(this._element.firstChild, firstNewlineIndex);
- selection.removeAllRanges();
- selection.addRange(selectionRange);
- }
- }
- return true;
- }
- return WebInspector.TextPrompt.prototype.defaultKeyHandler.apply(this, arguments);
- }
- }
- WebInspector.TextPromptWithHistory.prototype.__proto__ = WebInspector.TextPrompt.prototype;
- WebInspector.TextPrompt.SuggestBox = function(textPrompt, inputElement, className)
- {
- this._textPrompt = textPrompt;
- this._inputElement = inputElement;
- this._selectedElement = null;
- this._boundOnScroll = this._onscrollresize.bind(this, true);
- this._boundOnResize = this._onscrollresize.bind(this, false);
- window.addEventListener("scroll", this._boundOnScroll, true);
- window.addEventListener("resize", this._boundOnResize, true);
- this._bodyElement = inputElement.ownerDocument.body;
- this._element = inputElement.ownerDocument.createElement("div");
- this._element.className = "suggest-box " + (className || "");
- this._element.addEventListener("mousedown", this._onboxmousedown.bind(this), true);
- this.containerElement = this._element.createChild("div", "container");
- this.contentElement = this.containerElement.createChild("div", "content");
- }
- WebInspector.TextPrompt.SuggestBox.prototype = {
- get visible()
- {
- return !!this._element.parentElement;
- },
- get hasSelection()
- {
- return !!this._selectedElement;
- },
- _onscrollresize: function(isScroll, event)
- {
- if (isScroll && this._element.isAncestor(event.target) || !this.visible)
- return;
- this._updateBoxPositionWithExistingAnchor();
- },
- _updateBoxPositionWithExistingAnchor: function()
- {
- this._updateBoxPosition(this._anchorBox);
- },
- _updateBoxPosition: function(anchorBox)
- {
- this.contentElement.style.display = "inline-block";
- document.body.appendChild(this.contentElement);
- this.contentElement.positionAt(0, 0);
- var contentWidth = this.contentElement.offsetWidth;
- var contentHeight = this.contentElement.offsetHeight;
- this.contentElement.style.display = "block";
- this.containerElement.appendChild(this.contentElement);
- this._anchorBox = anchorBox;
- const spacer = 6;
- const suggestBoxPaddingX = 21;
- var maxWidth = document.body.offsetWidth - anchorBox.x - spacer;
- var width = Math.min(contentWidth, maxWidth - suggestBoxPaddingX) + suggestBoxPaddingX;
- var paddedWidth = contentWidth + suggestBoxPaddingX;
- var boxX = anchorBox.x;
- if (width < paddedWidth) {
- maxWidth = document.body.offsetWidth - spacer;
- width = Math.min(contentWidth, maxWidth - suggestBoxPaddingX) + suggestBoxPaddingX;
- boxX = document.body.offsetWidth - width;
- }
- const suggestBoxPaddingY = 2;
- var boxY;
- var aboveHeight = anchorBox.y;
- var underHeight = document.body.offsetHeight - anchorBox.y - anchorBox.height;
- var maxHeight = Math.max(underHeight, aboveHeight) - spacer;
- var height = Math.min(contentHeight, maxHeight - suggestBoxPaddingY) + suggestBoxPaddingY;
- if (underHeight >= aboveHeight) {
- boxY = anchorBox.y + anchorBox.height;
- this._element.removeStyleClass("above-anchor");
- this._element.addStyleClass("under-anchor");
- } else {
- boxY = anchorBox.y - height;
- this._element.removeStyleClass("under-anchor");
- this._element.addStyleClass("above-anchor");
- }
- this._element.positionAt(boxX, boxY);
- this._element.style.width = width + "px";
- this._element.style.height = height + "px";
- },
- _onboxmousedown: function(event)
- {
- event.preventDefault();
- },
- hide: function()
- {
- if (!this.visible)
- return;
- this._element.parentElement.removeChild(this._element);
- delete this._selectedElement;
- },
- removeFromElement: function()
- {
- window.removeEventListener("scroll", this._boundOnScroll, true);
- window.removeEventListener("resize", this._boundOnResize, true);
- this.hide();
- },
- _applySuggestion: function(text, isIntermediateSuggestion)
- {
- if (!this.visible || !(text || this._selectedElement))
- return false;
- var suggestion = text || this._selectedElement.textContent;
- if (!suggestion)
- return false;
- this._textPrompt.applySuggestion(suggestion, isIntermediateSuggestion);
- return true;
- },
- acceptSuggestion: function(text)
- {
- var result = this._applySuggestion(text, false);
- this.hide();
- if (!result)
- return false;
- this._textPrompt.acceptSuggestion();
- return true;
- },
- _onNextItem: function(event, isPageScroll)
- {
- var children = this.contentElement.childNodes;
- if (!children.length)
- return false;
- if (!this._selectedElement)
- this._selectedElement = this.contentElement.firstChild;
- else {
- if (!isPageScroll)
- this._selectedElement = this._selectedElement.nextSibling || this.contentElement.firstChild;
- else {
- var candidate = this._selectedElement;
- for (var itemsLeft = this._rowCountPerViewport; itemsLeft; --itemsLeft) {
- if (candidate.nextSibling)
- candidate = candidate.nextSibling;
- else
- break;
- }
- this._selectedElement = candidate;
- }
- }
- this._updateSelection();
- this._applySuggestion(undefined, true);
- return true;
- },
- _onPreviousItem: function(event, isPageScroll)
- {
- var children = this.contentElement.childNodes;
- if (!children.length)
- return false;
- if (!this._selectedElement)
- this._selectedElement = this.contentElement.lastChild;
- else {
- if (!isPageScroll)
- this._selectedElement = this._selectedElement.previousSibling || this.contentElement.lastChild;
- else {
- var candidate = this._selectedElement;
- for (var itemsLeft = this._rowCountPerViewport; itemsLeft; --itemsLeft) {
- if (candidate.previousSibling)
- candidate = candidate.previousSibling;
- else
- break;
- }
- this._selectedElement = candidate;
- }
- }
- this._updateSelection();
- this._applySuggestion(undefined, true);
- return true;
- },
- updateSuggestions: function(anchorBox, completions, canShowForSingleItem)
- {
- if (this._suggestTimeout) {
- clearTimeout(this._suggestTimeout);
- delete this._suggestTimeout;
- }
- this._completionsReady(anchorBox, completions, canShowForSingleItem);
- },
- _onItemMouseDown: function(text, event)
- {
- this.acceptSuggestion(text);
- event.consume(true);
- },
- _createItemElement: function(prefix, text)
- {
- var element = document.createElement("div");
- element.className = "suggest-box-content-item source-code";
- element.tabIndex = -1;
- if (prefix && prefix.length && !text.indexOf(prefix)) {
- var prefixElement = element.createChild("span", "prefix");
- prefixElement.textContent = prefix;
- var suffixElement = element.createChild("span", "suffix");
- suffixElement.textContent = text.substring(prefix.length);
- } else {
- var suffixElement = element.createChild("span", "suffix");
- suffixElement.textContent = text;
- }
- element.addEventListener("mousedown", this._onItemMouseDown.bind(this, text), false);
- return element;
- },
- _updateItems: function(items, canShowForSingleItem)
- {
- this.contentElement.removeChildren();
- var userEnteredText = this._textPrompt._userEnteredText;
- for (var i = 0; i < items.length; ++i) {
- var item = items[i];
- var currentItemElement = this._createItemElement(userEnteredText, item);
- this.contentElement.appendChild(currentItemElement);
- }
- this._selectedElement = canShowForSingleItem ? this.contentElement.firstChild : null;
- this._updateSelection();
- },
- _updateSelection: function()
- {
- for (var child = this.contentElement.firstChild; child; child = child.nextSibling) {
- if (child !== this._selectedElement)
- child.removeStyleClass("selected");
- }
- if (this._selectedElement) {
- this._selectedElement.addStyleClass("selected");
- this._selectedElement.scrollIntoViewIfNeeded(false);
- }
- },
- _canShowBox: function(completions, canShowForSingleItem)
- {
- if (!completions || !completions.length)
- return false;
- if (completions.length > 1)
- return true;
- return canShowForSingleItem && completions[0] !== this._textPrompt._userEnteredText;
- },
- _rememberRowCountPerViewport: function()
- {
- if (!this.contentElement.firstChild)
- return;
- this._rowCountPerViewport = Math.floor(this.containerElement.offsetHeight / this.contentElement.firstChild.offsetHeight);
- },
- _completionsReady: function(anchorBox, completions, canShowForSingleItem)
- {
- if (this._canShowBox(completions, canShowForSingleItem)) {
- this._updateItems(completions, canShowForSingleItem);
- this._updateBoxPosition(anchorBox);
- if (!this.visible)
- this._bodyElement.appendChild(this._element);
- this._rememberRowCountPerViewport();
- } else
- this.hide();
- },
- upKeyPressed: function(event)
- {
- return this._onPreviousItem(event, false);
- },
- downKeyPressed: function(event)
- {
- return this._onNextItem(event, false);
- },
- pageUpKeyPressed: function(event)
- {
- return this._onPreviousItem(event, true);
- },
- pageDownKeyPressed: function(event)
- {
- return this._onNextItem(event, true);
- },
- enterKeyPressed: function(event)
- {
- var hasSelectedItem = !!this._selectedElement;
- this.acceptSuggestion();
- return hasSelectedItem;
- },
- tabKeyPressed: function(event)
- {
- return this.enterKeyPressed(event);
- }
- }
- WebInspector.Popover = function(popoverHelper)
- {
- this.element = document.createElement("div");
- this.element.className = "popover custom-popup-vertical-scroll custom-popup-horizontal-scroll";
- this._popupArrowElement = document.createElement("div");
- this._popupArrowElement.className = "arrow";
- this.element.appendChild(this._popupArrowElement);
- this._contentDiv = document.createElement("div");
- this._contentDiv.className = "content";
- this._visible = false;
- this._popoverHelper = popoverHelper;
- }
- WebInspector.Popover.prototype = {
- show: function(contentElement, anchor, preferredWidth, preferredHeight)
- {
- if (this._disposed)
- return;
- this.contentElement = contentElement;
- if (WebInspector.Popover._popoverElement)
- document.body.removeChild(WebInspector.Popover._popoverElement);
- WebInspector.Popover._popoverElement = this.element;
- this.contentElement.positionAt(0, 0);
- document.body.appendChild(this.contentElement);
- preferredWidth = preferredWidth || this.contentElement.offsetWidth;
- 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);
- this._visible = true;
- if (this._popoverHelper)
- contentElement.addEventListener("mousemove", this._popoverHelper._killHidePopoverTimer.bind(this._popoverHelper), true);
- },
- hide: function()
- {
- if (WebInspector.Popover._popoverElement) {
- delete WebInspector.Popover._popoverElement;
- document.body.removeChild(this.element);
- }
- this._visible = false;
- },
- get visible()
- {
- return this._visible;
- },
- get disposed()
- {
- return this._disposed;
- },
- dispose: function()
- {
- if (this.visible)
- this.hide();
- this._disposed = true;
- },
- setCanShrink: function(canShrink)
- {
- this._hasFixedHeight = !canShrink;
- this._contentDiv.addStyleClass("fixed-height");
- },
- _positionElement: function(anchorElement, preferredWidth, preferredHeight)
- {
- const borderWidth = 25;
- const scrollerWidth = this._hasFixedHeight ? 0 : 11;
- const arrowHeight = 15;
- const arrowOffset = 10;
- const borderRadius = 10;
- preferredWidth = Math.max(preferredWidth, 50);
- const totalWidth = window.innerWidth;
- const totalHeight = window.innerHeight;
- var anchorBox = anchorElement.boxInWindow(window);
- 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) {
- if (anchorBox.y > newElementPosition.height + arrowHeight + borderRadius)
- newElementPosition.y = anchorBox.y - newElementPosition.height - arrowHeight;
- else {
- newElementPosition.y = borderRadius;
- newElementPosition.height = anchorBox.y - borderRadius * 2 - arrowHeight;
- if (this._hasFixedHeight && newElementPosition.height < preferredHeight) {
- newElementPosition.y = borderRadius;
- newElementPosition.height = preferredHeight;
- }
- }
- verticalAlignment = "bottom";
- } else {
- 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;
- if (this._hasFixedHeight && newElementPosition.height < preferredHeight) {
- newElementPosition.y = totalHeight - preferredHeight - borderRadius;
- newElementPosition.height = preferredHeight;
- }
- }
- 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";
- var arrowRightPosition = Math.max(0, totalWidth - anchorBox.x - anchorBox.width - borderRadius - arrowOffset);
- arrowRightPosition += anchorBox.width / 2;
- arrowRightPosition = Math.min(arrowRightPosition, newElementPosition.width - borderRadius - arrowOffset);
- 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;
- this._popupArrowElement.style.left = Math.max(0, anchorBox.x - borderRadius * 2 - arrowOffset) + "px";
- this._popupArrowElement.style.left += anchorBox.width / 2;
- }
- this.element.className = "popover custom-popup-vertical-scroll custom-popup-horizontal-scroll " + 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, showPopover, onHide, disableOnClick)
- {
- this._panelElement = panelElement;
- this._getAnchor = getAnchor;
- this._showPopover = showPopover;
- this._onHide = onHide;
- this._disableOnClick = !!disableOnClick;
- 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)
- {
- if (this._disableOnClick)
- this.hidePopover();
- else {
- this._killHidePopoverTimer();
- this._handleMouseAction(event, true);
- }
- },
- _mouseMove: function(event)
- {
- if (event.target.isSelfOrDescendant(this._hoverElement))
- return;
- if (this._popover && !this._hidePopoverTimer) {
- var self = this;
- function doHide()
- {
- self._hidePopover();
- delete self._hidePopoverTimer;
- }
- this._hidePopoverTimer = setTimeout(doHide, this._timeout / 2);
- }
- this._handleMouseAction(event, false);
- },
- _handleMouseAction: function(event, isMouseDown)
- {
- this._resetHoverTimer();
- if (event.which && this._disableOnClick)
- return;
- this._hoverElement = this._getAnchor(event.target, event);
- 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;
- }
- },
- isPopoverVisible: function()
- {
- return !!this._popover;
- },
- hidePopover: function()
- {
- this._resetHoverTimer();
- this._hidePopover();
- },
- _hidePopover: function()
- {
- if (!this._popover)
- return;
- if (this._onHide)
- this._onHide();
- this._popover.dispose();
- delete this._popover;
- },
- _mouseHover: function(element)
- {
- delete this._hoverTimer;
- this._hidePopover();
- this._popover = new WebInspector.Popover(this);
- this._showPopover(element, this._popover);
- },
- _killHidePopoverTimer: function()
- {
- if (this._hidePopoverTimer) {
- clearTimeout(this._hidePopoverTimer);
- delete this._hidePopoverTimer;
- this._resetHoverTimer();
- }
- }
- }
- 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;
- },
- discard: function()
- {
- }
- }
- WebInspector.View = function()
- {
- this.element = document.createElement("div");
- this.element.__view = this;
- this._visible = true;
- this._isRoot = false;
- this._isShowing = false;
- this._children = [];
- this._hideOnDetach = false;
- this._cssFiles = [];
- }
- WebInspector.View._cssFileToVisibleViewCount = {};
- WebInspector.View._cssFileToStyleElement = {};
- WebInspector.View.prototype = {
- markAsRoot: function()
- {
- this._isRoot = true;
- },
- isShowing: function()
- {
- return this._isShowing;
- },
- setHideOnDetach: function()
- {
- this._hideOnDetach = true;
- },
- _parentIsShowing: function()
- {
- return this._isRoot || (this._parentView && this._parentView.isShowing());
- },
- _callOnVisibleChildren: function(method)
- {
- for (var i = 0; i < this._children.length; ++i)
- if (this._children[i]._visible)
- method.call(this._children[i]);
- },
Add Comment
Please, Sign In to add comment