109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)/*
209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Copyright (C) 2014 Google Inc. All rights reserved.
309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *
409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * modification, are permitted provided that the following conditions are
609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * met:
709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *
809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
1009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
1109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
1209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * in the documentation and/or other materials provided with the
1309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * distribution.
1409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
1509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
1609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * this software without specific prior written permission.
1709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *
1809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) */
3009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
3109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#ifndef SVGBoolean_h
3209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#define SVGBoolean_h
3309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
3407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "core/svg/properties/SVGProperty.h"
3509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
3609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)namespace WebCore {
3709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
3807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochclass SVGBoolean : public SVGPropertyBase {
3909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)public:
4009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // SVGBoolean does not have a tear-off type.
4109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    typedef void TearOffType;
4209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    typedef bool PrimitiveType;
4309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
4409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    static PassRefPtr<SVGBoolean> create(bool value = false)
4509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    {
4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        return adoptRef(new SVGBoolean(value));
4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    }
4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
4909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    PassRefPtr<SVGBoolean> clone() const { return create(m_value); }
5007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const OVERRIDE;
5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
5209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    virtual String valueAsString() const OVERRIDE;
5309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setValueAsString(const String&, ExceptionState&);
5409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
55d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    virtual void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) OVERRIDE;
5607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPtr<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) OVERRIDE;
5707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement*) OVERRIDE;
5809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool operator==(const SVGBoolean& other) const { return m_value == other.m_value; }
6009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool operator!=(const SVGBoolean& other) const { return !operator==(other); }
6109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool value() const { return m_value; }
6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setValue(bool value) { m_value = value; }
6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
6509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    static AnimatedPropertyType classType() { return AnimatedBoolean; }
6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
6709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)private:
6809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    SVGBoolean(bool value)
6907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch        : SVGPropertyBase(classType())
7009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        , m_value(value)
7109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    {
7209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    }
7309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
7409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_value;
7509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)};
7609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
7707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochinline PassRefPtr<SVGBoolean> toSVGBoolean(PassRefPtr<SVGPropertyBase> passBase)
7809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
7907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    RefPtr<SVGPropertyBase> base = passBase;
8009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    ASSERT(base->type() == SVGBoolean::classType());
8109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    return static_pointer_cast<SVGBoolean>(base.release());
8209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
8309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
8409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} // namespace WebCore
8509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
8609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif // SVGBoolean_h
87