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

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

Issue 2390773004: reflow comments in core/svg/ (Closed)
Patch Set: comments (heh!) Created 4 years, 2 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) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 isCalcCSSUnitType(type)) && 97 isCalcCSSUnitType(type)) &&
98 type != CSSPrimitiveValue::UnitType::QuirkyEms; 98 type != CSSPrimitiveValue::UnitType::QuirkyEms;
99 } 99 }
100 100
101 void SVGLength::setUnitType(CSSPrimitiveValue::UnitType type) { 101 void SVGLength::setUnitType(CSSPrimitiveValue::UnitType type) {
102 ASSERT(isSupportedCSSUnitType(type)); 102 ASSERT(isSupportedCSSUnitType(type));
103 m_value = CSSPrimitiveValue::create(m_value->getFloatValue(), type); 103 m_value = CSSPrimitiveValue::create(m_value->getFloatValue(), type);
104 } 104 }
105 105
106 float SVGLength::valueAsPercentage() const { 106 float SVGLength::valueAsPercentage() const {
107 // LengthTypePercentage is represented with 100% = 100.0. Good for accuracy bu t could eventually be changed. 107 // LengthTypePercentage is represented with 100% = 100.0. Good for accuracy
108 // but could eventually be changed.
108 if (m_value->isPercentage()) { 109 if (m_value->isPercentage()) {
109 // Note: This division is a source of floating point inaccuracy. 110 // Note: This division is a source of floating point inaccuracy.
110 return m_value->getFloatValue() / 100; 111 return m_value->getFloatValue() / 100;
111 } 112 }
112 113
113 return m_value->getFloatValue(); 114 return m_value->getFloatValue();
114 } 115 }
115 116
116 float SVGLength::valueAsPercentage100() const { 117 float SVGLength::valueAsPercentage100() const {
117 // LengthTypePercentage is represented with 100% = 100.0. Good for accuracy bu t could eventually be changed. 118 // LengthTypePercentage is represented with 100% = 100.0. Good for accuracy
119 // but could eventually be changed.
118 if (m_value->isPercentage()) 120 if (m_value->isPercentage())
119 return m_value->getFloatValue(); 121 return m_value->getFloatValue();
120 122
121 return m_value->getFloatValue() * 100; 123 return m_value->getFloatValue() * 100;
122 } 124 }
123 125
124 float SVGLength::scaleByPercentage(float input) const { 126 float SVGLength::scaleByPercentage(float input) const {
125 float result = input * m_value->getFloatValue(); 127 float result = input * m_value->getFloatValue();
126 if (m_value->isPercentage()) { 128 if (m_value->isPercentage()) {
127 // Delaying division by 100 as long as possible since it introduces floating point errors. 129 // Delaying division by 100 as long as possible since it introduces floating
130 // point errors.
128 result = result / 100; 131 result = result / 100;
129 } 132 }
130 return result; 133 return result;
131 } 134 }
132 135
133 SVGParsingError SVGLength::setValueAsString(const String& string) { 136 SVGParsingError SVGLength::setValueAsString(const String& string) {
134 if (string.isEmpty()) { 137 if (string.isEmpty()) {
135 m_value = 138 m_value =
136 CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::UserUnits); 139 CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::UserUnits);
137 return SVGParseStatus::NoError; 140 return SVGParseStatus::NoError;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 SVGLengthContext lengthContext(contextElement); 243 SVGLengthContext lengthContext(contextElement);
241 float animatedNumber = value(lengthContext); 244 float animatedNumber = value(lengthContext);
242 animationElement->animateAdditiveNumber( 245 animationElement->animateAdditiveNumber(
243 percentage, repeatCount, fromLength->value(lengthContext), 246 percentage, repeatCount, fromLength->value(lengthContext),
244 toLength->value(lengthContext), 247 toLength->value(lengthContext),
245 toAtEndOfDurationLength->value(lengthContext), animatedNumber); 248 toAtEndOfDurationLength->value(lengthContext), animatedNumber);
246 249
247 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute( 250 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute(
248 animationElement->attributeName())); 251 animationElement->attributeName()));
249 252
250 // TODO(shanmuga.m): Construct a calc() expression if the units fall in differ ent categories. 253 // TODO(shanmuga.m): Construct a calc() expression if the units fall in
254 // different categories.
251 CSSPrimitiveValue::UnitType newUnit = CSSPrimitiveValue::UnitType::UserUnits; 255 CSSPrimitiveValue::UnitType newUnit = CSSPrimitiveValue::UnitType::UserUnits;
252 if (percentage < 0.5) { 256 if (percentage < 0.5) {
253 if (!fromLength->isCalculated()) 257 if (!fromLength->isCalculated())
254 newUnit = fromLength->typeWithCalcResolved(); 258 newUnit = fromLength->typeWithCalcResolved();
255 } else { 259 } else {
256 if (!toLength->isCalculated()) 260 if (!toLength->isCalculated())
257 newUnit = toLength->typeWithCalcResolved(); 261 newUnit = toLength->typeWithCalcResolved();
258 } 262 }
259 animatedNumber = lengthContext.convertValueFromUserUnits(animatedNumber, 263 animatedNumber = lengthContext.convertValueFromUserUnits(animatedNumber,
260 unitMode(), newUnit); 264 unitMode(), newUnit);
261 m_value = CSSPrimitiveValue::create(animatedNumber, newUnit); 265 m_value = CSSPrimitiveValue::create(animatedNumber, newUnit);
262 } 266 }
263 267
264 float SVGLength::calculateDistance(SVGPropertyBase* toValue, 268 float SVGLength::calculateDistance(SVGPropertyBase* toValue,
265 SVGElement* contextElement) { 269 SVGElement* contextElement) {
266 SVGLengthContext lengthContext(contextElement); 270 SVGLengthContext lengthContext(contextElement);
267 SVGLength* toLength = toSVGLength(toValue); 271 SVGLength* toLength = toSVGLength(toValue);
268 272
269 return fabsf(toLength->value(lengthContext) - value(lengthContext)); 273 return fabsf(toLength->value(lengthContext) - value(lengthContext));
270 } 274 }
271 275
272 } // namespace blink 276 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGLength.h ('k') | third_party/WebKit/Source/core/svg/SVGLengthContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698