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

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

Issue 897313004: Fold up the SVGLengthContext::convertValueFrom* helpers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/svg/SVGLengthContext.h » ('j') | 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) 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 && m_valueInSpecifiedUnits == other.m_valueInSpecifiedUnits; 159 && m_valueInSpecifiedUnits == other.m_valueInSpecifiedUnits;
160 } 160 }
161 161
162 float SVGLength::value(const SVGLengthContext& context) const 162 float SVGLength::value(const SVGLengthContext& context) const
163 { 163 {
164 return context.convertValueToUserUnits(m_valueInSpecifiedUnits, unitMode(), unitType()); 164 return context.convertValueToUserUnits(m_valueInSpecifiedUnits, unitMode(), unitType());
165 } 165 }
166 166
167 void SVGLength::setValue(float value, const SVGLengthContext& context) 167 void SVGLength::setValue(float value, const SVGLengthContext& context)
168 { 168 {
169 // LengthTypePercentage is represented with 100% = 100.0. Good for accuracy but could eventually be changed.
170 if (m_unitType == LengthTypePercentage)
171 value = value / 100;
172
173 m_valueInSpecifiedUnits = context.convertValueFromUserUnits(value, unitMode( ), unitType()); 169 m_valueInSpecifiedUnits = context.convertValueFromUserUnits(value, unitMode( ), unitType());
174 } 170 }
175 171
176 void SVGLength::setUnitType(SVGLengthType type) 172 void SVGLength::setUnitType(SVGLengthType type)
177 { 173 {
178 ASSERT(type != LengthTypeUnknown && type <= LengthTypePC); 174 ASSERT(type != LengthTypeUnknown && type <= LengthTypePC);
179 m_unitType = type; 175 m_unitType = type;
180 } 176 }
181 177
182 float SVGLength::valueAsPercentage() const 178 float SVGLength::valueAsPercentage() const
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 458
463 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal ue, SVGElement* contextElement) 459 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal ue, SVGElement* contextElement)
464 { 460 {
465 SVGLengthContext lengthContext(contextElement); 461 SVGLengthContext lengthContext(contextElement);
466 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); 462 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue);
467 463
468 return fabsf(toLength->value(lengthContext) - value(lengthContext)); 464 return fabsf(toLength->value(lengthContext) - value(lengthContext));
469 } 465 }
470 466
471 } 467 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/svg/SVGLengthContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698