Diff
Modified: trunk/Source/WebCore/ChangeLog (291397 => 291398)
--- trunk/Source/WebCore/ChangeLog 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/ChangeLog 2022-03-17 09:41:08 UTC (rev 291398)
@@ -1,3 +1,58 @@
+2022-03-17 Antti Koivisto <[email protected]>
+
+ Pass style builder context to CSSToLengthConversionData
+ https://bugs.webkit.org/show_bug.cgi?id=237963
+
+ Reviewed by Antoine Quint.
+
+ This is preparation for resolving container units.
+
+ Also general cleanups to CSSToLengthConversionData.
+
+ * css/CSSGradientValue.cpp:
+ (WebCore::CSSLinearGradientValue::createGradient):
+ (WebCore::CSSRadialGradientValue::createGradient):
+ (WebCore::CSSConicGradientValue::createGradient):
+ * css/CSSToLengthConversionData.cpp:
+ (WebCore::CSSToLengthConversionData::CSSToLengthConversionData):
+ (WebCore::CSSToLengthConversionData::zoom const): Deleted.
+ * css/CSSToLengthConversionData.h:
+ (WebCore::CSSToLengthConversionData::zoom const):
+ (WebCore::CSSToLengthConversionData::copyForFontSizeWithParentStyle const):
+ (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const):
+ (WebCore::CSSToLengthConversionData::copyForLineHeight const):
+ (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Deleted.
+ (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): Deleted.
+ * css/DOMMatrixReadOnly.cpp:
+ (WebCore::DOMMatrixReadOnly::parseStringIntoAbstractMatrix):
+ * css/MediaQueryEvaluator.cpp:
+ (WebCore::MediaQueryEvaluator::evaluate const):
+ * css/parser/SizesAttributeParser.cpp:
+ (WebCore::SizesAttributeParser::computeLength):
+ (WebCore::SizesAttributeParser::effectiveSizeDefaultValue):
+ * html/shadow/TextControlInnerElements.cpp:
+ (WebCore::TextControlInnerElement::resolveCustomStyle):
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::RenderThemeIOS::popupInternalPaddingBox const):
+ (WebCore::applyCommonButtonPaddingToStyle):
+
+ Setting the zoom to a weird value here does nothing, ems unit resolution ignores it.
+ Just don't do it.
+
+ (WebCore::RenderThemeIOS::adjustButtonStyle const):
+ (WebCore::RenderThemeIOS::paintMenuListButtonDecorationsWithFormControlRefresh):
+ (WebCore::RenderThemeIOS::adjustSearchFieldDecorationPartStyle const):
+ * style/ContainerQueryEvaluator.cpp:
+ (WebCore::Style::ContainerQueryEvaluator::selectContainer const):
+ * style/StyleBuilderConverter.h:
+ (WebCore::Style::BuilderConverter::convertLineHeight):
+ * style/StyleBuilderCustom.h:
+ (WebCore::Style::BuilderCustom::mmLength):
+ (WebCore::Style::BuilderCustom::inchLength):
+ (WebCore::Style::BuilderCustom::applyValueFontSize):
+ * style/StyleBuilderState.cpp:
+ (WebCore::Style::BuilderState::BuilderState):
+
2022-03-17 Diego Pino Garcia <[email protected]>
Unreviewed, non-unified build fix after r291390
Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (291397 => 291398)
--- trunk/Source/WebCore/css/CSSGradientValue.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -884,7 +884,7 @@
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());
FloatPoint firstPoint;
FloatPoint secondPoint;
@@ -1142,7 +1142,7 @@
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());
FloatPoint firstPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
if (!firstX())
@@ -1335,7 +1335,7 @@
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());
FloatPoint centerPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
if (!firstX())
Modified: trunk/Source/WebCore/css/CSSToLengthConversionData.cpp (291397 => 291398)
--- trunk/Source/WebCore/css/CSSToLengthConversionData.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/css/CSSToLengthConversionData.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -34,14 +34,32 @@
#include "FloatSize.h"
#include "RenderStyle.h"
#include "RenderView.h"
+#include "StyleBuilderState.h"
namespace WebCore {
+CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle& style, const Style::BuilderContext& builderContext)
+ : m_style(&style)
+ , m_rootStyle(builderContext.rootElementStyle)
+ , m_parentStyle(&builderContext.parentStyle)
+ , m_renderView(builderContext.document->renderView())
+ , m_viewportDependencyDetectionStyle(const_cast<RenderStyle*>(m_style))
+{
+}
+
+CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle& style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView)
+ : m_style(&style)
+ , m_rootStyle(rootStyle)
+ , m_parentStyle(parentStyle)
+ , m_renderView(renderView)
+ , m_zoom(1.f)
+ , m_viewportDependencyDetectionStyle(const_cast<RenderStyle*>(m_style))
+{
+}
+
float CSSToLengthConversionData::zoom() const
{
- if (!m_zoom)
- return m_style ? m_style->effectiveZoom() : 1;
- return *m_zoom;
+ return m_zoom.value_or(m_style ? m_style->effectiveZoom() : 1.f);
}
FloatSize CSSToLengthConversionData::defaultViewportFactor() const
Modified: trunk/Source/WebCore/css/CSSToLengthConversionData.h (291397 => 291398)
--- trunk/Source/WebCore/css/CSSToLengthConversionData.h 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/css/CSSToLengthConversionData.h 2022-03-17 09:41:08 UTC (rev 291398)
@@ -40,30 +40,17 @@
class RenderStyle;
class RenderView;
+namespace Style {
+struct BuilderContext;
+};
+
class CSSToLengthConversionData {
public:
- CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, float zoom, std::optional<CSSPropertyID> propertyToCompute = std::nullopt, RenderStyle* viewportDependencyDetectionStyle = nullptr)
- : m_style(style)
- , m_rootStyle(rootStyle)
- , m_parentStyle(parentStyle)
- , m_viewportDependencyDetectionStyle(viewportDependencyDetectionStyle ? viewportDependencyDetectionStyle : const_cast<RenderStyle*>(style))
- , m_renderView(renderView)
- , m_zoom(zoom)
- , m_propertyToCompute(propertyToCompute)
- {
- ASSERT(zoom > 0);
- }
+ // 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* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, std::optional<CSSPropertyID> propertyToCompute = std::nullopt)
- : m_style(style)
- , m_rootStyle(rootStyle)
- , m_parentStyle(parentStyle)
- , m_viewportDependencyDetectionStyle(const_cast<RenderStyle*>(style))
- , m_renderView(renderView)
- , m_propertyToCompute(propertyToCompute)
- {
- }
-
CSSToLengthConversionData() = default;
const RenderStyle* style() const { return m_style; }
@@ -80,14 +67,28 @@
FloatSize largeViewportFactor() const;
FloatSize dynamicViewportFactor() const;
- CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const
+ CSSToLengthConversionData copyForFontSizeWithParentStyle() const
{
- return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, newZoom, m_propertyToCompute);
+ CSSToLengthConversionData copy(*this);
+ copy.m_style = parentStyle();
+ copy.m_zoom = 1.f;
+ copy.m_propertyToCompute = CSSPropertyFontSize;
+ return copy;
+ };
+
+ CSSToLengthConversionData copyWithAdjustedZoom(float zoom) const
+ {
+ CSSToLengthConversionData copy(*this);
+ copy.m_zoom = zoom;
+ return copy;
}
- CSSToLengthConversionData copyWithAdjustedZoomAndPropertyToCompute(float zoom, std::optional<CSSPropertyID> propertyToCompute) const
+ CSSToLengthConversionData copyForLineHeight(float zoom) const
{
- return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, zoom, propertyToCompute);
+ CSSToLengthConversionData copy(*this);
+ copy.m_zoom = zoom;
+ copy.m_propertyToCompute = CSSPropertyLineHeight;
+ return copy;
}
private:
@@ -94,10 +95,11 @@
const RenderStyle* m_style { nullptr };
const RenderStyle* m_rootStyle { nullptr };
const RenderStyle* m_parentStyle { nullptr };
- RenderStyle* m_viewportDependencyDetectionStyle { nullptr };
const RenderView* m_renderView { nullptr };
std::optional<float> m_zoom;
std::optional<CSSPropertyID> m_propertyToCompute;
+ // FIXME: Remove this hack.
+ RenderStyle* m_viewportDependencyDetectionStyle { nullptr };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp (291397 => 291398)
--- trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -237,7 +237,7 @@
return AbstractMatrix { };
TransformOperations operations;
- if (!transformsForValue(*value, CSSToLengthConversionData(), operations))
+ if (!transformsForValue(*value, { }, operations))
return Exception { SyntaxError };
AbstractMatrix matrix;
Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (291397 => 291398)
--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -946,7 +946,7 @@
defaultStyle.fontCascade().update();
// Pass `nullptr` for `parentStyle` because we are in the context of a media query.
- return function(_expression_.value(), { m_style, &defaultStyle, nullptr, document.renderView(), 1, std::nullopt }, *frame, NoPrefix);
+ return function(_expression_.value(), { *m_style, &defaultStyle, nullptr, document.renderView() }, *frame, NoPrefix);
}
bool MediaQueryEvaluator::mediaAttributeMatches(Document& document, const String& attributeValue)
Modified: trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp (291397 => 291398)
--- trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -51,7 +51,7 @@
return 0;
auto& style = renderer->style();
- CSSToLengthConversionData conversionData(&style, &style, renderer->parentStyle(), renderer);
+ CSSToLengthConversionData conversionData(style, &style, renderer->parentStyle(), renderer);
// Because we evaluate "sizes" at parse time (before style has been resolved), the font metrics used for these specific units
// are not available. The font selector's internal consistency isn't guaranteed just yet, so we can just temporarily clear
// the pointer to it for the duration of the unit evaluation. This is acceptible because the style always comes from the
@@ -157,7 +157,7 @@
if (!renderer)
return 0;
auto& style = renderer->style();
- return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble({ &style, &style, renderer->parentStyle(), renderer }, CSSUnitType::CSS_VW, 100.0));
+ return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble({ style, &style, renderer->parentStyle(), renderer }, CSSUnitType::CSS_VW, 100.0));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (291397 => 291398)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -125,7 +125,7 @@
// style to calculate em lengths. Since the element might not be in a document, just pass nullptr
// for the root element style, the parent element style, and the render view.
auto emSize = CSSPrimitiveValue::create(1, CSSUnitType::CSS_EMS);
- int pixels = emSize->computeLength<int>(CSSToLengthConversionData { newStyle.get(), nullptr, nullptr, nullptr, 1.0, std::nullopt });
+ int pixels = emSize->computeLength<int>(CSSToLengthConversionData { *newStyle, nullptr, nullptr, nullptr });
newStyle->setFlexBasis(Length { pixels, LengthType::Fixed });
}
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (291397 => 291398)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2022-03-17 09:41:08 UTC (rev 291398)
@@ -702,7 +702,7 @@
float padding = MenuListButtonPaddingAfter;
if (settings.iOSFormControlRefreshEnabled()) {
auto emSize = CSSPrimitiveValue::create(1.0, CSSUnitType::CSS_EMS);
- padding = emSize->computeLength<float>(CSSToLengthConversionData(&style, nullptr, nullptr, nullptr, 1.0, std::nullopt));
+ padding = emSize->computeLength<float>({ style, nullptr, nullptr, nullptr });
}
if (style.effectiveAppearance() == MenulistButtonPart) {
@@ -752,7 +752,7 @@
Document& document = element.document();
auto emSize = CSSPrimitiveValue::create(0.5, CSSUnitType::CSS_EMS);
// We don't need this element's parent style to calculate `em` units, so it's okay to pass nullptr for it here.
- int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, document.renderStyle(), nullptr, document.renderView(), document.frame() ? document.frame()->pageZoomFactor() : 1.));
+ int pixels = emSize->computeLength<int>({ style, document.renderStyle(), nullptr, document.renderView() });
style.setPaddingBox(LengthBox(0, pixels, 0, pixels));
}
@@ -1285,7 +1285,7 @@
// Since the element might not be in a document, just pass nullptr for the root element style,
// the parent element style, and the render view.
auto emSize = CSSPrimitiveValue::create(1.0, CSSUnitType::CSS_EMS);
- int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, nullptr, nullptr, nullptr, 1.0, std::nullopt));
+ int pixels = emSize->computeLength<int>({ style, nullptr, nullptr, nullptr });
style.setPaddingBox(LengthBox(0, pixels, 0, pixels));
if (!element)
@@ -2888,7 +2888,7 @@
}
auto emSize = CSSPrimitiveValue::create(1.0, CSSUnitType::CSS_EMS);
- auto emPixels = emSize->computeLength<float>(CSSToLengthConversionData(&style, nullptr, nullptr, nullptr, 1.0, std::nullopt));
+ auto emPixels = emSize->computeLength<float>({ style, nullptr, nullptr, nullptr });
auto glyphScale = 0.65f * emPixels / glyphSize.width();
glyphSize = glyphScale * glyphSize;
@@ -2916,7 +2916,7 @@
constexpr int searchFieldDecorationEmSize = 1;
constexpr int searchFieldDecorationMargin = 4;
- CSSToLengthConversionData conversionData(&style, nullptr, nullptr, nullptr, 1.0, std::nullopt);
+ CSSToLengthConversionData conversionData(style, nullptr, nullptr, nullptr);
auto emSize = CSSPrimitiveValue::create(searchFieldDecorationEmSize, CSSUnitType::CSS_EMS);
auto size = emSize->computeLength<float>(conversionData);
Modified: trunk/Source/WebCore/style/ContainerQueryEvaluator.cpp (291397 => 291398)
--- trunk/Source/WebCore/style/ContainerQueryEvaluator.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/style/ContainerQueryEvaluator.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -74,7 +74,7 @@
auto& view = renderer->view();
return {
renderer,
- CSSToLengthConversionData { &renderer->style(), &view.style(), nullptr, &view, 1 }
+ CSSToLengthConversionData { renderer->style(), &view.style(), nullptr, &view }
};
};
Modified: trunk/Source/WebCore/style/StyleBuilderConverter.h (291397 => 291398)
--- trunk/Source/WebCore/style/StyleBuilderConverter.h 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/style/StyleBuilderConverter.h 2022-03-17 09:41:08 UTC (rev 291398)
@@ -1565,7 +1565,7 @@
return RenderStyle::initialLineHeight();
if (primitiveValue.isLength()) {
- auto conversionData = builderState.cssToLengthConversionData().copyWithAdjustedZoomAndPropertyToCompute(zoomWithTextZoomFactor(builderState), CSSPropertyLineHeight);
+ auto conversionData = builderState.cssToLengthConversionData().copyForLineHeight(zoomWithTextZoomFactor(builderState));
Length length = primitiveValue.computeLength<Length>(conversionData);
if (multiplier != 1.f)
length = Length(length.value() * multiplier, LengthType::Fixed);
Modified: trunk/Source/WebCore/style/StyleBuilderCustom.h (291397 => 291398)
--- trunk/Source/WebCore/style/StyleBuilderCustom.h 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/style/StyleBuilderCustom.h 2022-03-17 09:41:08 UTC (rev 291398)
@@ -250,12 +250,12 @@
inline Length BuilderCustom::mmLength(double mm)
{
Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSUnitType::CSS_MM));
- return value.get().computeLength<Length>(CSSToLengthConversionData());
+ return value.get().computeLength<Length>({ });
}
inline Length BuilderCustom::inchLength(double inch)
{
Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(inch, CSSUnitType::CSS_IN));
- return value.get().computeLength<Length>(CSSToLengthConversionData());
+ return value.get().computeLength<Length>({ });
}
bool BuilderCustom::getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
{
@@ -1834,13 +1834,13 @@
} else {
fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength()));
if (primitiveValue.isLength()) {
- CSSToLengthConversionData conversionData { &builderState.parentStyle(), builderState.rootElementStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize, &builderState.style() };
+ // font-size is resolved against the parent style instead of the current style.
+ auto conversionData = builderState.cssToLengthConversionData().copyForFontSizeWithParentStyle();
size = primitiveValue.computeLength<float>(conversionData);
} else if (primitiveValue.isPercentage())
size = (primitiveValue.floatValue() * parentSize) / 100.0f;
else if (primitiveValue.isCalculatedPercentageWithLength()) {
- // FIXME: Why does this need a different root style than the isLength case above?
- CSSToLengthConversionData conversionData { &builderState.parentStyle(), builderState.cssToLengthConversionData().rootStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize, &builderState.style() };
+ auto conversionData = builderState.cssToLengthConversionData().copyForFontSizeWithParentStyle();
size = primitiveValue.cssCalcValue()->createCalculationValue(conversionData)->evaluate(parentSize);
} else
return;
Modified: trunk/Source/WebCore/style/StyleBuilderState.cpp (291397 => 291398)
--- trunk/Source/WebCore/style/StyleBuilderState.cpp 2022-03-17 09:21:13 UTC (rev 291397)
+++ trunk/Source/WebCore/style/StyleBuilderState.cpp 2022-03-17 09:41:08 UTC (rev 291398)
@@ -63,7 +63,7 @@
, m_styleMap(*this)
, m_style(style)
, m_context(WTFMove(context))
- , m_cssToLengthConversionData(&style, rootElementStyle(), &parentStyle(), document().renderView())
+ , m_cssToLengthConversionData(style, m_context)
{
}