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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/TextRange.js

Issue 1943763002: DevTools: [SASS] fix CSSWorkspaceBinding.propertyUILocation to account for comments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@super-sass
Patch Set: fix tests Created 4 years, 7 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) 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 * @constructor 304 * @constructor
305 * @param {number} offset 305 * @param {number} offset
306 * @param {number} length 306 * @param {number} length
307 */ 307 */
308 WebInspector.SourceRange = function(offset, length) 308 WebInspector.SourceRange = function(offset, length)
309 { 309 {
310 this.offset = offset; 310 this.offset = offset;
311 this.length = length; 311 this.length = length;
312 } 312 }
313 313
314 WebInspector.SourceRange.prototype = {
315 /**
316 * @param {!WebInspector.Text} text
317 * @return {!WebInspector.TextRange}
318 */
319 toTextRange: function(text)
320 {
321 var p1 = fromOffset(text, this.offset);
322 var p2 = fromOffset(text, this.offset + this.length);
323 return new WebInspector.TextRange(p1.lineNumber, p1.columnNumber, p2.lin eNumber, p2.columnNumber);
324
325 /**
326 * @param {!WebInspector.Text} text
327 * @param {number} offset
328 * @return {!{lineNumber: number, columnNumber: number}}
329 */
330 function fromOffset(text, offset)
331 {
332 var lineEndings = text.lineEndings();
333 var lineNumber = lineEndings.lowerBound(offset);
334 var columnNumber = lineNumber === 0 ? offset : offset - lineEndings[ lineNumber - 1] - 1;
335 return {lineNumber: lineNumber, columnNumber: columnNumber};
336 }
337 }
338 }
339
340 /** 314 /**
341 * @constructor 315 * @constructor
342 * @param {string} sourceURL 316 * @param {string} sourceURL
343 * @param {!WebInspector.TextRange} oldRange 317 * @param {!WebInspector.TextRange} oldRange
344 * @param {string} newText 318 * @param {string} newText
345 */ 319 */
346 WebInspector.SourceEdit = function(sourceURL, oldRange, newText) 320 WebInspector.SourceEdit = function(sourceURL, oldRange, newText)
347 { 321 {
348 this.sourceURL = sourceURL; 322 this.sourceURL = sourceURL;
349 this.oldRange = oldRange; 323 this.oldRange = oldRange;
(...skipping 12 matching lines...) Expand all
362 336
363 /** 337 /**
364 * @param {!WebInspector.SourceEdit} edit1 338 * @param {!WebInspector.SourceEdit} edit1
365 * @param {!WebInspector.SourceEdit} edit2 339 * @param {!WebInspector.SourceEdit} edit2
366 * @return {number} 340 * @return {number}
367 */ 341 */
368 WebInspector.SourceEdit.comparator = function(edit1, edit2) 342 WebInspector.SourceEdit.comparator = function(edit1, edit2)
369 { 343 {
370 return WebInspector.TextRange.comparator(edit1.oldRange, edit2.oldRange); 344 return WebInspector.TextRange.comparator(edit1.oldRange, edit2.oldRange);
371 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698