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

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

Issue 206013003: Cache all the results in SVGSMILElement::repeatCount() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | « no previous file | 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 * 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 SMILTime clockValue = parseClockValue(value); 738 SMILTime clockValue = parseClockValue(value);
739 m_cachedRepeatDur = clockValue <= 0 ? SMILTime::unresolved() : clockValue; 739 m_cachedRepeatDur = clockValue <= 0 ? SMILTime::unresolved() : clockValue;
740 return m_cachedRepeatDur; 740 return m_cachedRepeatDur;
741 } 741 }
742 742
743 // So a count is not really a time but let just all pretend we did not notice. 743 // So a count is not really a time but let just all pretend we did not notice.
744 SMILTime SVGSMILElement::repeatCount() const 744 SMILTime SVGSMILElement::repeatCount() const
745 { 745 {
746 if (m_cachedRepeatCount != invalidCachedTime) 746 if (m_cachedRepeatCount != invalidCachedTime)
747 return m_cachedRepeatCount; 747 return m_cachedRepeatCount;
748 SMILTime computedRepeatCount = SMILTime::unresolved();
748 const AtomicString& value = fastGetAttribute(SVGNames::repeatCountAttr); 749 const AtomicString& value = fastGetAttribute(SVGNames::repeatCountAttr);
749 if (value.isNull()) 750 if (!value.isNull()) {
750 return SMILTime::unresolved(); 751 DEFINE_STATIC_LOCAL(const AtomicString, indefiniteValue, ("indefinite", AtomicString::ConstructFromLiteral));
751 752 if (value == indefiniteValue) {
752 DEFINE_STATIC_LOCAL(const AtomicString, indefiniteValue, ("indefinite", Atom icString::ConstructFromLiteral)); 753 computedRepeatCount = SMILTime::indefinite();
753 if (value == indefiniteValue) 754 } else {
754 return SMILTime::indefinite(); 755 bool ok;
755 bool ok; 756 double result = value.string().toDouble(&ok);
756 double result = value.string().toDouble(&ok); 757 if (ok && result > 0)
757 return m_cachedRepeatCount = ok && result > 0 ? result : SMILTime::unresolve d(); 758 computedRepeatCount = result;
759 }
760 }
761 m_cachedRepeatCount = computedRepeatCount;
762 return m_cachedRepeatCount;
758 } 763 }
759 764
760 SMILTime SVGSMILElement::maxValue() const 765 SMILTime SVGSMILElement::maxValue() const
761 { 766 {
762 if (m_cachedMax != invalidCachedTime) 767 if (m_cachedMax != invalidCachedTime)
763 return m_cachedMax; 768 return m_cachedMax;
764 const AtomicString& value = fastGetAttribute(SVGNames::maxAttr); 769 const AtomicString& value = fastGetAttribute(SVGNames::maxAttr);
765 SMILTime result = parseClockValue(value); 770 SMILTime result = parseClockValue(value);
766 return m_cachedMax = (result.isUnresolved() || result < 0) ? SMILTime::indef inite() : result; 771 return m_cachedMax = (result.isUnresolved() || result < 0) ? SMILTime::indef inite() : result;
767 } 772 }
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 if (eventType == "repeatn") { 1317 if (eventType == "repeatn") {
1313 unsigned repeatEventCount = m_repeatEventCountList.first(); 1318 unsigned repeatEventCount = m_repeatEventCountList.first();
1314 m_repeatEventCountList.remove(0); 1319 m_repeatEventCountList.remove(0);
1315 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount)); 1320 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount));
1316 } else { 1321 } else {
1317 dispatchEvent(Event::create(eventType)); 1322 dispatchEvent(Event::create(eventType));
1318 } 1323 }
1319 } 1324 }
1320 1325
1321 } 1326 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698