⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scriptspanel.js

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 JS
📖 第 1 页 / 共 2 页
字号:
        if (this._visibleView)            this._visibleView.hide();        this._visibleView = x;        if (x)            x.show(this.viewsContainerElement);    },    canShowResource: function(resource)    {        return resource && resource.scripts.length && InspectorController.debuggerEnabled();    },    showScript: function(script, line)    {        this._showScriptOrResource(script, line, true);    },    showResource: function(resource, line)    {        this._showScriptOrResource(resource, line, true);    },    showView: function(view)    {        if (!view)            return;        this._showScriptOrResource((view.resource || view.script));    },    scriptViewForScript: function(script)    {        if (!script)            return null;        if (!script._scriptView)            script._scriptView = new WebInspector.ScriptView(script);        return script._scriptView;    },    sourceFrameForScript: function(script)    {        var view = this.scriptViewForScript(script);        if (!view)            return null;        // Setting up the source frame requires that we be attached.        if (!this.element.parentNode)            this.attach();        view.setupSourceFrameIfNeeded();        return view.sourceFrame;    },    _sourceViewForScriptOrResource: function(scriptOrResource)    {        if (scriptOrResource instanceof WebInspector.Resource) {            if (!WebInspector.panels.resources)                return null;            return WebInspector.panels.resources.resourceViewForResource(scriptOrResource);        }        if (scriptOrResource instanceof WebInspector.Script)            return this.scriptViewForScript(scriptOrResource);    },    _sourceFrameForScriptOrResource: function(scriptOrResource)    {        if (scriptOrResource instanceof WebInspector.Resource) {            if (!WebInspector.panels.resources)                return null;            return WebInspector.panels.resources.sourceFrameForResource(scriptOrResource);        }        if (scriptOrResource instanceof WebInspector.Script)            return this.sourceFrameForScript(scriptOrResource);    },    _showScriptOrResource: function(scriptOrResource, line, shouldHighlightLine, fromBackForwardAction)    {        if (!scriptOrResource)            return;        var view;        if (scriptOrResource instanceof WebInspector.Resource) {            if (!WebInspector.panels.resources)                return null;            view = WebInspector.panels.resources.resourceViewForResource(scriptOrResource);            view.headersVisible = false;            if (scriptOrResource.url in this._breakpointsURLMap) {                var sourceFrame = this._sourceFrameForScriptOrResource(scriptOrResource);                if (sourceFrame && !sourceFrame.breakpoints.length) {                    var breakpoints = this._breakpointsURLMap[scriptOrResource.url];                    var breakpointsLength = breakpoints.length;                    for (var i = 0; i < breakpointsLength; ++i)                        sourceFrame.addBreakpoint(breakpoints[i]);                }            }        } else if (scriptOrResource instanceof WebInspector.Script)            view = this.scriptViewForScript(scriptOrResource);        if (!view)            return;        if (!fromBackForwardAction) {            var oldIndex = this._currentBackForwardIndex;            if (oldIndex >= 0)                this._backForwardList.splice(oldIndex + 1, this._backForwardList.length - oldIndex);            // Check for a previous entry of the same object in _backForwardList.            // If one is found, remove it and update _currentBackForwardIndex to match.            var previousEntryIndex = this._backForwardList.indexOf(scriptOrResource);            if (previousEntryIndex !== -1) {                this._backForwardList.splice(previousEntryIndex, 1);                --this._currentBackForwardIndex;            }            this._backForwardList.push(scriptOrResource);            ++this._currentBackForwardIndex;            this._updateBackAndForwardButtons();        }        this.visibleView = view;        if (line) {            if (view.revealLine)                view.revealLine(line);            if (view.highlightLine && shouldHighlightLine)                view.highlightLine(line);        }        var option;        if (scriptOrResource instanceof WebInspector.Script) {            option = scriptOrResource.filesSelectOption;            console.assert(option);        } else {            var url = scriptOrResource.url;            var script = this._scriptsForURLsInFilesSelect[url];            if (script)               option = script.filesSelectOption;        }        if (option)            this.filesSelectElement.selectedIndex = option.index;    },    _addScriptToFilesMenu: function(script)    {        if (script.resource && this._scriptsForURLsInFilesSelect[script.sourceURL])            return;        this._scriptsForURLsInFilesSelect[script.sourceURL] = script;        var select = this.filesSelectElement;        var option = document.createElement("option");        option.representedObject = (script.resource || script);        option.text = (script.sourceURL ? WebInspector.displayNameForURL(script.sourceURL) : WebInspector.UIString("(program)"));        var insertionIndex = -1;        if (select.childNodes) {            insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, function(a, b) {                    a = a.text.toLowerCase();                b = b.text.toLowerCase();                                if (a < b)                    return -1;                else if (a > b)                    return 1;                return 0;            });        }        if (insertionIndex < 0)            select.appendChild(option);        else            select.insertBefore(option, select.childNodes.item(insertionIndex));        script.filesSelectOption = option;        // Call _showScriptOrResource if the option we just appended ended up being selected.        // This will happen for the first item added to the menu.        if (select.options[select.selectedIndex] === option)            this._showScriptOrResource(option.representedObject);    },    _clearCurrentExecutionLine: function()    {        if (this._executionSourceFrame)            this._executionSourceFrame.executionLine = 0;        delete this._executionSourceFrame;    },    _callFrameSelected: function()    {        this._clearCurrentExecutionLine();        var callStackPane = this.sidebarPanes.callstack;        var currentFrame = callStackPane.selectedCallFrame;        if (!currentFrame)            return;        this.sidebarPanes.scopechain.update(currentFrame);        var scriptOrResource = this._sourceIDMap[currentFrame.sourceID];        this._showScriptOrResource(scriptOrResource, currentFrame.line);        this._executionSourceFrame = this._sourceFrameForScriptOrResource(scriptOrResource);        if (this._executionSourceFrame)            this._executionSourceFrame.executionLine = currentFrame.line;    },    _changeVisibleFile: function(event)    {        var select = this.filesSelectElement;        this._showScriptOrResource(select.options[select.selectedIndex].representedObject);    },    _startSidebarResizeDrag: function(event)    {        WebInspector.elementDragStart(this.sidebarElement, this._sidebarResizeDrag.bind(this), this._endSidebarResizeDrag.bind(this), event, "col-resize");        if (event.target === this.sidebarResizeWidgetElement)            this._dragOffset = (event.target.offsetWidth - (event.pageX - event.target.totalOffsetLeft));        else            this._dragOffset = 0;    },    _endSidebarResizeDrag: function(event)    {        WebInspector.elementDragEnd(event);        delete this._dragOffset;    },    _sidebarResizeDrag: function(event)    {        var x = event.pageX + this._dragOffset;        var newWidth = Number.constrain(window.innerWidth - x, Preferences.minScriptsSidebarWidth, window.innerWidth * 0.66);        this.sidebarElement.style.width = newWidth + "px";        this.sidebarButtonsElement.style.width = newWidth + "px";        this.viewsContainerElement.style.right = newWidth + "px";        this.sidebarResizeWidgetElement.style.right = newWidth + "px";        this.sidebarResizeElement.style.right = (newWidth - 3) + "px";        event.preventDefault();    },    _updatePauseOnExceptionsButton: function()    {        if (InspectorController.pauseOnExceptions()) {            this.pauseOnExceptionButton.title = WebInspector.UIString("Don't pause on exceptions.");            this.pauseOnExceptionButton.addStyleClass("toggled-on");        } else {            this.pauseOnExceptionButton.title = WebInspector.UIString("Pause on exceptions.");            this.pauseOnExceptionButton.removeStyleClass("toggled-on");        }    },    _updateDebuggerButtons: function()    {        if (InspectorController.debuggerEnabled()) {            this.enableToggleButton.title = WebInspector.UIString("Debugging enabled. Click to disable.");            this.enableToggleButton.addStyleClass("toggled-on");            this.pauseOnExceptionButton.removeStyleClass("hidden");            this.panelEnablerView.visible = false;        } else {            this.enableToggleButton.title = WebInspector.UIString("Debugging disabled. Click to enable.");            this.enableToggleButton.removeStyleClass("toggled-on");            this.pauseOnExceptionButton.addStyleClass("hidden");            this.panelEnablerView.visible = true;        }        this._updatePauseOnExceptionsButton();        if (this._paused) {            this.pauseButton.addStyleClass("paused");            this.pauseButton.disabled = false;            this.stepOverButton.disabled = false;            this.stepIntoButton.disabled = false;            this.stepOutButton.disabled = false;            this.debuggerStatusElement.textContent = WebInspector.UIString("Paused");        } else {            this.pauseButton.removeStyleClass("paused");            this.pauseButton.disabled = this._waitingToPause;            this.stepOverButton.disabled = true;            this.stepIntoButton.disabled = true;            this.stepOutButton.disabled = true;            if (this._waitingToPause)                this.debuggerStatusElement.textContent = WebInspector.UIString("Pausing");            else if (this._stepping)                this.debuggerStatusElement.textContent = WebInspector.UIString("Stepping");            else                this.debuggerStatusElement.textContent = "";        }    },    _updateBackAndForwardButtons: function()    {        this.backButton.disabled = this._currentBackForwardIndex <= 0;        this.forwardButton.disabled = this._currentBackForwardIndex >= (this._backForwardList.length - 1);    },    _clearInterface: function()    {        this.sidebarPanes.callstack.update(null);        this.sidebarPanes.scopechain.update(null);        this._clearCurrentExecutionLine();        this._updateDebuggerButtons();    },    _goBack: function()    {        if (this._currentBackForwardIndex <= 0) {            console.error("Can't go back from index " + this._currentBackForwardIndex);            return;        }        this._showScriptOrResource(this._backForwardList[--this._currentBackForwardIndex], null, false, true);        this._updateBackAndForwardButtons();    },    _goForward: function()    {        if (this._currentBackForwardIndex >= this._backForwardList.length - 1) {            console.error("Can't go forward from index " + this._currentBackForwardIndex);            return;        }        this._showScriptOrResource(this._backForwardList[++this._currentBackForwardIndex], null, false, true);        this._updateBackAndForwardButtons();    },    _enableDebugging: function()    {        if (InspectorController.debuggerEnabled())            return;        this._toggleDebugging();    },    _toggleDebugging: function()    {        this._paused = false;        this._waitingToPause = false;        this._stepping = false;        if (InspectorController.debuggerEnabled())            InspectorController.disableDebugger();        else            InspectorController.enableDebugger();    },    _togglePauseOnExceptions: function()    {        InspectorController.setPauseOnExceptions(!InspectorController.pauseOnExceptions());        this._updatePauseOnExceptionsButton();    },    _togglePause: function()    {        if (this._paused) {            this._paused = false;            this._waitingToPause = false;            InspectorController.resumeDebugger();        } else {            this._stepping = false;            this._waitingToPause = true;            InspectorController.pauseInDebugger();        }        this._clearInterface();    },    _stepOverClicked: function()    {        this._paused = false;        this._stepping = true;        this._clearInterface();        InspectorController.stepOverStatementInDebugger();    },    _stepIntoClicked: function()    {        this._paused = false;        this._stepping = true;        this._clearInterface();        InspectorController.stepIntoStatementInDebugger();    },    _stepOutClicked: function()    {        this._paused = false;        this._stepping = true;        this._clearInterface();        InspectorController.stepOutOfFunctionInDebugger();    }}WebInspector.ScriptsPanel.prototype.__proto__ = WebInspector.Panel.prototype;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -