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

Side by Side Diff: chrome/browser/resources/options/content_settings_exceptions_area.js

Issue 6099016: Drastically reduce the number of redraws when editing content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix selection bug Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/options/content_settings.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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('options.contentSettings', function() { 5 cr.define('options.contentSettings', function() {
6 const DeletableItemList = options.DeletableItemList; 6 const DeletableItemList = options.DeletableItemList;
7 const DeletableItem = options.DeletableItem; 7 const DeletableItem = options.DeletableItem;
8 const ArrayDataModel = cr.ui.ArrayDataModel; 8 const ArrayDataModel = cr.ui.ArrayDataModel;
9 9
10 /** 10 /**
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 417
418 var exceptionList = this; 418 var exceptionList = this;
419 function handleBlur(e) { 419 function handleBlur(e) {
420 // When the blur event happens we do not know who is getting focus so we 420 // When the blur event happens we do not know who is getting focus so we
421 // delay this a bit until we know if the new focus node is outside the 421 // delay this a bit until we know if the new focus node is outside the
422 // list. 422 // list.
423 var doc = e.target.ownerDocument; 423 var doc = e.target.ownerDocument;
424 window.setTimeout(function() { 424 window.setTimeout(function() {
425 var activeElement = doc.activeElement; 425 var activeElement = doc.activeElement;
426 if (!exceptionList.contains(activeElement)) 426 if (!exceptionList.contains(activeElement))
427 exceptionList.selectionModel.clear(); 427 exceptionList.selectionModel.unselectAll();
428 }, 50); 428 }, 50);
429 } 429 }
430 430
431 this.addEventListener('blur', handleBlur, true); 431 this.addEventListener('blur', handleBlur, true);
432 432
433 // Whether the exceptions in this list allow an 'Ask every time' option. 433 // Whether the exceptions in this list allow an 'Ask every time' option.
434 this.enableAskOption = (this.contentType == 'plugins' && 434 this.enableAskOption = (this.contentType == 'plugins' &&
435 templateData.enable_click_to_play); 435 templateData.enable_click_to_play);
436 436
437 this.autoExpands = true; 437 this.autoExpands = true;
(...skipping 13 matching lines...) Expand all
451 } else { 451 } else {
452 var addRowItem = new ExceptionsAddRowListItem(this.contentType, 452 var addRowItem = new ExceptionsAddRowListItem(this.contentType,
453 this.mode, 453 this.mode,
454 this.enableAskOption); 454 this.enableAskOption);
455 addRowItem.deletable = false; 455 addRowItem.deletable = false;
456 return addRowItem; 456 return addRowItem;
457 } 457 }
458 }, 458 },
459 459
460 /** 460 /**
461 * Adds an exception to the js model. 461 * Sets the exceptions in the js model.
462 * @param {Object} entry A dictionary of values for the exception. 462 * @param {Object} entries A list of dictionaries of values, each dictionary
463 * represents an exception.
463 */ 464 */
464 addException: function(entry) { 465 setExceptions: function(entries) {
466 var deleteCount = this.dataModel.length;
467
465 if (this.isEditable()) { 468 if (this.isEditable()) {
466 // We have to add it before the Add New Exception row. 469 // We don't want to remove the Add New Exception row.
467 this.dataModel.splice(this.dataModel.length - 1, 0, entry); 470 deleteCount = deleteCount - 1;
468 } else {
469 this.dataModel.push(entry);
470 } 471 }
472
473 var args = [0, deleteCount];
474 args.push.apply(args, entries);
475 this.dataModel.splice.apply(this.dataModel, args);
471 }, 476 },
472 477
473 /** 478 /**
474 * The browser has finished checking a pattern for validity. Update the 479 * The browser has finished checking a pattern for validity. Update the
475 * list item to reflect this. 480 * list item to reflect this.
476 * @param {string} pattern The pattern. 481 * @param {string} pattern The pattern.
477 * @param {bool} valid Whether said pattern is valid in the context of 482 * @param {bool} valid Whether said pattern is valid in the context of
478 * a content exception setting. 483 * a content exception setting.
479 */ 484 */
480 patternValidityCheckComplete: function(pattern, valid) { 485 patternValidityCheckComplete: function(pattern, valid) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 } 607 }
603 }; 608 };
604 609
605 return { 610 return {
606 ExceptionsListItem: ExceptionsListItem, 611 ExceptionsListItem: ExceptionsListItem,
607 ExceptionsAddRowListItem: ExceptionsAddRowListItem, 612 ExceptionsAddRowListItem: ExceptionsAddRowListItem,
608 ExceptionsList: ExceptionsList, 613 ExceptionsList: ExceptionsList,
609 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, 614 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea,
610 }; 615 };
611 }); 616 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698