Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @implements {WebInspector.TargetManager.Observer} | 7 * @implements {WebInspector.TargetManager.Observer} |
| 8 * @param {!WebInspector.TargetManager} targetManager | 8 * @param {!WebInspector.TargetManager} targetManager |
| 9 * @param {!WebInspector.Workspace} workspace | 9 * @param {!WebInspector.Workspace} workspace |
| 10 * @param {!WebInspector.NetworkMapping} networkMapping | 10 * @param {!WebInspector.NetworkMapping} networkMapping |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 var info = this._headerInfo(location._header); | 126 var info = this._headerInfo(location._header); |
| 127 if (info) | 127 if (info) |
| 128 info._removeLocation(location); | 128 info._removeLocation(location); |
| 129 }, | 129 }, |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * @param {!WebInspector.CSSProperty} cssProperty | 132 * @param {!WebInspector.CSSProperty} cssProperty |
| 133 * @param {boolean} forName | 133 * @param {boolean} forName |
| 134 * @return {?WebInspector.UILocation} | 134 * @return {?WebInspector.UILocation} |
| 135 */ | 135 */ |
| 136 propertyUILocation: function(cssProperty, forName) | 136 propertyUILocation: function(cssProperty, forName) |
|
pfeldman
2016/05/03 17:52:29
I don't think this method belongs here, lets move
lushnikov
2016/05/03 23:19:27
Introduced property.nameRange() and property.value
| |
| 137 { | 137 { |
| 138 var style = cssProperty.ownerStyle; | 138 var style = cssProperty.ownerStyle; |
| 139 if (!style || !style.parentRule || !style.styleSheetId) | 139 if (!style || !style.parentRule || !style.styleSheetId) |
| 140 return null; | 140 return null; |
| 141 | 141 |
| 142 var range = cssProperty.range; | 142 var range = cssProperty.range; |
| 143 if (!range) | 143 var text = cssProperty.text; |
| 144 var header = style.cssModel().styleSheetHeaderForId(style.styleSheetId); | |
| 145 if (!range || !text || !header) | |
| 144 return null; | 146 return null; |
| 145 | 147 |
| 146 var header = style.cssModel().styleSheetHeaderForId(style.styleSheetId); | 148 var textCursor = new WebInspector.TextCursor(cssProperty.text.computeLin eEndings()); |
| 147 if (!header) | 149 if (forName) { |
| 148 return null; | 150 var nameIndex = text.indexOf(cssProperty.name); |
| 149 | 151 textCursor.resetTo(nameIndex); |
| 150 var line = forName ? range.startLine : range.endLine; | 152 } else { |
| 151 // End of range is exclusive, so subtract 1 from the end offset. | 153 var valueIndex = text.lastIndexOf(cssProperty.value); |
| 152 var column = forName ? range.startColumn : range.endColumn - (cssPropert y.text && cssProperty.text.endsWith(";") ? 2 : 1); | 154 textCursor.resetTo(valueIndex + cssProperty.value.length); |
|
pfeldman
2016/05/03 17:52:29
You want to accompany this with a test. Otherwise
lushnikov
2016/05/03 23:19:27
Done.
| |
| 153 var rawLocation = new WebInspector.CSSLocation(header, header.lineNumber InSource(line), header.columnNumberInSource(line, column)); | 155 } |
| 156 var lineNumber = range.startLine; | |
| 157 var columnNumber = range.startColumn; | |
| 158 if (textCursor.lineNumber() === 0) { | |
| 159 columnNumber += textCursor.columnNumber(); | |
| 160 } else { | |
| 161 lineNumber += textCursor.lineNumber(); | |
| 162 columnNumber = textCursor.columnNumber(); | |
| 163 } | |
| 164 var rawLocation = new WebInspector.CSSLocation(header, header.lineNumber InSource(lineNumber), header.columnNumberInSource(lineNumber, columnNumber)); | |
| 154 return this.rawLocationToUILocation(rawLocation); | 165 return this.rawLocationToUILocation(rawLocation); |
| 155 }, | 166 }, |
| 156 | 167 |
| 157 /** | 168 /** |
| 158 * @param {?WebInspector.CSSLocation} rawLocation | 169 * @param {?WebInspector.CSSLocation} rawLocation |
| 159 * @return {?WebInspector.UILocation} | 170 * @return {?WebInspector.UILocation} |
| 160 */ | 171 */ |
| 161 rawLocationToUILocation: function(rawLocation) | 172 rawLocationToUILocation: function(rawLocation) |
| 162 { | 173 { |
| 163 if (!rawLocation) | 174 if (!rawLocation) |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 * @param {number} lineNumber | 461 * @param {number} lineNumber |
| 451 * @return {boolean} | 462 * @return {boolean} |
| 452 */ | 463 */ |
| 453 uiLineHasMapping: function(uiSourceCode, lineNumber) { } | 464 uiLineHasMapping: function(uiSourceCode, lineNumber) { } |
| 454 } | 465 } |
| 455 | 466 |
| 456 /** | 467 /** |
| 457 * @type {!WebInspector.CSSWorkspaceBinding} | 468 * @type {!WebInspector.CSSWorkspaceBinding} |
| 458 */ | 469 */ |
| 459 WebInspector.cssWorkspaceBinding; | 470 WebInspector.cssWorkspaceBinding; |
| OLD | NEW |