summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/style/style_crossfade_image.h
blob: dad4122f0362eec7051722c650168e6eaa014f76 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2021 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_STYLE_STYLE_CROSSFADE_IMAGE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_CROSSFADE_IMAGE_H_

#include "third_party/blink/renderer/core/style/style_image.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"

namespace blink {

namespace cssvalue {
class CSSCrossfadeValue;
}

// This class represents a <cross-fade()> <image> function.
class StyleCrossfadeImage final : public StyleImage {
 public:
  StyleCrossfadeImage(cssvalue::CSSCrossfadeValue&,
                      StyleImage* from_image,
                      StyleImage* to_image);
  ~StyleCrossfadeImage() override;

  CSSValue* CssValue() const override;
  CSSValue* ComputedCSSValue(const ComputedStyle&,
                             bool allow_visited_style) const override;

  bool CanRender() const override;
  bool IsLoaded() const override;
  bool ErrorOccurred() const override;
  bool IsAccessAllowed(String&) const override;

  FloatSize ImageSize(float multiplier,
                      const FloatSize& default_object_size,
                      RespectImageOrientationEnum) const override;

  bool HasIntrinsicSize() const override;

  void AddClient(ImageResourceObserver*) override;
  void RemoveClient(ImageResourceObserver*) override;

  scoped_refptr<Image> GetImage(const ImageResourceObserver&,
                                const Document&,
                                const ComputedStyle&,
                                const FloatSize& target_size) const override;

  WrappedImagePtr Data() const override;
  bool KnownToBeOpaque(const Document&, const ComputedStyle&) const override;

  void Trace(Visitor*) const override;

 private:
  bool IsEqual(const StyleImage&) const override;

  Member<cssvalue::CSSCrossfadeValue> original_value_;
  Member<StyleImage> from_image_;
  Member<StyleImage> to_image_;
};

template <>
struct DowncastTraits<StyleCrossfadeImage> {
  static bool AllowFrom(const StyleImage& style_image) {
    return style_image.IsCrossfadeImage();
  }
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_CROSSFADE_IMAGE_H_