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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSUnitValue.cpp

Issue 2903413002: Restructure type tracking in StyleValues to work better with new numeric types (Closed)
Patch Set: rebase 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 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/cssom/CSSUnitValue.h" 5 #include "core/css/cssom/CSSUnitValue.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 String CSSUnitValue::unit() const { 70 String CSSUnitValue::unit() const {
71 if (unit_ == CSSPrimitiveValue::UnitType::kNumber) 71 if (unit_ == CSSPrimitiveValue::UnitType::kNumber)
72 return "number"; 72 return "number";
73 if (unit_ == CSSPrimitiveValue::UnitType::kPercentage) 73 if (unit_ == CSSPrimitiveValue::UnitType::kPercentage)
74 return "percent"; 74 return "percent";
75 return CSSPrimitiveValue::UnitTypeToString(unit_); 75 return CSSPrimitiveValue::UnitTypeToString(unit_);
76 } 76 }
77 77
78 String CSSUnitValue::type() const { 78 String CSSUnitValue::type() const {
79 return StyleValueTypeToString(GetType());
80 }
81
82 CSSStyleValue::StyleValueType CSSUnitValue::GetType() const {
79 if (unit_ == CSSPrimitiveValue::UnitType::kNumber) 83 if (unit_ == CSSPrimitiveValue::UnitType::kNumber)
80 return "number"; 84 return StyleValueType::kNumberType;
81 if (unit_ == CSSPrimitiveValue::UnitType::kPercentage) 85 if (unit_ == CSSPrimitiveValue::UnitType::kPercentage)
82 return "percent"; 86 return StyleValueType::kPercentType;
83 if (CSSPrimitiveValue::IsLength(unit_)) 87 if (CSSPrimitiveValue::IsLength(unit_))
84 return "length"; 88 return StyleValueType::kLengthType;
85 if (CSSPrimitiveValue::IsAngle(unit_)) 89 if (CSSPrimitiveValue::IsAngle(unit_))
86 return "angle"; 90 return StyleValueType::kAngleType;
87 if (CSSPrimitiveValue::IsTime(unit_)) 91 if (CSSPrimitiveValue::IsTime(unit_))
88 return "time"; 92 return StyleValueType::kTimeType;
89 if (CSSPrimitiveValue::IsFrequency(unit_)) 93 if (CSSPrimitiveValue::IsFrequency(unit_))
90 return "frequency"; 94 return StyleValueType::kFrequencyType;
91 if (CSSPrimitiveValue::IsResolution(unit_)) 95 if (CSSPrimitiveValue::IsResolution(unit_))
92 return "resolution"; 96 return StyleValueType::kResolutionType;
93 if (CSSPrimitiveValue::IsFlex(unit_)) 97 if (CSSPrimitiveValue::IsFlex(unit_))
94 return "flex"; 98 return StyleValueType::kFlexType;
95 return ""; 99 NOTREACHED();
100 return StyleValueType::kUnknownType;
96 } 101 }
97 102
98 const CSSValue* CSSUnitValue::ToCSSValue() const { 103 const CSSValue* CSSUnitValue::ToCSSValue() const {
99 return CSSPrimitiveValue::Create(value_, unit_); 104 return CSSPrimitiveValue::Create(value_, unit_);
100 } 105 }
101 106
102 } // namespace blink 107 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h ('k') | third_party/WebKit/Source/core/css/cssom/CSSUnitValue.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698