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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 */ 1948 */
1949 _processColor: function(text) 1949 _processColor: function(text)
1950 { 1950 {
1951 // We can be called with valid non-color values of |text| (like 'none' f rom border style) 1951 // We can be called with valid non-color values of |text| (like 'none' f rom border style)
1952 var color = WebInspector.Color.parse(text); 1952 var color = WebInspector.Color.parse(text);
1953 if (!color) 1953 if (!color)
1954 return createTextNode(text); 1954 return createTextNode(text);
1955 1955
1956 if (!this._editable()) { 1956 if (!this._editable()) {
1957 var swatch = WebInspector.ColorSwatch.create(); 1957 var swatch = WebInspector.ColorSwatch.create();
1958 swatch.setColorText(text); 1958 swatch.setColor(color);
1959 return swatch; 1959 return swatch;
1960 } 1960 }
1961 1961
1962 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; 1962 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper;
1963 var swatch = WebInspector.ColorSwatch.create(); 1963 var swatch = WebInspector.ColorSwatch.create();
1964 swatch.setColorText(text); 1964 swatch.setColor(color);
1965 swatch.setFormat(WebInspector.Color.detectColorFormat(swatch.color())); 1965 swatch.setFormat(WebInspector.Color.detectColorFormat(swatch.color()));
1966 var swatchIcon = new WebInspector.ColorSwatchPopoverIcon(this, swatchPop overHelper, swatch); 1966 var swatchIcon = new WebInspector.ColorSwatchPopoverIcon(this, swatchPop overHelper, swatch);
1967 1967
1968 /** 1968 /**
1969 * @param {?Array<string>} backgroundColors 1969 * @param {?Array<string>} backgroundColors
1970 */ 1970 */
1971 function computedCallback(backgroundColors) 1971 function computedCallback(backgroundColors)
1972 { 1972 {
1973 // TODO(aboxhall): distinguish between !backgroundColors (no text) a nd 1973 // TODO(aboxhall): distinguish between !backgroundColors (no text) a nd
1974 // !backgroundColors.length (no computed bg color) 1974 // !backgroundColors.length (no computed bg color)
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 3150
3151 /** 3151 /**
3152 * @override 3152 * @override
3153 * @return {!WebInspector.ToolbarItem} 3153 * @return {!WebInspector.ToolbarItem}
3154 */ 3154 */
3155 item: function() 3155 item: function()
3156 { 3156 {
3157 return this._button; 3157 return this._button;
3158 } 3158 }
3159 } 3159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698