Changeset 52820 in webkit


Ignore:
Timestamp:
Jan 5, 2010 12:37:39 PM (14 years ago)
Author:
bweinstein@apple.com
Message:

Part of <https://bugs.webkit.org/show_bug.cgi?id=32568>.
Web Inspector: Context Menus should be used in more places.

Reviewed by Tim Hatcher.

Add context menus to handle the interaction with breakpoints in the Source Frame. Currently
we use left click to add/disable/remove breakpoints, and left click to edit (for conditional
breakpoints), but this is hard to discover and behaves differently than Xcode.

Change the behavior to be more like Xcode, left click adds a breakpoint if there isn't one, and
removes it if there is one.

On the context menu, if there is no breakpoint there, we have Add Breakpoint, and Add Conditional
Breakpoint. If there is a breakpoint there, we add entries for Edit Breakpoint (edit
the condition), Remove Breakpoint, and Enable/Disable Breakpoint (based on the current state).

  • English.lproj/localizedStrings.js: Added localized context menu entries.
  • inspector/front-end/SourceFrame.js:

(WebInspector.SourceFrame.prototype._documentContextMenu.addAndEditBreakpoint):
(WebInspector.SourceFrame.prototype._documentContextMenu): Added context menu entries and handlers.
(WebInspector.SourceFrame.prototype._documentMouseDown): Changed left click behavior (Add -> Remove).

Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52819 r52820  
     12010-01-04  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Tim Hatcher.
     4
     5        Part of <https://bugs.webkit.org/show_bug.cgi?id=32568>.
     6        Web Inspector: Context Menus should be used in more places.
     7       
     8        Add context menus to handle the interaction with breakpoints in the Source Frame. Currently
     9        we use left click to add/disable/remove breakpoints, and left click to edit (for conditional
     10        breakpoints), but this is hard to discover and behaves differently than Xcode.
     11       
     12        Change the behavior to be more like Xcode, left click adds a breakpoint if there isn't one, and
     13        removes it if there is one.
     14       
     15        On the context menu, if there is no breakpoint there, we have Add Breakpoint, and Add Conditional
     16        Breakpoint. If there is a breakpoint there, we add entries for Edit Breakpoint (edit
     17        the condition), Remove Breakpoint, and Enable/Disable Breakpoint (based on the current state).
     18
     19        * English.lproj/localizedStrings.js: Added localized context menu entries.
     20        * inspector/front-end/SourceFrame.js:
     21        (WebInspector.SourceFrame.prototype._documentContextMenu.addAndEditBreakpoint):
     22        (WebInspector.SourceFrame.prototype._documentContextMenu): Added context menu entries and handlers.
     23        (WebInspector.SourceFrame.prototype._documentMouseDown): Changed left click behavior (Add -> Remove).
     24
    1252010-01-05  Chris Fleizach  <cfleizach@apple.com>
    226
  • trunk/WebCore/inspector/front-end/SourceFrame.js

    r52439 r52820  
    311311        if (!event.target.hasStyleClass("webkit-line-number"))
    312312            return;
     313        if (!this.addBreakpointDelegate)
     314            return;
     315
    313316        var sourceRow = event.target.enclosingNodeOrSelfWithNodeName("tr");
    314         if (!sourceRow._breakpointObject && this.addBreakpointDelegate)
    315             this.addBreakpointDelegate(this.lineNumberForSourceRow(sourceRow));
    316 
    317         var breakpoint = sourceRow._breakpointObject;
    318         if (!breakpoint)
    319             return;
    320 
    321         this._editBreakpointCondition(event.target, sourceRow, breakpoint);
    322         event.preventDefault();
     317        var contextMenu = new WebInspector.ContextMenu();
     318       
     319        if (!sourceRow._breakpointObject && this.addBreakpointDelegate) {
     320            var lineNumber = this.lineNumberForSourceRow(sourceRow);
     321            // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
     322            contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this.addBreakpointDelegate.bind(this, lineNumber));
     323
     324            function addConditionalBreakpoint()
     325            {
     326                this.addBreakpointDelegate(lineNumber);
     327                var breakpoint = sourceRow._breakpointObject;
     328                if (breakpoint)
     329                    this._editBreakpointCondition(event.target, sourceRow, breakpoint);
     330            }
     331
     332            contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint..."), addConditionalBreakpoint.bind(this));
     333        } else if (sourceRow._breakpointObject) {
     334            // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
     335            contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), WebInspector.panels.scripts.removeBreakpoint.bind(WebInspector.panels.scripts, sourceRow._breakpointObject));
     336            contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint..."), this._editBreakpointCondition.bind(this, event.target, sourceRow, sourceRow._breakpointObject));
     337            if (sourceRow._breakpointObject.enabled)
     338                contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), function() { sourceRow._breakpointObject.enabled = false; });
     339            else
     340                contextMenu.appendItem(WebInspector.UIString("Enable Breakpoint"), function() { sourceRow._breakpointObject.enabled = true; });
     341        }
     342       
     343        contextMenu.show(event);
    323344    },
    324345
     
    330351            return;
    331352        var sourceRow = event.target.enclosingNodeOrSelfWithNodeName("tr");
    332         if (sourceRow._breakpointObject && sourceRow._breakpointObject.enabled)
    333             sourceRow._breakpointObject.enabled = false;
    334         else if (sourceRow._breakpointObject)
     353        if (sourceRow._breakpointObject)
    335354            WebInspector.panels.scripts.removeBreakpoint(sourceRow._breakpointObject);
    336355        else if (this.addBreakpointDelegate)
Note: See TracChangeset for help on using the changeset viewer.