Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (291593 => 291594)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-03-22 01:19:00 UTC (rev 291593)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-03-22 01:35:47 UTC (rev 291594)
@@ -1,3 +1,15 @@
+2022-03-21 Oriol Brufau <obru...@igalia.com>
+
+ [css-cascade] Let revert-layer roll back to preshints
+ https://bugs.webkit.org/show_bug.cgi?id=237532
+
+ Reviewed by Darin Adler.
+
+ Add test.
+
+ * web-platform-tests/css/css-cascade/presentational-hints-rollback-expected.txt: Added.
+ * web-platform-tests/css/css-cascade/presentational-hints-rollback.html: Added.
+
2022-03-21 Chris Dumez <cdu...@apple.com>
BroadcastChannel instances in distinct opaque origins can communicate
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback-expected.txt (0 => 291594)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback-expected.txt 2022-03-22 01:35:47 UTC (rev 291594)
@@ -0,0 +1,18 @@
+
+PASS #tests > * 1
+PASS #tests > * 2
+PASS #tests > * 3
+PASS #tests > * 4
+PASS #tests > * 5
+PASS #tests > * 6
+PASS #tests > * 7
+PASS #tests > * 8
+PASS #tests > * 9
+PASS #tests > * 10
+PASS #tests > * 11
+PASS #tests > * 12
+PASS #tests > * 13
+PASS #tests > * 14
+PASS #tests > * 15
+PASS #tests > * 16
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback.html (0 => 291594)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback.html 2022-03-22 01:35:47 UTC (rev 291594)
@@ -0,0 +1,125 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Cascade: rolling back the cascade with presentation hints</title>
+<link rel="author" title="Oriol Brufau" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<meta name="assert" content="Checks that 'revert' considers presentational hints as part of the author origin,
+ and 'revert-layer' considers them an independent origin between the user origin and the author origin.">
+
+<style>
+@layer {
+ .revert-1 {
+ width: revert;
+ height: revert;
+ }
+ .revert-layer-1 {
+ width: revert-layer;
+ height: revert-layer;
+ }
+}
+
+.revert-2 {
+ width: revert;
+ height: revert;
+}
+.revert-layer-2 {
+ width: revert-layer;
+ height: revert-layer;
+}
+
+.revert-3 {
+ animation: revert-3 paused 2s -1s;
+}
+.revert-layer-3 {
+ animation: revert-layer-3 paused 2s -1s;
+}
+@keyframes revert-3 {
+ from, to {
+ width: revert;
+ height: revert;
+ }
+}
+@keyframes revert-layer-3 {
+ from, to {
+ width: revert-layer;
+ height: revert-layer;
+ }
+}
+</style>
+
+<div id="log"></div>
+
+<div id="tests">
+ <!-- 'revert' considers presentational hints as part of the author origin, so it rolls back to user origin.
+ The images should then get an 'auto' size, which will use the natural size of the resource. -->
+ <img class="revert-1" src=""
+ width="44" data-expected-client-width="60"
+ height="33" data-expected-client-height="60">
+ <img class="revert-2" src=""
+ width="44" data-expected-client-width="60"
+ height="33" data-expected-client-height="60">
+ <img class="revert-3" src=""
+ width="44" data-expected-client-width="60"
+ height="33" data-expected-client-height="60">
+ <img style="width: revert; height: revert" src=""
+ width="44" data-expected-client-width="60"
+ height="33" data-expected-client-height="60">
+
+ <!-- 'revert-layer' considers presentational hints as an independent origin, so it rolls back to them.
+ The images should then get size specified in the attributes. -->
+ <img class="revert-layer-1" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33">
+ <img class="revert-layer-2" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33">
+ <img class="revert-layer-3" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33">
+ <img style="width: revert-layer; height: revert-layer" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33">
+
+ <!-- 'revert' considers presentational hints as part of the author origin, so it rolls back to user origin.
+ The iframes should then get an 'auto' size, which will default to 300x150. -->
+ <iframe class="revert-1" src=""
+ width="44" data-expected-client-width="300"
+ height="33" data-expected-client-height="150"></iframe>
+ <iframe class="revert-2" src=""
+ width="44" data-expected-client-width="300"
+ height="33" data-expected-client-height="150"></iframe>
+ <iframe class="revert-3" src=""
+ width="44" data-expected-client-width="300"
+ height="33" data-expected-client-height="150"></iframe>
+ <iframe style="width: revert; height: revert" src=""
+ width="44" data-expected-client-width="300"
+ height="33" data-expected-client-height="150"></iframe>
+
+ <!-- 'revert-layer' considers presentational hints as an independent origin, so it rolls back to them.
+ The iframes should then get size specified in the attributes. -->
+ <iframe class="revert-layer-1" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33"></iframe>
+ <iframe class="revert-layer-2" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33"></iframe>
+ <iframe class="revert-layer-3" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33"></iframe>
+ <iframe style="width: revert-layer; height: revert-layer" src=""
+ width="44" data-expected-client-width="44"
+ height="33" data-expected-client-height="33"></iframe>
+</div>
+
+<script src=""
+<script src=""
+<script src=""
+<script>
+addEventListener("load", function() {
+ checkLayout("#tests > *", false);
+ done();
+}, {once: true});
+</script>
Modified: trunk/Source/WebCore/ChangeLog (291593 => 291594)
--- trunk/Source/WebCore/ChangeLog 2022-03-22 01:19:00 UTC (rev 291593)
+++ trunk/Source/WebCore/ChangeLog 2022-03-22 01:35:47 UTC (rev 291594)
@@ -1,3 +1,25 @@
+2022-03-21 Oriol Brufau <obru...@igalia.com>
+
+ [css-cascade] Let revert-layer roll back to preshints
+ https://bugs.webkit.org/show_bug.cgi?id=237532
+
+ Reviewed by Darin Adler.
+
+ The patch makes presentational hints use a cascade layer priority of 0.
+ The priority of the lowest layer is then increased to 1.
+ This allows 'revert-layer' in author origin revert to the presentational
+ hints origin, which is between user origin and author origin.
+
+ Test: imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback.html
+
+ * style/ElementRuleCollector.cpp:
+ (WebCore::Style::ElementRuleCollector::addElementStyleProperties):
+ (WebCore::Style::ElementRuleCollector::matchAllRules):
+ (WebCore::Style::ElementRuleCollector::addElementInlineStyleProperties):
+ * style/ElementRuleCollector.h:
+ * style/RuleSetBuilder.cpp:
+ (WebCore::Style::RuleSetBuilder::updateCascadeLayerPriorities):
+
2022-03-21 Chris Dumez <cdu...@apple.com>
BroadcastChannel instances in distinct opaque origins can communicate
Modified: trunk/Source/WebCore/style/ElementRuleCollector.cpp (291593 => 291594)
--- trunk/Source/WebCore/style/ElementRuleCollector.cpp 2022-03-22 01:19:00 UTC (rev 291593)
+++ trunk/Source/WebCore/style/ElementRuleCollector.cpp 2022-03-22 01:35:47 UTC (rev 291594)
@@ -126,7 +126,7 @@
m_matchedRuleTransferIndex = 0;
}
-inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, bool isCacheable, FromStyleAttribute fromStyleAttribute)
+inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, CascadeLayerPriority priority, bool isCacheable, FromStyleAttribute fromStyleAttribute)
{
if (!propertySet || propertySet->isEmpty())
return;
@@ -135,6 +135,7 @@
m_result.isCacheable = false;
auto matchedProperty = MatchedProperties { propertySet };
+ matchedProperty.cascadeLayerPriority = priority;
matchedProperty.fromStyleAttribute = fromStyleAttribute;
addMatchedProperties(WTFMove(matchedProperty), DeclarationOrigin::Author);
}
@@ -549,11 +550,11 @@
if (is<StyledElement>(element())) {
auto& styledElement = downcast<StyledElement>(element());
// https://html.spec.whatwg.org/#presentational-hints
- addElementStyleProperties(styledElement.presentationalHintStyle());
+ addElementStyleProperties(styledElement.presentationalHintStyle(), RuleSet::cascadeLayerPriorityForPresentationalHints);
// Tables and table cells share an additional presentation style that must be applied
// after all attributes, since their style depends on the values of multiple attributes.
- addElementStyleProperties(styledElement.additionalPresentationalHintStyle());
+ addElementStyleProperties(styledElement.additionalPresentationalHintStyle(), RuleSet::cascadeLayerPriorityForPresentationalHints);
if (is<HTMLElement>(styledElement)) {
bool isAuto;
@@ -588,11 +589,11 @@
if (auto* inlineStyle = downcast<StyledElement>(element()).inlineStyle()) {
// FIXME: Media control shadow trees seem to have problems with caching.
bool isInlineStyleCacheable = !inlineStyle->isMutable() && !element().isInShadowTree();
- addElementStyleProperties(inlineStyle, isInlineStyleCacheable, FromStyleAttribute::Yes);
+ addElementStyleProperties(inlineStyle, RuleSet::cascadeLayerPriorityForUnlayered, isInlineStyleCacheable, FromStyleAttribute::Yes);
}
if (includeSMILProperties && is<SVGElement>(element()))
- addElementStyleProperties(downcast<SVGElement>(element()).animatedSMILStyleProperties(), false /* isCacheable */);
+ addElementStyleProperties(downcast<SVGElement>(element()).animatedSMILStyleProperties(), RuleSet::cascadeLayerPriorityForUnlayered, false /* isCacheable */);
}
bool ElementRuleCollector::hasAnyMatchingRules(const RuleSet& ruleSet)
Modified: trunk/Source/WebCore/style/ElementRuleCollector.h (291593 => 291594)
--- trunk/Source/WebCore/style/ElementRuleCollector.h 2022-03-22 01:19:00 UTC (rev 291593)
+++ trunk/Source/WebCore/style/ElementRuleCollector.h 2022-03-22 01:35:47 UTC (rev 291594)
@@ -96,7 +96,7 @@
void addAuthorKeyframeRules(const StyleRuleKeyframe&);
private:
- void addElementStyleProperties(const StyleProperties*, bool isCacheable = true, FromStyleAttribute = FromStyleAttribute::No);
+ void addElementStyleProperties(const StyleProperties*, CascadeLayerPriority, bool isCacheable = true, FromStyleAttribute = FromStyleAttribute::No);
void matchUARules(const RuleSet&);
Modified: trunk/Source/WebCore/style/RuleSet.h (291593 => 291594)
--- trunk/Source/WebCore/style/RuleSet.h 2022-03-22 01:19:00 UTC (rev 291593)
+++ trunk/Source/WebCore/style/RuleSet.h 2022-03-22 01:35:47 UTC (rev 291594)
@@ -105,6 +105,7 @@
bool hasShadowPseudoElementRules() const { return !m_shadowPseudoElementRules.isEmpty(); }
bool hasHostPseudoClassRulesMatchingInShadowTree() const { return m_hasHostPseudoClassRulesMatchingInShadowTree; }
+ static constexpr auto cascadeLayerPriorityForPresentationalHints = std::numeric_limits<CascadeLayerPriority>::min();
static constexpr auto cascadeLayerPriorityForUnlayered = std::numeric_limits<CascadeLayerPriority>::max();
CascadeLayerPriority cascadeLayerPriorityFor(const RuleData&) const;
Modified: trunk/Source/WebCore/style/RuleSetBuilder.cpp (291593 => 291594)
--- trunk/Source/WebCore/style/RuleSetBuilder.cpp 2022-03-22 01:19:00 UTC (rev 291593)
+++ trunk/Source/WebCore/style/RuleSetBuilder.cpp 2022-03-22 01:35:47 UTC (rev 291594)
@@ -289,8 +289,14 @@
std::sort(layersInPriorityOrder.begin(), layersInPriorityOrder.end(), compare);
+ // Priorities matter only relative to each other, so assign them enforcing these constraints:
+ // - Layers must get a priority greater than RuleSet::cascadeLayerPriorityForPresentationalHints.
+ // - Layers must get a priority smaller than RuleSet::cascadeLayerPriorityForUnlayered.
+ // - A layer must get at least the same priority as the previous one.
+ // - A layer should get more priority than the previous one, but this may be impossible if there are too many layers.
+ // In that case, the last layers will get the maximum priority for layers, RuleSet::cascadeLayerPriorityForUnlayered - 1.
for (unsigned i = 0; i < layerCount; ++i) {
- auto priority = std::min<unsigned>(i, RuleSet::cascadeLayerPriorityForUnlayered - 1);
+ auto priority = std::min<unsigned>(i + RuleSet::cascadeLayerPriorityForPresentationalHints + 1, RuleSet::cascadeLayerPriorityForUnlayered - 1);
m_ruleSet->cascadeLayerForIdentifier(layersInPriorityOrder[i]).priority = priority;
}
}