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

Side by Side Diff: Source/core/css/CSSCalculationValue.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/CSSCalculationValue.h ('k') | Source/core/css/CSSPrimitiveValue.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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 case CalcPercentNumber: 246 case CalcPercentNumber:
247 case CalcTime: 247 case CalcTime:
248 case CalcOther: 248 case CalcOther:
249 ASSERT_NOT_REACHED(); 249 ASSERT_NOT_REACHED();
250 break; 250 break;
251 } 251 }
252 ASSERT_NOT_REACHED(); 252 ASSERT_NOT_REACHED();
253 return 0; 253 return 0;
254 } 254 }
255 255
256 virtual void accumulateLengthArray(CSSLengthArray& lengthArray, double multi plier) const override 256 virtual void accumulateLengthArray(CSSLengthArray& lengthArray, CSSLengthTyp eArray& lengthTypeArray, double multiplier) const override
257 { 257 {
258 ASSERT(category() != CalcNumber); 258 ASSERT(category() != CalcNumber);
259 m_value->accumulateLengthArray(lengthArray, multiplier); 259 m_value->accumulateLengthArray(lengthArray, lengthTypeArray, multiplier) ;
260 } 260 }
261 261
262 virtual bool equals(const CSSCalcExpressionNode& other) const override 262 virtual bool equals(const CSSCalcExpressionNode& other) const override
263 { 263 {
264 if (type() != other.type()) 264 if (type() != other.type())
265 return false; 265 return false;
266 266
267 return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveVal ue&>(other).m_value); 267 return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveVal ue&>(other).m_value);
268 } 268 }
269 269
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue()); 442 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue());
443 } 443 }
444 444
445 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa ta) const override 445 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa ta) const override
446 { 446 {
447 const double leftValue = m_leftSide->computeLengthPx(conversionData); 447 const double leftValue = m_leftSide->computeLengthPx(conversionData);
448 const double rightValue = m_rightSide->computeLengthPx(conversionData); 448 const double rightValue = m_rightSide->computeLengthPx(conversionData);
449 return evaluate(leftValue, rightValue); 449 return evaluate(leftValue, rightValue);
450 } 450 }
451 451
452 virtual void accumulateLengthArray(CSSLengthArray& lengthArray, double multi plier) const override 452 virtual void accumulateLengthArray(CSSLengthArray& lengthArray, CSSLengthTyp eArray& lengthTypeArray, double multiplier) const override
453 { 453 {
454 switch (m_operator) { 454 switch (m_operator) {
455 case CalcAdd: 455 case CalcAdd:
456 m_leftSide->accumulateLengthArray(lengthArray, multiplier); 456 m_leftSide->accumulateLengthArray(lengthArray, lengthTypeArray, mult iplier);
457 m_rightSide->accumulateLengthArray(lengthArray, multiplier); 457 m_rightSide->accumulateLengthArray(lengthArray, lengthTypeArray, mul tiplier);
458 break; 458 break;
459 case CalcSubtract: 459 case CalcSubtract:
460 m_leftSide->accumulateLengthArray(lengthArray, multiplier); 460 m_leftSide->accumulateLengthArray(lengthArray, lengthTypeArray, mult iplier);
461 m_rightSide->accumulateLengthArray(lengthArray, -multiplier); 461 m_rightSide->accumulateLengthArray(lengthArray, lengthTypeArray, -mu ltiplier);
462 break; 462 break;
463 case CalcMultiply: 463 case CalcMultiply:
464 ASSERT((m_leftSide->category() == CalcNumber) != (m_rightSide->categ ory() == CalcNumber)); 464 ASSERT((m_leftSide->category() == CalcNumber) != (m_rightSide->categ ory() == CalcNumber));
465 if (m_leftSide->category() == CalcNumber) 465 if (m_leftSide->category() == CalcNumber)
466 m_rightSide->accumulateLengthArray(lengthArray, multiplier * m_l eftSide->doubleValue()); 466 m_rightSide->accumulateLengthArray(lengthArray, lengthTypeArray, multiplier * m_leftSide->doubleValue());
467 else 467 else
468 m_leftSide->accumulateLengthArray(lengthArray, multiplier * m_ri ghtSide->doubleValue()); 468 m_leftSide->accumulateLengthArray(lengthArray, lengthTypeArray, multiplier * m_rightSide->doubleValue());
469 break; 469 break;
470 case CalcDivide: 470 case CalcDivide:
471 ASSERT(m_rightSide->category() == CalcNumber); 471 ASSERT(m_rightSide->category() == CalcNumber);
472 m_leftSide->accumulateLengthArray(lengthArray, multiplier / m_rightS ide->doubleValue()); 472 m_leftSide->accumulateLengthArray(lengthArray, lengthTypeArray, mult iplier / m_rightSide->doubleValue());
473 break; 473 break;
474 default: 474 default:
475 ASSERT_NOT_REACHED(); 475 ASSERT_NOT_REACHED();
476 } 476 }
477 } 477 }
478 478
479 static String buildCSSText(const String& leftExpression, const String& right Expression, CalcOperator op) 479 static String buildCSSText(const String& leftExpression, const String& right Expression, CalcOperator op)
480 { 480 {
481 StringBuilder result; 481 StringBuilder result;
482 result.append('('); 482 result.append('(');
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 return adoptRefWillBeNoop(new CSSCalcValue(expression, range)); 761 return adoptRefWillBeNoop(new CSSCalcValue(expression, range));
762 } 762 }
763 763
764 void CSSCalcValue::traceAfterDispatch(Visitor* visitor) 764 void CSSCalcValue::traceAfterDispatch(Visitor* visitor)
765 { 765 {
766 visitor->trace(m_expression); 766 visitor->trace(m_expression);
767 CSSValue::traceAfterDispatch(visitor); 767 CSSValue::traceAfterDispatch(visitor);
768 } 768 }
769 769
770 } // namespace blink 770 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSCalculationValue.h ('k') | Source/core/css/CSSPrimitiveValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698