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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 SMILTime maxValue = this->maxValue(); | 888 SMILTime maxValue = this->maxValue(); |
889 if (minValue > maxValue) { | 889 if (minValue > maxValue) { |
890 // Ignore both. | 890 // Ignore both. |
891 // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#MinMax | 891 // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#MinMax |
892 minValue = 0; | 892 minValue = 0; |
893 maxValue = SMILTime::indefinite(); | 893 maxValue = SMILTime::indefinite(); |
894 } | 894 } |
895 return resolvedBegin + min(maxValue, max(minValue, preliminaryActiveDuration
)); | 895 return resolvedBegin + min(maxValue, max(minValue, preliminaryActiveDuration
)); |
896 } | 896 } |
897 | 897 |
898 void SVGSMILElement::resolveInterval(bool first, SMILTime& beginResult, SMILTime
& endResult) const | 898 SMILInterval SVGSMILElement::resolveInterval(ResolveInterval resolveIntervalType
) const |
899 { | 899 { |
| 900 bool first = resolveIntervalType == FirstInterval; |
900 // 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. |
901 SMILTime beginAfter = first ? -numeric_limits<double>::infinity() : m_interv
al.end; | 902 SMILTime beginAfter = first ? -numeric_limits<double>::infinity() : m_interv
al.end; |
902 SMILTime lastIntervalTempEnd = numeric_limits<double>::infinity(); | 903 SMILTime lastIntervalTempEnd = numeric_limits<double>::infinity(); |
903 while (true) { | 904 while (true) { |
904 bool equalsMinimumOK = !first || m_interval.end > m_interval.begin; | 905 bool equalsMinimumOK = !first || m_interval.end > m_interval.begin; |
905 SMILTime tempBegin = findInstanceTime(Begin, beginAfter, equalsMinimumOK
); | 906 SMILTime tempBegin = findInstanceTime(Begin, beginAfter, equalsMinimumOK
); |
906 if (tempBegin.isUnresolved()) | 907 if (tempBegin.isUnresolved()) |
907 break; | 908 break; |
908 SMILTime tempEnd; | 909 SMILTime tempEnd; |
909 if (m_endTimes.isEmpty()) | 910 if (m_endTimes.isEmpty()) |
910 tempEnd = resolveActiveEnd(tempBegin, SMILTime::indefinite()); | 911 tempEnd = resolveActiveEnd(tempBegin, SMILTime::indefinite()); |
911 else { | 912 else { |
912 tempEnd = findInstanceTime(End, tempBegin, true); | 913 tempEnd = findInstanceTime(End, tempBegin, true); |
913 if ((first && tempBegin == tempEnd && tempEnd == lastIntervalTempEnd
) || (!first && tempEnd == m_interval.end)) | 914 if ((first && tempBegin == tempEnd && tempEnd == lastIntervalTempEnd
) || (!first && tempEnd == m_interval.end)) |
914 tempEnd = findInstanceTime(End, tempBegin, false); | 915 tempEnd = findInstanceTime(End, tempBegin, false); |
915 if (tempEnd.isUnresolved()) { | 916 if (tempEnd.isUnresolved()) { |
916 if (!m_endTimes.isEmpty() && !m_hasEndEventConditions) | 917 if (!m_endTimes.isEmpty() && !m_hasEndEventConditions) |
917 break; | 918 break; |
918 } | 919 } |
919 tempEnd = resolveActiveEnd(tempBegin, tempEnd); | 920 tempEnd = resolveActiveEnd(tempBegin, tempEnd); |
920 } | 921 } |
921 if (!first || (tempEnd > 0 || (!tempBegin.value() && !tempEnd.value())))
{ | 922 if (!first || (tempEnd > 0 || (!tempBegin.value() && !tempEnd.value()))) |
922 beginResult = tempBegin; | 923 return SMILInterval(tempBegin, tempEnd); |
923 endResult = tempEnd; | |
924 return; | |
925 } | |
926 | 924 |
927 beginAfter = tempEnd; | 925 beginAfter = tempEnd; |
928 lastIntervalTempEnd = tempEnd; | 926 lastIntervalTempEnd = tempEnd; |
929 } | 927 } |
930 beginResult = SMILTime::unresolved(); | 928 return SMILInterval(SMILTime::unresolved(), SMILTime::unresolved()); |
931 endResult = SMILTime::unresolved(); | |
932 } | 929 } |
933 | 930 |
934 void SVGSMILElement::resolveFirstInterval() | 931 void SVGSMILElement::resolveFirstInterval() |
935 { | 932 { |
936 SMILInterval firstInterval; | 933 SMILInterval firstInterval = resolveInterval(FirstInterval); |
937 resolveInterval(true, firstInterval.begin, firstInterval.end); | |
938 ASSERT(!firstInterval.begin.isIndefinite()); | 934 ASSERT(!firstInterval.begin.isIndefinite()); |
939 | 935 |
940 if (!firstInterval.begin.isUnresolved() && firstInterval != SMILInterval(m_i
nterval.begin, m_interval.end)) { | 936 if (!firstInterval.begin.isUnresolved() && firstInterval != m_interval) { |
941 m_interval.begin = firstInterval.begin; | 937 m_interval = firstInterval; |
942 m_interval.end = firstInterval.end; | |
943 notifyDependentsIntervalChanged(); | 938 notifyDependentsIntervalChanged(); |
944 m_nextProgressTime = min(m_nextProgressTime, m_interval.begin); | 939 m_nextProgressTime = min(m_nextProgressTime, m_interval.begin); |
945 | 940 |
946 if (m_timeContainer) | 941 if (m_timeContainer) |
947 m_timeContainer->notifyIntervalsChanged(); | 942 m_timeContainer->notifyIntervalsChanged(); |
948 } | 943 } |
949 } | 944 } |
950 | 945 |
951 bool SVGSMILElement::resolveNextInterval() | 946 bool SVGSMILElement::resolveNextInterval() |
952 { | 947 { |
953 SMILTime begin; | 948 SMILInterval nextInterval = resolveInterval(NextInterval); |
954 SMILTime end; | 949 ASSERT(!nextInterval.begin.isIndefinite()); |
955 resolveInterval(false, begin, end); | |
956 ASSERT(!begin.isIndefinite()); | |
957 | 950 |
958 if (!begin.isUnresolved() && begin != m_interval.begin) { | 951 if (!nextInterval.begin.isUnresolved() && nextInterval.begin != m_interval.b
egin) { |
959 m_interval.begin = begin; | 952 m_interval = nextInterval; |
960 m_interval.end = end; | |
961 notifyDependentsIntervalChanged(); | 953 notifyDependentsIntervalChanged(); |
962 m_nextProgressTime = min(m_nextProgressTime, m_interval.begin); | 954 m_nextProgressTime = min(m_nextProgressTime, m_interval.begin); |
963 return true; | 955 return true; |
964 } | 956 } |
965 | 957 |
966 return false; | 958 return false; |
967 } | 959 } |
968 | 960 |
969 SMILTime SVGSMILElement::nextProgressTime() const | 961 SMILTime SVGSMILElement::nextProgressTime() const |
970 { | 962 { |
971 return m_nextProgressTime; | 963 return m_nextProgressTime; |
972 } | 964 } |
973 | 965 |
974 void SVGSMILElement::beginListChanged(SMILTime eventTime) | 966 void SVGSMILElement::beginListChanged(SMILTime eventTime) |
975 { | 967 { |
976 if (m_isWaitingForFirstInterval) | 968 if (m_isWaitingForFirstInterval) |
977 resolveFirstInterval(); | 969 resolveFirstInterval(); |
978 else { | 970 else { |
979 SMILTime newBegin = findInstanceTime(Begin, eventTime, true); | 971 SMILTime newBegin = findInstanceTime(Begin, eventTime, true); |
980 if (newBegin.isFinite() && (m_interval.end <= eventTime || newBegin < m_
interval.begin)) { | 972 if (newBegin.isFinite() && (m_interval.end <= eventTime || newBegin < m_
interval.begin)) { |
981 // Begin time changed, re-resolve the interval. | 973 // Begin time changed, re-resolve the interval. |
982 SMILTime oldBegin = m_interval.begin; | 974 SMILTime oldBegin = m_interval.begin; |
983 m_interval.end = eventTime; | 975 m_interval.end = eventTime; |
984 resolveInterval(false, m_interval.begin, m_interval.end); | 976 m_interval = resolveInterval(NextInterval); |
985 ASSERT(!m_interval.begin.isUnresolved()); | 977 ASSERT(!m_interval.begin.isUnresolved()); |
986 if (m_interval.begin != oldBegin) { | 978 if (m_interval.begin != oldBegin) { |
987 if (m_activeState == Active && m_interval.begin > eventTime) { | 979 if (m_activeState == Active && m_interval.begin > eventTime) { |
988 m_activeState = determineActiveState(eventTime); | 980 m_activeState = determineActiveState(eventTime); |
989 if (m_activeState != Active) | 981 if (m_activeState != Active) |
990 endedActiveInterval(); | 982 endedActiveInterval(); |
991 } | 983 } |
992 notifyDependentsIntervalChanged(); | 984 notifyDependentsIntervalChanged(); |
993 } | 985 } |
994 } | 986 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 void SVGSMILElement::trace(Visitor* visitor) | 1344 void SVGSMILElement::trace(Visitor* visitor) |
1353 { | 1345 { |
1354 visitor->trace(m_targetElement); | 1346 visitor->trace(m_targetElement); |
1355 visitor->trace(m_timeContainer); | 1347 visitor->trace(m_timeContainer); |
1356 visitor->trace(m_conditions); | 1348 visitor->trace(m_conditions); |
1357 visitor->trace(m_syncBaseDependents); | 1349 visitor->trace(m_syncBaseDependents); |
1358 SVGElement::trace(visitor); | 1350 SVGElement::trace(visitor); |
1359 } | 1351 } |
1360 | 1352 |
1361 } | 1353 } |
OLD | NEW |