Title: [222588] trunk
- Revision
- 222588
- Author
- [email protected]
- Date
- 2017-09-27 17:25:59 -0700 (Wed, 27 Sep 2017)
Log Message
Minimum font size may cause elements to have an infinite line-height
https://bugs.webkit.org/show_bug.cgi?id=177573
<rdar://problem/34573792>
Reviewed by Dan Bernstein.
Source/WebCore:
When minimum font size is specified, we were trying to preserve the ratio of specified font-size
and specified line-height in order to boost the computed font size proportionately to the font-size
boost. However, this doesn't work when the specified font-size is 0, because the ratio between
line-height and font-size is infinite.
The most straightforward solution is just to make small font-sizes opt out of the line-height
adjustment because the result would be too big.
Test: fast/text/line-height-minimumFontSize-text-small-font-size.html
* css/StyleBuilderCustom.h:
(WebCore::computeLineHeightMultiplierDueToFontSize):
(WebCore::StyleBuilderCustom::applyValueLineHeight):
LayoutTests:
* fast/text/line-height-minimumFontSize-text-small-font-size-expected.txt: Added.
* fast/text/line-height-minimumFontSize-text-small-font-size.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (222587 => 222588)
--- trunk/LayoutTests/ChangeLog 2017-09-28 00:07:12 UTC (rev 222587)
+++ trunk/LayoutTests/ChangeLog 2017-09-28 00:25:59 UTC (rev 222588)
@@ -1,3 +1,14 @@
+2017-09-27 Myles C. Maxfield <[email protected]>
+
+ Minimum font size may cause elements to have an infinite line-height
+ https://bugs.webkit.org/show_bug.cgi?id=177573
+ <rdar://problem/34573792>
+
+ Reviewed by Dan Bernstein.
+
+ * fast/text/line-height-minimumFontSize-text-small-font-size-expected.txt: Added.
+ * fast/text/line-height-minimumFontSize-text-small-font-size.html: Added.
+
2017-09-27 Matt Lewis <[email protected]>
Unreviewed, rolling out r222337.
Added: trunk/LayoutTests/fast/text/line-height-minimumFontSize-text-small-font-size-expected.txt (0 => 222588)
--- trunk/LayoutTests/fast/text/line-height-minimumFontSize-text-small-font-size-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/line-height-minimumFontSize-text-small-font-size-expected.txt 2017-09-28 00:25:59 UTC (rev 222588)
@@ -0,0 +1,5 @@
+PASS document.getElementById('target').offsetHeight < 100 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Hi
Added: trunk/LayoutTests/fast/text/line-height-minimumFontSize-text-small-font-size.html (0 => 222588)
--- trunk/LayoutTests/fast/text/line-height-minimumFontSize-text-small-font-size.html (rev 0)
+++ trunk/LayoutTests/fast/text/line-height-minimumFontSize-text-small-font-size.html 2017-09-28 00:25:59 UTC (rev 222588)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals) {
+ internals.settings.setMinimumFontSize(32);
+}
+</script>
+<script src=""
+</head>
+<body style="font-size: 16px;">
+<div id="target" style="font-size: 0px; line-height: 1rem;">Hi</div>
+<script>
+shouldBeTrue("document.getElementById('target').offsetHeight < 100");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (222587 => 222588)
--- trunk/Source/WebCore/ChangeLog 2017-09-28 00:07:12 UTC (rev 222587)
+++ trunk/Source/WebCore/ChangeLog 2017-09-28 00:25:59 UTC (rev 222588)
@@ -1,3 +1,25 @@
+2017-09-27 Myles C. Maxfield <[email protected]>
+
+ Minimum font size may cause elements to have an infinite line-height
+ https://bugs.webkit.org/show_bug.cgi?id=177573
+ <rdar://problem/34573792>
+
+ Reviewed by Dan Bernstein.
+
+ When minimum font size is specified, we were trying to preserve the ratio of specified font-size
+ and specified line-height in order to boost the computed font size proportionately to the font-size
+ boost. However, this doesn't work when the specified font-size is 0, because the ratio between
+ line-height and font-size is infinite.
+
+ The most straightforward solution is just to make small font-sizes opt out of the line-height
+ adjustment because the result would be too big.
+
+ Test: fast/text/line-height-minimumFontSize-text-small-font-size.html
+
+ * css/StyleBuilderCustom.h:
+ (WebCore::computeLineHeightMultiplierDueToFontSize):
+ (WebCore::StyleBuilderCustom::applyValueLineHeight):
+
2017-09-27 Alex Christensen <[email protected]>
Allow modern decoding of std::optional<T>
Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (222587 => 222588)
--- trunk/Source/WebCore/css/StyleBuilderCustom.h 2017-09-28 00:07:12 UTC (rev 222587)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h 2017-09-28 00:25:59 UTC (rev 222588)
@@ -670,7 +670,9 @@
auto minimumFontSize = document.settings().minimumFontSize();
if (minimumFontSize > 0) {
auto specifiedFontSize = computeBaseSpecifiedFontSize(document, style, percentageAutosizingEnabled);
- if (specifiedFontSize < minimumFontSize) {
+ // Small font sizes cause a preposterously large (near infinity) line-height. Add a fuzz-factor of 1px which opts out of
+ // boosted line-height.
+ if (specifiedFontSize < minimumFontSize && specifiedFontSize >= 1) {
// FIXME: There are two settings which are relevant here: minimum font size, and minimum logical font size (as
// well as things like the zoom property, text zoom on the page, and text autosizing). The minimum logical font
// size is nonzero by default, and already incorporated into the computed font size, so if we just use the ratio
@@ -706,11 +708,8 @@
auto multiplier = computeLineHeightMultiplierDueToFontSize(styleResolver.document(), *styleResolver.style(), primitiveValue);
if (multiplier == 1)
computedLineHeight = lineHeight.value();
- else {
- std::optional<Length> lineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, multiplier);
- ASSERT(static_cast<bool>(lineHeight));
- computedLineHeight = lineHeight.value();
- }
+ else
+ computedLineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, multiplier).value();
}
styleResolver.style()->setLineHeight(WTFMove(computedLineHeight));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes