| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 case CSSPrimitiveValue::CSS_IN: | 69 case CSSPrimitiveValue::CSS_IN: |
| 70 case CSSPrimitiveValue::CSS_KHZ: | 70 case CSSPrimitiveValue::CSS_KHZ: |
| 71 case CSSPrimitiveValue::CSS_MM: | 71 case CSSPrimitiveValue::CSS_MM: |
| 72 case CSSPrimitiveValue::CSS_MS: | 72 case CSSPrimitiveValue::CSS_MS: |
| 73 case CSSPrimitiveValue::CSS_NUMBER: | 73 case CSSPrimitiveValue::CSS_NUMBER: |
| 74 case CSSPrimitiveValue::CSS_PERCENTAGE: | 74 case CSSPrimitiveValue::CSS_PERCENTAGE: |
| 75 case CSSPrimitiveValue::CSS_PC: | 75 case CSSPrimitiveValue::CSS_PC: |
| 76 case CSSPrimitiveValue::CSS_PT: | 76 case CSSPrimitiveValue::CSS_PT: |
| 77 case CSSPrimitiveValue::CSS_PX: | 77 case CSSPrimitiveValue::CSS_PX: |
| 78 case CSSPrimitiveValue::CSS_RAD: | 78 case CSSPrimitiveValue::CSS_RAD: |
| 79 case CSSPrimitiveValue::CSS_REMS: | |
| 80 case CSSPrimitiveValue::CSS_CHS: | 79 case CSSPrimitiveValue::CSS_CHS: |
| 81 case CSSPrimitiveValue::CSS_S: | 80 case CSSPrimitiveValue::CSS_S: |
| 82 case CSSPrimitiveValue::CSS_TURN: | 81 case CSSPrimitiveValue::CSS_TURN: |
| 83 case CSSPrimitiveValue::CSS_VW: | 82 case CSSPrimitiveValue::CSS_VW: |
| 84 case CSSPrimitiveValue::CSS_VH: | 83 case CSSPrimitiveValue::CSS_VH: |
| 85 case CSSPrimitiveValue::CSS_VMIN: | 84 case CSSPrimitiveValue::CSS_VMIN: |
| 86 case CSSPrimitiveValue::CSS_VMAX: | 85 case CSSPrimitiveValue::CSS_VMAX: |
| 87 case CSSPrimitiveValue::CSS_FR: | 86 case CSSPrimitiveValue::CSS_FR: |
| 88 return true; | 87 return true; |
| 89 case CSSPrimitiveValue::CSS_ATTR: | 88 case CSSPrimitiveValue::CSS_ATTR: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 table.set(String("s"), CSSPrimitiveValue::CSS_S); | 126 table.set(String("s"), CSSPrimitiveValue::CSS_S); |
| 128 table.set(String("hz"), CSSPrimitiveValue::CSS_HZ); | 127 table.set(String("hz"), CSSPrimitiveValue::CSS_HZ); |
| 129 table.set(String("khz"), CSSPrimitiveValue::CSS_KHZ); | 128 table.set(String("khz"), CSSPrimitiveValue::CSS_KHZ); |
| 130 table.set(String("dpi"), CSSPrimitiveValue::CSS_DPI); | 129 table.set(String("dpi"), CSSPrimitiveValue::CSS_DPI); |
| 131 table.set(String("dpcm"), CSSPrimitiveValue::CSS_DPCM); | 130 table.set(String("dpcm"), CSSPrimitiveValue::CSS_DPCM); |
| 132 table.set(String("dppx"), CSSPrimitiveValue::CSS_DPPX); | 131 table.set(String("dppx"), CSSPrimitiveValue::CSS_DPPX); |
| 133 table.set(String("vw"), CSSPrimitiveValue::CSS_VW); | 132 table.set(String("vw"), CSSPrimitiveValue::CSS_VW); |
| 134 table.set(String("vh"), CSSPrimitiveValue::CSS_VH); | 133 table.set(String("vh"), CSSPrimitiveValue::CSS_VH); |
| 135 table.set(String("vmax"), CSSPrimitiveValue::CSS_VMIN); | 134 table.set(String("vmax"), CSSPrimitiveValue::CSS_VMIN); |
| 136 table.set(String("vmin"), CSSPrimitiveValue::CSS_VMAX); | 135 table.set(String("vmin"), CSSPrimitiveValue::CSS_VMAX); |
| 137 table.set(String("rem"), CSSPrimitiveValue::CSS_REMS); | |
| 138 table.set(String("fr"), CSSPrimitiveValue::CSS_FR); | 136 table.set(String("fr"), CSSPrimitiveValue::CSS_FR); |
| 139 table.set(String("turn"), CSSPrimitiveValue::CSS_TURN); | 137 table.set(String("turn"), CSSPrimitiveValue::CSS_TURN); |
| 140 table.set(String("ch"), CSSPrimitiveValue::CSS_CHS); | 138 table.set(String("ch"), CSSPrimitiveValue::CSS_CHS); |
| 141 return table; | 139 return table; |
| 142 } | 140 } |
| 143 | 141 |
| 144 CSSPrimitiveValue::UnitType CSSPrimitiveValue::fromName(const String& unit) | 142 CSSPrimitiveValue::UnitType CSSPrimitiveValue::fromName(const String& unit) |
| 145 { | 143 { |
| 146 DEFINE_STATIC_LOCAL(StringToUnitTable, unitTable, (createStringToUnitTable()
)); | 144 DEFINE_STATIC_LOCAL(StringToUnitTable, unitTable, (createStringToUnitTable()
)); |
| 147 return unitTable.get(unit.lower()); | 145 return unitTable.get(unit.lower()); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 case CSS_SHAPE: | 451 case CSS_SHAPE: |
| 454 // We must not call deref() when oilpan is enabled because m_value.shape
is traced. | 452 // We must not call deref() when oilpan is enabled because m_value.shape
is traced. |
| 455 #if !ENABLE(OILPAN) | 453 #if !ENABLE(OILPAN) |
| 456 m_value.shape->deref(); | 454 m_value.shape->deref(); |
| 457 #endif | 455 #endif |
| 458 break; | 456 break; |
| 459 case CSS_NUMBER: | 457 case CSS_NUMBER: |
| 460 case CSS_PERCENTAGE: | 458 case CSS_PERCENTAGE: |
| 461 case CSS_EMS: | 459 case CSS_EMS: |
| 462 case CSS_EXS: | 460 case CSS_EXS: |
| 463 case CSS_REMS: | |
| 464 case CSS_CHS: | 461 case CSS_CHS: |
| 465 case CSS_PX: | 462 case CSS_PX: |
| 466 case CSS_CM: | 463 case CSS_CM: |
| 467 case CSS_MM: | 464 case CSS_MM: |
| 468 case CSS_IN: | 465 case CSS_IN: |
| 469 case CSS_PT: | 466 case CSS_PT: |
| 470 case CSS_PC: | 467 case CSS_PC: |
| 471 case CSS_DEG: | 468 case CSS_DEG: |
| 472 case CSS_RAD: | 469 case CSS_RAD: |
| 473 case CSS_GRAD: | 470 case CSS_GRAD: |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 | 565 |
| 569 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c
onversionData) | 566 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c
onversionData) |
| 570 { | 567 { |
| 571 // The logic in this function is duplicated in MediaValues::computeLength | 568 // The logic in this function is duplicated in MediaValues::computeLength |
| 572 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make | 569 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make |
| 573 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. | 570 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. |
| 574 if (m_primitiveUnitType == CSS_CALC) | 571 if (m_primitiveUnitType == CSS_CALC) |
| 575 return m_value.calc->computeLengthPx(conversionData); | 572 return m_value.calc->computeLengthPx(conversionData); |
| 576 | 573 |
| 577 const RenderStyle& style = conversionData.style(); | 574 const RenderStyle& style = conversionData.style(); |
| 578 const RenderStyle* rootStyle = conversionData.rootStyle(); | |
| 579 bool computingFontSize = conversionData.computingFontSize(); | 575 bool computingFontSize = conversionData.computingFontSize(); |
| 580 | 576 |
| 581 double factor; | 577 double factor; |
| 582 | 578 |
| 583 switch (primitiveType()) { | 579 switch (primitiveType()) { |
| 584 case CSS_EMS: | 580 case CSS_EMS: |
| 585 factor = computingFontSize ? style.fontDescription().specifiedSize()
: style.fontDescription().computedSize(); | 581 factor = computingFontSize ? style.fontDescription().specifiedSize()
: style.fontDescription().computedSize(); |
| 586 break; | 582 break; |
| 587 case CSS_EXS: | 583 case CSS_EXS: |
| 588 // FIXME: We have a bug right now where the zoom will be applied twi
ce to EX units. | 584 // FIXME: We have a bug right now where the zoom will be applied twi
ce to EX units. |
| 589 // We really need to compute EX using fontMetrics for the original s
pecifiedSize and not use | 585 // We really need to compute EX using fontMetrics for the original s
pecifiedSize and not use |
| 590 // our actual constructed rendering font. | 586 // our actual constructed rendering font. |
| 591 if (style.fontMetrics().hasXHeight()) | 587 if (style.fontMetrics().hasXHeight()) |
| 592 factor = style.fontMetrics().xHeight(); | 588 factor = style.fontMetrics().xHeight(); |
| 593 else | 589 else |
| 594 factor = (computingFontSize ? style.fontDescription().specifiedS
ize() : style.fontDescription().computedSize()) / 2.0; | 590 factor = (computingFontSize ? style.fontDescription().specifiedS
ize() : style.fontDescription().computedSize()) / 2.0; |
| 595 break; | 591 break; |
| 596 case CSS_REMS: | |
| 597 if (rootStyle) | |
| 598 factor = computingFontSize ? rootStyle->fontDescription().specif
iedSize() : rootStyle->fontDescription().computedSize(); | |
| 599 else | |
| 600 factor = 1.0; | |
| 601 break; | |
| 602 case CSS_CHS: | 592 case CSS_CHS: |
| 603 factor = style.fontMetrics().zeroWidth(); | 593 factor = style.fontMetrics().zeroWidth(); |
| 604 break; | 594 break; |
| 605 case CSS_PX: | 595 case CSS_PX: |
| 606 factor = 1.0; | 596 factor = 1.0; |
| 607 break; | 597 break; |
| 608 case CSS_CM: | 598 case CSS_CM: |
| 609 factor = cssPixelsPerCentimeter; | 599 factor = cssPixelsPerCentimeter; |
| 610 break; | 600 break; |
| 611 case CSS_MM: | 601 case CSS_MM: |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 case CSSPrimitiveValue::CSS_PT: | 823 case CSSPrimitiveValue::CSS_PT: |
| 834 case CSSPrimitiveValue::CSS_PC: | 824 case CSSPrimitiveValue::CSS_PC: |
| 835 lengthType = UnitTypePixels; | 825 lengthType = UnitTypePixels; |
| 836 return true; | 826 return true; |
| 837 case CSSPrimitiveValue::CSS_EMS: | 827 case CSSPrimitiveValue::CSS_EMS: |
| 838 lengthType = UnitTypeFontSize; | 828 lengthType = UnitTypeFontSize; |
| 839 return true; | 829 return true; |
| 840 case CSSPrimitiveValue::CSS_EXS: | 830 case CSSPrimitiveValue::CSS_EXS: |
| 841 lengthType = UnitTypeFontXSize; | 831 lengthType = UnitTypeFontXSize; |
| 842 return true; | 832 return true; |
| 843 case CSSPrimitiveValue::CSS_REMS: | |
| 844 lengthType = UnitTypeRootFontSize; | |
| 845 return true; | |
| 846 case CSSPrimitiveValue::CSS_CHS: | 833 case CSSPrimitiveValue::CSS_CHS: |
| 847 lengthType = UnitTypeZeroCharacterWidth; | 834 lengthType = UnitTypeZeroCharacterWidth; |
| 848 return true; | 835 return true; |
| 849 case CSSPrimitiveValue::CSS_PERCENTAGE: | 836 case CSSPrimitiveValue::CSS_PERCENTAGE: |
| 850 lengthType = UnitTypePercentage; | 837 lengthType = UnitTypePercentage; |
| 851 return true; | 838 return true; |
| 852 case CSSPrimitiveValue::CSS_VW: | 839 case CSSPrimitiveValue::CSS_VW: |
| 853 lengthType = UnitTypeViewportWidth; | 840 lengthType = UnitTypeViewportWidth; |
| 854 return true; | 841 return true; |
| 855 case CSSPrimitiveValue::CSS_VH: | 842 case CSSPrimitiveValue::CSS_VH: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 868 | 855 |
| 869 CSSPrimitiveValue::UnitType CSSPrimitiveValue::lengthUnitTypeToUnitType(LengthUn
itType type) | 856 CSSPrimitiveValue::UnitType CSSPrimitiveValue::lengthUnitTypeToUnitType(LengthUn
itType type) |
| 870 { | 857 { |
| 871 switch (type) { | 858 switch (type) { |
| 872 case UnitTypePixels: | 859 case UnitTypePixels: |
| 873 return CSSPrimitiveValue::CSS_PX; | 860 return CSSPrimitiveValue::CSS_PX; |
| 874 case UnitTypeFontSize: | 861 case UnitTypeFontSize: |
| 875 return CSSPrimitiveValue::CSS_EMS; | 862 return CSSPrimitiveValue::CSS_EMS; |
| 876 case UnitTypeFontXSize: | 863 case UnitTypeFontXSize: |
| 877 return CSSPrimitiveValue::CSS_EXS; | 864 return CSSPrimitiveValue::CSS_EXS; |
| 878 case UnitTypeRootFontSize: | |
| 879 return CSSPrimitiveValue::CSS_REMS; | |
| 880 case UnitTypeZeroCharacterWidth: | 865 case UnitTypeZeroCharacterWidth: |
| 881 return CSSPrimitiveValue::CSS_CHS; | 866 return CSSPrimitiveValue::CSS_CHS; |
| 882 case UnitTypePercentage: | 867 case UnitTypePercentage: |
| 883 return CSSPrimitiveValue::CSS_PERCENTAGE; | 868 return CSSPrimitiveValue::CSS_PERCENTAGE; |
| 884 case UnitTypeViewportWidth: | 869 case UnitTypeViewportWidth: |
| 885 return CSSPrimitiveValue::CSS_VW; | 870 return CSSPrimitiveValue::CSS_VW; |
| 886 case UnitTypeViewportHeight: | 871 case UnitTypeViewportHeight: |
| 887 return CSSPrimitiveValue::CSS_VH; | 872 return CSSPrimitiveValue::CSS_VH; |
| 888 case UnitTypeViewportMin: | 873 case UnitTypeViewportMin: |
| 889 return CSSPrimitiveValue::CSS_VMIN; | 874 return CSSPrimitiveValue::CSS_VMIN; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 { | 990 { |
| 1006 switch (type) { | 991 switch (type) { |
| 1007 case CSS_NUMBER: | 992 case CSS_NUMBER: |
| 1008 return ""; | 993 return ""; |
| 1009 case CSS_PERCENTAGE: | 994 case CSS_PERCENTAGE: |
| 1010 return "%"; | 995 return "%"; |
| 1011 case CSS_EMS: | 996 case CSS_EMS: |
| 1012 return "em"; | 997 return "em"; |
| 1013 case CSS_EXS: | 998 case CSS_EXS: |
| 1014 return "ex"; | 999 return "ex"; |
| 1015 case CSS_REMS: | |
| 1016 return "rem"; | |
| 1017 case CSS_CHS: | 1000 case CSS_CHS: |
| 1018 return "ch"; | 1001 return "ch"; |
| 1019 case CSS_PX: | 1002 case CSS_PX: |
| 1020 return "px"; | 1003 return "px"; |
| 1021 case CSS_CM: | 1004 case CSS_CM: |
| 1022 return "cm"; | 1005 return "cm"; |
| 1023 case CSS_DPPX: | 1006 case CSS_DPPX: |
| 1024 return "dppx"; | 1007 return "dppx"; |
| 1025 case CSS_DPI: | 1008 case CSS_DPI: |
| 1026 return "dpi"; | 1009 return "dpi"; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 | 1079 |
| 1097 String text; | 1080 String text; |
| 1098 switch (m_primitiveUnitType) { | 1081 switch (m_primitiveUnitType) { |
| 1099 case CSS_UNKNOWN: | 1082 case CSS_UNKNOWN: |
| 1100 // FIXME | 1083 // FIXME |
| 1101 break; | 1084 break; |
| 1102 case CSS_NUMBER: | 1085 case CSS_NUMBER: |
| 1103 case CSS_PERCENTAGE: | 1086 case CSS_PERCENTAGE: |
| 1104 case CSS_EMS: | 1087 case CSS_EMS: |
| 1105 case CSS_EXS: | 1088 case CSS_EXS: |
| 1106 case CSS_REMS: | |
| 1107 case CSS_CHS: | 1089 case CSS_CHS: |
| 1108 case CSS_PX: | 1090 case CSS_PX: |
| 1109 case CSS_CM: | 1091 case CSS_CM: |
| 1110 case CSS_DPPX: | 1092 case CSS_DPPX: |
| 1111 case CSS_DPI: | 1093 case CSS_DPI: |
| 1112 case CSS_DPCM: | 1094 case CSS_DPCM: |
| 1113 case CSS_MM: | 1095 case CSS_MM: |
| 1114 case CSS_IN: | 1096 case CSS_IN: |
| 1115 case CSS_PT: | 1097 case CSS_PT: |
| 1116 case CSS_PC: | 1098 case CSS_PC: |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 result = CSSPrimitiveValue::create(m_value.calc); | 1193 result = CSSPrimitiveValue::create(m_value.calc); |
| 1212 break; | 1194 break; |
| 1213 case CSS_SHAPE: | 1195 case CSS_SHAPE: |
| 1214 // CSSShapeValue is not exposed to the CSSOM, no need for a deep clone. | 1196 // CSSShapeValue is not exposed to the CSSOM, no need for a deep clone. |
| 1215 result = CSSPrimitiveValue::create(m_value.shape); | 1197 result = CSSPrimitiveValue::create(m_value.shape); |
| 1216 break; | 1198 break; |
| 1217 case CSS_NUMBER: | 1199 case CSS_NUMBER: |
| 1218 case CSS_PERCENTAGE: | 1200 case CSS_PERCENTAGE: |
| 1219 case CSS_EMS: | 1201 case CSS_EMS: |
| 1220 case CSS_EXS: | 1202 case CSS_EXS: |
| 1221 case CSS_REMS: | |
| 1222 case CSS_CHS: | 1203 case CSS_CHS: |
| 1223 case CSS_PX: | 1204 case CSS_PX: |
| 1224 case CSS_CM: | 1205 case CSS_CM: |
| 1225 case CSS_MM: | 1206 case CSS_MM: |
| 1226 case CSS_IN: | 1207 case CSS_IN: |
| 1227 case CSS_PT: | 1208 case CSS_PT: |
| 1228 case CSS_PC: | 1209 case CSS_PC: |
| 1229 case CSS_DEG: | 1210 case CSS_DEG: |
| 1230 case CSS_RAD: | 1211 case CSS_RAD: |
| 1231 case CSS_GRAD: | 1212 case CSS_GRAD: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 if (m_primitiveUnitType != other.m_primitiveUnitType) | 1251 if (m_primitiveUnitType != other.m_primitiveUnitType) |
| 1271 return false; | 1252 return false; |
| 1272 | 1253 |
| 1273 switch (m_primitiveUnitType) { | 1254 switch (m_primitiveUnitType) { |
| 1274 case CSS_UNKNOWN: | 1255 case CSS_UNKNOWN: |
| 1275 return false; | 1256 return false; |
| 1276 case CSS_NUMBER: | 1257 case CSS_NUMBER: |
| 1277 case CSS_PERCENTAGE: | 1258 case CSS_PERCENTAGE: |
| 1278 case CSS_EMS: | 1259 case CSS_EMS: |
| 1279 case CSS_EXS: | 1260 case CSS_EXS: |
| 1280 case CSS_REMS: | |
| 1281 case CSS_PX: | 1261 case CSS_PX: |
| 1282 case CSS_CM: | 1262 case CSS_CM: |
| 1283 case CSS_DPPX: | 1263 case CSS_DPPX: |
| 1284 case CSS_DPI: | 1264 case CSS_DPI: |
| 1285 case CSS_DPCM: | 1265 case CSS_DPCM: |
| 1286 case CSS_MM: | 1266 case CSS_MM: |
| 1287 case CSS_IN: | 1267 case CSS_IN: |
| 1288 case CSS_PT: | 1268 case CSS_PT: |
| 1289 case CSS_PC: | 1269 case CSS_PC: |
| 1290 case CSS_DEG: | 1270 case CSS_DEG: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1321 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); | 1301 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); |
| 1322 case CSS_CALC: | 1302 case CSS_CALC: |
| 1323 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1303 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 1324 case CSS_SHAPE: | 1304 case CSS_SHAPE: |
| 1325 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1305 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
| 1326 } | 1306 } |
| 1327 return false; | 1307 return false; |
| 1328 } | 1308 } |
| 1329 | 1309 |
| 1330 } // namespace blink | 1310 } // namespace blink |
| OLD | NEW |