| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 heap_map_element; | 5 library heap_map_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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 void _addClass(int classId, String name, Iterable<int> color) { | 87 void _addClass(int classId, String name, Iterable<int> color) { |
| 88 _classIdToName[classId] = name.split('@')[0]; | 88 _classIdToName[classId] = name.split('@')[0]; |
| 89 _classIdToColor[classId] = color; | 89 _classIdToColor[classId] = color; |
| 90 _colorToClassId[_packColor(color)] = classId; | 90 _colorToClassId[_packColor(color)] = classId; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void _updateClassList(classList, int freeClassId) { | 93 void _updateClassList(classList, int freeClassId) { |
| 94 for (var member in classList['members']) { | 94 for (var member in classList['members']) { |
| 95 if (member['type'] != '@Class') { | 95 if (member is! Class) { |
| 96 Logger.root.info('$member'); | 96 Logger.root.info('$member'); |
| 97 continue; | 97 continue; |
| 98 } | 98 } |
| 99 var classId = int.parse(member['id'].split('/').last); | 99 var classId = int.parse(member.id.split('/').last); |
| 100 var color = _classIdToRGBA(classId); | 100 var color = _classIdToRGBA(classId); |
| 101 _addClass(classId, member['name'], color); | 101 _addClass(classId, member.name, color); |
| 102 } | 102 } |
| 103 _addClass(freeClassId, 'Free', _freeColor); | 103 _addClass(freeClassId, 'Free', _freeColor); |
| 104 _addClass(0, '', _pageSeparationColor); | 104 _addClass(0, '', _pageSeparationColor); |
| 105 } | 105 } |
| 106 | 106 |
| 107 Iterable<int> _classIdToRGBA(int classId) { | 107 Iterable<int> _classIdToRGBA(int classId) { |
| 108 // TODO(koda): Pick random hue, but fixed saturation and value. | 108 // TODO(koda): Pick random hue, but fixed saturation and value. |
| 109 var rng = new Random(classId); | 109 var rng = new Random(classId); |
| 110 return [rng.nextInt(128), rng.nextInt(128), rng.nextInt(128), 255]; | 110 return [rng.nextInt(128), rng.nextInt(128), rng.nextInt(128), 255]; |
| 111 } | 111 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 141 pageOffset * fragmentation['unit_size_bytes'], | 141 pageOffset * fragmentation['unit_size_bytes'], |
| 142 size * fragmentation['unit_size_bytes']); | 142 size * fragmentation['unit_size_bytes']); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void _handleMouseMove(MouseEvent event) { | 145 void _handleMouseMove(MouseEvent event) { |
| 146 var info = _objectAt(event.offset); | 146 var info = _objectAt(event.offset); |
| 147 var addressString = '${info.size}B @ 0x${info.address.toRadixString(16)}'; | 147 var addressString = '${info.size}B @ 0x${info.address.toRadixString(16)}'; |
| 148 var className = _classNameAt(event.offset); | 148 var className = _classNameAt(event.offset); |
| 149 status = (className == '') ? '-' : '$className $addressString'; | 149 status = (className == '') ? '-' : '$className $addressString'; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void _handleClick(MouseEvent event) { | 152 void _handleClick(MouseEvent event) { |
| 153 var address = _objectAt(event.offset).address.toRadixString(16); | 153 var address = _objectAt(event.offset).address.toRadixString(16); |
| 154 window.location.hash = "/${fragmentation.isolate.link}/address/$address"; | 154 window.location.hash = "/${fragmentation.isolate.link}/address/$address"; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void _updateFragmentationData() { | 157 void _updateFragmentationData() { |
| 158 if (fragmentation == null || _fragmentationCanvas == null) { | 158 if (fragmentation == null || _fragmentationCanvas == null) { |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 _updateClassList( | 161 _updateClassList( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 }).whenComplete(done); | 218 }).whenComplete(done); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void fragmentationChanged(oldValue) { | 221 void fragmentationChanged(oldValue) { |
| 222 // Async, in case enteredView has not yet run (observed in JS version). | 222 // Async, in case enteredView has not yet run (observed in JS version). |
| 223 new Future(() { | 223 new Future(() { |
| 224 _updateFragmentationData(); | 224 _updateFragmentationData(); |
| 225 }); | 225 }); |
| 226 } | 226 } |
| 227 } | 227 } |
| OLD | NEW |