16

铬(版本 23.0.1271.101)。我在 OS X 上,如果这很重要的话。

为什么 Chrome 能够禁用和/或停用断点?是否有一些我不知道的电源使用情况?

注意到我可以禁用一些断点,然后全部停用。重新激活它们后,相同的禁用对象将被禁用。除此之外,拥有这两种选择的目的是什么?

在此处输入图像描述

4

2 回答 2

12

Deactivate Breakpoints 关闭断点功能。禁用所有断点是将每个断点标记为禁用的快捷方式。

当您比较 Enable All Breakpoints 和 Activate Breakpoints 时,差异变得更加明显。

可以通过每个断点旁边的复选框启用或禁用单个断点。

在此处输入图像描述

禁用所有断点取消选中所有断点,实际上关闭断点功能。Deactivate Breakpoints 显式关闭断点功能。所以这两个选项具有相同的效果。

激活断点启用断点功能,保留各个断点的启用/禁用状态。Enable All Breakpoints 启用每个断点,但如果断点功能已被停用,则不会打开它本身。

于 2014-05-30T18:36:55.527 回答
1

这是最近铬源的断点原型。如您所见,断点已启用或禁用。我没有看到任何可以反映断点被“禁用”或“停用”的属性。可能跟条件有关。否则我会说这是前端不一致。

WebInspector.BreakpointManager.Breakpoint.prototype = {
/**
 * @return {WebInspector.UILocation}
 */
primaryUILocation: function()
{
    return this._primaryUILocation;
},

/**
 * @param {WebInspector.DebuggerModel.Location} location
 */
_addResolvedLocation: function(location)
{
    this._liveLocations.push(this._breakpointManager._debuggerModel.createLiveLocation(location, this._locationUpdated.bind(this, location)));
},

/**
 * @param {WebInspector.DebuggerModel.Location} location
 * @param {WebInspector.UILocation} uiLocation
 */
_locationUpdated: function(location, uiLocation)
{
    var stringifiedLocation = location.scriptId + ":" + location.lineNumber + ":" + location.columnNumber;
    var oldUILocation = /** @type {WebInspector.UILocation} */ (this._uiLocations[stringifiedLocation]);
    if (oldUILocation)
        this._breakpointManager._uiLocationRemoved(this, oldUILocation);
    if (this._uiLocations[""]) {
        delete this._uiLocations[""];
        this._breakpointManager._uiLocationRemoved(this, this._primaryUILocation);
    }
    this._uiLocations[stringifiedLocation] = uiLocation;
    this._breakpointManager._uiLocationAdded(this, uiLocation);
},

/**
 * @return {boolean}
 */
enabled: function()
{
    return this._enabled;
},

/**
 * @param {boolean} enabled
 */
setEnabled: function(enabled)
{
    this._updateBreakpoint(this._condition, enabled);
},

/**
 * @return {string}
 */
condition: function()
{
    return this._condition;
},

/**
 * @param {string} condition
 */
setCondition: function(condition)
{
    this._updateBreakpoint(condition, this._enabled);
},

/**
 * @param {string} condition
 * @param {boolean} enabled
 */
_updateBreakpoint: function(condition, enabled)
{
    if (this._enabled === enabled && this._condition === condition)
        return;

    if (this._enabled)
        this._removeFromDebugger();

    this._enabled = enabled;
    this._condition = condition;
    this._breakpointManager._storage._updateBreakpoint(this);

    var scriptFile = this._primaryUILocation.uiSourceCode.scriptFile();
    if (this._enabled && !(scriptFile && scriptFile.hasDivergedFromVM())) {
        this._setInDebugger();
        return;
    }

    this._fakeBreakpointAtPrimaryLocation();
},

/**
 * @param {boolean=} keepInStorage
 */
remove: function(keepInStorage)
{
    var removeFromStorage = !keepInStorage;
    this._resetLocations();
    this._removeFromDebugger();
    this._breakpointManager._removeBreakpoint(this, removeFromStorage);
},

_setInDebugger: function()
{
    var rawLocation = this._primaryUILocation.uiLocationToRawLocation();
    var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ (rawLocation);
    if (debuggerModelLocation)
        this._breakpointManager._debuggerModel.setBreakpointByScriptLocation(debuggerModelLocation, this._condition, didSetBreakpoint.bind(this));
    else
        this._breakpointManager._debuggerModel.setBreakpointByURL(this._primaryUILocation.uiSourceCode.url, this._primaryUILocation.lineNumber, 0, this._condition, didSetBreakpoint.bind(this));

    /**
     * @this {WebInspector.BreakpointManager.Breakpoint}
     * @param {?DebuggerAgent.BreakpointId} breakpointId
     * @param {Array.<WebInspector.DebuggerModel.Location>} locations
     */
    function didSetBreakpoint(breakpointId, locations)
    {
        if (!breakpointId) {
            this._resetLocations();
            this._breakpointManager._removeBreakpoint(this, false);
            return;
        }

        this._debuggerId = breakpointId;
        this._breakpointManager._breakpointForDebuggerId[breakpointId] = this;

        if (!locations.length) {
            this._fakeBreakpointAtPrimaryLocation();
            return;
        }

        this._resetLocations();
        for (var i = 0; i < locations.length; ++i) {
            var script = this._breakpointManager._debuggerModel.scriptForId(locations[i].scriptId);
            var uiLocation = script.rawLocationToUILocation(locations[i].lineNumber, locations[i].columnNumber);
            if (this._breakpointManager.findBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber)) {
                // location clash
                this.remove();
                return;
            }
        }

        for (var i = 0; i < locations.length; ++i)
            this._addResolvedLocation(locations[i]);
    }
},

_removeFromDebugger: function()
{
    if (this._debuggerId) {
        this._breakpointManager._debuggerModel.removeBreakpoint(this._debuggerId);
        delete this._breakpointManager._breakpointForDebuggerId[this._debuggerId];
        delete this._debuggerId;
    }
},

_resetLocations: function()
{
    for (var stringifiedLocation in this._uiLocations)
        this._breakpointManager._uiLocationRemoved(this, this._uiLocations[stringifiedLocation]);

    for (var i = 0; i < this._liveLocations.length; ++i)
        this._liveLocations[i].dispose();
    this._liveLocations = [];

    this._uiLocations = {};
},

/**
 * @return {string}
 */
_breakpointStorageId: function()
{
    return this._sourceFileId + ":" + this._primaryUILocation.lineNumber;
},

_fakeBreakpointAtPrimaryLocation: function()
{
    this._resetLocations();
    this._uiLocations[""] = this._primaryUILocation;
    this._breakpointManager._uiLocationAdded(this, this._primaryUILocation);
}
}
于 2013-01-04T15:34:25.580 回答