Bug 235003

Summary: Use IsNegation bit for more efficient pseudo-class style invalidation
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: CSSAssignee: Antti Koivisto <koivisto>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, cmarcelo, emilio, esprehn+autocc, ews-watchlist, gyuyoung.kim, kangil.han, mifenton, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch for landing none

Description Antti Koivisto 2022-01-08 06:11:25 PST
We already use it for class invalidation.
Comment 1 Antti Koivisto 2022-01-08 06:19:44 PST
Created attachment 448668 [details]
Patch
Comment 2 Antti Koivisto 2022-01-08 06:42:29 PST
Created attachment 448669 [details]
Patch
Comment 3 Antti Koivisto 2022-01-08 06:53:32 PST
Created attachment 448670 [details]
Patch
Comment 4 Simon Fraser (smfr) 2022-01-08 10:17:21 PST
Comment on attachment 448670 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        We now know is an invaliation ruleset is for negated context. We can use this to avoid

Does not parse

> Source/WebCore/dom/Element.cpp:799
> +        Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassActive, flag, invalidationScope);

flag needs a better name

> Source/WebCore/dom/Element.cpp:851
> +    Style::PseudoClassChangeInvalidation focusStyleInvalidation(*this, { { CSSSelector::PseudoClassFocus, flag }, { CSSSelector::PseudoClassFocusVisible, flag } });

Ditto

> Source/WebCore/dom/Element.cpp:887
> +        Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassFocusWithin, flag);

Ditto

> Source/WebCore/dom/Element.cpp:897
> +        Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassHover, flag, invalidationScope);

Ditto

> Source/WebCore/dom/Element.cpp:910
> +    Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassDrag, flag);

Ditto

> Source/WebCore/html/HTMLInputElement.cpp:978
> -void HTMLInputElement::setChecked(bool nowChecked)
> +void HTMLInputElement::setChecked(bool newChecked)

The rename doesn't really help. why not just isChecked or checked?
Comment 5 Antti Koivisto 2022-01-09 00:30:06 PST
Created attachment 448696 [details]
Patch for landing
Comment 6 EWS 2022-01-09 01:02:54 PST
Committed r287818 (245870@main): <https://commits.webkit.org/245870@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 448696 [details].
Comment 7 Radar WebKit Bug Importer 2022-01-09 01:03:18 PST
<rdar://problem/87304694>
Comment 8 Emilio Cobos Álvarez (:emilio) 2022-01-09 02:45:05 PST
Comment on attachment 448696 [details]
Patch for landing

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

> Source/WebCore/dom/Element.cpp:852
> +    document().userActionElements().setFocused(*this, value);

Probably a bug: this is not the value that ends up getting passed to setHasFocusVisible
Comment 9 Antti Koivisto 2022-01-09 04:54:31 PST
Comment on attachment 448696 [details]
Patch for landing

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

>> Source/WebCore/dom/Element.cpp:852
>> +    document().userActionElements().setFocused(*this, value);
> 
> Probably a bug: this is not the value that ends up getting passed to setHasFocusVisible

True though I think it just causes unnecessary invalidation in some cases (when focus changes but focus-visible stays the same).