Skip to content
Permalink
Browse files
[CSS Container Queries] Container units don't work in gradients
https://bugs.webkit.org/show_bug.cgi?id=241780

Reviewed by Tim Nguyen.

* LayoutTests/TestExpectations:
* Source/WebCore/css/CSSGradientValue.cpp:
(WebCore::CSSLinearGradientValue::createGradient):
(WebCore::CSSRadialGradientValue::createGradient):
(WebCore::CSSConicGradientValue::createGradient):

Provide the element to CSSToLengthConversionData so a container can be selected.

* Source/WebCore/css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
* Source/WebCore/css/CSSToLengthConversionData.cpp:
(WebCore::CSSToLengthConversionData::CSSToLengthConversionData):
* Source/WebCore/css/CSSToLengthConversionData.h:
(WebCore::CSSToLengthConversionData::elementForContainerUnitResolution const):
(WebCore::CSSToLengthConversionData::element const): Deleted.

Rename for clarity.

Canonical link: https://commits.webkit.org/251680@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295675 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
anttijk committed Jun 20, 2022
1 parent 1c31350 commit abcdaa9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
@@ -4793,8 +4793,6 @@ webkit.org/b/238555 imported/w3c/web-platform-tests/css/css-contain/contain-flex
# Container queries
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/custom-layout-container-001.https.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-gradient-invalidation.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-gradient.html [ ImageOnlyFailure ]
webkit.org/b/241778 [ Debug ] imported/w3c/web-platform-tests/css/css-contain/container-queries/svg-foreignobject-no-size-container.html [ Skip ]

# Flaky css-contain test
@@ -883,7 +883,7 @@ Ref<Gradient> CSSLinearGradientValue::createGradient(RenderElement& renderer, co
if (auto* documentElement = renderer.document().documentElement())
rootStyle = documentElement->renderStyle();

CSSToLengthConversionData conversionData(renderer.style(), rootStyle, renderer.parentStyle(), &renderer.view());
CSSToLengthConversionData conversionData(renderer.style(), rootStyle, renderer.parentStyle(), &renderer.view(), renderer.generatingElement());

FloatPoint firstPoint;
FloatPoint secondPoint;
@@ -1141,7 +1141,7 @@ Ref<Gradient> CSSRadialGradientValue::createGradient(RenderElement& renderer, co
if (auto* documentElement = renderer.document().documentElement())
rootStyle = documentElement->renderStyle();

CSSToLengthConversionData conversionData(renderer.style(), rootStyle, renderer.parentStyle(), &renderer.view());
CSSToLengthConversionData conversionData(renderer.style(), rootStyle, renderer.parentStyle(), &renderer.view(), renderer.generatingElement());

FloatPoint firstPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
if (!firstX())
@@ -1334,7 +1334,7 @@ Ref<Gradient> CSSConicGradientValue::createGradient(RenderElement& renderer, con
if (auto* documentElement = renderer.document().documentElement())
rootStyle = documentElement->renderStyle();

CSSToLengthConversionData conversionData(renderer.style(), rootStyle, renderer.parentStyle(), &renderer.view());
CSSToLengthConversionData conversionData(renderer.style(), rootStyle, renderer.parentStyle(), &renderer.view(), renderer.generatingElement());

FloatPoint centerPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
if (!firstX())
@@ -825,10 +825,11 @@ double CSSPrimitiveValue::computeNonCalcLengthDouble(const CSSToLengthConversion
{
auto selectContainerRenderer = [&](CQ::Axis axis) -> const RenderBox* {
conversionData.setUsesContainerUnits();
if (!conversionData.element())
auto* element = conversionData.elementForContainerUnitResolution();
if (!element)
return nullptr;
// FIXME: Use cached query containers when available.
auto* container = Style::ContainerQueryEvaluator::selectContainer(axis, nullString(), *conversionData.element());
auto* container = Style::ContainerQueryEvaluator::selectContainer(axis, nullString(), *element);
if (!container)
return nullptr;
return dynamicDowncast<RenderBox>(container->renderer());
@@ -43,16 +43,17 @@ CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle& style, c
, m_rootStyle(builderContext.rootElementStyle)
, m_parentStyle(&builderContext.parentStyle)
, m_renderView(builderContext.document->renderView())
, m_element(builderContext.element)
, m_elementForContainerUnitResolution(builderContext.element)
, m_viewportDependencyDetectionStyle(const_cast<RenderStyle*>(m_style))
{
}

CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle& style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView)
CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle& style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, const Element* elementForContainerUnitResolution)
: m_style(&style)
, m_rootStyle(rootStyle)
, m_parentStyle(parentStyle)
, m_renderView(renderView)
, m_elementForContainerUnitResolution(elementForContainerUnitResolution)
, m_zoom(1.f)
, m_viewportDependencyDetectionStyle(const_cast<RenderStyle*>(m_style))
{
@@ -51,7 +51,7 @@ class CSSToLengthConversionData {
// This is used during style building. The 'zoom' property is taken into account.
CSSToLengthConversionData(const RenderStyle&, const Style::BuilderContext&);
// This constructor ignores the `zoom` property.
CSSToLengthConversionData(const RenderStyle&, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView*);
CSSToLengthConversionData(const RenderStyle&, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView*, const Element* elementForContainerUnitResolution = nullptr);

CSSToLengthConversionData() = default;

@@ -63,7 +63,7 @@ class CSSToLengthConversionData {
bool computingLineHeight() const { return m_propertyToCompute == CSSPropertyLineHeight; }
CSSPropertyID propertyToCompute() const { return m_propertyToCompute.value_or(CSSPropertyInvalid); }
const RenderView* renderView() const { return m_renderView; }
const Element* element() const { return m_element.get(); }
const Element* elementForContainerUnitResolution() const { return m_elementForContainerUnitResolution.get(); }

FloatSize defaultViewportFactor() const;
FloatSize smallViewportFactor() const;
@@ -101,7 +101,7 @@ class CSSToLengthConversionData {
const RenderStyle* m_rootStyle { nullptr };
const RenderStyle* m_parentStyle { nullptr };
const RenderView* m_renderView { nullptr };
RefPtr<const Element> m_element;
RefPtr<const Element> m_elementForContainerUnitResolution;
std::optional<float> m_zoom;
std::optional<CSSPropertyID> m_propertyToCompute;
// FIXME: Remove this hack.

0 comments on commit abcdaa9

Please sign in to comment.