Changeset 121285 in webkit for trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
- Timestamp:
- Jun 26, 2012, 1:23:26 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r120849 r121285 456 456 } 457 457 458 template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)459 { 460 return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));461 } 462 463 template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)464 { 465 return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));466 } 467 468 template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)458 template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 459 { 460 return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)); 461 } 462 463 template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 464 { 465 return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)); 466 } 467 468 template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 469 469 { 470 470 #if ENABLE(SUBPIXEL_LAYOUT) 471 return Length(static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);471 return Length(static_cast<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)), Fixed); 472 472 #else 473 return Length(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);474 #endif 475 } 476 477 template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)478 { 479 return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));480 } 481 482 template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)483 { 484 return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));485 } 486 487 template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)488 { 489 return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));490 } 491 492 template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)493 { 494 return computeLengthDouble(style, rootStyle, multiplier, computingFontSize);495 } 496 497 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)473 return Length(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)), Fixed); 474 #endif 475 } 476 477 template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 478 { 479 return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)); 480 } 481 482 template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 483 { 484 return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)); 485 } 486 487 template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 488 { 489 return static_cast<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)); 490 } 491 492 template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 493 { 494 return computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize); 495 } 496 497 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize) 498 498 { 499 499 double factor; … … 538 538 ASSERT_NOT_REACHED(); 539 539 return -1.0; 540 case CSS_VW: 541 factor = parentStyle ? 0.01 * parentStyle->width().getFloatValue() : 0; 542 break; 543 case CSS_VH: 544 factor = parentStyle ? 0.01 * parentStyle->height().getFloatValue() : 0; 545 break; 546 case CSS_VMIN: 547 factor = 0; 548 if (parentStyle) 549 factor = .01 * (float) min(parentStyle->width().getFloatValue(), parentStyle->height().getFloatValue()); 550 break; 540 551 default: 541 552 ASSERT_NOT_REACHED(); … … 546 557 if (m_primitiveUnitType == CSS_CALC) 547 558 // The multiplier is passed in as 1.0 here to ensure it is only applied once 548 computedValue = m_value.calc->computeLengthPx(style, rootStyle, 1.0, computingFontSize);559 computedValue = m_value.calc->computeLengthPx(style, rootStyle, parentStyle, 1.0, computingFontSize); 549 560 else 550 561 computedValue = getDoubleValue();
Note:
See TracChangeset
for help on using the changeset viewer.