Closed Bug 737803 Opened 13 years ago Closed 12 years ago

Setting a breakpoint in a line without code should move the icon to the actual location

Categories

(DevTools :: Debugger, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 19

People

(Reporter: past, Assigned: anton)

References

Details

Attachments

(1 file, 2 obsolete files)

Setting a breakpoint in a line without code is automatically handled by the debugger by skipping forward to the first available line, returning an actualLocation property in the response. The debugger UI and editor should reflect that.
Jim suggested using an animation to slide the icon to the proper line, which sounds splendid!
Priority: P2 → P3
Spent today going through the debugger code, looking how things are done. As a result, taking this bug to make myself familiar with breakpoints and such in more practical sense.
Assignee: nobody → anton
Status: NEW → ASSIGNED
Attached patch Move breakpoint to the actual line (obsolete) (deleted) — Splinter Review
Spent way too much time on this patch. Partially because there are no docs so I was learning with scratchpad and generous usage of |dump| function. But mostly because I couldn't figure out why breakpoints don't go away sometimes.

It turns out that you can add unlimited amount of breakpoints to the same line with the same handler[1] and that created duplicates because we can't check if breakpoint is already there when the line is nonsensical (we have to wait for our callback to be called with |actualLocation| property).

My patch moves the visual breakpoint where needed and handles all duplicates. Asking for feedback to make sure I'm not too far off. After that I'll work on tests and animation.

[1] - https://wiki.mozilla.org/Debugger (see setBreakpoint)
Attachment #665222 - Flags: feedback?(past)
Attachment #665222 - Flags: feedback?(mihai.sucan)
Comment on attachment 665222 [details] [diff] [review]
Move breakpoint to the actual line

This looks good to me, but I don't know the debugger UI code very well. I'll let Panos take this patch.

Thanks!
Attachment #665222 - Flags: feedback?(mihai.sucan) → feedback+
Comment on attachment 665222 [details] [diff] [review]
Move breakpoint to the actual line

Review of attachment 665222 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/devtools/debugger/debugger-controller.js
@@ +1726,5 @@
> +    for each (let breakpoint in this.store) {
> +      if (breakpoint.location.url == aUrl && breakpoint.location.line == aLine) {
> +        breakpoints.push(breakpoint);
> +      }
> +    }

for-each...in statement is deprecated as part of E4X.
So it's better to use other way; for-of statement, or simple for statement.
Comment on attachment 665222 [details] [diff] [review]
Move breakpoint to the actual line

Review of attachment 665222 [details] [diff] [review]:
-----------------------------------------------------------------

Yes, this looks fine at first glance.
Attachment #665222 - Flags: feedback?(past) → feedback+
So I was working on and off for a day on trying to make breakpoint elements to fade but so far I don't think it is (easily) possible. I tried digging into Orion source and getting a link for an element from there but got lost in numerous events and callbacks that delegate actual actions one to another. Then Mihai told me on IRC that I should be looking at source-editor-orion.jsm instead and I found out how to change the class name:

> var ann = editor._getAnnotationsByType("breakpoint", 0,
>   editor.getCharCount())[0];
>
> ann.style.styleClass = "removed";
> editor._annotationModel.modifyAnnotation(ann);

CSS looks like this:

> .annotation.breakpoint {
>   transition: opacity 2s ease-in-out;
>   -moz-transition: opacity 2s ease-in-out;
>   opacity: 1;
> }    

> .annotation.breakpoint.removed {
>   opacity: 0;
> }

However, later I realized that |modifyAnnotation| kills the old element and replaces it with a new one making CSS transitions impossible. Is there some other way to either get a DOM reference to an annotation or update an annotation element without deleting it?
Unfortunately, it seems you can't do that fade easily - without changes in Orion. Just don't bother about the fade.
Attached patch Move breakpoint to the actual line (obsolete) (deleted) — Splinter Review
Added a test for this change. It sucks that we can't do any kind of animation/transformation in the ruler.
Attachment #665222 - Attachment is obsolete: true
Attachment #668682 - Flags: review?(past)
Comment on attachment 668682 [details] [diff] [review]
Move breakpoint to the actual line

Review of attachment 668682 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, just a couple of minor things. I'll file a followup for the case of adjusting the position of breakpoints on scripts not yet present in the debugger.

::: browser/devtools/debugger/test/browser_dbg_bug737803_editor_actual_location.js
@@ +74,5 @@
> +  }
> +
> +  function onBreakpointAdd(aBpClient) {
> +    is(aBpClient.location.url, gScripts.selected, "URL is the same");
> +    is(aBpClient.location.line, 6, "Line numbers is new");

Typo: "Line number"

::: browser/devtools/debugger/test/test-script-switching-02.js
@@ +6,5 @@
>    eval("debugger;");
> +  function foo() {}
> +  if (true) {
> +    foo();
> +  }

What is the point of this change?
Attachment #668682 - Flags: review?(past) → review+
One refactoring I would like us to do at some point, is to move the breakpoint store from the controller to the client, so that these smarts can be reused by Firebug et al.
(In reply to Panos Astithas [:past] from comment #11)
> One refactoring I would like us to do at some point, is to move the
> breakpoint store from the controller to the client, so that these smarts can
> be reused by Firebug et al.

A splendid idea.
> What is the point of this change?

Some tests were testing breakpoint by setting them on a nonsensical line and checking the line number afterwards. And since my patch changes the line number to reflect |actualLocation| these tests were failing. Basically, these tests needed at least three valid lines to set breakpoints on. This change adds these lines.
Fixed a typo.
Attachment #668682 - Attachment is obsolete: true
Attachment #669188 - Flags: review+
Whiteboard: [land-in-fx-team]
https://hg.mozilla.org/integration/fx-team/rev/586a2ae61c95
Whiteboard: [land-in-fx-team] → [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/586a2ae61c95
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 19
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: