Title: [208857] trunk
Revision
208857
Author
commit-qu...@webkit.org
Date
2016-11-17 12:25:24 -0800 (Thu, 17 Nov 2016)

Log Message

Web Inspector: Shift clicking on named color value only shows its hex form
https://bugs.webkit.org/show_bug.cgi?id=162758

Patch by Devin Rousso <dcrousso+web...@gmail.com> on 2016-11-17
Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

* UserInterface/Models/Color.js:
(WebInspector.Color.prototype.nextFormat):
Reworked the logic for the formatting order to be the following:
 - Long HEX and Long HEXAlpha
 - RGB and RGBA
 - HSL and HSLA
 - Keyword (if applicable)
 - Short HEX (if applicable)
 - Short HEXAlpha (if applicable)
It will only show formats with alpha values if the color value has an alpha that is not 1.
If the alpha is not 1, it will not show formats with non-alpha values.

The changes to this function have no effect on the context menu items of InlineSwatch
elements.  The purpose of each of those items is to allow the user to change the format to
a specified type, whereas WebInspector.Color.prototype.nextFormat is used to cycle through
all of the relevant formats.

(WebInspector.Color.prototype._toRGBString):
(WebInspector.Color.prototype._toRGBAString):
(WebInspector.Color.prototype._toHSLString):
(WebInspector.Color.prototype._toHSLAString):
Unrelated fix of extra decimals when converting from HEX to RGB and HSL.

* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor._inlineSwatchValueChanged):
Removed assertion for `_hasActiveInlineSwatchEditor` since the value may change from
switching the format of a color swatch (Shift-Click).

LayoutTests:

* inspector/model/color.html:
Updated the WebInspector.Color.prototype.nextFormat test for the new nextFormat logic.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208856 => 208857)


--- trunk/LayoutTests/ChangeLog	2016-11-17 20:15:51 UTC (rev 208856)
+++ trunk/LayoutTests/ChangeLog	2016-11-17 20:25:24 UTC (rev 208857)
@@ -1,3 +1,13 @@
+2016-11-17  Devin Rousso  <dcrousso+web...@gmail.com>
+
+        Web Inspector: Shift clicking on named color value only shows its hex form
+        https://bugs.webkit.org/show_bug.cgi?id=162758
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/model/color.html:
+        Updated the WebInspector.Color.prototype.nextFormat test for the new nextFormat logic.
+
 2016-11-17  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking http/tests/media/modern-media-controls/skip-back-support/skip-back-support-button-click.html as flaky.

Modified: trunk/LayoutTests/inspector/model/color.html (208856 => 208857)


--- trunk/LayoutTests/inspector/model/color.html	2016-11-17 20:15:51 UTC (rev 208856)
+++ trunk/LayoutTests/inspector/model/color.html	2016-11-17 20:25:24 UTC (rev 208857)
@@ -170,7 +170,7 @@
     suite.addTestCase({
         name: "WebInspector.Color.prototype.nextFormat",
         description: "Test we can cycle through color formats for different colors.",
-        test: (resolve, reject) => {
+        test(resolve, reject) {
             function test(string, phases) {
                 let color = WebInspector.Color.fromString(string);
                 color.format = WebInspector.Color.Format.Original;
@@ -193,7 +193,6 @@
                 WebInspector.Color.Format.Keyword,
                 WebInspector.Color.Format.ShortHEXAlpha,
                 WebInspector.Color.Format.HEXAlpha,
-                WebInspector.Color.Format.Original,
             ]);
 
             // All without alpha.
@@ -203,7 +202,6 @@
                 WebInspector.Color.Format.Keyword,
                 WebInspector.Color.Format.ShortHEX,
                 WebInspector.Color.Format.HEX,
-                WebInspector.Color.Format.Original,
             ]);
 
             // No short hex or keyword.
@@ -211,7 +209,6 @@
                 WebInspector.Color.Format.RGB,
                 WebInspector.Color.Format.HSL,
                 WebInspector.Color.Format.HEX,
-                WebInspector.Color.Format.Original,
             ]);
 
             // No short hex alpha or keyword.
@@ -219,7 +216,6 @@
                 WebInspector.Color.Format.RGBA,
                 WebInspector.Color.Format.HSLA,
                 WebInspector.Color.Format.HEXAlpha,
-                WebInspector.Color.Format.Original,
             ]);
 
             resolve();

