Changeset 276187 in webkit
- Timestamp:
- Apr 16, 2021, 6:08:45 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt (modified) (1 diff)
-
LayoutTests/css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSToLengthConversionData.cpp (modified) (4 diffs)
-
Source/WebCore/css/CSSToLengthConversionData.h (modified) (3 diffs)
-
Source/WebCore/style/StyleBuilderCustom.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r276186 r276187 1 2021-04-16 Darin Adler <darin@apple.com> 2 3 font-size with viewport units in calc() doesn't change when viewport resizes 4 https://bugs.webkit.org/show_bug.cgi?id=224614 5 6 Reviewed by Zalan Bujtas. 7 8 * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: 9 * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: 10 Added tests that involve calc, and broke rules up into multiple elements so that side 11 effects from one style won't give us false negatives. This now has a subtest that was 12 failing without the fix in this patch. 13 1 14 2021-04-16 Ian Gilbert <iang@apple.com> 2 15 -
trunk/LayoutTests/css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt
r198943 r276187 9 9 PASS innerWidth is 800 10 10 PASS innerHeight is 600 11 PASS getComputedStyle(test).fontSize is "30px"12 11 PASS getComputedStyle(test).width is "400px" 12 PASS getComputedStyle(testfontsize).fontSize is "30px" 13 PASS getComputedStyle(testcalc).width is "800px" 14 PASS getComputedStyle(testfontsizecalc).fontSize is "60px" 13 15 PASS getComputedStyle(testpseudo, ':after').marginLeft is "120px" 14 16 PASS getComputedStyle(testpseudo, ':after').paddingRight is "200px" 17 PASS getComputedStyle(testpseudocalc, ':after').marginLeft is "240px" 18 PASS getComputedStyle(testpseudocalc, ':after').paddingRight is "400px" 15 19 PASS innerWidth is 900 16 20 PASS innerHeight is 600 17 PASS getComputedStyle(test).fontSize is "30px"18 21 PASS getComputedStyle(test).width is "450px" 22 PASS getComputedStyle(testfontsize).fontSize is "30px" 23 PASS getComputedStyle(testcalc).width is "900px" 24 PASS getComputedStyle(testfontsizecalc).fontSize is "60px" 19 25 PASS getComputedStyle(testpseudo, ':after').marginLeft is "120px" 20 26 PASS getComputedStyle(testpseudo, ':after').paddingRight is "225px" 27 PASS getComputedStyle(testpseudocalc, ':after').marginLeft is "240px" 28 PASS getComputedStyle(testpseudocalc, ':after').paddingRight is "450px" 21 29 PASS innerWidth is 900 22 30 PASS innerHeight is 640 23 PASS getComputedStyle(test).fontSize is "32px"24 31 PASS getComputedStyle(test).width is "450px" 32 PASS getComputedStyle(testfontsize).fontSize is "32px" 33 PASS getComputedStyle(testcalc).width is "900px" 34 PASS getComputedStyle(testfontsizecalc).fontSize is "64px" 25 35 PASS getComputedStyle(testpseudo, ':after').marginLeft is "128px" 26 36 PASS getComputedStyle(testpseudo, ':after').paddingRight is "225px" 37 PASS getComputedStyle(testpseudocalc, ':after').marginLeft is "256px" 38 PASS getComputedStyle(testpseudocalc, ':after').paddingRight is "450px" 27 39 PASS innerWidth is 500 28 40 PASS innerHeight is 640 29 PASS getComputedStyle(test).fontSize is "32px"30 41 PASS getComputedStyle(test).width is "250px" 42 PASS getComputedStyle(testfontsize).fontSize is "32px" 43 PASS getComputedStyle(testcalc).width is "500px" 44 PASS getComputedStyle(testfontsizecalc).fontSize is "64px" 31 45 PASS getComputedStyle(testpseudo, ':after').marginLeft is "100px" 32 46 PASS getComputedStyle(testpseudo, ':after').paddingRight is "160px" 47 PASS getComputedStyle(testpseudocalc, ':after').marginLeft is "200px" 48 PASS getComputedStyle(testpseudocalc, ':after').paddingRight is "320px" 33 49 PASS innerWidth is 800 34 50 PASS innerHeight is 600 35 PASS getComputedStyle(test).fontSize is "30px"36 51 PASS getComputedStyle(test).width is "400px" 52 PASS getComputedStyle(testfontsize).fontSize is "30px" 53 PASS getComputedStyle(testcalc).width is "800px" 54 PASS getComputedStyle(testfontsizecalc).fontSize is "60px" 37 55 PASS getComputedStyle(testpseudo, ':after').marginLeft is "120px" 38 56 PASS getComputedStyle(testpseudo, ':after').paddingRight is "200px" 57 PASS getComputedStyle(testpseudocalc, ':after').marginLeft is "240px" 58 PASS getComputedStyle(testpseudocalc, ':after').paddingRight is "400px" 39 59 -
trunk/LayoutTests/css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html
r169505 r276187 2 2 <style> 3 3 #test { 4 width: 50vw; 5 } 6 #testfontsize { 4 7 font-size: 5vh; 5 width: 50vw; 8 } 9 #testcalc { 10 width: calc(50vw * 2); 11 } 12 #testfontsizecalc { 13 font-size: calc(5vh * 2); 6 14 } 7 15 #testpseudo:after { … … 10 18 content: ''; 11 19 } 20 #testpseudocalc:after { 21 margin-left: calc(20vmin * 2); 22 padding-right: calc(25vmax * 2); 23 content: ''; 24 } 12 25 </style> 13 26 <body> 14 27 <div id="test"></div> 28 <div id="testfontsize"></div> 29 <div id="testcalc"></div> 30 <div id="testfontsizecalc"></div> 15 31 <div id="testpseudo"></div> 32 <div id="testpseudocalc"></div> 16 33 </body> 17 34 <script src="../../resources/js-test-pre.js"></script> … … 22 39 var min = Math.min(innerWidth, innerHeight); 23 40 var max = Math.max(innerWidth, innerHeight); 24 shouldBeEqualToString("getComputedStyle(test).fontSize", innerHeight / 20 + "px");25 41 shouldBeEqualToString("getComputedStyle(test).width", innerWidth / 2 + "px"); 42 shouldBeEqualToString("getComputedStyle(testfontsize).fontSize", innerHeight / 20 + "px"); 43 shouldBeEqualToString("getComputedStyle(testcalc).width", innerWidth + "px"); 44 shouldBeEqualToString("getComputedStyle(testfontsizecalc).fontSize", innerHeight / 10 + "px"); 26 45 shouldBeEqualToString("getComputedStyle(testpseudo, ':after').marginLeft", min / 5 + "px"); 27 46 shouldBeEqualToString("getComputedStyle(testpseudo, ':after').paddingRight", max / 4 + "px"); 47 shouldBeEqualToString("getComputedStyle(testpseudocalc, ':after').marginLeft", (min * 2) / 5 + "px"); 48 shouldBeEqualToString("getComputedStyle(testpseudocalc, ':after').paddingRight", max / 2 + "px"); 28 49 }); 29 50 </script> -
trunk/Source/WebCore/ChangeLog
r276186 r276187 1 2021-04-16 Darin Adler <darin@apple.com> 2 3 font-size with viewport units in calc() doesn't change when viewport resizes 4 https://bugs.webkit.org/show_bug.cgi?id=224614 5 6 Reviewed by Zalan Bujtas. 7 8 * css/CSSToLengthConversionData.cpp: 9 (WebCore::CSSToLengthConversionData::zoom const): Updated since m_zoom is now optional. 10 We use effectiveZoom when m_zoom is not specified, which is the same semantic that was 11 implemented before with a separate boolean. 12 (WebCore::CSSToLengthConversionData::viewportWidthFactor const): When calling the 13 setHasViewportUnits function as a side effect, use m_viewportDependencyDetectionStyle, 14 rather than always using m_style. This lets us handle the font-size case correctly. 15 Also removed the explicit computingFontSize check for the same reason. 16 (WebCore::CSSToLengthConversionData::viewportHeightFactor const): Ditto. 17 (WebCore::CSSToLengthConversionData::viewportMinFactor const): Ditto. 18 (WebCore::CSSToLengthConversionData::viewportMaxFactor const): Ditto. 19 20 * css/CSSToLengthConversionData.h: Added a new member, m_viewportDependencyDetectionStyle, 21 which defaults to the same value as m_style. Also changed m_zoom to use Optional instead 22 of a separate boolean and an ignored "must be 1.0" value. Initialized data members in 23 the modern way, allowing us to use the default constructor. 24 25 * style/StyleBuilderCustom.h: 26 (WebCore::Style::BuilderCustom::applyValueFontSize): Pass in the builder's style as the 27 viewportDependencyDetectionStyle. This does the same thing that the existing code to 28 call setHasViewportUnits did directly, but does it even for more complex cases involving 29 calc(). Also made the isLength and isCalculatedPercentageWithLength cases more similar 30 to each other and left a FIXME behind about taking that a bit further, but doing that 31 probably requires creating some more test cases. 32 1 33 2021-04-16 Ian Gilbert <iang@apple.com> 2 34 -
trunk/Source/WebCore/css/CSSToLengthConversionData.cpp
r259703 r276187 39 39 float CSSToLengthConversionData::zoom() const 40 40 { 41 if ( m_useEffectiveZoom)41 if (!m_zoom) 42 42 return m_style ? m_style->effectiveZoom() : 1; 43 return m_zoom;43 return *m_zoom; 44 44 } 45 45 46 46 double CSSToLengthConversionData::viewportWidthFactor() const 47 47 { 48 if (m_ style && !computingFontSize())49 const_cast<RenderStyle*>(m_style)->setHasViewportUnits();48 if (m_viewportDependencyDetectionStyle) 49 m_viewportDependencyDetectionStyle->setHasViewportUnits(); 50 50 51 51 if (!m_renderView) … … 57 57 double CSSToLengthConversionData::viewportHeightFactor() const 58 58 { 59 if (m_ style && !computingFontSize())60 const_cast<RenderStyle*>(m_style)->setHasViewportUnits();59 if (m_viewportDependencyDetectionStyle) 60 m_viewportDependencyDetectionStyle->setHasViewportUnits(); 61 61 62 62 if (!m_renderView) … … 68 68 double CSSToLengthConversionData::viewportMinFactor() const 69 69 { 70 if (m_ style && !computingFontSize())71 const_cast<RenderStyle*>(m_style)->setHasViewportUnits();70 if (m_viewportDependencyDetectionStyle) 71 m_viewportDependencyDetectionStyle->setHasViewportUnits(); 72 72 73 73 if (!m_renderView) … … 80 80 double CSSToLengthConversionData::viewportMaxFactor() const 81 81 { 82 if (m_ style && !computingFontSize())83 const_cast<RenderStyle*>(m_style)->setHasViewportUnits();82 if (m_viewportDependencyDetectionStyle) 83 m_viewportDependencyDetectionStyle->setHasViewportUnits(); 84 84 85 85 if (!m_renderView) -
trunk/Source/WebCore/css/CSSToLengthConversionData.h
r273964 r276187 42 42 class CSSToLengthConversionData { 43 43 public: 44 CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, float zoom, Optional<CSSPropertyID> propertyToCompute = WTF::nullopt )44 CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, float zoom, Optional<CSSPropertyID> propertyToCompute = WTF::nullopt, RenderStyle* viewportDependencyDetectionStyle = nullptr) 45 45 : m_style(style) 46 46 , m_rootStyle(rootStyle) 47 47 , m_parentStyle(parentStyle) 48 , m_viewportDependencyDetectionStyle(viewportDependencyDetectionStyle ? viewportDependencyDetectionStyle : const_cast<RenderStyle*>(style)) 48 49 , m_renderView(renderView) 49 50 , m_zoom(zoom) 50 , m_useEffectiveZoom(false)51 51 , m_propertyToCompute(propertyToCompute) 52 52 { … … 58 58 , m_rootStyle(rootStyle) 59 59 , m_parentStyle(parentStyle) 60 , m_viewportDependencyDetectionStyle(const_cast<RenderStyle*>(style)) 60 61 , m_renderView(renderView) 61 , m_zoom(1)62 , m_useEffectiveZoom(true)63 62 , m_propertyToCompute(propertyToCompute) 64 63 { 65 64 } 66 65 67 CSSToLengthConversionData() 68 : CSSToLengthConversionData(nullptr, nullptr, nullptr, nullptr) 69 { 70 } 66 CSSToLengthConversionData() = default; 71 67 72 68 const RenderStyle* style() const { return m_style; } … … 95 91 96 92 private: 97 const RenderStyle* m_style ;98 const RenderStyle* m_rootStyle ;99 const RenderStyle* m_parentStyle ;100 const RenderView* m_renderView;101 float m_zoom;102 bool m_useEffectiveZoom;93 const RenderStyle* m_style { nullptr }; 94 const RenderStyle* m_rootStyle { nullptr }; 95 const RenderStyle* m_parentStyle { nullptr }; 96 RenderStyle* m_viewportDependencyDetectionStyle { nullptr }; 97 const RenderView* m_renderView { nullptr }; 98 Optional<float> m_zoom; 103 99 Optional<CSSPropertyID> m_propertyToCompute; 104 100 }; -
trunk/Source/WebCore/style/StyleBuilderCustom.h
r275495 r276187 1832 1832 fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength())); 1833 1833 if (primitiveValue.isLength()) { 1834 size = primitiveValue.computeLength<float>(CSSToLengthConversionData(&builderState.parentStyle(), builderState.rootElementStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize)); 1835 if (primitiveValue.isViewportPercentageLength()) 1836 builderState.style().setHasViewportUnits(); 1834 CSSToLengthConversionData conversionData { &builderState.parentStyle(), builderState.rootElementStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize, &builderState.style() }; 1835 size = primitiveValue.computeLength<float>(conversionData); 1837 1836 } else if (primitiveValue.isPercentage()) 1838 1837 size = (primitiveValue.floatValue() * parentSize) / 100.0f; 1839 1838 else if (primitiveValue.isCalculatedPercentageWithLength()) { 1840 const auto& conversionData = builderState.cssToLengthConversionData();1841 CSSToLengthConversionData parentConversionData { &builderState.parentStyle(), conversionData.rootStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize};1842 size = primitiveValue.cssCalcValue()->createCalculationValue( parentConversionData)->evaluate(parentSize);1839 // FIXME: Why does this need a different root style than the isLength case above? 1840 CSSToLengthConversionData conversionData { &builderState.parentStyle(), builderState.cssToLengthConversionData().rootStyle(), &builderState.parentStyle(), builderState.document().renderView(), 1.0f, CSSPropertyFontSize, &builderState.style() }; 1841 size = primitiveValue.cssCalcValue()->createCalculationValue(conversionData)->evaluate(parentSize); 1843 1842 } else 1844 1843 return;
Note:
See TracChangeset
for help on using the changeset viewer.