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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js

Issue 2310633002: DevTools: Reduce color parsing by passing in Color to ColorSwatch (Closed)
Patch Set: Created 4 years, 3 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
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 /** 134 /**
135 * @this {WebInspector.CSSSourceFrame} 135 * @this {WebInspector.CSSSourceFrame}
136 */ 136 */
137 function putColorSwatchesInline() 137 function putColorSwatchesInline()
138 { 138 {
139 this._clearBookmarks(startLine, endLine); 139 this._clearBookmarks(startLine, endLine);
140 140
141 for (var i = 0; i < colorPositions.length; i++) { 141 for (var i = 0; i < colorPositions.length; i++) {
142 var colorPosition = colorPositions[i]; 142 var colorPosition = colorPositions[i];
143 var swatch = WebInspector.ColorSwatch.create(); 143 var swatch = WebInspector.ColorSwatch.create();
144 swatch.setColorText(colorPosition.color.asString(WebInspector.Co lor.Format.Original)); 144 swatch.setColor(colorPosition.color);
145 swatch.iconElement().title = WebInspector.UIString("Open color p icker."); 145 swatch.iconElement().title = WebInspector.UIString("Open color p icker.");
146 swatch.hideText(true); 146 swatch.hideText(true);
147 var bookmark = this.textEditor.addBookmark(colorPosition.textRan ge.startLine, colorPosition.textRange.startColumn, swatch, WebInspector.CSSSourc eFrame.SwatchBookmark); 147 var bookmark = this.textEditor.addBookmark(colorPosition.textRan ge.startLine, colorPosition.textRange.startColumn, swatch, WebInspector.CSSSourc eFrame.SwatchBookmark);
148 swatch.iconElement().addEventListener("click", this._showSpectru m.bind(this, swatch, bookmark), true); 148 swatch.iconElement().addEventListener("click", this._showSpectru m.bind(this, swatch, bookmark), true);
149 } 149 }
150 } 150 }
151 }, 151 },
152 152
153 /** 153 /**
154 * @param {number} startLine 154 * @param {number} startLine
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 _spectrumResized: function(event) 193 _spectrumResized: function(event)
194 { 194 {
195 this._swatchPopoverHelper.reposition(); 195 this._swatchPopoverHelper.reposition();
196 }, 196 },
197 197
198 /** 198 /**
199 * @param {!WebInspector.Event} event 199 * @param {!WebInspector.Event} event
200 */ 200 */
201 _spectrumChanged: function(event) 201 _spectrumChanged: function(event)
202 { 202 {
203 var colorString = /** @type {string} */ (event.data);
204 var color = WebInspector.Color.parse(colorString)
dgozman 2016/09/02 22:08:01 style: missing semicolon
flandy 2016/09/02 23:09:18 Sorry, done.
205 if (!color)
206 return;
207 this._currentSwatch.setColor(color);
203 this._muteColorProcessing = true; 208 this._muteColorProcessing = true;
204 this._hadSpectrumChange = true; 209 this._hadSpectrumChange = true;
205 var colorString = /** @type {string} */ (event.data);
206 this._currentSwatch.setColorText(colorString);
207 this._textEditor.editRange(this._currentColorTextRange, colorString, "*c olor-text-changed"); 210 this._textEditor.editRange(this._currentColorTextRange, colorString, "*c olor-text-changed");
208 this._currentColorTextRange.endColumn = this._currentColorTextRange.star tColumn + colorString.length; 211 this._currentColorTextRange.endColumn = this._currentColorTextRange.star tColumn + colorString.length;
209 }, 212 },
210 213
211 /** 214 /**
212 * @param {boolean} commitEdit 215 * @param {boolean} commitEdit
213 */ 216 */
214 _spectrumHidden: function(commitEdit) 217 _spectrumHidden: function(commitEdit)
215 { 218 {
216 this._muteColorProcessing = false; 219 this._muteColorProcessing = false;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 * @param {!WebInspector.Color} color 329 * @param {!WebInspector.Color} color
327 * @param {number} lineNumber 330 * @param {number} lineNumber
328 * @param {number} startColumn 331 * @param {number} startColumn
329 * @param {number} textLength 332 * @param {number} textLength
330 */ 333 */
331 WebInspector.CSSSourceFrame.ColorPosition = function(color, lineNumber, startCol umn, textLength) 334 WebInspector.CSSSourceFrame.ColorPosition = function(color, lineNumber, startCol umn, textLength)
332 { 335 {
333 this.color = color; 336 this.color = color;
334 this.textRange = new WebInspector.TextRange(lineNumber, startColumn, lineNum ber, startColumn + textLength); 337 this.textRange = new WebInspector.TextRange(lineNumber, startColumn, lineNum ber, startColumn + textLength);
335 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698