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"; |
lushnikov
2016/07/29 17:46:24
could you please remind me why we add newlines her
flandy
2016/07/29 18:31:39
The textEditor.line() function does not include ne
| |
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); | 355 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); |
356 if (!propertyToken) | 356 if (!propertyToken) |
357 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); | 357 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); |
358 | 358 |
359 var line = editor.line(prefixRange.startLine); | 359 var line = editor.line(prefixRange.startLine); |
360 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); | 360 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); |
361 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); | 361 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); |
362 return keywords.startsWith(prefix); | 362 return keywords.startsWith(prefix); |
363 }, | 363 }, |
364 } | 364 } |
OLD | NEW |