Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: LayoutTests/svg/text/text-rect-precision.html

Issue 1034763002: Fix test tolerance for fixed-point line layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Fix TextExpectations Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/svg/text/text-rect-precision.html
diff --git a/LayoutTests/svg/text/text-rect-precision.html b/LayoutTests/svg/text/text-rect-precision.html
index b7587cd46b15cdfbedb58379290b59580c7e6b20..f05043d0d2082748b24a5799c688aab6eed4b2d8 100644
--- a/LayoutTests/svg/text/text-rect-precision.html
+++ b/LayoutTests/svg/text/text-rect-precision.html
@@ -15,6 +15,15 @@
var hasSubpixelPrecision = false;
+ function subpixelTolerance(testElement)
+ {
+ // Due to fixed-point rounding, each single-character measurement may differ by up to
+ // one LayoutUnit (i.e., 0.16 pixel) from the same character's measurement in the full
+ // string.
+ var str = testElement.firstChild.nodeValue;
+ return str.length * 0.16;
+ }
+
function measureText(testElement)
{
var measureElement = document.getElementById('measure');
@@ -40,7 +49,7 @@
var el = document.getElementById('test');
var elementWidth = el.getBoundingClientRect().width;
var textWidth = measureText(el);
- var tolerance = hasSubpixelPrecision ? 0.1 : 2; // enclosing may expand up to one pixel in each direction.
+ var tolerance = hasSubpixelPrecision ? subpixelTolerance(el) : 2; // enclosing may expand up to one pixel in each direction.
if (Math.abs(elementWidth - textWidth) <= tolerance)
testPassed('Width of text element is the sum of the width of all characters.');
else
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698