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

Side by Side Diff: Source/core/css/CSSPrimitiveValue.cpp

Issue 813233002: Animation: Fix loss of type information when interpolating value of 0 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix second accumulateLength method Created 6 years 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 | « Source/core/css/CSSPrimitiveValue.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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 // We do not apply the zoom factor when we are computing the value of the fo nt-size property. The zooming 658 // We do not apply the zoom factor when we are computing the value of the fo nt-size property. The zooming
659 // for font sizes is much more complicated, since we have to worry about enf orcing the minimum font size preference 659 // for font sizes is much more complicated, since we have to worry about enf orcing the minimum font size preference
660 // as well as enforcing the implicit "smart minimum." 660 // as well as enforcing the implicit "smart minimum."
661 double result = getDoubleValue() * factor; 661 double result = getDoubleValue() * factor;
662 if (isFontRelativeLength()) 662 if (isFontRelativeLength())
663 return result; 663 return result;
664 664
665 return result * conversionData.zoom(); 665 return result * conversionData.zoom();
666 } 666 }
667 667
668 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, CSSLe ngthTypeArray& lengthTypeArray, double multiplier) const
669 {
670 ASSERT(lengthArray.size() == LengthUnitTypeCount);
671
672 if (m_primitiveUnitType == CSS_CALC) {
673 cssCalcValue()->accumulateLengthArray(lengthArray, lengthTypeArray, mult iplier);
674 return;
675 }
676
677 LengthUnitType lengthType;
678 if (unitTypeToLengthUnitType(static_cast<UnitType>(m_primitiveUnitType), len gthType)) {
679 lengthArray.at(lengthType) += m_value.num * conversionToCanonicalUnitsSc aleFactor(static_cast<UnitType>(m_primitiveUnitType)) * multiplier;
680 lengthTypeArray.set(lengthType);
681 }
682 }
683
668 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, doubl e multiplier) const 684 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, doubl e multiplier) const
669 { 685 {
670 ASSERT(lengthArray.size() == LengthUnitTypeCount); 686 CSSLengthTypeArray lengthTypeArray;
671 687 lengthTypeArray.resize(CSSPrimitiveValue::LengthUnitTypeCount);
672 if (m_primitiveUnitType == CSS_CALC) { 688 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i)
673 cssCalcValue()->accumulateLengthArray(lengthArray, multiplier); 689 lengthTypeArray.clear(i);
674 return; 690 return CSSPrimitiveValue::accumulateLengthArray(lengthArray, lengthTypeArray , multiplier);
675 }
676
677 LengthUnitType lengthType;
678 if (unitTypeToLengthUnitType(static_cast<UnitType>(m_primitiveUnitType), len gthType))
679 lengthArray.at(lengthType) += m_value.num * conversionToCanonicalUnitsSc aleFactor(static_cast<UnitType>(m_primitiveUnitType)) * multiplier;
680 } 691 }
681 692
682 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(UnitType unitTyp e) 693 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(UnitType unitTyp e)
683 { 694 {
684 double factor = 1.0; 695 double factor = 1.0;
685 // FIXME: the switch can be replaced by an array of scale factors. 696 // FIXME: the switch can be replaced by an array of scale factors.
686 switch (unitType) { 697 switch (unitType) {
687 // These are "canonical" units in their respective categories. 698 // These are "canonical" units in their respective categories.
688 case CSS_PX: 699 case CSS_PX:
689 case CSS_DEG: 700 case CSS_DEG:
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 visitor->trace(m_value.shape); 1236 visitor->trace(m_value.shape);
1226 break; 1237 break;
1227 default: 1238 default:
1228 break; 1239 break;
1229 } 1240 }
1230 #endif 1241 #endif
1231 CSSValue::traceAfterDispatch(visitor); 1242 CSSValue::traceAfterDispatch(visitor);
1232 } 1243 }
1233 1244
1234 } // namespace blink 1245 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698