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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatter.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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 WebInspector.ScriptFormatter.prototype = { 103 WebInspector.ScriptFormatter.prototype = {
104 /** 104 /**
105 * @param {!MessageEvent} event 105 * @param {!MessageEvent} event
106 */ 106 */
107 _didFormatContent: function(event) 107 _didFormatContent: function(event)
108 { 108 {
109 this._worker.terminate(); 109 this._worker.terminate();
110 var originalContent = this._originalContent; 110 var originalContent = this._originalContent;
111 var formattedContent = event.data.content; 111 var formattedContent = event.data.content;
112 var mapping = event.data["mapping"]; 112 var mapping = event.data["mapping"];
113 var sourceMapping = new WebInspector.FormatterSourceMappingImpl(original Content.lineEndings(), formattedContent.lineEndings(), mapping); 113 var sourceMapping = new WebInspector.FormatterSourceMappingImpl(original Content.computeLineEndings(), formattedContent.computeLineEndings(), mapping);
114 this._callback(formattedContent, sourceMapping); 114 this._callback(formattedContent, sourceMapping);
115 } 115 }
116 } 116 }
117 117
118 /** 118 /**
119 * @constructor 119 * @constructor
120 * @implements {WebInspector.Formatter} 120 * @implements {WebInspector.Formatter}
121 * @param {string} mimeType 121 * @param {string} mimeType
122 * @param {string} content 122 * @param {string} content
123 * @param {function(string, !WebInspector.FormatterSourceMapping)} callback 123 * @param {function(string, !WebInspector.FormatterSourceMapping)} callback
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 */ 236 */
237 _convertPosition: function(positions1, positions2, position) 237 _convertPosition: function(positions1, positions2, position)
238 { 238 {
239 var index = positions1.upperBound(position) - 1; 239 var index = positions1.upperBound(position) - 1;
240 var convertedPosition = positions2[index] + position - positions1[index] ; 240 var convertedPosition = positions2[index] + position - positions1[index] ;
241 if (index < positions2.length - 1 && convertedPosition > positions2[inde x + 1]) 241 if (index < positions2.length - 1 && convertedPosition > positions2[inde x + 1])
242 convertedPosition = positions2[index + 1]; 242 convertedPosition = positions2[index + 1];
243 return convertedPosition; 243 return convertedPosition;
244 } 244 }
245 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698