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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if (value->isValuePair()) { | 338 if (value->isValuePair()) { |
339 const CSSValuePair* pair = toCSSValuePair(value); | 339 const CSSValuePair* pair = toCSSValuePair(value); |
340 if (toCSSPrimitiveValue(pair->first())->getValueID() == CSSValueLegacy)
{ | 340 if (toCSSPrimitiveValue(pair->first()).getValueID() == CSSValueLegacy) { |
341 alignmentData.setPositionType(LegacyPosition); | 341 alignmentData.setPositionType(LegacyPosition); |
342 alignmentData.setPosition(*toCSSPrimitiveValue(pair->second())); | 342 alignmentData.setPosition(toCSSPrimitiveValue(pair->second())); |
343 } else { | 343 } else { |
344 alignmentData.setPosition(*toCSSPrimitiveValue(pair->first())); | 344 alignmentData.setPosition(toCSSPrimitiveValue(pair->first())); |
345 alignmentData.setOverflow(*toCSSPrimitiveValue(pair->second())); | 345 alignmentData.setOverflow(toCSSPrimitiveValue(pair->second())); |
346 } | 346 } |
347 } else { | 347 } else { |
348 alignmentData.setPosition(*toCSSPrimitiveValue(value)); | 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(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 return toCSSPrimitiveValue(value)->convertToLength(state.cssToLengthConversi
onData()); | 529 return toCSSPrimitiveValue(value)->convertToLength(state.cssToLengthConversi
onData()); |
530 } | 530 } |
531 | 531 |
532 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS
tate& state, CSSValue* value) | 532 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS
tate& state, CSSValue* value) |
533 { | 533 { |
534 return UnzoomedLength(toCSSPrimitiveValue(value)->convertToLength(state.cssT
oLengthConversionData().copyWithAdjustedZoom(1.0f))); | 534 return UnzoomedLength(toCSSPrimitiveValue(value)->convertToLength(state.cssT
oLengthConversionData().copyWithAdjustedZoom(1.0f))); |
535 } | 535 } |
536 | 536 |
537 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat
e, CSSValue* value) | 537 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat
e, CSSValue* value) |
538 { | 538 { |
539 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 539 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*value); |
540 if (primitiveValue->getValueID() == CSSValueAuto) | 540 if (primitiveValue.getValueID() == CSSValueAuto) |
541 return Length(Auto); | 541 return Length(Auto); |
542 return primitiveValue->convertToLength(state.cssToLengthConversionData()); | 542 return primitiveValue.convertToLength(state.cssToLengthConversionData()); |
543 } | 543 } |
544 | 544 |
545 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS
Value* value) | 545 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS
Value* value) |
546 { | 546 { |
547 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 547 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
548 switch (primitiveValue->getValueID()) { | 548 switch (primitiveValue->getValueID()) { |
549 case CSSValueInvalid: | 549 case CSSValueInvalid: |
550 return convertLength(state, value); | 550 return convertLength(state, value); |
551 case CSSValueIntrinsic: | 551 case CSSValueIntrinsic: |
552 return Length(Intrinsic); | 552 return Length(Intrinsic); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, CSSValue* value) | 637 static Length convertPositionLength(StyleResolverState& state, CSSValue* value) |
638 { | 638 { |
639 if (value->isValuePair()) { | 639 if (value->isValuePair()) { |
640 const CSSValuePair* pair = toCSSValuePair(value); | 640 CSSValuePair* pair = toCSSValuePair(value); |
641 Length length = StyleBuilderConverter::convertLength(state, pair->second
()); | 641 Length length = StyleBuilderConverter::convertLength(state, &pair->secon
d()); |
642 if (toCSSPrimitiveValue(pair->first())->getValueID() == cssValueFor0) | 642 if (toCSSPrimitiveValue(pair->first()).getValueID() == cssValueFor0) |
643 return length; | 643 return length; |
644 ASSERT(toCSSPrimitiveValue(pair->first())->getValueID() == cssValueFor10
0); | 644 ASSERT(toCSSPrimitiveValue(pair->first()).getValueID() == cssValueFor100
); |
645 return length.subtractFromOneHundredPercent(); | 645 return length.subtractFromOneHundredPercent(); |
646 } | 646 } |
647 | 647 |
648 return StyleBuilderConverter::convertLength(state, value); | 648 return StyleBuilderConverter::convertLength(state, value); |
649 } | 649 } |
650 | 650 |
651 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS
SValue* value) | 651 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS
SValue* value) |
652 { | 652 { |
653 const CSSValuePair* pair = toCSSValuePair(value); | 653 CSSValuePair* pair = toCSSValuePair(value); |
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 } |
664 | 664 |
665 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, CSSVa
lue* value) | 665 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, CSSVa
lue* value) |
666 { | 666 { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const CSSValuePair* pair = toCSSValuePair(value); | 755 const CSSValuePair* pair = toCSSValuePair(value); |
756 Length radiusWidth = toCSSPrimitiveValue(pair->first())->convertToLength(sta
te.cssToLengthConversionData()); | 756 Length radiusWidth = toCSSPrimitiveValue(pair->first()).convertToLength(stat
e.cssToLengthConversionData()); |
757 Length radiusHeight = toCSSPrimitiveValue(pair->second())->convertToLength(s
tate.cssToLengthConversionData()); | 757 Length radiusHeight = toCSSPrimitiveValue(pair->second()).convertToLength(st
ate.cssToLengthConversionData()); |
758 float width = radiusWidth.value(); | 758 float width = radiusWidth.value(); |
759 float height = radiusHeight.value(); | 759 float height = radiusHeight.value(); |
760 ASSERT(width >= 0 && height >= 0); | 760 ASSERT(width >= 0 && height >= 0); |
761 if (width <= 0 || height <= 0) | 761 if (width <= 0 || height <= 0) |
762 return LengthSize(Length(0, Fixed), Length(0, Fixed)); | 762 return LengthSize(Length(0, Fixed), Length(0, Fixed)); |
763 return LengthSize(radiusWidth, radiusHeight); | 763 return LengthSize(radiusWidth, radiusHeight); |
764 } | 764 } |
765 | 765 |
766 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, CSSValue* value) | 766 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, CSSValue* value) |
767 { | 767 { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, CSSValue* value) | 827 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, CSSValue* value) |
828 { | 828 { |
829 if (!value->isValueList()) | 829 if (!value->isValueList()) |
830 return SVGComputedStyle::initialStrokeDashArray(); | 830 return SVGComputedStyle::initialStrokeDashArray(); |
831 | 831 |
832 CSSValueList* dashes = toCSSValueList(value); | 832 CSSValueList* dashes = toCSSValueList(value); |
833 | 833 |
834 RefPtr<SVGDashArray> array = SVGDashArray::create(); | 834 RefPtr<SVGDashArray> array = SVGDashArray::create(); |
835 size_t length = dashes->length(); | 835 size_t length = dashes->length(); |
836 for (size_t i = 0; i < length; ++i) { | 836 for (size_t i = 0; i < length; ++i) { |
837 CSSPrimitiveValue* dash = toCSSPrimitiveValue(dashes->item(i)); | 837 array->append(convertLength(state, toCSSPrimitiveValue(dashes->item(i)))
); |
838 array->append(convertLength(state, dash)); | |
839 } | 838 } |
840 | 839 |
841 return array.release(); | 840 return array.release(); |
842 } | 841 } |
843 | 842 |
844 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, C
SSValue* value, bool forVisitedLink) | 843 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, C
SSValue* value, bool forVisitedLink) |
845 { | 844 { |
846 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 845 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
847 if (primitiveValue->getValueID() == CSSValueCurrentcolor) | 846 if (primitiveValue->getValueID() == CSSValueCurrentcolor) |
848 return StyleColor::currentColor(); | 847 return StyleColor::currentColor(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); | 955 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); |
957 } | 956 } |
958 | 957 |
959 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, CSSValue* value) | 958 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, CSSValue* value) |
960 { | 959 { |
961 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 960 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
962 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien
tation : DoNotRespectImageOrientation; | 961 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien
tation : DoNotRespectImageOrientation; |
963 } | 962 } |
964 | 963 |
965 } // namespace blink | 964 } // namespace blink |
OLD | NEW |