File indexing completed on 2024-05-12 11:51:52
0001 /* 0002 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 0003 * 0004 * Redistribution and use in source and binary forms, with or without 0005 * modification, are permitted provided that the following conditions 0006 * are met: 0007 * 1. Redistributions of source code must retain the above copyright 0008 * notice, this list of conditions and the following disclaimer. 0009 * 2. Redistributions in binary form must reproduce the above copyright 0010 * notice, this list of conditions and the following disclaimer in the 0011 * documentation and/or other materials provided with the distribution. 0012 * 0013 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 0014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0015 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 0017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0018 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0019 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0020 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 0021 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0024 */ 0025 0026 #if ENABLE(SVG) 0027 #include "SMILTime.h" 0028 0029 #include <float.h> 0030 0031 using namespace WebCore; 0032 0033 const double SMILTime::unresolvedValue = DBL_MAX; 0034 // Just a big value smaller than DBL_MAX. Our times are relative to 0, we don't really need the full range. 0035 const double SMILTime::indefiniteValue = FLT_MAX; 0036 0037 SMILTime WebCore::operator+(const SMILTime &a, const SMILTime &b) 0038 { 0039 if (a.isUnresolved() || b.isUnresolved()) { 0040 return SMILTime::unresolved(); 0041 } 0042 if (a.isIndefinite() || b.isIndefinite()) { 0043 return SMILTime::indefinite(); 0044 } 0045 return a.value() + b.value(); 0046 } 0047 0048 SMILTime WebCore::operator-(const SMILTime &a, const SMILTime &b) 0049 { 0050 if (a.isUnresolved() || b.isUnresolved()) { 0051 return SMILTime::unresolved(); 0052 } 0053 if (a.isIndefinite() || b.isIndefinite()) { 0054 return SMILTime::indefinite(); 0055 } 0056 return a.value() - b.value(); 0057 } 0058 0059 SMILTime WebCore::operator*(const SMILTime &a, const SMILTime &b) 0060 { 0061 if (a.isUnresolved() || b.isUnresolved()) { 0062 return SMILTime::unresolved(); 0063 } 0064 if (a.value() == 0 || b.value() == 0) { 0065 return SMILTime(0); 0066 } 0067 if (a.isIndefinite() || b.isIndefinite()) { 0068 return SMILTime::indefinite(); 0069 } 0070 return a.value() * b.value(); 0071 } 0072 #endif 0073