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; |
302 case Undefined: | 293 case Undefined: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 break; | 333 break; |
343 case ExtendToZoom: | 334 case ExtendToZoom: |
344 m_primitiveUnitType = CSS_VALUE_ID; | 335 m_primitiveUnitType = CSS_VALUE_ID; |
345 m_value.valueID = CSSValueInternalExtendToZoom; | 336 m_value.valueID = CSSValueInternalExtendToZoom; |
346 break; | 337 break; |
347 case Percent: | 338 case Percent: |
348 m_primitiveUnitType = CSS_PERCENTAGE; | 339 m_primitiveUnitType = CSS_PERCENTAGE; |
349 ASSERT(std::isfinite(length.percent())); | 340 ASSERT(std::isfinite(length.percent())); |
350 m_value.num = length.percent(); | 341 m_value.num = length.percent(); |
351 break; | 342 break; |
352 case ViewportPercentageWidth: | |
353 m_primitiveUnitType = CSS_VW; | |
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: | 343 case Calculated: |
369 case Undefined: | 344 case Undefined: |
370 ASSERT_NOT_REACHED(); | 345 ASSERT_NOT_REACHED(); |
371 break; | 346 break; |
372 } | 347 } |
373 } | 348 } |
374 | 349 |
375 void CSSPrimitiveValue::init(PassRefPtr<Counter> c) | 350 void CSSPrimitiveValue::init(PassRefPtr<Counter> c) |
376 { | 351 { |
377 m_primitiveUnitType = CSS_COUNTER; | 352 m_primitiveUnitType = CSS_COUNTER; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 break; | 568 break; |
594 case CSS_IN: | 569 case CSS_IN: |
595 factor = cssPixelsPerInch; | 570 factor = cssPixelsPerInch; |
596 break; | 571 break; |
597 case CSS_PT: | 572 case CSS_PT: |
598 factor = cssPixelsPerPoint; | 573 factor = cssPixelsPerPoint; |
599 break; | 574 break; |
600 case CSS_PC: | 575 case CSS_PC: |
601 factor = cssPixelsPerPica; | 576 factor = cssPixelsPerPica; |
602 break; | 577 break; |
| 578 case CSS_VW: |
| 579 factor = conversionData.viewportWidthPercent(); |
| 580 break; |
| 581 case CSS_VH: |
| 582 factor = conversionData.viewportHeightPercent(); |
| 583 break; |
| 584 case CSS_VMIN: |
| 585 factor = conversionData.viewportMinPercent(); |
| 586 break; |
| 587 case CSS_VMAX: |
| 588 factor = conversionData.viewportMaxPercent(); |
| 589 break; |
603 case CSS_CALC_PERCENTAGE_WITH_LENGTH: | 590 case CSS_CALC_PERCENTAGE_WITH_LENGTH: |
604 case CSS_CALC_PERCENTAGE_WITH_NUMBER: | 591 case CSS_CALC_PERCENTAGE_WITH_NUMBER: |
605 ASSERT_NOT_REACHED(); | 592 ASSERT_NOT_REACHED(); |
606 return -1.0; | 593 return -1.0; |
607 default: | 594 default: |
608 ASSERT_NOT_REACHED(); | 595 ASSERT_NOT_REACHED(); |
609 return -1.0; | 596 return -1.0; |
610 } | 597 } |
611 | 598 |
612 // We do not apply the zoom factor when we are computing the value of the fo
nt-size property. The zooming | 599 // 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: | 700 case ULength: |
714 return CSS_PX; | 701 return CSS_PX; |
715 case UPercent: | 702 case UPercent: |
716 return CSS_UNKNOWN; // Cannot convert between numbers and percent. | 703 return CSS_UNKNOWN; // Cannot convert between numbers and percent. |
717 case UTime: | 704 case UTime: |
718 return CSS_MS; | 705 return CSS_MS; |
719 case UAngle: | 706 case UAngle: |
720 return CSS_DEG; | 707 return CSS_DEG; |
721 case UFrequency: | 708 case UFrequency: |
722 return CSS_HZ; | 709 return CSS_HZ; |
723 case UViewportPercentageLength: | |
724 return CSS_UNKNOWN; // Cannot convert between numbers and relative lengt
hs. | |
725 case UResolution: | 710 case UResolution: |
726 return CSS_DPPX; | 711 return CSS_DPPX; |
727 default: | 712 default: |
728 return CSS_UNKNOWN; | 713 return CSS_UNKNOWN; |
729 } | 714 } |
730 } | 715 } |
731 | 716 |
732 bool CSSPrimitiveValue::getDoubleValueInternal(UnitTypes requestedUnitType, doub
le* result) const | 717 bool CSSPrimitiveValue::getDoubleValueInternal(UnitTypes requestedUnitType, doub
le* result) const |
733 { | 718 { |
734 if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitTypes>(m_primitiv
eUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType)) | 719 if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitTypes>(m_primitiv
eUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType)) |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 return shapeValue->hasVariableReference(); | 1136 return shapeValue->hasVariableReference(); |
1152 return isVariableName(); | 1137 return isVariableName(); |
1153 } | 1138 } |
1154 | 1139 |
1155 void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const S
tyleSheetContents* styleSheet) const | 1140 void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const S
tyleSheetContents* styleSheet) const |
1156 { | 1141 { |
1157 if (m_primitiveUnitType == CSS_URI) | 1142 if (m_primitiveUnitType == CSS_URI) |
1158 addSubresourceURL(urls, styleSheet->completeURL(m_value.string)); | 1143 addSubresourceURL(urls, styleSheet->completeURL(m_value.string)); |
1159 } | 1144 } |
1160 | 1145 |
1161 Length CSSPrimitiveValue::viewportPercentageLength() | |
1162 { | |
1163 ASSERT(isViewportPercentageLength()); | |
1164 Length viewportLength; | |
1165 switch (m_primitiveUnitType) { | |
1166 case CSS_VW: | |
1167 viewportLength = Length(getDoubleValue(), ViewportPercentageWidth); | |
1168 break; | |
1169 case CSS_VH: | |
1170 viewportLength = Length(getDoubleValue(), ViewportPercentageHeight); | |
1171 break; | |
1172 case CSS_VMIN: | |
1173 viewportLength = Length(getDoubleValue(), ViewportPercentageMin); | |
1174 break; | |
1175 case CSS_VMAX: | |
1176 viewportLength = Length(getDoubleValue(), ViewportPercentageMax); | |
1177 break; | |
1178 default: | |
1179 break; | |
1180 } | |
1181 return viewportLength; | |
1182 } | |
1183 | |
1184 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const | 1146 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const |
1185 { | 1147 { |
1186 RefPtr<CSSPrimitiveValue> result; | 1148 RefPtr<CSSPrimitiveValue> result; |
1187 | 1149 |
1188 switch (m_primitiveUnitType) { | 1150 switch (m_primitiveUnitType) { |
1189 case CSS_STRING: | 1151 case CSS_STRING: |
1190 case CSS_URI: | 1152 case CSS_URI: |
1191 case CSS_ATTR: | 1153 case CSS_ATTR: |
1192 case CSS_COUNTER_NAME: | 1154 case CSS_COUNTER_NAME: |
1193 result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitTypes
>(m_primitiveUnitType)); | 1155 result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitTypes
>(m_primitiveUnitType)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 return m_value.parserOperator == other.m_value.parserOperator; | 1293 return m_value.parserOperator == other.m_value.parserOperator; |
1332 case CSS_CALC: | 1294 case CSS_CALC: |
1333 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1295 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); |
1334 case CSS_SHAPE: | 1296 case CSS_SHAPE: |
1335 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1297 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); |
1336 } | 1298 } |
1337 return false; | 1299 return false; |
1338 } | 1300 } |
1339 | 1301 |
1340 } // namespace WebCore | 1302 } // namespace WebCore |
OLD | NEW |