| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {string} value | 7 * @param {string} value |
| 8 */ | 8 */ |
| 9 WebInspector.Text = function(value) | 9 WebInspector.Text = function(value) |
| 10 { | 10 { |
| 11 this._value = value; | 11 this._value = value; |
| 12 } | 12 }; |
| 13 | 13 |
| 14 WebInspector.Text.prototype = { | 14 WebInspector.Text.prototype = { |
| 15 /** | 15 /** |
| 16 * @return {!Array<number>} | 16 * @return {!Array<number>} |
| 17 */ | 17 */ |
| 18 lineEndings: function() | 18 lineEndings: function() |
| 19 { | 19 { |
| 20 if (!this._lineEndings) | 20 if (!this._lineEndings) |
| 21 this._lineEndings = this._value.computeLineEndings(); | 21 this._lineEndings = this._value.computeLineEndings(); |
| 22 return this._lineEndings; | 22 return this._lineEndings; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 /** | 107 /** |
| 108 * @param {!WebInspector.TextRange} range | 108 * @param {!WebInspector.TextRange} range |
| 109 * @return {string} | 109 * @return {string} |
| 110 */ | 110 */ |
| 111 extract: function(range) | 111 extract: function(range) |
| 112 { | 112 { |
| 113 var sourceRange = this.toSourceRange(range); | 113 var sourceRange = this.toSourceRange(range); |
| 114 return this._value.substr(sourceRange.offset, sourceRange.length); | 114 return this._value.substr(sourceRange.offset, sourceRange.length); |
| 115 } | 115 } |
| 116 } | 116 }; |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * @constructor | 119 * @constructor |
| 120 * @param {!Array<number>} lineEndings | 120 * @param {!Array<number>} lineEndings |
| 121 */ | 121 */ |
| 122 WebInspector.TextCursor = function(lineEndings) | 122 WebInspector.TextCursor = function(lineEndings) |
| 123 { | 123 { |
| 124 this._lineEndings = lineEndings; | 124 this._lineEndings = lineEndings; |
| 125 this._offset = 0; | 125 this._offset = 0; |
| 126 this._lineNumber = 0; | 126 this._lineNumber = 0; |
| 127 this._columnNumber = 0; | 127 this._columnNumber = 0; |
| 128 } | 128 }; |
| 129 | 129 |
| 130 WebInspector.TextCursor.prototype = { | 130 WebInspector.TextCursor.prototype = { |
| 131 /** | 131 /** |
| 132 * @param {number} offset | 132 * @param {number} offset |
| 133 */ | 133 */ |
| 134 advance: function(offset) | 134 advance: function(offset) |
| 135 { | 135 { |
| 136 this._offset = offset; | 136 this._offset = offset; |
| 137 while (this._lineNumber < this._lineEndings.length && this._lineEndings[
this._lineNumber] < this._offset) | 137 while (this._lineNumber < this._lineEndings.length && this._lineEndings[
this._lineNumber] < this._offset) |
| 138 ++this._lineNumber; | 138 ++this._lineNumber; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 165 return this._lineNumber; | 165 return this._lineNumber; |
| 166 }, | 166 }, |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * @return {number} | 169 * @return {number} |
| 170 */ | 170 */ |
| 171 columnNumber: function() | 171 columnNumber: function() |
| 172 { | 172 { |
| 173 return this._columnNumber; | 173 return this._columnNumber; |
| 174 } | 174 } |
| 175 } | 175 }; |
| OLD | NEW |