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/CSSPrimitiveValueMappings.h

Issue 2767213003: First Implementation of Snapped Points
Patch Set: Rebase and format Created 3 years, 6 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) 2007 Alexey Proskuryakov <ap@nypop.com>. 2 * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
3 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 4 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
5 * (http://www.torchmobile.com/) 5 * (http://www.torchmobile.com/)
6 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 6 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
(...skipping 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 return kScrollBehaviorAuto; 2747 return kScrollBehaviorAuto;
2748 case CSSValueSmooth: 2748 case CSSValueSmooth:
2749 return kScrollBehaviorSmooth; 2749 return kScrollBehaviorSmooth;
2750 default: 2750 default:
2751 break; 2751 break;
2752 } 2752 }
2753 NOTREACHED(); 2753 NOTREACHED();
2754 return kScrollBehaviorAuto; 2754 return kScrollBehaviorAuto;
2755 } 2755 }
2756 2756
2757 template <> 2757 /*template <>
2758 inline CSSIdentifierValue::CSSIdentifierValue(ScrollSnapType snap_type) 2758 inline CSSIdentifierValue::CSSIdentifierValue(ScrollSnapType snap_type)
2759 : CSSValue(kIdentifierClass) { 2759 : CSSValue(kIdentifierClass) {
2760 switch (snap_type) { 2760 switch (snap_type) {
2761 case kScrollSnapTypeNone: 2761 case kScrollSnapTypeNone:
2762 value_id_ = CSSValueNone; 2762 value_id_ = CSSValueNone;
2763 break; 2763 break;
2764 case kScrollSnapTypeMandatory: 2764 case kScrollSnapTypeMandatory:
2765 value_id_ = CSSValueMandatory; 2765 value_id_ = CSSValueMandatory;
2766 break; 2766 break;
2767 case kScrollSnapTypeProximity: 2767 case kScrollSnapTypeProximity:
2768 value_id_ = CSSValueProximity; 2768 value_id_ = CSSValueProximity;
2769 break; 2769 break;
2770 } 2770 }
2771 } 2771 }
2772 2772
2773 template <> 2773 template <>
2774 inline ScrollSnapType CSSIdentifierValue::ConvertTo() const { 2774 inline ScrollSnapType CSSIdentifierValue::ConvertTo() const {
2775 switch (GetValueID()) { 2775 switch (GetValueID()) {
2776 case CSSValueNone: 2776 case CSSValueNone:
2777 return kScrollSnapTypeNone; 2777 return kScrollSnapTypeNone;
2778 case CSSValueMandatory: 2778 case CSSValueMandatory:
2779 return kScrollSnapTypeMandatory; 2779 return kScrollSnapTypeMandatory;
2780 case CSSValueProximity: 2780 case CSSValueProximity:
2781 return kScrollSnapTypeProximity; 2781 return kScrollSnapTypeProximity;
2782 default: 2782 default:
2783 break; 2783 break;
2784 } 2784 }
2785 NOTREACHED(); 2785 NOTREACHED();
2786 return kScrollSnapTypeNone; 2786 return kScrollSnapTypeNone;
2787 }*/
2788
2789 template <>
2790 inline CSSIdentifierValue::CSSIdentifierValue(SnapAxis axis)
2791 : CSSValue(kIdentifierClass) {
2792 switch (axis) {
2793 case kSnapAxisNone:
2794 value_id_ = CSSValueNone;
2795 break;
2796 case kSnapAxisX:
2797 value_id_ = CSSValueX;
2798 break;
2799 case kSnapAxisY:
2800 value_id_ = CSSValueY;
2801 break;
2802 case kSnapAxisBlock:
2803 value_id_ = CSSValueBlock;
2804 break;
2805 case kSnapAxisInline:
2806 value_id_ = CSSValueInline;
2807 break;
2808 case kSnapAxisBoth:
2809 value_id_ = CSSValueBoth;
2810 break;
2811 }
2787 } 2812 }
2788 2813
2789 template <> 2814 template <>
2815 inline SnapAxis CSSIdentifierValue::ConvertTo() const {
2816 switch (GetValueID()) {
2817 case CSSValueNone:
2818 return kSnapAxisNone;
2819 case CSSValueX:
2820 return kSnapAxisX;
2821 case CSSValueY:
2822 return kSnapAxisY;
2823 case CSSValueBlock:
2824 return kSnapAxisBlock;
2825 case CSSValueInline:
2826 return kSnapAxisInline;
2827 case CSSValueBoth:
2828 return kSnapAxisBoth;
2829 default:
2830 break;
2831 }
2832 NOTREACHED();
2833 return kSnapAxisNone;
2834 }
2835
2836 template <>
2837 inline CSSIdentifierValue::CSSIdentifierValue(SnapStrictness strictness)
2838 : CSSValue(kIdentifierClass) {
2839 switch (strictness) {
2840 case kSnapStrictnessProximity:
2841 value_id_ = CSSValueProximity;
2842 break;
2843 case kSnapStrictnessMandatory:
2844 value_id_ = CSSValueMandatory;
2845 break;
2846 }
2847 }
2848
2849 template <>
2850 inline SnapStrictness CSSIdentifierValue::ConvertTo() const {
2851 switch (GetValueID()) {
2852 case CSSValueProximity:
2853 return kSnapStrictnessProximity;
2854 case CSSValueMandatory:
2855 return kSnapStrictnessMandatory;
2856 default:
2857 break;
2858 }
2859 NOTREACHED();
2860 return kSnapStrictnessProximity;
2861 }
2862
2863 template <>
2864 inline CSSIdentifierValue::CSSIdentifierValue(SnapAlignment alignment)
2865 : CSSValue(kIdentifierClass) {
2866 switch (alignment) {
2867 case kSnapAlignmentNone:
2868 value_id_ = CSSValueNone;
2869 break;
2870 case kSnapAlignmentStart:
2871 value_id_ = CSSValueStart;
2872 break;
2873 case kSnapAlignmentEnd:
2874 value_id_ = CSSValueEnd;
2875 break;
2876 case kSnapAlignmentCenter:
2877 value_id_ = CSSValueCenter;
2878 break;
2879 }
2880 }
2881
2882 template <>
2883 inline SnapAlignment CSSIdentifierValue::ConvertTo() const {
2884 switch (GetValueID()) {
2885 case CSSValueNone:
2886 return kSnapAlignmentNone;
2887 case CSSValueStart:
2888 return kSnapAlignmentStart;
2889 case CSSValueEnd:
2890 return kSnapAlignmentEnd;
2891 case CSSValueCenter:
2892 return kSnapAlignmentCenter;
2893 default:
2894 break;
2895 }
2896 NOTREACHED();
2897 return kSnapAlignmentNone;
2898 }
2899
2900 template <>
2901 inline CSSIdentifierValue::CSSIdentifierValue(EScrollSnapStop stop)
2902 : CSSValue(kIdentifierClass) {
2903 switch (stop) {
2904 case EScrollSnapStop::kNormal:
2905 value_id_ = CSSValueNormal;
2906 break;
2907 case EScrollSnapStop::kAlways:
2908 value_id_ = CSSValueAlways;
2909 break;
2910 }
2911 }
2912
2913 template <>
2914 inline EScrollSnapStop CSSIdentifierValue::ConvertTo() const {
2915 switch (GetValueID()) {
2916 case CSSValueNormal:
2917 return EScrollSnapStop::kNormal;
2918 case CSSValueAlways:
2919 return EScrollSnapStop::kAlways;
2920 default:
2921 break;
2922 }
2923 NOTREACHED();
2924 return EScrollSnapStop::kNormal;
2925 }
2926
2927 template <>
2790 inline CSSIdentifierValue::CSSIdentifierValue(Containment snap_type) 2928 inline CSSIdentifierValue::CSSIdentifierValue(Containment snap_type)
2791 : CSSValue(kIdentifierClass) { 2929 : CSSValue(kIdentifierClass) {
2792 switch (snap_type) { 2930 switch (snap_type) {
2793 case kContainsNone: 2931 case kContainsNone:
2794 value_id_ = CSSValueNone; 2932 value_id_ = CSSValueNone;
2795 break; 2933 break;
2796 case kContainsStrict: 2934 case kContainsStrict:
2797 value_id_ = CSSValueStrict; 2935 value_id_ = CSSValueStrict;
2798 break; 2936 break;
2799 case kContainsContent: 2937 case kContainsContent:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 default: 2972 default:
2835 break; 2973 break;
2836 } 2974 }
2837 NOTREACHED(); 2975 NOTREACHED();
2838 return kContainsNone; 2976 return kContainsNone;
2839 } 2977 }
2840 2978
2841 } // namespace blink 2979 } // namespace blink
2842 2980
2843 #endif 2981 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698