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

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

Issue 2051313002: Encapsulate the CSSPrimitiveValue UnitType trie bethind a method that takes a StringView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/CSSAngleValue.h" 5 #include "core/css/cssom/CSSAngleValue.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/CSSPrimitiveValueUnitTrie.h"
10 #include "wtf/MathExtras.h" 9 #include "wtf/MathExtras.h"
11 10
12 namespace blink { 11 namespace blink {
13 12
14 CSSAngleValue* CSSAngleValue::create(double value, const String& unit, Exception State& exceptionState) 13 CSSAngleValue* CSSAngleValue::create(double value, const String& unit, Exception State& exceptionState)
15 { 14 {
16 CSSPrimitiveValue::UnitType primitiveUnit; 15 CSSPrimitiveValue::UnitType primitiveUnit = CSSPrimitiveValue::stringToUnitT ype(unit);
17 if (unit.is8Bit())
18 primitiveUnit = lookupCSSPrimitiveValueUnit(unit.characters8(), unit.len gth());
19 else
20 primitiveUnit = lookupCSSPrimitiveValueUnit(unit.characters16(), unit.le ngth());
21 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit)); 16 DCHECK(CSSPrimitiveValue::isAngle(primitiveUnit));
22 return new CSSAngleValue(value, primitiveUnit); 17 return new CSSAngleValue(value, primitiveUnit);
23 } 18 }
24 19
25 double CSSAngleValue::degrees() const 20 double CSSAngleValue::degrees() const
26 { 21 {
27 switch (m_unit) { 22 switch (m_unit) {
28 case CSSPrimitiveValue::UnitType::Degrees: 23 case CSSPrimitiveValue::UnitType::Degrees:
29 return m_value; 24 return m_value;
30 case CSSPrimitiveValue::UnitType::Radians: 25 case CSSPrimitiveValue::UnitType::Radians:
(...skipping 22 matching lines...) Expand all
53 { 48 {
54 return deg2turn(degrees()); 49 return deg2turn(degrees());
55 } 50 }
56 51
57 CSSValue* CSSAngleValue::toCSSValue() const 52 CSSValue* CSSAngleValue::toCSSValue() const
58 { 53 {
59 return CSSPrimitiveValue::create(m_value, m_unit); 54 return CSSPrimitiveValue::create(m_value, m_unit);
60 } 55 }
61 56
62 } // namespace blink 57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698