Changeset 219646 in webkit
- Timestamp:
- Jul 18, 2017 8:54:38 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r219642 r219646 1 2017-07-18 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 1 20 2017-07-18 Ali Juma <ajuma@chromium.org> 2 21 -
trunk/Source/WebCore/ChangeLog
r219645 r219646 1 2017-07-18 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 When the minimumFontSize API preference is set, we will increase the font size without increasing 10 the line height. If the content specifies line-height as an absolute value, there can be two 11 unfortunate results: 12 13 - Adjacent lines in a paragraph can overlap 14 - If the paragraph (or containin block or whatever) uses overflow: hidden, the first and last lines 15 can be cut off and potentially indecipherable. 16 17 Instead, we should use the minimum font size preference as a signal that we should increase the 18 line-height as well as the font-size. Eventually, we will want to increase it by an amount 19 proportional to the increase in font-size (which can be due to minimumFontSize, minimumLogicalFontSize, 20 text autosizing, etc.). However, because minimumLogicalFontSize is on by default, this would cause 21 a behavior change on many webpages which use small text, so such a change would be too risky right now. 22 Instead, we can pretend that minimumFontSize is the only cause that text increases, and use this as the 23 only signal to boost the corresponding line-height. 24 25 Tests: fast/text/line-height-minimumFontSize-text-zoom.html 26 fast/text/line-height-minimumFontSize-visual.html 27 fast/text/line-height-minimumFontSize-zoom.html 28 fast/text/line-height-minimumFontSize.html 29 fast/text/line-height-minimumFontSize-autosize.html 30 31 * css/StyleBuilderCustom.h: 32 (WebCore::computeBaseSpecifiedFontSize): 33 (WebCore::computeLineHeightMultiplierDueToFontSize): 34 (WebCore::StyleBuilderCustom::applyValueLineHeight): 35 (WebCore::StyleBuilderCustom::applyValueFill): 36 (WebCore::StyleBuilderCustom::applyValueStroke): 37 (WebCore::StyleBuilderCustom::applyValueContent): 38 * rendering/TextAutoSizing.cpp: 39 1 40 2017-07-18 Zalan Bujtas <zalan@apple.com> 2 41 -
trunk/Source/WebCore/css/StyleBuilderCustom.h
r219237 r219646 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 std::optional<Length> lineHeightLength; 708 if (multiplier == 1) 709 lineHeightLength = lineHeight; 710 else 711 lineHeightLength = StyleBuilderConverter::convertLineHeight(styleResolver, value, multiplier); 712 ASSERT(static_cast<bool>(lineHeightLength)); 713 computedLineHeight = lineHeight.value(); 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
r217893 r219646 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.