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 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 #include "core/css/BasicShapeFunctions.h" | 30 #include "core/css/BasicShapeFunctions.h" |
31 #include "core/css/CSSContentDistributionValue.h" | 31 #include "core/css/CSSContentDistributionValue.h" |
32 #include "core/css/CSSFontFeatureValue.h" | 32 #include "core/css/CSSFontFeatureValue.h" |
33 #include "core/css/CSSFunctionValue.h" | 33 #include "core/css/CSSFunctionValue.h" |
34 #include "core/css/CSSGridLineNamesValue.h" | 34 #include "core/css/CSSGridLineNamesValue.h" |
35 #include "core/css/CSSPrimitiveValueMappings.h" | 35 #include "core/css/CSSPrimitiveValueMappings.h" |
36 #include "core/css/CSSQuadValue.h" | 36 #include "core/css/CSSQuadValue.h" |
37 #include "core/css/CSSReflectValue.h" | 37 #include "core/css/CSSReflectValue.h" |
38 #include "core/css/CSSShadowValue.h" | 38 #include "core/css/CSSShadowValue.h" |
39 #include "core/css/Pair.h" | 39 #include "core/css/CSSValuePair.h" |
40 #include "core/svg/SVGElement.h" | 40 #include "core/svg/SVGElement.h" |
41 #include "core/svg/SVGURIReference.h" | 41 #include "core/svg/SVGURIReference.h" |
42 #include "platform/transforms/RotateTransformOperation.h" | 42 #include "platform/transforms/RotateTransformOperation.h" |
43 #include "platform/transforms/ScaleTransformOperation.h" | 43 #include "platform/transforms/ScaleTransformOperation.h" |
44 #include "platform/transforms/TranslateTransformOperation.h" | 44 #include "platform/transforms/TranslateTransformOperation.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 if (angle > 45.0f && angle <= 135.0f) | 328 if (angle > 45.0f && angle <= 135.0f) |
329 return GO_90DEG; | 329 return GO_90DEG; |
330 if (angle > 135.0f && angle <= 225.0f) | 330 if (angle > 135.0f && angle <= 225.0f) |
331 return GO_180DEG; | 331 return GO_180DEG; |
332 return GO_270DEG; | 332 return GO_270DEG; |
333 } | 333 } |
334 | 334 |
335 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( StyleResolverState&, CSSValue* value) | 335 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( StyleResolverState&, CSSValue* value) |
336 { | 336 { |
337 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment() ; | 337 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment() ; |
338 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 338 if (value->isValuePair()) { |
339 if (Pair* pairValue = primitiveValue->getPairValue()) { | 339 const CSSValuePair* pair = toCSSValuePair(value); |
340 if (pairValue->first()->getValueID() == CSSValueLegacy) { | 340 if (toCSSPrimitiveValue(pair->first())->getValueID() == CSSValueLegacy) { |
341 alignmentData.setPositionType(LegacyPosition); | 341 alignmentData.setPositionType(LegacyPosition); |
342 alignmentData.setPosition(*pairValue->second()); | 342 alignmentData.setPosition(*toCSSPrimitiveValue(pair->second())); |
343 } else { | 343 } else { |
344 alignmentData.setPosition(*pairValue->first()); | 344 alignmentData.setPosition(*toCSSPrimitiveValue(pair->first())); |
345 alignmentData.setOverflow(*pairValue->second()); | 345 alignmentData.setOverflow(*toCSSPrimitiveValue(pair->second())); |
346 } | 346 } |
347 } else { | 347 } else { |
348 alignmentData.setPosition(*primitiveValue); | 348 ASSERT(value->isPrimitiveValue()); |
Timothy Loh
2015/08/28 05:51:46
toCSSPrimitiveValue will do this assertion
sashab
2015/08/31 00:33:51
Just wanted to make it explicit, but you're right.
| |
349 alignmentData.setPosition(*toCSSPrimitiveValue(value)); | |
349 } | 350 } |
350 return alignmentData; | 351 return alignmentData; |
351 } | 352 } |
352 | 353 |
353 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty leResolverState&, CSSValue* value) | 354 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty leResolverState&, CSSValue* value) |
354 { | 355 { |
355 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign ment(); | 356 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign ment(); |
356 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va lue); | 357 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va lue); |
357 if (contentValue->distribution()->getValueID() != CSSValueInvalid) | 358 if (contentValue->distribution()->getValueID() != CSSValueInvalid) |
358 alignmentData.setDistribution(*contentValue->distribution()); | 359 alignmentData.setDistribution(*contentValue->distribution()); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue* value) | 628 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue* value) |
628 { | 629 { |
629 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 630 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
630 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); | 631 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); |
631 if (primitiveValue->isNumber()) | 632 if (primitiveValue->isNumber()) |
632 return primitiveValue->getFloatValue(); | 633 return primitiveValue->getFloatValue(); |
633 return primitiveValue->getFloatValue() / 100.0f; | 634 return primitiveValue->getFloatValue() / 100.0f; |
634 } | 635 } |
635 | 636 |
636 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 637 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> |
637 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue * primitiveValue) | 638 static Length convertPositionLength(StyleResolverState& state, CSSValue* value) |
638 { | 639 { |
639 if (Pair* pair = primitiveValue->getPairValue()) { | 640 if (value->isValuePair()) { |
641 const CSSValuePair* pair = toCSSValuePair(value); | |
640 Length length = StyleBuilderConverter::convertLength(state, pair->second ()); | 642 Length length = StyleBuilderConverter::convertLength(state, pair->second ()); |
641 if (pair->first()->getValueID() == cssValueFor0) | 643 if (toCSSPrimitiveValue(pair->first())->getValueID() == cssValueFor0) |
642 return length; | 644 return length; |
643 ASSERT(pair->first()->getValueID() == cssValueFor100); | 645 ASSERT(toCSSPrimitiveValue(pair->first())->getValueID() == cssValueFor10 0); |
644 return length.subtractFromOneHundredPercent(); | 646 return length.subtractFromOneHundredPercent(); |
645 } | 647 } |
646 | 648 |
647 return StyleBuilderConverter::convertLength(state, primitiveValue); | 649 ASSERT(value->isPrimitiveValue()); |
Timothy Loh
2015/08/28 05:51:46
convertLength will do all the relevant assertions
sashab
2015/08/31 00:33:51
Done.
| |
650 return StyleBuilderConverter::convertLength(state, value); | |
648 } | 651 } |
649 | 652 |
650 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS SValue* value) | 653 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS SValue* value) |
651 { | 654 { |
652 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 655 const CSSValuePair* pair = toCSSValuePair(value); |
653 Pair* pair = primitiveValue->getPairValue(); | |
654 return LengthPoint( | 656 return LengthPoint( |
655 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first()) , | 657 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first()) , |
656 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second() ) | 658 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second() ) |
657 ); | 659 ); |
658 } | 660 } |
659 | 661 |
660 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal ue* primitiveValue) | 662 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal ue* primitiveValue) |
661 { | 663 { |
662 return std::max(primitiveValue->computeLength<float>(state.cssToLengthConver sionData()), 0.0f); | 664 return std::max(primitiveValue->computeLength<float>(state.cssToLengthConver sionData()), 0.0f); |
663 } | 665 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
745 quotes->addPair(std::make_pair(startQuote, endQuote)); | 747 quotes->addPair(std::make_pair(startQuote, endQuote)); |
746 } | 748 } |
747 return quotes.release(); | 749 return quotes.release(); |
748 } | 750 } |
749 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo ne | 751 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo ne |
750 return QuotesData::create(); | 752 return QuotesData::create(); |
751 } | 753 } |
752 | 754 |
753 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value) | 755 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value) |
754 { | 756 { |
755 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 757 const CSSValuePair* pair = toCSSValuePair(value); |
756 Pair* pair = primitiveValue->getPairValue(); | 758 Length radiusWidth = toCSSPrimitiveValue(pair->first())->convertToLength(sta te.cssToLengthConversionData()); |
757 Length radiusWidth = pair->first()->convertToLength(state.cssToLengthConvers ionData()); | 759 Length radiusHeight = toCSSPrimitiveValue(pair->second())->convertToLength(s tate.cssToLengthConversionData()); |
758 Length radiusHeight = pair->second()->convertToLength(state.cssToLengthConve rsionData()); | |
759 float width = radiusWidth.value(); | 760 float width = radiusWidth.value(); |
760 float height = radiusHeight.value(); | 761 float height = radiusHeight.value(); |
761 ASSERT(width >= 0 && height >= 0); | 762 ASSERT(width >= 0 && height >= 0); |
762 if (width <= 0 || height <= 0) | 763 if (width <= 0 || height <= 0) |
763 return LengthSize(Length(0, Fixed), Length(0, Fixed)); | 764 return LengthSize(Length(0, Fixed), Length(0, Fixed)); |
764 return LengthSize(radiusWidth, radiusHeight); | 765 return LengthSize(radiusWidth, radiusHeight); |
765 } | 766 } |
766 | 767 |
767 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState& state, CSSValue* value) | 768 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState& state, CSSValue* value) |
768 { | 769 { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
957 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D); | 958 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D); |
958 } | 959 } |
959 | 960 |
960 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value) | 961 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value) |
961 { | 962 { |
962 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 963 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
963 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation; | 964 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation; |
964 } | 965 } |
965 | 966 |
966 } // namespace blink | 967 } // namespace blink |
OLD | NEW |