<commit_before>// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef InterpolableValue_h
#define InterpolableValue_h

#include "core/animation/AnimatableValue.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"

namespace WebCore {

class InterpolableValue : public NoBaseWillBeGarbageCollected<InterpolableValue> {
    DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue);
public:
    virtual bool isNumber() const { return false; }
    virtual bool isBool() const { return false; }
    virtual bool isList() const { return false; }
    virtual bool isAnimatableValue() const { return false; }

    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0;

    virtual void trace(Visitor*) = 0;

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &to, const double progress) const = 0;

    friend class Interpolation;

    // Keep interpolate private, but allow calls within the hierarchy without
    // knowledge of type.
    friend class InterpolableNumber;
    friend class InterpolableBool;
    friend class InterpolableList;
};

class InterpolableNumber : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value)
    {
        return adoptPtrWillBeNoop(new InterpolableNumber(value));
    }

    virtual bool isNumber() const OVERRIDE FINAL { return true; }
    double value() const { return m_value; }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); }

    virtual void trace(Visitor*) OVERRIDE { }

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &to, const double progress) const OVERRIDE FINAL;
    double m_value;

    explicit InterpolableNumber(double value)
        : m_value(value)
    {
    }

};

class InterpolableBool : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value)
    {
        return adoptPtrWillBeNoop(new InterpolableBool(value));
    }

    virtual bool isBool() const OVERRIDE FINAL { return true; }
    bool value() const { return m_value; }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); }

    virtual void trace(Visitor*) OVERRIDE { }

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &to, const double progress) const OVERRIDE FINAL;
    bool m_value;

    explicit InterpolableBool(bool value)
        : m_value(value)
    {
    }

};

class InterpolableList : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableList &other)
    {
        return adoptPtrWillBeNoop(new InterpolableList(other));
    }

    static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size)
    {
        return adoptPtrWillBeNoop(new InterpolableList(size));
    }

    virtual bool isList() const OVERRIDE FINAL { return true; }
    void set(size_t position, PassOwnPtrWillBeRawPtr<InterpolableValue> value)
    {
        ASSERT(position < m_size);
        m_values[position] = value;
    }
    const InterpolableValue* get(size_t position) const
    {
        ASSERT(position < m_size);
        return m_values[position].get();
    }
    size_t length() const { return m_size; }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(*this); }

    virtual void trace(Visitor*) OVERRIDE;

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &other, const double progress) const OVERRIDE FINAL;
    explicit InterpolableList(size_t size)
        : m_size(size)
    {
        m_values.reserveCapacity(m_size);
        m_values.resize(m_size);
    }

    InterpolableList(const InterpolableList& other)
        : m_size(other.m_size)
    {
        m_values.reserveCapacity(m_size);
        m_values.resize(m_size);
        for (size_t i = 0; i < m_size; i++)
            set(i, other.m_values[i]->clone());
    }

    size_t m_size;
    WillBeHeapVector<OwnPtrWillBeMember<InterpolableValue> > m_values;
};

// FIXME: Remove this when we can.
class InterpolableAnimatableValue : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableAnimatableValue> create(PassRefPtrWillBeRawPtr<AnimatableValue> value)
    {
        return adoptPtrWillBeNoop(new InterpolableAnimatableValue(value));
    }

    virtual bool isAnimatableValue() const OVERRIDE FINAL { return true; }
    AnimatableValue* value() const { return m_value.get(); }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); }

    virtual void trace(Visitor*) OVERRIDE;

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &other, const double progress) const OVERRIDE FINAL;
    RefPtrWillBeMember<AnimatableValue> m_value;

    InterpolableAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value)
        : m_value(value)
    {
    }
};<commit_msg>Oilpan: Initialize the size of InterporableValue::m_values in the constructor<commit_after>// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef InterpolableValue_h
#define InterpolableValue_h

#include "core/animation/AnimatableValue.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"

namespace WebCore {

class InterpolableValue : public NoBaseWillBeGarbageCollected<InterpolableValue> {
    DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue);
public:
    virtual bool isNumber() const { return false; }
    virtual bool isBool() const { return false; }
    virtual bool isList() const { return false; }
    virtual bool isAnimatableValue() const { return false; }

    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0;

    virtual void trace(Visitor*) = 0;

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &to, const double progress) const = 0;

    friend class Interpolation;

    // Keep interpolate private, but allow calls within the hierarchy without
    // knowledge of type.
    friend class InterpolableNumber;
    friend class InterpolableBool;
    friend class InterpolableList;
};

class InterpolableNumber : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value)
    {
        return adoptPtrWillBeNoop(new InterpolableNumber(value));
    }

    virtual bool isNumber() const OVERRIDE FINAL { return true; }
    double value() const { return m_value; }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); }

    virtual void trace(Visitor*) OVERRIDE { }

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &to, const double progress) const OVERRIDE FINAL;
    double m_value;

    explicit InterpolableNumber(double value)
        : m_value(value)
    {
    }

};

class InterpolableBool : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value)
    {
        return adoptPtrWillBeNoop(new InterpolableBool(value));
    }

    virtual bool isBool() const OVERRIDE FINAL { return true; }
    bool value() const { return m_value; }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); }

    virtual void trace(Visitor*) OVERRIDE { }

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &to, const double progress) const OVERRIDE FINAL;
    bool m_value;

    explicit InterpolableBool(bool value)
        : m_value(value)
    {
    }

};

class InterpolableList : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableList &other)
    {
        return adoptPtrWillBeNoop(new InterpolableList(other));
    }

    static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size)
    {
        return adoptPtrWillBeNoop(new InterpolableList(size));
    }

    virtual bool isList() const OVERRIDE FINAL { return true; }
    void set(size_t position, PassOwnPtrWillBeRawPtr<InterpolableValue> value)
    {
        ASSERT(position < m_size);
        m_values[position] = value;
    }
    const InterpolableValue* get(size_t position) const
    {
        ASSERT(position < m_size);
        return m_values[position].get();
    }
    size_t length() const { return m_size; }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(*this); }

    virtual void trace(Visitor*) OVERRIDE;

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &other, const double progress) const OVERRIDE FINAL;
    explicit InterpolableList(size_t size)
        : m_size(size)
        , m_values(m_size)
    {
    }

    InterpolableList(const InterpolableList& other)
        : m_size(other.m_size)
        , m_values(m_size)
    {
        for (size_t i = 0; i < m_size; i++)
            set(i, other.m_values[i]->clone());
    }

    size_t m_size;
    WillBeHeapVector<OwnPtrWillBeMember<InterpolableValue> > m_values;
};

// FIXME: Remove this when we can.
class InterpolableAnimatableValue : public InterpolableValue {
public:
    static PassOwnPtrWillBeRawPtr<InterpolableAnimatableValue> create(PassRefPtrWillBeRawPtr<AnimatableValue> value)
    {
        return adoptPtrWillBeNoop(new InterpolableAnimatableValue(value));
    }

    virtual bool isAnimatableValue() const OVERRIDE FINAL { return true; }
    AnimatableValue* value() const { return m_value.get(); }
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); }

    virtual void trace(Visitor*) OVERRIDE;

private:
    virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const InterpolableValue &other, const double progress) const OVERRIDE FINAL;
    RefPtrWillBeMember<AnimatableValue> m_value;

    InterpolableAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value)
        : m_value(value)
    {
    }
};
{'fraction_non_alphanumeric': 0.08022459078797108, 'fraction_numerical': 0.0015226494099733537, 'mean_word_length': 4.210213187902826, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4999229', 'n_tokens_mistral': 3269, 'n_tokens_neox': 3152, 'n_words': 780}