| 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 28 matching lines...) Expand all Loading... |
| 39 #include "Rect.h" | 39 #include "Rect.h" |
| 40 #include "RenderStyle.h" | 40 #include "RenderStyle.h" |
| 41 #include "StyleSheetContents.h" | 41 #include "StyleSheetContents.h" |
| 42 #include "WebCoreMemoryInstrumentation.h" | 42 #include "WebCoreMemoryInstrumentation.h" |
| 43 #include <wtf/ASCIICType.h> | 43 #include <wtf/ASCIICType.h> |
| 44 #include <wtf/DecimalNumber.h> | 44 #include <wtf/DecimalNumber.h> |
| 45 #include <wtf/StdLibExtras.h> | 45 #include <wtf/StdLibExtras.h> |
| 46 #include <wtf/text/StringBuffer.h> | 46 #include <wtf/text/StringBuffer.h> |
| 47 #include <wtf/text/StringBuilder.h> | 47 #include <wtf/text/StringBuilder.h> |
| 48 | 48 |
| 49 #if ENABLE(DASHBOARD_SUPPORT) | |
| 50 #include "DashboardRegion.h" | |
| 51 #endif | |
| 52 | |
| 53 using namespace WTF; | 49 using namespace WTF; |
| 54 | 50 |
| 55 namespace WebCore { | 51 namespace WebCore { |
| 56 | 52 |
| 57 // Max/min values for CSS, needs to slightly smaller/larger than the true max/mi
n values to allow for rounding without overflowing. | 53 // Max/min values for CSS, needs to slightly smaller/larger than the true max/mi
n values to allow for rounding without overflowing. |
| 58 // Subtract two (rather than one) to allow for values to be converted to float a
nd back without exceeding the LayoutUnit::max. | 54 // Subtract two (rather than one) to allow for values to be converted to float a
nd back without exceeding the LayoutUnit::max. |
| 59 const int maxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; | 55 const int maxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; |
| 60 const int minValueForCssLength = INT_MIN / kFixedPointDenominator + 2; | 56 const int minValueForCssLength = INT_MIN / kFixedPointDenominator + 2; |
| 61 | 57 |
| 62 static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit
Types unitType) | 58 static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit
Types unitType) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 92 case CSSPrimitiveValue::CSS_S: | 88 case CSSPrimitiveValue::CSS_S: |
| 93 case CSSPrimitiveValue::CSS_TURN: | 89 case CSSPrimitiveValue::CSS_TURN: |
| 94 case CSSPrimitiveValue::CSS_VW: | 90 case CSSPrimitiveValue::CSS_VW: |
| 95 case CSSPrimitiveValue::CSS_VH: | 91 case CSSPrimitiveValue::CSS_VH: |
| 96 case CSSPrimitiveValue::CSS_VMIN: | 92 case CSSPrimitiveValue::CSS_VMIN: |
| 97 case CSSPrimitiveValue::CSS_VMAX: | 93 case CSSPrimitiveValue::CSS_VMAX: |
| 98 return true; | 94 return true; |
| 99 case CSSPrimitiveValue::CSS_ATTR: | 95 case CSSPrimitiveValue::CSS_ATTR: |
| 100 case CSSPrimitiveValue::CSS_COUNTER: | 96 case CSSPrimitiveValue::CSS_COUNTER: |
| 101 case CSSPrimitiveValue::CSS_COUNTER_NAME: | 97 case CSSPrimitiveValue::CSS_COUNTER_NAME: |
| 102 #if ENABLE(DASHBOARD_SUPPORT) | |
| 103 case CSSPrimitiveValue::CSS_DASHBOARD_REGION: | |
| 104 #endif | |
| 105 #if !ENABLE(CSS_IMAGE_RESOLUTION) && !ENABLE(RESOLUTION_MEDIA_QUERY) | 98 #if !ENABLE(CSS_IMAGE_RESOLUTION) && !ENABLE(RESOLUTION_MEDIA_QUERY) |
| 106 case CSSPrimitiveValue::CSS_DPPX: | 99 case CSSPrimitiveValue::CSS_DPPX: |
| 107 case CSSPrimitiveValue::CSS_DPI: | 100 case CSSPrimitiveValue::CSS_DPI: |
| 108 case CSSPrimitiveValue::CSS_DPCM: | 101 case CSSPrimitiveValue::CSS_DPCM: |
| 109 #endif | 102 #endif |
| 110 case CSSPrimitiveValue::CSS_IDENT: | 103 case CSSPrimitiveValue::CSS_IDENT: |
| 111 case CSSPrimitiveValue::CSS_PAIR: | 104 case CSSPrimitiveValue::CSS_PAIR: |
| 112 case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR: | 105 case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR: |
| 113 case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER: | 106 case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER: |
| 114 case CSSPrimitiveValue::CSS_PARSER_INTEGER: | 107 case CSSPrimitiveValue::CSS_PARSER_INTEGER: |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 m_value.rect = r.leakRef(); | 329 m_value.rect = r.leakRef(); |
| 337 } | 330 } |
| 338 | 331 |
| 339 void CSSPrimitiveValue::init(PassRefPtr<Quad> quad) | 332 void CSSPrimitiveValue::init(PassRefPtr<Quad> quad) |
| 340 { | 333 { |
| 341 m_primitiveUnitType = CSS_QUAD; | 334 m_primitiveUnitType = CSS_QUAD; |
| 342 m_hasCachedCSSText = false; | 335 m_hasCachedCSSText = false; |
| 343 m_value.quad = quad.leakRef(); | 336 m_value.quad = quad.leakRef(); |
| 344 } | 337 } |
| 345 | 338 |
| 346 #if ENABLE(DASHBOARD_SUPPORT) | |
| 347 void CSSPrimitiveValue::init(PassRefPtr<DashboardRegion> r) | |
| 348 { | |
| 349 m_primitiveUnitType = CSS_DASHBOARD_REGION; | |
| 350 m_hasCachedCSSText = false; | |
| 351 m_value.region = r.leakRef(); | |
| 352 } | |
| 353 #endif | |
| 354 | |
| 355 void CSSPrimitiveValue::init(PassRefPtr<Pair> p) | 339 void CSSPrimitiveValue::init(PassRefPtr<Pair> p) |
| 356 { | 340 { |
| 357 m_primitiveUnitType = CSS_PAIR; | 341 m_primitiveUnitType = CSS_PAIR; |
| 358 m_hasCachedCSSText = false; | 342 m_hasCachedCSSText = false; |
| 359 m_value.pair = p.leakRef(); | 343 m_value.pair = p.leakRef(); |
| 360 } | 344 } |
| 361 | 345 |
| 362 void CSSPrimitiveValue::init(PassRefPtr<CSSCalcValue> c) | 346 void CSSPrimitiveValue::init(PassRefPtr<CSSCalcValue> c) |
| 363 { | 347 { |
| 364 m_primitiveUnitType = CSS_CALC; | 348 m_primitiveUnitType = CSS_CALC; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 break; | 381 break; |
| 398 case CSS_RECT: | 382 case CSS_RECT: |
| 399 m_value.rect->deref(); | 383 m_value.rect->deref(); |
| 400 break; | 384 break; |
| 401 case CSS_QUAD: | 385 case CSS_QUAD: |
| 402 m_value.quad->deref(); | 386 m_value.quad->deref(); |
| 403 break; | 387 break; |
| 404 case CSS_PAIR: | 388 case CSS_PAIR: |
| 405 m_value.pair->deref(); | 389 m_value.pair->deref(); |
| 406 break; | 390 break; |
| 407 #if ENABLE(DASHBOARD_SUPPORT) | |
| 408 case CSS_DASHBOARD_REGION: | |
| 409 if (m_value.region) | |
| 410 m_value.region->deref(); | |
| 411 break; | |
| 412 #endif | |
| 413 case CSS_CALC: | 391 case CSS_CALC: |
| 414 m_value.calc->deref(); | 392 m_value.calc->deref(); |
| 415 break; | 393 break; |
| 416 case CSS_CALC_PERCENTAGE_WITH_NUMBER: | 394 case CSS_CALC_PERCENTAGE_WITH_NUMBER: |
| 417 case CSS_CALC_PERCENTAGE_WITH_LENGTH: | 395 case CSS_CALC_PERCENTAGE_WITH_LENGTH: |
| 418 ASSERT_NOT_REACHED(); | 396 ASSERT_NOT_REACHED(); |
| 419 break; | 397 break; |
| 420 case CSS_SHAPE: | 398 case CSS_SHAPE: |
| 421 m_value.shape->deref(); | 399 m_value.shape->deref(); |
| 422 break; | 400 break; |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 result.append(alphaString, strlen(alphaString)); | 1020 result.append(alphaString, strlen(alphaString)); |
| 1043 } | 1021 } |
| 1044 | 1022 |
| 1045 result.append(')'); | 1023 result.append(')'); |
| 1046 text = String::adopt(result); | 1024 text = String::adopt(result); |
| 1047 break; | 1025 break; |
| 1048 } | 1026 } |
| 1049 case CSS_PAIR: | 1027 case CSS_PAIR: |
| 1050 text = getPairValue()->cssText(); | 1028 text = getPairValue()->cssText(); |
| 1051 break; | 1029 break; |
| 1052 #if ENABLE(DASHBOARD_SUPPORT) | |
| 1053 case CSS_DASHBOARD_REGION: { | |
| 1054 StringBuilder result; | |
| 1055 for (DashboardRegion* region = getDashboardRegionValue(); region; re
gion = region->m_next.get()) { | |
| 1056 if (!result.isEmpty()) | |
| 1057 result.append(' '); | |
| 1058 result.appendLiteral("dashboard-region("); | |
| 1059 result.append(region->m_label); | |
| 1060 if (region->m_isCircle) | |
| 1061 result.appendLiteral(" circle"); | |
| 1062 else if (region->m_isRectangle) | |
| 1063 result.appendLiteral(" rectangle"); | |
| 1064 else | |
| 1065 break; | |
| 1066 if (region->top()->m_primitiveUnitType == CSS_IDENT && region->t
op()->getIdent() == CSSValueInvalid) { | |
| 1067 ASSERT(region->right()->m_primitiveUnitType == CSS_IDENT); | |
| 1068 ASSERT(region->bottom()->m_primitiveUnitType == CSS_IDENT); | |
| 1069 ASSERT(region->left()->m_primitiveUnitType == CSS_IDENT); | |
| 1070 ASSERT(region->right()->getIdent() == CSSValueInvalid); | |
| 1071 ASSERT(region->bottom()->getIdent() == CSSValueInvalid); | |
| 1072 ASSERT(region->left()->getIdent() == CSSValueInvalid); | |
| 1073 } else { | |
| 1074 result.append(' '); | |
| 1075 result.append(region->top()->cssText()); | |
| 1076 result.append(' '); | |
| 1077 result.append(region->right()->cssText()); | |
| 1078 result.append(' '); | |
| 1079 result.append(region->bottom()->cssText()); | |
| 1080 result.append(' '); | |
| 1081 result.append(region->left()->cssText()); | |
| 1082 } | |
| 1083 result.append(')'); | |
| 1084 } | |
| 1085 text = result.toString(); | |
| 1086 break; | |
| 1087 } | |
| 1088 #endif | |
| 1089 case CSS_PARSER_OPERATOR: { | 1030 case CSS_PARSER_OPERATOR: { |
| 1090 char c = static_cast<char>(m_value.ident); | 1031 char c = static_cast<char>(m_value.ident); |
| 1091 text = String(&c, 1U); | 1032 text = String(&c, 1U); |
| 1092 break; | 1033 break; |
| 1093 } | 1034 } |
| 1094 case CSS_PARSER_IDENTIFIER: | 1035 case CSS_PARSER_IDENTIFIER: |
| 1095 text = quoteCSSStringIfNeeded(m_value.string); | 1036 text = quoteCSSStringIfNeeded(m_value.string); |
| 1096 break; | 1037 break; |
| 1097 case CSS_CALC: | 1038 case CSS_CALC: |
| 1098 text = m_value.calc->cssText(); | 1039 text = m_value.calc->cssText(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 case CSS_RECT: | 1146 case CSS_RECT: |
| 1206 result = CSSPrimitiveValue::create(m_value.rect->cloneForCSSOM()); | 1147 result = CSSPrimitiveValue::create(m_value.rect->cloneForCSSOM()); |
| 1207 break; | 1148 break; |
| 1208 case CSS_QUAD: | 1149 case CSS_QUAD: |
| 1209 result = CSSPrimitiveValue::create(m_value.quad->cloneForCSSOM()); | 1150 result = CSSPrimitiveValue::create(m_value.quad->cloneForCSSOM()); |
| 1210 break; | 1151 break; |
| 1211 case CSS_PAIR: | 1152 case CSS_PAIR: |
| 1212 // Pair is not exposed to the CSSOM, no need for a deep clone. | 1153 // Pair is not exposed to the CSSOM, no need for a deep clone. |
| 1213 result = CSSPrimitiveValue::create(m_value.pair); | 1154 result = CSSPrimitiveValue::create(m_value.pair); |
| 1214 break; | 1155 break; |
| 1215 #if ENABLE(DASHBOARD_SUPPORT) | |
| 1216 case CSS_DASHBOARD_REGION: | |
| 1217 // DashboardRegion is not exposed to the CSSOM, no need for a deep clone
. | |
| 1218 result = CSSPrimitiveValue::create(m_value.region); | |
| 1219 break; | |
| 1220 #endif | |
| 1221 case CSS_CALC: | 1156 case CSS_CALC: |
| 1222 // CSSCalcValue is not exposed to the CSSOM, no need for a deep clone. | 1157 // CSSCalcValue is not exposed to the CSSOM, no need for a deep clone. |
| 1223 result = CSSPrimitiveValue::create(m_value.calc); | 1158 result = CSSPrimitiveValue::create(m_value.calc); |
| 1224 break; | 1159 break; |
| 1225 case CSS_SHAPE: | 1160 case CSS_SHAPE: |
| 1226 // CSSShapeValue is not exposed to the CSSOM, no need for a deep clone. | 1161 // CSSShapeValue is not exposed to the CSSOM, no need for a deep clone. |
| 1227 result = CSSPrimitiveValue::create(m_value.shape); | 1162 result = CSSPrimitiveValue::create(m_value.shape); |
| 1228 break; | 1163 break; |
| 1229 case CSS_NUMBER: | 1164 case CSS_NUMBER: |
| 1230 case CSS_PARSER_INTEGER: | 1165 case CSS_PARSER_INTEGER: |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 case CSS_COUNTER: | 1266 case CSS_COUNTER: |
| 1332 return m_value.counter && other.m_value.counter && m_value.counter->equa
ls(*other.m_value.counter); | 1267 return m_value.counter && other.m_value.counter && m_value.counter->equa
ls(*other.m_value.counter); |
| 1333 case CSS_RECT: | 1268 case CSS_RECT: |
| 1334 return m_value.rect && other.m_value.rect && m_value.rect->equals(*other
.m_value.rect); | 1269 return m_value.rect && other.m_value.rect && m_value.rect->equals(*other
.m_value.rect); |
| 1335 case CSS_QUAD: | 1270 case CSS_QUAD: |
| 1336 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other
.m_value.quad); | 1271 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other
.m_value.quad); |
| 1337 case CSS_RGBCOLOR: | 1272 case CSS_RGBCOLOR: |
| 1338 return m_value.rgbcolor == other.m_value.rgbcolor; | 1273 return m_value.rgbcolor == other.m_value.rgbcolor; |
| 1339 case CSS_PAIR: | 1274 case CSS_PAIR: |
| 1340 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); | 1275 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); |
| 1341 #if ENABLE(DASHBOARD_SUPPORT) | |
| 1342 case CSS_DASHBOARD_REGION: { | |
| 1343 DashboardRegion* region = getDashboardRegionValue(); | |
| 1344 DashboardRegion* otherRegion = other.getDashboardRegionValue(); | |
| 1345 return region ? otherRegion && region->equals(*otherRegion) : !otherRegi
on; | |
| 1346 } | |
| 1347 #endif | |
| 1348 case CSS_PARSER_OPERATOR: | 1276 case CSS_PARSER_OPERATOR: |
| 1349 return m_value.ident == other.m_value.ident; | 1277 return m_value.ident == other.m_value.ident; |
| 1350 case CSS_CALC: | 1278 case CSS_CALC: |
| 1351 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1279 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
| 1352 case CSS_SHAPE: | 1280 case CSS_SHAPE: |
| 1353 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1281 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
| 1354 } | 1282 } |
| 1355 return false; | 1283 return false; |
| 1356 } | 1284 } |
| 1357 | 1285 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1376 break; | 1304 break; |
| 1377 case CSS_RECT: | 1305 case CSS_RECT: |
| 1378 info.addMember(m_value.rect, "value.rect"); | 1306 info.addMember(m_value.rect, "value.rect"); |
| 1379 break; | 1307 break; |
| 1380 case CSS_QUAD: | 1308 case CSS_QUAD: |
| 1381 info.addMember(m_value.quad, "value.quad"); | 1309 info.addMember(m_value.quad, "value.quad"); |
| 1382 break; | 1310 break; |
| 1383 case CSS_PAIR: | 1311 case CSS_PAIR: |
| 1384 info.addMember(m_value.pair, "value.pair"); | 1312 info.addMember(m_value.pair, "value.pair"); |
| 1385 break; | 1313 break; |
| 1386 #if ENABLE(DASHBOARD_SUPPORT) | |
| 1387 case CSS_DASHBOARD_REGION: | |
| 1388 info.addMember(m_value.region, "value.region"); | |
| 1389 break; | |
| 1390 #endif | |
| 1391 case CSS_SHAPE: | 1314 case CSS_SHAPE: |
| 1392 info.addMember(m_value.shape, "value.shape"); | 1315 info.addMember(m_value.shape, "value.shape"); |
| 1393 break; | 1316 break; |
| 1394 case CSS_CALC: | 1317 case CSS_CALC: |
| 1395 info.addMember(m_value.calc, "value.calc"); | 1318 info.addMember(m_value.calc, "value.calc"); |
| 1396 break; | 1319 break; |
| 1397 default: | 1320 default: |
| 1398 break; | 1321 break; |
| 1399 } | 1322 } |
| 1400 } | 1323 } |
| 1401 | 1324 |
| 1402 } // namespace WebCore | 1325 } // namespace WebCore |
| OLD | NEW |