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

Side by Side Diff: LayoutTests/fast/exclusions/resources/subpixel-utils.js

Issue 14959014: [CSS Exclusions] Programmatic layout tests fail when subpixel layout is disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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 unified diff | Download patch
OLDNEW
1 var SubPixelLayout = (function() { 1 var SubPixelLayout = (function() {
2 var _subPixelLayout = null; 2 var enabled = undefined;
leviw_travelin_and_unemployed 2013/05/21 22:21:56 I understand you're doing this for consistency wit
3 function initSubPixelLayout() { 3
4 var elem = document.createElement('div'); 4 function isEnabled()
5 elem.style.setProperty('width', '4.5px'); 5 {
6 document.body.appendChild(elem); 6 if (enabled === undefined) {
7 var bounds = elem.getBoundingClientRect(); 7 var elem = document.createElement('div');
8 _subPixelLayout = (bounds.width != Math.floor(bounds.width)); 8 elem.style.setProperty('width', '4.5px');
9 document.body.removeChild(elem); 9 document.body.appendChild(elem);
10 var bounds = elem.getBoundingClientRect();
11 enabled = (bounds.width != Math.floor(bounds.width));
12 document.body.removeChild(elem);
13 }
14 return enabled;
10 } 15 }
11 document.addEventListener('DOMContentLoaded', initSubPixelLayout); 16
12 return { 17 return {
13 initSubPixelLayout: initSubPixelLayout, 18 isEnabled: isEnabled,
14 roundLineLeft: function(f) { 19 snapToLayoutUnit: function(f) {
15 if (!_subPixelLayout) 20 return isEnabled() ? Math.floor(f * 64) / 64 : Math.floor(f); // as in LayoutUnit(f).toFloat()
16 return Math.floor(f);
17 return Math.floor((Math.floor(f * 64) + 32) / 64); // see FractionLa youtUnit::round()
18 }, 21 },
19 roundLineRight: function(f) { 22 ceilSnapToLayoutUnit: function(f) {
leviw_travelin_and_unemployed 2013/05/21 22:21:56 I find this name confusing, as "snap" in the conte
20 if (!_subPixelLayout) 23 return isEnabled() ? Math.ceil(f * 64) / 64 : Math.ceil(f); // see c eiledLayoutUnit(), LayoutUnit.h
21 return Math.floor(f);
22 return Math.floor(Math.floor(f * 64) / 64); // see FractionLayoutUni t::floor()
23 }, 24 },
24 isSubPixelLayoutEnabled: function() {
25 return _subPixelLayout;
26 }
27 } 25 }
28 }()); 26 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698