| Differences between
and this patch
- a/Source/WebCore/ChangeLog +21 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2022-04-27  Oriol Brufau  <obrufau@igalia.com>
2
3
        [css-cascade] Sort shorthand properties at the end of CSSPropertyID enum
4
        https://bugs.webkit.org/show_bug.cgi?id=238888
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Only longhands should matter during the CSS Cascade, so by sorting
9
        shorthands at the end, and ignoring them, we can save some memory and
10
        avoid some iterations.
11
12
        No test since now there should be no observable change in behavior.
13
14
        * css/makeprop.pl:
15
        (addProperty):
16
        (sortByDescendingPriorityAndName):
17
        Sort shorthand properties at the end.
18
19
        * style/PropertyCascade.h:
20
        Update comment.
21
1
2022-04-26  Oriol Brufau  <obrufau@igalia.com>
22
2022-04-26  Oriol Brufau  <obrufau@igalia.com>
2
23
3
        [css-logical] Side border shorthands should not be logical/physical
24
        [css-logical] Side border shorthands should not be logical/physical
- a/Source/WebCore/css/makeprop.pl -4 / +20 lines
Lines 284-291 sub addProperty($$) a/Source/WebCore/css/makeprop.pl_sec1
284
                } elsif ($codegenOptionName eq "comment") {
284
                } elsif ($codegenOptionName eq "comment") {
285
                    next;
285
                    next;
286
                } elsif ($codegenOptionName eq "high-priority") {
286
                } elsif ($codegenOptionName eq "high-priority") {
287
                    die "$name is a shorthand, but has high-priority" if exists $codegenProperties->{"longhands"};
287
                    $nameIsHighPriority{$name} = 1;
288
                    $nameIsHighPriority{$name} = 1;
288
                } elsif ($codegenOptionName eq "sink-priority") {
289
                } elsif ($codegenOptionName eq "sink-priority") {
290
                    die "$name is a shorthand, but has sink-priority" if exists $codegenProperties->{"longhands"};
289
                    $namePriorityShouldSink{$name} = 1;
291
                    $namePriorityShouldSink{$name} = 1;
290
                } elsif ($codegenOptionName eq "related-property") {
292
                } elsif ($codegenOptionName eq "related-property") {
291
                    $relatedProperty{$name} = $codegenProperties->{"related-property"}
293
                    $relatedProperty{$name} = $codegenProperties->{"related-property"}
Lines 353-366 sub addProperty($$) a/Source/WebCore/css/makeprop.pl_sec2
353
355
354
sub sortByDescendingPriorityAndName
356
sub sortByDescendingPriorityAndName
355
{
357
{
356
    # Sort names with high priority to the front
358
    # Sort shorthands to the back
359
    if (exists $propertiesWithStyleBuilderOptions{$a}{"longhands"} < exists $propertiesWithStyleBuilderOptions{$b}{"longhands"}) {
360
        return -1;
361
    }
362
    if (exists $propertiesWithStyleBuilderOptions{$a}{"longhands"} > exists $propertiesWithStyleBuilderOptions{$b}{"longhands"}) {
363
        return 1;
364
    }
365
    # Sort longhands with high priority to the front
357
    if (!!$nameIsHighPriority{$a} < !!$nameIsHighPriority{$b}) {
366
    if (!!$nameIsHighPriority{$a} < !!$nameIsHighPriority{$b}) {
358
        return 1;
367
        return 1;
359
    }
368
    }
360
    if (!!$nameIsHighPriority{$a} > !!$nameIsHighPriority{$b}) {
369
    if (!!$nameIsHighPriority{$a} > !!$nameIsHighPriority{$b}) {
361
        return -1;
370
        return -1;
362
    }
371
    }
363
    # Defer names with a related property to the back
372
    # Defer longhands with a related property to the back, before shorthands
364
    if (!!$relatedProperty{$a} < !!$relatedProperty{$b}) {
373
    if (!!$relatedProperty{$a} < !!$relatedProperty{$b}) {
365
        return -1;
374
        return -1;
366
    }
375
    }
Lines 849-857 my $firstLowPriorityPropertyName; a/Source/WebCore/css/makeprop.pl_sec3
849
my $lastLowPriorityPropertyName;
858
my $lastLowPriorityPropertyName;
850
my $firstDeferredPropertyName;
859
my $firstDeferredPropertyName;
851
my $lastDeferredPropertyName;
860
my $lastDeferredPropertyName;
861
my $firstShorthand;
862
my $lastShorthand;
852
foreach my $name (@names) {
863
foreach my $name (@names) {
853
  # Assumes that @names is sorted by descending priorities.
864
  # Assumes that @names is sorted by descending priorities.
854
  if ($nameIsHighPriority{$name}) {
865
  if (exists $propertiesWithStyleBuilderOptions{$name}{"longhands"}) {
866
    $firstShorthand = $name if !$firstShorthand;
867
    $lastShorthand = $name;
868
  } elsif ($nameIsHighPriority{$name}) {
855
    $firstHighPriorityPropertyName = $name if !$firstHighPriorityPropertyName;
869
    $firstHighPriorityPropertyName = $name if !$firstHighPriorityPropertyName;
856
    $lastHighPriorityPropertyName = $name;
870
    $lastHighPriorityPropertyName = $name;
857
  } elsif (!$relatedProperty{$name}) {
871
  } elsif (!$relatedProperty{$name}) {
Lines 880-886 print HEADER "const CSSPropertyID lastHighPriorityProperty = CSSProperty" . $nam a/Source/WebCore/css/makeprop.pl_sec4
880
print HEADER "const CSSPropertyID firstLowPriorityProperty = CSSProperty" . $nameToId{$firstLowPriorityPropertyName} . ";\n";
894
print HEADER "const CSSPropertyID firstLowPriorityProperty = CSSProperty" . $nameToId{$firstLowPriorityPropertyName} . ";\n";
881
print HEADER "const CSSPropertyID lastLowPriorityProperty = CSSProperty" . $nameToId{$lastLowPriorityPropertyName} . ";\n";
895
print HEADER "const CSSPropertyID lastLowPriorityProperty = CSSProperty" . $nameToId{$lastLowPriorityPropertyName} . ";\n";
882
print HEADER "const CSSPropertyID firstDeferredProperty = CSSProperty" . $nameToId{$firstDeferredPropertyName} . ";\n";
896
print HEADER "const CSSPropertyID firstDeferredProperty = CSSProperty" . $nameToId{$firstDeferredPropertyName} . ";\n";
883
print HEADER "const CSSPropertyID lastDeferredProperty = CSSProperty" . $nameToId{$lastDeferredPropertyName} . ";\n\n";
897
print HEADER "const CSSPropertyID lastDeferredProperty = CSSProperty" . $nameToId{$lastDeferredPropertyName} . ";\n";
898
print HEADER "const CSSPropertyID firstShorthand = CSSProperty" . $nameToId{$firstShorthand} . ";\n";
899
print HEADER "const CSSPropertyID lastShorthand = CSSProperty" . $nameToId{$lastShorthand} . ";\n\n";
884
900
885
print HEADER "static const CSSPropertyID computedPropertyIDs[] = {\n";
901
print HEADER "static const CSSPropertyID computedPropertyIDs[] = {\n";
886
my $numComputedPropertyIDs = 0;
902
my $numComputedPropertyIDs = 0;
- a/Source/WebCore/style/PropertyCascade.h -4 / +5 lines
Lines 99-109 private: a/Source/WebCore/style/PropertyCascade.h_sec1
99
99
100
    // The CSSPropertyID enum is sorted like this:
100
    // The CSSPropertyID enum is sorted like this:
101
    // 1. CSSPropertyInvalid and CSSPropertyCustom.
101
    // 1. CSSPropertyInvalid and CSSPropertyCustom.
102
    // 2. Normal properties (high priority ones followed by low priority ones).
102
    // 2. Normal longhands (high priority ones followed by low priority ones).
103
    // 3. Deferred properties.
103
    // 3. Deferred longhands.
104
    // 4. Shorthands.
104
    //
105
    //
105
    // 'm_properties' is used for both normal and deferred properties, so it has size 'lastDeferredProperty + 1'.
106
    // 'm_properties' is used for both normal and deferred longhands, so it has size 'lastDeferredProperty + 1'.
106
    // It could actually use 'numCSSProperties', but then we would have to subtract 'firstCSSProperty', which may not be worth it.
107
    // It could actually be 2 units smaller, but then we would have to subtract 'firstCSSProperty', which may not be worth it.
107
    // 'm_propertyIsPresent' is not used for deferred properties, so we only need to cover up to the last low priority one.
108
    // 'm_propertyIsPresent' is not used for deferred properties, so we only need to cover up to the last low priority one.
108
    std::array<Property, lastDeferredProperty + 1> m_properties;
109
    std::array<Property, lastDeferredProperty + 1> m_properties;
109
    std::bitset<lastLowPriorityProperty + 1> m_propertyIsPresent;
110
    std::bitset<lastLowPriorityProperty + 1> m_propertyIsPresent;

Return to Bug 238888