Bug 237236 - Fix typo in StyleSharingResolver
Summary: Fix typo in StyleSharingResolver
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Nguyen (:ntim)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-26 08:10 PST by Tim Nguyen (:ntim)
Modified: 2022-03-01 03:27 PST (History)
3 users (show)

See Also:


Attachments
Patch (1.66 KB, patch)
2022-02-28 00:46 PST, Tim Nguyen (:ntim)
koivisto: review+
Details | Formatted Diff | Diff
Patch (1.68 KB, patch)
2022-02-28 05:37 PST, Tim Nguyen (:ntim)
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (3.96 KB, patch)
2022-02-28 11:45 PST, Tim Nguyen (:ntim)
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (4.12 KB, patch)
2022-02-28 12:53 PST, Tim Nguyen (:ntim)
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (4.30 KB, patch)
2022-02-28 15:11 PST, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff
[fast-cq] Patch (4.48 KB, patch)
2022-02-28 15:16 PST, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Nguyen (:ntim) 2022-02-26 08:10:44 PST
https://webkit-search.igalia.com/webkit/rev/d9fb961816b603d071c05f5fbc2754c061adabaa/Source/WebCore/style/StyleSharingResolver.cpp#300-301

```
    if (element.matchesInvalidPseudoClass() != element.matchesValidPseudoClass())
        return false;
```

This essentially is `if (true) return false` in most cases.

This typo was introduced in bug 153768, before that it was:

```
    if (element->matchesInvalidPseudoClass() != state.element()->matchesValidPseudoClass())
        return false;
```

That version was introduced in bug 138769, which I also doubt is correct, since it says if both elements are invalid, then do not share.

I think the version that we want is:

```
    if (candidateElement.matchesInvalidPseudoClass() != element.matchesInvalidPseudoClass())
        return false;
```

which is sort of redundant with `if (candidateElement.matchesValidPseudoClass() != element.matchesValidPseudoClass())` above, so maybe this should just be an ASSERT checking that valid is the exact opposite of invalid.
Comment 1 Tim Nguyen (:ntim) 2022-02-28 00:46:56 PST
Created attachment 453372 [details]
Patch
Comment 2 Antti Koivisto 2022-02-28 04:14:16 PST
Comment on attachment 453372 [details]
Patch

test would be nice
Comment 3 Antti Koivisto 2022-02-28 04:16:03 PST
Comment on attachment 453372 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        The typo was introduced in bug 153768 and bug 138769. This essentially disables
> +        style sharing completely for many elements which isn't great.

I think it only really affected form controls.
Comment 4 Antti Koivisto 2022-02-28 04:22:16 PST
Another option would be to disable it more robustly as it is probably not a super valuable optimization. I'd like to eliminate style sharing completely at some point as it doesn't work well with things like :has() and container queries.
Comment 5 Tim Nguyen (:ntim) 2022-02-28 05:37:33 PST
Created attachment 453386 [details]
Patch
Comment 6 Tim Nguyen (:ntim) 2022-02-28 11:45:11 PST
Created attachment 453412 [details]
Patch
Comment 7 Tim Nguyen (:ntim) 2022-02-28 12:53:32 PST
Created attachment 453416 [details]
Patch
Comment 8 Darin Adler 2022-02-28 13:51:26 PST
Comment on attachment 453416 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        Explicitely disable style sharing for form controls

Spelling error here "Explicitly".

> Source/WebCore/ChangeLog:6
> +        Reviewed by Antti Koivisto.

If this is already reviewed, then I guess I won’t. Antti does seem like the best reviewer for a style sharing change.
Comment 9 Tim Nguyen (:ntim) 2022-02-28 15:11:13 PST
Created attachment 453438 [details]
Patch
Comment 10 Tim Nguyen (:ntim) 2022-02-28 15:16:53 PST
Created attachment 453441 [details]
[fast-cq] Patch
Comment 11 EWS 2022-03-01 03:26:10 PST
Committed r290640 (247913@main): <https://commits.webkit.org/247913@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453441 [details].
Comment 12 Radar WebKit Bug Importer 2022-03-01 03:27:18 PST
<rdar://problem/89611152>