| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // The logic in this function is duplicated in MediaValues::computeLength | 483 // The logic in this function is duplicated in MediaValues::computeLength |
| 484 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make | 484 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make |
| 485 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. | 485 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. |
| 486 if (type() == UnitType::Calc) | 486 if (type() == UnitType::Calc) |
| 487 return m_value.calc->computeLengthPx(conversionData); | 487 return m_value.calc->computeLengthPx(conversionData); |
| 488 | 488 |
| 489 double factor; | 489 double factor; |
| 490 | 490 |
| 491 switch (type()) { | 491 switch (type()) { |
| 492 case UnitType::Ems: | 492 case UnitType::Ems: |
| 493 case UnitType::QuirkyEms: |
| 493 factor = conversionData.emFontSize(); | 494 factor = conversionData.emFontSize(); |
| 494 break; | 495 break; |
| 495 case UnitType::Exs: | 496 case UnitType::Exs: |
| 496 factor = conversionData.exFontSize(); | 497 factor = conversionData.exFontSize(); |
| 497 break; | 498 break; |
| 498 case UnitType::Rems: | 499 case UnitType::Rems: |
| 499 factor = conversionData.remFontSize(); | 500 factor = conversionData.remFontSize(); |
| 500 break; | 501 break; |
| 501 case UnitType::Chs: | 502 case UnitType::Chs: |
| 502 factor = conversionData.chFontSize(); | 503 factor = conversionData.chFontSize(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 switch (unitType) { | 672 switch (unitType) { |
| 672 case CSSPrimitiveValue::UnitType::Pixels: | 673 case CSSPrimitiveValue::UnitType::Pixels: |
| 673 case CSSPrimitiveValue::UnitType::Centimeters: | 674 case CSSPrimitiveValue::UnitType::Centimeters: |
| 674 case CSSPrimitiveValue::UnitType::Millimeters: | 675 case CSSPrimitiveValue::UnitType::Millimeters: |
| 675 case CSSPrimitiveValue::UnitType::Inches: | 676 case CSSPrimitiveValue::UnitType::Inches: |
| 676 case CSSPrimitiveValue::UnitType::Points: | 677 case CSSPrimitiveValue::UnitType::Points: |
| 677 case CSSPrimitiveValue::UnitType::Picas: | 678 case CSSPrimitiveValue::UnitType::Picas: |
| 678 lengthType = UnitTypePixels; | 679 lengthType = UnitTypePixels; |
| 679 return true; | 680 return true; |
| 680 case CSSPrimitiveValue::UnitType::Ems: | 681 case CSSPrimitiveValue::UnitType::Ems: |
| 682 case CSSPrimitiveValue::UnitType::QuirkyEms: |
| 681 lengthType = UnitTypeFontSize; | 683 lengthType = UnitTypeFontSize; |
| 682 return true; | 684 return true; |
| 683 case CSSPrimitiveValue::UnitType::Exs: | 685 case CSSPrimitiveValue::UnitType::Exs: |
| 684 lengthType = UnitTypeFontXSize; | 686 lengthType = UnitTypeFontXSize; |
| 685 return true; | 687 return true; |
| 686 case CSSPrimitiveValue::UnitType::Rems: | 688 case CSSPrimitiveValue::UnitType::Rems: |
| 687 lengthType = UnitTypeRootFontSize; | 689 lengthType = UnitTypeRootFontSize; |
| 688 return true; | 690 return true; |
| 689 case CSSPrimitiveValue::UnitType::Chs: | 691 case CSSPrimitiveValue::UnitType::Chs: |
| 690 lengthType = UnitTypeZeroCharacterWidth; | 692 lengthType = UnitTypeZeroCharacterWidth; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 | 782 |
| 781 const char* CSSPrimitiveValue::unitTypeToString(UnitType type) | 783 const char* CSSPrimitiveValue::unitTypeToString(UnitType type) |
| 782 { | 784 { |
| 783 switch (type) { | 785 switch (type) { |
| 784 case UnitType::Number: | 786 case UnitType::Number: |
| 785 case UnitType::Integer: | 787 case UnitType::Integer: |
| 786 return ""; | 788 return ""; |
| 787 case UnitType::Percentage: | 789 case UnitType::Percentage: |
| 788 return "%"; | 790 return "%"; |
| 789 case UnitType::Ems: | 791 case UnitType::Ems: |
| 792 case UnitType::QuirkyEms: |
| 790 return "em"; | 793 return "em"; |
| 791 case UnitType::Exs: | 794 case UnitType::Exs: |
| 792 return "ex"; | 795 return "ex"; |
| 793 case UnitType::Rems: | 796 case UnitType::Rems: |
| 794 return "rem"; | 797 return "rem"; |
| 795 case UnitType::Chs: | 798 case UnitType::Chs: |
| 796 return "ch"; | 799 return "ch"; |
| 797 case UnitType::Pixels: | 800 case UnitType::Pixels: |
| 798 return "px"; | 801 return "px"; |
| 799 case UnitType::Centimeters: | 802 case UnitType::Centimeters: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 case UnitType::CustomIdentifier: | 845 case UnitType::CustomIdentifier: |
| 843 case UnitType::String: | 846 case UnitType::String: |
| 844 case UnitType::URI: | 847 case UnitType::URI: |
| 845 case UnitType::ValueID: | 848 case UnitType::ValueID: |
| 846 case UnitType::PropertyID: | 849 case UnitType::PropertyID: |
| 847 case UnitType::RGBColor: | 850 case UnitType::RGBColor: |
| 848 case UnitType::Calc: | 851 case UnitType::Calc: |
| 849 case UnitType::Shape: | 852 case UnitType::Shape: |
| 850 case UnitType::CalcPercentageWithNumber: | 853 case UnitType::CalcPercentageWithNumber: |
| 851 case UnitType::CalcPercentageWithLength: | 854 case UnitType::CalcPercentageWithLength: |
| 852 case UnitType::QuirkyEms: | |
| 853 break; | 855 break; |
| 854 }; | 856 }; |
| 855 ASSERT_NOT_REACHED(); | 857 ASSERT_NOT_REACHED(); |
| 856 return ""; | 858 return ""; |
| 857 } | 859 } |
| 858 | 860 |
| 859 String CSSPrimitiveValue::customCSSText() const | 861 String CSSPrimitiveValue::customCSSText() const |
| 860 { | 862 { |
| 861 if (m_hasCachedCSSText) { | 863 if (m_hasCachedCSSText) { |
| 862 ASSERT(cssTextCache().contains(this)); | 864 ASSERT(cssTextCache().contains(this)); |
| 863 return cssTextCache().get(this); | 865 return cssTextCache().get(this); |
| 864 } | 866 } |
| 865 | 867 |
| 866 String text; | 868 String text; |
| 867 switch (type()) { | 869 switch (type()) { |
| 868 case UnitType::Unknown: | 870 case UnitType::Unknown: |
| 869 // FIXME | 871 // FIXME |
| 870 break; | 872 break; |
| 871 case UnitType::Integer: | 873 case UnitType::Integer: |
| 872 text = String::format("%d", getIntValue()); | 874 text = String::format("%d", getIntValue()); |
| 873 break; | 875 break; |
| 874 case UnitType::Number: | 876 case UnitType::Number: |
| 875 case UnitType::Percentage: | 877 case UnitType::Percentage: |
| 876 case UnitType::Ems: | 878 case UnitType::Ems: |
| 879 case UnitType::QuirkyEms: |
| 877 case UnitType::Exs: | 880 case UnitType::Exs: |
| 878 case UnitType::Rems: | 881 case UnitType::Rems: |
| 879 case UnitType::Chs: | 882 case UnitType::Chs: |
| 880 case UnitType::Pixels: | 883 case UnitType::Pixels: |
| 881 case UnitType::Centimeters: | 884 case UnitType::Centimeters: |
| 882 case UnitType::DotsPerPixel: | 885 case UnitType::DotsPerPixel: |
| 883 case UnitType::DotsPerInch: | 886 case UnitType::DotsPerInch: |
| 884 case UnitType::DotsPerCentimeter: | 887 case UnitType::DotsPerCentimeter: |
| 885 case UnitType::Millimeters: | 888 case UnitType::Millimeters: |
| 886 case UnitType::Inches: | 889 case UnitType::Inches: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 break; | 925 break; |
| 923 } | 926 } |
| 924 case UnitType::Calc: | 927 case UnitType::Calc: |
| 925 text = m_value.calc->customCSSText(); | 928 text = m_value.calc->customCSSText(); |
| 926 break; | 929 break; |
| 927 case UnitType::Shape: | 930 case UnitType::Shape: |
| 928 text = m_value.shape->cssText(); | 931 text = m_value.shape->cssText(); |
| 929 break; | 932 break; |
| 930 case UnitType::CalcPercentageWithNumber: | 933 case UnitType::CalcPercentageWithNumber: |
| 931 case UnitType::CalcPercentageWithLength: | 934 case UnitType::CalcPercentageWithLength: |
| 932 case UnitType::QuirkyEms: | |
| 933 ASSERT_NOT_REACHED(); | 935 ASSERT_NOT_REACHED(); |
| 934 break; | 936 break; |
| 935 } | 937 } |
| 936 | 938 |
| 937 ASSERT(!cssTextCache().contains(this)); | 939 ASSERT(!cssTextCache().contains(this)); |
| 938 cssTextCache().set(this, text); | 940 cssTextCache().set(this, text); |
| 939 m_hasCachedCSSText = true; | 941 m_hasCachedCSSText = true; |
| 940 return text; | 942 return text; |
| 941 } | 943 } |
| 942 | 944 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 visitor->trace(m_value.shape); | 1013 visitor->trace(m_value.shape); |
| 1012 break; | 1014 break; |
| 1013 default: | 1015 default: |
| 1014 break; | 1016 break; |
| 1015 } | 1017 } |
| 1016 #endif | 1018 #endif |
| 1017 CSSValue::traceAfterDispatch(visitor); | 1019 CSSValue::traceAfterDispatch(visitor); |
| 1018 } | 1020 } |
| 1019 | 1021 |
| 1020 } // namespace blink | 1022 } // namespace blink |
| OLD | NEW |