Bug 238035 - nj.gov: Background color incorrect for 'State Vehicles' section
Summary: nj.gov: Background color incorrect for 'State Vehicles' section
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kate Cheney
URL:
Keywords: InRadar
: 223980 (view as bug list)
Depends on:
Blocks: 240087
  Show dependency treegraph
 
Reported: 2022-03-17 12:00 PDT by Kate Cheney
Modified: 2022-05-04 15:31 PDT (History)
11 users (show)

See Also:


Attachments
Patch (4.25 KB, patch)
2022-03-17 12:53 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (4.25 KB, patch)
2022-03-17 13:03 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (5.23 KB, patch)
2022-03-17 13:50 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (6.72 KB, patch)
2022-03-17 17:33 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (8.03 KB, patch)
2022-03-18 09:50 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
PFL once EWS is happy (8.03 KB, patch)
2022-03-18 09:57 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (8.68 KB, patch)
2022-03-21 13:01 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kate Cheney 2022-03-17 12:00:34 PDT
nj.gov: Background color incorrect for 'State Vehicles' section
Comment 1 Kate Cheney 2022-03-17 12:53:53 PDT
Created attachment 455006 [details]
Patch
Comment 2 Chris Dumez 2022-03-17 12:57:28 PDT
Comment on attachment 455006 [details]
Patch

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

> Source/WebCore/rendering/RenderTheme.cpp:114
> +static bool shouldIgnoreAppearance(RenderStyle& style)

Not really my area but it feels like this parameter could/should be const.
Comment 3 Kate Cheney 2022-03-17 13:03:37 PDT
Created attachment 455009 [details]
Patch
Comment 4 Aditya Keerthi 2022-03-17 13:18:07 PDT
Comment on attachment 455006 [details]
Patch

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

> Source/WebCore/ChangeLog:12
> +        controlled elements when they are styled by the author.

"controlled" -> "control"

>> Source/WebCore/rendering/RenderTheme.cpp:114
>> +static bool shouldIgnoreAppearance(RenderStyle& style)
> 
> Not really my area but it feels like this parameter could/should be const.

Would be nice if this method took two RenderStyle parameters, and was renamed, so that `RenderTheme::isControlStyled` can share the logic.

(and make the parameters const, as Chris said)

> LayoutTests/fast/css/non-form-control-element-drop-appearance.html:3
> +  -webkit-appearance: button;

