<input type=color> Mac UI behaviour
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2013 20:47:46 +0000 (20:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2013 20:47:46 +0000 (20:47 +0000)
commit50584b8505d4486b28a84ba3ea4c05476caf956e
tree0775218ad2749b9fa5460a66cf4ff5bdf16cb193
parente99ef61c1b5e826481181acdc04e99aaf105ec78
<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: https://svn.webkit.org/repository/webkit/trunk@153541 268f45cc-cd09-0410-ab3c-d52691b4dbfc
36 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/color/input-color-onchange-event-expected.txt
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/mac/accessibility/color-well-expected.txt
LayoutTests/platform/mac/accessibility/role-subrole-roledescription-expected.txt
LayoutTests/platform/mac/accessibility/role-subrole-roledescription.html
LayoutTests/platform/mac/fast/forms/color/input-appearance-color-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig
Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebCore/ChangeLog
Source/WebCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/ColorInputType.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/platform/ColorChooser.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/FeatureDefines.xcconfig
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/FeatureDefines.xcconfig
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/WebColorPicker.cpp
Source/WebKit2/UIProcess/WebColorPicker.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/mac/WebColorPickerMac.h [new file with mode: 0644]
Source/WebKit2/UIProcess/mac/WebColorPickerMac.mm [new file with mode: 0644]
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebColorChooser.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebColorChooser.h