Diff
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-invalidation-expected.txt (295210 => 295211)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-invalidation-expected.txt 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-invalidation-expected.txt 2022-06-03 15:29:29 UTC (rev 295211)
@@ -1,8 +1,8 @@
Test
-FAIL cqi respond when selected container changes type (inline-size -> none) assert_equals: expected "50px" but got "30px"
-FAIL cqb respond when selected container changes type (size -> none) assert_equals: expected "60px" but got "40px"
-FAIL cqb respond when intermediate container changes type (inline-size -> size) assert_equals: expected "20px" but got "40px"
-FAIL cqi respond when selected container changes inline-size assert_equals: expected "5px" but got "30px"
-FAIL cqb respond when selected container changes block-size assert_equals: expected "5px" but got "40px"
+PASS cqi respond when selected container changes type (inline-size -> none)
+PASS cqb respond when selected container changes type (size -> none)
+PASS cqb respond when intermediate container changes type (inline-size -> size)
+PASS cqi respond when selected container changes inline-size
+PASS cqb respond when selected container changes block-size
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (295210 => 295211)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2022-06-03 15:29:29 UTC (rev 295211)
@@ -824,6 +824,7 @@
double CSSPrimitiveValue::computeNonCalcLengthDouble(const CSSToLengthConversionData& conversionData, CSSUnitType primitiveType, double value)
{
auto selectContainerRenderer = [&](CQ::Axis axis) -> const RenderBox* {
+ conversionData.setUsesContainerUnits();
if (!conversionData.element())
return nullptr;
// FIXME: Use cached query containers when available.
Modified: trunk/Source/WebCore/css/CSSToLengthConversionData.cpp (295210 => 295211)
--- trunk/Source/WebCore/css/CSSToLengthConversionData.cpp 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/css/CSSToLengthConversionData.cpp 2022-06-03 15:29:29 UTC (rev 295211)
@@ -66,7 +66,7 @@
FloatSize CSSToLengthConversionData::defaultViewportFactor() const
{
if (m_viewportDependencyDetectionStyle)
- m_viewportDependencyDetectionStyle->setHasViewportUnits();
+ m_viewportDependencyDetectionStyle->setUsesViewportUnits();
if (!m_renderView)
return { };
@@ -77,7 +77,7 @@
FloatSize CSSToLengthConversionData::smallViewportFactor() const
{
if (m_viewportDependencyDetectionStyle)
- m_viewportDependencyDetectionStyle->setHasViewportUnits();
+ m_viewportDependencyDetectionStyle->setUsesViewportUnits();
if (!m_renderView)
return { };
@@ -88,7 +88,7 @@
FloatSize CSSToLengthConversionData::largeViewportFactor() const
{
if (m_viewportDependencyDetectionStyle)
- m_viewportDependencyDetectionStyle->setHasViewportUnits();
+ m_viewportDependencyDetectionStyle->setUsesViewportUnits();
if (!m_renderView)
return { };
@@ -99,7 +99,7 @@
FloatSize CSSToLengthConversionData::dynamicViewportFactor() const
{
if (m_viewportDependencyDetectionStyle)
- m_viewportDependencyDetectionStyle->setHasViewportUnits();
+ m_viewportDependencyDetectionStyle->setUsesViewportUnits();
if (!m_renderView)
return { };
@@ -107,4 +107,10 @@
return m_renderView->sizeForCSSDynamicViewportUnits() / 100.0;
}
+void CSSToLengthConversionData::setUsesContainerUnits() const
+{
+ if (m_viewportDependencyDetectionStyle)
+ m_viewportDependencyDetectionStyle->setUsesContainerUnits();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSToLengthConversionData.h (295210 => 295211)
--- trunk/Source/WebCore/css/CSSToLengthConversionData.h 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/css/CSSToLengthConversionData.h 2022-06-03 15:29:29 UTC (rev 295211)
@@ -94,6 +94,8 @@
return copy;
}
+ void setUsesContainerUnits() const;
+
private:
const RenderStyle* m_style { nullptr };
const RenderStyle* m_rootStyle { nullptr };
Modified: trunk/Source/WebCore/dom/Document.cpp (295210 => 295211)
--- trunk/Source/WebCore/dom/Document.cpp 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/dom/Document.cpp 2022-06-03 15:29:29 UTC (rev 295211)
@@ -4343,7 +4343,7 @@
// FIXME: Ideally, we should save the list of elements that have viewport units and only iterate over those.
for (RefPtr element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::nextIncludingPseudo(*element)) {
auto* renderer = element->renderer();
- if (renderer && renderer->style().hasViewportUnits())
+ if (renderer && renderer->style().usesViewportUnits())
element->invalidateStyle();
}
}
Modified: trunk/Source/WebCore/rendering/RenderIFrame.cpp (295210 => 295211)
--- trunk/Source/WebCore/rendering/RenderIFrame.cpp 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/rendering/RenderIFrame.cpp 2022-06-03 15:29:29 UTC (rev 295211)
@@ -76,7 +76,7 @@
{
// Some authors implement fullscreen popups as out-of-flow iframes with size set to full viewport (using vw/vh units).
// The size used may not perfectly match the viewport size so the following heuristic uses a relaxed constraint.
- return style().hasOutOfFlowPosition() && style().hasViewportUnits();
+ return style().hasOutOfFlowPosition() && style().usesViewportUnits();
}
bool RenderIFrame::flattenFrame() const
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (295210 => 295211)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2022-06-03 15:29:29 UTC (rev 295211)
@@ -198,7 +198,8 @@
m_nonInheritedFlags.hasExplicitlySetDirection = false;
m_nonInheritedFlags.hasExplicitlySetWritingMode = false;
m_nonInheritedFlags.hasExplicitlySetTextAlign = false;
- m_nonInheritedFlags.hasViewportUnits = false;
+ m_nonInheritedFlags.usesViewportUnits = false;
+ m_nonInheritedFlags.usesContainerUnits = false;
m_nonInheritedFlags.hasExplicitlyInheritedProperties = false;
m_nonInheritedFlags.disallowsFastPathInheritance = false;
m_nonInheritedFlags.isUnique = false;
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (295210 => 295211)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2022-06-03 15:29:29 UTC (rev 295211)
@@ -197,8 +197,10 @@
void setInheritedCustomPropertyValue(const AtomString& name, Ref<CSSCustomPropertyValue>&&);
void setNonInheritedCustomPropertyValue(const AtomString& name, Ref<CSSCustomPropertyValue>&&);
- void setHasViewportUnits(bool v = true) { m_nonInheritedFlags.hasViewportUnits = v; }
- bool hasViewportUnits() const { return m_nonInheritedFlags.hasViewportUnits; }
+ void setUsesViewportUnits() { m_nonInheritedFlags.usesViewportUnits = true; }
+ bool usesViewportUnits() const { return m_nonInheritedFlags.usesViewportUnits; }
+ void setUsesContainerUnits() { m_nonInheritedFlags.usesContainerUnits = true; }
+ bool usesContainerUnits() const { return m_nonInheritedFlags.usesContainerUnits; }
void setColumnStylesFromPaginationMode(const Pagination::Mode&);
@@ -1992,7 +1994,8 @@
#if ENABLE(DARK_MODE_CSS)
unsigned hasExplicitlySetColorScheme : 1;
#endif
- unsigned hasViewportUnits : 1;
+ unsigned usesViewportUnits : 1;
+ unsigned usesContainerUnits : 1;
unsigned hasExplicitlyInheritedProperties : 1; // Explicitly inherits a non-inherited property.
unsigned disallowsFastPathInheritance : 1;
unsigned isUnique : 1; // Style cannot be shared.
@@ -2133,7 +2136,8 @@
#if ENABLE(DARK_MODE_CSS)
&& hasExplicitlySetColorScheme == other.hasExplicitlySetColorScheme
#endif
- && hasViewportUnits == other.hasViewportUnits
+ && usesViewportUnits == other.usesViewportUnits
+ && usesContainerUnits == other.usesContainerUnits
&& hasExplicitlyInheritedProperties == other.hasExplicitlyInheritedProperties
&& disallowsFastPathInheritance == other.disallowsFastPathInheritance
&& isUnique == other.isUnique
@@ -2159,7 +2163,8 @@
unicodeBidi = other.unicodeBidi;
floating = other.floating;
tableLayout = other.tableLayout;
- hasViewportUnits = other.hasViewportUnits;
+ usesViewportUnits = other.usesViewportUnits;
+ usesContainerUnits = other.usesContainerUnits;
hasExplicitlyInheritedProperties = other.hasExplicitlyInheritedProperties;
disallowsFastPathInheritance = other.disallowsFastPathInheritance;
Modified: trunk/Source/WebCore/style/MatchedDeclarationsCache.cpp (295210 => 295211)
--- trunk/Source/WebCore/style/MatchedDeclarationsCache.cpp 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/style/MatchedDeclarationsCache.cpp 2022-06-03 15:29:29 UTC (rev 295211)
@@ -61,6 +61,8 @@
// The cache assumes static knowledge about which properties are inherited.
if (style.hasExplicitlyInheritedProperties())
return false;
+ if (style.usesContainerUnits())
+ return false;
// Getting computed style after a font environment change but before full style resolution may involve styles with non-current fonts.
// Avoid caching them.
@@ -138,7 +140,7 @@
void MatchedDeclarationsCache::clearEntriesAffectedByViewportUnits()
{
m_entries.removeIf([](auto& keyValue) {
- return keyValue.value.renderStyle->hasViewportUnits();
+ return keyValue.value.renderStyle->usesViewportUnits();
});
}
Modified: trunk/Source/WebCore/style/StyleResolver.cpp (295210 => 295211)
--- trunk/Source/WebCore/style/StyleResolver.cpp 2022-06-03 15:24:42 UTC (rev 295210)
+++ trunk/Source/WebCore/style/StyleResolver.cpp 2022-06-03 15:29:29 UTC (rev 295211)
@@ -269,7 +269,7 @@
Adjuster adjuster(document(), *state.parentStyle(), context.parentBoxStyle, &element);
adjuster.adjust(*state.style(), state.userAgentAppearanceStyle());
- if (state.style()->hasViewportUnits())
+ if (state.style()->usesViewportUnits())
document().setHasStyleWithViewportUnits();
return { state.takeStyle(), WTFMove(elementStyleRelations) };
@@ -465,7 +465,7 @@
Adjuster adjuster(document(), *state.parentStyle(), context.parentBoxStyle, nullptr);
adjuster.adjust(*state.style(), state.userAgentAppearanceStyle());
- if (state.style()->hasViewportUnits())
+ if (state.style()->usesViewportUnits())
document().setHasStyleWithViewportUnits();
return state.takeStyle();