Let's use the unprefixed "appearance".
Comment 5 Kate Cheney 2022-03-17 13:28:37 PDT
(In reply to Aditya Keerthi from comment #4)
> Comment on attachment 455006 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=455006&action=review
> 
> > Source/WebCore/ChangeLog:12
> > +        controlled elements when they are styled by the author.
> 
> "controlled" -> "control"
> 

will fix. 

> >> Source/WebCore/rendering/RenderTheme.cpp:114
> >> +static bool shouldIgnoreAppearance(RenderStyle& style)
> > 
> > Not really my area but it feels like this parameter could/should be const.
> 
> Would be nice if this method took two RenderStyle parameters, and was
> renamed, so that `RenderTheme::isControlStyled` can share the logic.
> 
> (and make the parameters const, as Chris said)
> 
sounds good, will fix

> > LayoutTests/fast/css/non-form-control-element-drop-appearance.html:3
> > +  -webkit-appearance: button;
> 
> Let's use the unprefixed "appearance".

ok. why?
Comment 6 Aditya Keerthi 2022-03-17 13:45:49 PDT
(In reply to Kate Cheney from comment #5)
> (In reply to Aditya Keerthi from comment #4)
> > Comment on attachment 455006 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=455006&action=review
> > 
> > > Source/WebCore/ChangeLog:12
> > > +        controlled elements when they are styled by the author.
> > 
> > "controlled" -> "control"
> > 
> 
> will fix. 
> 
> > >> Source/WebCore/rendering/RenderTheme.cpp:114
> > >> +static bool shouldIgnoreAppearance(RenderStyle& style)
> > > 
> > > Not really my area but it feels like this parameter could/should be const.
> > 
> > Would be nice if this method took two RenderStyle parameters, and was
> > renamed, so that `RenderTheme::isControlStyled` can share the logic.
> > 
> > (and make the parameters const, as Chris said)
> > 
> sounds good, will fix
> 
> > > LayoutTests/fast/css/non-form-control-element-drop-appearance.html:3
> > > +  -webkit-appearance: button;
> > 
> > Let's use the unprefixed "appearance".
> 
> ok. why?

There's no behavioral difference, because it's an alias, but I think it's better to use the unprefixed version of the property in new code.
Comment 7 Kate Cheney 2022-03-17 13:50:16 PDT
Created attachment 455021 [details]
Patch
Comment 8 Kate Cheney 2022-03-17 14:01:52 PDT
failing layout tests seem possibly related..
Comment 9 Kate Cheney 2022-03-17 17:33:52 PDT
Created attachment 455054 [details]
Patch
Comment 10 Aditya Keerthi 2022-03-17 21:58:54 PDT
Comment on attachment 455054 [details]
Patch

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

> Source/WebCore/rendering/RenderTheme.cpp:114
> +static bool styleBorderAndBackgroundDiffer(const RenderStyle& style, const RenderStyle& otherStyle)

I saw that we have the following methods in RenderStyle which compare two styles:

```
bool inheritedEqual(const RenderStyle&) const;
bool descendantAffectingNonInheritedPropertiesEqual(const RenderStyle&) const;
```

Consider declaring this as `bool borderAndBackgroundEqual(const RenderStyle&) const;` and implementing in `RenderStyle`.

> Source/WebCore/rendering/RenderTheme.cpp:124
> +    auto part = adjustAppearanceForElement(style, element, autoAppearanceForElement);

I prefer to avoid out-parameters when possible, as they add indirection when reading code, and can give a single method too much responsibility.

Consider moving the call to `autoAppearanceForElement()` to the line above, and passing the result into `adjustAppearanceForElement`.
Comment 11 Antti Koivisto 2022-03-17 22:08:53 PDT
Comment on attachment 455054 [details]
Patch

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

(just style comments, leaving substantive review to Aditya)

> Source/WebCore/rendering/RenderTheme.cpp:87
> +ControlPart RenderTheme::adjustAppearanceForElement(RenderStyle& style, const Element* element, ControlPart& autoAppearance) const

It would be more stylish to return both ControlPart as return values, either as struct or std::pair. Caller can then use structured bindings to unpack

auto [appareance, autoAppearance] = adjustAppearanceForElement(...).

> Source/WebCore/rendering/RenderTheme.cpp:114
> +static bool styleBorderAndBackgroundDiffer(const RenderStyle& style, const RenderStyle& otherStyle)

"differ" is an odd function name. Maybe something more descriptive like shouldIgnoreApparanceForStyle(style, baseStyle)?

> Source/WebCore/rendering/RenderTheme.cpp:151
> +    if (!userAgentAppearanceStyle && autoAppearanceForElement == NoControlPart && styleBorderAndBackgroundDiffer(style, style.defaultStyle()))

defaultStyle() is a static function, it is clearer to use RenderStyle::defaultStyle() to call it.
Comment 12 Kate Cheney 2022-03-18 09:50:12 PDT
Created attachment 455102 [details]
Patch
Comment 13 Kate Cheney 2022-03-18 09:57:58 PDT
Created attachment 455103 [details]
PFL once EWS is happy
Comment 14 Kate Cheney 2022-03-21 13:01:23 PDT
Created attachment 455266 [details]
Patch
Comment 15 EWS 2022-03-21 16:40:33 PDT
Committed r291588 (248683@main): <https://commits.webkit.org/248683@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 455266 [details].
Comment 16 Radar WebKit Bug Importer 2022-03-21 16:41:15 PDT
<rdar://problem/90600712>
Comment 17 Arcady Goldmints-Orlov 2022-04-27 14:11:33 PDT
*** Bug 223980 has been marked as a duplicate of this bug. ***