OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef CSSImageGeneratorValue_h | 26 #ifndef CSSImageGeneratorValue_h |
27 #define CSSImageGeneratorValue_h | 27 #define CSSImageGeneratorValue_h |
28 | 28 |
29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
30 #include "core/css/CSSValue.h" | 30 #include "core/css/CSSValue.h" |
| 31 #include "core/style/StyleImage.h" |
31 #include "platform/geometry/IntSizeHash.h" | 32 #include "platform/geometry/IntSizeHash.h" |
32 #include "wtf/HashCountedSet.h" | 33 #include "wtf/HashCountedSet.h" |
33 #include "wtf/RefPtr.h" | 34 #include "wtf/RefPtr.h" |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
| 38 class ComputedStyle; |
37 class Document; | 39 class Document; |
| 40 class ElementStyleResources; |
38 class Image; | 41 class Image; |
39 class LayoutObject; | 42 class LayoutObject; |
40 | 43 |
41 struct SizeAndCount { | 44 struct SizeAndCount { |
42 DISALLOW_ALLOCATION(); | 45 DISALLOW_ALLOCATION(); |
43 SizeAndCount(IntSize newSize = IntSize(), int newCount = 0) | 46 SizeAndCount(IntSize newSize = IntSize(), int newCount = 0) |
44 : size(newSize) | 47 : size(newSize) |
45 , count(newCount) | 48 , count(newCount) |
46 { | 49 { |
47 } | 50 } |
48 | 51 |
49 IntSize size; | 52 IntSize size; |
50 int count; | 53 int count; |
51 }; | 54 }; |
52 | 55 |
53 typedef HashMap<const LayoutObject*, SizeAndCount> LayoutObjectSizeCountMap; | 56 typedef HashMap<const LayoutObject*, SizeAndCount> LayoutObjectSizeCountMap; |
54 | 57 |
55 class CORE_EXPORT CSSImageGeneratorValue : public CSSValue { | 58 class CORE_EXPORT CSSImageGeneratorValue : public CSSValue { |
56 public: | 59 public: |
57 ~CSSImageGeneratorValue(); | 60 ~CSSImageGeneratorValue(); |
58 | 61 |
59 void addClient(LayoutObject*, const IntSize&); | 62 void addClient(LayoutObject*, const IntSize&); |
60 void removeClient(LayoutObject*); | 63 void removeClient(LayoutObject*); |
61 PassRefPtr<Image> image(LayoutObject*, const IntSize&); | 64 PassRefPtr<Image> image(LayoutObject*, const IntSize&); |
62 | 65 |
63 bool isFixedSize() const; | 66 bool isFixedSize() const; |
64 IntSize fixedSize(const LayoutObject*); | 67 IntSize fixedSize(const LayoutObject*); |
65 | 68 |
66 bool isPending() const; | 69 bool isPending(CSSStyleImageMap&) const; |
67 bool knownToBeOpaque(const LayoutObject*) const; | 70 bool knownToBeOpaque(const LayoutObject*) const; |
68 | 71 |
69 void loadSubimages(Document*); | 72 void loadSubimages(Document*, CSSStyleImageMap&); |
70 | 73 |
71 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { CSSValue::traceAfterDispatch(visitor)
; } | 74 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { CSSValue::traceAfterDispatch(visitor)
; } |
72 | 75 |
73 protected: | 76 protected: |
74 explicit CSSImageGeneratorValue(ClassType); | 77 explicit CSSImageGeneratorValue(ClassType); |
75 | 78 |
76 Image* getImage(LayoutObject*, const IntSize&); | 79 Image* getImage(LayoutObject*, const IntSize&); |
77 void putImage(const IntSize&, PassRefPtr<Image>); | 80 void putImage(const IntSize&, PassRefPtr<Image>); |
78 const LayoutObjectSizeCountMap& clients() const { return m_clients; } | 81 const LayoutObjectSizeCountMap& clients() const { return m_clients; } |
79 | 82 |
80 HashCountedSet<IntSize> m_sizes; // A count of how many times a given image
size is in use. | 83 HashCountedSet<IntSize> m_sizes; // A count of how many times a given image
size is in use. |
81 LayoutObjectSizeCountMap m_clients; // A map from LayoutObjects (with entry
count) to image sizes. | 84 LayoutObjectSizeCountMap m_clients; // A map from LayoutObjects (with entry
count) to image sizes. |
82 HashMap<IntSize, RefPtr<Image>> m_images; // A cache of Image objects by ima
ge size. | 85 HashMap<IntSize, RefPtr<Image>> m_images; // A cache of Image objects by ima
ge size. |
83 | 86 |
84 #if ENABLE(OILPAN) | 87 #if ENABLE(OILPAN) |
85 // FIXME: Oilpan: when/if we can make the layoutObject point directly to the
CSSImageGenerator value using | 88 // FIXME: Oilpan: when/if we can make the layoutObject point directly to the
CSSImageGenerator value using |
86 // a member we don't need to have this hack where we keep a persistent to th
e instance as long as | 89 // a member we don't need to have this hack where we keep a persistent to th
e instance as long as |
87 // there are clients in the LayoutObjectSizeCountMap. | 90 // there are clients in the LayoutObjectSizeCountMap. |
88 SelfKeepAlive<CSSImageGeneratorValue> m_keepAlive; | 91 SelfKeepAlive<CSSImageGeneratorValue> m_keepAlive; |
89 #endif | 92 #endif |
90 }; | 93 }; |
91 | 94 |
92 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageGeneratorValue, isImageGeneratorValue()); | 95 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageGeneratorValue, isImageGeneratorValue()); |
93 | 96 |
94 } // namespace blink | 97 } // namespace blink |
95 | 98 |
96 #endif // CSSImageGeneratorValue_h | 99 #endif // CSSImageGeneratorValue_h |
OLD | NEW |