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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js

Issue 1809533003: DevTools: remove illusionary caching from String.prototype.lineEndings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: String.prototype.lineEndings -> String.prototype.computeLineEndings Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 text = text.replace(regex, function() { return replacement; }); 479 text = text.replace(regex, function() { return replacement; });
480 480
481 var ranges = this._collectRegexMatches(regex); 481 var ranges = this._collectRegexMatches(regex);
482 if (!ranges.length) 482 if (!ranges.length)
483 return; 483 return;
484 484
485 // Calculate the position of the end of the last range to be edited. 485 // Calculate the position of the end of the last range to be edited.
486 var currentRangeIndex = insertionIndexForObjectInListSortedByFunction(th is._textEditor.selection(), ranges, WebInspector.TextRange.comparator); 486 var currentRangeIndex = insertionIndexForObjectInListSortedByFunction(th is._textEditor.selection(), ranges, WebInspector.TextRange.comparator);
487 var lastRangeIndex = mod(currentRangeIndex - 1, ranges.length); 487 var lastRangeIndex = mod(currentRangeIndex - 1, ranges.length);
488 var lastRange = ranges[lastRangeIndex]; 488 var lastRange = ranges[lastRangeIndex];
489 var replacementLineEndings = replacement.lineEndings(); 489 var replacementLineEndings = replacement.computeLineEndings();
490 var replacementLineCount = replacementLineEndings.length; 490 var replacementLineCount = replacementLineEndings.length;
491 var lastLineNumber = lastRange.startLine + replacementLineEndings.length - 1; 491 var lastLineNumber = lastRange.startLine + replacementLineEndings.length - 1;
492 var lastColumnNumber = lastRange.startColumn; 492 var lastColumnNumber = lastRange.startColumn;
493 if (replacementLineEndings.length > 1) 493 if (replacementLineEndings.length > 1)
494 lastColumnNumber = replacementLineEndings[replacementLineCount - 1] - replacementLineEndings[replacementLineCount - 2] - 1; 494 lastColumnNumber = replacementLineEndings[replacementLineCount - 1] - replacementLineEndings[replacementLineCount - 2] - 1;
495 495
496 this._textEditor.editRange(range, text); 496 this._textEditor.editRange(range, text);
497 this._textEditor.revealPosition(lastLineNumber, lastColumnNumber); 497 this._textEditor.revealPosition(lastLineNumber, lastColumnNumber);
498 this._textEditor.setSelection(WebInspector.TextRange.createFromLocation( lastLineNumber, lastColumnNumber)); 498 this._textEditor.setSelection(WebInspector.TextRange.createFromLocation( lastLineNumber, lastColumnNumber));
499 }, 499 },
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 /** 678 /**
679 * @override 679 * @override
680 * @param {?WebInspector.TextRange} from 680 * @param {?WebInspector.TextRange} from
681 * @param {?WebInspector.TextRange} to 681 * @param {?WebInspector.TextRange} to
682 */ 682 */
683 onJumpToPosition: function(from, to) 683 onJumpToPosition: function(from, to)
684 { 684 {
685 this._sourceFrame.onJumpToPosition(from, to); 685 this._sourceFrame.onJumpToPosition(from, to);
686 } 686 }
687 } 687 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698