1 var SubPixelLayout = (function() {
2 var enabled = undefined;
6 if (enabled === undefined) {
7 var elem = document.createElement('div');
8 elem.style.setProperty('width', '4.5px');
9 document.body.appendChild(elem);
10 var bounds = elem.getBoundingClientRect();
11 enabled = (bounds.width != Math.floor(bounds.width));
12 document.body.removeChild(elem);
19 snapToLayoutUnit: function(f) {
20 return isEnabled() ? Math.floor(f * 64) / 64 : Math.floor(f); // as in LayoutUnit(f).toFloat()
22 ceilToLayoutUnit: function(f) {
23 return isEnabled() ? Math.ceil(f * 64) / 64 : Math.ceil(f); // see ceiledLayoutUnit(), LayoutUnit.h
25 resolution: function() {
26 return isEnabled() ? 1/64 : 1;