summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/animation/underlying_length_checker.h
blob: badae96ef7c8f707b1e3bab7ceb3a5f1f363640f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2015 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 THIRD_PARTY_BLINK_RENDERER_CORE_ANIMATION_UNDERLYING_LENGTH_CHECKER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_ANIMATION_UNDERLYING_LENGTH_CHECKER_H_

#include <memory>

#include "base/memory/ptr_util.h"
#include "third_party/blink/renderer/core/animation/interpolable_value.h"
#include "third_party/blink/renderer/core/animation/interpolation_type.h"

namespace blink {

class UnderlyingLengthChecker : public InterpolationType::ConversionChecker {
 public:
  explicit UnderlyingLengthChecker(wtf_size_t underlying_length)
      : underlying_length_(underlying_length) {}

  static wtf_size_t GetUnderlyingLength(const InterpolationValue& underlying) {
    if (!underlying)
      return 0;
    return To<InterpolableList>(*underlying.interpolable_value).length();
  }

  bool IsValid(const InterpolationEnvironment&,
               const InterpolationValue& underlying) const final {
    return underlying_length_ == GetUnderlyingLength(underlying);
  }

 private:
  wtf_size_t underlying_length_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_ANIMATION_UNDERLYING_LENGTH_CHECKER_H_