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

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

Issue 2237383004: Fixed Observatory class-view crash (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:html'; 6 import 'dart:html';
7 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 7 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
8 import 'package:observatory/src/elements/helpers/tag.dart'; 8 import 'package:observatory/src/elements/helpers/tag.dart';
9 9
10 typedef HtmlElement VirtualCollectionCreateCallback(); 10 typedef HtmlElement VirtualCollectionCreateCallback();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 /// L = l + 2 * l / _preload 99 /// L = l + 2 * l / _preload
100 /// l = L * _preload / (_preload + 2) 100 /// l = L * _preload / (_preload + 2)
101 /// 101 ///
102 /// tail = l / _preload = L * 1 / (_preload + 2) = L * _inverse_preload 102 /// tail = l / _preload = L * 1 / (_preload + 2) = L * _inverse_preload
103 static const double _inverse_preload = 1 / (_preload + 2); 103 static const double _inverse_preload = 1 / (_preload + 2);
104 104
105 void render() { 105 void render() {
106 _top = (scrollTop / _itemHeight).floor(); 106 _top = (scrollTop / _itemHeight).floor();
107 107
108 _scroller.style.height = '${_itemHeight*(_items.length)}px'; 108 _scroller.style.height = '${_itemHeight*(_items.length)}px';
109 _shifter.style.top = '${_itemHeight*_top}px';
110 final tail_length = (_height / _itemHeight / _preload).ceil(); 109 final tail_length = (_height / _itemHeight / _preload).ceil();
110 _shifter.style.top = '${_itemHeight*(_top - tail_length)}px';
111 final length = tail_length * 2 + tail_length * _preload; 111 final length = tail_length * 2 + tail_length * _preload;
112 112
113 if (_shifter.children.length < length) { 113 if (_shifter.children.length < length) {
114 while (_shifter.children.length != length) { 114 while (_shifter.children.length != length) {
115 var e = _create(); 115 var e = _create();
116 e..style.display = 'hidden'; 116 e..style.display = 'hidden';
117 _shifter.children.add(e); 117 _shifter.children.add(e);
118 } 118 }
119 _shifter.style.height = '${_itemHeight*length}px';
120 children = [ 119 children = [
121 _scroller 120 _scroller
122 ..children = [_shifter] 121 ..children = [_shifter]
123 ]; 122 ];
124 } 123 }
125 124
126 int i = _top - tail_length; 125 int i = _top - tail_length;
127 for (final HtmlElement e in _shifter.children) { 126 for (final HtmlElement e in _shifter.children) {
128 if (0 <= i && i < _items.length) { 127 if (0 <= i && i < _items.length) {
129 e..style.display = null; 128 e..style.display = null;
(...skipping 15 matching lines...) Expand all
145 144
146 void _onScroll(_) { 145 void _onScroll(_) {
147 if(_r.isDirty) return; 146 if(_r.isDirty) return;
148 if ((scrollTop - _top * _itemHeight).abs() >= 147 if ((scrollTop - _top * _itemHeight).abs() >=
149 _shifter.children.length * _inverse_preload * _itemHeight) { 148 _shifter.children.length * _inverse_preload * _itemHeight) {
150 _r.dirty(); 149 _r.dirty();
151 } 150 }
152 } 151 }
153 152
154 void _onResize(_) { 153 void _onResize(_) {
155 _height = getBoundingClientRect().height; 154 final newHeight = getBoundingClientRect().height;
156 _r.dirty(); 155 if (newHeight > _height) {
156 _height = newHeight;
157 _r.dirty();
158 }
157 } 159 }
158 } 160 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/class_view.dart ('k') | runtime/observatory/lib/src/elements/css/shared.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698