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 'dart:math'; | 9 import 'dart:math'; |
10 import 'observatory_element.dart'; | 10 import 'observatory_element.dart'; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 379 } |
380 | 380 |
381 String get formattedSelfTicks { | 381 String get formattedSelfTicks { |
382 return Utils.formatPercent(selfTicks, sampleCount); | 382 return Utils.formatPercent(selfTicks, sampleCount); |
383 } | 383 } |
384 | 384 |
385 String get formattedTotalTicks { | 385 String get formattedTotalTicks { |
386 return Utils.formatPercent(totalTicks, sampleCount); | 386 return Utils.formatPercent(totalTicks, sampleCount); |
387 } | 387 } |
388 | 388 |
389 double _percent() { | 389 double _percent(bool self) { |
390 if (sampleCount == 0) { | 390 if (sampleCount == 0) { |
391 return 0.0; | 391 return 0.0; |
392 } | 392 } |
393 return totalTicks / sampleCount; | 393 if (self) { |
| 394 return selfTicks / sampleCount; |
| 395 } else { |
| 396 return totalTicks / sampleCount; |
| 397 } |
394 } | 398 } |
395 | 399 |
396 bool get isHot => _percent() > kHotThreshold; | 400 bool isHot(bool self) => _percent(self) > kHotThreshold; |
397 bool get isMedium => _percent() > kMediumThreshold; | 401 bool isMedium(bool self) => _percent(self) > kMediumThreshold; |
398 } | 402 } |
399 | 403 |
400 /// Box with script source code in it. | 404 /// Box with script source code in it. |
401 @CustomTag('script-inset') | 405 @CustomTag('script-inset') |
402 class ScriptInsetElement extends ObservatoryElement { | 406 class ScriptInsetElement extends ObservatoryElement { |
403 @published Script script; | 407 @published Script script; |
404 @published int startPos; | 408 @published int startPos; |
405 @published int endPos; | 409 @published int endPos; |
406 | 410 |
407 /// Set the height to make the script inset scroll. Otherwise it | 411 /// Set the height to make the script inset scroll. Otherwise it |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 e.text = nbsp; | 1137 e.text = nbsp; |
1134 return e; | 1138 return e; |
1135 } | 1139 } |
1136 | 1140 |
1137 if (self) { | 1141 if (self) { |
1138 e.text = lineProfile.formattedSelfTicks; | 1142 e.text = lineProfile.formattedSelfTicks; |
1139 } else { | 1143 } else { |
1140 e.text = lineProfile.formattedTotalTicks; | 1144 e.text = lineProfile.formattedTotalTicks; |
1141 } | 1145 } |
1142 | 1146 |
1143 if (lineProfile.isHot) { | 1147 if (lineProfile.isHot(self)) { |
1144 e.classes.add('hotProfile'); | 1148 e.classes.add('hotProfile'); |
1145 } else if (lineProfile.isMedium) { | 1149 } else if (lineProfile.isMedium(self)) { |
1146 e.classes.add('mediumProfile'); | 1150 e.classes.add('mediumProfile'); |
1147 } else { | 1151 } else { |
1148 e.classes.add('coldProfile'); | 1152 e.classes.add('coldProfile'); |
1149 } | 1153 } |
1150 | 1154 |
1151 return e; | 1155 return e; |
1152 } | 1156 } |
1153 | 1157 |
1154 Element lineBreakpointElement(ScriptLine line) { | 1158 Element lineBreakpointElement(ScriptLine line) { |
1155 var e = new DivElement(); | 1159 var e = new DivElement(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 class SourceInsetElement extends PolymerElement { | 1366 class SourceInsetElement extends PolymerElement { |
1363 SourceInsetElement.created() : super.created(); | 1367 SourceInsetElement.created() : super.created(); |
1364 | 1368 |
1365 @published SourceLocation location; | 1369 @published SourceLocation location; |
1366 @published String height = null; | 1370 @published String height = null; |
1367 @published int currentPos; | 1371 @published int currentPos; |
1368 @published bool inDebuggerContext = false; | 1372 @published bool inDebuggerContext = false; |
1369 @published ObservableList variables; | 1373 @published ObservableList variables; |
1370 @published Element scroller; | 1374 @published Element scroller; |
1371 } | 1375 } |
OLD | NEW |