Title: [258282] trunk
- Revision
- 258282
- Author
- [email protected]
- Date
- 2020-03-11 14:00:17 -0700 (Wed, 11 Mar 2020)
Log Message
icloud.com Notes text in titles and headings is distorted
https://bugs.webkit.org/show_bug.cgi?id=208908
<rdar://problem/58874371>
Reviewed by Zalan Bujtas.
Source/WebCore:
icloud.com Notes determines if a font has finished loading by measuring it repeatedly.
Depending on the state of the page, we may slice the text differently in different
circumstances. These slices are all supposed to sum together equivalently, but
floating point precision may cause the results to be slightly off.
WidthIterator::applyFontTransforms() was summing a large list of numbers, and then
subtracting the same large list of numbers. A more robust design would be to sum
it twice, and then subtract the two sums.
Test: fast/text/shaping-width-precision.html
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::applyFontTransforms):
LayoutTests:
* fast/text/shaping-width-precision-expected.txt: Added.
* fast/text/shaping-width-precision.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (258281 => 258282)
--- trunk/LayoutTests/ChangeLog 2020-03-11 20:47:04 UTC (rev 258281)
+++ trunk/LayoutTests/ChangeLog 2020-03-11 21:00:17 UTC (rev 258282)
@@ -1,3 +1,14 @@
+2020-03-11 Myles C. Maxfield <[email protected]>
+
+ icloud.com Notes text in titles and headings is distorted
+ https://bugs.webkit.org/show_bug.cgi?id=208908
+ <rdar://problem/58874371>
+
+ Reviewed by Zalan Bujtas.
+
+ * fast/text/shaping-width-precision-expected.txt: Added.
+ * fast/text/shaping-width-precision.html: Added.
+
2020-03-11 Diego Pino Garcia <[email protected]>
[WPE] Gardening, update TestExpectations
Added: trunk/LayoutTests/fast/text/shaping-width-precision-expected.txt (0 => 258282)
--- trunk/LayoutTests/fast/text/shaping-width-precision-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/shaping-width-precision-expected.txt 2020-03-11 21:00:17 UTC (rev 258282)
@@ -0,0 +1,10 @@
+This test makes sure that width calculations when shaping in the fast codepath have enough precision.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS beforeWidth is afterWidth
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/text/shaping-width-precision.html (0 => 258282)
--- trunk/LayoutTests/fast/text/shaping-width-precision.html (rev 0)
+++ trunk/LayoutTests/fast/text/shaping-width-precision.html 2020-03-11 21:00:17 UTC (rev 258282)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+</body>
+<script>
+description("This test makes sure that width calculations when shaping in the fast codepath have enough precision.");
+
+const canvas = document.createElement('canvas');
+const ctx = canvas.getContext('2d');
+
+const font1 = '200 72px myFunFont, ct_noexist, sans-serif';
+const font2 = '200 72px ct_noexist, sans-serif';
+
+const testString = '1234567abcdefg!@#$%^&*()_+';
+
+ctx.font = font1;
+const beforeWidth = ctx.measureText(testString).width;
+ctx.font = font2;
+ctx.measureText(testString).width;
+
+const tag = document.createElement('style');
+tag.textContent = `
+ @font-face {
+ font-family: "myFunFont";
+ src: url("/some/path/to/myFunFont.woff") format("woff");
+ }
+`;
+tag.type = 'text/css';
+document.head.appendChild(tag);
+
+ctx.font = font1;
+const afterWidth = ctx.measureText(testString).width;
+
+shouldBe("beforeWidth", "afterWidth");
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (258281 => 258282)
--- trunk/Source/WebCore/ChangeLog 2020-03-11 20:47:04 UTC (rev 258281)
+++ trunk/Source/WebCore/ChangeLog 2020-03-11 21:00:17 UTC (rev 258282)
@@ -1,3 +1,25 @@
+2020-03-11 Myles C. Maxfield <[email protected]>
+
+ icloud.com Notes text in titles and headings is distorted
+ https://bugs.webkit.org/show_bug.cgi?id=208908
+ <rdar://problem/58874371>
+
+ Reviewed by Zalan Bujtas.
+
+ icloud.com Notes determines if a font has finished loading by measuring it repeatedly.
+ Depending on the state of the page, we may slice the text differently in different
+ circumstances. These slices are all supposed to sum together equivalently, but
+ floating point precision may cause the results to be slightly off.
+
+ WidthIterator::applyFontTransforms() was summing a large list of numbers, and then
+ subtracting the same large list of numbers. A more robust design would be to sum
+ it twice, and then subtract the two sums.
+
+ Test: fast/text/shaping-width-precision.html
+
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::applyFontTransforms):
+
2020-03-11 Zalan Bujtas <[email protected]>
SVG filter triggers unstable layout.
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (258281 => 258282)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-03-11 20:47:04 UTC (rev 258281)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-03-11 21:00:17 UTC (rev 258282)
@@ -105,9 +105,9 @@
}
GlyphBufferAdvance* advances = glyphBuffer->advances(0);
- float widthDifference = 0;
+ float beforeWidth = 0;
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i)
- widthDifference -= advances[i].width();
+ beforeWidth += advances[i].width();
ASSERT(lastGlyphCount <= glyphBufferSize);
if (!ltr)
@@ -137,11 +137,12 @@
}
charactersTreatedAsSpace.clear();
+ float afterWidth = 0;
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i)
- widthDifference += advances[i].width();
+ afterWidth += advances[i].width();
lastGlyphCount = glyphBufferSize;
- return widthDifference;
+ return afterWidth - beforeWidth;
}
static inline std::pair<bool, bool> expansionLocation(bool ideograph, bool treatAsSpace, bool ltr, bool isAfterExpansion, bool forbidLeadingExpansion, bool forbidTrailingExpansion, bool forceLeadingExpansion, bool forceTrailingExpansion)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes