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

Side by Side Diff: Source/devtools/front_end/TextRange.js

Issue 220403005: DevTools: synchronize links in StylesSidebarPane on edits. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix setDisabled case Created 6 years, 8 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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 * @return {boolean} 82 * @return {boolean}
83 */ 83 */
84 immediatelyFollows: function(range) 84 immediatelyFollows: function(range)
85 { 85 {
86 if (!range) 86 if (!range)
87 return false; 87 return false;
88 return range.immediatelyPrecedes(this); 88 return range.immediatelyPrecedes(this);
89 }, 89 },
90 90
91 /** 91 /**
92 * @param {!WebInspector.TextRange} range
93 * @return {boolean}
94 */
95 follows: function(range)
96 {
97 return (range.endLine === this.startLine && range.endColumn <= this.star tColumn)
98 || range.endLine < this.startLine;
99 },
100
101 /**
92 * @return {number} 102 * @return {number}
93 */ 103 */
94 get linesCount() 104 get linesCount()
95 { 105 {
96 return this.endLine - this.startLine; 106 return this.endLine - this.startLine;
97 }, 107 },
98 108
99 /** 109 /**
100 * @return {!WebInspector.TextRange} 110 * @return {!WebInspector.TextRange}
101 */ 111 */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 /** 176 /**
167 * @param {number} lineOffset 177 * @param {number} lineOffset
168 * @return {!WebInspector.TextRange} 178 * @return {!WebInspector.TextRange}
169 */ 179 */
170 shift: function(lineOffset) 180 shift: function(lineOffset)
171 { 181 {
172 return new WebInspector.TextRange(this.startLine + lineOffset, this.star tColumn, this.endLine + lineOffset, this.endColumn); 182 return new WebInspector.TextRange(this.startLine + lineOffset, this.star tColumn, this.endLine + lineOffset, this.endColumn);
173 }, 183 },
174 184
175 /** 185 /**
186 * @param {!WebInspector.TextRange} originalRange
187 * @param {!WebInspector.TextRange} editedRange
188 * @return {!WebInspector.TextRange}
189 */
190 rebaseAfterTextEdit: function(originalRange, editedRange)
191 {
192 console.assert(originalRange.startLine === editedRange.startLine);
193 console.assert(originalRange.startColumn === editedRange.startColumn);
194 var rebase = this.clone();
195 if (!this.follows(originalRange))
196 return rebase;
197 var lineDelta = editedRange.endLine - originalRange.endLine;
198 var columnDelta = editedRange.endColumn - originalRange.endColumn;
199 rebase.startLine += lineDelta;
200 rebase.endLine += lineDelta;
201 if (rebase.startLine === editedRange.endLine)
202 rebase.startColumn += columnDelta;
203 if (rebase.endLine === editedRange.endLine)
204 rebase.endColumn += columnDelta;
205 return rebase;
206 },
207
208 /**
176 * @return {string} 209 * @return {string}
177 */ 210 */
178 toString: function() 211 toString: function()
179 { 212 {
180 return JSON.stringify(this); 213 return JSON.stringify(this);
181 } 214 }
182 } 215 }
183 216
184 /** 217 /**
185 * @constructor 218 * @constructor
186 * @param {number} offset 219 * @param {number} offset
187 * @param {number} length 220 * @param {number} length
188 */ 221 */
189 WebInspector.SourceRange = function(offset, length) 222 WebInspector.SourceRange = function(offset, length)
190 { 223 {
191 this.offset = offset; 224 this.offset = offset;
192 this.length = length; 225 this.length = length;
193 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698