OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library script_inset_element; | 5 library script_inset_element; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
10 import 'service_ref.dart'; | 10 import 'service_ref.dart'; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 annotations.add(new CallSiteAnnotation(callSite)); | 375 annotations.add(new CallSiteAnnotation(callSite)); |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 annotations.sort(); | 379 annotations.sort(); |
380 } | 380 } |
381 | 381 |
382 Element linesTable() { | 382 Element linesTable() { |
383 var table = new DivElement(); | 383 var table = new DivElement(); |
384 table.classes.add("sourceTable"); | 384 table.classes.add("sourceTable"); |
385 table.onCopy.listen((event) { | |
386 // Omit breakpoint indicators and line numbers when copying text by | |
387 // marking them as hidden before the copy happens, then marking them | |
388 // visible on the next event loop turn. | |
389 var noCopyNodes = shadowRoot.getElementsByClassName("noCopy"); | |
390 for(var node in noCopyNodes) { | |
391 node.style.visibility = 'hidden'; | |
392 } | |
393 Timer.run(() { | |
Cutch
2015/05/07 22:58:17
This is Timer.run is a beautiful hack. Could we fa
rmacnak
2015/05/08 19:58:18
Extracted as makeCssClassUncopyable.
| |
394 for (var node in noCopyNodes) { | |
395 node.style.visibility = 'visible'; | |
396 } | |
397 }); | |
398 }); | |
385 | 399 |
386 annotationsCursor = 0; | 400 annotationsCursor = 0; |
387 | 401 |
388 int blankLineCount = 0; | 402 int blankLineCount = 0; |
389 for (int i = _startLine; i <= _endLine; i++) { | 403 for (int i = _startLine; i <= _endLine; i++) { |
390 var line = script.getLine(i); | 404 var line = script.getLine(i); |
391 if (line.isBlank) { | 405 if (line.isBlank) { |
392 // Try to introduce elipses if there are 4 or more contiguous | 406 // Try to introduce elipses if there are 4 or more contiguous |
393 // blank lines. | 407 // blank lines. |
394 blankLineCount++; | 408 blankLineCount++; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 e.append(lineNumberElement(line)); | 456 e.append(lineNumberElement(line)); |
443 e.append(lineSourceElement(line)); | 457 e.append(lineSourceElement(line)); |
444 return e; | 458 return e; |
445 } | 459 } |
446 | 460 |
447 Element lineBreakpointElement(ScriptLine line) { | 461 Element lineBreakpointElement(ScriptLine line) { |
448 var e = new DivElement(); | 462 var e = new DivElement(); |
449 var busy = false; | 463 var busy = false; |
450 if (line == null || !line.possibleBpt) { | 464 if (line == null || !line.possibleBpt) { |
451 e.classes.add("emptyBreakpoint"); | 465 e.classes.add("emptyBreakpoint"); |
466 e.classes.add('noCopy'); | |
452 e.text = nbsp; | 467 e.text = nbsp; |
453 return e; | 468 return e; |
454 } | 469 } |
455 e.text = 'B'; | 470 e.text = 'B'; |
456 update() { | 471 update() { |
457 if (busy) { | 472 if (busy) { |
458 e.classes.clear(); | 473 e.classes.clear(); |
459 e.classes.add("busyBreakpoint"); | 474 e.classes.add("busyBreakpoint"); |
475 e.classes.add('noCopy'); | |
460 } else { | 476 } else { |
461 if (line.breakpoints != null) { | 477 if (line.breakpoints != null) { |
462 if (line.breakpointResolved) { | 478 if (line.breakpointResolved) { |
463 e.classes.clear(); | 479 e.classes.clear(); |
464 e.classes.add("resolvedBreakpoint"); | 480 e.classes.add("resolvedBreakpoint"); |
481 e.classes.add('noCopy'); | |
465 } else { | 482 } else { |
466 e.classes.clear(); | 483 e.classes.clear(); |
467 e.classes.add("unresolvedBreakpoint"); | 484 e.classes.add("unresolvedBreakpoint"); |
485 e.classes.add('noCopy'); | |
468 } | 486 } |
469 } else { | 487 } else { |
470 e.classes.clear(); | 488 e.classes.clear(); |
471 e.classes.add("possibleBreakpoint"); | 489 e.classes.add("possibleBreakpoint"); |
Cutch
2015/05/07 22:58:17
every branch adds the class, why not move it to th
rmacnak
2015/05/08 19:58:18
Done.
| |
490 e.classes.add('noCopy'); | |
472 } | 491 } |
473 } | 492 } |
474 } | 493 } |
475 line.changes.listen((_) => update()); | 494 line.changes.listen((_) => update()); |
476 e.onClick.listen((event) { | 495 e.onClick.listen((event) { |
477 if (busy) { | 496 if (busy) { |
478 return; | 497 return; |
479 } | 498 } |
480 busy = true; | 499 busy = true; |
481 if (line.breakpoints == null) { | 500 if (line.breakpoints == null) { |
(...skipping 15 matching lines...) Expand all Loading... | |
497 } | 516 } |
498 update(); | 517 update(); |
499 }); | 518 }); |
500 update(); | 519 update(); |
501 return e; | 520 return e; |
502 } | 521 } |
503 | 522 |
504 Element lineNumberElement(ScriptLine line) { | 523 Element lineNumberElement(ScriptLine line) { |
505 var lineNumber = line == null ? "..." : line.line; | 524 var lineNumber = line == null ? "..." : line.line; |
506 var e = span("$nbsp$lineNumber$nbsp"); | 525 var e = span("$nbsp$lineNumber$nbsp"); |
526 e.classes.add('noCopy'); | |
507 | 527 |
508 if ((line == null) || (line.hits == null)) { | 528 if ((line == null) || (line.hits == null)) { |
509 hitsUnknown(e); | 529 hitsUnknown(e); |
510 } else if (line.hits == 0) { | 530 } else if (line.hits == 0) { |
511 hitsNotExecuted(e); | 531 hitsNotExecuted(e); |
512 } else { | 532 } else { |
513 hitsExecuted(e); | 533 hitsExecuted(e); |
514 } | 534 } |
515 | 535 |
516 return e; | 536 return e; |
(...skipping 29 matching lines...) Expand all Loading... | |
546 | 566 |
547 // TODO(rmacnak): Tolerate overlapping annotations. | 567 // TODO(rmacnak): Tolerate overlapping annotations. |
548 var annotation; | 568 var annotation; |
549 while ((annotation = nextAnnotationOnLine(line.line)) != null) { | 569 while ((annotation = nextAnnotationOnLine(line.line)) != null) { |
550 consumeUntil(annotation.columnStart); | 570 consumeUntil(annotation.columnStart); |
551 annotation.applyStyleTo(consumeUntil(annotation.columnStop)); | 571 annotation.applyStyleTo(consumeUntil(annotation.columnStop)); |
552 } | 572 } |
553 consumeUntil(line.text.length); | 573 consumeUntil(line.text.length); |
554 } | 574 } |
555 | 575 |
576 e.append(span('\n')); | |
Cutch
2015/05/07 22:58:17
<br> ?
rmacnak
2015/05/08 19:58:18
No, this is here so blank lines are included when
| |
577 | |
556 return e; | 578 return e; |
557 } | 579 } |
558 | 580 |
559 ScriptInsetElement.created() : super.created(); | 581 ScriptInsetElement.created() : super.created(); |
560 } | 582 } |
OLD | NEW |