Log Message
[css-cascade] Merge getRelatedPropertyId() and shouldApplyPropertyInParseOrder() https://bugs.webkit.org/show_bug.cgi?id=238350
Reviewed by Darin Adler. Both getRelatedPropertyId() and shouldApplyPropertyInParseOrder() pursue the same thing: if there are two properties (typically a standard one and a -webkit- prefixed one) which share the same field in RenderStyle, then we should take specified order into account when applying them. The problem is that the logic for getRelatedPropertyId() doesn't work well in all cases. It was only used for -webkit-text-orientation and text-orientation, but bug 238356 implemented the former as a shorthand. So now there is no consumer of getRelatedPropertyId(). On the other hand, shouldApplyPropertyInParseOrder() works better, but it will need to be automatically generated for bug 238345, and bug 238125 will need to know which property shares a computed value with a given one. So this patch removes the consumers of the old getRelatedPropertyId(), and changes shouldApplyPropertyInParseOrder() to be based on it. No new tests since there is no change in behavior. * css/CSSProperties.json: Mark properties for which shouldApplyPropertyInParseOrder() returned true with the "related-property" flag. * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal): Remove old getRelatedPropertyId() logic which was unused. * css/makeprop.pl: Throw errors if "related-property" flag is invalid. * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): Remove old getRelatedPropertyId() logic which was unused. * style/PropertyCascade.cpp: (WebCore::Style::shouldApplyPropertyInParseOrder): Base shouldApplyPropertyInParseOrder() on getRelatedPropertyId().
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (292635 => 292636)
--- trunk/Source/WebCore/ChangeLog 2022-04-08 21:35:00 UTC (rev 292635)
+++ trunk/Source/WebCore/ChangeLog 2022-04-08 21:39:57 UTC (rev 292636)
@@ -1,3 +1,49 @@
+2022-04-08 Oriol Brufau <obru...@igalia.com>
+
+ [css-cascade] Merge getRelatedPropertyId() and shouldApplyPropertyInParseOrder()
+ https://bugs.webkit.org/show_bug.cgi?id=238350
+
+ Reviewed by Darin Adler.
+
+ Both getRelatedPropertyId() and shouldApplyPropertyInParseOrder() pursue
+ the same thing: if there are two properties (typically a standard one
+ and a -webkit- prefixed one) which share the same field in RenderStyle,
+ then we should take specified order into account when applying them.
+
+ The problem is that the logic for getRelatedPropertyId() doesn't work
+ well in all cases. It was only used for -webkit-text-orientation and
+ text-orientation, but bug 238356 implemented the former as a shorthand.
+ So now there is no consumer of getRelatedPropertyId().
+
+ On the other hand, shouldApplyPropertyInParseOrder() works better, but
+ it will need to be automatically generated for bug 238345, and bug
+ 238125 will need to know which property shares a computed value with a
+ given one.
+
+ So this patch removes the consumers of the old getRelatedPropertyId(),
+ and changes shouldApplyPropertyInParseOrder() to be based on it.
+
+ No new tests since there is no change in behavior.
+
+ * css/CSSProperties.json:
+ Mark properties for which shouldApplyPropertyInParseOrder() returned
+ true with the "related-property" flag.
+
+ * css/PropertySetCSSStyleDeclaration.cpp:
+ (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal):
+ Remove old getRelatedPropertyId() logic which was unused.
+
+ * css/makeprop.pl:
+ Throw errors if "related-property" flag is invalid.
+
+ * css/parser/CSSParserImpl.cpp:
+ (WebCore::filterProperties):
+ Remove old getRelatedPropertyId() logic which was unused.
+
+ * style/PropertyCascade.cpp:
+ (WebCore::Style::shouldApplyPropertyInParseOrder):
+ Base shouldApplyPropertyInParseOrder() on getRelatedPropertyId().
+
2022-04-08 Antti Koivisto <an...@apple.com>
[CSS Container Queries] Search query containers for ::slotted and and ::part rules in their scope
Modified: trunk/Source/WebCore/css/CSSProperties.json (292635 => 292636)
--- trunk/Source/WebCore/css/CSSProperties.json 2022-04-08 21:35:00 UTC (rev 292635)
+++ trunk/Source/WebCore/css/CSSProperties.json 2022-04-08 21:39:57 UTC (rev 292636)
@@ -142,10 +142,13 @@
"in CSS cascading order.",
"",
"* related-property:",
- "Indicates the prefixed or unprefixed version of the same property.",
- "When parsing high priority CSS properties with both prefixed and unprefixed",
- "versions, this flig will help the parser to mark all related properties ",
- "as seen when one is seen. This could enforce the 'last-one-wins' rule.",
+ "Indicates another property which shares a computed style with the current one.",
+ "Typically used for the prefixed or unprefixed version of the same property, e.g.",
+ "-webkit-box-shadow has box-shadow as the related property, and vice versa.",
+ "Properties with this flag can't be high-priority, they are deferred to be applied",
+ "after low-priority ones, and they are specially handled to apply in parse order.",
+ "So if a declaration block contains both properties, they will be applied in the",
+ "specified order, not alphabetically within their priority bucket as usual.",
"",
"* aliases:",
"An array of the alternative names for this property. Aliases are folded at",
@@ -1123,6 +1126,7 @@
}
],
"codegen-properties": {
+ "related-property": "-webkit-background-clip",
"name-for-methods": "Clip",
"fill-layer-property": true
},
@@ -1153,6 +1157,7 @@
},
"background-origin": {
"codegen-properties": {
+ "related-property": "-webkit-background-origin",
"name-for-methods": "Origin",
"fill-layer-property": true
},
@@ -1243,6 +1248,7 @@
},
"background-size": {
"codegen-properties": {
+ "related-property": "-webkit-background-size",
"name-for-methods": "Size",
"fill-layer-property": true
},
@@ -2283,6 +2289,7 @@
},
"box-shadow": {
"codegen-properties": {
+ "related-property": "-webkit-box-shadow",
"custom": "All"
},
"specification": {
@@ -5339,6 +5346,7 @@
},
"-webkit-background-clip": {
"codegen-properties": {
+ "related-property": "background-clip",
"name-for-methods": "Clip",
"fill-layer-property": true
}
@@ -5345,6 +5353,7 @@
},
"-webkit-background-origin": {
"codegen-properties": {
+ "related-property": "background-origin",
"name-for-methods": "Origin",
"fill-layer-property": true
}
@@ -5351,6 +5360,7 @@
},
"-webkit-background-size": {
"codegen-properties": {
+ "related-property": "background-size",
"name-for-methods": "Size",
"fill-layer-property": true
},
@@ -5495,6 +5505,7 @@
},
"-webkit-box-shadow": {
"codegen-properties": {
+ "related-property": "box-shadow",
"custom": "All"
},
"status": {
Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (292635 => 292636)
--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2022-04-08 21:35:00 UTC (rev 292635)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2022-04-08 21:39:57 UTC (rev 292636)
@@ -300,14 +300,10 @@
String PropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
{
String value = m_propertySet->getPropertyValue(propertyID);
- CSSPropertyID relatedPropertyID = getRelatedPropertyId(propertyID);
- String relatedValue = m_propertySet->getPropertyValue(relatedPropertyID);
-
+
if (!value.isEmpty())
return value;
- if (!relatedValue.isEmpty())
- return relatedValue;
-
+
return { };
}
Modified: trunk/Source/WebCore/css/makeprop.pl (292635 => 292636)
--- trunk/Source/WebCore/css/makeprop.pl 2022-04-08 21:35:00 UTC (rev 292635)
+++ trunk/Source/WebCore/css/makeprop.pl 2022-04-08 21:39:57 UTC (rev 292636)
@@ -600,8 +600,14 @@
if (!$relatedProperty{$name}) {
next;
}
+ my $related = $relatedProperty{$name};
+ die "Property $name has an unknown related property: $related\n" if !exists($nameToId{$related});
+ die "High priority property $name can't have a related property: $related\n" if $nameIsHighPriority{$name};
+ die "Shorthand property $name can't have a related property: $related\n" if exists $propertiesWithStyleBuilderOptions{$name}{"longhands"};
+ die "Property $name can't have itself as a related property\n" if $related eq $name;
+ die "Property $name has $related as a related property, but it's not reciprocal\n" if $relatedProperty{$related} ne $name;
print GPERF " case CSSPropertyID::CSSProperty" . $nameToId{$name} . ":\n";
- print GPERF " return CSSPropertyID::CSSProperty" . $nameToId{$relatedProperty{$name}} . ";\n";
+ print GPERF " return CSSPropertyID::CSSProperty" . $nameToId{$related} . ";\n";
}
print GPERF << "EOF";
default:
Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.cpp (292635 => 292636)
--- trunk/Source/WebCore/css/parser/CSSParserImpl.cpp 2022-04-08 21:35:00 UTC (rev 292635)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.cpp 2022-04-08 21:39:57 UTC (rev 292636)
@@ -125,15 +125,10 @@
continue;
}
- if (seenProperties.test(propertyIDIndex))
+ auto seenPropertyBit = seenProperties[propertyIDIndex];
+ if (seenPropertyBit)
continue;
- const unsigned relatedPropertyId = getRelatedPropertyId(property.id());
- if (property.id() != CSSPropertyInvalid && relatedPropertyId != CSSPropertyInvalid) {
- const unsigned relatedPropertyIDIndex = relatedPropertyId - firstCSSProperty;
- seenProperties.set(relatedPropertyIDIndex);
- seenProperties.set(propertyIDIndex);
- } else
- seenProperties.set(propertyIDIndex);
+ seenPropertyBit = true;
output[--unusedEntries] = property;
}
Modified: trunk/Source/WebCore/style/PropertyCascade.cpp (292635 => 292636)
--- trunk/Source/WebCore/style/PropertyCascade.cpp 2022-04-08 21:35:00 UTC (rev 292635)
+++ trunk/Source/WebCore/style/PropertyCascade.cpp 2022-04-08 21:39:57 UTC (rev 292636)
@@ -40,19 +40,7 @@
static inline bool shouldApplyPropertyInParseOrder(CSSPropertyID propertyID)
{
- switch (propertyID) {
- case CSSPropertyWebkitBackgroundClip:
- case CSSPropertyBackgroundClip:
- case CSSPropertyWebkitBackgroundOrigin:
- case CSSPropertyBackgroundOrigin:
- case CSSPropertyWebkitBackgroundSize:
- case CSSPropertyBackgroundSize:
- case CSSPropertyWebkitBoxShadow:
- case CSSPropertyBoxShadow:
- return true;
- default:
- return false;
- }
+ return getRelatedPropertyId(propertyID) != CSSPropertyInvalid;
}
PropertyCascade::PropertyCascade(const MatchResult& matchResult, CascadeLevel maximumCascadeLevel, IncludedProperties includedProperties, Direction direction)
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes