| Index: third_party/WebKit/Source/devtools/front_end/components/Spectrum.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/components/Spectrum.js b/third_party/WebKit/Source/devtools/front_end/components/Spectrum.js
|
| index 2b96d791d26eb7b24dc33f70c08bf16f1857bed4..4d287e15344df4f7978f6145c9533de0119a7948 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/components/Spectrum.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/components/Spectrum.js
|
| @@ -90,7 +90,7 @@ WebInspector.Spectrum = function()
|
| // HEX display.
|
| this._hexContainer = this.contentElement.createChild("div", "spectrum-text spectrum-text-hex source-code");
|
| this._hexValue = this._hexContainer.createChild("input", "spectrum-text-value");
|
| - this._hexValue.maxLength = 9;
|
| + this._hexValue.maxLength = 7;
|
| this._hexValue.addEventListener("keydown", this._inputChanged.bind(this), false);
|
| this._hexValue.addEventListener("input", this._inputChanged.bind(this), false);
|
| this._hexValue.addEventListener("mousewheel", this._inputChanged.bind(this), false);
|
| @@ -165,8 +165,8 @@ WebInspector.Spectrum = function()
|
| var hsva = this._hsv.slice();
|
| hsva[3] = Number.constrain(newAlpha, 0, 1);
|
| var colorFormat = undefined;
|
| - if (hsva[3] !== 1 && this._colorFormat === WebInspector.Color.Format.Nickname)
|
| - colorFormat = WebInspector.Color.Format.HEX;
|
| + if (hsva[3] !== 1 && (this._colorFormat === WebInspector.Color.Format.ShortHEX || this._colorFormat === WebInspector.Color.Format.HEX || this._colorFormat === WebInspector.Color.Format.Nickname))
|
| + colorFormat = WebInspector.Color.Format.RGB;
|
| this._innerSetColor(hsva, "", colorFormat, WebInspector.Spectrum._ChangeSource.Other);
|
| }
|
|
|
| @@ -584,16 +584,11 @@ WebInspector.Spectrum.prototype = {
|
| if (colorString !== undefined)
|
| this._colorString = colorString;
|
| if (colorFormat !== undefined) {
|
| - var cf = WebInspector.Color.Format;
|
| - console.assert(colorFormat !== cf.Original, "Spectrum's color format cannot be Original");
|
| - if (colorFormat === cf.RGBA)
|
| - colorFormat = cf.RGB;
|
| - else if (colorFormat === cf.HSLA)
|
| - colorFormat = cf.HSL;
|
| - else if (colorFormat === cf.HEXA)
|
| - colorFormat = cf.HEX;
|
| - else if (colorFormat === cf.ShortHEXA)
|
| - colorFormat = cf.ShortHEX;
|
| + console.assert(colorFormat !== WebInspector.Color.Format.Original, "Spectrum's color format cannot be Original");
|
| + if (colorFormat === WebInspector.Color.Format.RGBA)
|
| + colorFormat = WebInspector.Color.Format.RGB;
|
| + else if (colorFormat === WebInspector.Color.Format.HSLA)
|
| + colorFormat = WebInspector.Color.Format.HSL;
|
| this._colorFormat = colorFormat;
|
| }
|
|
|
| @@ -636,23 +631,14 @@ WebInspector.Spectrum.prototype = {
|
| if (colorString)
|
| return colorString;
|
|
|
| - if (this._colorFormat === cf.Nickname) {
|
| + if (this._colorFormat === cf.Nickname || this._colorFormat === cf.ShortHEX) {
|
| colorString = color.asString(cf.HEX);
|
| if (colorString)
|
| return colorString;
|
| }
|
|
|
| - if (this._colorFormat === cf.ShortHEX)
|
| - colorString = color.asString(color.detectHEXFormat());
|
| - else if (this._colorFormat === cf.HEX)
|
| - colorString = color.asString(color.hasAlpha() ? cf.HEXA : cf.HEX);
|
| - else if (this._colorFormat === cf.HSL)
|
| - colorString = color.asString(cf.HSLA);
|
| - else
|
| - colorString = color.asString(cf.RGBA);
|
| -
|
| - console.assert(colorString);
|
| - return colorString || "";
|
| + console.assert(color.hasAlpha());
|
| + return this._colorFormat === cf.HSL ? /** @type {string} */(color.asString(cf.HSLA)) : /** @type {string} */(color.asString(cf.RGBA));
|
| },
|
|
|
| _updateHelperLocations: function()
|
| @@ -686,11 +672,10 @@ WebInspector.Spectrum.prototype = {
|
| if (this._colorFormat === cf.HEX || this._colorFormat === cf.ShortHEX || this._colorFormat === cf.Nickname) {
|
| this._hexContainer.hidden = false;
|
| this._displayContainer.hidden = true;
|
| - if (this._colorFormat === cf.ShortHEX)
|
| - this._hexValue.value = this._color().asString(this._color().detectHEXFormat());
|
| + if (this._colorFormat === cf.ShortHEX && this._color().canBeShortHex())
|
| + this._hexValue.value = this._color().asString(cf.ShortHEX);
|
| else
|
| - // Don't use short HEX if original was not in that format.
|
| - this._hexValue.value = this._color().asString(this._color().hasAlpha() ? cf.HEXA : cf.HEX);
|
| + this._hexValue.value = this._color().asString(cf.HEX);
|
| } else {
|
| // RGBA, HSLA display.
|
| this._hexContainer.hidden = true;
|
| @@ -817,7 +802,7 @@ WebInspector.Spectrum.prototype = {
|
| var format = cf.RGB;
|
| if (this._colorFormat === cf.RGB)
|
| format = cf.HSL;
|
| - else if (this._colorFormat === cf.HSL)
|
| + else if (this._colorFormat === cf.HSL && !this._color().hasAlpha())
|
| format = this._originalFormat === cf.ShortHEX ? cf.ShortHEX : cf.HEX;
|
| this._innerSetColor(undefined, "", format, WebInspector.Spectrum._ChangeSource.Other);
|
| },
|
| @@ -864,7 +849,7 @@ WebInspector.Spectrum.prototype = {
|
| return;
|
| var hsv = color.hsva();
|
| if (this._colorFormat === cf.HEX || this._colorFormat === cf.ShortHEX)
|
| - this._colorFormat = color.detectHEXFormat();
|
| + this._colorFormat = color.canBeShortHex() ? cf.ShortHEX : cf.HEX;
|
| this._innerSetColor(hsv, colorString, undefined, WebInspector.Spectrum._ChangeSource.Input);
|
| },
|
|
|
|
|