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

Side by Side Diff: src/messages.js

Issue 43130: Fix the handling of line offset when getting the source line from a ScriptMirror (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « src/debug-delay.js ('k') | src/mirror-delay.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Default is first column. If on the first line add the offset within the 295 // Default is first column. If on the first line add the offset within the
296 // resource. 296 // resource.
297 var column = opt_column || 0; 297 var column = opt_column || 0;
298 if (line == 0) { 298 if (line == 0) {
299 column -= this.column_offset 299 column -= this.column_offset
300 } 300 }
301 301
302 var offset_position = opt_offset_position || 0; 302 var offset_position = opt_offset_position || 0;
303 if (line < 0 || column < 0 || offset_position < 0) return null; 303 if (line < 0 || column < 0 || offset_position < 0) return null;
304 if (line == 0) { 304 if (line == 0) {
305 return this.locationFromPosition(offset_position + column); 305 return this.locationFromPosition(offset_position + column, false);
306 } else { 306 } else {
307 // Find the line where the offset position is located 307 // Find the line where the offset position is located
308 var lineCount = this.lineCount(); 308 var lineCount = this.lineCount();
309 var offset_line; 309 var offset_line;
310 for (var i = 0; i < lineCount; i++) { 310 for (var i = 0; i < lineCount; i++) {
311 if (offset_position <= this.line_ends[i]) { 311 if (offset_position <= this.line_ends[i]) {
312 offset_line = i; 312 offset_line = i;
313 break; 313 break;
314 } 314 }
315 } 315 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 * the line terminating characters (if any) 512 * the line terminating characters (if any)
513 */ 513 */
514 SourceSlice.prototype.sourceText = function () { 514 SourceSlice.prototype.sourceText = function () {
515 return this.script.source.substring(this.from_position, this.to_position); 515 return this.script.source.substring(this.from_position, this.to_position);
516 }; 516 };
517 517
518 518
519 // Returns the offset of the given position within the containing 519 // Returns the offset of the given position within the containing
520 // line. 520 // line.
521 function GetPositionInLine(message) { 521 function GetPositionInLine(message) {
522 var location = message.script.locationFromPosition(message.startPos); 522 var location = message.script.locationFromPosition(message.startPos, false);
523 if (location == null) return -1; 523 if (location == null) return -1;
524 location.restrict(); 524 location.restrict();
525 return message.startPos - location.start; 525 return message.startPos - location.start;
526 } 526 }
527 527
528 528
529 function ErrorMessage(type, args, startPos, endPos, script, stackTrace) { 529 function ErrorMessage(type, args, startPos, endPos, script, stackTrace) {
530 this.startPos = startPos; 530 this.startPos = startPos;
531 this.endPos = endPos; 531 this.endPos = endPos;
532 this.type = type; 532 this.type = type;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 return this.name + ": " + FormatMessage({ type: type, args: this.arguments } ); 677 return this.name + ": " + FormatMessage({ type: type, args: this.arguments } );
678 } 678 }
679 var message = this.message; 679 var message = this.message;
680 return this.name + (message ? (": " + message) : ""); 680 return this.name + (message ? (": " + message) : "");
681 }, DONT_ENUM); 681 }, DONT_ENUM);
682 682
683 683
684 // Boilerplate for exceptions for stack overflows. Used from 684 // Boilerplate for exceptions for stack overflows. Used from
685 // Top::StackOverflow(). 685 // Top::StackOverflow().
686 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); 686 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);
OLDNEW
« no previous file with comments | « src/debug-delay.js ('k') | src/mirror-delay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698