Title: [293622] trunk/Source/WebCore
- Revision
- 293622
- Author
- [email protected]
- Date
- 2022-04-29 11:08:24 -0700 (Fri, 29 Apr 2022)
Log Message
[css-cascade] Sort shorthand properties at the end of CSSPropertyID enum
https://bugs.webkit.org/show_bug.cgi?id=238888
Reviewed by Darin Adler.
Only longhands should matter during the CSS Cascade, so by sorting
shorthands at the end, and ignoring them, we can save some memory and
avoid some iterations.
No test since now there should be no observable change in behavior.
* css/StylePropertyShorthand.cpp:
(WebCore::isShorthandCSSProperty): Deleted.
* css/StylePropertyShorthand.h:
(WebCore::isShorthandCSSProperty):
Turn function into a simple constexpr comparison.
* css/makeprop.pl:
(addProperty):
(sortByDescendingPriorityAndName):
Sort shorthand properties at the end.
* style/PropertyCascade.h:
Update comment.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (293621 => 293622)
--- trunk/Source/WebCore/ChangeLog 2022-04-29 17:47:48 UTC (rev 293621)
+++ trunk/Source/WebCore/ChangeLog 2022-04-29 18:08:24 UTC (rev 293622)
@@ -1,3 +1,30 @@
+2022-04-29 Oriol Brufau <[email protected]>
+
+ [css-cascade] Sort shorthand properties at the end of CSSPropertyID enum
+ https://bugs.webkit.org/show_bug.cgi?id=238888
+
+ Reviewed by Darin Adler.
+
+ Only longhands should matter during the CSS Cascade, so by sorting
+ shorthands at the end, and ignoring them, we can save some memory and
+ avoid some iterations.
+
+ No test since now there should be no observable change in behavior.
+
+ * css/StylePropertyShorthand.cpp:
+ (WebCore::isShorthandCSSProperty): Deleted.
+ * css/StylePropertyShorthand.h:
+ (WebCore::isShorthandCSSProperty):
+ Turn function into a simple constexpr comparison.
+
+ * css/makeprop.pl:
+ (addProperty):
+ (sortByDescendingPriorityAndName):
+ Sort shorthand properties at the end.
+
+ * style/PropertyCascade.h:
+ Update comment.
+
2022-04-29 Jer Noble <[email protected]>
[iOS] Video on twitch.tv shifts to top of screen when toggling playback in fullscreen
Modified: trunk/Source/WebCore/css/StylePropertyShorthand.cpp (293621 => 293622)
--- trunk/Source/WebCore/css/StylePropertyShorthand.cpp 2022-04-29 17:47:48 UTC (rev 293621)
+++ trunk/Source/WebCore/css/StylePropertyShorthand.cpp 2022-04-29 18:08:24 UTC (rev 293622)
@@ -53,11 +53,6 @@
return StylePropertyShorthand(CSSPropertyTransition, transitionProperties);
}
-bool isShorthandCSSProperty(CSSPropertyID id)
-{
- return shorthandForProperty(id).length();
-}
-
unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const StylePropertyShorthandVector& shorthands)
{
for (unsigned i = 0, size = shorthands.size(); i < size; ++i) {
Modified: trunk/Source/WebCore/css/StylePropertyShorthand.h (293621 => 293622)
--- trunk/Source/WebCore/css/StylePropertyShorthand.h 2022-04-29 17:47:48 UTC (rev 293621)
+++ trunk/Source/WebCore/css/StylePropertyShorthand.h 2022-04-29 18:08:24 UTC (rev 293622)
@@ -66,6 +66,9 @@
unsigned indexOfShorthandForLonghand(CSSPropertyID, const StylePropertyShorthandVector&);
-bool isShorthandCSSProperty(CSSPropertyID);
+constexpr bool isShorthandCSSProperty(CSSPropertyID id)
+{
+ return id >= firstShorthandProperty && id <= lastShorthandProperty;
+}
} // namespace WebCore
Modified: trunk/Source/WebCore/css/makeprop.pl (293621 => 293622)
--- trunk/Source/WebCore/css/makeprop.pl 2022-04-29 17:47:48 UTC (rev 293621)
+++ trunk/Source/WebCore/css/makeprop.pl 2022-04-29 18:08:24 UTC (rev 293622)
@@ -285,8 +285,10 @@
} elsif ($codegenOptionName eq "comment") {
next;
} elsif ($codegenOptionName eq "high-priority") {
+ die "$name is a shorthand, but has high-priority" if exists $codegenProperties->{"longhands"};
$nameIsHighPriority{$name} = 1;
} elsif ($codegenOptionName eq "sink-priority") {
+ die "$name is a shorthand, but has sink-priority" if exists $codegenProperties->{"longhands"};
$namePriorityShouldSink{$name} = 1;
} elsif ($codegenOptionName eq "related-property") {
$nameIsDeferred{$name} = 1;
@@ -356,7 +358,14 @@
sub sortByDescendingPriorityAndName
{
- # Sort names with high priority to the front
+ # Sort shorthands to the back
+ if (exists $propertiesWithStyleBuilderOptions{$a}{"longhands"} < exists $propertiesWithStyleBuilderOptions{$b}{"longhands"}) {
+ return -1;
+ }
+ if (exists $propertiesWithStyleBuilderOptions{$a}{"longhands"} > exists $propertiesWithStyleBuilderOptions{$b}{"longhands"}) {
+ return 1;
+ }
+ # Sort longhands with high priority to the front
if (!!$nameIsHighPriority{$a} < !!$nameIsHighPriority{$b}) {
return 1;
}
@@ -363,7 +372,7 @@
if (!!$nameIsHighPriority{$a} > !!$nameIsHighPriority{$b}) {
return -1;
}
- # Defer names with a related property to the back
+ # Sort deferred longhands to the back, before shorthands
if (!!$nameIsDeferred{$a} < !!$nameIsDeferred{$b}) {
return -1;
}
@@ -850,9 +859,14 @@
my $lastLowPriorityPropertyName;
my $firstDeferredPropertyName;
my $lastDeferredPropertyName;
+my $firstShorthandPropertyName;
+my $lastShorthandPropertyName;
foreach my $name (@names) {
# Assumes that @names is sorted by descending priorities.
- if ($nameIsHighPriority{$name}) {
+ if (exists $propertiesWithStyleBuilderOptions{$name}{"longhands"}) {
+ $firstShorthandPropertyName = $name if !$firstShorthandPropertyName;
+ $lastShorthandPropertyName = $name;
+ } elsif ($nameIsHighPriority{$name}) {
$firstHighPriorityPropertyName = $name if !$firstHighPriorityPropertyName;
$lastHighPriorityPropertyName = $name;
} elsif (!$nameIsDeferred{$name}) {
@@ -881,7 +895,9 @@
print HEADER "const CSSPropertyID firstLowPriorityProperty = CSSProperty" . $nameToId{$firstLowPriorityPropertyName} . ";\n";
print HEADER "const CSSPropertyID lastLowPriorityProperty = CSSProperty" . $nameToId{$lastLowPriorityPropertyName} . ";\n";
print HEADER "const CSSPropertyID firstDeferredProperty = CSSProperty" . $nameToId{$firstDeferredPropertyName} . ";\n";
-print HEADER "const CSSPropertyID lastDeferredProperty = CSSProperty" . $nameToId{$lastDeferredPropertyName} . ";\n\n";
+print HEADER "const CSSPropertyID lastDeferredProperty = CSSProperty" . $nameToId{$lastDeferredPropertyName} . ";\n";
+print HEADER "const CSSPropertyID firstShorthandProperty = CSSProperty" . $nameToId{$firstShorthandPropertyName} . ";\n";
+print HEADER "const CSSPropertyID lastShorthandProperty = CSSProperty" . $nameToId{$lastShorthandPropertyName} . ";\n\n";
print HEADER "static const CSSPropertyID computedPropertyIDs[] = {\n";
my $numComputedPropertyIDs = 0;
Modified: trunk/Source/WebCore/style/PropertyCascade.h (293621 => 293622)
--- trunk/Source/WebCore/style/PropertyCascade.h 2022-04-29 17:47:48 UTC (rev 293621)
+++ trunk/Source/WebCore/style/PropertyCascade.h 2022-04-29 18:08:24 UTC (rev 293622)
@@ -89,11 +89,12 @@
// The CSSPropertyID enum is sorted like this:
// 1. CSSPropertyInvalid and CSSPropertyCustom.
- // 2. Normal properties (high priority ones followed by low priority ones).
- // 3. Deferred properties.
+ // 2. Normal longhand properties (high priority ones followed by low priority ones).
+ // 3. Deferred longhand properties.
+ // 4. Shorthand properties.
//
- // 'm_properties' is used for both normal and deferred properties, so it has size 'lastDeferredProperty + 1'.
- // It could actually use 'numCSSProperties', but then we would have to subtract 'firstCSSProperty', which may not be worth it.
+ // 'm_properties' is used for both normal and deferred longhands, so it has size 'lastDeferredProperty + 1'.
+ // It could actually be 2 units smaller, but then we would have to subtract 'firstCSSProperty', which may not be worth it.
// 'm_propertyIsPresent' is not used for deferred properties, so we only need to cover up to the last low priority one.
std::array<Property, lastDeferredProperty + 1> m_properties;
std::bitset<lastLowPriorityProperty + 1> m_propertyIsPresent;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes