Bug 210419

Summary: [CSS Selectors] Selectors Level 4 specificity calculation for pseudo classes
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: allan.jensen, cdumez, commit-queue, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, hi, joepeck, kangil.han, macpherson, menard, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 210480    
Bug Blocks:    
Attachments:
Description Flags
patch
none
patch
none
patch
none
patch
none
patch
simon.fraser: review+
patch
none
patch none

Antti Koivisto
Reported 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.
Attachments
patch (111.82 KB, patch)
2020-04-13 03:21 PDT, Antti Koivisto
no flags
patch (111.96 KB, patch)
2020-04-13 03:42 PDT, Antti Koivisto
no flags
patch (112.68 KB, patch)
2020-04-13 04:34 PDT, Antti Koivisto
no flags
patch (113.27 KB, patch)
2020-04-13 06:26 PDT, Antti Koivisto
no flags
patch (113.32 KB, patch)
2020-04-13 06:32 PDT, Antti Koivisto
simon.fraser: review+
patch (113.22 KB, patch)
2020-04-13 09:58 PDT, Antti Koivisto
no flags
patch (102.48 KB, patch)
2020-04-14 03:20 PDT, Antti Koivisto
no flags
Antti Koivisto
Comment 1 2020-04-13 03:21:02 PDT
Antti Koivisto
Comment 2 2020-04-13 03:42:30 PDT
Antti Koivisto
Comment 3 2020-04-13 04:34:56 PDT
Antti Koivisto
Comment 4 2020-04-13 06:26:50 PDT
Antti Koivisto
Comment 5 2020-04-13 06:32:03 PDT
Simon Fraser (smfr)
Comment 6 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.
Antti Koivisto
Comment 7 2020-04-13 09:58:59 PDT
Antti Koivisto
Comment 8 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.
EWS
Comment 9 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].
Radar WebKit Bug Importer
Comment 10 2020-04-13 10:46:24 PDT
WebKit Commit Bot
Comment 11 2020-04-14 00:05:25 PDT
Re-opened since this is blocked by bug 210480
Antti Koivisto
Comment 12 2020-04-14 03:20:13 PDT
Created attachment 396398 [details] patch Reduces scope a bit so compiled selectors still cache the specificity.
EWS
Comment 13 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].
Note You need to log in before you can comment on or make changes to this bug.