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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSPrimitiveValueMappings.h

Issue 2932593004: Update the snap points css properties (Closed)
Patch Set: update some tests 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 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 case CSSValueSmooth: 2678 case CSSValueSmooth:
2679 return kScrollBehaviorSmooth; 2679 return kScrollBehaviorSmooth;
2680 default: 2680 default:
2681 break; 2681 break;
2682 } 2682 }
2683 NOTREACHED(); 2683 NOTREACHED();
2684 return kScrollBehaviorAuto; 2684 return kScrollBehaviorAuto;
2685 } 2685 }
2686 2686
2687 template <> 2687 template <>
2688 inline CSSIdentifierValue::CSSIdentifierValue(ScrollSnapType snap_type) 2688 inline CSSIdentifierValue::CSSIdentifierValue(SnapAxis axis)
2689 : CSSValue(kIdentifierClass) { 2689 : CSSValue(kIdentifierClass) {
2690 switch (snap_type) { 2690 switch (axis) {
2691 case kScrollSnapTypeNone: 2691 case kSnapAxisNone:
2692 value_id_ = CSSValueNone; 2692 value_id_ = CSSValueNone;
2693 break; 2693 break;
2694 case kScrollSnapTypeMandatory: 2694 case kSnapAxisX:
2695 value_id_ = CSSValueMandatory; 2695 value_id_ = CSSValueX;
2696 break; 2696 break;
2697 case kScrollSnapTypeProximity: 2697 case kSnapAxisY:
2698 value_id_ = CSSValueProximity; 2698 value_id_ = CSSValueY;
2699 break;
2700 case kSnapAxisBlock:
2701 value_id_ = CSSValueBlock;
2702 break;
2703 case kSnapAxisInline:
2704 value_id_ = CSSValueInline;
2705 break;
2706 case kSnapAxisBoth:
2707 value_id_ = CSSValueBoth;
2699 break; 2708 break;
2700 } 2709 }
2701 } 2710 }
2702 2711
2703 template <> 2712 template <>
2704 inline ScrollSnapType CSSIdentifierValue::ConvertTo() const { 2713 inline SnapAxis CSSIdentifierValue::ConvertTo() const {
2705 switch (GetValueID()) { 2714 switch (GetValueID()) {
2706 case CSSValueNone: 2715 case CSSValueNone:
2707 return kScrollSnapTypeNone; 2716 return kSnapAxisNone;
2708 case CSSValueMandatory: 2717 case CSSValueX:
2709 return kScrollSnapTypeMandatory; 2718 return kSnapAxisX;
2710 case CSSValueProximity: 2719 case CSSValueY:
2711 return kScrollSnapTypeProximity; 2720 return kSnapAxisY;
2721 case CSSValueBlock:
2722 return kSnapAxisBlock;
2723 case CSSValueInline:
2724 return kSnapAxisInline;
2725 case CSSValueBoth:
2726 return kSnapAxisBoth;
2712 default: 2727 default:
2713 break; 2728 break;
2714 } 2729 }
2715 NOTREACHED(); 2730 NOTREACHED();
2716 return kScrollSnapTypeNone; 2731 return kSnapAxisNone;
2717 } 2732 }
2718 2733
2719 template <> 2734 template <>
2735 inline CSSIdentifierValue::CSSIdentifierValue(SnapStrictness strictness)
2736 : CSSValue(kIdentifierClass) {
2737 switch (strictness) {
2738 case kSnapStrictnessProximity:
2739 value_id_ = CSSValueProximity;
2740 break;
2741 case kSnapStrictnessMandatory:
2742 value_id_ = CSSValueMandatory;
2743 break;
2744 }
2745 }
2746
2747 template <>
2748 inline SnapStrictness CSSIdentifierValue::ConvertTo() const {
2749 switch (GetValueID()) {
2750 case CSSValueProximity:
2751 return kSnapStrictnessProximity;
2752 case CSSValueMandatory:
2753 return kSnapStrictnessMandatory;
2754 default:
2755 break;
2756 }
2757 NOTREACHED();
2758 return kSnapStrictnessProximity;
2759 }
2760
2761 template <>
2762 inline CSSIdentifierValue::CSSIdentifierValue(SnapAlignment alignment)
2763 : CSSValue(kIdentifierClass) {
2764 switch (alignment) {
2765 case kSnapAlignmentNone:
2766 value_id_ = CSSValueNone;
2767 break;
2768 case kSnapAlignmentStart:
2769 value_id_ = CSSValueStart;
2770 break;
2771 case kSnapAlignmentEnd:
2772 value_id_ = CSSValueEnd;
2773 break;
2774 case kSnapAlignmentCenter:
2775 value_id_ = CSSValueCenter;
2776 break;
2777 }
2778 }
2779
2780 template <>
2781 inline SnapAlignment CSSIdentifierValue::ConvertTo() const {
2782 switch (GetValueID()) {
2783 case CSSValueNone:
2784 return kSnapAlignmentNone;
2785 case CSSValueStart:
2786 return kSnapAlignmentStart;
2787 case CSSValueEnd:
2788 return kSnapAlignmentEnd;
2789 case CSSValueCenter:
2790 return kSnapAlignmentCenter;
2791 default:
2792 break;
2793 }
2794 NOTREACHED();
2795 return kSnapAlignmentNone;
2796 }
2797
2798 template <>
shend 2017/06/14 01:37:38 (*) You may delete this function.
sunyunjia 2017/06/14 18:36:21 Done.
2799 inline CSSIdentifierValue::CSSIdentifierValue(EScrollSnapStop stop)
2800 : CSSValue(kIdentifierClass) {
2801 switch (stop) {
2802 case EScrollSnapStop::kNormal:
2803 value_id_ = CSSValueNormal;
2804 break;
2805 case EScrollSnapStop::kAlways:
2806 value_id_ = CSSValueAlways;
2807 break;
2808 }
2809 }
2810
2811 template <>
shend 2017/06/14 01:37:38 (*) You may delete this function.
sunyunjia 2017/06/14 18:36:21 Done.
2812 inline EScrollSnapStop CSSIdentifierValue::ConvertTo() const {
2813 switch (GetValueID()) {
2814 case CSSValueNormal:
2815 return EScrollSnapStop::kNormal;
2816 case CSSValueAlways:
2817 return EScrollSnapStop::kAlways;
2818 default:
2819 break;
2820 }
2821 NOTREACHED();
2822 return EScrollSnapStop::kNormal;
2823 }
2824
2825 template <>
2720 inline CSSIdentifierValue::CSSIdentifierValue(Containment snap_type) 2826 inline CSSIdentifierValue::CSSIdentifierValue(Containment snap_type)
2721 : CSSValue(kIdentifierClass) { 2827 : CSSValue(kIdentifierClass) {
2722 switch (snap_type) { 2828 switch (snap_type) {
2723 case kContainsNone: 2829 case kContainsNone:
2724 value_id_ = CSSValueNone; 2830 value_id_ = CSSValueNone;
2725 break; 2831 break;
2726 case kContainsStrict: 2832 case kContainsStrict:
2727 value_id_ = CSSValueStrict; 2833 value_id_ = CSSValueStrict;
2728 break; 2834 break;
2729 case kContainsContent: 2835 case kContainsContent:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 default: 2870 default:
2765 break; 2871 break;
2766 } 2872 }
2767 NOTREACHED(); 2873 NOTREACHED();
2768 return kContainsNone; 2874 return kContainsNone;
2769 } 2875 }
2770 2876
2771 } // namespace blink 2877 } // namespace blink
2772 2878
2773 #endif 2879 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698