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 alignmentData.setPosition(*toCSSPrimitiveValue(value)); |
349 } | 349 } |
350 return alignmentData; | 350 return alignmentData; |
351 } | 351 } |
352 | 352 |
353 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty
leResolverState&, CSSValue* value) | 353 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty
leResolverState&, CSSValue* value) |
354 { | 354 { |
355 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign
ment(); | 355 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign
ment(); |
356 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va
lue); | 356 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va
lue); |
357 if (contentValue->distribution()->getValueID() != CSSValueInvalid) | 357 if (contentValue->distribution()->getValueID() != CSSValueInvalid) |
358 alignmentData.setDistribution(*contentValue->distribution()); | 358 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) | 627 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, CSSValue* value) |
628 { | 628 { |
629 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 629 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
630 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); | 630 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); |
631 if (primitiveValue->isNumber()) | 631 if (primitiveValue->isNumber()) |
632 return primitiveValue->getFloatValue(); | 632 return primitiveValue->getFloatValue(); |
633 return primitiveValue->getFloatValue() / 100.0f; | 633 return primitiveValue->getFloatValue() / 100.0f; |
634 } | 634 } |
635 | 635 |
636 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 636 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> |
637 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue
* primitiveValue) | 637 static Length convertPositionLength(StyleResolverState& state, CSSValue* value) |
638 { | 638 { |
639 if (Pair* pair = primitiveValue->getPairValue()) { | 639 if (value->isValuePair()) { |
| 640 const CSSValuePair* pair = toCSSValuePair(value); |
640 Length length = StyleBuilderConverter::convertLength(state, pair->second
()); | 641 Length length = StyleBuilderConverter::convertLength(state, pair->second
()); |
641 if (pair->first()->getValueID() == cssValueFor0) | 642 if (toCSSPrimitiveValue(pair->first())->getValueID() == cssValueFor0) |
642 return length; | 643 return length; |
643 ASSERT(pair->first()->getValueID() == cssValueFor100); | 644 ASSERT(toCSSPrimitiveValue(pair->first())->getValueID() == cssValueFor10
0); |
644 return length.subtractFromOneHundredPercent(); | 645 return length.subtractFromOneHundredPercent(); |
645 } | 646 } |
646 | 647 |
647 return StyleBuilderConverter::convertLength(state, primitiveValue); | 648 return StyleBuilderConverter::convertLength(state, value); |
648 } | 649 } |
649 | 650 |
650 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS
SValue* value) | 651 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS
SValue* value) |
651 { | 652 { |
652 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 653 const CSSValuePair* pair = toCSSValuePair(value); |
653 Pair* pair = primitiveValue->getPairValue(); | |
654 return LengthPoint( | 654 return LengthPoint( |
655 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first())
, | 655 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first())
, |
656 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second()
) | 656 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second()
) |
657 ); | 657 ); |
658 } | 658 } |
659 | 659 |
660 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal
ue* primitiveValue) | 660 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal
ue* primitiveValue) |
661 { | 661 { |
662 return std::max(primitiveValue->computeLength<float>(state.cssToLengthConver
sionData()), 0.0f); | 662 return std::max(primitiveValue->computeLength<float>(state.cssToLengthConver
sionData()), 0.0f); |
663 } | 663 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 quotes->addPair(std::make_pair(startQuote, endQuote)); | 745 quotes->addPair(std::make_pair(startQuote, endQuote)); |
746 } | 746 } |
747 return quotes.release(); | 747 return quotes.release(); |
748 } | 748 } |
749 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo
ne | 749 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo
ne |
750 return QuotesData::create(); | 750 return QuotesData::create(); |
751 } | 751 } |
752 | 752 |
753 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa
lue* value) | 753 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa
lue* value) |
754 { | 754 { |
755 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 755 const CSSValuePair* pair = toCSSValuePair(value); |
756 Pair* pair = primitiveValue->getPairValue(); | 756 Length radiusWidth = toCSSPrimitiveValue(pair->first())->convertToLength(sta
te.cssToLengthConversionData()); |
757 Length radiusWidth = pair->first()->convertToLength(state.cssToLengthConvers
ionData()); | 757 Length radiusHeight = toCSSPrimitiveValue(pair->second())->convertToLength(s
tate.cssToLengthConversionData()); |
758 Length radiusHeight = pair->second()->convertToLength(state.cssToLengthConve
rsionData()); | |
759 float width = radiusWidth.value(); | 758 float width = radiusWidth.value(); |
760 float height = radiusHeight.value(); | 759 float height = radiusHeight.value(); |
761 ASSERT(width >= 0 && height >= 0); | 760 ASSERT(width >= 0 && height >= 0); |
762 if (width <= 0 || height <= 0) | 761 if (width <= 0 || height <= 0) |
763 return LengthSize(Length(0, Fixed), Length(0, Fixed)); | 762 return LengthSize(Length(0, Fixed), Length(0, Fixed)); |
764 return LengthSize(radiusWidth, radiusHeight); | 763 return LengthSize(radiusWidth, radiusHeight); |
765 } | 764 } |
766 | 765 |
767 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, CSSValue* value) | 766 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, CSSValue* value) |
768 { | 767 { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); | 956 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); |
958 } | 957 } |
959 | 958 |
960 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, CSSValue* value) | 959 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, CSSValue* value) |
961 { | 960 { |
962 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 961 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
963 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien
tation : DoNotRespectImageOrientation; | 962 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien
tation : DoNotRespectImageOrientation; |
964 } | 963 } |
965 | 964 |
966 } // namespace blink | 965 } // namespace blink |
OLD | NEW |