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

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

Issue 2738863002: Replace ASSERT with DCHECK in core/svg/ (Closed)
Patch Set: static_cast<unsigned>(1) > 1u 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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 UseCounter::count(document(), UseCounter::SVGSMILElementInDocument); 307 UseCounter::count(document(), UseCounter::SVGSMILElementInDocument);
308 if (document().isLoadCompleted()) 308 if (document().isLoadCompleted())
309 UseCounter::count(&document(), UseCounter::SVGSMILElementInsertedAfterLoad); 309 UseCounter::count(&document(), UseCounter::SVGSMILElementInsertedAfterLoad);
310 310
311 SVGSVGElement* owner = ownerSVGElement(); 311 SVGSVGElement* owner = ownerSVGElement();
312 if (!owner) 312 if (!owner)
313 return InsertionDone; 313 return InsertionDone;
314 314
315 m_timeContainer = owner->timeContainer(); 315 m_timeContainer = owner->timeContainer();
316 ASSERT(m_timeContainer); 316 DCHECK(m_timeContainer);
317 m_timeContainer->setDocumentOrderIndexesDirty(); 317 m_timeContainer->setDocumentOrderIndexesDirty();
318 318
319 // "If no attribute is present, the default begin value (an offset-value of 0) 319 // "If no attribute is present, the default begin value (an offset-value of 0)
320 // must be evaluated." 320 // must be evaluated."
321 if (!fastHasAttribute(SVGNames::beginAttr)) 321 if (!fastHasAttribute(SVGNames::beginAttr))
322 m_beginTimes.push_back(SMILTimeWithOrigin()); 322 m_beginTimes.push_back(SMILTimeWithOrigin());
323 323
324 if (m_isWaitingForFirstInterval) 324 if (m_isWaitingForFirstInterval)
325 resolveFirstInterval(); 325 resolveFirstInterval();
326 326
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 const SMILTime& currentTime = list[indexOfResult].time(); 748 const SMILTime& currentTime = list[indexOfResult].time();
749 749
750 // The special value "indefinite" does not yield an instance time in the begin 750 // The special value "indefinite" does not yield an instance time in the begin
751 // list. 751 // list.
752 if (currentTime.isIndefinite() && beginOrEnd == Begin) 752 if (currentTime.isIndefinite() && beginOrEnd == Begin)
753 return SMILTime::unresolved(); 753 return SMILTime::unresolved();
754 754
755 if (currentTime > minimumTime) 755 if (currentTime > minimumTime)
756 return currentTime; 756 return currentTime;
757 757
758 ASSERT(currentTime == minimumTime); 758 DCHECK(currentTime == minimumTime);
tkent 2017/03/14 22:33:14 Use DCHECK_EQ if possible
mrunal 2017/03/14 23:52:14 It throws compiler error, ../../base/logging.h:659
759 if (equalsMinimumOK) 759 if (equalsMinimumOK)
760 return currentTime; 760 return currentTime;
761 761
762 // If the equals is not accepted, return the next bigger item in the list. 762 // If the equals is not accepted, return the next bigger item in the list.
763 SMILTime nextTime = currentTime; 763 SMILTime nextTime = currentTime;
764 while (indexOfResult < sizeOfList - 1) { 764 while (indexOfResult < sizeOfList - 1) {
765 nextTime = list[indexOfResult + 1].time(); 765 nextTime = list[indexOfResult + 1].time();
766 if (nextTime > minimumTime) 766 if (nextTime > minimumTime)
767 return nextTime; 767 return nextTime;
768 ++indexOfResult; 768 ++indexOfResult;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 return SMILInterval(tempBegin, tempEnd); 843 return SMILInterval(tempBegin, tempEnd);
844 844
845 beginAfter = tempEnd; 845 beginAfter = tempEnd;
846 lastIntervalTempEnd = tempEnd; 846 lastIntervalTempEnd = tempEnd;
847 } 847 }
848 return SMILInterval(SMILTime::unresolved(), SMILTime::unresolved()); 848 return SMILInterval(SMILTime::unresolved(), SMILTime::unresolved());
849 } 849 }
850 850
851 void SVGSMILElement::resolveFirstInterval() { 851 void SVGSMILElement::resolveFirstInterval() {
852 SMILInterval firstInterval = resolveInterval(FirstInterval); 852 SMILInterval firstInterval = resolveInterval(FirstInterval);
853 ASSERT(!firstInterval.begin.isIndefinite()); 853 DCHECK(!firstInterval.begin.isIndefinite());
854 854
855 if (!firstInterval.begin.isUnresolved() && firstInterval != m_interval) { 855 if (!firstInterval.begin.isUnresolved() && firstInterval != m_interval) {
856 m_interval = firstInterval; 856 m_interval = firstInterval;
857 notifyDependentsIntervalChanged(); 857 notifyDependentsIntervalChanged();
858 m_nextProgressTime = m_nextProgressTime.isUnresolved() 858 m_nextProgressTime = m_nextProgressTime.isUnresolved()
859 ? m_interval.begin 859 ? m_interval.begin
860 : std::min(m_nextProgressTime, m_interval.begin); 860 : std::min(m_nextProgressTime, m_interval.begin);
861 861
862 if (m_timeContainer) 862 if (m_timeContainer)
863 m_timeContainer->notifyIntervalsChanged(); 863 m_timeContainer->notifyIntervalsChanged();
864 } 864 }
865 } 865 }
866 866
867 bool SVGSMILElement::resolveNextInterval() { 867 bool SVGSMILElement::resolveNextInterval() {
868 SMILInterval nextInterval = resolveInterval(NextInterval); 868 SMILInterval nextInterval = resolveInterval(NextInterval);
869 ASSERT(!nextInterval.begin.isIndefinite()); 869 DCHECK(!nextInterval.begin.isIndefinite());
870 870
871 if (!nextInterval.begin.isUnresolved() && 871 if (!nextInterval.begin.isUnresolved() &&
872 nextInterval.begin != m_interval.begin) { 872 nextInterval.begin != m_interval.begin) {
873 m_interval = nextInterval; 873 m_interval = nextInterval;
874 notifyDependentsIntervalChanged(); 874 notifyDependentsIntervalChanged();
875 m_nextProgressTime = m_nextProgressTime.isUnresolved() 875 m_nextProgressTime = m_nextProgressTime.isUnresolved()
876 ? m_interval.begin 876 ? m_interval.begin
877 : std::min(m_nextProgressTime, m_interval.begin); 877 : std::min(m_nextProgressTime, m_interval.begin);
878 return true; 878 return true;
879 } 879 }
880 880
881 return false; 881 return false;
882 } 882 }
883 883
884 SMILTime SVGSMILElement::nextProgressTime() const { 884 SMILTime SVGSMILElement::nextProgressTime() const {
885 return m_nextProgressTime; 885 return m_nextProgressTime;
886 } 886 }
887 887
888 void SVGSMILElement::beginListChanged(SMILTime eventTime) { 888 void SVGSMILElement::beginListChanged(SMILTime eventTime) {
889 if (m_isWaitingForFirstInterval) { 889 if (m_isWaitingForFirstInterval) {
890 resolveFirstInterval(); 890 resolveFirstInterval();
891 } else if (this->getRestart() != RestartNever) { 891 } else if (this->getRestart() != RestartNever) {
892 SMILTime newBegin = findInstanceTime(Begin, eventTime, true); 892 SMILTime newBegin = findInstanceTime(Begin, eventTime, true);
893 if (newBegin.isFinite() && 893 if (newBegin.isFinite() &&
894 (m_interval.end <= eventTime || newBegin < m_interval.begin)) { 894 (m_interval.end <= eventTime || newBegin < m_interval.begin)) {
895 // Begin time changed, re-resolve the interval. 895 // Begin time changed, re-resolve the interval.
896 SMILTime oldBegin = m_interval.begin; 896 SMILTime oldBegin = m_interval.begin;
897 m_interval.end = eventTime; 897 m_interval.end = eventTime;
898 m_interval = resolveInterval(NextInterval); 898 m_interval = resolveInterval(NextInterval);
899 ASSERT(!m_interval.begin.isUnresolved()); 899 DCHECK(!m_interval.begin.isUnresolved());
900 if (m_interval.begin != oldBegin) { 900 if (m_interval.begin != oldBegin) {
901 if (m_activeState == Active && m_interval.begin > eventTime) { 901 if (m_activeState == Active && m_interval.begin > eventTime) {
902 m_activeState = determineActiveState(eventTime); 902 m_activeState = determineActiveState(eventTime);
903 if (m_activeState != Active) 903 if (m_activeState != Active)
904 endedActiveInterval(); 904 endedActiveInterval();
905 } 905 }
906 notifyDependentsIntervalChanged(); 906 notifyDependentsIntervalChanged();
907 } 907 }
908 } 908 }
909 } 909 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 bool SVGSMILElement::isContributing(double elapsed) const { 1068 bool SVGSMILElement::isContributing(double elapsed) const {
1069 // Animation does not contribute during the active time if it is past its 1069 // Animation does not contribute during the active time if it is past its
1070 // repeating duration and has fill=remove. 1070 // repeating duration and has fill=remove.
1071 return (m_activeState == Active && 1071 return (m_activeState == Active &&
1072 (fill() == FillFreeze || 1072 (fill() == FillFreeze ||
1073 elapsed <= m_interval.begin + repeatingDuration())) || 1073 elapsed <= m_interval.begin + repeatingDuration())) ||
1074 m_activeState == Frozen; 1074 m_activeState == Frozen;
1075 } 1075 }
1076 1076
1077 bool SVGSMILElement::progress(double elapsed, bool seekToTime) { 1077 bool SVGSMILElement::progress(double elapsed, bool seekToTime) {
1078 ASSERT(m_timeContainer); 1078 DCHECK(m_timeContainer);
1079 ASSERT(m_isWaitingForFirstInterval || m_interval.begin.isFinite()); 1079 DCHECK(m_isWaitingForFirstInterval || m_interval.begin.isFinite());
1080 1080
1081 if (!m_syncBaseConditionsConnected) 1081 if (!m_syncBaseConditionsConnected)
1082 connectSyncBaseConditions(); 1082 connectSyncBaseConditions();
1083 1083
1084 if (!m_interval.begin.isFinite()) { 1084 if (!m_interval.begin.isFinite()) {
1085 ASSERT(m_activeState == Inactive); 1085 DCHECK_EQ(m_activeState, Inactive);
1086 m_nextProgressTime = SMILTime::unresolved(); 1086 m_nextProgressTime = SMILTime::unresolved();
1087 return false; 1087 return false;
1088 } 1088 }
1089 1089
1090 if (elapsed < m_interval.begin) { 1090 if (elapsed < m_interval.begin) {
1091 ASSERT(m_activeState != Active); 1091 DCHECK_NE(m_activeState, Active);
1092 m_nextProgressTime = m_interval.begin; 1092 m_nextProgressTime = m_interval.begin;
1093 // If the animation is frozen, it's still contributing. 1093 // If the animation is frozen, it's still contributing.
1094 return m_activeState == Frozen; 1094 return m_activeState == Frozen;
1095 } 1095 }
1096 1096
1097 m_previousIntervalBegin = m_interval.begin; 1097 m_previousIntervalBegin = m_interval.begin;
1098 1098
1099 if (m_isWaitingForFirstInterval) { 1099 if (m_isWaitingForFirstInterval) {
1100 m_isWaitingForFirstInterval = false; 1100 m_isWaitingForFirstInterval = false;
1101 resolveFirstInterval(); 1101 resolveFirstInterval();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 1154
1155 if (m_activeState == Inactive || m_activeState == Frozen) 1155 if (m_activeState == Inactive || m_activeState == Frozen)
1156 scheduleEvent(EventTypeNames::endEvent); 1156 scheduleEvent(EventTypeNames::endEvent);
1157 } 1157 }
1158 1158
1159 m_nextProgressTime = calculateNextProgressTime(elapsed); 1159 m_nextProgressTime = calculateNextProgressTime(elapsed);
1160 return animationIsContributing; 1160 return animationIsContributing;
1161 } 1161 }
1162 1162
1163 void SVGSMILElement::notifyDependentsIntervalChanged() { 1163 void SVGSMILElement::notifyDependentsIntervalChanged() {
1164 ASSERT(m_interval.begin.isFinite()); 1164 DCHECK(m_interval.begin.isFinite());
1165 // |loopBreaker| is used to avoid infinite recursions which may be caused by: 1165 // |loopBreaker| is used to avoid infinite recursions which may be caused by:
1166 // |notifyDependentsIntervalChanged| -> |createInstanceTimesFromSyncbase| -> 1166 // |notifyDependentsIntervalChanged| -> |createInstanceTimesFromSyncbase| ->
1167 // |add{Begin,End}Time| -> |{begin,end}TimeChanged| -> 1167 // |add{Begin,End}Time| -> |{begin,end}TimeChanged| ->
1168 // |notifyDependentsIntervalChanged| 1168 // |notifyDependentsIntervalChanged|
1169 // 1169 //
1170 // As the set here records SVGSMILElements on the stack, it is acceptable to 1170 // As the set here records SVGSMILElements on the stack, it is acceptable to
1171 // use a HashSet of untraced heap references -- any conservative GC which 1171 // use a HashSet of untraced heap references -- any conservative GC which
1172 // strikes before unwinding will find these elements on the stack. 1172 // strikes before unwinding will find these elements on the stack.
1173 DEFINE_STATIC_LOCAL(HashSet<UntracedMember<SVGSMILElement>>, loopBreaker, ()); 1173 DEFINE_STATIC_LOCAL(HashSet<UntracedMember<SVGSMILElement>>, loopBreaker, ());
1174 if (!loopBreaker.insert(this).isNewEntry) 1174 if (!loopBreaker.insert(this).isNewEntry)
1175 return; 1175 return;
1176 1176
1177 for (SVGSMILElement* element : m_syncBaseDependents) 1177 for (SVGSMILElement* element : m_syncBaseDependents)
1178 element->createInstanceTimesFromSyncbase(*this); 1178 element->createInstanceTimesFromSyncbase(*this);
1179 1179
1180 loopBreaker.erase(this); 1180 loopBreaker.erase(this);
1181 } 1181 }
1182 1182
1183 void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement& syncBase) { 1183 void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement& syncBase) {
1184 // FIXME: To be really correct, this should handle updating exising interval 1184 // FIXME: To be really correct, this should handle updating exising interval
1185 // by changing the associated times instead of creating new ones. 1185 // by changing the associated times instead of creating new ones.
1186 for (Condition* condition : m_conditions) { 1186 for (Condition* condition : m_conditions) {
1187 if (condition->getType() == Condition::Syncbase && 1187 if (condition->getType() == Condition::Syncbase &&
1188 condition->syncBaseEquals(syncBase)) { 1188 condition->syncBaseEquals(syncBase)) {
1189 ASSERT(condition->name() == "begin" || condition->name() == "end"); 1189 DCHECK(condition->name() == "begin" || condition->name() == "end");
1190 // No nested time containers in SVG, no need for crazy time space 1190 // No nested time containers in SVG, no need for crazy time space
1191 // conversions. Phew! 1191 // conversions. Phew!
1192 SMILTime time = 0; 1192 SMILTime time = 0;
1193 if (condition->name() == "begin") 1193 if (condition->name() == "begin")
1194 time = syncBase.m_interval.begin + condition->offset(); 1194 time = syncBase.m_interval.begin + condition->offset();
1195 else 1195 else
1196 time = syncBase.m_interval.end + condition->offset(); 1196 time = syncBase.m_interval.end + condition->offset();
1197 if (!time.isFinite()) 1197 if (!time.isFinite())
1198 continue; 1198 continue;
1199 addInstanceTime(condition->getBeginOrEnd(), time); 1199 addInstanceTime(condition->getBeginOrEnd(), time);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 visitor->trace(m_targetElement); 1274 visitor->trace(m_targetElement);
1275 visitor->trace(m_targetIdObserver); 1275 visitor->trace(m_targetIdObserver);
1276 visitor->trace(m_timeContainer); 1276 visitor->trace(m_timeContainer);
1277 visitor->trace(m_conditions); 1277 visitor->trace(m_conditions);
1278 visitor->trace(m_syncBaseDependents); 1278 visitor->trace(m_syncBaseDependents);
1279 SVGElement::trace(visitor); 1279 SVGElement::trace(visitor);
1280 SVGTests::trace(visitor); 1280 SVGTests::trace(visitor);
1281 } 1281 }
1282 1282
1283 } // namespace blink 1283 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698