hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008 Apple Inc. All rights reserved. |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, 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 THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #ifndef CSSImageGeneratorValue_h |
| 27 | #define CSSImageGeneratorValue_h |
| 28 | |
| 29 | #include "CSSValue.h" |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 30 | #include "IntSizeHash.h" |
| 31 | #include <wtf/HashCountedSet.h> |
| 32 | #include <wtf/RefPtr.h> |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 33 | |
| 34 | namespace WebCore { |
| 35 | |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 36 | class CachedResourceLoader; |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 37 | class Image; |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 38 | class RenderObject; |
commit-queue@webkit.org | 0cda1fa | 2012-07-24 05:34:42 +0000 | [diff] [blame] | 39 | class StyleResolver; |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 40 | |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 41 | struct SizeAndCount { |
| 42 | SizeAndCount(IntSize newSize = IntSize(), int newCount = 0) |
| 43 | : size(newSize) |
| 44 | , count(newCount) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | IntSize size; |
| 49 | int count; |
| 50 | }; |
| 51 | |
| 52 | typedef HashMap<const RenderObject*, SizeAndCount> RenderObjectSizeCountMap; |
| 53 | |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 54 | class CSSImageGeneratorValue : public CSSValue { |
| 55 | public: |
andreas.kling@nokia.com | a5eb3c5 | 2011-11-08 18:27:07 +0000 | [diff] [blame] | 56 | ~CSSImageGeneratorValue(); |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 57 | |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 58 | void addClient(RenderObject*, const IntSize&); |
| 59 | void removeClient(RenderObject*); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 60 | PassRefPtr<Image> image(RenderObject*, const IntSize&); |
hyatt@apple.com | 18d8fbf | 2008-04-13 08:16:23 +0000 | [diff] [blame] | 61 | |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 62 | bool isFixedSize() const; |
| 63 | IntSize fixedSize(const RenderObject*); |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 64 | |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 65 | bool isPending() const; |
| 66 | |
| 67 | void loadSubimages(CachedResourceLoader*); |
| 68 | |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 69 | protected: |
andreas.kling@nokia.com | 5fd2a71 | 2011-11-07 21:19:45 +0000 | [diff] [blame] | 70 | CSSImageGeneratorValue(ClassType); |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 71 | |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 72 | Image* getImage(RenderObject*, const IntSize&); |
eric@webkit.org | 0f90168 | 2008-08-29 21:38:56 +0000 | [diff] [blame] | 73 | void putImage(const IntSize&, PassRefPtr<Image>); |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 74 | const RenderObjectSizeCountMap& clients() const { return m_clients; } |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 75 | |
yurys@chromium.org | 3f4777f | 2012-08-06 14:09:59 +0000 | [diff] [blame] | 76 | void reportBaseClassMemoryUsage(MemoryObjectInfo*) const; |
| 77 | |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 78 | HashCountedSet<IntSize> m_sizes; // A count of how many times a given image size is in use. |
| 79 | RenderObjectSizeCountMap m_clients; // A map from RenderObjects (with entry count) to image sizes. |
| 80 | HashMap<IntSize, RefPtr<Image> > m_images; // A cache of Image objects by image size. |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace WebCore |
| 84 | |
| 85 | #endif // CSSImageGeneratorValue_h |