Bug 282009

Summary: :hover does not apply outline styles if there is also a text-decoration style
Product: WebKit Reporter: Alex Chan <webkitbugzilla>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, fantasai.bugs, koivisto, simon.fraser, vitor.roriz, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari 18   
Hardware: Unspecified   
OS: macOS 14   
Attachments:
Description Flags
Screen recording of the demo
none
Test reduction
none
[fast-cq]Patch none

Alex Chan
Reported 2024-10-23 15:50:08 PDT
Created attachment 473025 [details] Screen recording of the demo Here's a simple reproduction test case: ``` <style> div { display: block; height: 50px; background: #ccc; margin: 1em; } div:hover { outline: 5px solid blue; } div#outline_and_text_decoration:hover { text-decoration: underline; } </style> <div id="outline_and_text_decoration"> this gets an outline and text-decoration on hover </div> <div id="outline_only"> this only gets an outline on hover </div> ``` ## Expected behaviour ## * When you hover over the first link, it should get a thick blue outline and an underline. * When you hover over the second link, it should only get a thick blue outline. ## Actual behaviour ## * Hovering over the first link behaves incorrectly: it only gets the underline, no outline. * Hovering over the second link behaves correctly: it gets the outline. ## Affected versions ## I was able to reproduce in: * Safari 17 in macOS Sonoma 14.6.1 (I didn't get an exact version number, sorry) * Safari 18.0.1 (19619.1.26.111.11, 19619) in macOS Sonoma 14.6.1 * Safari Technology Preview Release 206 (Safari 18.0, WebKit 19621.1.3.21.1) Firefox and Chrome both do what I'd expect. I've attached a screen recording comparing Safari 18.0.1, Firefox 131.0, and Chrome 130.0.6723.70. Safari/WebKit seem to have some awareness of what the right thing is here, because applying the hover styles using the Web Inspector has the desired effect. ## The :hover is important ## If you have a persistent `text-decoration` and then apply an `outline` style on :hover, it works correctly. i.e. ``` div#outline_and_text_decoration { text-decoration: underline; } ``` instead of ``` div#outline_and_text_decoration:outline { text-decoration: underline; } ``` ## Related bugs ## I'm not sure if these are related, but I remembered a previous :hover bug I had with the anchor element: https://bugs.webkit.org/show_bug.cgi?id=61697, https://bugs.webkit.org/show_bug.cgi?id=187799
Attachments
Screen recording of the demo (17.41 MB, video/quicktime)
2024-10-23 15:50 PDT, Alex Chan
no flags
Test reduction (272 bytes, text/html)
2024-10-25 09:43 PDT, zalan
no flags
[fast-cq]Patch (3.31 KB, patch)
2024-10-25 12:16 PDT, zalan
no flags
Alex Chan
Comment 1 2024-10-23 15:51:31 PDT
The expected/actual behaviour should read: "hover over the first **div**" not link I initially encountered this bug on <a> and thought maybe it was a-specific because of 61697, but changed to div as a more generic element for the repro.
zalan
Comment 2 2024-10-25 08:50:31 PDT
It looks like a repaint issue as when repaint is forced (option+command+p -debug only) outline shows up fine.
Radar WebKit Bug Importer
Comment 3 2024-10-25 08:50:56 PDT
zalan
Comment 4 2024-10-25 09:43:50 PDT
Created attachment 473042 [details] Test reduction
zalan
Comment 5 2024-10-25 12:16:40 PDT
Created attachment 473048 [details] [fast-cq]Patch
EWS
Comment 6 2024-10-28 05:31:51 PDT
Committed 285763@main (a6d261838dcb): <https://commits.webkit.org/285763@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 473048 [details].
Note You need to log in before you can comment on or make changes to this bug.