Changeset 49554 in webkit
- Timestamp:
- Oct 13, 2009 9:09:02 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r49552 r49554 1 2009-10-13 Evan Martin <evan@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Float formatting changes affect three tests: 6 - large-number-round-trip now passes 7 - opacity-float now passes and has more test cases 8 - compound-2d-transforms output tweaked slightly 9 10 https://bugs.webkit.org/show_bug.cgi?id=18994 11 12 * fast/css/large-number-round-trip-expected.txt: 13 * fast/css/opacity-float-expected.txt: 14 * fast/css/opacity-float.html: 15 * platform/mac/fast/css/opacity-float-expected.txt: Removed. 16 * transforms/2d/compound-2d-transforms-expected.txt: 17 * transforms/2d/compound-2d-transforms.html: 18 1 19 2009-10-13 Zan Dobersek <zandobersek@gmail.com> 2 20 -
trunk/LayoutTests/fast/css/large-number-round-trip-expected.txt
r49254 r49554 1 FAIL: read 90010000px back as 9.001e+07px, read again as0px1 PASS: read 90010000px back as 90010000px, read again as 90010000px -
trunk/LayoutTests/fast/css/opacity-float-expected.txt
r49253 r49554 2 2 3 3 PASS 4 PASS 5 PASS 6 PASS 7 PASS 8 PASS 9 PASS 10 PASS 11 PASS 12 PASS 13 PASS 14 PASS 15 PASS 16 PASS 17 -
trunk/LayoutTests/fast/css/opacity-float.html
r49253 r49554 16 16 17 17 <script> 18 var opacity = document.getElementById('test').style.opacity.toString(); 19 if (opacity == '0.9') 20 document.write('PASS'); 21 else 22 document.write('FAIL: ' + opacity); 18 var test = document.getElementById('test'); 19 20 function doTest(expected, input) { 21 test.style.opacity = input; 22 var opacity = test.style.opacity.toString(); 23 if (opacity == expected) 24 document.write('PASS'); 25 else 26 document.write('FAIL: expected ' + expected + ', got ' + opacity); 27 document.write('<br>'); 28 } 29 30 var tests = [['0.9', '0.9'], 31 ['98765432198', '98765432198'], 32 ['9870000', '9870000'], 33 ['0.000321', '0.000321'], 34 ['50.02', '50.02'], 35 // Check we clip precision to six decimals. 36 ['1234.567891', '1234.567891234']]; 37 for (var i = 0; i < tests.length; i++) 38 doTest(tests[i][0], tests[i][1]); 39 40 // Test a too-small value. 41 doTest('0', '0.0000001'); 42 // Test that a beyond-precision digit will be rounded in. 43 doTest('0.000001', '0.0000009'); 44 45 // Run the test list again with negatives. 46 for (var i = 0; i < tests.length; i++) 47 doTest('-' + tests[i][0], '-' + tests[i][1]); 23 48 </script> -
trunk/LayoutTests/transforms/2d/compound-2d-transforms-expected.txt
r36454 r49554 7 7 transform "matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)" : PASS 8 8 transform "translate(50px, 20px) rotate(12deg)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)" : PASS 9 transform "rotate(12deg) translate(50px, 20px)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.7491 , 29.9585)" : PASS10 transform "rotate(12deg) translate(50px, 20px) scale(1.4)" expected "matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 44.7491, 29.9585)" : PASS11 transform "scale(1.4) rotate(12deg) translate(50px, 20px) " expected "matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 62.6488, 41.942)" : PASS12 transform "scale(1.4) translate(50px, 20px) rotate(12deg)" expected "matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 70, 28)" : PASS13 transform "translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)" expected "matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 39.6044, 68.9074)" : PASS14 transform "rotate(12deg) translate(50px, 20px) scale(1.4) translate(-80px, 40px) skew(34deg) translate(10px, 10px) scale(0.7) skewY(-25deg) rotate(21deg) translateX(50px) scale(1.4, 1.8)" expected "matrix(1.2051 7, 0.148207, 0.258987, 2.04004, -13.3847, 85.31)" : PASS9 transform "rotate(12deg) translate(50px, 20px)" expected "matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.749146, 29.958537)" : PASS 10 transform "rotate(12deg) translate(50px, 20px) scale(1.4)" expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 44.749146, 29.958537)" : PASS 11 transform "scale(1.4) rotate(12deg) translate(50px, 20px) " expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 62.648805, 41.941951)" : PASS 12 transform "scale(1.4) translate(50px, 20px) rotate(12deg)" expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 70, 28)" : PASS 13 transform "translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)" expected "matrix(1.369407, 0.291076, -0.291076, 1.369407, 39.604415, 68.90738)" : PASS 14 transform "rotate(12deg) translate(50px, 20px) scale(1.4) translate(-80px, 40px) skew(34deg) translate(10px, 10px) scale(0.7) skewY(-25deg) rotate(21deg) translateX(50px) scale(1.4, 1.8)" expected "matrix(1.205166, 0.148207, 0.258987, 2.040044, -13.384723, 85.309967)" : PASS 15 15 transform ",rotate(12deg) translate(50px, 20px)" expected "none" : PASS 16 16 transform "rotate(12deg), translate(50px, 20px)" expected "none" : PASS -
trunk/LayoutTests/transforms/2d/compound-2d-transforms.html
r36454 r49554 44 44 // two functions 45 45 { 'transform' : 'translate(50px, 20px) rotate(12deg)', 'result' : 'matrix(0.978148, 0.207912, -0.207912, 0.978148, 50, 20)' }, 46 { 'transform' : 'rotate(12deg) translate(50px, 20px)', 'result' : 'matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.7491 , 29.9585)' },46 { 'transform' : 'rotate(12deg) translate(50px, 20px)', 'result' : 'matrix(0.978148, 0.207912, -0.207912, 0.978148, 44.749146, 29.958537)' }, 47 47 48 48 // three functions 49 { 'transform' : 'rotate(12deg) translate(50px, 20px) scale(1.4)', 'result' : 'matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 44.7491, 29.9585)' },50 { 'transform' : 'scale(1.4) rotate(12deg) translate(50px, 20px) ', 'result' : 'matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 62.6488, 41.942)' },51 { 'transform' : 'scale(1.4) translate(50px, 20px) rotate(12deg)', 'result' : 'matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 70, 28)' },52 { 'transform' : 'translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)', 'result' : 'matrix(1.3694 1, 0.291076, -0.291076, 1.36941, 39.6044, 68.9074)' },49 { 'transform' : 'rotate(12deg) translate(50px, 20px) scale(1.4)', 'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 44.749146, 29.958537)' }, 50 { 'transform' : 'scale(1.4) rotate(12deg) translate(50px, 20px) ', 'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 62.648805, 41.941951)' }, 51 { 'transform' : 'scale(1.4) translate(50px, 20px) rotate(12deg)', 'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 70, 28)' }, 52 { 'transform' : 'translate(50px, 20px) rotate(12deg) translateY(50px) scale(1.4)', 'result' : 'matrix(1.369407, 0.291076, -0.291076, 1.369407, 39.604415, 68.90738)' }, 53 53 54 54 // lots of functions 55 55 { 'transform' : 'rotate(12deg) translate(50px, 20px) scale(1.4) translate(-80px, 40px) skew(34deg) translate(10px, 10px) scale(0.7) skewY(-25deg) rotate(21deg) translateX(50px) scale(1.4, 1.8)', 56 'result' : 'matrix(1.2051 7, 0.148207, 0.258987, 2.04004, -13.3847, 85.31)' },56 'result' : 'matrix(1.205166, 0.148207, 0.258987, 2.040044, -13.384723, 85.309967)' }, 57 57 58 58 // invalid compound functions -
trunk/WebCore/ChangeLog
r49553 r49554 1 2009-10-13 Evan Martin <evan@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Stringify CSS units manually (without printf) to make the formatting 6 locale-insensitive and obey CSS spec with respect to large values. 7 8 https://bugs.webkit.org/show_bug.cgi?id=18994 9 10 * css/CSSPrimitiveValue.cpp: 11 (WebCore::appendCSSDouble): 12 (WebCore::formatWithUnits): 13 (WebCore::CSSPrimitiveValue::cssText): 14 1 15 2009-10-13 Evan Martin <evan@chromium.org> 2 16 -
trunk/WebCore/css/CSSPrimitiveValue.cpp
r47230 r49554 685 685 } 686 686 687 static void appendCSSDouble(Vector<UChar>& vector, double value) 688 { 689 // From the CSS specification section titled "Integers and real numbers", 690 // real numbers are only formatted as [sign] [digits] "." [digits]. 691 // This differs from printf-style formatting in that exponents (e.g. 1.3e06) 692 // are not allowed. Since NaN/inf are also not valid CSS values this 693 // function doesn't handle them. 694 695 // For compatibility with what was returned by older versions of 696 // WebKit, we target 6 digits of precision. 697 const int digitsAfterDecimalPoint = 6; 698 long long rounded = llround(fabs(value) * 1000000.0); 699 if (rounded == 0) { 700 vector.append('0'); 701 return; 702 } 703 704 char buf[24]; 705 int length = snprintf(buf, sizeof(buf), "%lld", rounded); 706 int decimalPoint = length - digitsAfterDecimalPoint; 707 708 // We are matching printf("%g")'s behavior and must trim trailing zeros, 709 // regardless of whether they're significant. 710 while (length > 0 && length > decimalPoint && buf[length - 1] == '0') 711 length--; 712 713 // Reserve an estimate of space for the number of digits we anticipate 714 // along with a minus sign/initial zero/decimal point. 715 vector.reserveCapacity(vector.size() + 3 + length); 716 717 if (value < 0) 718 vector.append('-'); 719 720 if (decimalPoint <= 0) { 721 // Only digits after the decimal point. 722 vector.append('0'); 723 vector.append('.'); 724 for (int i = decimalPoint; i < 0; i++) 725 vector.append('0'); 726 for (int i = 0; i < length; i++) 727 vector.append(buf[i]); 728 } else if (length <= decimalPoint) { 729 // Only digits before the decimal point. 730 for (int i = 0; i < length; i++) 731 vector.append(buf[i]); 732 } else { 733 // Digits before and after the decimal point. 734 for (int i = 0; i < decimalPoint; i++) 735 vector.append(buf[i]); 736 vector.append('.'); 737 for (int i = decimalPoint; i < length; i++) 738 vector.append(buf[i]); 739 } 740 } 741 742 static String formatWithUnits(double value, const char* units) 743 { 744 Vector<UChar> result; 745 appendCSSDouble(result, value); 746 result.reserveCapacity(result.size() + strlen(units)); 747 for (int i = 0; units[i]; i++) 748 result.append(units[i]); 749 return String::adopt(result); 750 } 751 687 752 String CSSPrimitiveValue::cssText() const 688 753 { … … 696 761 case CSS_NUMBER: 697 762 case CSS_PARSER_INTEGER: 698 text = String::number(m_value.num);763 text = formatWithUnits(m_value.num, ""); 699 764 break; 700 765 case CSS_PERCENTAGE: 701 text = String::format("%.6lg%%", m_value.num);766 text = formatWithUnits(m_value.num, "%"); 702 767 break; 703 768 case CSS_EMS: 704 text = String::format("%.6lgem", m_value.num);769 text = formatWithUnits(m_value.num, "em"); 705 770 break; 706 771 case CSS_EXS: 707 text = String::format("%.6lgex", m_value.num);772 text = formatWithUnits(m_value.num, "ex"); 708 773 break; 709 774 case CSS_REMS: 710 text = String::format("%.6lgrem", m_value.num);775 text = formatWithUnits(m_value.num, "rem"); 711 776 break; 712 777 case CSS_PX: 713 text = String::format("%.6lgpx", m_value.num);778 text = formatWithUnits(m_value.num, "px"); 714 779 break; 715 780 case CSS_CM: 716 text = String::format("%.6lgcm", m_value.num);781 text = formatWithUnits(m_value.num, "cm"); 717 782 break; 718 783 case CSS_MM: 719 text = String::format("%.6lgmm", m_value.num);784 text = formatWithUnits(m_value.num, "mm"); 720 785 break; 721 786 case CSS_IN: 722 text = String::format("%.6lgin", m_value.num);787 text = formatWithUnits(m_value.num, "in"); 723 788 break; 724 789 case CSS_PT: 725 text = String::format("%.6lgpt", m_value.num);790 text = formatWithUnits(m_value.num, "pt"); 726 791 break; 727 792 case CSS_PC: 728 text = String::format("%.6lgpc", m_value.num);793 text = formatWithUnits(m_value.num, "pc"); 729 794 break; 730 795 case CSS_DEG: 731 text = String::format("%.6lgdeg", m_value.num);796 text = formatWithUnits(m_value.num, "deg"); 732 797 break; 733 798 case CSS_RAD: 734 text = String::format("%.6lgrad", m_value.num);799 text = formatWithUnits(m_value.num, "rad"); 735 800 break; 736 801 case CSS_GRAD: 737 text = String::format("%.6lggrad", m_value.num);802 text = formatWithUnits(m_value.num, "grad"); 738 803 break; 739 804 case CSS_MS: 740 text = String::format("%.6lgms", m_value.num);805 text = formatWithUnits(m_value.num, "ms"); 741 806 break; 742 807 case CSS_S: 743 text = String::format("%.6lgs", m_value.num);808 text = formatWithUnits(m_value.num, "s"); 744 809 break; 745 810 case CSS_HZ: 746 text = String::format("%.6lghz", m_value.num);811 text = formatWithUnits(m_value.num, "hz"); 747 812 break; 748 813 case CSS_KHZ: 749 text = String::format("%.6lgkhz", m_value.num);814 text = formatWithUnits(m_value.num, "khz"); 750 815 break; 751 816 case CSS_TURN: 752 text = String::format("%.6lgturn", m_value.num);817 text = formatWithUnits(m_value.num, "turn"); 753 818 break; 754 819 case CSS_DIMENSION:
Note: See TracChangeset
for help on using the changeset viewer.