1/*
2 * Copyright (C) 2018 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
17 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
18 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
22 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
23 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#pragma once
28
29#if ENABLE(CSS_PAINTING_API)
30
31#include "CSSImageGeneratorValue.h"
32
33namespace WebCore {
34class CSSVariableData;
35
36class CSSPaintImageValue final : public CSSImageGeneratorValue {
37public:
38 static Ref<CSSPaintImageValue> create(const String& name, Ref<CSSVariableData>&& arguments)
39 {
40 return adoptRef(*new CSSPaintImageValue(name, WTFMove(arguments)));
41 }
42
43 const String& name() const { return m_name; }
44
45 RefPtr<Image> image(RenderElement&, const FloatSize&);
46
47 bool equals(const CSSPaintImageValue& other) const { return m_name == other.m_name; }
48 String customCSSText() const;
49
50 bool isFixedSize() const { return false; }
51 FloatSize fixedSize(const RenderElement&) const { return FloatSize(); }
52
53 bool isPending() const { return false; }
54 bool knownToBeOpaque(const RenderElement&) const { return false; }
55
56 void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&) { }
57
58private:
59 CSSPaintImageValue(const String& name, Ref<CSSVariableData>&& arguments)
60 : CSSImageGeneratorValue(PaintImageClass)
61 , m_name(name)
62 , m_arguments(WTFMove(arguments))
63 {
64 }
65
66 const String m_name;
67 Ref<CSSVariableData> m_arguments;
68};
69
70} // namespace WebCore
71
72SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSPaintImageValue, isPaintImageValue())
73
74#endif
75