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

Side by Side Diff: third_party/WebKit/Source/core/animation/animatable/AnimatableLengthBoxAndBool.cpp

Issue 2750293003: Delete unused AnimatableValue code (Closed)
Patch Set: Fix unit tests Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h" 31 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h"
32 32
33 #include "core/animation/animatable/AnimatableLength.h"
34 #include "core/animation/animatable/AnimatableLengthBox.h" 33 #include "core/animation/animatable/AnimatableLengthBox.h"
35 34
36 namespace blink { 35 namespace blink {
37 36
38 static bool sidesHaveSameUnits(const AnimatableValue* sideA,
39 const AnimatableValue* sideB) {
40 if (!sideA->isLength() || !sideB->isLength())
41 return false;
42 return toAnimatableLength(sideA)->hasSameUnits(toAnimatableLength(sideB));
43 }
44
45 // This is only used by *-image-slice properties which cannot interpolate
46 // between numbers and percentages. Numbers are internally represented by pixels
47 // on the ComputedStyle so we must manually type check both sides.
48 bool AnimatableLengthBoxAndBool::usesDefaultInterpolationWith(
49 const AnimatableValue* value) const {
50 const AnimatableLengthBoxAndBool* lengthBoxAndBool =
51 toAnimatableLengthBoxAndBool(value);
52 if (lengthBoxAndBool->flag() != flag())
53 return true;
54 if (!box()->isLengthBox() || !lengthBoxAndBool->box()->isLengthBox())
55 return AnimatableValue::usesDefaultInterpolation(box(),
56 lengthBoxAndBool->box());
57 const AnimatableLengthBox* boxA = toAnimatableLengthBox(box());
58 const AnimatableLengthBox* boxB =
59 toAnimatableLengthBox(lengthBoxAndBool->box());
60 return !sidesHaveSameUnits(boxA->left(), boxB->left()) ||
61 !sidesHaveSameUnits(boxA->right(), boxB->right()) ||
62 !sidesHaveSameUnits(boxA->top(), boxB->top()) ||
63 !sidesHaveSameUnits(boxA->bottom(), boxB->bottom());
64 }
65
66 PassRefPtr<AnimatableValue> AnimatableLengthBoxAndBool::interpolateTo(
67 const AnimatableValue* value,
68 double fraction) const {
69 const AnimatableLengthBoxAndBool* lengthBoxAndBool =
70 toAnimatableLengthBoxAndBool(value);
71 if (usesDefaultInterpolationWith(lengthBoxAndBool))
72 return defaultInterpolateTo(this, value, fraction);
73 return AnimatableLengthBoxAndBool::create(
74 AnimatableValue::interpolate(box(), lengthBoxAndBool->box(), fraction),
75 flag());
76 }
77
78 bool AnimatableLengthBoxAndBool::equalTo(const AnimatableValue* value) const { 37 bool AnimatableLengthBoxAndBool::equalTo(const AnimatableValue* value) const {
79 const AnimatableLengthBoxAndBool* lengthBox = 38 const AnimatableLengthBoxAndBool* lengthBox =
80 toAnimatableLengthBoxAndBool(value); 39 toAnimatableLengthBoxAndBool(value);
81 return box()->equals(lengthBox->box()) && flag() == lengthBox->flag(); 40 return m_box->equals(lengthBox->m_box.get()) && m_flag == lengthBox->m_flag;
82 } 41 }
83 42
84 } // namespace blink 43 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698