[macOS] Color wells should appear pressed when presenting a color picker
authorakeerthi@apple.com <akeerthi@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Aug 2018 20:19:25 +0000 (20:19 +0000)
committerakeerthi@apple.com <akeerthi@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Aug 2018 20:19:25 +0000 (20:19 +0000)
commit1ea08187306d020d431ebc3a8255b356618a53ff
tree1acc2ad3bfa1135e1a9e5bfb644ef5a56b55f4bb
parentacbe6c2b71217129679a6daf06e5bd757b456d00
[macOS] Color wells should appear pressed when presenting a color picker
https://bugs.webkit.org/show_bug.cgi?id=188477

Reviewed by Tim Horton.

Source/WebCore:

Currently, when clicking on a color well, the color well loses its pressed
appearance once the mouse is lifted. Because of this behavior, the color well
does not appear to be active when the color picker is displayed.

Added the color-well -webkit-appearance value to control the drawing of the color
well separate from other buttons. Also added a new ControlState, named
PresentingState. A control can be in this state whenever it is presenting some
attached view. In the case of the color well this is the color picker. The
Information as to whether a form control is in the presenting state comes from
isPresentingAttachedView() in HTMLInputElement.

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSProperties.json:
* css/CSSValueKeywords.in:
* css/html.css:
(input[type="color"]::-webkit-color-swatch):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::isPresentingAttachedView const):
(WebCore::ColorInputType::elementDidBlur):
(WebCore::ColorInputType::didEndChooser):
* html/ColorInputType.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::isPresentingAttachedView const):
* html/HTMLInputElement.h:
* html/InputType.cpp:
(WebCore::InputType::isPresentingAttachedView const):
* html/InputType.h:
* platform/ControlStates.h:
* platform/ThemeTypes.h:
* platform/mac/ThemeMac.mm:
(WebCore::updateStates):
(WebCore::setUpButtonCell):
(WebCore::paintColorWell):
(WebCore::ThemeMac::minimumControlSize const):
(WebCore::ThemeMac::controlBorder const):
(WebCore::ThemeMac::paint):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle):
(WebCore::RenderTheme::paint):
(WebCore::RenderTheme::paintBorderOnly):
(WebCore::RenderTheme::paintDecorations):
(WebCore::RenderTheme::isControlStyled const):
(WebCore::RenderTheme::extractControlStatesForRenderer const):
(WebCore::RenderTheme::isPresenting const):
* rendering/RenderTheme.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::adjustRepaintRect):

Source/WebInspectorUI:

Add keyword completion for 'color-well'.

* UserInterface/External/CodeMirror/css.js:
* UserInterface/Models/CSSKeywordCompletions.js:

Source/WebKit:

In order for the color well to accurately reflect the state of the picker, it is
necessary to ensure that the picker is destroyed at the appropriate time.

Added windowWillClose and didClosePopover delegate methods to destroy the picker
it has been closed. Also added a call to WebColorPicker::endPicker in
WebColorPickerMac's implementation of endPicker to ensure that the object is
destroyed. Removed redundant calls to endPicker in the WebPageProxy.

The hitTest method was overridden in WKPopoverColorWell to ensure that AppKit's
view does not block our drawn color well from receiving click events.

* UIProcess/WebColorPicker.cpp:
(WebKit::WebColorPicker::endPicker):
* UIProcess/WebColorPicker.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::endColorPicker):
(WebKit::WebPageProxy::didEndColorPicker):
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::closeOverlayedViews):
* UIProcess/mac/WebColorPickerMac.mm:
(WebKit::WebColorPickerMac::~WebColorPickerMac):
(WebKit::WebColorPickerMac::endPicker):
(-[WKPopoverColorWell popoverDidClose:]):
(-[WKPopoverColorWell hitTest:]):
(-[WKColorPopoverMac setAndShowPicker:withColor:suggestions:]):
(-[WKColorPopoverMac invalidate]):
(-[WKColorPopoverMac windowWillClose:]):
(-[WKColorPopoverMac didClosePopover]):

LayoutTests:

Rebaseline tests to match new color-well appearance.

* platform/mac/fast/forms/color/input-appearance-color-expected.png:
* platform/mac/fast/forms/color/input-appearance-color-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234788 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/fast/forms/color/input-appearance-color-expected.png
LayoutTests/platform/mac/fast/forms/color/input-appearance-color-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSProperties.json
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/html.css
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/ColorInputType.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/platform/ControlStates.h
Source/WebCore/platform/ThemeTypes.h
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/External/CodeMirror/css.js
Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebColorPicker.cpp
Source/WebKit/UIProcess/WebColorPicker.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/mac/WebColorPickerMac.mm