Chromium Code Reviews| Index: LayoutTests/fast/exclusions/resources/subpixel-utils.js |
| diff --git a/LayoutTests/fast/exclusions/resources/subpixel-utils.js b/LayoutTests/fast/exclusions/resources/subpixel-utils.js |
| index 4965177949b6e62d46f7f6e08c6bd4af4daead3d..ae083b31622036f7192270a689c40c0b06ad21f4 100644 |
| --- a/LayoutTests/fast/exclusions/resources/subpixel-utils.js |
| +++ b/LayoutTests/fast/exclusions/resources/subpixel-utils.js |
| @@ -1,28 +1,26 @@ |
| var SubPixelLayout = (function() { |
| - var _subPixelLayout = null; |
| - function initSubPixelLayout() { |
| - var elem = document.createElement('div'); |
| - elem.style.setProperty('width', '4.5px'); |
| - document.body.appendChild(elem); |
| - var bounds = elem.getBoundingClientRect(); |
| - _subPixelLayout = (bounds.width != Math.floor(bounds.width)); |
| - document.body.removeChild(elem); |
| + var enabled = undefined; |
|
leviw_travelin_and_unemployed
2013/05/21 22:21:56
I understand you're doing this for consistency wit
|
| + |
| + function isEnabled() |
| + { |
| + if (enabled === undefined) { |
| + var elem = document.createElement('div'); |
| + elem.style.setProperty('width', '4.5px'); |
| + document.body.appendChild(elem); |
| + var bounds = elem.getBoundingClientRect(); |
| + enabled = (bounds.width != Math.floor(bounds.width)); |
| + document.body.removeChild(elem); |
| + } |
| + return enabled; |
| } |
| - document.addEventListener('DOMContentLoaded', initSubPixelLayout); |
| + |
| return { |
| - initSubPixelLayout: initSubPixelLayout, |
| - roundLineLeft: function(f) { |
| - if (!_subPixelLayout) |
| - return Math.floor(f); |
| - return Math.floor((Math.floor(f * 64) + 32) / 64); // see FractionLayoutUnit::round() |
| + isEnabled: isEnabled, |
| + snapToLayoutUnit: function(f) { |
| + return isEnabled() ? Math.floor(f * 64) / 64 : Math.floor(f); // as in LayoutUnit(f).toFloat() |
| }, |
| - roundLineRight: function(f) { |
| - if (!_subPixelLayout) |
| - return Math.floor(f); |
| - return Math.floor(Math.floor(f * 64) / 64); // see FractionLayoutUnit::floor() |
| + ceilSnapToLayoutUnit: function(f) { |
|
leviw_travelin_and_unemployed
2013/05/21 22:21:56
I find this name confusing, as "snap" in the conte
|
| + return isEnabled() ? Math.ceil(f * 64) / 64 : Math.ceil(f); // see ceiledLayoutUnit(), LayoutUnit.h |
| }, |
| - isSubPixelLayoutEnabled: function() { |
| - return _subPixelLayout; |
| - } |
| } |
| }()); |