hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 1 | /* |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2011, 2012, 2013 Apple Inc. All rights reserved. |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 3 | * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 14 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | * (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] | 24 | * 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] | 25 | */ |
| 26 | |
| 27 | #include "config.h" |
| 28 | #include "CSSImageGeneratorValue.h" |
| 29 | |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 30 | #include "CSSCanvasValue.h" |
| 31 | #include "CSSCrossfadeValue.h" |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 32 | #include "CSSFilterImageValue.h" |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 33 | #include "CSSGradientValue.h" |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 34 | #include "CSSImageValue.h" |
darin@apple.com | 044e722 | 2013-12-13 06:52:57 +0000 | [diff] [blame] | 35 | #include "GeneratedImage.h" |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 36 | #include "RenderElement.h" |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 37 | #include "StyleCachedImage.h" |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 38 | |
| 39 | namespace WebCore { |
| 40 | |
andersca@apple.com | 8ef4e62 | 2014-06-02 23:44:48 +0000 | [diff] [blame] | 41 | static const auto timeToKeepCachedGeneratedImages = std::chrono::seconds { 3 }; |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 42 | |
andreas.kling@nokia.com | 5fd2a71 | 2011-11-07 21:19:45 +0000 | [diff] [blame] | 43 | CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) |
| 44 | : CSSValue(classType) |
hyatt@apple.com | 18d8fbf | 2008-04-13 08:16:23 +0000 | [diff] [blame] | 45 | { |
hyatt@apple.com | 18d8fbf | 2008-04-13 08:16:23 +0000 | [diff] [blame] | 46 | } |
| 47 | |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 48 | CSSImageGeneratorValue::~CSSImageGeneratorValue() |
| 49 | { |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 50 | } |
| 51 | |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 52 | void CSSImageGeneratorValue::addClient(RenderElement* renderer) |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 53 | { |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 54 | ASSERT(renderer); |
darin@apple.com | 41cef87 | 2013-12-15 16:40:48 +0000 | [diff] [blame] | 55 | if (m_clients.isEmpty()) |
| 56 | ref(); |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 57 | m_clients.add(renderer); |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 58 | } |
| 59 | |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 60 | void CSSImageGeneratorValue::removeClient(RenderElement* renderer) |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 61 | { |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 62 | ASSERT(renderer); |
darin@apple.com | 41cef87 | 2013-12-15 16:40:48 +0000 | [diff] [blame] | 63 | ASSERT(m_clients.contains(renderer)); |
| 64 | if (m_clients.remove(renderer) && m_clients.isEmpty()) |
| 65 | deref(); |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 66 | } |
| 67 | |
zalan@apple.com | facdea7 | 2014-04-02 14:18:58 +0000 | [diff] [blame] | 68 | GeneratedImage* CSSImageGeneratorValue::cachedImageForSize(FloatSize size) |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 69 | { |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 70 | if (size.isEmpty()) |
darin@apple.com | 41cef87 | 2013-12-15 16:40:48 +0000 | [diff] [blame] | 71 | return nullptr; |
zimmermann@webkit.org | 57e4d0f | 2011-11-08 12:29:38 +0000 | [diff] [blame] | 72 | |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 73 | CachedGeneratedImage* cachedGeneratedImage = m_images.get(size); |
| 74 | if (!cachedGeneratedImage) |
darin@apple.com | 41cef87 | 2013-12-15 16:40:48 +0000 | [diff] [blame] | 75 | return nullptr; |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 76 | |
| 77 | cachedGeneratedImage->puntEvictionTimer(); |
| 78 | return cachedGeneratedImage->image(); |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 79 | } |
| 80 | |
zalan@apple.com | facdea7 | 2014-04-02 14:18:58 +0000 | [diff] [blame] | 81 | void CSSImageGeneratorValue::saveCachedImageForSize(FloatSize size, PassRefPtr<GeneratedImage> image) |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 82 | { |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 83 | ASSERT(!m_images.contains(size)); |
darin@apple.com | 044e722 | 2013-12-13 06:52:57 +0000 | [diff] [blame] | 84 | m_images.add(size, std::make_unique<CachedGeneratedImage>(*this, size, image)); |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 85 | } |
| 86 | |
zalan@apple.com | facdea7 | 2014-04-02 14:18:58 +0000 | [diff] [blame] | 87 | void CSSImageGeneratorValue::evictCachedGeneratedImage(FloatSize size) |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 88 | { |
| 89 | ASSERT(m_images.contains(size)); |
| 90 | m_images.remove(size); |
| 91 | } |
| 92 | |
zalan@apple.com | facdea7 | 2014-04-02 14:18:58 +0000 | [diff] [blame] | 93 | CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage(CSSImageGeneratorValue& owner, FloatSize size, PassRefPtr<GeneratedImage> image) |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 94 | : m_owner(owner) |
| 95 | , m_size(size) |
| 96 | , m_image(image) |
andersca@apple.com | 8ef4e62 | 2014-06-02 23:44:48 +0000 | [diff] [blame] | 97 | , m_evictionTimer(this, &CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired, timeToKeepCachedGeneratedImages) |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 98 | { |
| 99 | m_evictionTimer.restart(); |
| 100 | } |
| 101 | |
andersca@apple.com | 8ef4e62 | 2014-06-02 23:44:48 +0000 | [diff] [blame] | 102 | void CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired() |
akling@apple.com | f7adfcf | 2013-05-10 17:34:36 +0000 | [diff] [blame] | 103 | { |
| 104 | // NOTE: This is essentially a "delete this", the object is no longer valid after this line. |
| 105 | m_owner.evictCachedGeneratedImage(m_size); |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 106 | } |
| 107 | |
zalan@apple.com | facdea7 | 2014-04-02 14:18:58 +0000 | [diff] [blame] | 108 | PassRefPtr<Image> CSSImageGeneratorValue::image(RenderElement* renderer, const FloatSize& size) |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 109 | { |
| 110 | switch (classType()) { |
| 111 | case CanvasClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 112 | return downcast<CSSCanvasValue>(*this).image(renderer, size); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 113 | case CrossfadeClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 114 | return downcast<CSSCrossfadeValue>(*this).image(renderer, size); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 115 | case FilterImageClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 116 | return downcast<CSSFilterImageValue>(*this).image(renderer, size); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 117 | case LinearGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 118 | return downcast<CSSLinearGradientValue>(*this).image(renderer, size); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 119 | case RadialGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 120 | return downcast<CSSRadialGradientValue>(*this).image(renderer, size); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 121 | default: |
| 122 | ASSERT_NOT_REACHED(); |
| 123 | } |
darin@apple.com | 41cef87 | 2013-12-15 16:40:48 +0000 | [diff] [blame] | 124 | return nullptr; |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | bool CSSImageGeneratorValue::isFixedSize() const |
| 128 | { |
| 129 | switch (classType()) { |
| 130 | case CanvasClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 131 | return downcast<CSSCanvasValue>(*this).isFixedSize(); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 132 | case CrossfadeClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 133 | return downcast<CSSCrossfadeValue>(*this).isFixedSize(); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 134 | case FilterImageClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 135 | return downcast<CSSFilterImageValue>(*this).isFixedSize(); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 136 | case LinearGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 137 | return downcast<CSSLinearGradientValue>(*this).isFixedSize(); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 138 | case RadialGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 139 | return downcast<CSSRadialGradientValue>(*this).isFixedSize(); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 140 | default: |
| 141 | ASSERT_NOT_REACHED(); |
| 142 | } |
| 143 | return false; |
| 144 | } |
| 145 | |
zalan@apple.com | facdea7 | 2014-04-02 14:18:58 +0000 | [diff] [blame] | 146 | FloatSize CSSImageGeneratorValue::fixedSize(const RenderElement* renderer) |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 147 | { |
| 148 | switch (classType()) { |
| 149 | case CanvasClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 150 | return downcast<CSSCanvasValue>(*this).fixedSize(renderer); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 151 | case CrossfadeClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 152 | return downcast<CSSCrossfadeValue>(*this).fixedSize(renderer); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 153 | case FilterImageClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 154 | return downcast<CSSFilterImageValue>(*this).fixedSize(renderer); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 155 | case LinearGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 156 | return downcast<CSSLinearGradientValue>(*this).fixedSize(renderer); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 157 | case RadialGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 158 | return downcast<CSSRadialGradientValue>(*this).fixedSize(renderer); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 159 | default: |
| 160 | ASSERT_NOT_REACHED(); |
| 161 | } |
zalan@apple.com | facdea7 | 2014-04-02 14:18:58 +0000 | [diff] [blame] | 162 | return FloatSize(); |
andreas.kling@nokia.com | 30778ea | 2011-11-08 17:33:07 +0000 | [diff] [blame] | 163 | } |
| 164 | |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 165 | bool CSSImageGeneratorValue::isPending() const |
| 166 | { |
| 167 | switch (classType()) { |
| 168 | case CrossfadeClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 169 | return downcast<CSSCrossfadeValue>(*this).isPending(); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 170 | case CanvasClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 171 | return downcast<CSSCanvasValue>(*this).isPending(); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 172 | case FilterImageClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 173 | return downcast<CSSFilterImageValue>(*this).isPending(); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 174 | case LinearGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 175 | return downcast<CSSLinearGradientValue>(*this).isPending(); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 176 | case RadialGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 177 | return downcast<CSSRadialGradientValue>(*this).isPending(); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 178 | default: |
| 179 | ASSERT_NOT_REACHED(); |
| 180 | } |
| 181 | return false; |
| 182 | } |
| 183 | |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 184 | bool CSSImageGeneratorValue::knownToBeOpaque(const RenderElement* renderer) const |
junov@google.com | f3d27f2 | 2012-11-23 18:43:51 +0000 | [diff] [blame] | 185 | { |
| 186 | switch (classType()) { |
| 187 | case CrossfadeClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 188 | return downcast<CSSCrossfadeValue>(*this).knownToBeOpaque(renderer); |
junov@google.com | f3d27f2 | 2012-11-23 18:43:51 +0000 | [diff] [blame] | 189 | case CanvasClass: |
pdr@google.com | ebc67c6 | 2013-02-01 21:31:00 +0000 | [diff] [blame] | 190 | return false; |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 191 | case FilterImageClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 192 | return downcast<CSSFilterImageValue>(*this).knownToBeOpaque(renderer); |
junov@google.com | f3d27f2 | 2012-11-23 18:43:51 +0000 | [diff] [blame] | 193 | case LinearGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 194 | return downcast<CSSLinearGradientValue>(*this).knownToBeOpaque(renderer); |
junov@google.com | f3d27f2 | 2012-11-23 18:43:51 +0000 | [diff] [blame] | 195 | case RadialGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 196 | return downcast<CSSRadialGradientValue>(*this).knownToBeOpaque(renderer); |
junov@google.com | f3d27f2 | 2012-11-23 18:43:51 +0000 | [diff] [blame] | 197 | default: |
| 198 | ASSERT_NOT_REACHED(); |
| 199 | } |
pdr@google.com | ebc67c6 | 2013-02-01 21:31:00 +0000 | [diff] [blame] | 200 | return false; |
junov@google.com | f3d27f2 | 2012-11-23 18:43:51 +0000 | [diff] [blame] | 201 | } |
| 202 | |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 203 | void CSSImageGeneratorValue::loadSubimages(CachedResourceLoader* cachedResourceLoader) |
| 204 | { |
| 205 | switch (classType()) { |
| 206 | case CrossfadeClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 207 | downcast<CSSCrossfadeValue>(*this).loadSubimages(cachedResourceLoader); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 208 | break; |
| 209 | case CanvasClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 210 | downcast<CSSCanvasValue>(*this).loadSubimages(cachedResourceLoader); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 211 | break; |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 212 | case FilterImageClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 213 | downcast<CSSFilterImageValue>(*this).loadSubimages(cachedResourceLoader); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 214 | break; |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 215 | case LinearGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 216 | downcast<CSSLinearGradientValue>(*this).loadSubimages(cachedResourceLoader); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 217 | break; |
| 218 | case RadialGradientClass: |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 219 | downcast<CSSRadialGradientValue>(*this).loadSubimages(cachedResourceLoader); |
timothy_horton@apple.com | 37b1764 | 2011-11-17 01:28:25 +0000 | [diff] [blame] | 220 | break; |
| 221 | default: |
| 222 | ASSERT_NOT_REACHED(); |
| 223 | } |
| 224 | } |
| 225 | |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 226 | bool CSSImageGeneratorValue::subimageIsPending(CSSValue* value) |
| 227 | { |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 228 | if (is<CSSImageValue>(*value)) |
| 229 | return downcast<CSSImageValue>(*value).cachedOrPendingImage()->isPendingImage(); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 230 | |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 231 | if (is<CSSImageGeneratorValue>(*value)) |
| 232 | return downcast<CSSImageGeneratorValue>(*value).isPending(); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 233 | |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 234 | if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).getValueID() == CSSValueNone) |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 235 | return false; |
| 236 | |
| 237 | ASSERT_NOT_REACHED(); |
| 238 | |
| 239 | return false; |
| 240 | } |
| 241 | |
| 242 | CachedImage* CSSImageGeneratorValue::cachedImageForCSSValue(CSSValue* value, CachedResourceLoader* cachedResourceLoader) |
| 243 | { |
| 244 | if (!value) |
darin@apple.com | 044e722 | 2013-12-13 06:52:57 +0000 | [diff] [blame] | 245 | return nullptr; |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 246 | |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 247 | if (is<CSSImageValue>(*value)) { |
| 248 | StyleCachedImage* styleCachedImage = downcast<CSSImageValue>(*value).cachedImage(cachedResourceLoader); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 249 | if (!styleCachedImage) |
darin@apple.com | 044e722 | 2013-12-13 06:52:57 +0000 | [diff] [blame] | 250 | return nullptr; |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 251 | |
| 252 | return styleCachedImage->cachedImage(); |
| 253 | } |
| 254 | |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 255 | if (is<CSSImageGeneratorValue>(*value)) { |
| 256 | downcast<CSSImageGeneratorValue>(*value).loadSubimages(cachedResourceLoader); |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 257 | // FIXME: Handle CSSImageGeneratorValue (and thus cross-fades with gradients and canvas). |
darin@apple.com | 044e722 | 2013-12-13 06:52:57 +0000 | [diff] [blame] | 258 | return nullptr; |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 259 | } |
| 260 | |
cdumez@apple.com | 7e1bcb2 | 2014-10-03 23:17:00 +0000 | [diff] [blame] | 261 | if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).getValueID() == CSSValueNone) |
darin@apple.com | 044e722 | 2013-12-13 06:52:57 +0000 | [diff] [blame] | 262 | return nullptr; |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 263 | |
| 264 | ASSERT_NOT_REACHED(); |
| 265 | |
darin@apple.com | 044e722 | 2013-12-13 06:52:57 +0000 | [diff] [blame] | 266 | return nullptr; |
krit@webkit.org | c18645d | 2013-08-15 21:29:26 +0000 | [diff] [blame] | 267 | } |
hyatt@apple.com | 805aaf4 | 2008-04-12 03:24:45 +0000 | [diff] [blame] | 268 | } // namespace WebCore |