1 | /* |
2 | * Copyright (C) 2006 Rob Buis <buis@kde.org> |
3 | * Copyright (C) 2008 Apple Inc. All right reserved. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include "CSSValue.h" |
24 | #include "IntPoint.h" |
25 | #include "ResourceLoaderOptions.h" |
26 | #include <wtf/HashSet.h> |
27 | |
28 | namespace WebCore { |
29 | |
30 | class CachedImage; |
31 | class CachedResourceLoader; |
32 | class Document; |
33 | class Element; |
34 | class SVGCursorElement; |
35 | class SVGElement; |
36 | |
37 | class CSSCursorImageValue final : public CSSValue { |
38 | public: |
39 | static Ref<CSSCursorImageValue> create(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource) |
40 | { |
41 | return adoptRef(*new CSSCursorImageValue(WTFMove(imageValue), hasHotSpot, hotSpot, loadedFromOpaqueSource)); |
42 | } |
43 | |
44 | ~CSSCursorImageValue(); |
45 | |
46 | bool hasHotSpot() const { return m_hasHotSpot; } |
47 | |
48 | IntPoint hotSpot() const |
49 | { |
50 | if (m_hasHotSpot) |
51 | return m_hotSpot; |
52 | return IntPoint(-1, -1); |
53 | } |
54 | |
55 | const URL& imageURL() const { return m_originalURL; } |
56 | |
57 | String customCSSText() const; |
58 | |
59 | std::pair<CachedImage*, float> loadImage(CachedResourceLoader&, const ResourceLoaderOptions&); |
60 | |
61 | void removeReferencedElement(SVGElement*); |
62 | |
63 | bool equals(const CSSCursorImageValue&) const; |
64 | |
65 | void cursorElementRemoved(SVGCursorElement&); |
66 | void cursorElementChanged(SVGCursorElement&); |
67 | |
68 | private: |
69 | CSSCursorImageValue(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot, LoadedFromOpaqueSource); |
70 | |
71 | SVGCursorElement* updateCursorElement(const Document&); |
72 | |
73 | URL m_originalURL; |
74 | Ref<CSSValue> m_imageValue; |
75 | |
76 | bool m_hasHotSpot; |
77 | IntPoint m_hotSpot; |
78 | HashSet<SVGCursorElement*> m_cursorElements; |
79 | LoadedFromOpaqueSource m_loadedFromOpaqueSource { LoadedFromOpaqueSource::No }; |
80 | }; |
81 | |
82 | } // namespace WebCore |
83 | |
84 | SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSCursorImageValue, isCursorImageValue()) |
85 | |