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

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

Issue 499933002: Simplify SMILTime operators (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move +/- operators to the header. Created 6 years, 3 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
« no previous file with comments | « Source/core/svg/animation/SMILTime.h ('k') | 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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "core/svg/animation/SMILTime.h" 28 #include "core/svg/animation/SMILTime.h"
29 29
30 #include <float.h> 30 #include <float.h>
31 31
32 using namespace blink; 32 using namespace blink;
33 33
34 SMILTime blink::operator+(const SMILTime& a, const SMILTime& b)
35 {
36 if (a.isUnresolved() || b.isUnresolved())
37 return SMILTime::unresolved();
38 if (a.isIndefinite() || b.isIndefinite())
39 return SMILTime::indefinite();
40 return a.value() + b.value();
41 }
42
43 SMILTime blink::operator-(const SMILTime& a, const SMILTime& b)
44 {
45 if (a.isUnresolved() || b.isUnresolved())
46 return SMILTime::unresolved();
47 if (a.isIndefinite() || b.isIndefinite())
48 return SMILTime::indefinite();
49 return a.value() - b.value();
50 }
51
52 SMILTime blink::operator*(const SMILTime& a, const SMILTime& b) 34 SMILTime blink::operator*(const SMILTime& a, const SMILTime& b)
53 { 35 {
54 if (a.isUnresolved() || b.isUnresolved()) 36 // Equal operators have to be used instead of negation here to make NaN work as well.
55 return SMILTime::unresolved(); 37 if (a.value() == 0 || b.value() == 0)
56 if (!a.value() || !b.value())
57 return SMILTime(0); 38 return SMILTime(0);
58 if (a.isIndefinite() || b.isIndefinite())
59 return SMILTime::indefinite();
60 return a.value() * b.value(); 39 return a.value() * b.value();
61 } 40 }
OLDNEW
« no previous file with comments | « Source/core/svg/animation/SMILTime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698