Bug 53961

Summary: Implement a calendar picker
Product: WebKit Reporter: Kent Tamura <tkent>
Component: FormsAssignee: Kent Tamura <tkent>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, adele, ap, darin, dglazkov, donggwan.kim, fishd, gyuyoung.kim, haizhang, hyatt, james, joepeck, jonlee, jshin, manyoso, marcoos+bwo, mathias, melo, mifenton, mjs, mstaikos, peter, priyajeet.hora, rjkroege, tonikitoo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 54174, 54175, 61415, 79078, 80106, 80478, 81081, 83001, 83011, 83129, 83235, 83258, 83656, 83668, 83672, 83685, 83990, 83991, 84007, 84388, 84389, 84390, 84826, 84827, 85272, 85331, 85337    
Bug Blocks: 29359, 83852    
Attachments:
Description Flags
WIP patch
none
WIP patch 2
none
WIP patch 3
none
WIP patch 4
none
WIP patch 5
none
WIP Patch 6 (HTMLPopup)
none
WIP Patch 7 none

Description Kent Tamura 2011-02-07 16:28:43 PST
Implement a calendar picker for date, datetime, datetime-local, and week types.

My plan is:
 - Use Windows::showModalDialog() from C++ code
 - Add a mechanism to load an internal resource via a URL to open it by showModalDialog()
 - Develop a calendar picker UI by HTML + CSS + JavaScript
