Commit 450a3e9d authored by samli@chromium.org's avatar samli@chromium.org

Devtools Color: Support decimal values which omit 0

BUG=526315

Review URL: https://codereview.chromium.org/1313863003

git-svn-id: svn://svn.chromium.org/blink/trunk@201491 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0744aae7
...@@ -124,6 +124,30 @@ color: hsla(200,1.5%,50%,1) ...@@ -124,6 +124,30 @@ color: hsla(200,1.5%,50%,1)
rgb: rgb(126, 128, 129) rgb: rgb(126, 128, 129)
hsl: hsl(200, 1%, 50%) hsl: hsl(200, 1%, 50%)
color: rgba(0,0,0,.5)
simple: false
original: rgba(0,0,0,.5)
rgb: null
rgba: rgba(0,0,0,.5)
hsl: null
hsla: hsla(0, 0%, 0%, 0.5)
color: hsla(.5,.5%,.5%,.5)
simple: false
original: hsla(.5,.5%,.5%,.5)
rgb: null
rgba: rgba(1, 1, 1, 0.5)
hsl: null
hsla: hsla(.5,.5%,.5%,.5)
color: hsla(100.5,50.5%,50.5%,.5)
simple: false
original: hsla(100.5,50.5%,50.5%,.5)
rgb: null
rgba: rgba(106, 193, 65, 0.5)
hsl: null
hsla: hsla(100.5,50.5%,50.5%,.5)
color: rgba(255, 0, 0, -5) color: rgba(255, 0, 0, -5)
simple: false simple: false
original: rgba(255, 0, 0, -5) original: rgba(255, 0, 0, -5)
...@@ -159,10 +183,14 @@ SUCCESS: parsed invalid color rgb(1,1,1.2) to null ...@@ -159,10 +183,14 @@ SUCCESS: parsed invalid color rgb(1,1,1.2) to null
SUCCESS: parsed invalid color rgba(0,0,0,1%) to null SUCCESS: parsed invalid color rgba(0,0,0,1%) to null
SUCCESS: parsed invalid color rgba(0,0,0,) to null
SUCCESS: parsed invalid color hsl(0,0,0) to null SUCCESS: parsed invalid color hsl(0,0,0) to null
SUCCESS: parsed invalid color hsl(0%, 0%, 0%) to null SUCCESS: parsed invalid color hsl(0%, 0%, 0%) to null
SUCCESS: parsed invalid color hsla(0,,0,1) to null
SUCCESS: parsed invalid color hsl(0, 0%, 0) to null SUCCESS: parsed invalid color hsl(0, 0%, 0) to null
SUCCESS: parsed invalid color hsl(a,b,c) to null SUCCESS: parsed invalid color hsl(a,b,c) to null
......
...@@ -23,6 +23,9 @@ function test() ...@@ -23,6 +23,9 @@ function test()
'hsla(240,100%,50%,0.05)', 'hsla(240,100%,50%,0.05)',
'hsl(200.5,0%,50%)', 'hsl(200.5,0%,50%)',
'hsla(200,1.5%,50%,1)', 'hsla(200,1.5%,50%,1)',
'rgba(0,0,0,.5)',
'hsla(.5,.5%,.5%,.5)',
'hsla(100.5,50.5%,50.5%,.5)',
// Each of these has their alpha clipped [0.0, 1.0]. // Each of these has their alpha clipped [0.0, 1.0].
'rgba(255, 0, 0, -5)', // clipped to rgba(255,0,0,0) 'rgba(255, 0, 0, -5)', // clipped to rgba(255,0,0,0)
...@@ -39,8 +42,10 @@ function test() ...@@ -39,8 +42,10 @@ function test()
'rgb(a,b,c,d)', 'rgb(a,b,c,d)',
'rgb(1,1,1.2)', 'rgb(1,1,1.2)',
'rgba(0,0,0,1%)', 'rgba(0,0,0,1%)',
'rgba(0,0,0,)',
'hsl(0,0,0)', 'hsl(0,0,0)',
'hsl(0%, 0%, 0%)', 'hsl(0%, 0%, 0%)',
'hsla(0,,0,1)',
'hsl(0, 0%, 0)', 'hsl(0, 0%, 0)',
'hsl(a,b,c)', 'hsl(a,b,c)',
'hsla(0,0,0,0)', 'hsla(0,0,0,0)',
......
...@@ -127,7 +127,7 @@ WebInspector.Color.parse = function(text) ...@@ -127,7 +127,7 @@ WebInspector.Color.parse = function(text)
} }
// Advanced - rgba(), hsla() // Advanced - rgba(), hsla()
var advanced = /^(?:rgba\(((?:-?\d+%?,){3}-?\d+(?:\.\d+)?)\)|hsla\((-?\d+\.?\d*(?:,-?\d+\.?\d*%){2},-?\d+(?:\.\d+)?)\))$/; var advanced = /^(?:rgba\(((?:-?\d+%?,){3}-?(?:\d+|\d*\.\d+))\)|hsla\((-?(?:\d+|\d*\.\d+)(?:,-?(?:\d+|\d*\.\d+)*%){2},-?(?:\d+|\d*\.\d+))\))$/;
match = value.match(advanced); match = value.match(advanced);
if (match) { if (match) {
if (match[1]) { // rgba if (match[1]) { // rgba
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment