Bug 223208 - [iOS][FCR] Add pressed state for button-like controls
Summary: [iOS][FCR] Add pressed state for button-like controls
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Aditya Keerthi
URL:
Keywords: InRadar
Depends on: 223287
Blocks:
  Show dependency treegraph
 
Reported: 2021-03-15 12:27 PDT by Aditya Keerthi
Modified: 2021-03-23 11:32 PDT (History)
14 users (show)

See Also:


Attachments
Patch (5.85 KB, patch)
2021-03-15 12:33 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff
Patch (9.30 KB, patch)
2021-03-19 11:03 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff
Patch (15.54 KB, patch)
2021-03-19 12:26 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 2021-03-15 12:27:49 PDT
...
Comment 1 Aditya Keerthi 2021-03-15 12:28:05 PDT
<rdar://problem/72399087>
Comment 2 Aditya Keerthi 2021-03-15 12:33:51 PDT
Created attachment 423220 [details]
Patch
Comment 3 EWS 2021-03-16 06:43:00 PDT
Committed r274473: <https://commits.webkit.org/r274473>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 423220 [details].
Comment 4 Simon Fraser (smfr) 2021-03-16 15:37:47 PDT
Comment on attachment 423220 [details]
Patch

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

> Source/WebCore/rendering/RenderThemeIOS.mm:350
> +        style.setOpacity(0.75f);

You can't just set opacity in the style without calling Adjuster::adjust() - opacity has side effects, like creating CSS stacking context.
Comment 5 WebKit Commit Bot 2021-03-16 15:50:05 PDT
Re-opened since this is blocked by bug 223287
Comment 6 Aditya Keerthi 2021-03-19 11:03:19 PDT
Created attachment 423746 [details]
Patch
Comment 7 Simon Fraser (smfr) 2021-03-19 11:23:23 PDT
Comment on attachment 423746 [details]
Patch

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

> Source/WebCore/rendering/RenderThemeIOS.mm:2124
> +        if (pressed)
> +            context.fillRoundedRect(checkboxRect, systemColor(CSSValueAppleSystemBlue, styleColorOptions).colorWithAlphaMultipliedBy(pressedStateOpacity));
> +        else if (enabled)
>              context.fillRoundedRect(checkboxRect, systemColor(CSSValueAppleSystemBlue, styleColorOptions));
>          else
>              context.fillRoundedRect(checkboxRect, systemColor(CSSValueAppleSystemSecondaryFillDisabled, styleColorOptions));

With code like this, it's much better to factor it so that you only call the actual function once. Prepare the inputs based on state, but just have one call to context.fillRoundedRect()
Comment 8 Aditya Keerthi 2021-03-19 12:26:59 PDT
Created attachment 423759 [details]
Patch
Comment 9 Aditya Keerthi 2021-03-19 12:28:03 PDT
(In reply to Simon Fraser (smfr) from comment #7)
> Comment on attachment 423746 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=423746&action=review
> 
> > Source/WebCore/rendering/RenderThemeIOS.mm:2124
> > +        if (pressed)
> > +            context.fillRoundedRect(checkboxRect, systemColor(CSSValueAppleSystemBlue, styleColorOptions).colorWithAlphaMultipliedBy(pressedStateOpacity));
> > +        else if (enabled)
> >              context.fillRoundedRect(checkboxRect, systemColor(CSSValueAppleSystemBlue, styleColorOptions));
> >          else
> >              context.fillRoundedRect(checkboxRect, systemColor(CSSValueAppleSystemSecondaryFillDisabled, styleColorOptions));
> 
> With code like this, it's much better to factor it so that you only call the
> actual function once. Prepare the inputs based on state, but just have one
> call to context.fillRoundedRect()

Done. I moved the color determination into separate methods, so that they can be used for both checkboxes and radio buttons.
Comment 10 Simon Fraser (smfr) 2021-03-23 10:57:43 PDT
Comment on attachment 423759 [details]
Patch

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

> Source/WebCore/rendering/RenderThemeIOS.mm:2100
> +    if (!(states & ControlStates::EnabledState))

ControlStates::States should be an enum class, and be used OptionSet<>
Comment 11 Aditya Keerthi 2021-03-23 11:04:10 PDT
(In reply to Simon Fraser (smfr) from comment #10)
> Comment on attachment 423759 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=423759&action=review
> 
> > Source/WebCore/rendering/RenderThemeIOS.mm:2100
> > +    if (!(states & ControlStates::EnabledState))
> 
> ControlStates::States should be an enum class, and be used OptionSet<>

Tracking this refactoring in https://bugs.webkit.org/show_bug.cgi?id=223647.
Comment 12 EWS 2021-03-23 11:32:03 PDT
Committed r274886: <https://commits.webkit.org/r274886>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 423759 [details].