📄 inspector.js
字号:
for (var panelName in this.panels) { var panel = this.panels[panelName]; if ("reset" in panel) panel.reset(); } for (var category in this.resourceCategories) this.resourceCategories[category].removeAllResources(); this.resources = []; this.resourceURLMap = {}; this.hoveredDOMNode = null; delete this.mainResource; this.console.clearMessages();}WebInspector.inspectedWindowCleared = function(inspectedWindow){ this.panels.elements.inspectedWindowCleared(inspectedWindow);}WebInspector.resourceURLChanged = function(resource, oldURL){ delete this.resourceURLMap[oldURL]; this.resourceURLMap[resource.url] = resource;}WebInspector.addMessageToConsole = function(msg){ this.console.addMessage(msg);}WebInspector.addProfile = function(profile){ this.panels.profiles.addProfile(profile);}WebInspector.setRecordingProfile = function(isProfiling){ this.panels.profiles.setRecordingProfile(isProfiling);}WebInspector.drawLoadingPieChart = function(canvas, percent) { var g = canvas.getContext("2d"); var darkColor = "rgb(122, 168, 218)"; var lightColor = "rgb(228, 241, 251)"; var cx = 8; var cy = 8; var r = 7; g.beginPath(); g.arc(cx, cy, r, 0, Math.PI * 2, false); g.closePath(); g.lineWidth = 1; g.strokeStyle = darkColor; g.fillStyle = lightColor; g.fill(); g.stroke(); var startangle = -Math.PI / 2; var endangle = startangle + (percent * Math.PI * 2); g.beginPath(); g.moveTo(cx, cy); g.arc(cx, cy, r, startangle, endangle, false); g.closePath(); g.fillStyle = darkColor; g.fill();}WebInspector.updateFocusedNode = function(node){ if (!node) // FIXME: Should we deselect if null is passed in? return; this.currentPanel = this.panels.elements; this.panels.elements.focusedDOMNode = node;}WebInspector.displayNameForURL = function(url){ if (!url) return ""; var resource = this.resourceURLMap[url]; if (resource) return resource.displayName; return url.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "");}WebInspector.resourceForURL = function(url){ if (url in this.resourceURLMap) return this.resourceURLMap[url]; // No direct match found. Search for resources that contain // a substring of the URL. for (var resourceURL in this.resourceURLMap) { if (resourceURL.hasSubstring(url)) return this.resourceURLMap[resourceURL]; } return null;}WebInspector.showResourceForURL = function(url, line, preferredPanel){ var resource = this.resourceForURL(url); if (!resource) return false; if (preferredPanel && preferredPanel in WebInspector.panels) { var panel = this.panels[preferredPanel]; if (!("showResource" in panel)) panel = null; else if ("canShowResource" in panel && !panel.canShowResource(resource)) panel = null; } this.currentPanel = panel || this.panels.resources; if (!this.currentPanel) return false; this.currentPanel.showResource(resource, line); return true;}WebInspector.linkifyStringAsFragment = function(string){ var container = document.createDocumentFragment(); var linkStringRegEx = new RegExp("(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}://|www\\.)[\\w$\\-_+*'=\\|/\\\\(){}[\\]%@&#~,:;.!?]{2,}[\\w$\\-_+*=\\|/\\\\({%@&#~]"); while (string) { var linkString = linkStringRegEx.exec(string); if (!linkString) break; linkString = linkString[0]; var title = linkString; var linkIndex = string.indexOf(linkString); var nonLink = string.substring(0, linkIndex); container.appendChild(document.createTextNode(nonLink)); var profileStringRegEx = new RegExp("webkit-profile://(.+)/[0-9]+"); var profileStringMatches = profileStringRegEx.exec(title); var profileTitle; if (profileStringMatches) profileTitle = profileStringMatches[1]; if (profileTitle) title = WebInspector.panels.profiles.displayTitleForProfileLink(profileTitle); var realURL = (linkString.indexOf("www.") === 0 ? "http://" + linkString : linkString); container.appendChild(WebInspector.linkifyURLAsNode(realURL, title, null, (realURL in WebInspector.resourceURLMap))); string = string.substring(linkIndex + linkString.length, string.length); } if (string) container.appendChild(document.createTextNode(string)); return container;}WebInspector.showProfileById = function(uid) { WebInspector.showProfilesPanel(); WebInspector.panels.profiles.showProfileById(uid);}WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal){ if (!linkText) linkText = url; classes = (classes ? classes + " " : ""); classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource-link"; var a = document.createElement("a"); a.href = url; a.className = classes; a.title = url; a.target = "_blank"; a.textContent = linkText; return a;}WebInspector.linkifyURL = function(url, linkText, classes, isExternal){ // Use the DOM version of this function so as to avoid needing to escape attributes. // FIXME: Get rid of linkifyURL entirely. return WebInspector.linkifyURLAsNode(url, linkText, classes, isExternal).outerHTML;}WebInspector.addMainEventListeners = function(doc){ doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), true); doc.defaultView.addEventListener("blur", this.windowBlured.bind(this), true); doc.addEventListener("click", this.documentClick.bind(this), true);}WebInspector.searchKeyDown = function(event){ if (event.keyIdentifier !== "Enter") return; // Call preventDefault since this was the Enter key. This prevents a "search" event // from firing for key down. We handle the Enter key on key up in searchKeyUp. This // stops performSearch from being called twice in a row. event.preventDefault();}WebInspector.searchKeyUp = function(event){ if (event.keyIdentifier !== "Enter") return; // Select all of the text so the user can easily type an entirely new query. event.target.select(); // Only call performSearch if the Enter key was pressed. Otherwise the search // performance is poor because of searching on every key. The search field has // the incremental attribute set, so we still get incremental searches. this.performSearch(event);}WebInspector.performSearch = function(event){ var query = event.target.value; var forceSearch = event.keyIdentifier === "Enter"; if (!query || !query.length || (!forceSearch && query.length < 3)) { delete this.currentQuery; for (var panelName in this.panels) { var panel = this.panels[panelName]; if (panel.currentQuery && panel.searchCanceled) panel.searchCanceled(); delete panel.currentQuery; } this.updateSearchMatchesCount(); return; } if (query === this.currentPanel.currentQuery && this.currentPanel.currentQuery === this.currentQuery) { // When this is the same query and a forced search, jump to the next // search result for a good user experience. if (forceSearch && this.currentPanel.jumpToNextSearchResult) this.currentPanel.jumpToNextSearchResult(); return; } this.currentQuery = query; this.updateSearchMatchesCount(); if (!this.currentPanel.performSearch) return; this.currentPanel.currentQuery = query; this.currentPanel.performSearch(query);}WebInspector.updateSearchMatchesCount = function(matches, panel){ if (!panel) panel = this.currentPanel; panel.currentSearchMatches = matches; if (panel !== this.currentPanel) return; if (!this.currentPanel.currentQuery) { document.getElementById("search-results-matches").addStyleClass("hidden"); return; } if (matches) { if (matches === 1) var matchesString = WebInspector.UIString("1 match"); else var matchesString = WebInspector.UIString("%d matches", matches); } else var matchesString = WebInspector.UIString("Not Found"); var matchesToolbarElement = document.getElementById("search-results-matches"); matchesToolbarElement.removeStyleClass("hidden"); matchesToolbarElement.textContent = matchesString;}WebInspector.UIString = function(string){ if (window.localizedStrings && string in window.localizedStrings) string = window.localizedStrings[string]; else { if (!(string in this.missingLocalizedStrings)) { console.error("Localized string \"" + string + "\" not found."); this.missingLocalizedStrings[string] = true; } if (Preferences.showMissingLocalizedStrings) string += " (not localized)"; } return String.vsprintf(string, Array.prototype.slice.call(arguments, 1));}WebInspector.isBeingEdited = function(element){ return element.__editing;}WebInspector.startEditing = function(element, committedCallback, cancelledCallback, context){ if (element.__editing) return; element.__editing = true; var oldText = element.textContent; var oldHandleKeyEvent = element.handleKeyEvent; element.addStyleClass("editing"); var oldTabIndex = element.tabIndex; if (element.tabIndex < 0) element.tabIndex = 0; function blurEventListener() { editingCommitted.call(element); } function cleanUpAfterEditing() { delete this.__editing; this.removeStyleClass("editing"); this.tabIndex = oldTabIndex; this.scrollTop = 0; this.scrollLeft = 0; this.handleKeyEvent = oldHandleKeyEvent; element.removeEventListener("blur", blurEventListener, false); if (element === WebInspector.currentFocusElement || element.isAncestor(WebInspector.currentFocusElement)) WebInspector.currentFocusElement = WebInspector.previousFocusElement; } function editingCancelled() { this.innerText = oldText; cleanUpAfterEditing.call(this); cancelledCallback(this, context); } function editingCommitted() { cleanUpAfterEditing.call(this); committedCallback(this, this.textContent, oldText, context); } element.handleKeyEvent = function(event) { if (oldHandleKeyEvent) oldHandleKeyEvent(event); if (event.handled) return; if (event.keyIdentifier === "Enter") { editingCommitted.call(element); event.preventDefault(); } else if (event.keyCode === 27) { // Escape key editingCancelled.call(element); event.preventDefault(); event.handled = true; } } element.addEventListener("blur", blurEventListener, false); WebInspector.currentFocusElement = element;}WebInspector._toolbarItemClicked = function(event){ var toolbarItem = event.currentTarget; this.currentPanel = toolbarItem.panel;}// This table maps MIME types to the Resource.Types which are valid for them.// The following line:// "text/html": {0: 1},// means that text/html is a valid MIME type for resources that have type// WebInspector.Resource.Type.Document (which has a value of 0).WebInspector.MIMETypes = { "text/html": {0: true}, "text/xml": {0: true}, "text/plain": {0: true}, "application/xhtml+xml": {0: true}, "text/css": {1: true}, "text/xsl": {1: true}, "image/jpeg": {2: true}, "image/png": {2: true}, "image/gif": {2: true}, "image/bmp": {2: true}, "image/x-icon": {2: true}, "image/x-xbitmap": {2: true}, "font/ttf": {3: true}, "font/opentype": {3: true}, "application/x-font-type1": {3: true}, "application/x-font-ttf": {3: true}, "application/x-truetype-font": {3: true}, "text/javascript": {4: true}, "text/ecmascript": {4: true}, "application/javascript": {4: true}, "application/ecmascript": {4: true}, "application/x-javascript": {4: true}, "text/javascript1.1": {4: true}, "text/javascript1.2": {4: true}, "text/javascript1.3": {4: true}, "text/jscript": {4: true}, "text/livescript": {4: true},}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -