Changeset 219665 in webkit
- Timestamp:
- Jul 19, 2017 4:38:06 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r219663 r219665 1 2017-07-19 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Setting the minimum font size preference doesn’t affect absolute line-height values, so lines overlap 4 https://bugs.webkit.org/show_bug.cgi?id=174406 5 <rdar://problem/10139227> 6 7 Reviewed by Simon Fraser. 8 9 * fast/text/line-height-minimumFontSize-autosize-expected.text: Added. 10 * fast/text/line-height-minimumFontSize-autosize.html: Added. 11 * fast/text/line-height-minimumFontSize-expected.txt: Added. 12 * fast/text/line-height-minimumFontSize-text-zoom-expected.html: Added. 13 * fast/text/line-height-minimumFontSize-text-zoom.html: Added. 14 * fast/text/line-height-minimumFontSize-visual-expected.html: Added. 15 * fast/text/line-height-minimumFontSize-visual.html: Added. 16 * fast/text/line-height-minimumFontSize-zoom-expected.html: Added. 17 * fast/text/line-height-minimumFontSize-zoom.html: Added. 18 * fast/text/line-height-minimumFontSize.html: Added. 19 20 2017-07-18 Myles C. Maxfield <mmaxfield@apple.com> 21 22 Setting the minimum font size preference doesn’t affect absolute line-height values, so lines overlap 23 https://bugs.webkit.org/show_bug.cgi?id=174406 24 <rdar://problem/10139227> 25 26 Reviewed by Simon Fraser. 27 28 * fast/text/line-height-minimumFontSize-autosize-expected.text: Added. 29 * fast/text/line-height-minimumFontSize-autosize.html: Added. 30 * fast/text/line-height-minimumFontSize-expected.txt: Added. 31 * fast/text/line-height-minimumFontSize-text-zoom-expected.html: Added. 32 * fast/text/line-height-minimumFontSize-text-zoom.html: Added. 33 * fast/text/line-height-minimumFontSize-visual-expected.html: Added. 34 * fast/text/line-height-minimumFontSize-visual.html: Added. 35 * fast/text/line-height-minimumFontSize-zoom-expected.html: Added. 36 * fast/text/line-height-minimumFontSize-zoom.html: Added. 37 * fast/text/line-height-minimumFontSize.html: Added. 38 1 39 2017-07-19 Chris Dumez <cdumez@apple.com> 2 40 -
trunk/Source/WebCore/ChangeLog
r219663 r219665 1 2017-07-19 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Setting the minimum font size preference doesn’t affect absolute line-height values, so lines overlap 4 https://bugs.webkit.org/show_bug.cgi?id=174406 5 6 Reviewed by Simon Fraser. 7 <rdar://problem/10139227> 8 9 Reviewed by NOBODY. 10 11 When the minimumFontSize API preference is set, we will increase the font size without increasing 12 the line height. If the content specifies line-height as an absolute value, there can be two 13 unfortunate results: 14 15 - Adjacent lines in a paragraph can overlap 16 - If the paragraph (or containin block or whatever) uses overflow: hidden, the first and last lines 17 can be cut off and potentially indecipherable. 18 19 Instead, we should use the minimum font size preference as a signal that we should increase the 20 line-height as well as the font-size. Eventually, we will want to increase it by an amount 21 proportional to the increase in font-size (which can be due to minimumFontSize, minimumLogicalFontSize, 22 text autosizing, etc.). However, because minimumLogicalFontSize is on by default, this would cause 23 a behavior change on many webpages which use small text, so such a change would be too risky right now. 24 Instead, we can pretend that minimumFontSize is the only cause that text increases, and use this as the 25 only signal to boost the corresponding line-height. 26 27 Tests: fast/text/line-height-minimumFontSize-text-zoom.html 28 fast/text/line-height-minimumFontSize-visual.html 29 fast/text/line-height-minimumFontSize-zoom.html 30 fast/text/line-height-minimumFontSize.html 31 fast/text/line-height-minimumFontSize-autosize.html 32 33 * css/StyleBuilderCustom.h: 34 (WebCore::computeBaseSpecifiedFontSize): 35 (WebCore::computeLineHeightMultiplierDueToFontSize): 36 (WebCore::StyleBuilderCustom::applyValueLineHeight): 37 (WebCore::StyleBuilderCustom::applyValueFill): 38 (WebCore::StyleBuilderCustom::applyValueStroke): 39 (WebCore::StyleBuilderCustom::applyValueContent): 40 * rendering/TextAutoSizing.cpp: 41 42 2017-07-18 Myles C. Maxfield <mmaxfield@apple.com> 43 44 Setting the minimum font size preference doesn’t affect absolute line-height values, so lines overlap 45 https://bugs.webkit.org/show_bug.cgi?id=174406 46 <rdar://problem/10139227> 47 48 Reviewed by Simon Fraser. 49 50 When the minimumFontSize API preference is set, we will increase the font size without increasing 51 the line height. If the content specifies line-height as an absolute value, there can be two 52 unfortunate results: 53 54 - Adjacent lines in a paragraph can overlap 55 - If the paragraph (or containin block or whatever) uses overflow: hidden, the first and last lines 56 can be cut off and potentially indecipherable. 57 58 Instead, we should use the minimum font size preference as a signal that we should increase the 59 line-height as well as the font-size. Eventually, we will want to increase it by an amount 60 proportional to the increase in font-size (which can be due to minimumFontSize, minimumLogicalFontSize, 61 text autosizing, etc.). However, because minimumLogicalFontSize is on by default, this would cause 62 a behavior change on many webpages which use small text, so such a change would be too risky right now. 63 Instead, we can pretend that minimumFontSize is the only cause that text increases, and use this as the 64 only signal to boost the corresponding line-height. 65 66 Tests: fast/text/line-height-minimumFontSize-text-zoom.html 67 fast/text/line-height-minimumFontSize-visual.html 68 fast/text/line-height-minimumFontSize-zoom.html 69 fast/text/line-height-minimumFontSize.html 70 fast/text/line-height-minimumFontSize-autosize.html 71 72 * css/StyleBuilderCustom.h: 73 (WebCore::computeBaseSpecifiedFontSize): 74 (WebCore::computeLineHeightMultiplierDueToFontSize): 75 (WebCore::StyleBuilderCustom::applyValueLineHeight): 76 (WebCore::StyleBuilderCustom::applyValueFill): 77 (WebCore::StyleBuilderCustom::applyValueStroke): 78 (WebCore::StyleBuilderCustom::applyValueContent): 79 * rendering/TextAutoSizing.cpp: 80 1 81 2017-07-19 Chris Dumez <cdumez@apple.com> 2 82 -
trunk/Source/WebCore/css/StyleBuilderCustom.h
r219656 r219665 651 651 } 652 652 653 static inline float computeBaseSpecifiedFontSize(const Document& document, const RenderStyle& style, bool percentageAutosizingEnabled) 654 { 655 float result = style.specifiedFontSize(); 656 auto* frame = document.frame(); 657 if (frame && style.textZoom() != TextZoomReset) 658 result *= frame->textZoomFactor(); 659 result *= style.effectiveZoom(); 660 if (percentageAutosizingEnabled) 661 result *= style.textSizeAdjust().multiplier(); 662 return result; 663 } 664 665 static inline float computeLineHeightMultiplierDueToFontSize(const Document& document, const RenderStyle& style, const CSSPrimitiveValue& value) 666 { 667 bool percentageAutosizingEnabled = document.settings().textAutosizingEnabled() && style.textSizeAdjust().isPercentage(); 668 669 if (value.isLength()) { 670 auto minimumFontSize = document.settings().minimumFontSize(); 671 if (minimumFontSize > 0) { 672 auto specifiedFontSize = computeBaseSpecifiedFontSize(document, style, percentageAutosizingEnabled); 673 if (specifiedFontSize < minimumFontSize) { 674 // FIXME: There are two settings which are relevant here: minimum font size, and minimum logical font size (as 675 // well as things like the zoom property, text zoom on the page, and text autosizing). The minimum logical font 676 // size is nonzero by default, and already incorporated into the computed font size, so if we just use the ratio 677 // of the computed : specified font size, it will be > 1 in the cases where the minimum logical font size kicks 678 // in. In general, this is the right thing to do, however, this kind of blanket change is too risky to perform 679 // right now. https://bugs.webkit.org/show_bug.cgi?id=174570 tracks turning this on. For now, we can just pretend 680 // that the minimum font size is the only thing affecting the computed font size. 681 682 // This calculation matches the line-height computed size calculation in 683 // TextAutoSizingValue::adjustTextNodeSizes(). 684 auto scaleChange = minimumFontSize / specifiedFontSize; 685 return scaleChange; 686 } 687 } 688 } 689 690 if (percentageAutosizingEnabled) 691 return style.textSizeAdjust().multiplier(); 692 return 1; 693 } 694 653 695 inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value) 654 696 { 655 float multiplier = styleResolver.style()->textSizeAdjust().isPercentage() ? styleResolver.style()->textSizeAdjust().multiplier() : 1.f; 656 std::optional<Length> lineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, multiplier); 697 std::optional<Length> lineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, 1); 657 698 if (!lineHeight) 658 699 return; 659 700 660 styleResolver.style()->setLineHeight(Length { lineHeight.value() }); 701 Length computedLineHeight; 702 if (lineHeight.value().isNegative()) 703 computedLineHeight = lineHeight.value(); 704 else { 705 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); 706 auto multiplier = computeLineHeightMultiplierDueToFontSize(styleResolver.document(), *styleResolver.style(), primitiveValue); 707 if (multiplier == 1) 708 computedLineHeight = lineHeight.value(); 709 else { 710 std::optional<Length> lineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, multiplier); 711 ASSERT(static_cast<bool>(lineHeight)); 712 computedLineHeight = lineHeight.value(); 713 } 714 } 715 716 styleResolver.style()->setLineHeight(WTFMove(computedLineHeight)); 661 717 styleResolver.style()->setSpecifiedLineHeight(WTFMove(lineHeight.value())); 662 718 } … … 734 790 styleResolver.style()->setHasExplicitlySetWritingMode(true); 735 791 } 736 792 737 793 inline void StyleBuilderCustom::applyValueWebkitTextOrientation(StyleResolver& styleResolver, CSSValue& value) 738 794 { … … 1211 1267 localValue = downcast<CSSPrimitiveValue>(list.item(1)); 1212 1268 } 1213 1269 1214 1270 if (!localValue) 1215 1271 return; 1216 1272 1217 1273 Color color; 1218 1274 auto paintType = SVG_PAINTTYPE_RGBCOLOR; … … 1255 1311 localValue = downcast<CSSPrimitiveValue>(list.item(1)); 1256 1312 } 1257 1313 1258 1314 if (!localValue) 1259 1315 return; 1260 1316 1261 1317 Color color; 1262 1318 auto paintType = SVG_PAINTTYPE_RGBCOLOR; … … 1353 1409 return; 1354 1410 } 1355 1411 1356 1412 bool didSet = false; 1357 1413 for (auto& item : downcast<CSSValueList>(value)) { -
trunk/Source/WebCore/rendering/TextAutoSizing.cpp
r219656 r219665 143 143 specifiedLineHeight = lineHeightLength.value(); 144 144 145 // This calculation matches the line-height computed size calculation in StyleBuilderCustom::applyValueLineHeight(). 145 146 int lineHeight = specifiedLineHeight * scaleChange; 146 147 if (lineHeightLength.isFixed() && lineHeightLength.value() == lineHeight)
Note: See TracChangeset
for help on using the changeset viewer.