Bug 210419 - [CSS Selectors] Selectors Level 4 specificity calculation for pseudo classes
Summary: [CSS Selectors] Selectors Level 4 specificity calculation for pseudo classes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on: 210480
Blocks:
  Show dependency treegraph
 
Reported: 2020-04-13 02:46 PDT by Antti Koivisto
Modified: 2020-04-14 04:37 PDT (History)
14 users (show)

See Also:


Attachments
patch (111.82 KB, patch)
2020-04-13 03:21 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (111.96 KB, patch)
2020-04-13 03:42 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (112.68 KB, patch)
2020-04-13 04:34 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (113.27 KB, patch)
2020-04-13 06:26 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (113.32 KB, patch)
2020-04-13 06:32 PDT, Antti Koivisto
simon.fraser: review+
Details | Formatted Diff | Diff
patch (113.22 KB, patch)
2020-04-13 09:58 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (102.48 KB, patch)
2020-04-14 03:20 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2020-04-13 02:46:52 PDT
CSS selector specification drafts at some point had a concept of "dynamic specificity" where the specificity of a selector depended on the element it matched. It was only ever used with :matches and :nth-child pseudo classes and has subsequently been removed. Selector specificity can now always be computed statically.

There is a ton of code to support this obsolete feature. It can be removed.
Comment 1 Antti Koivisto 2020-04-13 03:21:02 PDT
Created attachment 396264 [details]
patch
Comment 2 Antti Koivisto 2020-04-13 03:42:30 PDT
Created attachment 396265 [details]
patch
Comment 3 Antti Koivisto 2020-04-13 04:34:56 PDT
Created attachment 396266 [details]
patch
Comment 4 Antti Koivisto 2020-04-13 06:26:50 PDT
Created attachment 396267 [details]
patch
Comment 5 Antti Koivisto 2020-04-13 06:32:03 PDT
Created attachment 396268 [details]
patch
Comment 6 Simon Fraser (smfr) 2020-04-13 09:40:07 PDT
Comment on attachment 396268 [details]
patch

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

> LayoutTests/fast/css/is-specificity-3-expected.html:6
> +<div style="color: purple; background-color: blue;">Text</nottarget>

Mixing div and nottarget tags?

> LayoutTests/fast/css/matches-specificity-3-expected.html:6
> +<div style="color: purple; background-color: blue;">Text</nottarget>

Ditto.

> Source/WebCore/css/CSSSelector.cpp:95
> +static unsigned selectorSpecificity(const CSSSelector& firstSimpleSelector)

Would be nice to have a typedef for "specificity" rather than using 'unsigned' everywhere.
Comment 7 Antti Koivisto 2020-04-13 09:58:59 PDT
Created attachment 396298 [details]
patch
Comment 8 Antti Koivisto 2020-04-13 10:01:08 PDT
> Would be nice to have a typedef for "specificity" rather than using
> 'unsigned' everywhere.

Or even wrap it into a class.
Comment 9 EWS 2020-04-13 10:46:00 PDT
Committed r260024: <https://trac.webkit.org/changeset/260024>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396298 [details].
Comment 10 Radar WebKit Bug Importer 2020-04-13 10:46:24 PDT
<rdar://problem/61724793>
Comment 11 WebKit Commit Bot 2020-04-14 00:05:25 PDT
Re-opened since this is blocked by bug 210480
Comment 12 Antti Koivisto 2020-04-14 03:20:13 PDT
Created attachment 396398 [details]
patch

Reduces scope a bit so compiled selectors still cache the specificity.
Comment 13 EWS 2020-04-14 04:37:45 PDT
Committed r260069: <https://trac.webkit.org/changeset/260069>

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