Diff
Modified: trunk/LayoutTests/ChangeLog (259702 => 259703)
--- trunk/LayoutTests/ChangeLog 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/LayoutTests/ChangeLog 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1,3 +1,13 @@
+2020-04-07 Tyler Wilcock <[email protected]>
+
+ [css-values-4] Support font-relative lh and rlh unit
+ https://bugs.webkit.org/show_bug.cgi?id=195180
+
+ Reviewed by Antti Koivisto.
+
+ Implement support for the font-relative 'lh' and 'rlh' units.
+ https://www.w3.org/TR/css-values-4/#font-relative-lengths
+
2020-04-07 Ryan Haddad <[email protected]>
[iOS] webrtc/h265.html is consistently timing out
Modified: trunk/LayoutTests/TestExpectations (259702 => 259703)
--- trunk/LayoutTests/TestExpectations 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/LayoutTests/TestExpectations 2020-04-08 04:45:45 UTC (rev 259703)
@@ -3104,8 +3104,8 @@
webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-010.html [ ImageOnlyFailure ]
webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-011.html [ ImageOnlyFailure ]
webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-012.html [ ImageOnlyFailure ]
-webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-001.html [ ImageOnlyFailure ]
-webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-002.html [ ImageOnlyFailure ]
+webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-001.html [ Pass ]
+webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-002.html [ Pass ]
webkit.org/b/203337 imported/w3c/web-platform-tests/css/css-values/vh-support-atviewport.html [ ImageOnlyFailure ]
webkit.org/b/203338 imported/w3c/web-platform-tests/css/css-values/vh_not_refreshing_on_chrome.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (259702 => 259703)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1,3 +1,14 @@
+2020-04-07 Tyler Wilcock <[email protected]>
+
+ [css-values-4] Support font-relative lh and rlh unit
+ https://bugs.webkit.org/show_bug.cgi?id=195180
+
+ Reviewed by Antti Koivisto.
+
+ Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055
+
+ * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt:
+
2020-04-07 Chris Dumez <[email protected]>
documentFragment.getElementById() should not work for empty-string IDs
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt (259702 => 259703)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1,11 +1,11 @@
-FAIL lh in line-height on root assert_approx_equals: the lh unit on the root element's line-height property uses font metrics corresponding to the initial values of the font or line-height properties expected 18 +/- 1 but got 164
-FAIL rlh in line-height on root assert_approx_equals: the rlh unit on the root element's line-height property uses font metrics corresponding to the initial values of the font or line-height properties expected 18 +/- 1 but got 164
-FAIL lh in font-size on root assert_approx_equals: the lh unit on the root element's font-size property uses font metrics corresponding to the initial values of the font or line-height properties expected 18 +/- 1 but got 16
-FAIL rlh in font-size on root assert_approx_equals: the rlh unit on the root element's font-size property uses font metrics corresponding to the initial values of the font or line-height properties expected 18 +/- 1 but got 16
-FAIL 2lh in line-height on root assert_approx_equals: the lh unit on the root element's line-height property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 36 +/- 1 but got 164
-FAIL 2rlh in line-height on root assert_approx_equals: the rlh unit on the root element's line-height property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 36 +/- 1 but got 164
-FAIL 2lh in font-size on root assert_approx_equals: the lh unit on the root element's font-size property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 36 +/- 1 but got 16
-FAIL 2rlh in font-size on root assert_approx_equals: the rlh unit on the root element's font-size property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 32 +/- 1 but got 16
+PASS lh in line-height on root
+PASS rlh in line-height on root
+PASS lh in font-size on root
+PASS rlh in font-size on root
+PASS 2lh in line-height on root
+PASS 2rlh in line-height on root
+PASS 2lh in font-size on root
+FAIL 2rlh in font-size on root assert_approx_equals: the rlh unit on the root element's font-size property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 32 +/- 1 but got 36
Modified: trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt (259702 => 259703)
--- trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1,11 +1,11 @@
-FAIL lh in line-height on root assert_approx_equals: the lh unit on the root element's line-height property uses font metrics corresponding to the initial values of the font or line-height properties expected 20 +/- 1 but got 165
-FAIL rlh in line-height on root assert_approx_equals: the rlh unit on the root element's line-height property uses font metrics corresponding to the initial values of the font or line-height properties expected 20 +/- 1 but got 165
-FAIL lh in font-size on root assert_approx_equals: the lh unit on the root element's font-size property uses font metrics corresponding to the initial values of the font or line-height properties expected 20 +/- 1 but got 16
-FAIL rlh in font-size on root assert_approx_equals: the rlh unit on the root element's font-size property uses font metrics corresponding to the initial values of the font or line-height properties expected 20 +/- 1 but got 16
-FAIL 2lh in line-height on root assert_approx_equals: the lh unit on the root element's line-height property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 40 +/- 1 but got 165
-FAIL 2rlh in line-height on root assert_approx_equals: the rlh unit on the root element's line-height property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 40 +/- 1 but got 165
-FAIL 2lh in font-size on root assert_approx_equals: the lh unit on the root element's font-size property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 40 +/- 1 but got 16
-FAIL 2rlh in font-size on root assert_approx_equals: the rlh unit on the root element's font-size property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 32 +/- 1 but got 16
+PASS lh in line-height on root
+PASS rlh in line-height on root
+PASS lh in font-size on root
+PASS rlh in font-size on root
+PASS 2lh in line-height on root
+PASS 2rlh in line-height on root
+PASS 2lh in font-size on root
+FAIL 2rlh in font-size on root assert_approx_equals: the rlh unit on the root element's font-size property actually works as a unit and doesn't merely cause a fallback that doesn't take the number of units into account expected 32 +/- 1 but got 40
Modified: trunk/Source/WebCore/ChangeLog (259702 => 259703)
--- trunk/Source/WebCore/ChangeLog 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/ChangeLog 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1,3 +1,80 @@
+2020-04-07 Tyler Wilcock <[email protected]>
+
+ [css-values-4] Support font-relative lh and rlh unit
+ https://bugs.webkit.org/show_bug.cgi?id=195180
+
+ Reviewed by Antti Koivisto.
+
+ Implement support for 'lh' and 'rlh' units.
+ https://www.w3.org/TR/css-values-4/#font-relative-lengths
+
+ * css/CSSCalculationValue.cpp:
+ (WebCore::calcUnitCategory):
+ (WebCore::calculationCategoryForCombination):
+ (WebCore::hasDoubleValue):
+ * css/CSSGradientValue.cpp:
+ (WebCore::CSSLinearGradientValue::createGradient):
+ (WebCore::CSSRadialGradientValue::createGradient):
+ (WebCore::CSSConicGradientValue::createGradient):
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::isValidCSSUnitTypeForDoubleConversion):
+ (WebCore::isStringType):
+ (WebCore::CSSPrimitiveValue::cleanup):
+ (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
+ (WebCore::CSSPrimitiveValue::unitTypeString):
+ (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
+ (WebCore::CSSPrimitiveValue::equals const):
+ (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const):
+ (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const):
+ * css/CSSPrimitiveValue.h:
+ (WebCore::CSSPrimitiveValue::isFontRelativeLength):
+ (WebCore::CSSPrimitiveValue::isLength):
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const):
+ * css/CSSToLengthConversionData.cpp:
+ (WebCore::CSSToLengthConversionData::viewportWidthFactor const):
+ (WebCore::CSSToLengthConversionData::viewportHeightFactor const):
+ (WebCore::CSSToLengthConversionData::viewportMinFactor const):
+ (WebCore::CSSToLengthConversionData::viewportMaxFactor const):
+ * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know.
+ (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values.
+ (WebCore::CSSToLengthConversionData::parentStyle const):
+ (WebCore::CSSToLengthConversionData::computingFontSize const):
+ (WebCore::CSSToLengthConversionData::computingLineHeight const):
+ (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const):
+ (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const):
+ * css/CSSUnits.cpp:
+ (WebCore::operator<<):
+ * css/CSSUnits.h:
+ * css/MediaQueryEvaluator.cpp:
+ (WebCore::MediaQueryEvaluator::evaluate const):
+ * css/parser/CSSParserToken.cpp:
+ (WebCore::cssPrimitiveValueUnitFromTrie):
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::consumeLength):
+ * css/parser/SizesAttributeParser.cpp:
+ (WebCore::SizesAttributeParser::computeLength):
+ (WebCore::SizesAttributeParser::effectiveSizeDefaultValue):
+ * html/shadow/TextControlInnerElements.cpp:
+ (WebCore::TextControlInnerElement::resolveCustomStyle):
+ * rendering/RenderElement.h:
+ (WebCore::RenderElement::parentStyle const):
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::applyCommonButtonPaddingToStyle):
+ (WebCore::RenderThemeIOS::adjustButtonStyle const):
+ * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere.
+ (WebCore::RenderStyle::computedLineHeight const):
+ (WebCore::RenderStyle::computeLineHeight const):
+ * rendering/style/RenderStyle.h:
+ * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere.
+ (WebCore::Style::zoomWithTextZoomFactor):
+ (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor):
+ (WebCore::Style::BuilderConverter::convertLineHeight):
+ * style/StyleBuilderCustom.h:
+ (WebCore::Style::BuilderCustom::applyValueFontSize):
+ * style/StyleBuilderState.cpp:
+ (WebCore::Style::BuilderState::BuilderState):
+
2020-04-07 Zalan Bujtas <[email protected]>
fastclick.com: A Gradient banner is missing
Modified: trunk/Source/WebCore/css/CSSCalculationValue.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/CSSCalculationValue.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSCalculationValue.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -80,6 +80,8 @@
case CSSUnitType::CSS_PT:
case CSSUnitType::CSS_PC:
case CSSUnitType::CSS_Q:
+ case CSSUnitType::CSS_LHS:
+ case CSSUnitType::CSS_RLHS:
case CSSUnitType::CSS_REMS:
case CSSUnitType::CSS_CHS:
case CSSUnitType::CSS_VW:
@@ -133,7 +135,9 @@
return CalculationCategory::Frequency;
case CSSUnitType::CSS_EMS:
case CSSUnitType::CSS_EXS:
+ case CSSUnitType::CSS_LHS:
case CSSUnitType::CSS_REMS:
+ case CSSUnitType::CSS_RLHS:
case CSSUnitType::CSS_CHS:
case CSSUnitType::CSS_VW:
case CSSUnitType::CSS_VH:
@@ -195,6 +199,8 @@
case CSSUnitType::CSS_DPCM:
case CSSUnitType::CSS_FR:
case CSSUnitType::CSS_Q:
+ case CSSUnitType::CSS_LHS:
+ case CSSUnitType::CSS_RLHS:
return true;
case CSSUnitType::CSS_UNKNOWN:
case CSSUnitType::CSS_STRING:
Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/CSSGradientValue.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -807,7 +807,7 @@
{
ASSERT(!size.isEmpty());
- CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());
+ CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view());
FloatPoint firstPoint;
FloatPoint secondPoint;
@@ -1056,7 +1056,7 @@
{
ASSERT(!size.isEmpty());
- CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());
+ CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view());
FloatPoint firstPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
if (!firstX())
@@ -1247,7 +1247,7 @@
{
ASSERT(!size.isEmpty());
- CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());
+ CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view());
FloatPoint centerPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
if (!firstX())
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -71,6 +71,8 @@
case CSSUnitType::CSS_PT:
case CSSUnitType::CSS_PX:
case CSSUnitType::CSS_Q:
+ case CSSUnitType::CSS_LHS:
+ case CSSUnitType::CSS_RLHS:
case CSSUnitType::CSS_QUIRKY_EMS:
case CSSUnitType::CSS_RAD:
case CSSUnitType::CSS_REMS:
@@ -147,6 +149,8 @@
case CSSUnitType::CSS_PT:
case CSSUnitType::CSS_PX:
case CSSUnitType::CSS_Q:
+ case CSSUnitType::CSS_LHS:
+ case CSSUnitType::CSS_RLHS:
case CSSUnitType::CSS_QUAD:
case CSSUnitType::CSS_QUIRKY_EMS:
case CSSUnitType::CSS_RAD:
@@ -502,6 +506,8 @@
case CSSUnitType::CSS_DPCM:
case CSSUnitType::CSS_FR:
case CSSUnitType::CSS_Q:
+ case CSSUnitType::CSS_LHS:
+ case CSSUnitType::CSS_RLHS:
case CSSUnitType::CSS_IDENT:
case CSSUnitType::CSS_UNKNOWN:
case CSSUnitType::CSS_UNICODE_RANGE:
@@ -631,6 +637,23 @@
case CSSUnitType::CSS_Q:
factor = cssPixelsPerInch / QPerInch;
break;
+ case CSSUnitType::CSS_LHS:
+ ASSERT(conversionData.style());
+ if (conversionData.computingLineHeight() || conversionData.computingFontSize()) {
+ // Try to get the parent's computed line-height, or fall back to the initial line-height of this element's font spacing.
+ factor = conversionData.parentStyle() ? conversionData.parentStyle()->computedLineHeight() : conversionData.style()->fontMetrics().lineSpacing();
+ } else
+ factor = conversionData.style()->computedLineHeight();
+ break;
+ case CSSUnitType::CSS_RLHS:
+ if (conversionData.rootStyle()) {
+ if (conversionData.computingLineHeight() || conversionData.computingFontSize())
+ factor = conversionData.rootStyle()->computeLineHeight(conversionData.rootStyle()->specifiedLineHeight());
+ else
+ factor = conversionData.rootStyle()->computedLineHeight();
+ } else
+ factor = 1.0;
+ break;
case CSSUnitType::CSS_IN:
factor = cssPixelsPerInch;
break;
@@ -925,6 +948,8 @@
case CSSUnitType::CSS_DPCM: return "dpcm";
case CSSUnitType::CSS_FR: return "fr";
case CSSUnitType::CSS_Q: return "q";
+ case CSSUnitType::CSS_LHS: return "lh";
+ case CSSUnitType::CSS_RLHS: return "rlh";
case CSSUnitType::CSS_TURN: return "turn";
case CSSUnitType::CSS_REMS: return "rem";
case CSSUnitType::CSS_CHS: return "ch";
@@ -1012,6 +1037,10 @@
return formatNumberValue("fr");
case CSSUnitType::CSS_Q:
return formatNumberValue("q");
+ case CSSUnitType::CSS_LHS:
+ return formatNumberValue("lh");
+ case CSSUnitType::CSS_RLHS:
+ return formatNumberValue("rlh");
case CSSUnitType::CSS_DIMENSION:
// FIXME: We currently don't handle CSSUnitType::CSS_DIMENSION properly as we don't store
// the actual dimension, just the numeric value as a string.
@@ -1139,6 +1168,8 @@
case CSSUnitType::CSS_VMAX:
case CSSUnitType::CSS_FR:
case CSSUnitType::CSS_Q:
+ case CSSUnitType::CSS_LHS:
+ case CSSUnitType::CSS_RLHS:
return m_value.num == other.m_value.num;
case CSSUnitType::CSS_PROPERTY_ID:
return propertyName(m_value.propertyID) == propertyName(other.m_value.propertyID);
@@ -1182,7 +1213,7 @@
return DeprecatedCSSOMPrimitiveValue::create(*this, styleDeclaration);
}
-// https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles-via-relative-units
+// https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles
void CSSPrimitiveValue::collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const
{
switch (primitiveUnitType()) {
@@ -1192,6 +1223,10 @@
case CSSUnitType::CSS_CHS:
values.add(CSSPropertyFontSize);
break;
+ case CSSUnitType::CSS_LHS:
+ values.add(CSSPropertyFontSize);
+ values.add(CSSPropertyLineHeight);
+ break;
case CSSUnitType::CSS_CALC:
m_value.calc->collectDirectComputationalDependencies(values);
break;
@@ -1206,6 +1241,10 @@
case CSSUnitType::CSS_REMS:
values.add(CSSPropertyFontSize);
break;
+ case CSSUnitType::CSS_RLHS:
+ values.add(CSSPropertyFontSize);
+ values.add(CSSPropertyLineHeight);
+ break;
case CSSUnitType::CSS_CALC:
m_value.calc->collectDirectRootComputationalDependencies(values);
break;
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (259702 => 259703)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -260,6 +260,8 @@
{
return type == CSSUnitType::CSS_EMS
|| type == CSSUnitType::CSS_EXS
+ || type == CSSUnitType::CSS_LHS
+ || type == CSSUnitType::CSS_RLHS
|| type == CSSUnitType::CSS_REMS
|| type == CSSUnitType::CSS_CHS
|| type == CSSUnitType::CSS_QUIRKY_EMS;
@@ -271,6 +273,8 @@
|| type == CSSUnitType::CSS_REMS
|| type == CSSUnitType::CSS_CHS
|| type == CSSUnitType::CSS_Q
+ || type == CSSUnitType::CSS_LHS
+ || type == CSSUnitType::CSS_RLHS
|| isViewportPercentageLength(type)
|| type == CSSUnitType::CSS_QUIRKY_EMS;
}
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (259702 => 259703)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -4514,6 +4514,7 @@
case CSSUnitType::CSS_EMS:
case CSSUnitType::CSS_EXS:
case CSSUnitType::CSS_CHS:
+ case CSSUnitType::CSS_LHS:
return lengthConversion & (FixedIntegerConversion | FixedFloatConversion);
default:
return false;
Modified: trunk/Source/WebCore/css/CSSToLengthConversionData.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/CSSToLengthConversionData.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSToLengthConversionData.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -45,7 +45,7 @@
double CSSToLengthConversionData::viewportWidthFactor() const
{
- if (m_style && !m_computingFontSize)
+ if (m_style && !computingFontSize())
const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
if (!m_renderView)
@@ -56,7 +56,7 @@
double CSSToLengthConversionData::viewportHeightFactor() const
{
- if (m_style && !m_computingFontSize)
+ if (m_style && !computingFontSize())
const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
if (!m_renderView)
@@ -67,7 +67,7 @@
double CSSToLengthConversionData::viewportMinFactor() const
{
- if (m_style && !m_computingFontSize)
+ if (m_style && !computingFontSize())
const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
if (!m_renderView)
@@ -79,7 +79,7 @@
double CSSToLengthConversionData::viewportMaxFactor() const
{
- if (m_style && !m_computingFontSize)
+ if (m_style && !computingFontSize())
const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
if (!m_renderView)
Modified: trunk/Source/WebCore/css/CSSToLengthConversionData.h (259702 => 259703)
--- trunk/Source/WebCore/css/CSSToLengthConversionData.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSToLengthConversionData.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -30,7 +30,9 @@
#pragma once
+#include "CSSPropertyNames.h"
#include <wtf/Assertions.h>
+#include <wtf/Optional.h>
namespace WebCore {
@@ -39,36 +41,40 @@
class CSSToLengthConversionData {
public:
- CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderView* renderView, float zoom, bool computingFontSize = false)
+ CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, float zoom, Optional<CSSPropertyID> propertyToCompute = WTF::nullopt)
: m_style(style)
, m_rootStyle(rootStyle)
+ , m_parentStyle(parentStyle)
, m_renderView(renderView)
, m_zoom(zoom)
, m_useEffectiveZoom(false)
- , m_computingFontSize(computingFontSize)
+ , m_propertyToCompute(propertyToCompute)
{
ASSERT(zoom > 0);
}
- CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderView* renderView, bool computingFontSize = false)
+ CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, Optional<CSSPropertyID> propertyToCompute = WTF::nullopt)
: m_style(style)
, m_rootStyle(rootStyle)
+ , m_parentStyle(parentStyle)
, m_renderView(renderView)
, m_zoom(1)
, m_useEffectiveZoom(true)
- , m_computingFontSize(computingFontSize)
+ , m_propertyToCompute(propertyToCompute)
{
}
CSSToLengthConversionData()
- : CSSToLengthConversionData(nullptr, nullptr, nullptr)
+ : CSSToLengthConversionData(nullptr, nullptr, nullptr, nullptr)
{
}
const RenderStyle* style() const { return m_style; }
const RenderStyle* rootStyle() const { return m_rootStyle; }
+ const RenderStyle* parentStyle() const { return m_parentStyle; }
float zoom() const;
- bool computingFontSize() const { return m_computingFontSize; }
+ bool computingFontSize() const { return m_propertyToCompute == CSSPropertyFontSize; }
+ bool computingLineHeight() const { return m_propertyToCompute == CSSPropertyLineHeight; }
double viewportWidthFactor() const;
double viewportHeightFactor() const;
@@ -77,16 +83,22 @@
CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const
{
- return CSSToLengthConversionData(m_style, m_rootStyle, m_renderView, newZoom, m_computingFontSize);
+ return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, newZoom, m_propertyToCompute);
}
+ CSSToLengthConversionData copyWithAdjustedZoomAndPropertyToCompute(float zoom, Optional<CSSPropertyID> propertyToCompute) const
+ {
+ return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, zoom, propertyToCompute);
+ }
+
private:
const RenderStyle* m_style;
const RenderStyle* m_rootStyle;
+ const RenderStyle* m_parentStyle;
const RenderView* m_renderView;
float m_zoom;
bool m_useEffectiveZoom;
- bool m_computingFontSize;
+ Optional<CSSPropertyID> m_propertyToCompute;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSUnits.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/CSSUnits.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSUnits.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -142,6 +142,8 @@
case CSSUnitType::CSS_DPCM: ts << "dpcm"; break;
case CSSUnitType::CSS_FR: ts << "fr"; break;
case CSSUnitType::CSS_Q: ts << "q"; break;
+ case CSSUnitType::CSS_LHS: ts << "lh"; break;
+ case CSSUnitType::CSS_RLHS: ts << "rlh"; break;
case CSSUnitType::CSS_PAIR: ts << "pair"; break;
case CSSUnitType::CSS_UNICODE_RANGE: ts << "unicode_range"; break;
case CSSUnitType::CSS_TURN: ts << "turn"; break;
Modified: trunk/Source/WebCore/css/CSSUnits.h (259702 => 259703)
--- trunk/Source/WebCore/css/CSSUnits.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/CSSUnits.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -63,6 +63,8 @@
CSS_DPCM = 32,
CSS_FR = 33,
CSS_Q = 34,
+ CSS_LHS = 35,
+ CSS_RLHS = 36,
CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
CSS_UNICODE_RANGE = 102,
CSS_TURN = 107,
Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -899,7 +899,9 @@
if (!document.documentElement())
return false;
- return function(_expression_.value(), { m_style, document.documentElement()->renderStyle(), document.renderView(), 1, false }, *frame, NoPrefix);
+
+ // Pass `nullptr` for `parentStyle` because we are in the context of a media query.
+ return function(_expression_.value(), { m_style, document.documentElement()->renderStyle(), nullptr, document.renderView(), 1, WTF::nullopt }, *frame, NoPrefix);
}
bool MediaQueryEvaluator::mediaAttributeMatches(Document& document, const String& attributeValue)
Modified: trunk/Source/WebCore/css/parser/CSSParserToken.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/parser/CSSParserToken.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/parser/CSSParserToken.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -83,6 +83,10 @@
if (toASCIILower(data[1]) == 'n')
return CSSUnitType::CSS_IN;
break;
+ case 'l':
+ if (toASCIILower(data[1]) == 'h')
+ return CSSUnitType::CSS_LHS;
+ break;
case 'm':
switch (toASCIILower(data[1])) {
case 'm':
@@ -139,6 +143,10 @@
if (toASCIILower(data[2]) == 'm')
return CSSUnitType::CSS_REMS;
break;
+ case 'l':
+ if (toASCIILower(data[2]) == 'h')
+ return CSSUnitType::CSS_RLHS;
+ break;
}
break;
}
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -253,6 +253,8 @@
FALLTHROUGH;
case CSSUnitType::CSS_EMS:
case CSSUnitType::CSS_REMS:
+ case CSSUnitType::CSS_LHS:
+ case CSSUnitType::CSS_RLHS:
case CSSUnitType::CSS_CHS:
case CSSUnitType::CSS_EXS:
case CSSUnitType::CSS_PX:
Modified: trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp (259702 => 259703)
--- trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -51,8 +51,7 @@
return 0;
auto& style = renderer->style();
- CSSToLengthConversionData conversionData(&style, &style, 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
@@ -65,7 +64,6 @@
style.fontCascade().update(fontSelector.get());
return result;
}
-
return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble(conversionData, type, value));
}
@@ -159,7 +157,7 @@
if (!renderer)
return 0;
auto& style = renderer->style();
- return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble({ &style, &style, 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 (259702 => 259703)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -121,9 +121,9 @@
// Set "flex-basis: 1em". Note that CSSPrimitiveValue::computeLengthInt() only needs the element's
// style to calculate em lengths. Since the element might not be in a document, just pass nullptr
- // for the root element style and the render view.
+ // 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, 1.0, false });
+ int pixels = emSize->computeLength<int>(CSSToLengthConversionData { newStyle.get(), nullptr, nullptr, nullptr, 1.0, WTF::nullopt });
newStyle->setFlexBasis(Length { pixels, Fixed });
}
Modified: trunk/Source/WebCore/rendering/RenderElement.h (259702 => 259703)
--- trunk/Source/WebCore/rendering/RenderElement.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/rendering/RenderElement.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -43,6 +43,7 @@
bool hasInitializedStyle() const { return m_hasInitializedStyle; }
const RenderStyle& style() const { return m_style; }
+ const RenderStyle* parentStyle() const { return !m_parent ? nullptr : &m_parent->style(); }
const RenderStyle& firstLineStyle() const;
// FIXME: Style shouldn't be mutated.
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (259702 => 259703)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-04-08 04:45:45 UTC (rev 259703)
@@ -563,7 +563,8 @@
{
Document& document = element.document();
auto emSize = CSSPrimitiveValue::create(0.5, CSSUnitType::CSS_EMS);
- int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, document.renderStyle(), document.renderView(), document.frame()->pageZoomFactor()));
+ // 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()->pageZoomFactor()));
style.setPaddingBox(LengthBox(0, pixels, 0, pixels));
}
@@ -1023,10 +1024,10 @@
// Set padding: 0 1.0em; on buttons.
// CSSPrimitiveValue::computeLengthInt only needs the element's style to calculate em lengths.
- // Since the element might not be in a document, just pass nullptr for the root element style
- // and the render view.
+ // 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, 1.0, false));
+ int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, nullptr, nullptr, nullptr, 1.0, WTF::nullopt));
style.setPaddingBox(LengthBox(0, pixels, 0, pixels));
if (!element)
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (259702 => 259703)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1776,16 +1776,19 @@
int RenderStyle::computedLineHeight() const
{
- const Length& lh = lineHeight();
+ return computeLineHeight(lineHeight());
+}
+int RenderStyle::computeLineHeight(const Length& lineHeightLength) const
+{
// Negative value means the line height is not set. Use the font's built-in spacing.
- if (lh.isNegative())
+ if (lineHeightLength.isNegative())
return fontMetrics().lineSpacing();
- if (lh.isPercentOrCalculated())
- return minimumValueForLength(lh, computedFontPixelSize());
+ if (lineHeightLength.isPercentOrCalculated())
+ return minimumValueForLength(lineHeightLength, computedFontPixelSize());
- return clampTo<int>(lh.value());
+ return clampTo<int>(lineHeightLength.value());
}
void RenderStyle::setWordSpacing(Length&& value)
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (259702 => 259703)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -391,6 +391,7 @@
const Length& specifiedLineHeight() const;
WEBCORE_EXPORT const Length& lineHeight() const;
WEBCORE_EXPORT int computedLineHeight() const;
+ int computeLineHeight(const Length&) const;
WhiteSpace whiteSpace() const { return static_cast<WhiteSpace>(m_inheritedFlags.whiteSpace); }
static bool autoWrap(WhiteSpace);
@@ -1508,6 +1509,7 @@
static Length initialOneLength() { return Length(1, Fixed); }
static short initialWidows() { return 2; }
static short initialOrphans() { return 2; }
+ // Returning -100% percent here means the line-height is not set.
static Length initialLineHeight() { return Length(-100.0f, Percent); }
static TextAlignMode initialTextAlign() { return TextAlignMode::Start; }
static OptionSet<TextDecoration> initialTextDecoration() { return OptionSet<TextDecoration> { }; }
Modified: trunk/Source/WebCore/style/StyleBuilderConverter.h (259702 => 259703)
--- trunk/Source/WebCore/style/StyleBuilderConverter.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/style/StyleBuilderConverter.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1167,15 +1167,24 @@
return autoFlow;
}
-inline CSSToLengthConversionData BuilderConverter::csstoLengthConversionDataWithTextZoomFactor(BuilderState& builderState)
+inline float zoomWithTextZoomFactor(BuilderState& builderState)
{
if (auto* frame = builderState.document().frame()) {
float textZoomFactor = builderState.style().textZoom() != TextZoom::Reset ? frame->textZoomFactor() : 1.0f;
- return builderState.cssToLengthConversionData().copyWithAdjustedZoom(builderState.style().effectiveZoom() * textZoomFactor);
+ return builderState.style().effectiveZoom() * textZoomFactor;
}
- return builderState.cssToLengthConversionData();
+ return builderState.cssToLengthConversionData().zoom();
}
+inline CSSToLengthConversionData BuilderConverter::csstoLengthConversionDataWithTextZoomFactor(BuilderState& builderState)
+{
+ float zoom = zoomWithTextZoomFactor(builderState);
+ if (zoom == builderState.cssToLengthConversionData().zoom())
+ return builderState.cssToLengthConversionData();
+
+ return builderState.cssToLengthConversionData().copyWithAdjustedZoom(zoom);
+}
+
inline Optional<Length> BuilderConverter::convertWordSpacing(BuilderState& builderState, const CSSValue& value)
{
Optional<Length> wordSpacing;
@@ -1511,7 +1520,8 @@
return RenderStyle::initialLineHeight();
if (primitiveValue.isLength()) {
- Length length = primitiveValue.computeLength<Length>(BuilderConverter::csstoLengthConversionDataWithTextZoomFactor(builderState));
+ auto conversionData = builderState.cssToLengthConversionData().copyWithAdjustedZoomAndPropertyToCompute(zoomWithTextZoomFactor(builderState), CSSPropertyLineHeight);
+ Length length = primitiveValue.computeLength<Length>(conversionData);
if (multiplier != 1.f)
length = Length(length.value() * multiplier, Fixed);
return length;
Modified: trunk/Source/WebCore/style/StyleBuilderCustom.h (259702 => 259703)
--- trunk/Source/WebCore/style/StyleBuilderCustom.h 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/style/StyleBuilderCustom.h 2020-04-08 04:45:45 UTC (rev 259703)
@@ -1622,7 +1622,7 @@
} else {
fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength()));
if (primitiveValue.isLength()) {
- size = primitiveValue.computeLength<float>(CSSToLengthConversionData(&builderState.parentStyle(), builderState.rootElementStyle(), builderState.document().renderView(), 1.0f, true));
+ size = primitiveValue.computeLength<float>(CSSToLengthConversionData(&builderState.parentStyle(), builderState.rootElementStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize));
if (primitiveValue.isViewportPercentageLength())
builderState.style().setHasViewportUnits();
} else if (primitiveValue.isPercentage())
@@ -1629,7 +1629,7 @@
size = (primitiveValue.floatValue() * parentSize) / 100.0f;
else if (primitiveValue.isCalculatedPercentageWithLength()) {
const auto& conversionData = builderState.cssToLengthConversionData();
- CSSToLengthConversionData parentConversionData { &builderState.parentStyle(), conversionData.rootStyle(), builderState.document().renderView(), 1.0f, true };
+ CSSToLengthConversionData parentConversionData { &builderState.parentStyle(), conversionData.rootStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize };
size = primitiveValue.cssCalcValue()->createCalculationValue(parentConversionData)->evaluate(parentSize);
} else
return;
Modified: trunk/Source/WebCore/style/StyleBuilderState.cpp (259702 => 259703)
--- trunk/Source/WebCore/style/StyleBuilderState.cpp 2020-04-08 03:59:00 UTC (rev 259702)
+++ trunk/Source/WebCore/style/StyleBuilderState.cpp 2020-04-08 04:45:45 UTC (rev 259703)
@@ -60,7 +60,7 @@
, m_styleMap(*this)
, m_style(style)
, m_context(WTFMove(context))
- , m_cssToLengthConversionData(&style, rootElementStyle(), document().renderView())
+ , m_cssToLengthConversionData(&style, rootElementStyle(), &parentStyle(), document().renderView())
{
}