| OLD | NEW |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return std::max(value, 0.0); | 43 return std::max(value, 0.0); |
| 44 ASSERT(range == ValueRangeAll); | 44 ASSERT(range == ValueRangeAll); |
| 45 return value; | 45 return value; |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 AnimatableLength::AnimatableLength(const Length& length, float zoom) | 50 AnimatableLength::AnimatableLength(const Length& length, float zoom) |
| 51 { | 51 { |
| 52 ASSERT(zoom); | 52 ASSERT(zoom); |
| 53 PixelsAndPercent pixelsAndPercent = length.pixelsAndPercent(); | 53 PixelsAndPercent pixelsAndPercent = length.getPixelsAndPercent(); |
| 54 m_pixels = pixelsAndPercent.pixels / zoom; | 54 m_pixels = pixelsAndPercent.pixels / zoom; |
| 55 m_percent = pixelsAndPercent.percent; | 55 m_percent = pixelsAndPercent.percent; |
| 56 m_hasPixels = length.type() != Percent; | 56 m_hasPixels = length.type() != Percent; |
| 57 m_hasPercent = !length.isFixed(); | 57 m_hasPercent = !length.isFixed(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 Length AnimatableLength::length(float zoom, ValueRange range) const | 60 Length AnimatableLength::length(float zoom, ValueRange range) const |
| 61 { | 61 { |
| 62 if (!m_hasPercent) | 62 if (!m_hasPercent) |
| 63 return Length(clampNumber(m_pixels, range) * zoom, Fixed); | 63 return Length(clampNumber(m_pixels, range) * zoom, Fixed); |
| 64 if (!m_hasPixels) | 64 if (!m_hasPixels) |
| 65 return Length(clampNumber(m_percent, range), Percent); | 65 return Length(clampNumber(m_percent, range), Percent); |
| 66 return Length(CalculationValue::create(PixelsAndPercent(m_pixels * zoom, m_p
ercent), range)); | 66 return Length(CalculationValue::create(PixelsAndPercent(m_pixels * zoom, m_p
ercent), range)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 PassRefPtr<AnimatableValue> AnimatableLength::interpolateTo(const AnimatableValu
e* value, double fraction) const | 69 PassRefPtr<AnimatableValue> AnimatableLength::interpolateTo(const AnimatableValu
e* value, double fraction) const |
| 70 { | 70 { |
| 71 const AnimatableLength* length = toAnimatableLength(value); | 71 const AnimatableLength* length = toAnimatableLength(value); |
| 72 return create(blend(m_pixels, length->m_pixels, fraction), blend(m_percent,
length->m_percent, fraction), | 72 return create(blend(m_pixels, length->m_pixels, fraction), blend(m_percent,
length->m_percent, fraction), |
| 73 m_hasPixels || length->m_hasPixels, m_hasPercent || length->m_hasPercent
); | 73 m_hasPixels || length->m_hasPixels, m_hasPercent || length->m_hasPercent
); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool AnimatableLength::equalTo(const AnimatableValue* value) const | 76 bool AnimatableLength::equalTo(const AnimatableValue* value) const |
| 77 { | 77 { |
| 78 const AnimatableLength* length = toAnimatableLength(value); | 78 const AnimatableLength* length = toAnimatableLength(value); |
| 79 return m_pixels == length->m_pixels && m_percent == length->m_percent && m_h
asPixels == length->m_hasPixels && m_hasPercent == length->m_hasPercent; | 79 return m_pixels == length->m_pixels && m_percent == length->m_percent && m_h
asPixels == length->m_hasPixels && m_hasPercent == length->m_hasPercent; |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace blink | 82 } // namespace blink |
| OLD | NEW |