Modified: trunk/Source/WebInspectorUI/ChangeLog (208856 => 208857)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-11-17 20:15:51 UTC (rev 208856)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-11-17 20:25:24 UTC (rev 208857)
@@ -1,3 +1,38 @@
+2016-11-17  Devin Rousso  <dcrousso+web...@gmail.com>
+
+        Web Inspector: Shift clicking on named color value only shows its hex form
+        https://bugs.webkit.org/show_bug.cgi?id=162758
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/Color.js:
+        (WebInspector.Color.prototype.nextFormat):
+        Reworked the logic for the formatting order to be the following:
+         - Long HEX and Long HEXAlpha
+         - RGB and RGBA
+         - HSL and HSLA
+         - Keyword (if applicable)
+         - Short HEX (if applicable)
+         - Short HEXAlpha (if applicable)
+        It will only show formats with alpha values if the color value has an alpha that is not 1.
+        If the alpha is not 1, it will not show formats with non-alpha values.
+
+        The changes to this function have no effect on the context menu items of InlineSwatch
+        elements.  The purpose of each of those items is to allow the user to change the format to
+        a specified type, whereas WebInspector.Color.prototype.nextFormat is used to cycle through
+        all of the relevant formats.
+
+        (WebInspector.Color.prototype._toRGBString):
+        (WebInspector.Color.prototype._toRGBAString):
+        (WebInspector.Color.prototype._toHSLString):
+        (WebInspector.Color.prototype._toHSLAString):
+        Unrelated fix of extra decimals when converting from HEX to RGB and HSL.
+
+        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+        (WebInspector.CSSStyleDeclarationTextEditor._inlineSwatchValueChanged):
+        Removed assertion for `_hasActiveInlineSwatchEditor` since the value may change from
+        switching the format of a color swatch (Shift-Click).
+
 2016-11-16  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Background tabs are often updating non-stop because they think they are visible

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Color.js (208856 => 208857)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Color.js	2016-11-17 20:15:51 UTC (rev 208856)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Color.js	2016-11-17 20:25:24 UTC (rev 208857)
@@ -234,6 +234,8 @@
 
         switch (format) {
         case WebInspector.Color.Format.Original:
+        case WebInspector.Color.Format.HEX:
+        case WebInspector.Color.Format.HEXAlpha:
             return this.simple ? WebInspector.Color.Format.RGB : WebInspector.Color.Format.RGBA;
 
         case WebInspector.Color.Format.RGB:
@@ -242,7 +244,7 @@
 
         case WebInspector.Color.Format.HSL:
         case WebInspector.Color.Format.HSLA:
-            if (this.keyword)
+            if (this.isKeyword())
                 return WebInspector.Color.Format.Keyword;
             if (this.simple)
                 return this.canBeSerializedAsShortHEX() ? WebInspector.Color.Format.ShortHEX : WebInspector.Color.Format.HEX;
@@ -254,10 +256,6 @@
         case WebInspector.Color.Format.ShortHEXAlpha:
             return WebInspector.Color.Format.HEXAlpha;
 
-        case WebInspector.Color.Format.HEX:
-        case WebInspector.Color.Format.HEXAlpha:
-            return WebInspector.Color.Format.Original;
-
         case WebInspector.Color.Format.Keyword:
             if (this.simple)
                 return this.canBeSerializedAsShortHEX() ? WebInspector.Color.Format.ShortHEX : WebInspector.Color.Format.HEX;
@@ -484,12 +482,15 @@
             return this._toRGBAString();
 
         let rgba = this.rgba.slice(0, -1);
+        rgba = rgba.map((value) => value.maxDecimals(2));
         return "rgb(" + rgba.join(", ") + ")";
     }
 
     _toRGBAString()
     {
-        return "rgba(" + this.rgba.join(", ") + ")";
+        let rgba = this.rgba;
+        rgba = rgba.map((value) => value.maxDecimals(2));
+        return "rgba(" + rgba.join(", ") + ")";
     }
 
     _toHSLString()
@@ -498,6 +499,7 @@
             return this._toHSLAString();
 
         let hsla = this.hsla;
+        hsla = hsla.map((value) => value.maxDecimals(2));
         return "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)";
     }
 
@@ -504,6 +506,7 @@
     _toHSLAString()
     {
         let hsla = this.hsla;
+        hsla = hsla.map((value) => value.maxDecimals(2));
         return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js (208856 => 208857)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js	2016-11-17 20:15:51 UTC (rev 208856)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js	2016-11-17 20:25:24 UTC (rev 208857)
@@ -1330,8 +1330,6 @@
 
     _inlineSwatchValueChanged(event)
     {
-        console.assert(this._hasActiveInlineSwatchEditor);
-
         let swatch = event && event.target;
         console.assert(swatch);
         if (!swatch)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to