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

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

Issue 2273993002: Converted Observatory cpu-profile-table element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/containers/virtual_collection.dart
diff --git a/runtime/observatory/lib/src/elements/containers/virtual_collection.dart b/runtime/observatory/lib/src/elements/containers/virtual_collection.dart
index b6f91b96661e63c525cdf4136b9ee12abbeaf86c..d0973e2bca4be73a9cc3519d61e772724fa9f053 100644
--- a/runtime/observatory/lib/src/elements/containers/virtual_collection.dart
+++ b/runtime/observatory/lib/src/elements/containers/virtual_collection.dart
@@ -24,6 +24,7 @@ class VirtualCollectionElement extends HtmlElement implements Renderable {
VirtualCollectionCreateCallback _createHeader;
VirtualCollectionUpdateCallback _update;
double _itemHeight;
+ double _headerHeight = 0.0;
int _top;
double _height;
List _items;
@@ -106,6 +107,13 @@ class VirtualCollectionElement extends HtmlElement implements Renderable {
/// tail = l / _preload = L * 1 / (_preload + 2) = L * _inverse_preload
static const double _inverse_preload = 1 / (_preload + 2);
+ var _takeIntoView;
+
+ void takeIntoView(item) {
+ _takeIntoView = item;
+ _r.dirty();
+ }
+
void render() {
if (children.isEmpty) {
children = [
@@ -118,14 +126,26 @@ class VirtualCollectionElement extends HtmlElement implements Renderable {
if (_createHeader != null) {
_header.children = [_createHeader()];
_scroller.children.insert(0, _header);
+ _headerHeight = _header.children[0].getBoundingClientRect().height;
}
_itemHeight = _shifter.children[0].getBoundingClientRect().height;
_height = getBoundingClientRect().height;
}
+
+ if (_takeIntoView != null) {
+ final index = items.indexOf(_takeIntoView);
+ if (index >= 0) {
+ final minScrollTop = _itemHeight * (index + 1) - _height;
+ final maxScrollTop = _itemHeight * index;
+ scrollTop = ((maxScrollTop - minScrollTop) / 2 + minScrollTop).floor();
+ }
+ _takeIntoView = null;
+ }
+
final top = (scrollTop / _itemHeight).floor();
_header.style.top = '${scrollTop}px';
- _scroller.style.height = '${_itemHeight*(_items.length)}px';
+ _scroller.style.height = '${_itemHeight*(_items.length)+_headerHeight}px';
final tail_length = (_height / _itemHeight / _preload).ceil();
final length = tail_length * 2 + tail_length * _preload;
« no previous file with comments | « runtime/observatory/lib/src/cpu_profile/cpu_profile.dart ('k') | runtime/observatory/lib/src/elements/cpu_profile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698