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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 case CSS_S: | 133 case CSS_S: |
134 return CSSPrimitiveValue::UTime; | 134 return CSSPrimitiveValue::UTime; |
135 case CSS_DEG: | 135 case CSS_DEG: |
136 case CSS_RAD: | 136 case CSS_RAD: |
137 case CSS_GRAD: | 137 case CSS_GRAD: |
138 case CSS_TURN: | 138 case CSS_TURN: |
139 return CSSPrimitiveValue::UAngle; | 139 return CSSPrimitiveValue::UAngle; |
140 case CSS_HZ: | 140 case CSS_HZ: |
141 case CSS_KHZ: | 141 case CSS_KHZ: |
142 return CSSPrimitiveValue::UFrequency; | 142 return CSSPrimitiveValue::UFrequency; |
143 case CSS_VW: | |
144 case CSS_VH: | |
145 case CSS_VMIN: | |
146 case CSS_VMAX: | |
147 return CSSPrimitiveValue::UViewportPercentageLength; | |
148 case CSS_DPPX: | 143 case CSS_DPPX: |
149 case CSS_DPI: | 144 case CSS_DPI: |
150 case CSS_DPCM: | 145 case CSS_DPCM: |
151 return CSSPrimitiveValue::UResolution; | 146 return CSSPrimitiveValue::UResolution; |
152 default: | 147 default: |
153 return CSSPrimitiveValue::UOther; | 148 return CSSPrimitiveValue::UOther; |
154 } | 149 } |
155 } | 150 } |
156 | 151 |
157 bool CSSPrimitiveValue::colorIsDerivedFromElement() const | 152 bool CSSPrimitiveValue::colorIsDerivedFromElement() const |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 switch (length.type()) { | 274 switch (length.type()) { |
280 case Auto: | 275 case Auto: |
281 case Intrinsic: | 276 case Intrinsic: |
282 case MinIntrinsic: | 277 case MinIntrinsic: |
283 case MinContent: | 278 case MinContent: |
284 case MaxContent: | 279 case MaxContent: |
285 case FillAvailable: | 280 case FillAvailable: |
286 case FitContent: | 281 case FitContent: |
287 case ExtendToZoom: | 282 case ExtendToZoom: |
288 case Percent: | 283 case Percent: |
289 case ViewportPercentageWidth: | |
290 case ViewportPercentageHeight: | |
291 case ViewportPercentageMin: | |
292 case ViewportPercentageMax: | |
293 init(length); | 284 init(length); |
294 return; | 285 return; |
295 case Fixed: | 286 case Fixed: |
296 m_primitiveUnitType = CSS_PX; | 287 m_primitiveUnitType = CSS_PX; |
297 m_value.num = length.value() / zoom; | 288 m_value.num = length.value() / zoom; |
298 return; | 289 return; |
299 case Calculated: | 290 case Calculated: |
300 init(CSSCalcValue::create(length.calculationValue(), zoom)); | 291 init(CSSCalcValue::create(length.calculationValue(), zoom)); |
301 return; | 292 return; |
| 293 case DeviceWidth: |
| 294 case DeviceHeight: |
302 case Undefined: | 295 case Undefined: |
303 ASSERT_NOT_REACHED(); | 296 ASSERT_NOT_REACHED(); |
304 break; | 297 break; |
305 } | 298 } |
306 } | 299 } |
307 | 300 |
308 void CSSPrimitiveValue::init(const Length& length) | 301 void CSSPrimitiveValue::init(const Length& length) |
309 { | 302 { |
310 switch (length.type()) { | 303 switch (length.type()) { |
311 case Auto: | 304 case Auto: |
(...skipping 30 matching lines...) Expand all Loading... |
342 break; | 335 break; |
343 case ExtendToZoom: | 336 case ExtendToZoom: |
344 m_primitiveUnitType = CSS_VALUE_ID; | 337 m_primitiveUnitType = CSS_VALUE_ID; |
345 m_value.valueID = CSSValueInternalExtendToZoom; | 338 m_value.valueID = CSSValueInternalExtendToZoom; |
346 break; | 339 break; |
347 case Percent: | 340 case Percent: |
348 m_primitiveUnitType = CSS_PERCENTAGE; | 341 m_primitiveUnitType = CSS_PERCENTAGE; |
349 ASSERT(std::isfinite(length.percent())); | 342 ASSERT(std::isfinite(length.percent())); |
350 m_value.num = length.percent(); | 343 m_value.num = length.percent(); |
351 break; | 344 break; |
352 case ViewportPercentageWidth: | 345 case DeviceWidth: |
353 m_primitiveUnitType = CSS_VW; | 346 case DeviceHeight: |
354 m_value.num = length.viewportPercentageLength(); | |
355 break; | |
356 case ViewportPercentageHeight: | |
357 m_primitiveUnitType = CSS_VH; | |
358 m_value.num = length.viewportPercentageLength(); | |
359 break; | |
360 case ViewportPercentageMin: | |
361 m_primitiveUnitType = CSS_VMIN; | |
362 m_value.num = length.viewportPercentageLength(); | |
363 break; | |
364 case ViewportPercentageMax: | |
365 m_primitiveUnitType = CSS_VMAX; | |
366 m_value.num = length.viewportPercentageLength(); | |
367 break; | |
368 case Calculated: | 347 case Calculated: |
369 case Undefined: | 348 case Undefined: |
370 ASSERT_NOT_REACHED(); | 349 ASSERT_NOT_REACHED(); |
371 break; | 350 break; |
372 } | 351 } |
373 } | 352 } |
374 | 353 |
375 void CSSPrimitiveValue::init(PassRefPtr<Counter> c) | 354 void CSSPrimitiveValue::init(PassRefPtr<Counter> c) |
376 { | 355 { |
377 m_primitiveUnitType = CSS_COUNTER; | 356 m_primitiveUnitType = CSS_COUNTER; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 break; | 572 break; |
594 case CSS_IN: | 573 case CSS_IN: |
595 factor = cssPixelsPerInch; | 574 factor = cssPixelsPerInch; |
596 break; | 575 break; |
597 case CSS_PT: | 576 case CSS_PT: |
598 factor = cssPixelsPerPoint; | 577 factor = cssPixelsPerPoint; |
599 break; | 578 break; |
600 case CSS_PC: | 579 case CSS_PC: |
601 factor = cssPixelsPerPica; | 580 factor = cssPixelsPerPica; |
602 break; | 581 break; |
| 582 case CSS_VW: |
| 583 factor = conversionData.viewportWidthPercent(); |
| 584 break; |
| 585 case CSS_VH: |
| 586 factor = conversionData.viewportHeightPercent(); |
| 587 break; |
| 588 case CSS_VMIN: |
| 589 factor = conversionData.viewportMinPercent(); |
| 590 break; |
| 591 case CSS_VMAX: |
| 592 factor = conversionData.viewportMaxPercent(); |
| 593 break; |
603 case CSS_CALC_PERCENTAGE_WITH_LENGTH: | 594 case CSS_CALC_PERCENTAGE_WITH_LENGTH: |
604 case CSS_CALC_PERCENTAGE_WITH_NUMBER: | 595 case CSS_CALC_PERCENTAGE_WITH_NUMBER: |
605 ASSERT_NOT_REACHED(); | 596 ASSERT_NOT_REACHED(); |
606 return -1.0; | 597 return -1.0; |
607 default: | 598 default: |
608 ASSERT_NOT_REACHED(); | 599 ASSERT_NOT_REACHED(); |
609 return -1.0; | 600 return -1.0; |
610 } | 601 } |
611 | 602 |
612 // We do not apply the zoom factor when we are computing the value of the fo
nt-size property. The zooming | 603 // We do not apply the zoom factor when we are computing the value of the fo
nt-size property. The zooming |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 case ULength: | 704 case ULength: |
714 return CSS_PX; | 705 return CSS_PX; |
715 case UPercent: | 706 case UPercent: |
716 return CSS_UNKNOWN; // Cannot convert between numbers and percent. | 707 return CSS_UNKNOWN; // Cannot convert between numbers and percent. |
717 case UTime: | 708 case UTime: |
718 return CSS_MS; | 709 return CSS_MS; |
719 case UAngle: | 710 case UAngle: |
720 return CSS_DEG; | 711 return CSS_DEG; |
721 case UFrequency: | 712 case UFrequency: |
722 return CSS_HZ; | 713 return CSS_HZ; |
723 case UViewportPercentageLength: | |
724 return CSS_UNKNOWN; // Cannot convert between numbers and relative lengt
hs. | |
725 case UResolution: | 714 case UResolution: |
726 return CSS_DPPX; | 715 return CSS_DPPX; |
727 default: | 716 default: |
728 return CSS_UNKNOWN; | 717 return CSS_UNKNOWN; |
729 } | 718 } |
730 } | 719 } |
731 | 720 |
732 bool CSSPrimitiveValue::getDoubleValueInternal(UnitTypes requestedUnitType, doub
le* result) const | 721 bool CSSPrimitiveValue::getDoubleValueInternal(UnitTypes requestedUnitType, doub
le* result) const |
733 { | 722 { |
734 if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitTypes>(m_primitiv
eUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType)) | 723 if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitTypes>(m_primitiv
eUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType)) |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 return pairValue->hasVariableReference(); | 1109 return pairValue->hasVariableReference(); |
1121 if (Quad* quadValue = getQuadValue()) | 1110 if (Quad* quadValue = getQuadValue()) |
1122 return quadValue->hasVariableReference(); | 1111 return quadValue->hasVariableReference(); |
1123 if (Rect* rectValue = getRectValue()) | 1112 if (Rect* rectValue = getRectValue()) |
1124 return rectValue->hasVariableReference(); | 1113 return rectValue->hasVariableReference(); |
1125 if (CSSBasicShape* shapeValue = getShapeValue()) | 1114 if (CSSBasicShape* shapeValue = getShapeValue()) |
1126 return shapeValue->hasVariableReference(); | 1115 return shapeValue->hasVariableReference(); |
1127 return isVariableName(); | 1116 return isVariableName(); |
1128 } | 1117 } |
1129 | 1118 |
1130 Length CSSPrimitiveValue::viewportPercentageLength() | |
1131 { | |
1132 ASSERT(isViewportPercentageLength()); | |
1133 Length viewportLength; | |
1134 switch (m_primitiveUnitType) { | |
1135 case CSS_VW: | |
1136 viewportLength = Length(getDoubleValue(), ViewportPercentageWidth); | |
1137 break; | |
1138 case CSS_VH: | |
1139 viewportLength = Length(getDoubleValue(), ViewportPercentageHeight); | |
1140 break; | |
1141 case CSS_VMIN: | |
1142 viewportLength = Length(getDoubleValue(), ViewportPercentageMin); | |
1143 break; | |
1144 case CSS_VMAX: | |
1145 viewportLength = Length(getDoubleValue(), ViewportPercentageMax); | |
1146 break; | |
1147 default: | |
1148 break; | |
1149 } | |
1150 return viewportLength; | |
1151 } | |
1152 | |
1153 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const | 1119 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const |
1154 { | 1120 { |
1155 RefPtr<CSSPrimitiveValue> result; | 1121 RefPtr<CSSPrimitiveValue> result; |
1156 | 1122 |
1157 switch (m_primitiveUnitType) { | 1123 switch (m_primitiveUnitType) { |
1158 case CSS_STRING: | 1124 case CSS_STRING: |
1159 case CSS_URI: | 1125 case CSS_URI: |
1160 case CSS_ATTR: | 1126 case CSS_ATTR: |
1161 case CSS_COUNTER_NAME: | 1127 case CSS_COUNTER_NAME: |
1162 result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitTypes
>(m_primitiveUnitType)); | 1128 result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitTypes
>(m_primitiveUnitType)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 return m_value.parserOperator == other.m_value.parserOperator; | 1266 return m_value.parserOperator == other.m_value.parserOperator; |
1301 case CSS_CALC: | 1267 case CSS_CALC: |
1302 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1268 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
1303 case CSS_SHAPE: | 1269 case CSS_SHAPE: |
1304 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1270 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
1305 } | 1271 } |
1306 return false; | 1272 return false; |
1307 } | 1273 } |
1308 | 1274 |
1309 } // namespace WebCore | 1275 } // namespace WebCore |
OLD | NEW |