<input type=color> Mac UI behaviour
<rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276

Source/JavaScriptCore:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.

Source/WebCore:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

This patch turns on INPUT_TYPE_COLOR and implements it using the native
Mac color panel.

No new tests added.

Currently, there are no automated ways to test the types of changes made in this patch. (i.e. checking
which color is being displayed in the color panel, checking which color element is currently
associated to the color panel, checking the state of color elements after directing away and
being directed back to its page, etc.)

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:

* html/ColorInputType.cpp:
(WebCore::ColorInputType::handleDOMActivateEvent): Reattaches the color picker if
  a color picker has already been shown for an element
(WebCore::ColorInputType::shouldResetOnDocumentActivation): Always returns true, needed to
  detach the color picker when caching a page.
* html/ColorInputType.h:

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::documentDidResumeFromPageCache): For <input type='color'>,
  don't reset the element.
(WebCore::HTMLInputElement::documentWillSuspendForPageCache): For <input type='color'>, call detach().
* html/HTMLInputElement.h:

* platform/ColorChooser.h:
(WebCore::ColorChooser::reattachColorChooser): Added definition.

Source/WebKit/mac:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::createColorPicker): Added stub implementation.

Source/WebKit2:

Implemented <input type='color'> on Mac using the native color picker.

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

Code for WebColorPickerMac is derived from Chromium's color_chooser_mac.mm:
https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/cocoa/color_chooser_mac.mm

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.

* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::createColorPicker): Replaced stub implementation
  and return a WebColorPickerMac object.

* UIProcess/WebColorPicker.cpp:
(WebKit::WebColorPicker::invalidate): Updated to call endChooser().
(WebKit::WebColorPicker::showColorPicker): Added stub implementation.
* UIProcess/WebColorPicker.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close): Removed invalidation of removed color picker objects.
(WebKit::WebPageProxy::showColorPicker): Updated so that it works for
  multiple <input type='color'> elements on a page.
(WebKit::WebPageProxy::didEndColorPicker): Removed cleanup of removed color picker objects.
(WebKit::WebPageProxy::resetStateAfterProcessExited): Removed cleanup of removed color picker objects.

* UIProcess/mac/WebColorPickerMac.h: Added.
* UIProcess/mac/WebColorPickerMac.mm: Added.
(WebKit::WebColorPickerMac::create):
(WebKit::WebColorPickerMac::~WebColorPickerMac):
(WebKit::WebColorPickerMac::WebColorPickerMac):
(WebKit::WebColorPickerMac::endPicker):
(WebKit::WebColorPickerMac::setSelectedColor):
(WebKit::WebColorPickerMac::didChooseColor):
(WebKit::WebColorPickerMac::showColorPicker):
WebColorPickerMac contains a reference to a WKColorPanelMac object
  and is responsible for maintaining the color picker UI.

(-[WKColorPanelMac setAndShowPicker:withColor:]):
(-[WKColorPanelMac invalidate]):
(-[WKColorPanelMac windowWillClose:]):
(-[WKColorPanelMac didChooseColor:]):
(-[WKColorPanelMac setColor:]):
WKColorPanelMac is a wrapper for a NSColorPanel object and
  is responsible for the color picker UI.

* WebKit2.xcodeproj/project.pbxproj:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createColorChooser): Updated to always create a
  WebColorChooser object.

* WebProcess/WebCoreSupport/WebColorChooser.cpp:
(WebKit::WebColorChooser::reattachColorChooser): Sets the page's
  active color chooser to the current object and pings the UIProcess
  to show the color picker.
(WebKit::WebColorChooser::setSelectedColor): Only sets the color in the
  color picker if the WebColorChooser object is the active color element.
* WebProcess/WebCoreSupport/WebColorChooser.h:

Source/WTF:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

* wtf/FeatureDefines.h: Enabled INPUT_TYPE_COLOR on Mac port.

LayoutTests:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

Updated tests to reflect <input type='color'> being implemented with a native color picker.

* fast/forms/color/input-color-onchange-event-expected.txt:

* platform/mac/TestExpectations: Enabled fast/form/color tests on Mac.

* platform/mac/accessibility/color-well-expected.txt:
* platform/mac/accessibility/role-subrole-roledescription-expected.txt:
* platform/mac/accessibility/role-subrole-roledescription.html:

* platform/mac/fast/forms/color/input-appearance-color-expected.txt: Updated test expectations
on Mac to reflect the fact that the list attribute for <input type='color'> is not yet supported.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153541 268f45cc-cd09-0410-ab3c-d52691b4dbfc
36 files changed