Bug 188477 - [macOS] Color wells should appear pressed when presenting a color picker
Summary: [macOS] Color wells should appear pressed when presenting a color picker
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-10 13:29 PDT by Aditya Keerthi
Modified: 2018-08-16 11:57 PDT (History)
5 users (show)

See Also:


Attachments
Patch (119.24 KB, patch)
2018-08-10 13:55 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff
Patch (119.68 KB, patch)
2018-08-10 14:39 PDT, Aditya Keerthi
thorton: review+
Details | Formatted Diff | Diff
Patch for landing (119.70 KB, patch)
2018-08-12 11:38 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aditya Keerthi 2018-08-10 13:29:54 PDT
Color wells should appear pressed when presenting a color picker.
Comment 1 Aditya Keerthi 2018-08-10 13:55:21 PDT
Created attachment 346921 [details]
Patch
Comment 2 Tim Horton 2018-08-10 14:02:20 PDT
Comment on attachment 346921 [details]
Patch

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

> Source/WebCore/platform/mac/ThemeMac.mm:714
> +    NSButtonCell *buttonCell = button(ColorWellPart, controlStates, IntSize(zoomedRect.size()), zoomFactor);

This button is kept statically, right? Who unsets highlighted?

> Source/WebKit/UIProcess/WebColorPicker.cpp:48
> +    m_client = 0;

nullptr?

> Source/WebKit/UIProcess/mac/WebColorPickerMac.mm:98
> +    if (m_colorPickerUI) {

Why doesn't this just call endPicker?
Comment 3 Aditya Keerthi 2018-08-10 14:24:04 PDT
(In reply to Tim Horton from comment #2)
> Comment on attachment 346921 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=346921&action=review
> 
> > Source/WebCore/platform/mac/ThemeMac.mm:714
> > +    NSButtonCell *buttonCell = button(ColorWellPart, controlStates, IntSize(zoomedRect.size()), zoomFactor);
> 
> This button is kept statically, right? Who unsets highlighted?

Each time a button cell is created, setUpButtonCell is called. This in turn calls updateStates, which sets the correct highlighted value given the state. Both of those methods are in ThemeMac. Now that I think about it, it might make sense to move the statement that sets the highlight from paintColorWell, to updateStates.

> 
> > Source/WebKit/UIProcess/mac/WebColorPickerMac.mm:98
> > +    if (m_colorPickerUI) {
> 
> Why doesn't this just call endPicker?

There are two ways this destructor can be called. One is by calling endPicker() which
eventually sets m_colorPicker to nullptr in WebPageProxy. If we had endPicker() in the
destructor we would be calling endPicker() in an infinite loop.

The other way for the destructor to be called is for a new color picker to be created while the previous one is still active. For example, when clicking on another color input while one is already active. In this case, endPicker() may not be called before the new color picker is created - which is why we invalidate m_colorPickerUI.
Comment 4 Tim Horton 2018-08-10 14:29:16 PDT
(In reply to Aditya Keerthi from comment #3)
> (In reply to Tim Horton from comment #2)
> > Comment on attachment 346921 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=346921&action=review
> > 
> > > Source/WebCore/platform/mac/ThemeMac.mm:714
> > > +    NSButtonCell *buttonCell = button(ColorWellPart, controlStates, IntSize(zoomedRect.size()), zoomFactor);
> > 
> > This button is kept statically, right? Who unsets highlighted?
> 
> Each time a button cell is created, setUpButtonCell is called. This in turn
> calls updateStates, which sets the correct highlighted value given the
> state. Both of those methods are in ThemeMac. Now that I think about it, it
> might make sense to move the statement that sets the highlight from
> paintColorWell, to updateStates.

Yes please.

Also fix the build.
Comment 5 Aditya Keerthi 2018-08-10 14:39:06 PDT
Created attachment 346926 [details]
Patch
Comment 6 Tim Horton 2018-08-11 12:41:00 PDT
Comment on attachment 346926 [details]
Patch

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

> Source/WebKit/UIProcess/mac/WebColorPickerMac.mm:55
> +@protocol WKPopoverColorWellDelegate<NSObject>

You should check, but I think we usually put a space before brackets for protocol conformance

> Source/WebKit/UIProcess/mac/WebColorPickerMac.mm:277
> +        [[NSColorPanel sharedColorPanel] setDelegate:nil];

Why do you use dot notation for delegate on one line and bracket notation on the next? DOTS!
Comment 7 Aditya Keerthi 2018-08-12 11:38:06 PDT
Created attachment 346987 [details]
Patch for landing
Comment 8 WebKit Commit Bot 2018-08-12 13:19:32 PDT
Comment on attachment 346987 [details]
Patch for landing

Clearing flags on attachment: 346987

Committed r234788: <https://trac.webkit.org/changeset/234788>
Comment 9 Radar WebKit Bug Importer 2018-08-16 11:57:21 PDT
<rdar://problem/43391628>