| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 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 #include "sky/engine/config.h" | 26 #include "sky/engine/config.h" |
| 27 #include "sky/engine/core/css/CSSImageGeneratorValue.h" | 27 #include "sky/engine/core/css/CSSImageGeneratorValue.h" |
| 28 | 28 |
| 29 #include "sky/engine/core/css/CSSCanvasValue.h" | |
| 30 #include "sky/engine/core/css/CSSCrossfadeValue.h" | 29 #include "sky/engine/core/css/CSSCrossfadeValue.h" |
| 31 #include "sky/engine/core/css/CSSGradientValue.h" | 30 #include "sky/engine/core/css/CSSGradientValue.h" |
| 32 #include "sky/engine/platform/graphics/Image.h" | 31 #include "sky/engine/platform/graphics/Image.h" |
| 33 | 32 |
| 34 namespace blink { | 33 namespace blink { |
| 35 | 34 |
| 36 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) | 35 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) |
| 37 : CSSValue(classType) | 36 : CSSValue(classType) |
| 38 { | 37 { |
| 39 } | 38 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 110 } |
| 112 | 111 |
| 113 void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
ge) | 112 void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
ge) |
| 114 { | 113 { |
| 115 m_images.add(size, image); | 114 m_images.add(size, image); |
| 116 } | 115 } |
| 117 | 116 |
| 118 PassRefPtr<Image> CSSImageGeneratorValue::image(RenderObject* renderer, const In
tSize& size) | 117 PassRefPtr<Image> CSSImageGeneratorValue::image(RenderObject* renderer, const In
tSize& size) |
| 119 { | 118 { |
| 120 switch (classType()) { | 119 switch (classType()) { |
| 121 case CanvasClass: | |
| 122 return toCSSCanvasValue(this)->image(renderer, size); | |
| 123 case CrossfadeClass: | 120 case CrossfadeClass: |
| 124 return toCSSCrossfadeValue(this)->image(renderer, size); | 121 return toCSSCrossfadeValue(this)->image(renderer, size); |
| 125 case LinearGradientClass: | 122 case LinearGradientClass: |
| 126 return toCSSLinearGradientValue(this)->image(renderer, size); | 123 return toCSSLinearGradientValue(this)->image(renderer, size); |
| 127 case RadialGradientClass: | 124 case RadialGradientClass: |
| 128 return toCSSRadialGradientValue(this)->image(renderer, size); | 125 return toCSSRadialGradientValue(this)->image(renderer, size); |
| 129 default: | 126 default: |
| 130 ASSERT_NOT_REACHED(); | 127 ASSERT_NOT_REACHED(); |
| 131 } | 128 } |
| 132 return nullptr; | 129 return nullptr; |
| 133 } | 130 } |
| 134 | 131 |
| 135 bool CSSImageGeneratorValue::isFixedSize() const | 132 bool CSSImageGeneratorValue::isFixedSize() const |
| 136 { | 133 { |
| 137 switch (classType()) { | 134 switch (classType()) { |
| 138 case CanvasClass: | |
| 139 return toCSSCanvasValue(this)->isFixedSize(); | |
| 140 case CrossfadeClass: | 135 case CrossfadeClass: |
| 141 return toCSSCrossfadeValue(this)->isFixedSize(); | 136 return toCSSCrossfadeValue(this)->isFixedSize(); |
| 142 case LinearGradientClass: | 137 case LinearGradientClass: |
| 143 return toCSSLinearGradientValue(this)->isFixedSize(); | 138 return toCSSLinearGradientValue(this)->isFixedSize(); |
| 144 case RadialGradientClass: | 139 case RadialGradientClass: |
| 145 return toCSSRadialGradientValue(this)->isFixedSize(); | 140 return toCSSRadialGradientValue(this)->isFixedSize(); |
| 146 default: | 141 default: |
| 147 ASSERT_NOT_REACHED(); | 142 ASSERT_NOT_REACHED(); |
| 148 } | 143 } |
| 149 return false; | 144 return false; |
| 150 } | 145 } |
| 151 | 146 |
| 152 IntSize CSSImageGeneratorValue::fixedSize(const RenderObject* renderer) | 147 IntSize CSSImageGeneratorValue::fixedSize(const RenderObject* renderer) |
| 153 { | 148 { |
| 154 switch (classType()) { | 149 switch (classType()) { |
| 155 case CanvasClass: | |
| 156 return toCSSCanvasValue(this)->fixedSize(renderer); | |
| 157 case CrossfadeClass: | 150 case CrossfadeClass: |
| 158 return toCSSCrossfadeValue(this)->fixedSize(renderer); | 151 return toCSSCrossfadeValue(this)->fixedSize(renderer); |
| 159 case LinearGradientClass: | 152 case LinearGradientClass: |
| 160 return toCSSLinearGradientValue(this)->fixedSize(renderer); | 153 return toCSSLinearGradientValue(this)->fixedSize(renderer); |
| 161 case RadialGradientClass: | 154 case RadialGradientClass: |
| 162 return toCSSRadialGradientValue(this)->fixedSize(renderer); | 155 return toCSSRadialGradientValue(this)->fixedSize(renderer); |
| 163 default: | 156 default: |
| 164 ASSERT_NOT_REACHED(); | 157 ASSERT_NOT_REACHED(); |
| 165 } | 158 } |
| 166 return IntSize(); | 159 return IntSize(); |
| 167 } | 160 } |
| 168 | 161 |
| 169 bool CSSImageGeneratorValue::isPending() const | 162 bool CSSImageGeneratorValue::isPending() const |
| 170 { | 163 { |
| 171 switch (classType()) { | 164 switch (classType()) { |
| 172 case CrossfadeClass: | 165 case CrossfadeClass: |
| 173 return toCSSCrossfadeValue(this)->isPending(); | 166 return toCSSCrossfadeValue(this)->isPending(); |
| 174 case CanvasClass: | |
| 175 return toCSSCanvasValue(this)->isPending(); | |
| 176 case LinearGradientClass: | 167 case LinearGradientClass: |
| 177 return toCSSLinearGradientValue(this)->isPending(); | 168 return toCSSLinearGradientValue(this)->isPending(); |
| 178 case RadialGradientClass: | 169 case RadialGradientClass: |
| 179 return toCSSRadialGradientValue(this)->isPending(); | 170 return toCSSRadialGradientValue(this)->isPending(); |
| 180 default: | 171 default: |
| 181 ASSERT_NOT_REACHED(); | 172 ASSERT_NOT_REACHED(); |
| 182 } | 173 } |
| 183 return false; | 174 return false; |
| 184 } | 175 } |
| 185 | 176 |
| 186 bool CSSImageGeneratorValue::knownToBeOpaque(const RenderObject* renderer) const | 177 bool CSSImageGeneratorValue::knownToBeOpaque(const RenderObject* renderer) const |
| 187 { | 178 { |
| 188 switch (classType()) { | 179 switch (classType()) { |
| 189 case CrossfadeClass: | 180 case CrossfadeClass: |
| 190 return toCSSCrossfadeValue(this)->knownToBeOpaque(renderer); | 181 return toCSSCrossfadeValue(this)->knownToBeOpaque(renderer); |
| 191 case CanvasClass: | |
| 192 return false; | |
| 193 case LinearGradientClass: | 182 case LinearGradientClass: |
| 194 return toCSSLinearGradientValue(this)->knownToBeOpaque(renderer); | 183 return toCSSLinearGradientValue(this)->knownToBeOpaque(renderer); |
| 195 case RadialGradientClass: | 184 case RadialGradientClass: |
| 196 return toCSSRadialGradientValue(this)->knownToBeOpaque(renderer); | 185 return toCSSRadialGradientValue(this)->knownToBeOpaque(renderer); |
| 197 default: | 186 default: |
| 198 ASSERT_NOT_REACHED(); | 187 ASSERT_NOT_REACHED(); |
| 199 } | 188 } |
| 200 return false; | 189 return false; |
| 201 } | 190 } |
| 202 | 191 |
| 203 void CSSImageGeneratorValue::loadSubimages(ResourceFetcher* fetcher) | 192 void CSSImageGeneratorValue::loadSubimages(ResourceFetcher* fetcher) |
| 204 { | 193 { |
| 205 switch (classType()) { | 194 switch (classType()) { |
| 206 case CrossfadeClass: | 195 case CrossfadeClass: |
| 207 toCSSCrossfadeValue(this)->loadSubimages(fetcher); | 196 toCSSCrossfadeValue(this)->loadSubimages(fetcher); |
| 208 break; | 197 break; |
| 209 case CanvasClass: | |
| 210 toCSSCanvasValue(this)->loadSubimages(fetcher); | |
| 211 break; | |
| 212 case LinearGradientClass: | 198 case LinearGradientClass: |
| 213 toCSSLinearGradientValue(this)->loadSubimages(fetcher); | 199 toCSSLinearGradientValue(this)->loadSubimages(fetcher); |
| 214 break; | 200 break; |
| 215 case RadialGradientClass: | 201 case RadialGradientClass: |
| 216 toCSSRadialGradientValue(this)->loadSubimages(fetcher); | 202 toCSSRadialGradientValue(this)->loadSubimages(fetcher); |
| 217 break; | 203 break; |
| 218 default: | 204 default: |
| 219 ASSERT_NOT_REACHED(); | 205 ASSERT_NOT_REACHED(); |
| 220 } | 206 } |
| 221 } | 207 } |
| 222 | 208 |
| 223 } // namespace blink | 209 } // namespace blink |
| OLD | NEW |