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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js

Issue 2474143002: DevTools: Rename prefix to query in the context of autocomplete (Closed)
Patch Set: merge Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 /** 263 /**
264 * @param {!Event} event 264 * @param {!Event} event
265 */ 265 */
266 _onItemMouseDown(event) { 266 _onItemMouseDown(event) {
267 this._selectedElement = event.currentTarget; 267 this._selectedElement = event.currentTarget;
268 this.acceptSuggestion(); 268 this.acceptSuggestion();
269 event.consume(true); 269 event.consume(true);
270 } 270 }
271 271
272 /** 272 /**
273 * @param {string} prefix 273 * @param {string} query
274 * @param {string} text 274 * @param {string} text
275 * @param {string=} className 275 * @param {string=} className
276 * @return {!Element} 276 * @return {!Element}
277 */ 277 */
278 _createItemElement(prefix, text, className) { 278 _createItemElement(query, text, className) {
279 var element = createElementWithClass('div', 'suggest-box-content-item source -code ' + (className || '')); 279 var element = createElementWithClass('div', 'suggest-box-content-item source -code ' + (className || ''));
280 element.tabIndex = -1; 280 element.tabIndex = -1;
281 if (prefix && prefix.length && !text.indexOf(prefix)) { 281 if (query && query.length && !text.indexOf(query)) {
282 element.createChild('span', 'prefix').textContent = prefix; 282 element.createChild('span', 'query').textContent = query;
283 element.createChild('span', 'suffix').textContent = text.substring(prefix. length).trimEnd(50); 283 element.createChild('span').textContent = text.substring(query.length).tri mEnd(50);
284 } else { 284 } else {
285 element.createChild('span', 'suffix').textContent = text.trimEnd(50); 285 element.createChild('span').textContent = text.trimEnd(50);
286 } 286 }
287 element.__fullValue = text; 287 element.__fullValue = text;
288 element.createChild('span', 'spacer'); 288 element.createChild('span', 'spacer');
289 element.addEventListener('mousedown', this._onItemMouseDown.bind(this), fals e); 289 element.addEventListener('mousedown', this._onItemMouseDown.bind(this), fals e);
290 return element; 290 return element;
291 } 291 }
292 292
293 /** 293 /**
294 * @param {!WebInspector.SuggestBox.Suggestions} items 294 * @param {!WebInspector.SuggestBox.Suggestions} items
295 * @param {string} userEnteredText 295 * @param {string} userEnteredText
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 * @param {string} userEnteredText 367 * @param {string} userEnteredText
368 * @return {boolean} 368 * @return {boolean}
369 */ 369 */
370 _canShowBox(completions, canShowForSingleItem, userEnteredText) { 370 _canShowBox(completions, canShowForSingleItem, userEnteredText) {
371 if (!completions || !completions.length) 371 if (!completions || !completions.length)
372 return false; 372 return false;
373 373
374 if (completions.length > 1) 374 if (completions.length > 1)
375 return true; 375 return true;
376 376
377 // Do not show a single suggestion if it is the same as user-entered prefix, even if allowed to show single-item suggest boxes. 377 // Do not show a single suggestion if it is the same as user-entered query, even if allowed to show single-item suggest boxes.
378 return canShowForSingleItem && completions[0].title !== userEnteredText; 378 return canShowForSingleItem && completions[0].title !== userEnteredText;
379 } 379 }
380 380
381 _ensureRowCountPerViewport() { 381 _ensureRowCountPerViewport() {
382 if (this._rowCountPerViewport) 382 if (this._rowCountPerViewport)
383 return; 383 return;
384 if (!this._items.length) 384 if (!this._items.length)
385 return; 385 return;
386 386
387 this._rowCountPerViewport = Math.floor(this._element.getBoundingClientRect() .height / this._rowHeight); 387 this._rowCountPerViewport = Math.floor(this._element.getBoundingClientRect() .height / this._rowHeight);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 this.element.style.left = containerBox.x + 'px'; 568 this.element.style.left = containerBox.x + 'px';
569 this.element.style.top = containerBox.y + 'px'; 569 this.element.style.top = containerBox.y + 'px';
570 this.element.style.height = containerBox.height + 'px'; 570 this.element.style.height = containerBox.height + 'px';
571 this.element.style.width = containerBox.width + 'px'; 571 this.element.style.width = containerBox.width + 'px';
572 } 572 }
573 573
574 dispose() { 574 dispose() {
575 this.element.remove(); 575 this.element.remove();
576 } 576 }
577 }; 577 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698