OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // require: array_data_model.js | 5 // require: array_data_model.js |
6 // require: list_selection_model.js | 6 // require: list_selection_model.js |
7 // require: list_selection_controller.js | 7 // require: list_selection_controller.js |
8 // require: list_item.js | 8 // require: list_item.js |
9 | 9 |
10 /** | 10 /** |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 var dataModel = this.dataModel; | 1041 var dataModel = this.dataModel; |
1042 if (!dataModel) { | 1042 if (!dataModel) { |
1043 this.cachedItems_ = {}; | 1043 this.cachedItems_ = {}; |
1044 this.firstIndex_ = 0; | 1044 this.firstIndex_ = 0; |
1045 this.lastIndex_ = 0; | 1045 this.lastIndex_ = 0; |
1046 this.remainingSpace_ = true; | 1046 this.remainingSpace_ = true; |
1047 this.mergeItems(0, 0, {}, {}); | 1047 this.mergeItems(0, 0, {}, {}); |
1048 return; | 1048 return; |
1049 } | 1049 } |
1050 | 1050 |
| 1051 // Save the previous positions before any manipulation of elements. |
| 1052 var scrollTop = this.scrollTop; |
| 1053 var clientHeight = this.clientHeight; |
| 1054 |
1051 // Store all the item sizes into the cache in advance, to prevent | 1055 // Store all the item sizes into the cache in advance, to prevent |
1052 // interleave measuring with mutating dom. | 1056 // interleave measuring with mutating dom. |
1053 if (!this.fixedHeight_) | 1057 if (!this.fixedHeight_) |
1054 this.ensureAllItemSizesInCache(); | 1058 this.ensureAllItemSizesInCache(); |
1055 | 1059 |
1056 // We cache the list items since creating the DOM nodes is the most | 1060 // We cache the list items since creating the DOM nodes is the most |
1057 // expensive part of redrawing. | 1061 // expensive part of redrawing. |
1058 var cachedItems = this.cachedItems_ || {}; | 1062 var cachedItems = this.cachedItems_ || {}; |
1059 var newCachedItems = {}; | 1063 var newCachedItems = {}; |
1060 | 1064 |
1061 var autoExpands = this.autoExpands_; | 1065 var autoExpands = this.autoExpands_; |
1062 var scrollTop = this.scrollTop; | |
1063 var clientHeight = this.clientHeight; | |
1064 | 1066 |
1065 var itemsInViewPort = this.getItemsInViewPort(scrollTop, clientHeight); | 1067 var itemsInViewPort = this.getItemsInViewPort(scrollTop, clientHeight); |
1066 // Draws the hidden rows just above/below the viewport to prevent | 1068 // Draws the hidden rows just above/below the viewport to prevent |
1067 // flashing in scroll. | 1069 // flashing in scroll. |
1068 var firstIndex = Math.max(0, itemsInViewPort.first - 1); | 1070 var firstIndex = Math.max(0, itemsInViewPort.first - 1); |
1069 var lastIndex = Math.min(itemsInViewPort.last + 1, dataModel.length); | 1071 var lastIndex = Math.min(itemsInViewPort.last + 1, dataModel.length); |
1070 | 1072 |
1071 var beforeFillerHeight = | 1073 var beforeFillerHeight = |
1072 this.autoExpands ? 0 : this.getItemTop(firstIndex); | 1074 this.autoExpands ? 0 : this.getItemTop(firstIndex); |
1073 var afterFillerHeight = | 1075 var afterFillerHeight = |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 * because list items can contain controls that can be focused, and for some | 1176 * because list items can contain controls that can be focused, and for some |
1175 * purposes (e.g., styling), the list can still be conceptually focused at | 1177 * purposes (e.g., styling), the list can still be conceptually focused at |
1176 * that point even though it doesn't actually have the page focus. | 1178 * that point even though it doesn't actually have the page focus. |
1177 */ | 1179 */ |
1178 cr.defineProperty(List, 'hasElementFocus', cr.PropertyKind.BOOL_ATTR); | 1180 cr.defineProperty(List, 'hasElementFocus', cr.PropertyKind.BOOL_ATTR); |
1179 | 1181 |
1180 return { | 1182 return { |
1181 List: List | 1183 List: List |
1182 } | 1184 } |
1183 }); | 1185 }); |
OLD | NEW |