1e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch/* 2e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 2013 Google Inc. All rights reserved. 3e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * 4e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Redistribution and use in source and binary forms, with or without 5e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * modification, are permitted provided that the following conditions are 6e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * met: 7e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * 8e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * * Redistributions of source code must retain the above copyright 9e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * notice, this list of conditions and the following disclaimer. 10e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * * Redistributions in binary form must reproduce the above 11e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * copyright notice, this list of conditions and the following disclaimer 12e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * in the documentation and/or other materials provided with the 13e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * distribution. 14e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * * Neither the name of Google Inc. nor the names of its 15e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * contributors may be used to endorse or promote products derived from 16e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * this software without specific prior written permission. 17e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * 18e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch */ 30e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#ifndef AnimatableLength_h 321e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#define AnimatableLength_h 33e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 34197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "core/animation/animatable/AnimatableValue.h" 35bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)#include "platform/Length.h" 36e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 37c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 38e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 3909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class AnimatableLength FINAL : public AnimatableValue { 40e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochpublic: 41323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) static PassRefPtrWillBeRawPtr<AnimatableLength> create(const Length& length, float zoom) 421e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) { 43323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) return adoptRefWillBeNoop(new AnimatableLength(length, zoom)); 44f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) } 45323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) Length length(float zoom, ValueRange) const; 4607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 47f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)protected: 4807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch virtual PassRefPtrWillBeRawPtr<AnimatableValue> interpolateTo(const AnimatableValue*, double fraction) const OVERRIDE; 49f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 50f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)private: 51323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) static PassRefPtrWillBeRawPtr<AnimatableLength> create(double pixels, double percent, bool hasPixels, bool hasPercent) 52e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch { 53323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) return adoptRefWillBeNoop(new AnimatableLength(pixels, percent, hasPixels, hasPercent)); 54e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch } 55323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) AnimatableLength(const Length&, float zoom); 56323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) AnimatableLength(double pixels, double percent, bool hasPixels, bool hasPercent) 57323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) : m_pixels(pixels) 58323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) , m_percent(percent) 59323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) , m_hasPixels(hasPixels) 60323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) , m_hasPercent(hasPercent) 61e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch { 62323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) ASSERT(m_hasPixels || m_hasPercent); 63e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch } 641e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) virtual AnimatableType type() const OVERRIDE { return TypeLength; } 651e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) virtual bool equalTo(const AnimatableValue*) const OVERRIDE; 66e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 67323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) virtual void trace(Visitor* visitor) OVERRIDE { AnimatableValue::trace(visitor); } 68bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles) 69323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) double m_pixels; 70323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) double m_percent; 71323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) bool m_hasPixels; 72323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) bool m_hasPercent; 73e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch}; 74e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 75bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableLength, isLength()); 76e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 77c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 78e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 791e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#endif // AnimatableLength_h 80