haikuwebkit/LayoutTests/inspector/model/color.html

702 lines
34 KiB
HTML
Raw Permalink Normal View History

<!doctype html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function test()
{
function formatToString(format) {
switch (format) {
case WI.Color.Format.Original:
return "Original";
case WI.Color.Format.Keyword:
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
return "Keyword";
case WI.Color.Format.HEX:
return "HEX";
case WI.Color.Format.ShortHEX:
return "Short HEX";
case WI.Color.Format.HEXAlpha:
return "HEX with Alpha";
case WI.Color.Format.ShortHEXAlpha:
return "Short HEX with Alpha";
case WI.Color.Format.RGB:
return "RGB";
case WI.Color.Format.RGBA:
return "RGBA";
case WI.Color.Format.HSL:
return "HSL";
case WI.Color.Format.HSLA:
return "HSLA";
case WI.Color.Format.ColorFunction:
return "Function";
default:
return "Unexpected format";
}
}
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
let suite = InspectorTest.createSyncSuite("WI.Color");
suite.addTestCase({
name: "WI.Color.fromString",
description: "Test we can detect colors from strings.",
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test() {
function testGood(string, expectedFormat) {
let color = WI.Color.fromString(string);
InspectorTest.assert(color instanceof WI.Color, `'${string}' should be detected`);
InspectorTest.assert(color.format === expectedFormat, `'${string}' was the expected '${formatToString(expectedFormat)}' format`);
InspectorTest.log(`"${string}" resolves to "${color.toString()}"`);
}
function testBad(string) {
let color = WI.Color.fromString(string);
InspectorTest.expectNull(color, `'${string}' should not be detected`);
if (color)
InspectorTest.log(`'${string}' detected with format '${formatToString(color.format)}'`);
}
testGood("#000", WI.Color.Format.ShortHEX);
testGood("#a0A", WI.Color.Format.ShortHEX);
testGood("#000000", WI.Color.Format.HEX);
testGood("#a0Aa0A", WI.Color.Format.HEX);
testGood("#0000", WI.Color.Format.ShortHEXAlpha);
testGood("#a0Af", WI.Color.Format.ShortHEXAlpha);
testGood("#00000000", WI.Color.Format.HEXAlpha);
testGood("#a0Aa0Aff", WI.Color.Format.HEXAlpha);
testGood("rgb(10,20,30)", WI.Color.Format.RGB);
testGood("RGB(10,20,30)", WI.Color.Format.RGB);
testGood("rgb( 10 , 20 , 30 )", WI.Color.Format.RGB);
testGood("rgb(999, 999, 999)", WI.Color.Format.RGB);
testGood("rgb(10 20 30)", WI.Color.Format.RGB);
testGood("RGB(10 20 30)", WI.Color.Format.RGB);
testGood("rgb( 10 20 30 )", WI.Color.Format.RGB);
testGood("rgb(999 999 999)", WI.Color.Format.RGB);
testGood("rgb(10,20,30,40)", WI.Color.Format.RGBA);
testGood("RGB(10,20,30,40)", WI.Color.Format.RGBA);
testGood("rgb( 10 , 20 , 30 , 40 )", WI.Color.Format.RGBA);
testGood("rgb(999, 999, 999, 999)", WI.Color.Format.RGBA);
testGood("rgb(10,20,30,40%)", WI.Color.Format.RGBA);
testGood("RGB(10,20,30,40%)", WI.Color.Format.RGBA);
testGood("rgb( 10 , 20 , 30 , 40% )", WI.Color.Format.RGBA);
testGood("rgb(999, 999, 999, 999%)", WI.Color.Format.RGBA);
testGood("rgb(10 20 30 / 40)", WI.Color.Format.RGBA);
testGood("RGB(10 20 30 / 40)", WI.Color.Format.RGBA);
testGood("rgb( 10 20 30 / 40 )", WI.Color.Format.RGBA);
testGood("rgb(999 999 999 / 999)", WI.Color.Format.RGBA);
testGood("rgb(10 20 30 / 40%)", WI.Color.Format.RGBA);
testGood("RGB(10 20 30 / 40%)", WI.Color.Format.RGBA);
testGood("rgb( 10 20 30 / 40% )", WI.Color.Format.RGBA);
testGood("rgb(999 999 999 / 999%)", WI.Color.Format.RGBA);
testGood("rgba(10,20,30,40)", WI.Color.Format.RGBA);
testGood("RGBA(10,20,30,40)", WI.Color.Format.RGBA);
testGood("rgba( 10 , 20 , 30 , 40 )", WI.Color.Format.RGBA);
testGood("rgba(999, 999, 999, 999)", WI.Color.Format.RGBA);
testGood("rgba(10,20,30,40%)", WI.Color.Format.RGBA);
testGood("RGBA(10,20,30,40%)", WI.Color.Format.RGBA);
testGood("rgba( 10 , 20 , 30 , 40% )", WI.Color.Format.RGBA);
testGood("rgba(999, 999, 999, 999%)", WI.Color.Format.RGBA);
testGood("rgba(10 20 30 / 40)", WI.Color.Format.RGBA);
testGood("RGBA(10 20 30 / 40)", WI.Color.Format.RGBA);
testGood("rgba( 10 20 30 / 40 )", WI.Color.Format.RGBA);
testGood("rgba(999 999 999 / 999)", WI.Color.Format.RGBA);
testGood("rgba(10 20 30 / 40%)", WI.Color.Format.RGBA);
testGood("RGBA(10 20 30 / 40%)", WI.Color.Format.RGBA);
testGood("rgba( 10 20 30 / 40% )", WI.Color.Format.RGBA);
testGood("rgba(999 999 999 / 999%)", WI.Color.Format.RGBA);
testGood("rgb(10%,20%,30%)", WI.Color.Format.RGB);
testGood("RGB(10%,20%,30%)", WI.Color.Format.RGB);
testGood("rgb( 10% , 20% , 30% )", WI.Color.Format.RGB);
testGood("rgb(999%, 999%, 999%)", WI.Color.Format.RGB);
testGood("rgb(10% 20% 30%)", WI.Color.Format.RGB);
testGood("RGB(10% 20% 30%)", WI.Color.Format.RGB);
testGood("rgb( 10% 20% 30% )", WI.Color.Format.RGB);
testGood("rgb(999% 999% 999%)", WI.Color.Format.RGB);
testGood("rgb(10%,20%,30%,40)", WI.Color.Format.RGBA);
testGood("RGB(10%,20%,30%,40)", WI.Color.Format.RGBA);
testGood("rgb( 10% , 20% , 30% , 40 )", WI.Color.Format.RGBA);
testGood("rgb(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
testGood("rgb(10%,20%,30%,40%)", WI.Color.Format.RGBA);
testGood("RGB(10%,20%,30%,40%)", WI.Color.Format.RGBA);
testGood("rgb( 10% , 20% , 30% , 40% )", WI.Color.Format.RGBA);
testGood("rgb(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
testGood("rgb(10% 20% 30% / 40)", WI.Color.Format.RGBA);
testGood("RGB(10% 20% 30% / 40)", WI.Color.Format.RGBA);
testGood("rgb( 10% 20% 30% / 40 )", WI.Color.Format.RGBA);
testGood("rgb(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
testGood("rgb(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
testGood("RGB(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
testGood("rgb( 10% 20% 30% / 40% )", WI.Color.Format.RGBA);
testGood("rgb(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
testGood("rgba(10%,20%,30%,40)", WI.Color.Format.RGBA);
testGood("RGBA(10%,20%,30%,40)", WI.Color.Format.RGBA);
testGood("rgba( 10% , 20% , 30% , 40 )", WI.Color.Format.RGBA);
testGood("rgba(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
testGood("rgba(10%,20%,30%,40%)", WI.Color.Format.RGBA);
testGood("RGBA(10%,20%,30%,40%)", WI.Color.Format.RGBA);
testGood("rgba( 10% , 20% , 30% , 40% )", WI.Color.Format.RGBA);
testGood("rgba(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
testGood("rgba(10% 20% 30% / 40)", WI.Color.Format.RGBA);
testGood("RGBA(10% 20% 30% / 40)", WI.Color.Format.RGBA);
testGood("rgba( 10% 20% 30% / 40 )", WI.Color.Format.RGBA);
testGood("rgba(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
testGood("rgba(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
testGood("RGBA(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
testGood("rgba( 10% 20% 30% / 40% )", WI.Color.Format.RGBA);
testGood("rgba(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
for (let unit of ["", "deg", "rad", "grad", "turn"]) {
testGood(`hsl(10${unit},20%,30%)`, WI.Color.Format.HSL);
testGood(`HSL(10${unit},20%,30%)`, WI.Color.Format.HSL);
testGood(`hsl( 10${unit} , 20% , 30% )`, WI.Color.Format.HSL);
testGood(`hsl(999${unit}, 999%, 999%)`, WI.Color.Format.HSL);
testGood(`hsl(10${unit} 20% 30%)`, WI.Color.Format.HSL);
testGood(`HSL(10${unit} 20% 30%)`, WI.Color.Format.HSL);
testGood(`hsl( 10${unit} 20% 30% )`, WI.Color.Format.HSL);
testGood(`hsl(999${unit} 999% 999%)`, WI.Color.Format.HSL);
testGood(`hsl(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
testGood(`HSL(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
testGood(`hsl( 10${unit} , 20% , 30% , 40 )`, WI.Color.Format.HSLA);
testGood(`hsl(999${unit}, 999%, 999%, 999)`, WI.Color.Format.HSLA);
testGood(`hsl(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
testGood(`HSL(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
testGood(`hsl( 10${unit} , 20% , 30% , 40% )`, WI.Color.Format.HSLA);
testGood(`hsl(999${unit}, 999%, 999%, 999%)`, WI.Color.Format.HSLA);
testGood(`hsl(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
testGood(`HSL(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
testGood(`hsl( 10${unit} 20% 30% / 40 )`, WI.Color.Format.HSLA);
testGood(`hsl(999${unit} 999% 999% / 999)`, WI.Color.Format.HSLA);
testGood(`hsl(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
testGood(`HSL(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
testGood(`hsl( 10${unit} 20% 30% / 40% )`, WI.Color.Format.HSLA);
testGood(`hsl(999${unit} 999% 999% / 999%)`, WI.Color.Format.HSLA);
testGood(`hsl(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
testGood(`HSL(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
testGood(`hsl( 10${unit} , 20% , 30% , 40 )`, WI.Color.Format.HSLA);
testGood(`hsl(999${unit}, 999%, 999%, 999)`, WI.Color.Format.HSLA);
testGood(`hsl(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
testGood(`HSL(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
testGood(`hsl( 10${unit} , 20% , 30% , 40% )`, WI.Color.Format.HSLA);
testGood(`hsl(999${unit}, 999%, 999%, 999%)`, WI.Color.Format.HSLA);
testGood(`hsla(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
testGood(`HSLA(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
testGood(`hsla( 10${unit} , 0% , 50% , 40 )`, WI.Color.Format.HSLA);
testGood(`hsla(999${unit}, 999%, 999%, 999)`, WI.Color.Format.HSLA);
testGood(`hsla(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
testGood(`HSLA(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
testGood(`hsla( 10${unit} , 20% , 30% , 40% )`, WI.Color.Format.HSLA);
testGood(`hsla(999${unit}, 999%, 999%, 999%)`, WI.Color.Format.HSLA);
testGood(`hsla(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
testGood(`HSLA(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
testGood(`hsla( 10${unit} 20% 30% / 40 )`, WI.Color.Format.HSLA);
testGood(`hsla(999${unit} 999% 999% / 999)`, WI.Color.Format.HSLA);
testGood(`hsla(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
testGood(`HSLA(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
testGood(`hsla( 10${unit} 20% 30% / 40% )`, WI.Color.Format.HSLA);
testGood(`hsla(999${unit} 999% 999% / 999%)`, WI.Color.Format.HSLA);
}
testGood("color(display-p3 0 1 0.5)", WI.Color.Format.ColorFunction);
testGood("COLOR(DISPLAY-P3 0 1 0.5)", WI.Color.Format.ColorFunction);
testGood("color(srgb 0.123 0.999 1)", WI.Color.Format.ColorFunction);
testGood("COLOR(SRGB 0.123 0.999 1)", WI.Color.Format.ColorFunction);
testGood("color( display-p3 0 1 0.5 )", WI.Color.Format.ColorFunction);
testGood("color(display-p3 999 999 999)", WI.Color.Format.ColorFunction);
testGood("color(srgb 0.123 0.999 1/0.5)", WI.Color.Format.ColorFunction);
testGood("COLOR(SRGB 0.123 0.999 1/0.5)", WI.Color.Format.ColorFunction);
testGood("color( display-p3 0 1 0.5/0.5)", WI.Color.Format.ColorFunction);
testGood("color(display-p3 999 999 999/999)", WI.Color.Format.ColorFunction);
testGood("color(srgb 0.123 0.999 1 / 0.5)", WI.Color.Format.ColorFunction);
testGood("COLOR(SRGB 0.123 0.999 1 / 0.5)", WI.Color.Format.ColorFunction);
testGood("color( display-p3 0 1 0.5 / 0.5)", WI.Color.Format.ColorFunction);
testGood("color(display-p3 999 999 999 / 999)", WI.Color.Format.ColorFunction);
testGood("color(srgb 0.123 0.999 1/33%)", WI.Color.Format.ColorFunction);
testGood("COLOR(SRGB 0.123 0.999 1/33%)", WI.Color.Format.ColorFunction);
testGood("color( display-p3 0 1 0.5/33%)", WI.Color.Format.ColorFunction);
testGood("color(display-p3 999 999 999/999%)", WI.Color.Format.ColorFunction);
testGood("color(srgb 0.123 0.999 1 / 33%)", WI.Color.Format.ColorFunction);
testGood("COLOR(SRGB 0.123 0.999 1 / 33%)", WI.Color.Format.ColorFunction);
testGood("color( display-p3 0 1 0.5 / 33%)", WI.Color.Format.ColorFunction);
testGood("color(display-p3 999 999 999 / 999%)", WI.Color.Format.ColorFunction);
InspectorTest.log("");
testBad(" #000 "); // whitespace
testBad("#rgb"); // bad hex
testBad("#1"); // 1
testBad("#12"); // 2
testBad("#12345"); // 5
testBad("#1234567"); // 7
testBad("#123456789"); // 9
testBad("rgb(255, 255, 255, 0.5, 1)"); // extra values
testBad("rgba(255, 255, 255, 0.5, 1)"); // extra values
testBad("hsl(0, 0%, 50%, 1, 2)"); // extra value
testBad("hsla(0, 0%, 50%, 1, 2)"); // extra values
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
testBad("superblue"); // not a keyword
testBad("color(display-p3 0 1)"); // 2
testBad("color(display-p3 0 1 2 4 5)"); // 5
// FIXME: currentColor?
// FIXME: Should we consider missing %s as bad? Currently we just strip them.
// testBad("hsl(0, 0, 50)"); // missing %s
// testBad("hsla(0, 0, 50, 1)"); // missing %s
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
}
});
suite.addTestCase({
name: "WI.Color properties",
description: "Test different color properties.",
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test() {
let color;
color = WI.Color.fromString("red");
InspectorTest.expectThat(color.alpha === 1, "'red' should have alpha of 1.");
InspectorTest.expectThat(color.simple === true, "'red' should be simple.");
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
InspectorTest.expectThat(color.isKeyword() === true, "'red' should be a keyword.");
InspectorTest.expectShallowEqual(color.rgb, [255, 0, 0], "'red' has rgb of [255, 0, 0].");
InspectorTest.expectShallowEqual(color.rgba, [255, 0, 0, 1], "'red' has rgba of [255, 0, 0, 1].");
InspectorTest.expectShallowEqual(color.hsl, [0, 100, 50], "'red' has hsl of [0, 100, 50].");
InspectorTest.expectShallowEqual(color.hsla, [0, 100, 50, 1], "'red' has hsla of [0, 100, 50, 1].");
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === true, "'red' should be serializable as a short Hex");
color = WI.Color.fromString("transparent");
InspectorTest.expectThat(color.alpha === 0, "'transparent' should have alpha of 0.");
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
InspectorTest.expectThat(color.simple === false, "'transparent' should not be simple.");
InspectorTest.expectThat(color.isKeyword() === true, "'transparent' should be a keyword.");
InspectorTest.expectShallowEqual(color.rgb, [0, 0, 0], "'transparent' has rgb of [0, 0, 0].");
InspectorTest.expectShallowEqual(color.rgba, [0, 0, 0, 0], "'transparent' has rgba of [0, 0, 0, 0].");
InspectorTest.expectShallowEqual(color.hsl, [0, 0, 0], "'transparent' has hsl of [0, 0, 0].");
InspectorTest.expectShallowEqual(color.hsla, [0, 0, 0, 0], "'transparent' has hsla of [0, 0, 0, 0].");
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === true, "'transparent' should be serializable as a short Hex");
color = WI.Color.fromString("#11122233");
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
InspectorTest.expectThat(color.alpha !== 0, "'#11122233' should not have alpha of 0.");
InspectorTest.expectThat(color.simple === false, "'#11122233' should be not be simple.");
InspectorTest.expectThat(color.isKeyword() === false, "'#11122233' should not be a keyword.");
InspectorTest.expectShallowEqual(color.rgba, [17, 18, 34, 0.2], "'#11122233' has rgba of [17, 18, 34, 0.2].");
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
InspectorTest.expectShallowEqual(color.hsla.map((value) => value.maxDecimals(2)), [236.47, 33.33, 10, 0.2], "'#11122233' has hsla of [236.47, 33.33, 10, 0.2].");
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === false, "'#11122233' should not be serializable as a short Hex");
color = WI.Color.fromString("#11223344");
InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === true, "'#11223344' should be serializable as a short Hex");
color = WI.Color.fromString("#11223345");
InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === false, "'#11223345' should not be serializable as a short Hex");
color = WI.Color.fromString("color(display-p3 0 1 0.5)");
InspectorTest.expectThat(color.alpha === 1, "'color(display-p3 0 1 0.5)' color should have a default alpha of 1");
InspectorTest.expectThat(color.isKeyword() === false, "color function is not a keyword");
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
InspectorTest.expectShallowEqual(color.normalizedRGB, [0, 1, 0.5], "'color(display-p3 0 1 0.5)' has normalized RGB of [0, 1, 0.5]");
InspectorTest.expectShallowEqual(color.normalizedRGBA, [0, 1, 0.5, 1], "'color(display-p3 0 1 0.5)' has normalized RGBA of [0, 1, 0.5, 1]");
color = WI.Color.fromString("color(display-p3 0 1 0.5 / 0.3)");
InspectorTest.expectThat(color.alpha === 0.3, "'color(display-p3 0 1 0.5 / 0.3)' should have an alpha of 0.3");
InspectorTest.expectThat(color.isKeyword() === false, "color function is not a keyword");
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
InspectorTest.expectShallowEqual(color.normalizedRGB, [0, 1, 0.5], "'color(display-p3 0 1 0.5 / 0.3)' has normalized RGB of [0, 1, 0.5]");
InspectorTest.expectShallowEqual(color.normalizedRGBA, [0, 1, 0.5, 0.3], "'color(display-p3 0 1 0.5 / 0.3)' has normalized RGBA of [0, 1, 0.5, 0.3]");
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
}
});
suite.addTestCase({
name: "WI.Color from components",
description: "Test different three- and four-component colors.",
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test() {
function test(color, components) {
InspectorTest.log(`Check components for color '${color.toString()}'.`);
for (let key in components) {
let value = components[key];
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
InspectorTest.expectShallowEqual(color[key].map((value) => value.maxDecimals(2)), value, `Should have ${key} of ${JSON.stringify(value)}.`);
}
}
test(new WI.Color(WI.Color.Format.RGB, [255, 0, 0]), {
rgb: [255, 0, 0],
rgba: [255, 0, 0, 1],
hsl: [0, 100, 50],
hsla: [0, 100, 50, 1],
});
test(new WI.Color(WI.Color.Format.RGBA, [128, 128, 128, 0.5]), {
rgb: [128, 128, 128],
rgba: [128, 128, 128, 0.5],
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
hsl: [0, 0, 50.2],
hsla: [0, 0, 50.2, 0.5],
});
test(new WI.Color(WI.Color.Format.HSL, [0, 0, 50]), {
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
rgb: [127.5, 127.5, 127.5],
rgba: [127.5, 127.5, 127.5, 1],
hsl: [0, 0, 50],
hsla: [0, 0, 50, 1],
});
test(new WI.Color(WI.Color.Format.HSLA, [0, 0, 50, 0.5]), {
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
rgb: [127.5, 127.5, 127.5],
rgba: [127.5, 127.5, 127.5, 0.5],
hsl: [0, 0, 50],
hsla: [0, 0, 50, 0.5],
});
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
}
});
suite.addTestCase({
name: "WI.Color.prototype.nextFormat",
description: "Test we can cycle through color formats for different colors.",
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test() {
function test(string, phases) {
let color = WI.Color.fromString(string);
color.format = WI.Color.Format.Original;
let pass = true;
for (let expectedNextFormat of phases) {
let nextFormat = color.nextFormat();
InspectorTest.assert(nextFormat === expectedNextFormat, `Next format '${formatToString(nextFormat)}' was not the expected '${formatToString(expectedNextFormat)}'`);
pass = pass && nextFormat === expectedNextFormat;
color.format = nextFormat;
}
InspectorTest.expectThat(pass, `All format phases of '${string}' should be as expected.`);
}
// All with alpha.
test("transparent", [
WI.Color.Format.RGBA,
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
WI.Color.Format.ColorFunction,
WI.Color.Format.HSLA,
WI.Color.Format.Keyword,
WI.Color.Format.ShortHEXAlpha,
WI.Color.Format.HEXAlpha,
]);
// All without alpha.
test("red", [
WI.Color.Format.RGB,
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
WI.Color.Format.ColorFunction,
WI.Color.Format.HSL,
WI.Color.Format.Keyword,
WI.Color.Format.ShortHEX,
WI.Color.Format.HEX,
]);
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
// No short hex or keyword.
test("rgb(100, 150, 200)", [
WI.Color.Format.RGB,
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
WI.Color.Format.ColorFunction,
WI.Color.Format.HSL,
WI.Color.Format.HEX,
]);
Web Inspector: add context menu items to switch CSS color property value syntax between RGB, HSL, etc https://bugs.webkit.org/show_bug.cgi?id=151918 Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-04 Reviewed by Timothy Hatcher. Source/WebInspectorUI: Created a ColorSwatch class to hold all functionality for color swatches, allowing all context menu and popover events to be centralized. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Main.html: * UserInterface/Models/Color.js: Changed all 'var' to 'let' and 'nickname' to 'keyword' as per the spec. Mostly mechanical changes. (WebInspector.Color.prototype.isKeyword): Looks at the RGB values of each keyword to see if the current color matches any of them. (WebInspector.Color.prototype.canBeSerializedAsShortHEX): Fixed to account for alpha values, since HEXAlpha is now supported. * UserInterface/Views/CSSStyleDeclarationTextEditor.css: (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch): Deleted. (@media (-webkit-max-device-pixel-ratio: 1)): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:hover > span): Deleted. (.css-style-text-editor > .CodeMirror .CodeMirror-lines .color-swatch:active > span): Deleted. * UserInterface/Views/CSSStyleDeclarationTextEditor.js: (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._createColorSwatches): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged.update): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchColorChanged): (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror): Deleted. (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked): Deleted. * UserInterface/Views/ColorSwatch.css: Copied from Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css. (.color-swatch): (@media (-webkit-max-device-pixel-ratio: 1)): (.color-swatch > span): (.color-swatch:hover > span): (.color-swatch:active > span): * UserInterface/Views/ColorSwatch.js: Added. (WebInspector.ColorSwatch): (WebInspector.ColorSwatch.prototype.get element): (WebInspector.ColorSwatch.prototype.set color): (WebInspector.ColorSwatch.prototype.get color): (WebInspector.ColorSwatch.prototype._colorSwatchClicked): (WebInspector.ColorSwatch.prototype._colorPickerColorDidChange): (WebInspector.ColorSwatch.prototype._handleContextMenuEvent): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat.hexMatchesCurrentColor): (WebInspector.ColorSwatch.prototype._getNextValidHEXFormat): Loops through the list of HEX formats to find the first format that is valid for the current color in the list after the current format. (WebInspector.ColorSwatch.prototype._updateSwatch): * UserInterface/Views/VisualStyleColorPicker.css: (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch): (.visual-style-property-container.input-color-picker > .visual-style-property-value-container > .color-swatch > span): * UserInterface/Views/VisualStyleColorPicker.js: (WebInspector.VisualStyleColorPicker): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchColorChanged): (WebInspector.VisualStyleColorPicker.prototype._updateColorSwatch): (WebInspector.VisualStyleColorPicker.prototype._colorSwatchClicked): Deleted. (WebInspector.VisualStyleColorPicker.prototype._colorPickerColorDidChange): Deleted. LayoutTests: * inspector/model/color-expected.html: * inspector/model/color.html: Changed "nickname" to "keyword". Canonical link: https://commits.webkit.org/170806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-05 01:48:00 +00:00
// No short hex alpha or keyword.
test("rgba(100, 150, 200, 0.5)", [
WI.Color.Format.RGBA,
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
WI.Color.Format.ColorFunction,
WI.Color.Format.HSLA,
WI.Color.Format.HEXAlpha,
]);
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
}
});
suite.addTestCase({
name: "WI.Color.prototype.toString",
description: "Test the different toString outputs.",
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test() {
let color;
function test(expected, format) {
let pass = color.toString(format) === expected;
InspectorTest.expectThat(pass, `Color as '${formatToString(format)}' should be '${expected}'`);
if (!pass) InspectorTest.log("WAS: " + color.toString(format));
}
// A color with all formats.
color = WI.Color.fromString("RED");
test("RED", WI.Color.Format.Original);
test("red", WI.Color.Format.Keyword);
test("#f00", WI.Color.Format.ShortHEX);
test("#ff0000", WI.Color.Format.HEX);
test("#f00f", WI.Color.Format.ShortHEXAlpha);
test("#ff0000ff", WI.Color.Format.HEXAlpha);
test("rgb(255, 0, 0)", WI.Color.Format.RGB);
test("rgba(255, 0, 0, 1)", WI.Color.Format.RGBA);
test("hsl(0, 100%, 50%)", WI.Color.Format.HSL);
test("hsla(0, 100%, 50%, 1)", WI.Color.Format.HSLA);
// A color which cannot be some formats, those fallback to something else.
color = WI.Color.fromString("rGbA( 100, 200, 255, 0.5 )");
test("rgba(100, 200, 255, 0.5)", WI.Color.Format.Original); // Original text ignored for some formats.
test("rgba(100, 200, 255, 0.5)", WI.Color.Format.Keyword); // fallback (rgba)
test("rgba(100, 200, 255, 0.5)", WI.Color.Format.ShortHEX); // fallback (rgba)
test("rgba(100, 200, 255, 0.5)", WI.Color.Format.HEX); // fallback (rgba)
test("#64c8ff80", WI.Color.Format.ShortHEXAlpha); // fallback (hex alpha)
test("#64c8ff80", WI.Color.Format.HEXAlpha);
test("rgba(100, 200, 255, 0.5)", WI.Color.Format.RGB); // fallback (rgba)
test("rgba(100, 200, 255, 0.5)", WI.Color.Format.RGBA);
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test("hsla(201.29, 100%, 69.61%, 0.5)", WI.Color.Format.HSL); // fallback (hsla)
test("hsla(201.29, 100%, 69.61%, 0.5)", WI.Color.Format.HSLA);
// FIXME: Should we clamp rgb(300, 300, 300) => rgb(255, 255, 255) in toStrings?
// FIXME: Should we always stash the original string, no matter how poor?
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
}
});
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
function testColorConversion(func, value, expected) {
let actual = func(...value);
InspectorTest.expectShallowEqual(actual, expected, `Should convert ${JSON.stringify(value)} to ${JSON.stringify(expected)}.`);
}
suite.addTestCase({
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
name: "WI.Color.rgb2hsl",
description: "Test conversion from RGB to HSL.",
test() {
testColorConversion(WI.Color.rgb2hsl, [0, 0, 0], [0, 0, 0]);
testColorConversion(WI.Color.rgb2hsl, [255, 255, 255], [0, 0, 100]);
testColorConversion(WI.Color.rgb2hsl, [255, 0, 0], [0, 100, 50]);
testColorConversion(WI.Color.rgb2hsl, [0, 255, 0], [120, 100, 50]);
testColorConversion(WI.Color.rgb2hsl, [0, 0, 255], [240, 100, 50]);
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
// Out-of-bounds and floating point inputs.
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
testColorConversion(WI.Color.rgb2hsl, [-1, -1, -1], [0, 0, 0]);
testColorConversion(WI.Color.rgb2hsl, [256, 256, 256], [0, 0, 100]);
testColorConversion(WI.Color.rgb2hsl, [254.9, 0, 0], [0, 100, 50]);
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
}
});
suite.addTestCase({
name: "WI.Color.hsl2rgb",
description: "Test conversion from HSL to RGB.",
test() {
testColorConversion(WI.Color.hsl2rgb, [0, 0, 0], [0, 0, 0]);
testColorConversion(WI.Color.hsl2rgb, [0, 0, 100], [255, 255, 255]);
testColorConversion(WI.Color.hsl2rgb, [0, 100, 50], [255, 0, 0]);
testColorConversion(WI.Color.hsl2rgb, [120, 100, 50], [0, 255, 0]);
testColorConversion(WI.Color.hsl2rgb, [240, 100, 50], [0, 0, 255]);
// Out-of-bounds.
testColorConversion(WI.Color.hsl2rgb, [-1, -1, -1], [0, 0, 0]);
testColorConversion(WI.Color.hsl2rgb, [361, 101, 50], [255, 0, 0]);
testColorConversion(WI.Color.hsl2rgb, [361, 101, 101], [255, 255, 255]);
return true;
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
}
});
suite.addTestCase({
name: "WI.Color.hsv2hsl",
description: "Test conversion from HSV to HSL.",
test() {
testColorConversion(WI.Color.hsv2hsl, [42, 100, 0], [42, 0, 0]);
testColorConversion(WI.Color.hsv2hsl, [42, 50, 100], [42, 100, 75]);
testColorConversion(WI.Color.hsv2hsl, [42, 100, 50], [42, 100, 25]);
testColorConversion(WI.Color.hsv2hsl, [42, 50, 50], [42, 33.33333333333333, 37.5]);
testColorConversion(WI.Color.hsv2hsl, [42, 100, 100], [42, 100, 50]);
// Out-of-bounds.
testColorConversion(WI.Color.hsv2hsl, [-1, -1, -1], [0, 0, 0]);
testColorConversion(WI.Color.hsv2hsl, [361, 101, 50], [360, 100, 25]);
testColorConversion(WI.Color.hsv2hsl, [361, 101, 101], [360, 100, 50]);
return true;
}
});
Web Inspector: Display color picker for p3 colors https://bugs.webkit.org/show_bug.cgi?id=203436 <rdar://problem/56635062> Reviewed by Brian Burg. Source/WebInspectorUI: For p3 colors, display ColorSquare with display-p3 gamut. Continue showing ColorSquare with sRGB gamut by default. * UserInterface/Base/Setting.js: * UserInterface/Models/Color.js: (WI.Color): (WI.Color.rgb2hsv): (WI.Color.hsv2rgb.fraction): (WI.Color.hsv2rgb): (WI.Color.prototype.get hsla): (WI.Color.prototype.isKeyword): * UserInterface/Views/ColorPicker.css: (.color-picker > .hue): (@media (color-gamut: p3)): (.color-picker.gamut-p3 > .hue): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): (WI.ColorPicker.prototype._handleFormatChange): Introduce `gamut` parameter. Previously, the only available `gamut` was sRGB. * UserInterface/Views/ColorSquare.css: (.color-square > .crosshair): Update the crosshair style to look better for both light and dark backgrounds. * UserInterface/Views/ColorSquare.js: (WI.ColorSquare): (WI.ColorSquare.prototype.get tintedColor): (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._setCrosshairPosition): (WI.ColorSquare.prototype._updateBaseColor): (WI.ColorSquare.prototype._updateCrosshairBackground): * UserInterface/Views/InlineSwatch.js: Make p3 color picker a preview (e.g. STP-only) feature. LayoutTests: Add tests for WI.Color.rgb2hsv and WI.Color.hsv2rgb. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217274@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-11-07 02:53:40 +00:00
suite.addTestCase({
name: "WI.Color.rgb2hsv",
description: "Test conversion from RGB to HSV.",
test() {
testColorConversion(WI.Color.rgb2hsv, [0, 0, 0], [0, 0, 0]);
testColorConversion(WI.Color.rgb2hsv, [1, 1, 1], [0, 0, 100]);
testColorConversion(WI.Color.rgb2hsv, [1, 0, 0], [0, 100, 100]);
testColorConversion(WI.Color.rgb2hsv, [0, 1, 0], [120, 100, 100]);
testColorConversion(WI.Color.rgb2hsv, [0, 0, 1], [240, 100, 100]);
// Out-of-bounds.
testColorConversion(WI.Color.rgb2hsv, [-1, -1, -1], [0, 0, 0]);
testColorConversion(WI.Color.rgb2hsv, [1.1, 1.1, 1.1], [0, 0, 100]);
return true;
}
});
suite.addTestCase({
name: "WI.Color.hsv2rgb",
description: "Test conversion from HSV to RGB.",
test() {
testColorConversion(WI.Color.hsv2rgb, [42, 100, 0], [0, 0, 0]);
testColorConversion(WI.Color.hsv2rgb, [42, 50, 100], [1, 0.8500000000000001, 0.5]);
testColorConversion(WI.Color.hsv2rgb, [42, 100, 50], [0.5, 0.3500000000000001, 0]);
testColorConversion(WI.Color.hsv2rgb, [42, 50, 50], [0.5, 0.42500000000000004, 0.25]);
testColorConversion(WI.Color.hsv2rgb, [42, 100, 100], [1, 0.7000000000000002, 0]);
// Out-of-bounds.
testColorConversion(WI.Color.hsv2rgb, [-1, -1, -1], [0, 0, 0]);
testColorConversion(WI.Color.hsv2rgb, [361, 101, 50], [0.5, 0, 0]);
testColorConversion(WI.Color.hsv2rgb, [361, 101, 101], [1, 0, 0]);
return true;
}
});
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
suite.addTestCase({
name: "WI.Color.cmyk2rgb",
description: "Test conversion from CMYK to RGB.",
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test() {
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
testColorConversion(WI.Color.cmyk2rgb, [0, 0, 0, 1], [0, 0, 0]);
testColorConversion(WI.Color.cmyk2rgb, [1, 0, 0, 0], [0, 255, 255]);
testColorConversion(WI.Color.cmyk2rgb, [0, 1, 0, 0], [255, 0, 255]);
testColorConversion(WI.Color.cmyk2rgb, [0, 0, 1, 0], [255, 255, 0]);
testColorConversion(WI.Color.cmyk2rgb, [0, 0, 0, 0], [255, 255, 255]);
// Out-of-bounds inputs.
testColorConversion(WI.Color.cmyk2rgb, [2, 0, 0, 0], [0, 255, 255]);
testColorConversion(WI.Color.cmyk2rgb, [-1, 0, 0, 0], [255, 255, 255]);
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
}
});
suite.addTestCase({
name: "WI.Color.normalized2rgb",
description: "Test conversion from normalized RGB to RGB.",
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
test() {
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
testColorConversion(WI.Color.normalized2rgb, [0, 0, 0], [0, 0, 0]);
testColorConversion(WI.Color.normalized2rgb, [1, 1, 1], [255, 255, 255]);
testColorConversion(WI.Color.normalized2rgb, [0.24, 0.25, 0.26], [61, 64, 66]); // Values chosen to test round up/down behavior.
// Out-of-bounds inputs.
testColorConversion(WI.Color.normalized2rgb, [2, 0, 0], [255, 0, 0]);
testColorConversion(WI.Color.normalized2rgb, [-1, 0, 0], [0, 0, 0]);
Web Inspector: conic-gradient color picker doesn't accurately show color when saturation value is not 100% https://bugs.webkit.org/show_bug.cgi?id=192729 <rdar://problem/46746815> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Rework `WI.ColorWheel` to use similar canvas drawing logic as `WI.LegacyColorWheel` so that it's able to adjust the saturation value as the pixels gets closer to the center. * UserInterface/Models/Color.js: (WI.Color.rgb2hsl): Added. (WI.Color.hsl2rgb): Added. (WI.Color.cmyk2rgb): (WI.Color.prototype.isKeyword): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._rgbaToHSLA): (WI.Color.prototype._hslaToRGBA): (WI.Color.rgb2hsv): Deleted. (WI.Color.hsv2rgb): Deleted. (WI.Color.prototype._rgbToHSL): Deleted. (WI.Color.prototype._hslToRGB): Deleted. Adjust the conversion functions of `WI.Color` to be more accurate. * UserInterface/Views/ColorWheel.js: (WI.ColorWheel): (WI.ColorWheel.prototype.set dimension): (WI.ColorWheel.prototype.set brightness): (WI.ColorWheel.prototype.get tintedColor): (WI.ColorWheel.prototype.set tintedColor): (WI.ColorWheel.prototype._updateColorForMouseEvent): (WI.ColorWheel.prototype._updateCanvas): Added. (WI.ColorWheel.prototype._updateGradient): Deleted. * UserInterface/Views/ColorWheel.css: (.color-wheel > canvas): Added. (.color-wheel > .gradient): Deleted. * UserInterface/Views/ColorPicker.js: (WI.ColorPicker): (WI.ColorPicker.prototype.set color): (WI.ColorPicker.prototype.sliderValueDidChange): (WI.ColorPicker.prototype._updateSliders): (WI.ColorPicker.prototype._showColorComponentInputs): (WI.ColorPicker.supportsConicGradient): Deleted. * UserInterface/Main.html: * UserInterface/Views/LegacyColorWheel.js: Removed. LayoutTests: * inspector/model/color.html: * inspector/model/color-expected.txt: Canonical link: https://commits.webkit.org/207627@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-03 21:58:23 +00:00
return true;
Web Inspector: Canvas: recording parameters that include colors should show an InlineSwatch (2D canvas) https://bugs.webkit.org/show_bug.cgi?id=176822 <rdar://problem/34402170> Reviewed by Devin Rousso. Source/WebInspectorUI: Show inline swatches in the canvas recording action and state sidebars. * UserInterface/Models/Color.js: Added helpers for dealing with CMYK and normalized RGB. The latter is for RGB components scaled to the range [0, 1]. Also improved handling for 8-bit channel values. (WI.Color.rgb2hsv): (WI.Color.cmyk2rgb): (WI.Color.normalized2rgb): (WI.Color._eightBitChannel): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._componentToHexValue): (WI.Color.prototype._rgbToHSL): (WI.Color.prototype._componentToNumber): Deleted. Replaced by _eightBitChannel. * UserInterface/Models/RecordingAction.js: (WI.RecordingAction): (WI.RecordingAction.prototype.getColorParameters): Get a subset of parameters that describe a color. This can be an array containing one value (e.g. fillStyle), or multiple values, as is the case with non-standard API functions that describe color using multiple parameters (e.g. setFillColor). * UserInterface/Views/InlineSwatch.css: (.inline-swatch:not(.read-only):hover > span): (.inline-swatch:hover > span): Deleted. * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): Read-only colors shouldn't show a context menu or hover effects. * UserInterface/Views/RecordingActionTreeElement.css: (.tree-outline:matches(:focus, .force-focus) .item.action > .titles .parameters > .inline-swatch): * UserInterface/Views/RecordingActionTreeElement.js: (WI.RecordingActionTreeElement._generateDOM.createParameterElement): (WI.RecordingActionTreeElement._generateDOM): (WI.RecordingActionTreeElement._createSwatchForColorParameters): * UserInterface/Views/RecordingStateDetailsSidebarPanel.css: (.sidebar > .panel.details.recording-state > .content > .data-grid .inline-swatch): * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.isColorProperty): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D.createInlineSwatch): (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): (WI.RecordingStateDetailsSidebarPanel): LayoutTests: Add tests for color space conversions. * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/193424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-15 19:50:40 +00:00
}
});
suite.addTestCase({
name: "WI.Color.displayP3toSRGB",
description: "Test conversion from display-P3 gamut to sRGB.",
test() {
testColorConversion(WI.Color.displayP3toSRGB, [0, 0, 0], [0, 0, 0]);
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
testColorConversion(WI.Color.displayP3toSRGB, [1, 1, 1], [0.9999, 1, 1.0001]);
testColorConversion(WI.Color.displayP3toSRGB, [1, 0, 0], [1.093, -0.5434, -0.2538]);
testColorConversion(WI.Color.displayP3toSRGB, [0, 1, 0], [-2.9058, 1.0183, -1.0162]);
testColorConversion(WI.Color.displayP3toSRGB, [0, 0, 1], [0, 0, 1.0421]);
// Out-of-bounds inputs.
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
testColorConversion(WI.Color.displayP3toSRGB, [2, 0, 0], [1.093, -0.5434, -0.2538]);
testColorConversion(WI.Color.displayP3toSRGB, [-1, 0, 0], [0, 0, 0]);
return true;
}
});
Web Inspector: Provide UI to convert between sRGB and p3 color spaces https://bugs.webkit.org/show_bug.cgi?id=203534 <rdar://problem/56688523> Reviewed by Devin Rousso. Source/WebInspectorUI: Add context menus: - "Convert to sRGB" and "Clamp to sRGB" for p3 colors, such as `color(display-p3 0 1 0)`. - "Convert to Display-P3" for sRGB colors, such as `rgb(0, 255, 0)`. Shift-clicking the color swatch of sRGB colors now goes through the color function syntax as well. Shift-clicking the color swatch of Display-P3 colors converts the color to sRGB when it can be lossless. When the convertion cannot be lossless, Web Inspector beeps. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Base/Utilities.js: * UserInterface/Models/Color.js: (WI.Color): Introduce `_normalizedRGB` property, which stores rgb values from 0 to 1. Previously, `_rgba` stored values from 0 to 1 for color function format, and from 0 to 255 otherwise. That required format checks before every `rgb` value access and resulted in silent errors when the values were in the wrong format. Store alpha as a separate property to simplify format conversion. Previously, alpha was duplicated between `_rgba` and `_hsla`. (WI.Color.displayP3toSRGB): (WI.Color.srgbToDisplayP3): Added. (WI.Color.prototype.nextFormat): (WI.Color.prototype.get rgb): (WI.Color.prototype.get hsl): (WI.Color.prototype.get normalizedRGB): (WI.Color.prototype.get rgba): (WI.Color.prototype.get hsla): (WI.Color.prototype.get normalizedRGBA): (WI.Color.prototype.get gamut): (WI.Color.prototype.set gamut): (WI.Color.prototype.copy): (WI.Color.prototype.isKeyword): (WI.Color.prototype.isOutsideSRGB): Added. (WI.Color.prototype.canBeSerializedAsShortHEX): (WI.Color.prototype._toKeywordString): (WI.Color.prototype._toShortHEXString): (WI.Color.prototype._toHEXString): (WI.Color.prototype._toShortHEXAlphaString): (WI.Color.prototype._toHEXAlphaString): (WI.Color.prototype._toRGBString): (WI.Color.prototype._toRGBAString): (WI.Color.prototype._toFunctionString): Limit the values to 4 decimals. (WI.Color.prototype._toHSLString): (WI.Color.prototype._toHSLAString): (WI.Color.prototype._hslToRGB): * UserInterface/Views/ColorPicker.js: (WI.ColorPicker.prototype._updateColor): (WI.ColorPicker.prototype._updateOpacitySlider): * UserInterface/Views/ColorSquare.css: (.color-square > .svg-root): (.color-square > .svg-root > .srgb-edge): (.color-square > .srgb-label): (.color-square > .srgb-label:hover): (.color-square > .srgb-label:hover + .svg-root > .srgb-edge): (@media (-webkit-device-pixel-ratio: 1)): (.color-square > .srgb-edge): * UserInterface/Views/ColorSquare.js: (WI.ColorSquare.prototype.set tintedColor): (WI.ColorSquare.prototype._drawSRGBOutline): (WI.ColorSquare): * UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch): (WI.InlineSwatch.prototype._updateSwatch): (WI.InlineSwatch.prototype._allowShiftClickColor): Added. (WI.InlineSwatch.prototype._handleContextMenuEvent): LayoutTests: * inspector/model/color-expected.txt: * inspector/model/color.html: Canonical link: https://commits.webkit.org/217986@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-03 01:46:11 +00:00
suite.addTestCase({
name: "WI.Color.srgbToDisplayP3",
description: "Test conversion from sRGB gamut to display-P3.",
test() {
testColorConversion(WI.Color.srgbToDisplayP3, [0, 0, 0], [0, 0, 0]);
testColorConversion(WI.Color.srgbToDisplayP3, [1, 1, 1], [1.0001, 1, 0.9999]);
testColorConversion(WI.Color.srgbToDisplayP3, [1, 0, 0], [0.9176, 0.2003, 0.1386]);
testColorConversion(WI.Color.srgbToDisplayP3, [0, 1, 0], [0.4584, 0.9853, 0.2983]);
testColorConversion(WI.Color.srgbToDisplayP3, [0, 0, 1], [0, 0, 0.9595]);
// Out-of-bounds inputs.
testColorConversion(WI.Color.srgbToDisplayP3, [2, 0, 0], [0.9176, 0.2003, 0.1386]);
testColorConversion(WI.Color.srgbToDisplayP3, [-1, 0, 0], [0, 0, 0]);
return true;
}
});
suite.addTestCase({
name: "WI.Color.isOutsideSRGB",
description: "Test conversion from sRGB gamut to display-P3.",
test() {
function test(string) {
let color = WI.Color.fromString(string);
let result = color.isOutsideSRGB();
InspectorTest.log(`"${string}" is ${result ? "outside" : "inside"} sRGB.`);
}
test("color(display-p3 0 0 0)");
test("color(display-p3 1 1 1)");
test("color(display-p3 0.04 0.14 0.016)"); // Barely inside sRGB. Values chosen to test rounding behavior.
test("color(display-p3 1 0 0)");
test("color(display-p3 0.93 0.353 0.353)"); // Barely outside sRGB.
return true;
}
});
Web Inspector: implement the basics for showing/hiding grid overlays https://bugs.webkit.org/show_bug.cgi?id=221062 Reviewed by Devin Rousso. Source/JavaScriptCore: Add new commands to show and hide CSS grid overlays: - DOM.showGridOverlay - DOM.hideGridOverlay * inspector/protocol/DOM.json: Source/WebCore: Implement backend commands for showing and hiding CSS grid overlays. This patch draws a very simplistic grid overlay. Support for the various grid overlay options will be added in later patches. New test: inspector/dom/showGridOverlay.html * inspector/InspectorOverlay.h: (WebCore::InspectorOverlay::gridOverlayCount const): Added, for testing only. * inspector/InspectorOverlay.cpp: (WebCore::InspectorOverlay::paint): (WebCore::InspectorOverlay::shouldShowOverlay const): Hook up the painting of any active grid overlays. (WebCore::InspectorOverlay::setGridOverlayForNode): (WebCore::InspectorOverlay::clearGridOverlayForNode): (WebCore::InspectorOverlay::clearAllGridOverlays): Maintain the list of active grid overlays. A node can only have one grid overlay at a time. (WebCore::InspectorOverlay::drawNodeHighlight): Add a note about why grid overlays are not considered when calculating the ruler exclusion area. (WebCore::InspectorOverlay::drawGridOverlay): Added. This drawing code exists to flesh out the rest of this patch, and is obviously incomplete. Draw grid lines that extend to the edge of the viewport, equivalent to `config.showExtendedGridLines = true`. * inspector/agents/InspectorDOMAgent.h: * inspector/agents/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::showGridOverlay): (WebCore::InspectorDOMAgent::hideGridOverlay): Translate protocol commands into InspectorOverlay method calls. * inspector/InspectorController.h: * inspector/InspectorController.cpp: (WebCore::InspectorController::gridOverlayCount const): Added. This is used for testing purposes only. * testing/Internals.h: * testing/Internals.idl: * testing/Internals.cpp: (WebCore::Internals::inspectorGridOverlayCount): Added. Source/WebInspectorUI: Expose new DOM.showGridOverlay and DOM.hideGridOverlay commands via WI.DOMNode. Add initial engineering UI to toggle grid overlays. New methods are covered by a new test: inspector/dom/showGridOverlay.html Additions to WI.DOMManager.prototype.requestDocument are covered by existing tests (callback case) and a new test (promise case). Additions to WI.Color are covered by a new test case in: inspector/model/color.html * UserInterface/Controllers/DOMManager.js: (WI.DOMManager.prototype.requestDocument): (WI.DOMManager.prototype._requestDocumentWithPromise): Drive-by: upgrade requestDocument() to return a promise if no callback argument was passed. This is used by a new test. * UserInterface/Models/Color.js: (WI.Color.prototype.toProtocol): Added. The protocol object is DOM.RGBAColor, which is the same thing as WI.Color.Format.RGBA. * UserInterface/Models/DOMNode.js: (WI.DOMNode.prototype.showGridOverlay): (WI.DOMNode.prototype.hideGridOverlay): Added. These are the methods that the rest of WebInspectorUI uses to interact with grid overlays for a particular node. Note that these methods return either an unsettled promise (from the agent call) or a rejected promise (in the case that the node is destroyed). This allows test cases to `await` before checking the grid overlay count. * UserInterface/Test/TestHarness.js: (TestHarness.prototype.expectException): Improve logging output when InspectorTest.expectException does not catch an exception. * UserInterface/Views/ContextMenuUtilities.js: Add some engineering-only context menu items for showing/hiding grid overlays to DOMTreeElements in the Elements Tab. These are in place for development purposes and should eventually be removed when no longer needed. LayoutTests: * inspector/dom/showGridOverlay-expected.txt: Added. * inspector/dom/showGridOverlay.html: Added. This test does not cover the actual drawing code. The drawing method will change a lot and is not easy to test currently. The new test covers the behavior of showGridOverlay/hideGridOverlay by querying how many grid overlays are active according to InspectorOverlay. * inspector/model/color-expected.txt: * inspector/model/color.html: Add a test case to exercise WI.Color.prototype.toProtocol(). * inspector/unit-tests/test-harness-expect-functions-async-expected.txt: Rebaseline results after adding more state dumping in the failure case for InspectorTest.expectException(). Canonical link: https://commits.webkit.org/233573@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-02 09:02:31 +00:00
suite.addTestCase({
name: "WI.Color.toProtocol",
description: "Test serialization of WI.Color into DOM.RGBAColor.",
test() {
function testInput(input, expected) {
let color = WI.Color.fromString(input);
let actual = color.toProtocol();
InspectorTest.expectShallowEqual(actual, expected, `Should convert ${input} to ${JSON.stringify(expected)}.`);
}
testInput("rgba(10,20,30,40)", {r: 10, g: 20, b: 30, a: 1});
testInput("rgb(10 20 30 / 40%)", {r: 10, g: 20, b: 30, a: 0.4});
testInput("#a0Aa0A", {r: 160, g: 170, b: 10, a: 1});
testInput("rgb(10% 20% 30% / 40%)", {r: 25.5, g: 51, b: 76.5, a: 0.4});
return true;
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for the WI.Color model object.</p>
</body>
</html>