Ignore:
Timestamp:
Apr 7, 2020, 9:45:45 PM (5 years ago)
Author:
[email protected]
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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.