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

Side by Side Diff: chrome/browser/resources/md_history/history_item.js

Issue 2318643003: MD History: truncate title to 300 chars in C++ instead of JS (Closed)
Patch Set: !android in tests as well Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 cr.define('md_history', function() { 5 cr.define('md_history', function() {
6 var HistoryItem = Polymer({ 6 var HistoryItem = Polymer({
7 is: 'history-item', 7 is: 'history-item',
8 8
9 properties: { 9 properties: {
10 // Underlying HistoryEntry data for this item. Contains read-only fields 10 // Underlying HistoryEntry data for this item. Contains read-only fields
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 * @private 144 * @private
145 */ 145 */
146 cardTitle_: function(numberOfItems, historyDate, search) { 146 cardTitle_: function(numberOfItems, historyDate, search) {
147 if (!search) 147 if (!search)
148 return this.item.dateRelativeDay; 148 return this.item.dateRelativeDay;
149 149
150 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; 150 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
151 return loadTimeData.getStringF('foundSearchResults', numberOfItems, 151 return loadTimeData.getStringF('foundSearchResults', numberOfItems,
152 loadTimeData.getString(resultId), search); 152 loadTimeData.getString(resultId), search);
153 }, 153 },
154
155 /**
156 * Crop long item titles to reduce their effect on layout performance. See
157 * crbug.com/621347.
158 * @param {string} title
159 * @return {string}
160 */
161 cropItemTitle_: function(title) {
162 return (title.length > TITLE_MAX_LENGTH) ?
163 title.substr(0, TITLE_MAX_LENGTH) :
164 title;
165 }
166 }); 154 });
167 155
168 /** 156 /**
169 * Check whether the time difference between the given history item and the 157 * Check whether the time difference between the given history item and the
170 * next one is large enough for a spacer to be required. 158 * next one is large enough for a spacer to be required.
171 * @param {Array<HistoryEntry>} visits 159 * @param {Array<HistoryEntry>} visits
172 * @param {number} currentIndex 160 * @param {number} currentIndex
173 * @param {string} searchedTerm 161 * @param {string} searchedTerm
174 * @return {boolean} Whether or not time gap separator is required. 162 * @return {boolean} Whether or not time gap separator is required.
175 * @private 163 * @private
176 */ 164 */
177 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { 165 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) {
178 if (currentIndex >= visits.length - 1 || visits.length == 0) 166 if (currentIndex >= visits.length - 1 || visits.length == 0)
179 return false; 167 return false;
180 168
181 var currentItem = visits[currentIndex]; 169 var currentItem = visits[currentIndex];
182 var nextItem = visits[currentIndex + 1]; 170 var nextItem = visits[currentIndex + 1];
183 171
184 if (searchedTerm) 172 if (searchedTerm)
185 return currentItem.dateShort != nextItem.dateShort; 173 return currentItem.dateShort != nextItem.dateShort;
186 174
187 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && 175 return currentItem.time - nextItem.time > BROWSING_GAP_TIME &&
188 currentItem.dateRelativeDay == nextItem.dateRelativeDay; 176 currentItem.dateRelativeDay == nextItem.dateRelativeDay;
189 }; 177 };
190 178
191 return { HistoryItem: HistoryItem }; 179 return { HistoryItem: HistoryItem };
192 }); 180 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698