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

Side by Side Diff: LayoutTests/imported/csswg-test/css-shapes-1/shape-outside/values/support/parsing-utils.js

Issue 1120133004: Serialize <number> to round to at most 6 decimals (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: V7 Created 5 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 ParsingUtils = (function() { 1 var ParsingUtils = (function() {
2 function testInlineStyle(value, expected) { 2 function testInlineStyle(value, expected) {
3 var div = document.createElement('div'); 3 var div = document.createElement('div');
4 div.style.setProperty('shape-outside', value); 4 div.style.setProperty('shape-outside', value);
5 var actual = div.style.getPropertyValue('shape-outside'); 5 var actual = div.style.getPropertyValue('shape-outside');
6 assert_equals(actual, expected); 6 assert_equals(actual, expected);
7 } 7 }
8 8
9 function testComputedStyle(value, expected) { 9 function testComputedStyle(value, expected) {
10 var div = document.createElement('div'); 10 var div = document.createElement('div');
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } else if (unit == 'vh') { 360 } else if (unit == 'vh') {
361 number = ((.01 * window.innerHeight) * number); 361 number = ((.01 * window.innerHeight) * number);
362 } else if (unit == 'vmin') { 362 } else if (unit == 'vmin') {
363 number = Math.min( (.01 * window.innerWidth), (.01 * window.inn erHeight) ) * number; 363 number = Math.min( (.01 * window.innerWidth), (.01 * window.inn erHeight) ) * number;
364 } else if (unit == 'vmax') { 364 } else if (unit == 'vmax') {
365 number = Math.max( (.01 * window.innerWidth), (.01 * window.inne rHeight) ) * number; 365 number = Math.max( (.01 * window.innerWidth), (.01 * window.inne rHeight) ) * number;
366 } 366 }
367 else { 367 else {
368 convertedUnit = unit; 368 convertedUnit = unit;
369 } 369 }
370 if (number < 1000) {
Timothy Loh 2015/05/18 04:32:02 We shouldn't be changing this file, see LayoutTest
370 number = Math.round(number * 1000) / 1000; 371 number = Math.round(number * 1000) / 1000;
372 } else {
373 number = Math.round(number * 100) / 100;
374 }
371 var find = valuesToConvert[i]; 375 var find = valuesToConvert[i];
372 var replace = number.toString() + convertedUnit; 376 var replace = number.toString() + convertedUnit;
373 retStr = retStr.replace(valuesToConvert[i], number.toString() + conv ertedUnit); 377 retStr = retStr.replace(valuesToConvert[i], number.toString() + conv ertedUnit);
374 } 378 }
375 } 379 }
376 return retStr.replace(',,', ','); 380 return retStr.replace(',,', ',');
377 } 381 }
378 382
379 function roundResultStr(str) { 383 function roundResultStr(str) {
380 if(Object.prototype.toString.call( str ) !== '[object String]') 384 if(Object.prototype.toString.call( str ) !== '[object String]')
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 buildPositionTests: buildPositionTests, 861 buildPositionTests: buildPositionTests,
858 buildInsetTests: buildInsetTests, 862 buildInsetTests: buildInsetTests,
859 buildPolygonTests: buildPolygonTests, 863 buildPolygonTests: buildPolygonTests,
860 generateInsetRoundCases: generateInsetRoundCases, 864 generateInsetRoundCases: generateInsetRoundCases,
861 buildCalcTests: buildCalcTests, 865 buildCalcTests: buildCalcTests,
862 validUnits: validUnits, 866 validUnits: validUnits,
863 calcTestValues: calcTestValues, 867 calcTestValues: calcTestValues,
864 roundResultStr: roundResultStr 868 roundResultStr: roundResultStr
865 } 869 }
866 })(); 870 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698