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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGLengthTearOff.cpp

Issue 2354283002: Drop the SVGLengthType enumeration (Closed)
Patch Set: Drop the enum entirely 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
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGLengthTearOff.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 inline bool canResolveRelativeUnits(const SVGElement* contextElement) 60 inline bool canResolveRelativeUnits(const SVGElement* contextElement)
61 { 61 {
62 return contextElement && contextElement->isConnected(); 62 return contextElement && contextElement->isConnected();
63 } 63 }
64 64
65 inline CSSPrimitiveValue::UnitType toCSSUnitType(unsigned short type) 65 inline CSSPrimitiveValue::UnitType toCSSUnitType(unsigned short type)
66 { 66 {
67 ASSERT(isValidLengthUnit(type)); 67 ASSERT(isValidLengthUnit(type));
68 if (type == LengthTypeNumber) 68 if (type == SVGLengthTearOff::kSvgLengthtypeNumber)
69 return CSSPrimitiveValue::UnitType::UserUnits; 69 return CSSPrimitiveValue::UnitType::UserUnits;
70 return static_cast<CSSPrimitiveValue::UnitType>(type); 70 return static_cast<CSSPrimitiveValue::UnitType>(type);
71 } 71 }
72 72
73 inline SVGLengthType toSVGLengthType(CSSPrimitiveValue::UnitType type) 73 inline unsigned short toInterfaceConstant(CSSPrimitiveValue::UnitType type)
74 { 74 {
75 switch (type) { 75 switch (type) {
76 case CSSPrimitiveValue::UnitType::Unknown: 76 case CSSPrimitiveValue::UnitType::Unknown:
77 return LengthTypeUnknown; 77 return SVGLengthTearOff::kSvgLengthtypeUnknown;
78 case CSSPrimitiveValue::UnitType::UserUnits: 78 case CSSPrimitiveValue::UnitType::UserUnits:
79 return LengthTypeNumber; 79 return SVGLengthTearOff::kSvgLengthtypeNumber;
80 case CSSPrimitiveValue::UnitType::Percentage: 80 case CSSPrimitiveValue::UnitType::Percentage:
81 return LengthTypePercentage; 81 return SVGLengthTearOff::kSvgLengthtypePercentage;
82 case CSSPrimitiveValue::UnitType::Ems: 82 case CSSPrimitiveValue::UnitType::Ems:
83 return LengthTypeEMS; 83 return SVGLengthTearOff::kSvgLengthtypeEms;
84 case CSSPrimitiveValue::UnitType::Exs: 84 case CSSPrimitiveValue::UnitType::Exs:
85 return LengthTypeEXS; 85 return SVGLengthTearOff::kSvgLengthtypeExs;
86 case CSSPrimitiveValue::UnitType::Pixels: 86 case CSSPrimitiveValue::UnitType::Pixels:
87 return LengthTypePX; 87 return SVGLengthTearOff::kSvgLengthtypePx;
88 case CSSPrimitiveValue::UnitType::Centimeters: 88 case CSSPrimitiveValue::UnitType::Centimeters:
89 return LengthTypeCM; 89 return SVGLengthTearOff::kSvgLengthtypeCm;
90 case CSSPrimitiveValue::UnitType::Millimeters: 90 case CSSPrimitiveValue::UnitType::Millimeters:
91 return LengthTypeMM; 91 return SVGLengthTearOff::kSvgLengthtypeMm;
92 case CSSPrimitiveValue::UnitType::Inches: 92 case CSSPrimitiveValue::UnitType::Inches:
93 return LengthTypeIN; 93 return SVGLengthTearOff::kSvgLengthtypeIn;
94 case CSSPrimitiveValue::UnitType::Points: 94 case CSSPrimitiveValue::UnitType::Points:
95 return LengthTypePT; 95 return SVGLengthTearOff::kSvgLengthtypePt;
96 case CSSPrimitiveValue::UnitType::Picas: 96 case CSSPrimitiveValue::UnitType::Picas:
97 return LengthTypePC; 97 return SVGLengthTearOff::kSvgLengthtypePc;
98 default: 98 default:
99 return LengthTypeUnknown; 99 return SVGLengthTearOff::kSvgLengthtypeUnknown;
100 } 100 }
101 } 101 }
102 102
103 } // namespace 103 } // namespace
104 104
105 bool SVGLengthTearOff::hasExposedLengthUnit() 105 bool SVGLengthTearOff::hasExposedLengthUnit()
106 { 106 {
107 if (target()->isCalculated()) 107 if (target()->isCalculated())
108 return false; 108 return false;
109 109
110 CSSPrimitiveValue::UnitType unit = target()->typeWithCalcResolved(); 110 CSSPrimitiveValue::UnitType unit = target()->typeWithCalcResolved();
111 return isValidLengthUnit(unit) 111 return isValidLengthUnit(unit)
112 || unit == CSSPrimitiveValue::UnitType::Unknown 112 || unit == CSSPrimitiveValue::UnitType::Unknown
113 || unit == CSSPrimitiveValue::UnitType::UserUnits; 113 || unit == CSSPrimitiveValue::UnitType::UserUnits;
114 } 114 }
115 115
116 SVGLengthType SVGLengthTearOff::unitType() 116 unsigned short SVGLengthTearOff::unitType()
117 { 117 {
118 return hasExposedLengthUnit() ? toSVGLengthType(target()->typeWithCalcResolv ed()) : LengthTypeUnknown; 118 return hasExposedLengthUnit() ? toInterfaceConstant(target()->typeWithCalcRe solved()) : kSvgLengthtypeUnknown;
119 } 119 }
120 120
121 SVGLengthMode SVGLengthTearOff::unitMode() 121 SVGLengthMode SVGLengthTearOff::unitMode()
122 { 122 {
123 return target()->unitMode(); 123 return target()->unitMode();
124 } 124 }
125 125
126 float SVGLengthTearOff::value(ExceptionState& exceptionState) 126 float SVGLengthTearOff::value(ExceptionState& exceptionState)
127 { 127 {
128 if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) { 128 if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 : SVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, a ttributeName) 234 : SVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, a ttributeName)
235 { 235 {
236 } 236 }
237 237
238 DEFINE_TRACE_WRAPPERS(SVGLengthTearOff) 238 DEFINE_TRACE_WRAPPERS(SVGLengthTearOff)
239 { 239 {
240 visitor->traceWrappers(contextElement()); 240 visitor->traceWrappers(contextElement());
241 } 241 }
242 242
243 } // namespace blink 243 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGLengthTearOff.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698