| 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/core/css/CSSImageGeneratorValue.h" | 26 #include "sky/engine/core/css/CSSImageGeneratorValue.h" |
| 27 | 27 |
| 28 #include "sky/engine/core/css/CSSCrossfadeValue.h" | |
| 29 #include "sky/engine/core/css/CSSGradientValue.h" | 28 #include "sky/engine/core/css/CSSGradientValue.h" |
| 30 #include "sky/engine/platform/graphics/Image.h" | 29 #include "sky/engine/platform/graphics/Image.h" |
| 31 | 30 |
| 32 namespace blink { | 31 namespace blink { |
| 33 | 32 |
| 34 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) | 33 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) |
| 35 : CSSValue(classType) | 34 : CSSValue(classType) |
| 36 { | 35 { |
| 37 } | 36 } |
| 38 | 37 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 108 } |
| 110 | 109 |
| 111 void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
ge) | 110 void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
ge) |
| 112 { | 111 { |
| 113 m_images.add(size, image); | 112 m_images.add(size, image); |
| 114 } | 113 } |
| 115 | 114 |
| 116 PassRefPtr<Image> CSSImageGeneratorValue::image(RenderObject* renderer, const In
tSize& size) | 115 PassRefPtr<Image> CSSImageGeneratorValue::image(RenderObject* renderer, const In
tSize& size) |
| 117 { | 116 { |
| 118 switch (classType()) { | 117 switch (classType()) { |
| 119 case CrossfadeClass: | |
| 120 return toCSSCrossfadeValue(this)->image(renderer, size); | |
| 121 case LinearGradientClass: | 118 case LinearGradientClass: |
| 122 return toCSSLinearGradientValue(this)->image(renderer, size); | 119 return toCSSLinearGradientValue(this)->image(renderer, size); |
| 123 case RadialGradientClass: | 120 case RadialGradientClass: |
| 124 return toCSSRadialGradientValue(this)->image(renderer, size); | 121 return toCSSRadialGradientValue(this)->image(renderer, size); |
| 125 default: | 122 default: |
| 126 ASSERT_NOT_REACHED(); | 123 ASSERT_NOT_REACHED(); |
| 127 } | 124 } |
| 128 return nullptr; | 125 return nullptr; |
| 129 } | 126 } |
| 130 | 127 |
| 131 bool CSSImageGeneratorValue::isFixedSize() const | 128 bool CSSImageGeneratorValue::isFixedSize() const |
| 132 { | 129 { |
| 133 switch (classType()) { | 130 switch (classType()) { |
| 134 case CrossfadeClass: | |
| 135 return toCSSCrossfadeValue(this)->isFixedSize(); | |
| 136 case LinearGradientClass: | 131 case LinearGradientClass: |
| 137 return toCSSLinearGradientValue(this)->isFixedSize(); | 132 return toCSSLinearGradientValue(this)->isFixedSize(); |
| 138 case RadialGradientClass: | 133 case RadialGradientClass: |
| 139 return toCSSRadialGradientValue(this)->isFixedSize(); | 134 return toCSSRadialGradientValue(this)->isFixedSize(); |
| 140 default: | 135 default: |
| 141 ASSERT_NOT_REACHED(); | 136 ASSERT_NOT_REACHED(); |
| 142 } | 137 } |
| 143 return false; | 138 return false; |
| 144 } | 139 } |
| 145 | 140 |
| 146 IntSize CSSImageGeneratorValue::fixedSize(const RenderObject* renderer) | 141 IntSize CSSImageGeneratorValue::fixedSize(const RenderObject* renderer) |
| 147 { | 142 { |
| 148 switch (classType()) { | 143 switch (classType()) { |
| 149 case CrossfadeClass: | |
| 150 return toCSSCrossfadeValue(this)->fixedSize(renderer); | |
| 151 case LinearGradientClass: | 144 case LinearGradientClass: |
| 152 return toCSSLinearGradientValue(this)->fixedSize(renderer); | 145 return toCSSLinearGradientValue(this)->fixedSize(renderer); |
| 153 case RadialGradientClass: | 146 case RadialGradientClass: |
| 154 return toCSSRadialGradientValue(this)->fixedSize(renderer); | 147 return toCSSRadialGradientValue(this)->fixedSize(renderer); |
| 155 default: | 148 default: |
| 156 ASSERT_NOT_REACHED(); | 149 ASSERT_NOT_REACHED(); |
| 157 } | 150 } |
| 158 return IntSize(); | 151 return IntSize(); |
| 159 } | 152 } |
| 160 | 153 |
| 161 bool CSSImageGeneratorValue::isPending() const | 154 bool CSSImageGeneratorValue::isPending() const |
| 162 { | 155 { |
| 163 switch (classType()) { | 156 switch (classType()) { |
| 164 case CrossfadeClass: | |
| 165 return toCSSCrossfadeValue(this)->isPending(); | |
| 166 case LinearGradientClass: | 157 case LinearGradientClass: |
| 167 return toCSSLinearGradientValue(this)->isPending(); | 158 return toCSSLinearGradientValue(this)->isPending(); |
| 168 case RadialGradientClass: | 159 case RadialGradientClass: |
| 169 return toCSSRadialGradientValue(this)->isPending(); | 160 return toCSSRadialGradientValue(this)->isPending(); |
| 170 default: | 161 default: |
| 171 ASSERT_NOT_REACHED(); | 162 ASSERT_NOT_REACHED(); |
| 172 } | 163 } |
| 173 return false; | 164 return false; |
| 174 } | 165 } |
| 175 | 166 |
| 176 bool CSSImageGeneratorValue::knownToBeOpaque(const RenderObject* renderer) const | 167 bool CSSImageGeneratorValue::knownToBeOpaque(const RenderObject* renderer) const |
| 177 { | 168 { |
| 178 switch (classType()) { | 169 switch (classType()) { |
| 179 case CrossfadeClass: | |
| 180 return toCSSCrossfadeValue(this)->knownToBeOpaque(renderer); | |
| 181 case LinearGradientClass: | 170 case LinearGradientClass: |
| 182 return toCSSLinearGradientValue(this)->knownToBeOpaque(renderer); | 171 return toCSSLinearGradientValue(this)->knownToBeOpaque(renderer); |
| 183 case RadialGradientClass: | 172 case RadialGradientClass: |
| 184 return toCSSRadialGradientValue(this)->knownToBeOpaque(renderer); | 173 return toCSSRadialGradientValue(this)->knownToBeOpaque(renderer); |
| 185 default: | 174 default: |
| 186 ASSERT_NOT_REACHED(); | 175 ASSERT_NOT_REACHED(); |
| 187 } | 176 } |
| 188 return false; | 177 return false; |
| 189 } | 178 } |
| 190 | 179 |
| 191 void CSSImageGeneratorValue::loadSubimages(ResourceFetcher* fetcher) | 180 void CSSImageGeneratorValue::loadSubimages(ResourceFetcher* fetcher) |
| 192 { | 181 { |
| 193 switch (classType()) { | 182 switch (classType()) { |
| 194 case CrossfadeClass: | |
| 195 toCSSCrossfadeValue(this)->loadSubimages(fetcher); | |
| 196 break; | |
| 197 case LinearGradientClass: | 183 case LinearGradientClass: |
| 198 toCSSLinearGradientValue(this)->loadSubimages(fetcher); | 184 toCSSLinearGradientValue(this)->loadSubimages(fetcher); |
| 199 break; | 185 break; |
| 200 case RadialGradientClass: | 186 case RadialGradientClass: |
| 201 toCSSRadialGradientValue(this)->loadSubimages(fetcher); | 187 toCSSRadialGradientValue(this)->loadSubimages(fetcher); |
| 202 break; | 188 break; |
| 203 default: | 189 default: |
| 204 ASSERT_NOT_REACHED(); | 190 ASSERT_NOT_REACHED(); |
| 205 } | 191 } |
| 206 } | 192 } |
| 207 | 193 |
| 208 } // namespace blink | 194 } // namespace blink |
| OLD | NEW |