OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "core/events/EventSender.h" | 35 #include "core/events/EventSender.h" |
36 #include "core/svg/SVGDocumentExtensions.h" | 36 #include "core/svg/SVGDocumentExtensions.h" |
37 #include "core/svg/SVGSVGElement.h" | 37 #include "core/svg/SVGSVGElement.h" |
38 #include "core/svg/SVGURIReference.h" | 38 #include "core/svg/SVGURIReference.h" |
39 #include "core/svg/animation/SMILTimeContainer.h" | 39 #include "core/svg/animation/SMILTimeContainer.h" |
40 #include "platform/FloatConversion.h" | 40 #include "platform/FloatConversion.h" |
41 #include "wtf/MathExtras.h" | 41 #include "wtf/MathExtras.h" |
42 #include "wtf/StdLibExtras.h" | 42 #include "wtf/StdLibExtras.h" |
43 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
44 | 44 |
| 45 using namespace std; |
| 46 |
45 namespace WebCore { | 47 namespace WebCore { |
46 | 48 |
47 class RepeatEvent FINAL : public Event { | 49 class RepeatEvent FINAL : public Event { |
48 public: | 50 public: |
49 static PassRefPtrWillBeRawPtr<RepeatEvent> create(const AtomicString& type,
int repeat) | 51 static PassRefPtrWillBeRawPtr<RepeatEvent> create(const AtomicString& type,
int repeat) |
50 { | 52 { |
51 return adoptRefWillBeNoop(new RepeatEvent(type, false, false, repeat)); | 53 return adoptRefWillBeNoop(new RepeatEvent(type, false, false, repeat)); |
52 } | 54 } |
53 | 55 |
54 virtual ~RepeatEvent() { } | 56 virtual ~RepeatEvent() { } |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 { | 790 { |
789 if (m_cachedMin != invalidCachedTime) | 791 if (m_cachedMin != invalidCachedTime) |
790 return m_cachedMin; | 792 return m_cachedMin; |
791 const AtomicString& value = fastGetAttribute(SVGNames::minAttr); | 793 const AtomicString& value = fastGetAttribute(SVGNames::minAttr); |
792 SMILTime result = parseClockValue(value); | 794 SMILTime result = parseClockValue(value); |
793 return m_cachedMin = (result.isUnresolved() || result < 0) ? 0 : result; | 795 return m_cachedMin = (result.isUnresolved() || result < 0) ? 0 : result; |
794 } | 796 } |
795 | 797 |
796 SMILTime SVGSMILElement::simpleDuration() const | 798 SMILTime SVGSMILElement::simpleDuration() const |
797 { | 799 { |
798 return std::min(dur(), SMILTime::indefinite()); | 800 return min(dur(), SMILTime::indefinite()); |
799 } | 801 } |
800 | 802 |
801 void SVGSMILElement::addBeginTime(SMILTime eventTime, SMILTime beginTime, SMILTi
meWithOrigin::Origin origin) | 803 void SVGSMILElement::addBeginTime(SMILTime eventTime, SMILTime beginTime, SMILTi
meWithOrigin::Origin origin) |
802 { | 804 { |
803 ASSERT(!std::isnan(beginTime.value())); | 805 ASSERT(!std::isnan(beginTime.value())); |
804 m_beginTimes.append(SMILTimeWithOrigin(beginTime, origin)); | 806 m_beginTimes.append(SMILTimeWithOrigin(beginTime, origin)); |
805 sortTimeList(m_beginTimes); | 807 sortTimeList(m_beginTimes); |
806 beginListChanged(eventTime); | 808 beginListChanged(eventTime); |
807 } | 809 } |
808 | 810 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 SMILTime SVGSMILElement::repeatingDuration() const | 862 SMILTime SVGSMILElement::repeatingDuration() const |
861 { | 863 { |
862 // Computing the active duration | 864 // Computing the active duration |
863 // http://www.w3.org/TR/SMIL2/smil-timing.html#Timing-ComputingActiveDur | 865 // http://www.w3.org/TR/SMIL2/smil-timing.html#Timing-ComputingActiveDur |
864 SMILTime repeatCount = this->repeatCount(); | 866 SMILTime repeatCount = this->repeatCount(); |
865 SMILTime repeatDur = this->repeatDur(); | 867 SMILTime repeatDur = this->repeatDur(); |
866 SMILTime simpleDuration = this->simpleDuration(); | 868 SMILTime simpleDuration = this->simpleDuration(); |
867 if (!simpleDuration || (repeatDur.isUnresolved() && repeatCount.isUnresolved
())) | 869 if (!simpleDuration || (repeatDur.isUnresolved() && repeatCount.isUnresolved
())) |
868 return simpleDuration; | 870 return simpleDuration; |
869 SMILTime repeatCountDuration = simpleDuration * repeatCount; | 871 SMILTime repeatCountDuration = simpleDuration * repeatCount; |
870 return std::min(repeatCountDuration, std::min(repeatDur, SMILTime::indefinit
e())); | 872 return min(repeatCountDuration, min(repeatDur, SMILTime::indefinite())); |
871 } | 873 } |
872 | 874 |
873 SMILTime SVGSMILElement::resolveActiveEnd(SMILTime resolvedBegin, SMILTime resol
vedEnd) const | 875 SMILTime SVGSMILElement::resolveActiveEnd(SMILTime resolvedBegin, SMILTime resol
vedEnd) const |
874 { | 876 { |
875 // Computing the active duration | 877 // Computing the active duration |
876 // http://www.w3.org/TR/SMIL2/smil-timing.html#Timing-ComputingActiveDur | 878 // http://www.w3.org/TR/SMIL2/smil-timing.html#Timing-ComputingActiveDur |
877 SMILTime preliminaryActiveDuration; | 879 SMILTime preliminaryActiveDuration; |
878 if (!resolvedEnd.isUnresolved() && dur().isUnresolved() && repeatDur().isUnr
esolved() && repeatCount().isUnresolved()) | 880 if (!resolvedEnd.isUnresolved() && dur().isUnresolved() && repeatDur().isUnr
esolved() && repeatCount().isUnresolved()) |
879 preliminaryActiveDuration = resolvedEnd - resolvedBegin; | 881 preliminaryActiveDuration = resolvedEnd - resolvedBegin; |
880 else if (!resolvedEnd.isFinite()) | 882 else if (!resolvedEnd.isFinite()) |
881 preliminaryActiveDuration = repeatingDuration(); | 883 preliminaryActiveDuration = repeatingDuration(); |
882 else | 884 else |
883 preliminaryActiveDuration = std::min(repeatingDuration(), resolvedEnd -
resolvedBegin); | 885 preliminaryActiveDuration = min(repeatingDuration(), resolvedEnd - resol
vedBegin); |
884 | 886 |
885 SMILTime minValue = this->minValue(); | 887 SMILTime minValue = this->minValue(); |
886 SMILTime maxValue = this->maxValue(); | 888 SMILTime maxValue = this->maxValue(); |
887 if (minValue > maxValue) { | 889 if (minValue > maxValue) { |
888 // Ignore both. | 890 // Ignore both. |
889 // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#MinMax | 891 // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#MinMax |
890 minValue = 0; | 892 minValue = 0; |
891 maxValue = SMILTime::indefinite(); | 893 maxValue = SMILTime::indefinite(); |
892 } | 894 } |
893 return resolvedBegin + std::min(maxValue, std::max(minValue, preliminaryActi
veDuration)); | 895 return resolvedBegin + min(maxValue, max(minValue, preliminaryActiveDuration
)); |
894 } | 896 } |
895 | 897 |
896 SMILInterval SVGSMILElement::resolveInterval(ResolveInterval resolveIntervalType
) const | 898 SMILInterval SVGSMILElement::resolveInterval(ResolveInterval resolveIntervalType
) const |
897 { | 899 { |
898 bool first = resolveIntervalType == FirstInterval; | 900 bool first = resolveIntervalType == FirstInterval; |
899 // See the pseudocode in http://www.w3.org/TR/SMIL3/smil-timing.html#q90. | 901 // See the pseudocode in http://www.w3.org/TR/SMIL3/smil-timing.html#q90. |
900 SMILTime beginAfter = first ? -std::numeric_limits<double>::infinity() : m_i
nterval.end; | 902 SMILTime beginAfter = first ? -numeric_limits<double>::infinity() : m_interv
al.end; |
901 SMILTime lastIntervalTempEnd = std::numeric_limits<double>::infinity(); | 903 SMILTime lastIntervalTempEnd = numeric_limits<double>::infinity(); |
902 while (true) { | 904 while (true) { |
903 bool equalsMinimumOK = !first || m_interval.end > m_interval.begin; | 905 bool equalsMinimumOK = !first || m_interval.end > m_interval.begin; |
904 SMILTime tempBegin = findInstanceTime(Begin, beginAfter, equalsMinimumOK
); | 906 SMILTime tempBegin = findInstanceTime(Begin, beginAfter, equalsMinimumOK
); |
905 if (tempBegin.isUnresolved()) | 907 if (tempBegin.isUnresolved()) |
906 break; | 908 break; |
907 SMILTime tempEnd; | 909 SMILTime tempEnd; |
908 if (m_endTimes.isEmpty()) | 910 if (m_endTimes.isEmpty()) |
909 tempEnd = resolveActiveEnd(tempBegin, SMILTime::indefinite()); | 911 tempEnd = resolveActiveEnd(tempBegin, SMILTime::indefinite()); |
910 else { | 912 else { |
911 tempEnd = findInstanceTime(End, tempBegin, true); | 913 tempEnd = findInstanceTime(End, tempBegin, true); |
(...skipping 15 matching lines...) Expand all Loading... |
927 } | 929 } |
928 | 930 |
929 void SVGSMILElement::resolveFirstInterval() | 931 void SVGSMILElement::resolveFirstInterval() |
930 { | 932 { |
931 SMILInterval firstInterval = resolveInterval(FirstInterval); | 933 SMILInterval firstInterval = resolveInterval(FirstInterval); |
932 ASSERT(!firstInterval.begin.isIndefinite()); | 934 ASSERT(!firstInterval.begin.isIndefinite()); |
933 | 935 |
934 if (!firstInterval.begin.isUnresolved() && firstInterval != m_interval) { | 936 if (!firstInterval.begin.isUnresolved() && firstInterval != m_interval) { |
935 m_interval = firstInterval; | 937 m_interval = firstInterval; |
936 notifyDependentsIntervalChanged(); | 938 notifyDependentsIntervalChanged(); |
937 m_nextProgressTime = std::min(m_nextProgressTime, m_interval.begin); | 939 m_nextProgressTime = min(m_nextProgressTime, m_interval.begin); |
938 | 940 |
939 if (m_timeContainer) | 941 if (m_timeContainer) |
940 m_timeContainer->notifyIntervalsChanged(); | 942 m_timeContainer->notifyIntervalsChanged(); |
941 } | 943 } |
942 } | 944 } |
943 | 945 |
944 bool SVGSMILElement::resolveNextInterval() | 946 bool SVGSMILElement::resolveNextInterval() |
945 { | 947 { |
946 SMILInterval nextInterval = resolveInterval(NextInterval); | 948 SMILInterval nextInterval = resolveInterval(NextInterval); |
947 ASSERT(!nextInterval.begin.isIndefinite()); | 949 ASSERT(!nextInterval.begin.isIndefinite()); |
948 | 950 |
949 if (!nextInterval.begin.isUnresolved() && nextInterval.begin != m_interval.b
egin) { | 951 if (!nextInterval.begin.isUnresolved() && nextInterval.begin != m_interval.b
egin) { |
950 m_interval = nextInterval; | 952 m_interval = nextInterval; |
951 notifyDependentsIntervalChanged(); | 953 notifyDependentsIntervalChanged(); |
952 m_nextProgressTime = std::min(m_nextProgressTime, m_interval.begin); | 954 m_nextProgressTime = min(m_nextProgressTime, m_interval.begin); |
953 return true; | 955 return true; |
954 } | 956 } |
955 | 957 |
956 return false; | 958 return false; |
957 } | 959 } |
958 | 960 |
959 SMILTime SVGSMILElement::nextProgressTime() const | 961 SMILTime SVGSMILElement::nextProgressTime() const |
960 { | 962 { |
961 return m_nextProgressTime; | 963 return m_nextProgressTime; |
962 } | 964 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 ASSERT(simpleDuration.isFinite()); | 1089 ASSERT(simpleDuration.isFinite()); |
1088 SMILTime activeTime = elapsed - m_interval.begin; | 1090 SMILTime activeTime = elapsed - m_interval.begin; |
1089 SMILTime repeatingDuration = this->repeatingDuration(); | 1091 SMILTime repeatingDuration = this->repeatingDuration(); |
1090 if (elapsed >= m_interval.end || activeTime > repeatingDuration) { | 1092 if (elapsed >= m_interval.end || activeTime > repeatingDuration) { |
1091 repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuratio
n.value()); | 1093 repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuratio
n.value()); |
1092 if (!fmod(repeatingDuration.value(), simpleDuration.value())) | 1094 if (!fmod(repeatingDuration.value(), simpleDuration.value())) |
1093 repeat--; | 1095 repeat--; |
1094 | 1096 |
1095 double percent = (m_interval.end.value() - m_interval.begin.value()) / s
impleDuration.value(); | 1097 double percent = (m_interval.end.value() - m_interval.begin.value()) / s
impleDuration.value(); |
1096 percent = percent - floor(percent); | 1098 percent = percent - floor(percent); |
1097 if (percent < std::numeric_limits<float>::epsilon() || 1 - percent < std
::numeric_limits<float>::epsilon()) | 1099 if (percent < numeric_limits<float>::epsilon() || 1 - percent < numeric_
limits<float>::epsilon()) |
1098 return 1.0f; | 1100 return 1.0f; |
1099 return narrowPrecisionToFloat(percent); | 1101 return narrowPrecisionToFloat(percent); |
1100 } | 1102 } |
1101 repeat = static_cast<unsigned>(activeTime.value() / simpleDuration.value()); | 1103 repeat = static_cast<unsigned>(activeTime.value() / simpleDuration.value()); |
1102 SMILTime simpleTime = fmod(activeTime.value(), simpleDuration.value()); | 1104 SMILTime simpleTime = fmod(activeTime.value(), simpleDuration.value()); |
1103 return narrowPrecisionToFloat(simpleTime.value() / simpleDuration.value()); | 1105 return narrowPrecisionToFloat(simpleTime.value() / simpleDuration.value()); |
1104 } | 1106 } |
1105 | 1107 |
1106 SMILTime SVGSMILElement::calculateNextProgressTime(SMILTime elapsed) const | 1108 SMILTime SVGSMILElement::calculateNextProgressTime(SMILTime elapsed) const |
1107 { | 1109 { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 void SVGSMILElement::trace(Visitor* visitor) | 1346 void SVGSMILElement::trace(Visitor* visitor) |
1345 { | 1347 { |
1346 visitor->trace(m_targetElement); | 1348 visitor->trace(m_targetElement); |
1347 visitor->trace(m_timeContainer); | 1349 visitor->trace(m_timeContainer); |
1348 visitor->trace(m_conditions); | 1350 visitor->trace(m_conditions); |
1349 visitor->trace(m_syncBaseDependents); | 1351 visitor->trace(m_syncBaseDependents); |
1350 SVGElement::trace(visitor); | 1352 SVGElement::trace(visitor); |
1351 } | 1353 } |
1352 | 1354 |
1353 } | 1355 } |
OLD | NEW |