Changeset 235273 in webkit
- Timestamp:
- Aug 23, 2018 9:55:28 PM (6 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r235271 r235273 1 2018-08-23 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Color picker: can't enter decimal numbers for opacity 4 https://bugs.webkit.org/show_bug.cgi?id=187026 5 <rdar://problem/41446500> 6 7 Reviewed by Brian Burg. 8 9 After every "input" event, we update the `color` value of the `WI.ColorPicker` based on a 10 generated string using the values of the various <input>. The issue with this approach is 11 that adding a decimal point (e.g. "0.") would still be construed as 0, meaning that the 12 color wouldn't change and would instead be reset back to it's old value. This patch adds an 13 early return if the newly generated color has the same value as the current color, thereby 14 meaning that the `color` wouldn't change when changing from "0" to "0.". 15 16 * UserInterface/Views/ColorPicker.js: 17 (WI.ColorPicker): 18 (WI.ColorPicker.createColorInput): 19 (WI.ColorPicker.prototype._handleColorInputInput): 20 1 21 2018-08-23 Simon Fraser <simon.fraser@apple.com> 2 22 -
trunk/Source/WebInspectorUI/UserInterface/Views/ColorPicker.js
r220119 r235273 45 45 colorInputsContainerElement.classList.add("color-inputs"); 46 46 47 function createColorInput(label, {min: min = 0, max: max = 100, step: step = 1, units} = {}){47 let createColorInput = (label, {min, max, step, units} = {}) => { 48 48 let containerElement = colorInputsContainerElement.createChild("div"); 49 49 … … 52 52 let numberInputElement = containerElement.createChild("input"); 53 53 numberInputElement.type = "number"; 54 numberInputElement.min = min ;55 numberInputElement.max = max ;56 numberInputElement.step = step ;54 numberInputElement.min = min || 0; 55 numberInputElement.max = max || 100; 56 numberInputElement.step = step || 1; 57 57 numberInputElement.addEventListener("input", this._handleColorInputInput.bind(this)); 58 58 … … 61 61 62 62 return {containerElement, numberInputElement}; 63 } 63 }; 64 64 65 65 this._colorInputs = new Map([ 66 ["R", createColorInput .call(this,"R", {max: 255})],67 ["G", createColorInput .call(this,"G", {max: 255})],68 ["B", createColorInput .call(this,"B", {max: 255})],69 ["H", createColorInput .call(this,"H", {max: 360})],70 ["S", createColorInput .call(this,"S", {units: "%"})],71 ["L", createColorInput .call(this,"L", {units: "%"})],72 ["A", createColorInput .call(this, "A"), {max: 1, step: 0.01}]66 ["R", createColorInput("R", {max: 255})], 67 ["G", createColorInput("G", {max: 255})], 68 ["B", createColorInput("B", {max: 255})], 69 ["H", createColorInput("H", {max: 360})], 70 ["S", createColorInput("S", {units: "%"})], 71 ["L", createColorInput("L", {units: "%"})], 72 ["A", createColorInput("A", {max: 1, step: 0.01})] 73 73 ]); 74 74 … … 325 325 } 326 326 327 this.color = WI.Color.fromString(colorString); 327 let newColor = WI.Color.fromString(colorString); 328 if (newColor.toString() === this._color.toString()) 329 return; 330 331 this.color = newColor; 328 332 this._color.format = oldFormat; 329 333
Note: See TracChangeset
for help on using the changeset viewer.