Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 /** | 105 /** |
| 106 * @param {number} startLine | 106 * @param {number} startLine |
| 107 * @param {number} endLine | 107 * @param {number} endLine |
| 108 */ | 108 */ |
| 109 _updateColorSwatches: function(startLine, endLine) | 109 _updateColorSwatches: function(startLine, endLine) |
| 110 { | 110 { |
| 111 var colorPositions = []; | 111 var colorPositions = []; |
| 112 | 112 |
| 113 var colorRegex = /[\s:;,(){}]((?:rgb|hsl)a?\([^)]+\)|#[0-9a-f]{8}|#[0-9a -f]{6}|#[0-9a-f]{3,4}|[a-z]+)(?=[\s;,(){}])/gi; | 113 var colorRegex = /[\s:;,(){}]((?:rgb|hsl)a?\([^)]+\)|#[0-9a-f]{8}|#[0-9a -f]{6}|#[0-9a-f]{3,4}|[a-z]+)(?=[\s;,(){}])/gi; |
| 114 for (var lineNumber = startLine; lineNumber <= endLine; lineNumber++) { | 114 for (var lineNumber = startLine; lineNumber <= endLine; lineNumber++) { |
| 115 var line = this.textEditor.line(lineNumber).substring(0, WebInspecto r.CSSSourceFrame.maxSwatchProcessingLength) + "\n"; | 115 var line = "\n" + this.textEditor.line(lineNumber).substring(0, WebI nspector.CSSSourceFrame.maxSwatchProcessingLength) + "\n"; |
| 116 var match; | 116 var match; |
| 117 while ((match = colorRegex.exec(line)) !== null) { | 117 while ((match = colorRegex.exec(line)) !== null) { |
| 118 if (match.length < 2) | 118 if (match.length < 2) |
| 119 continue; | 119 continue; |
| 120 var colorText = match[1]; | 120 var colorText = match[1]; |
| 121 var color = WebInspector.Color.parse(colorText); | 121 var color = WebInspector.Color.parse(colorText); |
| 122 if (color) | 122 if (color) |
| 123 colorPositions.push(new WebInspector.CSSSourceFrame.ColorPos ition(color, lineNumber, match.index + 1, colorText.length)); | 123 colorPositions.push(new WebInspector.CSSSourceFrame.ColorPos ition(color, lineNumber, match.index, colorText.length)); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 this.textEditor.operation(putColorSwatchesInline.bind(this)); | 127 this.textEditor.operation(putColorSwatchesInline.bind(this)); |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * @this {WebInspector.CSSSourceFrame} | 130 * @this {WebInspector.CSSSourceFrame} |
| 131 */ | 131 */ |
| 132 function putColorSwatchesInline() | 132 function putColorSwatchesInline() |
| 133 { | 133 { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 }, | 146 }, |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * @param {number} startLine | 149 * @param {number} startLine |
| 150 * @param {number} endLine | 150 * @param {number} endLine |
| 151 */ | 151 */ |
| 152 _clearBookmarks: function(startLine, endLine) | 152 _clearBookmarks: function(startLine, endLine) |
| 153 { | 153 { |
| 154 var range = new WebInspector.TextRange(startLine, 0, endLine, this.textE ditor.line(endLine).length); | 154 var startPos = new CodeMirror.Pos(startLine, 0); |
|
lushnikov
2016/07/27 23:32:02
we shouldn't be using CodeMirror.Pos outside of Co
flandy
2016/07/29 17:25:51
Done.
| |
| 155 var markers = this.textEditor.bookmarks(range); | 155 var endPos = new CodeMirror.Pos(endLine, this.textEditor.line(endLine).l ength) |
| 156 for (var i = 0; i < markers.length; i++) | 156 var range = WebInspector.CodeMirrorUtils.toRange(startPos, endPos); |
| 157 markers[i].clear(); | 157 |
| 158 var startMarkers = this.textEditor.bookmarksAt(startPos); | |
| 159 for (var i = 0; i < startMarkers.length; i++) | |
| 160 startMarkers[i].clear(); | |
| 161 | |
| 162 var endMarkers = this.textEditor.bookmarksAt(endPos) | |
| 163 for (var i = 0; i < endMarkers.length; i++) | |
| 164 endMarkers[i].clear(); | |
| 165 | |
| 166 var innerMarkers = this.textEditor.bookmarks(range); | |
| 167 for (var i = 0; i < innerMarkers.length; i++) | |
| 168 innerMarkers[i].clear(); | |
| 158 }, | 169 }, |
| 159 | 170 |
| 160 /** | 171 /** |
| 161 * @param {!WebInspector.ColorSwatch} swatch | 172 * @param {!WebInspector.ColorSwatch} swatch |
| 162 * @param {!CodeMirror.TextMarker} bookmark | 173 * @param {!CodeMirror.TextMarker} bookmark |
| 163 * @param {!Event} event | 174 * @param {!Event} event |
| 164 */ | 175 */ |
| 165 _showSpectrum: function(swatch, bookmark, event) | 176 _showSpectrum: function(swatch, bookmark, event) |
| 166 { | 177 { |
| 167 event.consume(true); | 178 event.consume(true); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); | 366 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); |
| 356 if (!propertyToken) | 367 if (!propertyToken) |
| 357 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); | 368 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); |
| 358 | 369 |
| 359 var line = editor.line(prefixRange.startLine); | 370 var line = editor.line(prefixRange.startLine); |
| 360 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); | 371 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); |
| 361 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); | 372 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); |
| 362 return keywords.startsWith(prefix); | 373 return keywords.startsWith(prefix); |
| 363 }, | 374 }, |
| 364 } | 375 } |
| OLD | NEW |