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

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

Issue 966923003: Make SVGLengthMode an enum class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | « Source/core/svg/SVGLength.h ('k') | 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return type; 110 return type;
111 111
112 return LengthTypeUnknown; 112 return LengthTypeUnknown;
113 } 113 }
114 114
115 } // namespace 115 } // namespace
116 116
117 SVGLength::SVGLength(SVGLengthMode mode) 117 SVGLength::SVGLength(SVGLengthMode mode)
118 : SVGPropertyBase(classType()) 118 : SVGPropertyBase(classType())
119 , m_valueInSpecifiedUnits(0) 119 , m_valueInSpecifiedUnits(0)
120 , m_unitMode(mode) 120 , m_unitMode(static_cast<unsigned>(mode))
121 , m_unitType(LengthTypeNumber) 121 , m_unitType(LengthTypeNumber)
122 { 122 {
123 ASSERT(unitMode() == mode);
123 } 124 }
124 125
125 SVGLength::SVGLength(const SVGLength& o) 126 SVGLength::SVGLength(const SVGLength& o)
126 : SVGPropertyBase(classType()) 127 : SVGPropertyBase(classType())
127 , m_valueInSpecifiedUnits(o.m_valueInSpecifiedUnits) 128 , m_valueInSpecifiedUnits(o.m_valueInSpecifiedUnits)
128 , m_unitMode(o.m_unitMode) 129 , m_unitMode(o.m_unitMode)
129 , m_unitType(o.m_unitType) 130 , m_unitType(o.m_unitType)
130 { 131 {
131 } 132 }
132 133
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 353
353 return CSSPrimitiveValue::create(length->valueInSpecifiedUnits(), cssType); 354 return CSSPrimitiveValue::create(length->valueInSpecifiedUnits(), cssType);
354 } 355 }
355 356
356 SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam e& attrName) 357 SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam e& attrName)
357 { 358 {
358 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa p; 359 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa p;
359 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ()); 360 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ());
360 361
361 if (s_lengthModeMap.isEmpty()) { 362 if (s_lengthModeMap.isEmpty()) {
362 s_lengthModeMap.set(SVGNames::xAttr, LengthModeWidth); 363 s_lengthModeMap.set(SVGNames::xAttr, SVGLengthMode::Width);
363 s_lengthModeMap.set(SVGNames::yAttr, LengthModeHeight); 364 s_lengthModeMap.set(SVGNames::yAttr, SVGLengthMode::Height);
364 s_lengthModeMap.set(SVGNames::cxAttr, LengthModeWidth); 365 s_lengthModeMap.set(SVGNames::cxAttr, SVGLengthMode::Width);
365 s_lengthModeMap.set(SVGNames::cyAttr, LengthModeHeight); 366 s_lengthModeMap.set(SVGNames::cyAttr, SVGLengthMode::Height);
366 s_lengthModeMap.set(SVGNames::dxAttr, LengthModeWidth); 367 s_lengthModeMap.set(SVGNames::dxAttr, SVGLengthMode::Width);
367 s_lengthModeMap.set(SVGNames::dyAttr, LengthModeHeight); 368 s_lengthModeMap.set(SVGNames::dyAttr, SVGLengthMode::Height);
368 s_lengthModeMap.set(SVGNames::fxAttr, LengthModeWidth); 369 s_lengthModeMap.set(SVGNames::fxAttr, SVGLengthMode::Width);
369 s_lengthModeMap.set(SVGNames::fyAttr, LengthModeHeight); 370 s_lengthModeMap.set(SVGNames::fyAttr, SVGLengthMode::Height);
370 s_lengthModeMap.set(SVGNames::rAttr, LengthModeOther); 371 s_lengthModeMap.set(SVGNames::rAttr, SVGLengthMode::Other);
371 s_lengthModeMap.set(SVGNames::rxAttr, LengthModeWidth); 372 s_lengthModeMap.set(SVGNames::rxAttr, SVGLengthMode::Width);
372 s_lengthModeMap.set(SVGNames::ryAttr, LengthModeHeight); 373 s_lengthModeMap.set(SVGNames::ryAttr, SVGLengthMode::Height);
373 s_lengthModeMap.set(SVGNames::widthAttr, LengthModeWidth); 374 s_lengthModeMap.set(SVGNames::widthAttr, SVGLengthMode::Width);
374 s_lengthModeMap.set(SVGNames::heightAttr, LengthModeHeight); 375 s_lengthModeMap.set(SVGNames::heightAttr, SVGLengthMode::Height);
375 s_lengthModeMap.set(SVGNames::x1Attr, LengthModeWidth); 376 s_lengthModeMap.set(SVGNames::x1Attr, SVGLengthMode::Width);
376 s_lengthModeMap.set(SVGNames::x2Attr, LengthModeWidth); 377 s_lengthModeMap.set(SVGNames::x2Attr, SVGLengthMode::Width);
377 s_lengthModeMap.set(SVGNames::y1Attr, LengthModeHeight); 378 s_lengthModeMap.set(SVGNames::y1Attr, SVGLengthMode::Height);
378 s_lengthModeMap.set(SVGNames::y2Attr, LengthModeHeight); 379 s_lengthModeMap.set(SVGNames::y2Attr, SVGLengthMode::Height);
379 s_lengthModeMap.set(SVGNames::refXAttr, LengthModeWidth); 380 s_lengthModeMap.set(SVGNames::refXAttr, SVGLengthMode::Width);
380 s_lengthModeMap.set(SVGNames::refYAttr, LengthModeHeight); 381 s_lengthModeMap.set(SVGNames::refYAttr, SVGLengthMode::Height);
381 s_lengthModeMap.set(SVGNames::markerWidthAttr, LengthModeWidth); 382 s_lengthModeMap.set(SVGNames::markerWidthAttr, SVGLengthMode::Width);
382 s_lengthModeMap.set(SVGNames::markerHeightAttr, LengthModeHeight); 383 s_lengthModeMap.set(SVGNames::markerHeightAttr, SVGLengthMode::Height);
383 s_lengthModeMap.set(SVGNames::textLengthAttr, LengthModeWidth); 384 s_lengthModeMap.set(SVGNames::textLengthAttr, SVGLengthMode::Width);
384 s_lengthModeMap.set(SVGNames::startOffsetAttr, LengthModeWidth); 385 s_lengthModeMap.set(SVGNames::startOffsetAttr, SVGLengthMode::Width);
385 } 386 }
386 387
387 if (s_lengthModeMap.contains(attrName)) 388 if (s_lengthModeMap.contains(attrName))
388 return s_lengthModeMap.get(attrName); 389 return s_lengthModeMap.get(attrName);
389 390
390 return LengthModeOther; 391 return SVGLengthMode::Other;
391 } 392 }
392 393
393 PassRefPtrWillBeRawPtr<SVGLength> SVGLength::blend(PassRefPtrWillBeRawPtr<SVGLen gth> passFrom, float progress) const 394 PassRefPtrWillBeRawPtr<SVGLength> SVGLength::blend(PassRefPtrWillBeRawPtr<SVGLen gth> passFrom, float progress) const
394 { 395 {
395 RefPtrWillBeRawPtr<SVGLength> from = passFrom; 396 RefPtrWillBeRawPtr<SVGLength> from = passFrom;
396 397
397 SVGLengthType toType = unitType(); 398 SVGLengthType toType = unitType();
398 SVGLengthType fromType = from->unitType(); 399 SVGLengthType fromType = from->unitType();
399 if ((from->isZero() && isZero()) 400 if ((from->isZero() && isZero())
400 || fromType == LengthTypeUnknown 401 || fromType == LengthTypeUnknown
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 459
459 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal ue, SVGElement* contextElement) 460 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal ue, SVGElement* contextElement)
460 { 461 {
461 SVGLengthContext lengthContext(contextElement); 462 SVGLengthContext lengthContext(contextElement);
462 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); 463 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue);
463 464
464 return fabsf(toLength->value(lengthContext) - value(lengthContext)); 465 return fabsf(toLength->value(lengthContext) - value(lengthContext));
465 } 466 }
466 467
467 } 468 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGLength.h ('k') | Source/core/svg/SVGLengthContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698