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

Unified 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 side-by-side diff with in-line comments
Download patch
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;
- }
}
}());

Powered by Google App Engine
This is Rietveld 408576698