Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: runtime/observatory/lib/src/elements/script_inset.dart

Issue 849263002: Introduce elipses when there are long stretches of blank lines in observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/script_inset.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:html'; 7 import 'dart:html';
8 import 'observatory_element.dart'; 8 import 'observatory_element.dart';
9 import 'package:observatory/service.dart'; 9 import 'package:observatory/service.dart';
10 import 'package:polymer/polymer.dart'; 10 import 'package:polymer/polymer.dart';
11 11
12 /// Box with script source code in it. 12 /// Box with script source code in it.
13 @CustomTag('script-inset') 13 @CustomTag('script-inset')
14 class ScriptInsetElement extends ObservatoryElement { 14 class ScriptInsetElement extends ObservatoryElement {
15 @published Script script; 15 @published Script script;
16 16
17 /// Set the height to make the script inset scroll. Otherwise it 17 /// Set the height to make the script inset scroll. Otherwise it
18 /// will show from startPos to endPos. 18 /// will show from startPos to endPos.
19 @published String height = null; 19 @published String height = null;
20 20
21 @published int currentPos; 21 @published int currentPos;
22 @published int startPos; 22 @published int startPos;
23 @published int endPos; 23 @published int endPos;
24 24
25 @observable int currentLine; 25 @observable int currentLine;
26 @observable int startLine; 26 @observable int startLine;
27 @observable int endLine; 27 @observable int endLine;
28 @observable bool linesReady = false; 28 @observable bool linesReady = false;
29 29
30 @observable List<ScriptLine> lines = toObservable([]); 30 // Contents are either ScriptLine or ScriptElipsis.
31 @observable List lines = toObservable([]);
31 32
32 String makeLineId(int line) { 33 String makeLineId(int line) {
33 return 'line-$line'; 34 return 'line-$line';
34 } 35 }
35 36
36 MutationObserver _observer; 37 MutationObserver _observer;
37 38
38 void _scrollToCurrentPos() { 39 void _scrollToCurrentPos() {
39 var line = shadowRoot.querySelector('#line-$currentLine'); 40 var line = shadowRoot.querySelector('#line-$currentLine');
40 if (line != null) { 41 if (line != null) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ? script.tokenToLine(startPos) 106 ? script.tokenToLine(startPos)
106 : 1); 107 : 1);
107 currentLine = (currentPos != null 108 currentLine = (currentPos != null
108 ? script.tokenToLine(currentPos) 109 ? script.tokenToLine(currentPos)
109 : null); 110 : null);
110 endLine = (endPos != null 111 endLine = (endPos != null
111 ? script.tokenToLine(endPos) 112 ? script.tokenToLine(endPos)
112 : script.lines.length); 113 : script.lines.length);
113 114
114 lines.clear(); 115 lines.clear();
116 int blankLineCount = 0;
115 for (int i = (startLine - 1); i <= (endLine - 1); i++) { 117 for (int i = (startLine - 1); i <= (endLine - 1); i++) {
116 lines.add(script.lines[i]); 118 if (script.lines[i].isBlank) {
119 // Try to introduce elipses if there are 4 or more contiguous blank line s.
120 blankLineCount++;
121 } else {
122 if (blankLineCount > 0) {
123 int firstBlank = i - blankLineCount;
124 int lastBlank = i - 1;
125 if (blankLineCount < 4) {
126 // Too few blank lines for an elipsis.
127 for (int j = firstBlank; j <= lastBlank; j++) {
128 lines.add(script.lines[j]);
129 }
130 } else {
131 // Add an elipsis for the skipped region.
132 lines.add(script.lines[firstBlank]);
133 lines.add(null);
134 lines.add(script.lines[lastBlank]);
135 }
136 blankLineCount = 0;
137 }
138 lines.add(script.lines[i]);
139 }
117 } 140 }
118 linesReady = true; 141 linesReady = true;
119 } 142 }
120 143
121 ScriptInsetElement.created() : super.created(); 144 ScriptInsetElement.created() : super.created();
122 } 145 }
123 146
124 @CustomTag('breakpoint-toggle') 147 @CustomTag('breakpoint-toggle')
125 class BreakpointToggleElement extends ObservatoryElement { 148 class BreakpointToggleElement extends ObservatoryElement {
126 @published ScriptLine line; 149 @published ScriptLine line;
(...skipping 12 matching lines...) Expand all
139 } else { 162 } else {
140 // Existing breakpoint. Remove it. 163 // Existing breakpoint. Remove it.
141 line.script.isolate.clearBreakpoint(line.bpt).then((_) { 164 line.script.isolate.clearBreakpoint(line.bpt).then((_) {
142 busy = false; 165 busy = false;
143 }); 166 });
144 } 167 }
145 } 168 }
146 169
147 BreakpointToggleElement.created() : super.created(); 170 BreakpointToggleElement.created() : super.created();
148 } 171 }
OLDNEW
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/script_inset.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698