diff options
author | japhet@chromium.org <japhet@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2009-10-14 16:26:38 +0000 |
---|---|---|
committer | japhet@chromium.org <japhet@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2009-10-14 16:26:38 +0000 |
commit | 7dc2d1314d551fd8d548b6cad7106ce3f76dcc37 (patch) | |
tree | 8ed9583264a9d2fa1ce25131692649242fdbb25c /third_party/WebKit/LayoutTests/fast/css/line-height-rounding.html | |
parent | 317f833e7cb173d5510901f6ffe53b91e28c79ef (diff) | |
download | chromium_src-7dc2d1314d551fd8d548b6cad7106ce3f76dcc37.zip chromium_src-7dc2d1314d551fd8d548b6cad7106ce3f76dcc37.tar.gz chromium_src-7dc2d1314d551fd8d548b6cad7106ce3f76dcc37.tar.bz2 |
2009-10-14 Victor Wang <victorw@chromium.org>
Reviewed by David Hyatt.
Round non-integer line height values.
Change webkit to rounding non-integer line height values
instead of truncating them. This fixes a layout test
failure on Windows and matches the calculation in IE and Firefox.
https://bugs.webkit.org/show_bug.cgi?id=24434
git-svn-id: svn://svn.chromium.org/blink/trunk@49567 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/css/line-height-rounding.html')
-rw-r--r-- | third_party/WebKit/LayoutTests/fast/css/line-height-rounding.html | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/css/line-height-rounding.html b/third_party/WebKit/LayoutTests/fast/css/line-height-rounding.html new file mode 100644 index 0000000..ce54057a --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/css/line-height-rounding.html @@ -0,0 +1,49 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<style type="text/css"> +</style> + +<script> +if (window.layoutTestController) + layoutTestController.dumpAsText(); + +function checkLineHeight(fontSize, lineHeightPercent, expectedLineHeight) { + var testElement = document.getElementById('testElement'); + testElement.style.fontSize = fontSize; + testElement.style.lineHeight = lineHeightPercent; + + var style = document.defaultView.getComputedStyle(testElement, null); + var actualLineHeight = style.getPropertyValue('line-height'); + if (actualLineHeight != expectedLineHeight) { + return "FAIL: font size: " + fontSize + + "; line height percent: " + lineHeightPercent + + "; expected line height: " + expectedLineHeight + + "; actual line height: " + actualLineHeight + "<br>"; + } + + return ""; +} + +function test() { + var message = checkLineHeight("10px", 1.05, '11px'); // 10*1.05 = 10.50 + message += checkLineHeight("10px", 1.049, '10px'); // 10*1.049 = 10.49 + message += checkLineHeight("10px", 0, '0px'); // 10*0 = 0 + message += checkLineHeight("10px", 1, '10px'); // 10*1.00 = 10.00 + + if (message != "") + document.getElementById("results").innerHTML = "Test failed:<br>" + message; + else + document.getElementById("results").innerHTML = "Test passed."; + + document.getElementById('testElement').innerHTML = ""; +} + +</script> +</head> +<body onload="test()"> + <p>This tests non-integer line height is rounded to the nearest integer.</p> + <p id='testElement'>test data</p> + <div id='results'></div> +</body> +</html> |