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

Unified Diff: chrome/browser/resources/shared/js/cr/ui/list_selection_model.js

Issue 8608007: cr/ui/list.js: Support rows with variable heights. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Omit the custom lead item height Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/list.js ('k') | chrome/browser/resources/shared/js/cr/ui/table.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
diff --git a/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js b/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
index 8c16d577f5f2f9d5105df1511ebdbad9fabec353..a0e5b983681db836cec3d83bccb4b9218f446856 100644
--- a/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
+++ b/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
@@ -143,12 +143,7 @@ cr.define('cr.ui', function() {
this.beginChange();
- // Changing back?
- if (index in this.changedIndexes_ && this.changedIndexes_[index] == !b) {
- delete this.changedIndexes_[index];
- } else {
- this.changedIndexes_[index] = b;
- }
+ this.changedIndexes_[index] = b;
// End change dispatches an event which in turn may update the view.
this.endChange();
@@ -182,6 +177,20 @@ cr.define('cr.ui', function() {
endChange: function() {
this.changeCount_--;
if (!this.changeCount_) {
+ // Calls delayed |dispatchPropertyChange|s, only when |leadIndex| or
+ // |anchorIndex| has been actually changed in the batch.
+ if (this.oldLeadIndex_ != null) {
+ cr.dispatchPropertyChange(this, 'leadIndex',
+ this.leadIndex_, this.oldLeadIndex_);
+ this.oldLeadIndex_ = null;
+ }
+
+ if (this.oldAnchorIndex_ != null) {
+ cr.dispatchPropertyChange(this, 'anchorIndex',
+ this.anchorIndex_, this.oldAnchorIndex_);
+ this.oldAnchorIndex_ = null;
+ }
+
var indexes = Object.keys(this.changedIndexes_);
if (indexes.length) {
var e = new Event('change');
@@ -198,6 +207,7 @@ cr.define('cr.ui', function() {
},
leadIndex_: -1,
+ oldLeadIndex_: null,
/**
* The leadIndex is used with multiple selection and it is the index that
@@ -212,11 +222,19 @@ cr.define('cr.ui', function() {
if (li != this.leadIndex_) {
var oldLeadIndex = this.leadIndex_;
this.leadIndex_ = li;
- cr.dispatchPropertyChange(this, 'leadIndex', li, oldLeadIndex);
+
+ // Delays the call of dispatchPropertyChange if batch is running.
+ if (this.changeCount_) {
+ if (this.oldLeadIndex_ == null)
+ this.oldLeadIndex_ = oldLeadIndex;
+ } else {
+ cr.dispatchPropertyChange(this, 'leadIndex', li, oldLeadIndex);
+ }
}
},
anchorIndex_: -1,
+ oldAnchorIndex_: null,
/**
* The anchorIndex is used with multiple selection.
@@ -230,7 +248,14 @@ cr.define('cr.ui', function() {
if (ai != this.anchorIndex_) {
var oldAnchorIndex = this.anchorIndex_;
this.anchorIndex_ = ai;
- cr.dispatchPropertyChange(this, 'anchorIndex', ai, oldAnchorIndex);
+
+ // Delays the call of dispatchPropertyChange if batch is running.
+ if (this.changeCount_) {
+ if (this.oldAnchorIndex_ == null)
+ this.oldAnchorIndex_ = oldAnchorIndex;
+ } else {
+ cr.dispatchPropertyChange(this, 'anchorIndex', ai, oldAnchorIndex);
+ }
}
},
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/list.js ('k') | chrome/browser/resources/shared/js/cr/ui/table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698