Comment 1 Kent Tamura 2011-02-08 00:15:26 PST
Created attachment 81609 [details]
WIP patch
Comment 2 Kent Tamura 2011-02-08 00:21:09 PST
(In reply to comment #1)
> Created an attachment (id=81609) [details]
> WIP patch

This patch introduces x-webkit URL scheme.  It needs some hacks against the loader and SecurityOrigin.

I wonder if this is a right approach.  I couldn't use simple file: URLs for a calendar picker file because of SecurityOrigin restrictions.

Using showModalDialog() might be not good for user experience and the SecurityOrigin restriction.
Comment 3 Dimitri Glazkov (Google) 2011-02-08 07:57:54 PST
What do you guys think about implementing createPopup API for this? https://bugs.webkit.org/show_bug.cgi?id=16730
Comment 4 Simon Fraser (smfr) 2011-02-08 08:40:24 PST
showModalDialog: ugh. Can we make this non-modal?

Are we just doing Gregorian, or other calendars as well?

Is there a spec for this?
Comment 5 Kent Tamura 2011-02-08 15:51:18 PST
(In reply to comment #3)
> What do you guys think about implementing createPopup API for this? 
(In reply to comment #4)
> showModalDialog: ugh. Can we make this non-modal?

Yeah, createPopup() should be much better.  I'll try to implement it.
A modal dialog stops everything including other tabs and Inspector.  Too bad.

> Are we just doing Gregorian, or other calendars as well?
> Is there a spec for this?

The HTML specification doesn't define a picker UI for <input type=date>.  We should support other calendars if they have popular demand.  Anyway, the input and output of the calendar picker should be date strings in Gregorian calendar.

The requirements are:
 - input: minimum date, maximum date, step value
 - output: ISO-8601 date in YYYY-MM-DD format, or ISO-8601 week in YYYY-Wnn format
 - should be localized by the browser locale

I investigated a way to use OS-native calendar controls in OS X and Windows, and concluded they were not usable in WebKit.
Comment 6 Kent Tamura 2011-02-08 18:09:05 PST
(In reply to comment #5)
> > What do you guys think about implementing createPopup API for this? 
> 
> Yeah, createPopup() should be much better.  I'll try to implement it.

I checked createPopup() behavior, and found it's not so good.

http://msdn.microsoft.com/en-us/library/ms533025(v=vs.85).aspx
> * The popup object never has focus when it is displayed so processes continue to run in the parent window.
> * The popup object does not support text boxes of any kind.
> * No elements inside of the popup object can be selected.

These are not good.  I have confirmed a popup document never fires keyboard events.
Comment 7 Dimitri Glazkov (Google) 2011-02-08 18:38:28 PST
(In reply to comment #6)
> (In reply to comment #5)
> > > What do you guys think about implementing createPopup API for this? 
> > 
> > Yeah, createPopup() should be much better.  I'll try to implement it.
> 
> I checked createPopup() behavior, and found it's not so good.
> 
> http://msdn.microsoft.com/en-us/library/ms533025(v=vs.85).aspx
> > * The popup object never has focus when it is displayed so processes continue to run in the parent window.
> > * The popup object does not support text boxes of any kind.
> > * No elements inside of the popup object can be selected.
> 
> These are not good.  I have confirmed a popup document never fires keyboard events.

Yeah, that makes sense. Perhaps we need to define a better abstraction of a similar kind?
Comment 8 Kent Tamura 2011-02-10 01:25:17 PST
Created attachment 81937 [details]
WIP patch 2

Proof of concept code for shadow <iframe>
Comment 9 Kent Tamura 2011-02-17 01:54:08 PST
Created attachment 82769 [details]
WIP patch 3

Calendar picker works.
Comment 10 Kent Tamura 2011-02-17 02:11:11 PST
(In reply to comment #9)
> Created an attachment (id=82769) [details]
> WIP patch 3
> 
> Calendar picker works.

I'll suspend the development until shadow DOM refactoring (Bug 48698) is completed.  I'd like to add a button to kick the calendar picker to RenderTextControlSingleLine.
Comment 11 Kent Tamura 2011-02-22 00:41:31 PST
Created attachment 83281 [details]
WIP patch 4

* Supports keyboard operations.\n* Adjust picker position\n* Fix a TAB focus issue.
Comment 12 Kent Tamura 2011-03-04 01:01:35 PST
Created attachment 84707 [details]
WIP patch 5

* Apply feedbacks from Chrome UI/UX teams.
* Fix some bugs.
Comment 13 Darth 2011-03-07 17:22:48 PST
Would be nice to optionally have keyboard shortcuts for calendar date picking. Pressing T chooses today's date, M moves a month ahead keeping day inact etc. So like having accessKey's definable for the calendar buttons.
Comment 14 Kent Tamura 2012-02-15 23:11:00 PST
Created attachment 127315 [details]
WIP Patch 6 (HTMLPopup)
Comment 15 Kent Tamura 2012-02-15 23:29:45 PST
(In reply to comment #14)
> Created an attachment (id=127315) [details]
> WIP Patch 6 (HTMLPopup)

I stopped using shadow DOM.

The idea is very close to createPopup API which Dimitri wrote in comment #3.
 * Introduce HTMLPopup class
   It is created and deleted by WebCore::Chrome.
   HTMLPopupClient provides an HTML source and can receive resultant values from the popup.
 * DateInputType implements HTMLPopupClient.

Because iOS and Android don't need a calendar picker for type=date, I'll add ENABLE_CALENDAR_PICKER flag.
Comment 16 Robert Kroeger 2012-02-29 08:39:43 PST
Comment on attachment 127315 [details]
WIP Patch 6 (HTMLPopup)

View in context: https://bugs.webkit.org/attachment.cgi?id=127315&action=review

> Source/WebKit/chromium/src/WebHTMLPopupImpl.cpp:159
> +    m_page->settings()->setScriptEnabled(true);

This could be modified to adjust settings for DIP/touch enablement correct?

> Source/WebKit/chromium/src/WebHTMLPopupImpl.cpp:279
> +        // GESTURE and TOUCH

you could make a bug for me for this.
Comment 17 Kent Tamura 2012-02-29 17:10:20 PST
(In reply to comment #16)
> (From update of attachment 127315 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=127315&action=review
> 
> > Source/WebKit/chromium/src/WebHTMLPopupImpl.cpp:159
> > +    m_page->settings()->setScriptEnabled(true);
> 
> This could be modified to adjust settings for DIP/touch enablement correct?

Yes, of course we should support them.
Comment 18 Kent Tamura 2012-04-02 21:24:31 PDT
Created attachment 135271 [details]
WIP Patch 7
Comment 19 Kent Tamura 2012-06-28 18:16:00 PDT
Major parts of the implementation were completed. Closing.