| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * * Redistributions of source code must retain the above copyright | 4 * * Redistributions of source code must retain the above copyright |
| 5 * notice, this list of conditions and the following disclaimer. | 5 * notice, this list of conditions and the following disclaimer. |
| 6 * * Redistributions in binary form must reproduce the above | 6 * * Redistributions in binary form must reproduce the above |
| 7 * copyright notice, this list of conditions and the following disclaimer | 7 * copyright notice, this list of conditions and the following disclaimer |
| 8 * in the documentation and/or other materials provided with the | 8 * in the documentation and/or other materials provided with the |
| 9 * distribution. | 9 * distribution. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 578 |
| 579 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, CSSValue* value) | 579 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, CSSValue* value) |
| 580 { | 580 { |
| 581 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 581 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 582 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); | 582 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); |
| 583 if (primitiveValue->isNumber()) | 583 if (primitiveValue->isNumber()) |
| 584 return primitiveValue->getFloatValue(); | 584 return primitiveValue->getFloatValue(); |
| 585 return primitiveValue->getFloatValue() / 100.0f; | 585 return primitiveValue->getFloatValue() / 100.0f; |
| 586 } | 586 } |
| 587 | 587 |
| 588 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal
ue* primitiveValue) |
| 589 { |
| 590 return std::max(primitiveValue->computeLength<float>(state.cssToLengthConver
sionData()), 0.0f); |
| 591 } |
| 592 |
| 593 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, CSSVa
lue* value) |
| 594 { |
| 595 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 596 |
| 597 if (primitiveValue->getValueID() == CSSValueNone) |
| 598 return RenderStyle::initialPerspective(); |
| 599 |
| 600 // CSSPropertyWebkitPerspective accepts unitless numbers. |
| 601 if (primitiveValue->isNumber()) { |
| 602 RefPtr<CSSPrimitiveValue> px = CSSPrimitiveValue::create(primitiveValue-
>getDoubleValue(), CSSPrimitiveValue::CSS_PX); |
| 603 return convertPerspectiveLength(state, px.get()); |
| 604 } |
| 605 |
| 606 return convertPerspectiveLength(state, primitiveValue); |
| 607 } |
| 608 |
| 588 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, CSSVal
ue* cssPaintOrder) | 609 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, CSSVal
ue* cssPaintOrder) |
| 589 { | 610 { |
| 590 if (cssPaintOrder->isValueList()) { | 611 if (cssPaintOrder->isValueList()) { |
| 591 int paintOrder = 0; | 612 int paintOrder = 0; |
| 592 const CSSValueList& list = *toCSSValueList(cssPaintOrder); | 613 const CSSValueList& list = *toCSSValueList(cssPaintOrder); |
| 593 for (size_t i = 0; i < list.length(); ++i) { | 614 for (size_t i = 0; i < list.length(); ++i) { |
| 594 EPaintOrderType paintOrderType = PT_NONE; | 615 EPaintOrderType paintOrderType = PT_NONE; |
| 595 switch (toCSSPrimitiveValue(list.item(i))->getValueID()) { | 616 switch (toCSSPrimitiveValue(list.item(i))->getValueID()) { |
| 596 case CSSValueFill: | 617 case CSSValueFill: |
| 597 paintOrderType = PT_FILL; | 618 paintOrderType = PT_FILL; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 { | 751 { |
| 731 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 752 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 732 if (primitiveValue->getValueID()) { | 753 if (primitiveValue->getValueID()) { |
| 733 float multiplier = convertLineWidth<float>(state, value); | 754 float multiplier = convertLineWidth<float>(state, value); |
| 734 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS
_EMS)->computeLength<float>(state.cssToLengthConversionData()); | 755 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS
_EMS)->computeLength<float>(state.cssToLengthConversionData()); |
| 735 } | 756 } |
| 736 return primitiveValue->computeLength<float>(state.cssToLengthConversionData(
)); | 757 return primitiveValue->computeLength<float>(state.cssToLengthConversionData(
)); |
| 737 } | 758 } |
| 738 | 759 |
| 739 } // namespace blink | 760 } // namespace blink |
| OLD | NEW |