Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 2247773004: [WIP] CSS Motion Path: offset-anchor and offset-position Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: offsetAnchor Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 737
738 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , const CSSValue& value) 738 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , const CSSValue& value)
739 { 739 {
740 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 740 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
741 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); 741 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage());
742 if (primitiveValue.isNumber()) 742 if (primitiveValue.isNumber())
743 return primitiveValue.getFloatValue(); 743 return primitiveValue.getFloatValue();
744 return primitiveValue.getFloatValue() / 100.0f; 744 return primitiveValue.getFloatValue() / 100.0f;
745 } 745 }
746 746
747 StyleMotionRotation StyleBuilderConverter::convertMotionRotation(StyleResolverSt ate&, const CSSValue& value) 747 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation(StyleResolverSt ate&, const CSSValue& value)
748 { 748 {
749 return convertMotionRotation(value); 749 return convertOffsetRotation(value);
750 } 750 }
751 751
752 StyleMotionRotation StyleBuilderConverter::convertMotionRotation(const CSSValue& value) 752 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation(const CSSValue& value)
753 { 753 {
754 StyleMotionRotation result(0, MotionRotationFixed); 754 StyleOffsetRotation result(0, OffsetRotationFixed);
755 755
756 const CSSValueList& list = toCSSValueList(value); 756 const CSSValueList& list = toCSSValueList(value);
757 ASSERT(list.length() == 1 || list.length() == 2); 757 ASSERT(list.length() == 1 || list.length() == 2);
758 for (const auto& item : list) { 758 for (const auto& item : list) {
759 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item); 759 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item);
760 if (primitiveValue.getValueID() == CSSValueAuto) { 760 if (primitiveValue.getValueID() == CSSValueAuto) {
761 result.type = MotionRotationAuto; 761 result.type = OffsetRotationAuto;
762 } else if (primitiveValue.getValueID() == CSSValueReverse) { 762 } else if (primitiveValue.getValueID() == CSSValueReverse) {
763 result.type = MotionRotationAuto; 763 result.type = OffsetRotationAuto;
764 result.angle += 180; 764 result.angle += 180;
765 } else { 765 } else {
766 result.angle += primitiveValue.computeDegrees(); 766 result.angle += primitiveValue.computeDegrees();
767 } 767 }
768 } 768 }
769 result.angle = clampTo<float>(result.angle); 769 result.angle = clampTo<float>(result.angle);
770 770
771 return result; 771 return result;
772 } 772 }
773 773
(...skipping 28 matching lines...) Expand all
802 802
803 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, co nst CSSValue& value) 803 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, co nst CSSValue& value)
804 { 804 {
805 const CSSValuePair& pair = toCSSValuePair(value); 805 const CSSValuePair& pair = toCSSValuePair(value);
806 return LengthPoint( 806 return LengthPoint(
807 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair.first()), 807 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair.first()),
808 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair.second()) 808 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair.second())
809 ); 809 );
810 } 810 }
811 811
812 LengthPoint StyleBuilderConverter::convertPositionOrAuto(StyleResolverState& sta te, const CSSValue& value)
813 {
814 if (value.isValuePair())
815 return convertPosition(state, value);
816 DCHECK(toCSSPrimitiveValue(value).getValueID() == CSSValueAuto);
817 return LengthPoint(Length(Auto), Length(Auto));
818 }
819
812 static float convertPerspectiveLength(StyleResolverState& state, const CSSPrimit iveValue& primitiveValue) 820 static float convertPerspectiveLength(StyleResolverState& state, const CSSPrimit iveValue& primitiveValue)
813 { 821 {
814 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers ionData()), 0.0f); 822 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers ionData()), 0.0f);
815 } 823 }
816 824
817 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const CSSValue& value) 825 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const CSSValue& value)
818 { 826 {
819 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 827 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
820 828
821 if (primitiveValue.getValueID() == CSSValueNone) 829 if (primitiveValue.getValueID() == CSSValueNone)
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1098
1091 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone(StyleResolverStat e& state, const CSSValue& value) 1099 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone(StyleResolverStat e& state, const CSSValue& value)
1092 { 1100 {
1093 if (value.isPathValue()) 1101 if (value.isPathValue())
1094 return toCSSPathValue(value).stylePath(); 1102 return toCSSPathValue(value).stylePath();
1095 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() = = CSSValueNone); 1103 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() = = CSSValueNone);
1096 return nullptr; 1104 return nullptr;
1097 } 1105 }
1098 1106
1099 } // namespace blink 1107 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698