| OLD | NEW |
| (Empty) | |
| 1 part of vmstats; |
| 2 |
| 3 class IsolateList { |
| 4 UListElement _listArea; |
| 5 |
| 6 final String CSS_VISIBLE = 'isolate_details'; |
| 7 final String CSS_HIDDEN = 'isolate_details_hidden'; |
| 8 |
| 9 IsolateList(UListElement area) { |
| 10 _listArea = area; |
| 11 } |
| 12 |
| 13 void updateList(IsolateListModel model) { |
| 14 var detailsClass = CSS_HIDDEN; |
| 15 if (_listArea.children.length > 0) { |
| 16 // Preserve visibility state. |
| 17 LIElement listItem = _listArea.children.first; |
| 18 DivElement item = listItem.children.first; |
| 19 if (item.classes.length > 0 && item.classes.first == CSS_VISIBLE) { |
| 20 detailsClass = CSS_VISIBLE; |
| 21 } |
| 22 _listArea.children.clear(); |
| 23 } |
| 24 Iterator<Isolate> iterator = model.iterator; |
| 25 while (iterator.moveNext()) { |
| 26 Isolate isolate = iterator.current; |
| 27 LIElement listItem = new LIElement(); |
| 28 listItem.classes.add('isolate_list'); |
| 29 listItem.text = isolate.name |
| 30 .replaceAll('\$', ': ') // Split script from isolate, and ... |
| 31 .replaceAll('-', ' '); // ... split name from port number. |
| 32 |
| 33 // Add isolate details as hidden children. |
| 34 DivElement details = new DivElement(); |
| 35 isolateDetails(isolate, details); |
| 36 details.classes.add(detailsClass); |
| 37 listItem.children.add(details); |
| 38 listItem.onClick.listen((e) => toggle(details)); |
| 39 |
| 40 _listArea.children.add(listItem); |
| 41 } |
| 42 } |
| 43 |
| 44 void isolateDetails(Isolate isolate, DivElement parent) { |
| 45 DivElement newSpace = new DivElement(); |
| 46 newSpace.text = 'New space: ${isolate.newSpace.used}K'; |
| 47 parent.children.add(newSpace); |
| 48 DivElement oldSpace = new DivElement(); |
| 49 oldSpace.text = 'Old space: ${isolate.oldSpace.used}K'; |
| 50 parent.children.add(oldSpace); |
| 51 DivElement stack = new DivElement(); |
| 52 stack.text = 'Stack limit: ${(isolate.stackLimit / 1000000).round()}M'; |
| 53 parent.children.add(stack); |
| 54 } |
| 55 |
| 56 void toggle(DivElement e) { |
| 57 e.classes.toggle(CSS_VISIBLE); |
| 58 e.classes.toggle(CSS_HIDDEN); |
| 59 } |
| 60 } |
| OLD | NEW |