Changeset 259703 in webkit


Ignore:
Timestamp:
Apr 7, 2020 9:45:45 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

[css-values-4] Support font-relative lh and rlh unit
https://bugs.webkit.org/show_bug.cgi?id=195180

Patch by Tyler Wilcock <Tyler Wilcock> on 2020-04-07
Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

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:

Source/WebCore:

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):

LayoutTests:

Implement support for the font-relative 'lh' and 'rlh' units.
https://www.w3.org/TR/css-values-4/#font-relative-lengths

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r259702 r259703  
     12020-04-07  Tyler Wilcock  <twilco.o@protonmail.com>
     2
     3        [css-values-4] Support font-relative lh and rlh unit
     4        https://bugs.webkit.org/show_bug.cgi?id=195180
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Implement support for the font-relative 'lh' and 'rlh' units.
     9        https://www.w3.org/TR/css-values-4/#font-relative-lengths
     10
    1112020-04-07  Ryan Haddad  <ryanhaddad@apple.com>
    212
  • trunk/LayoutTests/TestExpectations

    r259532 r259703  
    31053105webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-011.html [ ImageOnlyFailure ]
    31063106webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-012.html [ ImageOnlyFailure ]
    3107 webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-001.html [ ImageOnlyFailure ]
    3108 webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-002.html [ ImageOnlyFailure ]
     3107webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-001.html [ Pass ]
     3108webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-002.html [ Pass ]
    31093109webkit.org/b/203337 imported/w3c/web-platform-tests/css/css-values/vh-support-atviewport.html [ ImageOnlyFailure ]
    31103110webkit.org/b/203338 imported/w3c/web-platform-tests/css/css-values/vh_not_refreshing_on_chrome.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r259651 r259703  
     12020-04-07  Tyler Wilcock  <twilco.o@protonmail.com>
     2
     3        [css-values-4] Support font-relative lh and rlh unit
     4        https://bugs.webkit.org/show_bug.cgi?id=195180
     5
     6        Reviewed by Antti Koivisto.
     7
     8        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
     9
     10        * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt:
     11
    1122020-04-07  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt

    r251521 r259703  
    11 
    22
    3 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
    4 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
    5 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
    6 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
    7 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
    8 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
    9 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
    10 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
     3PASS lh in line-height on root
     4PASS rlh in line-height on root
     5PASS lh in font-size on root
     6PASS rlh in font-size on root
     7PASS 2lh in line-height on root
     8PASS 2rlh in line-height on root
     9PASS 2lh in font-size on root
     10FAIL 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
    1111
  • trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt

    r251521 r259703  
    11 
    22
    3 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
    4 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
    5 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
    6 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
    7 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
    8 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
    9 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
    10 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
     3PASS lh in line-height on root
     4PASS rlh in line-height on root
     5PASS lh in font-size on root
     6PASS rlh in font-size on root
     7PASS 2lh in line-height on root
     8PASS 2rlh in line-height on root
     9PASS 2lh in font-size on root
     10FAIL 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
    1111
  • trunk/Source/WebCore/ChangeLog

    r259701 r259703  
     12020-04-07  Tyler Wilcock  <twilco.o@protonmail.com>
     2
     3        [css-values-4] Support font-relative lh and rlh unit
     4        https://bugs.webkit.org/show_bug.cgi?id=195180
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Implement support for 'lh' and 'rlh' units.
     9        https://www.w3.org/TR/css-values-4/#font-relative-lengths
     10
     11        * css/CSSCalculationValue.cpp:
     12        (WebCore::calcUnitCategory):
     13        (WebCore::calculationCategoryForCombination):
     14        (WebCore::hasDoubleValue):
     15        * css/CSSGradientValue.cpp:
     16        (WebCore::CSSLinearGradientValue::createGradient):
     17        (WebCore::CSSRadialGradientValue::createGradient):
     18        (WebCore::CSSConicGradientValue::createGradient):
     19        * css/CSSPrimitiveValue.cpp:
     20        (WebCore::isValidCSSUnitTypeForDoubleConversion):
     21        (WebCore::isStringType):
     22        (WebCore::CSSPrimitiveValue::cleanup):
     23        (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
     24        (WebCore::CSSPrimitiveValue::unitTypeString):
     25        (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
     26        (WebCore::CSSPrimitiveValue::equals const):
     27        (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const):
     28        (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const):
     29        * css/CSSPrimitiveValue.h:
     30        (WebCore::CSSPrimitiveValue::isFontRelativeLength):
     31        (WebCore::CSSPrimitiveValue::isLength):
     32        * css/CSSPrimitiveValueMappings.h:
     33        (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const):
     34        * css/CSSToLengthConversionData.cpp:
     35        (WebCore::CSSToLengthConversionData::viewportWidthFactor const):
     36        (WebCore::CSSToLengthConversionData::viewportHeightFactor const):
     37        (WebCore::CSSToLengthConversionData::viewportMinFactor const):
     38        (WebCore::CSSToLengthConversionData::viewportMaxFactor const):
     39        * 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.
     40        (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values.
     41        (WebCore::CSSToLengthConversionData::parentStyle const):
     42        (WebCore::CSSToLengthConversionData::computingFontSize const):
     43        (WebCore::CSSToLengthConversionData::computingLineHeight const):
     44        (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const):
     45        (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const):
     46        * css/CSSUnits.cpp:
     47        (WebCore::operator<<):
     48        * css/CSSUnits.h:
     49        * css/MediaQueryEvaluator.cpp:
     50        (WebCore::MediaQueryEvaluator::evaluate const):
     51        * css/parser/CSSParserToken.cpp:
     52        (WebCore::cssPrimitiveValueUnitFromTrie):
     53        * css/parser/CSSPropertyParserHelpers.cpp:
     54        (WebCore::CSSPropertyParserHelpers::consumeLength):
     55        * css/parser/SizesAttributeParser.cpp:
     56        (WebCore::SizesAttributeParser::computeLength):
     57        (WebCore::SizesAttributeParser::effectiveSizeDefaultValue):
     58        * html/shadow/TextControlInnerElements.cpp:
     59        (WebCore::TextControlInnerElement::resolveCustomStyle):
     60        * rendering/RenderElement.h:
     61        (WebCore::RenderElement::parentStyle const):
     62        * rendering/RenderThemeIOS.mm:
     63        (WebCore::applyCommonButtonPaddingToStyle):
     64        (WebCore::RenderThemeIOS::adjustButtonStyle const):
     65        * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere.
     66        (WebCore::RenderStyle::computedLineHeight const):
     67        (WebCore::RenderStyle::computeLineHeight const):
     68        * rendering/style/RenderStyle.h:
     69        * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere.
     70        (WebCore::Style::zoomWithTextZoomFactor):
     71        (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor):
     72        (WebCore::Style::BuilderConverter::convertLineHeight):
     73        * style/StyleBuilderCustom.h:
     74        (WebCore::Style::BuilderCustom::applyValueFontSize):
     75        * style/StyleBuilderState.cpp:
     76        (WebCore::Style::BuilderState::BuilderState):
     77
    1782020-04-07  Zalan Bujtas  <zalan@apple.com>
    279
  • trunk/Source/WebCore/css/CSSCalculationValue.cpp

    r254087 r259703  
    8181    case CSSUnitType::CSS_PC:
    8282    case CSSUnitType::CSS_Q:
     83    case CSSUnitType::CSS_LHS:
     84    case CSSUnitType::CSS_RLHS:
    8385    case CSSUnitType::CSS_REMS:
    8486    case CSSUnitType::CSS_CHS:
     
    134136    case CSSUnitType::CSS_EMS:
    135137    case CSSUnitType::CSS_EXS:
     138    case CSSUnitType::CSS_LHS:
    136139    case CSSUnitType::CSS_REMS:
     140    case CSSUnitType::CSS_RLHS:
    137141    case CSSUnitType::CSS_CHS:
    138142    case CSSUnitType::CSS_VW:
     
    196200    case CSSUnitType::CSS_FR:
    197201    case CSSUnitType::CSS_Q:
     202    case CSSUnitType::CSS_LHS:
     203    case CSSUnitType::CSS_RLHS:
    198204        return true;
    199205    case CSSUnitType::CSS_UNKNOWN:
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r259532 r259703  
    808808    ASSERT(!size.isEmpty());
    809809
    810     CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());
     810    CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view());
    811811
    812812    FloatPoint firstPoint;
     
    10571057    ASSERT(!size.isEmpty());
    10581058
    1059     CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());
     1059    CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view());
    10601060
    10611061    FloatPoint firstPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
     
    12481248    ASSERT(!size.isEmpty());
    12491249
    1250     CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());
     1250    CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view());
    12511251
    12521252    FloatPoint centerPoint = computeEndPoint(firstX(), firstY(), conversionData, size);
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r258625 r259703  
    7272    case CSSUnitType::CSS_PX:
    7373    case CSSUnitType::CSS_Q:
     74    case CSSUnitType::CSS_LHS:
     75    case CSSUnitType::CSS_RLHS:
    7476    case CSSUnitType::CSS_QUIRKY_EMS:
    7577    case CSSUnitType::CSS_RAD:
     
    148150    case CSSUnitType::CSS_PX:
    149151    case CSSUnitType::CSS_Q:
     152    case CSSUnitType::CSS_LHS:
     153    case CSSUnitType::CSS_RLHS:
    150154    case CSSUnitType::CSS_QUAD:
    151155    case CSSUnitType::CSS_QUIRKY_EMS:
     
    503507    case CSSUnitType::CSS_FR:
    504508    case CSSUnitType::CSS_Q:
     509    case CSSUnitType::CSS_LHS:
     510    case CSSUnitType::CSS_RLHS:
    505511    case CSSUnitType::CSS_IDENT:
    506512    case CSSUnitType::CSS_UNKNOWN:
     
    631637    case CSSUnitType::CSS_Q:
    632638        factor = cssPixelsPerInch / QPerInch;
     639        break;
     640    case CSSUnitType::CSS_LHS:
     641        ASSERT(conversionData.style());
     642        if (conversionData.computingLineHeight() || conversionData.computingFontSize()) {
     643            // Try to get the parent's computed line-height, or fall back to the initial line-height of this element's font spacing.
     644            factor = conversionData.parentStyle() ? conversionData.parentStyle()->computedLineHeight() : conversionData.style()->fontMetrics().lineSpacing();
     645        } else
     646            factor = conversionData.style()->computedLineHeight();
     647        break;
     648    case CSSUnitType::CSS_RLHS:
     649        if (conversionData.rootStyle()) {
     650            if (conversionData.computingLineHeight() || conversionData.computingFontSize())
     651                factor = conversionData.rootStyle()->computeLineHeight(conversionData.rootStyle()->specifiedLineHeight());
     652            else
     653                factor = conversionData.rootStyle()->computedLineHeight();
     654        } else
     655            factor = 1.0;
    633656        break;
    634657    case CSSUnitType::CSS_IN:
     
    926949        case CSSUnitType::CSS_FR: return "fr";
    927950        case CSSUnitType::CSS_Q: return "q";
     951        case CSSUnitType::CSS_LHS: return "lh";
     952        case CSSUnitType::CSS_RLHS: return "rlh";
    928953        case CSSUnitType::CSS_TURN: return "turn";
    929954        case CSSUnitType::CSS_REMS: return "rem";
     
    10131038    case CSSUnitType::CSS_Q:
    10141039        return formatNumberValue("q");
     1040    case CSSUnitType::CSS_LHS:
     1041        return formatNumberValue("lh");
     1042    case CSSUnitType::CSS_RLHS:
     1043        return formatNumberValue("rlh");
    10151044    case CSSUnitType::CSS_DIMENSION:
    10161045        // FIXME: We currently don't handle CSSUnitType::CSS_DIMENSION properly as we don't store
     
    11401169    case CSSUnitType::CSS_FR:
    11411170    case CSSUnitType::CSS_Q:
     1171    case CSSUnitType::CSS_LHS:
     1172    case CSSUnitType::CSS_RLHS:
    11421173        return m_value.num == other.m_value.num;
    11431174    case CSSUnitType::CSS_PROPERTY_ID:
     
    11831214}
    11841215
    1185 // https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles-via-relative-units
     1216// https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles
    11861217void CSSPrimitiveValue::collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const
    11871218{
     
    11931224        values.add(CSSPropertyFontSize);
    11941225        break;
     1226    case CSSUnitType::CSS_LHS:
     1227        values.add(CSSPropertyFontSize);
     1228        values.add(CSSPropertyLineHeight);
     1229        break;
    11951230    case CSSUnitType::CSS_CALC:
    11961231        m_value.calc->collectDirectComputationalDependencies(values);
     
    12071242        values.add(CSSPropertyFontSize);
    12081243        break;
     1244    case CSSUnitType::CSS_RLHS:
     1245        values.add(CSSPropertyFontSize);
     1246        values.add(CSSPropertyLineHeight);
     1247        break;
    12091248    case CSSUnitType::CSS_CALC:
    12101249        m_value.calc->collectDirectRootComputationalDependencies(values);
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r257698 r259703  
    261261    return type == CSSUnitType::CSS_EMS
    262262        || type == CSSUnitType::CSS_EXS
     263        || type == CSSUnitType::CSS_LHS
     264        || type == CSSUnitType::CSS_RLHS
    263265        || type == CSSUnitType::CSS_REMS
    264266        || type == CSSUnitType::CSS_CHS
     
    272274        || type == CSSUnitType::CSS_CHS
    273275        || type == CSSUnitType::CSS_Q
     276        || type == CSSUnitType::CSS_LHS
     277        || type == CSSUnitType::CSS_RLHS
    274278        || isViewportPercentageLength(type)
    275279        || type == CSSUnitType::CSS_QUIRKY_EMS;
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r258148 r259703  
    45154515    case CSSUnitType::CSS_EXS:
    45164516    case CSSUnitType::CSS_CHS:
     4517    case CSSUnitType::CSS_LHS:
    45174518        return lengthConversion & (FixedIntegerConversion | FixedFloatConversion);
    45184519    default:
  • trunk/Source/WebCore/css/CSSToLengthConversionData.cpp

    r200098 r259703  
    4646double CSSToLengthConversionData::viewportWidthFactor() const
    4747{
    48     if (m_style && !m_computingFontSize)
     48    if (m_style && !computingFontSize())
    4949        const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
    5050
     
    5757double CSSToLengthConversionData::viewportHeightFactor() const
    5858{
    59     if (m_style && !m_computingFontSize)
     59    if (m_style && !computingFontSize())
    6060        const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
    6161
     
    6868double CSSToLengthConversionData::viewportMinFactor() const
    6969{
    70     if (m_style && !m_computingFontSize)
     70    if (m_style && !computingFontSize())
    7171        const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
    7272
     
    8080double CSSToLengthConversionData::viewportMaxFactor() const
    8181{
    82     if (m_style && !m_computingFontSize)
     82    if (m_style && !computingFontSize())
    8383        const_cast<RenderStyle*>(m_style)->setHasViewportUnits();
    8484
  • trunk/Source/WebCore/css/CSSToLengthConversionData.h

    r218588 r259703  
    3131#pragma once
    3232
     33#include "CSSPropertyNames.h"
    3334#include <wtf/Assertions.h>
     35#include <wtf/Optional.h>
    3436
    3537namespace WebCore {
     
    4042class CSSToLengthConversionData {
    4143public:
    42     CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderView* renderView, float zoom, bool computingFontSize = false)
     44    CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, float zoom, Optional<CSSPropertyID> propertyToCompute = WTF::nullopt)
    4345        : m_style(style)
    4446        , m_rootStyle(rootStyle)
     47        , m_parentStyle(parentStyle)
    4548        , m_renderView(renderView)
    4649        , m_zoom(zoom)
    4750        , m_useEffectiveZoom(false)
    48         , m_computingFontSize(computingFontSize)
     51        , m_propertyToCompute(propertyToCompute)
    4952    {
    5053        ASSERT(zoom > 0);
    5154    }
    5255
    53     CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderView* renderView, bool computingFontSize = false)
     56    CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, Optional<CSSPropertyID> propertyToCompute = WTF::nullopt)
    5457        : m_style(style)
    5558        , m_rootStyle(rootStyle)
     59        , m_parentStyle(parentStyle)
    5660        , m_renderView(renderView)
    5761        , m_zoom(1)
    5862        , m_useEffectiveZoom(true)
    59         , m_computingFontSize(computingFontSize)
     63        , m_propertyToCompute(propertyToCompute)
    6064    {
    6165    }
    6266
    6367    CSSToLengthConversionData()
    64         : CSSToLengthConversionData(nullptr, nullptr, nullptr)
     68        : CSSToLengthConversionData(nullptr, nullptr, nullptr, nullptr)
    6569    {
    6670    }
     
    6872    const RenderStyle* style() const { return m_style; }
    6973    const RenderStyle* rootStyle() const { return m_rootStyle; }
     74    const RenderStyle* parentStyle() const { return m_parentStyle; }
    7075    float zoom() const;
    71     bool computingFontSize() const { return m_computingFontSize; }
     76    bool computingFontSize() const { return m_propertyToCompute == CSSPropertyFontSize; }
     77    bool computingLineHeight() const { return m_propertyToCompute == CSSPropertyLineHeight; }
    7278
    7379    double viewportWidthFactor() const;
     
    7884    CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const
    7985    {
    80         return CSSToLengthConversionData(m_style, m_rootStyle, m_renderView, newZoom, m_computingFontSize);
     86        return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, newZoom, m_propertyToCompute);
     87    }
     88
     89    CSSToLengthConversionData copyWithAdjustedZoomAndPropertyToCompute(float zoom, Optional<CSSPropertyID> propertyToCompute) const
     90    {
     91        return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, zoom, propertyToCompute);
    8192    }
    8293
     
    8495    const RenderStyle* m_style;
    8596    const RenderStyle* m_rootStyle;
     97    const RenderStyle* m_parentStyle;
    8698    const RenderView* m_renderView;
    8799    float m_zoom;
    88100    bool m_useEffectiveZoom;
    89     bool m_computingFontSize;
     101    Optional<CSSPropertyID> m_propertyToCompute;
    90102};
    91103
  • trunk/Source/WebCore/css/CSSUnits.cpp

    r253079 r259703  
    143143    case CSSUnitType::CSS_FR: ts << "fr"; break;
    144144    case CSSUnitType::CSS_Q: ts << "q"; break;
     145    case CSSUnitType::CSS_LHS: ts << "lh"; break;
     146    case CSSUnitType::CSS_RLHS: ts << "rlh"; break;
    145147    case CSSUnitType::CSS_PAIR: ts << "pair"; break;
    146148    case CSSUnitType::CSS_UNICODE_RANGE: ts << "unicode_range"; break;
  • trunk/Source/WebCore/css/CSSUnits.h

    r253079 r259703  
    6464    CSS_FR = 33,
    6565    CSS_Q = 34,
     66    CSS_LHS = 35,
     67    CSS_RLHS = 36,
    6668    CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
    6769    CSS_UNICODE_RANGE = 102,
  • trunk/Source/WebCore/css/MediaQueryEvaluator.cpp

    r259387 r259703  
    900900    if (!document.documentElement())
    901901        return false;
    902     return function(expression.value(), { m_style, document.documentElement()->renderStyle(), document.renderView(), 1, false }, *frame, NoPrefix);
     902   
     903    // Pass `nullptr` for `parentStyle` because we are in the context of a media query.
     904    return function(expression.value(), { m_style, document.documentElement()->renderStyle(), nullptr, document.renderView(), 1, WTF::nullopt }, *frame, NoPrefix);
    903905}
    904906
  • trunk/Source/WebCore/css/parser/CSSParserToken.cpp

    r254514 r259703  
    8484                return CSSUnitType::CSS_IN;
    8585            break;
     86        case 'l':
     87            if (toASCIILower(data[1]) == 'h')
     88                return CSSUnitType::CSS_LHS;
     89            break;
    8690        case 'm':
    8791            switch (toASCIILower(data[1])) {
     
    139143                if (toASCIILower(data[2]) == 'm')
    140144                    return CSSUnitType::CSS_REMS;
     145                break;
     146            case 'l':
     147                if (toASCIILower(data[2]) == 'h')
     148                    return CSSUnitType::CSS_RLHS;
    141149                break;
    142150            }
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

    r258392 r259703  
    254254        case CSSUnitType::CSS_EMS:
    255255        case CSSUnitType::CSS_REMS:
     256        case CSSUnitType::CSS_LHS:
     257        case CSSUnitType::CSS_RLHS:
    256258        case CSSUnitType::CSS_CHS:
    257259        case CSSUnitType::CSS_EXS:
  • trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp

    r252828 r259703  
    5252    auto& style = renderer->style();
    5353
    54     CSSToLengthConversionData conversionData(&style, &style, renderer);
    55    
     54    CSSToLengthConversionData conversionData(&style, &style, renderer->parentStyle(), renderer);
    5655    // Because we evaluate "sizes" at parse time (before style has been resolved), the font metrics used for these specific units
    5756    // are not available. The font selector's internal consistency isn't guaranteed just yet, so we can just temporarily clear
     
    6665        return result;
    6766    }
    68    
    6967    return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble(conversionData, type, value));
    7068}
     
    160158        return 0;
    161159    auto& style = renderer->style();
    162     return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble({ &style, &style, renderer }, CSSUnitType::CSS_VW, 100.0));
     160    return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble({ &style, &style, renderer->parentStyle(), renderer }, CSSUnitType::CSS_VW, 100.0));
    163161}
    164162
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp

    r257839 r259703  
    122122        // Set "flex-basis: 1em". Note that CSSPrimitiveValue::computeLengthInt() only needs the element's
    123123        // style to calculate em lengths. Since the element might not be in a document, just pass nullptr
    124         // for the root element style and the render view.
     124        // for the root element style, the parent element style, and the render view.
    125125        auto emSize = CSSPrimitiveValue::create(1, CSSUnitType::CSS_EMS);
    126         int pixels = emSize->computeLength<int>(CSSToLengthConversionData { newStyle.get(), nullptr, nullptr, 1.0, false });
     126        int pixels = emSize->computeLength<int>(CSSToLengthConversionData { newStyle.get(), nullptr, nullptr, nullptr, 1.0, WTF::nullopt });
    127127        newStyle->setFlexBasis(Length { pixels, Fixed });
    128128    }
  • trunk/Source/WebCore/rendering/RenderElement.h

    r252968 r259703  
    4444
    4545    const RenderStyle& style() const { return m_style; }
     46    const RenderStyle* parentStyle() const { return !m_parent ? nullptr : &m_parent->style(); }
    4647    const RenderStyle& firstLineStyle() const;
    4748
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r259435 r259703  
    564564    Document& document = element.document();
    565565    auto emSize = CSSPrimitiveValue::create(0.5, CSSUnitType::CSS_EMS);
    566     int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, document.renderStyle(), document.renderView(), document.frame()->pageZoomFactor()));
     566    // We don't need this element's parent style to calculate `em` units, so it's okay to pass nullptr for it here.
     567    int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, document.renderStyle(), nullptr, document.renderView(), document.frame()->pageZoomFactor()));
    567568    style.setPaddingBox(LengthBox(0, pixels, 0, pixels));
    568569}
     
    10241025    // Set padding: 0 1.0em; on buttons.
    10251026    // CSSPrimitiveValue::computeLengthInt only needs the element's style to calculate em lengths.
    1026     // Since the element might not be in a document, just pass nullptr for the root element style
    1027     // and the render view.
     1027    // Since the element might not be in a document, just pass nullptr for the root element style,
     1028    // the parent element style, and the render view.
    10281029    auto emSize = CSSPrimitiveValue::create(1.0, CSSUnitType::CSS_EMS);
    1029     int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, nullptr, nullptr, 1.0, false));
     1030    int pixels = emSize->computeLength<int>(CSSToLengthConversionData(&style, nullptr, nullptr, nullptr, 1.0, WTF::nullopt));
    10301031    style.setPaddingBox(LengthBox(0, pixels, 0, pixels));
    10311032
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r259585 r259703  
    17771777int RenderStyle::computedLineHeight() const
    17781778{
    1779     const Length& lh = lineHeight();
    1780 
     1779    return computeLineHeight(lineHeight());
     1780}
     1781
     1782int RenderStyle::computeLineHeight(const Length& lineHeightLength) const
     1783{
    17811784    // Negative value means the line height is not set. Use the font's built-in spacing.
    1782     if (lh.isNegative())
     1785    if (lineHeightLength.isNegative())
    17831786        return fontMetrics().lineSpacing();
    17841787
    1785     if (lh.isPercentOrCalculated())
    1786         return minimumValueForLength(lh, computedFontPixelSize());
    1787 
    1788     return clampTo<int>(lh.value());
     1788    if (lineHeightLength.isPercentOrCalculated())
     1789        return minimumValueForLength(lineHeightLength, computedFontPixelSize());
     1790
     1791    return clampTo<int>(lineHeightLength.value());
    17891792}
    17901793
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r259585 r259703  
    392392    WEBCORE_EXPORT const Length& lineHeight() const;
    393393    WEBCORE_EXPORT int computedLineHeight() const;
     394    int computeLineHeight(const Length&) const;
    394395
    395396    WhiteSpace whiteSpace() const { return static_cast<WhiteSpace>(m_inheritedFlags.whiteSpace); }
     
    15091510    static short initialWidows() { return 2; }
    15101511    static short initialOrphans() { return 2; }
     1512    // Returning -100% percent here means the line-height is not set.
    15111513    static Length initialLineHeight() { return Length(-100.0f, Percent); }
    15121514    static TextAlignMode initialTextAlign() { return TextAlignMode::Start; }
  • trunk/Source/WebCore/style/StyleBuilderConverter.h

    r258148 r259703  
    11681168}
    11691169
    1170 inline CSSToLengthConversionData BuilderConverter::csstoLengthConversionDataWithTextZoomFactor(BuilderState& builderState)
     1170inline float zoomWithTextZoomFactor(BuilderState& builderState)
    11711171{
    11721172    if (auto* frame = builderState.document().frame()) {
    11731173        float textZoomFactor = builderState.style().textZoom() != TextZoom::Reset ? frame->textZoomFactor() : 1.0f;
    1174         return builderState.cssToLengthConversionData().copyWithAdjustedZoom(builderState.style().effectiveZoom() * textZoomFactor);
    1175     }
    1176     return builderState.cssToLengthConversionData();
     1174        return builderState.style().effectiveZoom() * textZoomFactor;
     1175    }
     1176    return builderState.cssToLengthConversionData().zoom();
     1177}
     1178
     1179inline CSSToLengthConversionData BuilderConverter::csstoLengthConversionDataWithTextZoomFactor(BuilderState& builderState)
     1180{
     1181    float zoom = zoomWithTextZoomFactor(builderState);
     1182    if (zoom == builderState.cssToLengthConversionData().zoom())
     1183        return builderState.cssToLengthConversionData();
     1184
     1185    return builderState.cssToLengthConversionData().copyWithAdjustedZoom(zoom);
    11771186}
    11781187
     
    15121521
    15131522    if (primitiveValue.isLength()) {
    1514         Length length = primitiveValue.computeLength<Length>(BuilderConverter::csstoLengthConversionDataWithTextZoomFactor(builderState));
     1523        auto conversionData = builderState.cssToLengthConversionData().copyWithAdjustedZoomAndPropertyToCompute(zoomWithTextZoomFactor(builderState), CSSPropertyLineHeight);
     1524        Length length = primitiveValue.computeLength<Length>(conversionData);
    15151525        if (multiplier != 1.f)
    15161526            length = Length(length.value() * multiplier, Fixed);
  • trunk/Source/WebCore/style/StyleBuilderCustom.h

    r259532 r259703  
    16231623        fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength()));
    16241624        if (primitiveValue.isLength()) {
    1625             size = primitiveValue.computeLength<float>(CSSToLengthConversionData(&builderState.parentStyle(), builderState.rootElementStyle(), builderState.document().renderView(), 1.0f, true));
     1625            size = primitiveValue.computeLength<float>(CSSToLengthConversionData(&builderState.parentStyle(), builderState.rootElementStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize));
    16261626            if (primitiveValue.isViewportPercentageLength())
    16271627                builderState.style().setHasViewportUnits();
     
    16301630        else if (primitiveValue.isCalculatedPercentageWithLength()) {
    16311631            const auto& conversionData = builderState.cssToLengthConversionData();
    1632             CSSToLengthConversionData parentConversionData { &builderState.parentStyle(), conversionData.rootStyle(), builderState.document().renderView(), 1.0f, true };
     1632            CSSToLengthConversionData parentConversionData { &builderState.parentStyle(), conversionData.rootStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize };
    16331633            size = primitiveValue.cssCalcValue()->createCalculationValue(parentConversionData)->evaluate(parentSize);
    16341634        } else
  • trunk/Source/WebCore/style/StyleBuilderState.cpp

    r259585 r259703  
    6161    , m_style(style)
    6262    , m_context(WTFMove(context))
    63     , m_cssToLengthConversionData(&style, rootElementStyle(), document().renderView())
     63    , m_cssToLengthConversionData(&style, rootElementStyle(), &parentStyle(), document().renderView())
    6464{
    6565}
Note: See TracChangeset for help on using the changeset viewer.