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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js

Issue 2832653002: DevTools: brush up color blending and theming APIs. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartNetworkDataProvider.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 colorUsage |= UI.ThemeSupport.ColorUsage.Selection; 1845 colorUsage |= UI.ThemeSupport.ColorUsage.Selection;
1846 if (name.indexOf('background') === 0 || name.indexOf('border') === 0) 1846 if (name.indexOf('background') === 0 || name.indexOf('border') === 0)
1847 colorUsage |= UI.ThemeSupport.ColorUsage.Background; 1847 colorUsage |= UI.ThemeSupport.ColorUsage.Background;
1848 if (name.indexOf('background') === -1) 1848 if (name.indexOf('background') === -1)
1849 colorUsage |= UI.ThemeSupport.ColorUsage.Foreground; 1849 colorUsage |= UI.ThemeSupport.ColorUsage.Foreground;
1850 1850
1851 output.push(name); 1851 output.push(name);
1852 output.push(':'); 1852 output.push(':');
1853 var items = value.replace(Common.Color.Regex, '\0$1\0').split('\0'); 1853 var items = value.replace(Common.Color.Regex, '\0$1\0').split('\0');
1854 for (var i = 0; i < items.length; ++i) 1854 for (var i = 0; i < items.length; ++i)
1855 output.push(this.patchColor(items[i], colorUsage)); 1855 output.push(this.patchColorText(items[i], colorUsage));
1856 if (style.getPropertyPriority(name)) 1856 if (style.getPropertyPriority(name))
1857 output.push(' !important'); 1857 output.push(' !important');
1858 output.push(';'); 1858 output.push(';');
1859 } 1859 }
1860 1860
1861 /** 1861 /**
1862 * @param {string} text 1862 * @param {string} text
1863 * @param {!UI.ThemeSupport.ColorUsage} colorUsage 1863 * @param {!UI.ThemeSupport.ColorUsage} colorUsage
1864 * @return {string} 1864 * @return {string}
1865 */ 1865 */
1866 patchColor(text, colorUsage) { 1866 patchColorText(text, colorUsage) {
1867 var color = Common.Color.parse(text); 1867 var color = Common.Color.parse(text);
1868 if (!color) 1868 if (!color)
1869 return text; 1869 return text;
1870 1870 var outColor = this.patchColor(color, colorUsage);
1871 var hsla = color.hsla();
1872 this._patchHSLA(hsla, colorUsage);
1873 var rgba = [];
1874 Common.Color.hsl2rgb(hsla, rgba);
1875 var outColor = new Common.Color(rgba, color.format());
1876 var outText = outColor.asString(null); 1871 var outText = outColor.asString(null);
1877 if (!outText) 1872 if (!outText)
1878 outText = outColor.asString(outColor.hasAlpha() ? Common.Color.Format.RGBA : Common.Color.Format.RGB); 1873 outText = outColor.asString(outColor.hasAlpha() ? Common.Color.Format.RGBA : Common.Color.Format.RGB);
1879 return outText || text; 1874 return outText || text;
1880 } 1875 }
1881 1876
1882 /** 1877 /**
1878 * @param {!Common.Color} color
1879 * @param {!UI.ThemeSupport.ColorUsage} colorUsage
1880 * @return {!Common.Color}
1881 */
1882 patchColor(color, colorUsage) {
1883 var hsla = color.hsla();
1884 this._patchHSLA(hsla, colorUsage);
1885 var rgba = [];
1886 Common.Color.hsl2rgb(hsla, rgba);
1887 return new Common.Color(rgba, color.format());
1888 }
1889
1890 /**
1883 * @param {!Array<number>} hsla 1891 * @param {!Array<number>} hsla
1884 * @param {!UI.ThemeSupport.ColorUsage} colorUsage 1892 * @param {!UI.ThemeSupport.ColorUsage} colorUsage
1885 */ 1893 */
1886 _patchHSLA(hsla, colorUsage) { 1894 _patchHSLA(hsla, colorUsage) {
1887 var hue = hsla[0]; 1895 var hue = hsla[0];
1888 var sat = hsla[1]; 1896 var sat = hsla[1];
1889 var lit = hsla[2]; 1897 var lit = hsla[2];
1890 var alpha = hsla[3]; 1898 var alpha = hsla[3];
1891 1899
1892 switch (this._themeName) { 1900 switch (this._themeName) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 */ 2071 */
2064 constructor(message, okCallback, cancelCallback) { 2072 constructor(message, okCallback, cancelCallback) {
2065 super(true); 2073 super(true);
2066 this.registerRequiredCSS('ui/confirmDialog.css'); 2074 this.registerRequiredCSS('ui/confirmDialog.css');
2067 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message; 2075 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message;
2068 var buttonsBar = this.contentElement.createChild('div', 'button'); 2076 var buttonsBar = this.contentElement.createChild('div', 'button');
2069 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback )); 2077 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback ));
2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback)); 2078 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback));
2071 } 2079 }
2072 }; 2080 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartNetworkDataProvider.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698