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

Unified Diff: ui/webui/resources/js/cr/ui/list.js

Issue 2745593003: Use actual client width of list excluding scroll bar for adjusting column widths.
Patch Set: rebase Created 3 years, 9 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
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/table.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/cr/ui/list.js
diff --git a/ui/webui/resources/js/cr/ui/list.js b/ui/webui/resources/js/cr/ui/list.js
index 99196c6a1a37d87cbf73f0a5afdc2d45ce991418..e3015d5fcc71466f47120931c90de02f9d8b4781 100644
--- a/ui/webui/resources/js/cr/ui/list.js
+++ b/ui/webui/resources/js/cr/ui/list.js
@@ -325,6 +325,7 @@ cr.define('cr.ui', function() {
this.addEventListener('blur', this.handleElementBlur_, true);
this.addEventListener('scroll', this.handleScroll.bind(this));
this.setAttribute('role', 'list');
+ this.onClientWidthChangedCallback_ = null;
// Make list focusable
if (!this.hasAttribute('tabindex'))
@@ -1058,6 +1059,13 @@ cr.define('cr.ui', function() {
return height;
},
+ setClientWidthChangedCallback: function(callback) {
+ this.onClientWidthChangedCallback_ = callback;
+ },
+
+ // Memorize the last clientWidth to trigger onClientWidthChanged callback.
+ oldClientWidth: -1,
+
/**
* Redraws the viewport.
*/
@@ -1072,6 +1080,11 @@ cr.define('cr.ui', function() {
this.lastIndex_ = 0;
this.remainingSpace_ = this.clientHeight != 0;
this.mergeItems(0, 0);
+ if (this.clientWidth != this.oldClientWidth &&
+ this.onClientWidthChangedCallback_) {
+ this.oldClientWidth = this.clientWidth;
+ this.onClientWidthChangedCallback_(this.clientWidth);
+ }
return;
}
@@ -1116,6 +1129,11 @@ cr.define('cr.ui', function() {
}
this.mergeItems(firstIndex, lastIndex);
+ if (this.clientWidth != this.oldClientWidth &&
+ this.onClientWidthChangedCallback_) {
+ this.oldClientWidth = this.clientWidth;
+ this.onClientWidthChangedCallback_(this.clientWidth);
+ }
if (!this.pinnedItem_ && this.cachedItems_[leadIndex] &&
this.cachedItems_[leadIndex].parentNode == this) {
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698