Bug 29358

Summary: <input type=color> UI
Product: WebKit Reporter: Kent Tamura <tkent>
Component: FormsAssignee: Keishi Hattori <keishi>
Status: RESOLVED FIXED    
Severity: Normal CC: aaron.bushnell, alfred, cgarcia, cmarcelo, donggwan.kim, hyerim.bae, joepeck, jonlee, kangax, keishi, kossnocorp, marcoos+bwo, mathias, me, me, michelangelo, morrita, skyul, stalcup, syoichi, tmpsantos, webkit-bug-importer, webmaster
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
URL: http://www.whatwg.org/specs/web-apps/current-work/multipage/number-state.html#color-state
Bug Depends on: 28966, 52612, 61273, 61275, 61276, 65897    
Bug Blocks: 19264    
Attachments:
Description Flags
Color picker
none
Patch
keishi: review-
implements UI appearance keishi: review-

Description Kent Tamura 2009-09-17 21:00:53 PDT
Add dedicated UI for <input type=color>.
Comment 1 Alfred Morgan 2010-04-17 10:48:39 PDT
I would like to help implement this feature if I can.  I just don't know where/how to start.
Comment 2 Hajime Morrita 2010-04-17 10:52:43 PDT
(In reply to comment #1)
> I would like to help implement this feature if I can.  I just don't know
> where/how to start.
Searching ChangeLog for similar implementation will be a good starting point.
To find out what to search, Bug 19264 will be helpful.
Comment 3 Kent Tamura 2010-04-20 03:39:14 PDT
(In reply to comment #1)
> I would like to help implement this feature if I can.  I just don't know
> where/how to start.

The process would be:
1. Define new value for -webkit-appearance
  See CSSStyleSelector::SelectorChecker::checkOneSelector()
2. Implement the appearance (rendering/RenderTheme*)
3. Assign the appearance for input[type=color] (css/html.css)
4. Implement UI behavior
  - Add a new function to page/Chrome and page/ChromeClient to open a color picker
   (See runOpenPanel()
  - Implement it for various platforms
  - Add a click handling to html/HTMLInputElement.cpp defaultEventHandler()
Comment 4 Alfred Morgan 2010-04-20 09:50:24 PDT
Thank you Kent.  This is great.

> - Implement it for various platforms

I'm going to need help doing this task.  I can do the generics and the Mac platform.
Comment 5 Keishi Hattori 2010-10-15 00:50:05 PDT
I was interested in this for Bug 25032, so I've started working on this. As a first step, I am trying to draw a NSColorWell and I have a couple of questions.

1. https://docs.google.com/View?id=dch3zh37_0cf8kc8c4 proposes implementing it like this.

input[type="color"]::-webkit-input-color-button {
  -webkit-appearance: color-button;
}

But do I need to  create -webkit-input-color-button pseudo element? Why can't I do this?

input[type="color"] {
  -webkit-appearance: color-button;
}

2. NSColorWell does not have NSCell. How should I paint it?
Comment 6 Kent Tamura 2010-10-15 02:05:21 PDT
(In reply to comment #5)
> I was interested in this for Bug 25032, so I've started working on this. As a first step, I am trying to draw a NSColorWell and I have a couple of questions.
> 
> 1. https://docs.google.com/View?id=dch3zh37_0cf8kc8c4 proposes implementing it like this.
> 
> input[type="color"]::-webkit-input-color-button {
>   -webkit-appearance: color-button;
> }
> 
> But do I need to  create -webkit-input-color-button pseudo element? Why can't I do this?
> 
> input[type="color"] {
>   -webkit-appearance: color-button;
> }

It's ok to omit ::-webkit-input-color-button if the 'color-button' appearance supports all of states such as :disabled :active.  I guess it can support.

> 2. NSColorWell does not have NSCell. How should I paint it?

I think NSColorWell appearance is just a square button + a filled rectangle.  So we can use NSButtonCell.
Comment 7 Alfred Morgan 2010-10-15 17:00:39 PDT
> 2. NSColorWell does not have NSCell. How should I paint it?

I would like to see it drawn like this:
http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGControls/XHIGControls.html%23//apple_ref/doc/uid/TP30000359-TPXREF213

That Google proposal you mentioned looks more like how a <select> is drawn, all the way down to the mini popup.

I would rather like to see the color well be clean like in the HIG.  It would be nice if your color well element coulb be used as the Color Swatch in the Web Inspector (a small color square with a thin gray border).
Comment 8 Peter Kasting 2010-10-15 17:58:33 PDT
(In reply to comment #7)
> I would like to see it drawn like this:
> http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGControls/XHIGControls.html%23//apple_ref/doc/uid/TP30000359-TPXREF213
> 
> That Google proposal you mentioned looks more like how a <select> is drawn, all the way down to the mini popup.

This may be an area where different platforms would prefer different styles.  The proposal on Google Docs is basically the Windows native UI.  The Mac-style color well looks out of place on Windows in the same way that the reverse is true.

I don't know whether that causes problems for web developers looking to style the controls.
Comment 9 Keishi Hattori 2010-10-15 18:02:51 PDT
(In reply to comment #6)

> > 2. NSColorWell does not have NSCell. How should I paint it?
> 
> I think NSColorWell appearance is just a square button + a filled rectangle.  So we can use NSButtonCell.

Thanks Kent!

I'm busy next week but I'll have my patch ready the week after.
Comment 10 Keishi Hattori 2010-10-15 18:26:41 PDT
(In reply to comment #7)
> I would like to see it drawn like this:
> http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGControls/XHIGControls.html%23//apple_ref/doc/uid/TP30000359-TPXREF213

Yes. That is all I'm trying to do for my first patch. 

However I think the mac might also need the popup UI to support the "list" attribute. Maybe something like http://i56.tinypic.com/e6zujn.png in the Interface Builder.
Comment 11 Alfred Morgan 2010-10-15 19:00:54 PDT
> like in the Interface Builder.

Oh wow! That's exactly how to do it.  I like how clicking on the left half brings the color well right away and can be used as a drop target.  And the right half acts as a dropdown with the possibility of text.  The popup then contains recently used colors at top, and the @list following that, and then Other… at the bottom.  It's perfect.
Comment 12 Aaron 2010-11-30 03:38:35 PST
Eager to see this implemented into the browser as well as Web Inspector.  This will be a huge improvement for both.
Comment 13 Joseph Pecoraro 2011-01-18 11:01:57 PST
> I'm busy next week but I'll have my patch ready the week after.

Keishi, how did progress go on this?
Comment 14 Aaron 2011-02-10 17:50:33 PST
Created attachment 82080 [details]
Color picker
Comment 15 Aaron 2011-02-10 17:50:44 PST
Anyone ever get a chance to add this? I'd like to see something like this for the Inspector. Something simple I found that uses jQuery to build cross-browser compatible HTML5 forms.
Comment 16 Aaron 2011-02-10 17:51:23 PST
Comment on attachment 82080 [details]
Color picker

Anyone ever get a chance to add this? I'd like to see something like this for the Inspector. Something simple I found that uses jQuery to build cross-browser compatible HTML5 forms.
Comment 17 Kent Tamura 2011-03-09 22:42:26 PST
(In reply to comment #6)
> > 2. NSColorWell does not have NSCell. How should I paint it?
> 
> I think NSColorWell appearance is just a square button + a filled rectangle.  So we can use NSButtonCell.

Probably, having a shadow tree like the following would be enough.

<button style="-webkit-appearance: square-button; padding:2px;"><div style="display:inline-block;background-color:yellow;width:16px;height:10px;border:1px black solid"></div></button>
Comment 18 Keishi Hattori 2011-05-23 05:11:11 PDT
Created attachment 94401 [details]
Patch
Comment 19 Keishi Hattori 2011-05-23 05:16:14 PDT
(In reply to comment #18)
> Created an attachment (id=94401) [details]
> Patch
This first patch does the following
- disables the current input type=color implementation
- adds ENABLE_INPUT_COLOR feature flag
- replace typemismatch with value sanitization
Comment 20 Kent Tamura 2011-05-23 05:21:50 PDT
(In reply to comment #19)
> (In reply to comment #18)
> > Created an attachment (id=94401) [details] [details]
> > Patch
> This first patch does the following
> - disables the current input type=color implementation
> - adds ENABLE_INPUT_COLOR feature flag
> - replace typemismatch with value sanitization

The code change looks ok.  I'll review the patch tomorrow.

Anyway, please post an announcement of the new feature flag to webkit-dev.  This flag change the existing behavior and will require browser-side implementation, won't it?
Comment 21 Kent Tamura 2011-05-23 05:22:51 PDT
Also, I prefer one patch per one bug.
Comment 22 Keishi Hattori 2011-05-23 05:27:16 PDT
Created attachment 94402 [details]
implements UI appearance
Comment 23 Keishi Hattori 2011-05-23 05:29:20 PDT
(In reply to comment #21)
> Also, I prefer one patch per one bug.

Okay, I'll make separate bugs.
Comment 24 Keishi Hattori 2011-05-23 05:46:47 PDT
(In reply to comment #23)
> Okay, I'll make separate bugs.

Moved first patch to Bug 61273
Moved second patch to Bug 61275
Comment 25 Hyerim Bae 2011-06-24 23:06:47 PDT
I'm also interested this color input feature. Do you think this feature also can be useful on mobile environment which has small screen with no accurate mouse pointer?

I think user can input color value only though keypad via input field.
Somebody may want to select color on color picker with mobile environment.
Comment 26 Jon Lee 2011-09-06 13:29:44 PDT
<rdar://problem/8489889>
Comment 27 john stalcup 2011-12-12 13:29:25 PST
i want this functionality as well :-/
Comment 28 Jon Lee 2012-01-31 16:33:37 PST
What exactly is the state of the completion of this feature at this point?
Comment 29 Kent Tamura 2013-03-28 01:30:01 PDT
Finished platform-independent part.