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

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

Issue 2738863002: Replace ASSERT with DCHECK in core/svg/ (Closed)
Patch Set: Split DCHECKS wherever possible Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 svgEnumeration->setValueAsString(value); 44 svgEnumeration->setValueAsString(value);
45 return svgEnumeration; 45 return svgEnumeration;
46 } 46 }
47 47
48 String SVGEnumerationBase::valueAsString() const { 48 String SVGEnumerationBase::valueAsString() const {
49 for (const auto& entry : m_entries) { 49 for (const auto& entry : m_entries) {
50 if (m_value == entry.first) 50 if (m_value == entry.first)
51 return entry.second; 51 return entry.second;
52 } 52 }
53 53
54 ASSERT(m_value < maxInternalEnumValue()); 54 DCHECK_LT(m_value, maxInternalEnumValue());
55 return emptyString; 55 return emptyString;
56 } 56 }
57 57
58 void SVGEnumerationBase::setValue(unsigned short value) { 58 void SVGEnumerationBase::setValue(unsigned short value) {
59 m_value = value; 59 m_value = value;
60 notifyChange(); 60 notifyChange();
61 } 61 }
62 62
63 SVGParsingError SVGEnumerationBase::setValueAsString(const String& string) { 63 SVGParsingError SVGEnumerationBase::setValueAsString(const String& string) {
64 for (const auto& entry : m_entries) { 64 for (const auto& entry : m_entries) {
65 if (string == entry.second) { 65 if (string == entry.second) {
66 // 0 corresponds to _UNKNOWN enumeration values, and should not be 66 // 0 corresponds to _UNKNOWN enumeration values, and should not be
67 // settable. 67 // settable.
68 ASSERT(entry.first); 68 DCHECK(entry.first);
69 m_value = entry.first; 69 m_value = entry.first;
70 notifyChange(); 70 notifyChange();
71 return SVGParseStatus::NoError; 71 return SVGParseStatus::NoError;
72 } 72 }
73 } 73 }
74 74
75 notifyChange(); 75 notifyChange();
76 return SVGParseStatus::ExpectedEnumeration; 76 return SVGParseStatus::ExpectedEnumeration;
77 } 77 }
78 78
79 void SVGEnumerationBase::add(SVGPropertyBase*, SVGElement*) { 79 void SVGEnumerationBase::add(SVGPropertyBase*, SVGElement*) {
80 ASSERT_NOT_REACHED(); 80 ASSERT_NOT_REACHED();
81 } 81 }
82 82
83 void SVGEnumerationBase::calculateAnimatedValue( 83 void SVGEnumerationBase::calculateAnimatedValue(
84 SVGAnimationElement* animationElement, 84 SVGAnimationElement* animationElement,
85 float percentage, 85 float percentage,
86 unsigned repeatCount, 86 unsigned repeatCount,
87 SVGPropertyBase* from, 87 SVGPropertyBase* from,
88 SVGPropertyBase* to, 88 SVGPropertyBase* to,
89 SVGPropertyBase*, 89 SVGPropertyBase*,
90 SVGElement*) { 90 SVGElement*) {
91 ASSERT(animationElement); 91 DCHECK(animationElement);
92 unsigned short fromEnumeration = 92 unsigned short fromEnumeration =
93 animationElement->getAnimationMode() == ToAnimation 93 animationElement->getAnimationMode() == ToAnimation
94 ? m_value 94 ? m_value
95 : toSVGEnumerationBase(from)->value(); 95 : toSVGEnumerationBase(from)->value();
96 unsigned short toEnumeration = toSVGEnumerationBase(to)->value(); 96 unsigned short toEnumeration = toSVGEnumerationBase(to)->value();
97 97
98 animationElement->animateDiscreteType<unsigned short>( 98 animationElement->animateDiscreteType<unsigned short>(
99 percentage, fromEnumeration, toEnumeration, m_value); 99 percentage, fromEnumeration, toEnumeration, m_value);
100 } 100 }
101 101
102 float SVGEnumerationBase::calculateDistance(SVGPropertyBase*, SVGElement*) { 102 float SVGEnumerationBase::calculateDistance(SVGPropertyBase*, SVGElement*) {
103 // No paced animations for boolean. 103 // No paced animations for boolean.
104 return -1; 104 return -1;
105 } 105 }
106 106
107 } // namespace blink 107 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGEnumeration.h ('k') | third_party/WebKit/Source/core/svg/SVGFEBlendElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698