Changeset 259703 in webkit
- Timestamp:
- Apr 7, 2020 9:45:45 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r259702 r259703 1 2020-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 1 11 2020-04-07 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/LayoutTests/TestExpectations
r259532 r259703 3105 3105 webkit.org/b/203334 imported/w3c/web-platform-tests/css/css-values/ic-unit-011.html [ ImageOnlyFailure ] 3106 3106 webkit.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]3107 webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-001.html [ Pass ] 3108 webkit.org/b/203336 imported/w3c/web-platform-tests/css/css-values/lh-unit-002.html [ Pass ] 3109 3109 webkit.org/b/203337 imported/w3c/web-platform-tests/css/css-values/vh-support-atviewport.html [ ImageOnlyFailure ] 3110 3110 webkit.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 1 2020-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 1 12 2020-04-07 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt
r251521 r259703 1 1 2 2 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 163 PASS lh in line-height on root 4 PASS rlh in line-height on root 5 PASS lh in font-size on root 6 PASS rlh in font-size on root 7 PASS 2lh in line-height on root 8 PASS 2rlh in line-height on root 9 PASS 2lh in font-size on root 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 36 11 11 -
trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt
r251521 r259703 1 1 2 2 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 163 PASS lh in line-height on root 4 PASS rlh in line-height on root 5 PASS lh in font-size on root 6 PASS rlh in font-size on root 7 PASS 2lh in line-height on root 8 PASS 2rlh in line-height on root 9 PASS 2lh in font-size on root 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 40 11 11 -
trunk/Source/WebCore/ChangeLog
r259701 r259703 1 2020-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 1 78 2020-04-07 Zalan Bujtas <zalan@apple.com> 2 79 -
trunk/Source/WebCore/css/CSSCalculationValue.cpp
r254087 r259703 81 81 case CSSUnitType::CSS_PC: 82 82 case CSSUnitType::CSS_Q: 83 case CSSUnitType::CSS_LHS: 84 case CSSUnitType::CSS_RLHS: 83 85 case CSSUnitType::CSS_REMS: 84 86 case CSSUnitType::CSS_CHS: … … 134 136 case CSSUnitType::CSS_EMS: 135 137 case CSSUnitType::CSS_EXS: 138 case CSSUnitType::CSS_LHS: 136 139 case CSSUnitType::CSS_REMS: 140 case CSSUnitType::CSS_RLHS: 137 141 case CSSUnitType::CSS_CHS: 138 142 case CSSUnitType::CSS_VW: … … 196 200 case CSSUnitType::CSS_FR: 197 201 case CSSUnitType::CSS_Q: 202 case CSSUnitType::CSS_LHS: 203 case CSSUnitType::CSS_RLHS: 198 204 return true; 199 205 case CSSUnitType::CSS_UNKNOWN: -
trunk/Source/WebCore/css/CSSGradientValue.cpp
r259532 r259703 808 808 ASSERT(!size.isEmpty()); 809 809 810 CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());810 CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view()); 811 811 812 812 FloatPoint firstPoint; … … 1057 1057 ASSERT(!size.isEmpty()); 1058 1058 1059 CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());1059 CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view()); 1060 1060 1061 1061 FloatPoint firstPoint = computeEndPoint(firstX(), firstY(), conversionData, size); … … 1248 1248 ASSERT(!size.isEmpty()); 1249 1249 1250 CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), &renderer.view());1250 CSSToLengthConversionData conversionData(&renderer.style(), renderer.document().documentElement()->renderStyle(), renderer.parentStyle(), &renderer.view()); 1251 1251 1252 1252 FloatPoint centerPoint = computeEndPoint(firstX(), firstY(), conversionData, size); -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r258625 r259703 72 72 case CSSUnitType::CSS_PX: 73 73 case CSSUnitType::CSS_Q: 74 case CSSUnitType::CSS_LHS: 75 case CSSUnitType::CSS_RLHS: 74 76 case CSSUnitType::CSS_QUIRKY_EMS: 75 77 case CSSUnitType::CSS_RAD: … … 148 150 case CSSUnitType::CSS_PX: 149 151 case CSSUnitType::CSS_Q: 152 case CSSUnitType::CSS_LHS: 153 case CSSUnitType::CSS_RLHS: 150 154 case CSSUnitType::CSS_QUAD: 151 155 case CSSUnitType::CSS_QUIRKY_EMS: … … 503 507 case CSSUnitType::CSS_FR: 504 508 case CSSUnitType::CSS_Q: 509 case CSSUnitType::CSS_LHS: 510 case CSSUnitType::CSS_RLHS: 505 511 case CSSUnitType::CSS_IDENT: 506 512 case CSSUnitType::CSS_UNKNOWN: … … 631 637 case CSSUnitType::CSS_Q: 632 638 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; 633 656 break; 634 657 case CSSUnitType::CSS_IN: … … 926 949 case CSSUnitType::CSS_FR: return "fr"; 927 950 case CSSUnitType::CSS_Q: return "q"; 951 case CSSUnitType::CSS_LHS: return "lh"; 952 case CSSUnitType::CSS_RLHS: return "rlh"; 928 953 case CSSUnitType::CSS_TURN: return "turn"; 929 954 case CSSUnitType::CSS_REMS: return "rem"; … … 1013 1038 case CSSUnitType::CSS_Q: 1014 1039 return formatNumberValue("q"); 1040 case CSSUnitType::CSS_LHS: 1041 return formatNumberValue("lh"); 1042 case CSSUnitType::CSS_RLHS: 1043 return formatNumberValue("rlh"); 1015 1044 case CSSUnitType::CSS_DIMENSION: 1016 1045 // FIXME: We currently don't handle CSSUnitType::CSS_DIMENSION properly as we don't store … … 1140 1169 case CSSUnitType::CSS_FR: 1141 1170 case CSSUnitType::CSS_Q: 1171 case CSSUnitType::CSS_LHS: 1172 case CSSUnitType::CSS_RLHS: 1142 1173 return m_value.num == other.m_value.num; 1143 1174 case CSSUnitType::CSS_PROPERTY_ID: … … 1183 1214 } 1184 1215 1185 // https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles -via-relative-units1216 // https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles 1186 1217 void CSSPrimitiveValue::collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const 1187 1218 { … … 1193 1224 values.add(CSSPropertyFontSize); 1194 1225 break; 1226 case CSSUnitType::CSS_LHS: 1227 values.add(CSSPropertyFontSize); 1228 values.add(CSSPropertyLineHeight); 1229 break; 1195 1230 case CSSUnitType::CSS_CALC: 1196 1231 m_value.calc->collectDirectComputationalDependencies(values); … … 1207 1242 values.add(CSSPropertyFontSize); 1208 1243 break; 1244 case CSSUnitType::CSS_RLHS: 1245 values.add(CSSPropertyFontSize); 1246 values.add(CSSPropertyLineHeight); 1247 break; 1209 1248 case CSSUnitType::CSS_CALC: 1210 1249 m_value.calc->collectDirectRootComputationalDependencies(values); -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r257698 r259703 261 261 return type == CSSUnitType::CSS_EMS 262 262 || type == CSSUnitType::CSS_EXS 263 || type == CSSUnitType::CSS_LHS 264 || type == CSSUnitType::CSS_RLHS 263 265 || type == CSSUnitType::CSS_REMS 264 266 || type == CSSUnitType::CSS_CHS … … 272 274 || type == CSSUnitType::CSS_CHS 273 275 || type == CSSUnitType::CSS_Q 276 || type == CSSUnitType::CSS_LHS 277 || type == CSSUnitType::CSS_RLHS 274 278 || isViewportPercentageLength(type) 275 279 || type == CSSUnitType::CSS_QUIRKY_EMS; -
trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h
r258148 r259703 4515 4515 case CSSUnitType::CSS_EXS: 4516 4516 case CSSUnitType::CSS_CHS: 4517 case CSSUnitType::CSS_LHS: 4517 4518 return lengthConversion & (FixedIntegerConversion | FixedFloatConversion); 4518 4519 default: -
trunk/Source/WebCore/css/CSSToLengthConversionData.cpp
r200098 r259703 46 46 double CSSToLengthConversionData::viewportWidthFactor() const 47 47 { 48 if (m_style && ! m_computingFontSize)48 if (m_style && !computingFontSize()) 49 49 const_cast<RenderStyle*>(m_style)->setHasViewportUnits(); 50 50 … … 57 57 double CSSToLengthConversionData::viewportHeightFactor() const 58 58 { 59 if (m_style && ! m_computingFontSize)59 if (m_style && !computingFontSize()) 60 60 const_cast<RenderStyle*>(m_style)->setHasViewportUnits(); 61 61 … … 68 68 double CSSToLengthConversionData::viewportMinFactor() const 69 69 { 70 if (m_style && ! m_computingFontSize)70 if (m_style && !computingFontSize()) 71 71 const_cast<RenderStyle*>(m_style)->setHasViewportUnits(); 72 72 … … 80 80 double CSSToLengthConversionData::viewportMaxFactor() const 81 81 { 82 if (m_style && ! m_computingFontSize)82 if (m_style && !computingFontSize()) 83 83 const_cast<RenderStyle*>(m_style)->setHasViewportUnits(); 84 84 -
trunk/Source/WebCore/css/CSSToLengthConversionData.h
r218588 r259703 31 31 #pragma once 32 32 33 #include "CSSPropertyNames.h" 33 34 #include <wtf/Assertions.h> 35 #include <wtf/Optional.h> 34 36 35 37 namespace WebCore { … … 40 42 class CSSToLengthConversionData { 41 43 public: 42 CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const Render View* 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) 43 45 : m_style(style) 44 46 , m_rootStyle(rootStyle) 47 , m_parentStyle(parentStyle) 45 48 , m_renderView(renderView) 46 49 , m_zoom(zoom) 47 50 , m_useEffectiveZoom(false) 48 , m_ computingFontSize(computingFontSize)51 , m_propertyToCompute(propertyToCompute) 49 52 { 50 53 ASSERT(zoom > 0); 51 54 } 52 55 53 CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const Render View* renderView, bool computingFontSize = false)56 CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, Optional<CSSPropertyID> propertyToCompute = WTF::nullopt) 54 57 : m_style(style) 55 58 , m_rootStyle(rootStyle) 59 , m_parentStyle(parentStyle) 56 60 , m_renderView(renderView) 57 61 , m_zoom(1) 58 62 , m_useEffectiveZoom(true) 59 , m_ computingFontSize(computingFontSize)63 , m_propertyToCompute(propertyToCompute) 60 64 { 61 65 } 62 66 63 67 CSSToLengthConversionData() 64 : CSSToLengthConversionData(nullptr, nullptr, nullptr )68 : CSSToLengthConversionData(nullptr, nullptr, nullptr, nullptr) 65 69 { 66 70 } … … 68 72 const RenderStyle* style() const { return m_style; } 69 73 const RenderStyle* rootStyle() const { return m_rootStyle; } 74 const RenderStyle* parentStyle() const { return m_parentStyle; } 70 75 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; } 72 78 73 79 double viewportWidthFactor() const; … … 78 84 CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const 79 85 { 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); 81 92 } 82 93 … … 84 95 const RenderStyle* m_style; 85 96 const RenderStyle* m_rootStyle; 97 const RenderStyle* m_parentStyle; 86 98 const RenderView* m_renderView; 87 99 float m_zoom; 88 100 bool m_useEffectiveZoom; 89 bool m_computingFontSize;101 Optional<CSSPropertyID> m_propertyToCompute; 90 102 }; 91 103 -
trunk/Source/WebCore/css/CSSUnits.cpp
r253079 r259703 143 143 case CSSUnitType::CSS_FR: ts << "fr"; break; 144 144 case CSSUnitType::CSS_Q: ts << "q"; break; 145 case CSSUnitType::CSS_LHS: ts << "lh"; break; 146 case CSSUnitType::CSS_RLHS: ts << "rlh"; break; 145 147 case CSSUnitType::CSS_PAIR: ts << "pair"; break; 146 148 case CSSUnitType::CSS_UNICODE_RANGE: ts << "unicode_range"; break; -
trunk/Source/WebCore/css/CSSUnits.h
r253079 r259703 64 64 CSS_FR = 33, 65 65 CSS_Q = 34, 66 CSS_LHS = 35, 67 CSS_RLHS = 36, 66 68 CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.) 67 69 CSS_UNICODE_RANGE = 102, -
trunk/Source/WebCore/css/MediaQueryEvaluator.cpp
r259387 r259703 900 900 if (!document.documentElement()) 901 901 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); 903 905 } 904 906 -
trunk/Source/WebCore/css/parser/CSSParserToken.cpp
r254514 r259703 84 84 return CSSUnitType::CSS_IN; 85 85 break; 86 case 'l': 87 if (toASCIILower(data[1]) == 'h') 88 return CSSUnitType::CSS_LHS; 89 break; 86 90 case 'm': 87 91 switch (toASCIILower(data[1])) { … … 139 143 if (toASCIILower(data[2]) == 'm') 140 144 return CSSUnitType::CSS_REMS; 145 break; 146 case 'l': 147 if (toASCIILower(data[2]) == 'h') 148 return CSSUnitType::CSS_RLHS; 141 149 break; 142 150 } -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r258392 r259703 254 254 case CSSUnitType::CSS_EMS: 255 255 case CSSUnitType::CSS_REMS: 256 case CSSUnitType::CSS_LHS: 257 case CSSUnitType::CSS_RLHS: 256 258 case CSSUnitType::CSS_CHS: 257 259 case CSSUnitType::CSS_EXS: -
trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp
r252828 r259703 52 52 auto& style = renderer->style(); 53 53 54 CSSToLengthConversionData conversionData(&style, &style, renderer); 55 54 CSSToLengthConversionData conversionData(&style, &style, renderer->parentStyle(), renderer); 56 55 // Because we evaluate "sizes" at parse time (before style has been resolved), the font metrics used for these specific units 57 56 // are not available. The font selector's internal consistency isn't guaranteed just yet, so we can just temporarily clear … … 66 65 return result; 67 66 } 68 69 67 return clampTo<float>(CSSPrimitiveValue::computeNonCalcLengthDouble(conversionData, type, value)); 70 68 } … … 160 158 return 0; 161 159 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)); 163 161 } 164 162 -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp
r257839 r259703 122 122 // Set "flex-basis: 1em". Note that CSSPrimitiveValue::computeLengthInt() only needs the element's 123 123 // 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. 125 125 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 }); 127 127 newStyle->setFlexBasis(Length { pixels, Fixed }); 128 128 } -
trunk/Source/WebCore/rendering/RenderElement.h
r252968 r259703 44 44 45 45 const RenderStyle& style() const { return m_style; } 46 const RenderStyle* parentStyle() const { return !m_parent ? nullptr : &m_parent->style(); } 46 47 const RenderStyle& firstLineStyle() const; 47 48 -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r259435 r259703 564 564 Document& document = element.document(); 565 565 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())); 567 568 style.setPaddingBox(LengthBox(0, pixels, 0, pixels)); 568 569 } … … 1024 1025 // Set padding: 0 1.0em; on buttons. 1025 1026 // 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. 1028 1029 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)); 1030 1031 style.setPaddingBox(LengthBox(0, pixels, 0, pixels)); 1031 1032 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r259585 r259703 1777 1777 int RenderStyle::computedLineHeight() const 1778 1778 { 1779 const Length& lh = lineHeight(); 1780 1779 return computeLineHeight(lineHeight()); 1780 } 1781 1782 int RenderStyle::computeLineHeight(const Length& lineHeightLength) const 1783 { 1781 1784 // Negative value means the line height is not set. Use the font's built-in spacing. 1782 if (l h.isNegative())1785 if (lineHeightLength.isNegative()) 1783 1786 return fontMetrics().lineSpacing(); 1784 1787 1785 if (l h.isPercentOrCalculated())1786 return minimumValueForLength(l h, computedFontPixelSize());1787 1788 return clampTo<int>(l h.value());1788 if (lineHeightLength.isPercentOrCalculated()) 1789 return minimumValueForLength(lineHeightLength, computedFontPixelSize()); 1790 1791 return clampTo<int>(lineHeightLength.value()); 1789 1792 } 1790 1793 -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r259585 r259703 392 392 WEBCORE_EXPORT const Length& lineHeight() const; 393 393 WEBCORE_EXPORT int computedLineHeight() const; 394 int computeLineHeight(const Length&) const; 394 395 395 396 WhiteSpace whiteSpace() const { return static_cast<WhiteSpace>(m_inheritedFlags.whiteSpace); } … … 1509 1510 static short initialWidows() { return 2; } 1510 1511 static short initialOrphans() { return 2; } 1512 // Returning -100% percent here means the line-height is not set. 1511 1513 static Length initialLineHeight() { return Length(-100.0f, Percent); } 1512 1514 static TextAlignMode initialTextAlign() { return TextAlignMode::Start; } -
trunk/Source/WebCore/style/StyleBuilderConverter.h
r258148 r259703 1168 1168 } 1169 1169 1170 inline CSSToLengthConversionData BuilderConverter::csstoLengthConversionDataWithTextZoomFactor(BuilderState& builderState)1170 inline float zoomWithTextZoomFactor(BuilderState& builderState) 1171 1171 { 1172 1172 if (auto* frame = builderState.document().frame()) { 1173 1173 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 1179 inline 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); 1177 1186 } 1178 1187 … … 1512 1521 1513 1522 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); 1515 1525 if (multiplier != 1.f) 1516 1526 length = Length(length.value() * multiplier, Fixed); -
trunk/Source/WebCore/style/StyleBuilderCustom.h
r259532 r259703 1623 1623 fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength())); 1624 1624 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)); 1626 1626 if (primitiveValue.isViewportPercentageLength()) 1627 1627 builderState.style().setHasViewportUnits(); … … 1630 1630 else if (primitiveValue.isCalculatedPercentageWithLength()) { 1631 1631 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 }; 1633 1633 size = primitiveValue.cssCalcValue()->createCalculationValue(parentConversionData)->evaluate(parentSize); 1634 1634 } else -
trunk/Source/WebCore/style/StyleBuilderState.cpp
r259585 r259703 61 61 , m_style(style) 62 62 , m_context(WTFMove(context)) 63 , m_cssToLengthConversionData(&style, rootElementStyle(), document().renderView())63 , m_cssToLengthConversionData(&style, rootElementStyle(), &parentStyle(), document().renderView()) 64 64 { 65 65 }
Note: See TracChangeset
for help on using the changeset viewer.