Bug 238888 - [css-cascade] makeprop.pl could sort shorthands properties at the end, and ignore them during the cascade
Summary: [css-cascade] makeprop.pl could sort shorthands properties at the end, and ig...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Oriol Brufau
URL:
Keywords: InRadar
Depends on: 239734
Blocks: 245901
  Show dependency treegraph
 
Reported: 2022-04-06 13:55 PDT by Oriol Brufau
Modified: 2022-09-30 15:10 PDT (History)
9 users (show)

See Also:


Attachments
Patch (6.03 KB, patch)
2022-04-27 08:11 PDT, Oriol Brufau
no flags Details | Formatted Diff | Diff
Patch (7.74 KB, patch)
2022-04-28 03:37 PDT, Oriol Brufau
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oriol Brufau 2022-04-06 13:55:01 PDT
In bug 238345 I plan to sort deferred properties after normal properties, since they cascade in a special way.
Something similar could be done for shorthands.

StyleBuilder.cpp does something like

    applyProperties(firstCSSProperty, lastHighPriorityProperty);
    applyProperties(firstLowPriorityProperty, lastCSSProperty);
    
    inline void Builder::applyPropertiesImpl(int firstProperty, int lastProperty)
    {
        for (int id = firstProperty; id <= lastProperty; ++id) {
            CSSPropertyID propertyID = static_cast<CSSPropertyID>(id);
            if (!m_cascade.hasProperty(propertyID))
                continue;

Currently, shorthand properties are mixed among longhands, so they are iterated, but hasProperty() will be false.
Then they are wasting some memory in PropertyCascade.h:

    Property m_properties[numCSSProperties + 2];
    std::bitset<numCSSProperties + 2> m_propertyIsPresent;

So I think CSSPropertyID could be sorted as such:

 1. Special meaning (CSSPropertyInvalid and CSSPropertyCustom)
 2. High priority longhands
 3. Low priority longhands
 4. Deferred longhands
 5. Shorthands

About a 15-20% of the properties seem to be shorthands, so it may be worth trying.
Comment 1 Radar WebKit Bug Importer 2022-04-13 13:55:14 PDT
<rdar://problem/91712874>
Comment 2 Oriol Brufau 2022-04-27 08:11:12 PDT
Created attachment 458446 [details]
Patch
Comment 3 Oriol Brufau 2022-04-28 03:37:24 PDT
Created attachment 458509 [details]
Patch
Comment 4 EWS 2022-04-29 11:09:37 PDT
Committed r293622 (250128@main): <https://commits.webkit.org/250128@main>

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