| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) | 36 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) |
| 37 : CSSValue(classType) {} | 37 : CSSValue(classType) {} |
| 38 | 38 |
| 39 CSSImageGeneratorValue::~CSSImageGeneratorValue() {} | 39 CSSImageGeneratorValue::~CSSImageGeneratorValue() {} |
| 40 | 40 |
| 41 void CSSImageGeneratorValue::addClient(const LayoutObject* layoutObject, | 41 void CSSImageGeneratorValue::addClient(const LayoutObject* layoutObject, |
| 42 const IntSize& size) { | 42 const IntSize& size) { |
| 43 ASSERT(layoutObject); | 43 DCHECK(layoutObject); |
| 44 if (m_clients.isEmpty()) { | 44 if (m_clients.isEmpty()) { |
| 45 ASSERT(!m_keepAlive); | 45 DCHECK(!m_keepAlive); |
| 46 m_keepAlive = this; | 46 m_keepAlive = this; |
| 47 } | 47 } |
| 48 | 48 |
| 49 if (!size.isEmpty()) | 49 if (!size.isEmpty()) |
| 50 m_sizes.add(size); | 50 m_sizes.add(size); |
| 51 | 51 |
| 52 LayoutObjectSizeCountMap::iterator it = m_clients.find(layoutObject); | 52 LayoutObjectSizeCountMap::iterator it = m_clients.find(layoutObject); |
| 53 if (it == m_clients.end()) { | 53 if (it == m_clients.end()) { |
| 54 m_clients.insert(layoutObject, SizeAndCount(size, 1)); | 54 m_clients.insert(layoutObject, SizeAndCount(size, 1)); |
| 55 } else { | 55 } else { |
| 56 SizeAndCount& sizeCount = it->value; | 56 SizeAndCount& sizeCount = it->value; |
| 57 ++sizeCount.count; | 57 ++sizeCount.count; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 CSSImageGeneratorValue* CSSImageGeneratorValue::valueWithURLsMadeAbsolute() { | 61 CSSImageGeneratorValue* CSSImageGeneratorValue::valueWithURLsMadeAbsolute() { |
| 62 if (isCrossfadeValue()) | 62 if (isCrossfadeValue()) |
| 63 return toCSSCrossfadeValue(this)->valueWithURLsMadeAbsolute(); | 63 return toCSSCrossfadeValue(this)->valueWithURLsMadeAbsolute(); |
| 64 return this; | 64 return this; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void CSSImageGeneratorValue::removeClient(const LayoutObject* layoutObject) { | 67 void CSSImageGeneratorValue::removeClient(const LayoutObject* layoutObject) { |
| 68 ASSERT(layoutObject); | 68 DCHECK(layoutObject); |
| 69 LayoutObjectSizeCountMap::iterator it = m_clients.find(layoutObject); | 69 LayoutObjectSizeCountMap::iterator it = m_clients.find(layoutObject); |
| 70 SECURITY_DCHECK(it != m_clients.end()); | 70 SECURITY_DCHECK(it != m_clients.end()); |
| 71 | 71 |
| 72 IntSize removedImageSize; | 72 IntSize removedImageSize; |
| 73 SizeAndCount& sizeCount = it->value; | 73 SizeAndCount& sizeCount = it->value; |
| 74 IntSize size = sizeCount.size; | 74 IntSize size = sizeCount.size; |
| 75 if (!size.isEmpty()) { | 75 if (!size.isEmpty()) { |
| 76 m_sizes.remove(size); | 76 m_sizes.remove(size); |
| 77 if (!m_sizes.contains(size)) | 77 if (!m_sizes.contains(size)) |
| 78 m_images.erase(size); | 78 m_images.erase(size); |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (!--sizeCount.count) | 81 if (!--sizeCount.count) |
| 82 m_clients.erase(layoutObject); | 82 m_clients.erase(layoutObject); |
| 83 | 83 |
| 84 if (m_clients.isEmpty()) { | 84 if (m_clients.isEmpty()) { |
| 85 ASSERT(m_keepAlive); | 85 DCHECK(m_keepAlive); |
| 86 m_keepAlive.clear(); | 86 m_keepAlive.clear(); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 Image* CSSImageGeneratorValue::getImage(const LayoutObject* layoutObject, | 90 Image* CSSImageGeneratorValue::getImage(const LayoutObject* layoutObject, |
| 91 const IntSize& size) { | 91 const IntSize& size) { |
| 92 LayoutObjectSizeCountMap::iterator it = m_clients.find(layoutObject); | 92 LayoutObjectSizeCountMap::iterator it = m_clients.find(layoutObject); |
| 93 if (it != m_clients.end()) { | 93 if (it != m_clients.end()) { |
| 94 SizeAndCount& sizeCount = it->value; | 94 SizeAndCount& sizeCount = it->value; |
| 95 IntSize oldSize = sizeCount.size; | 95 IntSize oldSize = sizeCount.size; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 121 return toCSSCrossfadeValue(this)->image(layoutObject, size); | 121 return toCSSCrossfadeValue(this)->image(layoutObject, size); |
| 122 case LinearGradientClass: | 122 case LinearGradientClass: |
| 123 return toCSSLinearGradientValue(this)->image(layoutObject, size); | 123 return toCSSLinearGradientValue(this)->image(layoutObject, size); |
| 124 case PaintClass: | 124 case PaintClass: |
| 125 return toCSSPaintValue(this)->image(layoutObject, size, zoom); | 125 return toCSSPaintValue(this)->image(layoutObject, size, zoom); |
| 126 case RadialGradientClass: | 126 case RadialGradientClass: |
| 127 return toCSSRadialGradientValue(this)->image(layoutObject, size); | 127 return toCSSRadialGradientValue(this)->image(layoutObject, size); |
| 128 case ConicGradientClass: | 128 case ConicGradientClass: |
| 129 return toCSSConicGradientValue(this)->image(layoutObject, size); | 129 return toCSSConicGradientValue(this)->image(layoutObject, size); |
| 130 default: | 130 default: |
| 131 ASSERT_NOT_REACHED(); | 131 NOTREACHED(); |
| 132 } | 132 } |
| 133 return nullptr; | 133 return nullptr; |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool CSSImageGeneratorValue::isFixedSize() const { | 136 bool CSSImageGeneratorValue::isFixedSize() const { |
| 137 switch (getClassType()) { | 137 switch (getClassType()) { |
| 138 case CrossfadeClass: | 138 case CrossfadeClass: |
| 139 return toCSSCrossfadeValue(this)->isFixedSize(); | 139 return toCSSCrossfadeValue(this)->isFixedSize(); |
| 140 case LinearGradientClass: | 140 case LinearGradientClass: |
| 141 return toCSSLinearGradientValue(this)->isFixedSize(); | 141 return toCSSLinearGradientValue(this)->isFixedSize(); |
| 142 case PaintClass: | 142 case PaintClass: |
| 143 return toCSSPaintValue(this)->isFixedSize(); | 143 return toCSSPaintValue(this)->isFixedSize(); |
| 144 case RadialGradientClass: | 144 case RadialGradientClass: |
| 145 return toCSSRadialGradientValue(this)->isFixedSize(); | 145 return toCSSRadialGradientValue(this)->isFixedSize(); |
| 146 case ConicGradientClass: | 146 case ConicGradientClass: |
| 147 return toCSSConicGradientValue(this)->isFixedSize(); | 147 return toCSSConicGradientValue(this)->isFixedSize(); |
| 148 default: | 148 default: |
| 149 ASSERT_NOT_REACHED(); | 149 NOTREACHED(); |
| 150 } | 150 } |
| 151 return false; | 151 return false; |
| 152 } | 152 } |
| 153 | 153 |
| 154 IntSize CSSImageGeneratorValue::fixedSize(const LayoutObject& layoutObject, | 154 IntSize CSSImageGeneratorValue::fixedSize(const LayoutObject& layoutObject, |
| 155 const FloatSize& defaultObjectSize) { | 155 const FloatSize& defaultObjectSize) { |
| 156 switch (getClassType()) { | 156 switch (getClassType()) { |
| 157 case CrossfadeClass: | 157 case CrossfadeClass: |
| 158 return toCSSCrossfadeValue(this)->fixedSize(layoutObject, | 158 return toCSSCrossfadeValue(this)->fixedSize(layoutObject, |
| 159 defaultObjectSize); | 159 defaultObjectSize); |
| 160 case LinearGradientClass: | 160 case LinearGradientClass: |
| 161 return toCSSLinearGradientValue(this)->fixedSize(layoutObject); | 161 return toCSSLinearGradientValue(this)->fixedSize(layoutObject); |
| 162 case PaintClass: | 162 case PaintClass: |
| 163 return toCSSPaintValue(this)->fixedSize(layoutObject); | 163 return toCSSPaintValue(this)->fixedSize(layoutObject); |
| 164 case RadialGradientClass: | 164 case RadialGradientClass: |
| 165 return toCSSRadialGradientValue(this)->fixedSize(layoutObject); | 165 return toCSSRadialGradientValue(this)->fixedSize(layoutObject); |
| 166 case ConicGradientClass: | 166 case ConicGradientClass: |
| 167 return toCSSConicGradientValue(this)->fixedSize(layoutObject); | 167 return toCSSConicGradientValue(this)->fixedSize(layoutObject); |
| 168 default: | 168 default: |
| 169 ASSERT_NOT_REACHED(); | 169 NOTREACHED(); |
| 170 } | 170 } |
| 171 return IntSize(); | 171 return IntSize(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool CSSImageGeneratorValue::isPending() const { | 174 bool CSSImageGeneratorValue::isPending() const { |
| 175 switch (getClassType()) { | 175 switch (getClassType()) { |
| 176 case CrossfadeClass: | 176 case CrossfadeClass: |
| 177 return toCSSCrossfadeValue(this)->isPending(); | 177 return toCSSCrossfadeValue(this)->isPending(); |
| 178 case LinearGradientClass: | 178 case LinearGradientClass: |
| 179 return toCSSLinearGradientValue(this)->isPending(); | 179 return toCSSLinearGradientValue(this)->isPending(); |
| 180 case PaintClass: | 180 case PaintClass: |
| 181 return toCSSPaintValue(this)->isPending(); | 181 return toCSSPaintValue(this)->isPending(); |
| 182 case RadialGradientClass: | 182 case RadialGradientClass: |
| 183 return toCSSRadialGradientValue(this)->isPending(); | 183 return toCSSRadialGradientValue(this)->isPending(); |
| 184 case ConicGradientClass: | 184 case ConicGradientClass: |
| 185 return toCSSConicGradientValue(this)->isPending(); | 185 return toCSSConicGradientValue(this)->isPending(); |
| 186 default: | 186 default: |
| 187 ASSERT_NOT_REACHED(); | 187 NOTREACHED(); |
| 188 } | 188 } |
| 189 return false; | 189 return false; |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool CSSImageGeneratorValue::knownToBeOpaque( | 192 bool CSSImageGeneratorValue::knownToBeOpaque( |
| 193 const LayoutObject& layoutObject) const { | 193 const LayoutObject& layoutObject) const { |
| 194 switch (getClassType()) { | 194 switch (getClassType()) { |
| 195 case CrossfadeClass: | 195 case CrossfadeClass: |
| 196 return toCSSCrossfadeValue(this)->knownToBeOpaque(layoutObject); | 196 return toCSSCrossfadeValue(this)->knownToBeOpaque(layoutObject); |
| 197 case LinearGradientClass: | 197 case LinearGradientClass: |
| 198 return toCSSLinearGradientValue(this)->knownToBeOpaque(layoutObject); | 198 return toCSSLinearGradientValue(this)->knownToBeOpaque(layoutObject); |
| 199 case PaintClass: | 199 case PaintClass: |
| 200 return toCSSPaintValue(this)->knownToBeOpaque(layoutObject); | 200 return toCSSPaintValue(this)->knownToBeOpaque(layoutObject); |
| 201 case RadialGradientClass: | 201 case RadialGradientClass: |
| 202 return toCSSRadialGradientValue(this)->knownToBeOpaque(layoutObject); | 202 return toCSSRadialGradientValue(this)->knownToBeOpaque(layoutObject); |
| 203 case ConicGradientClass: | 203 case ConicGradientClass: |
| 204 return toCSSConicGradientValue(this)->knownToBeOpaque(layoutObject); | 204 return toCSSConicGradientValue(this)->knownToBeOpaque(layoutObject); |
| 205 default: | 205 default: |
| 206 ASSERT_NOT_REACHED(); | 206 NOTREACHED(); |
| 207 } | 207 } |
| 208 return false; | 208 return false; |
| 209 } | 209 } |
| 210 | 210 |
| 211 void CSSImageGeneratorValue::loadSubimages(const Document& document) { | 211 void CSSImageGeneratorValue::loadSubimages(const Document& document) { |
| 212 switch (getClassType()) { | 212 switch (getClassType()) { |
| 213 case CrossfadeClass: | 213 case CrossfadeClass: |
| 214 toCSSCrossfadeValue(this)->loadSubimages(document); | 214 toCSSCrossfadeValue(this)->loadSubimages(document); |
| 215 break; | 215 break; |
| 216 case LinearGradientClass: | 216 case LinearGradientClass: |
| 217 toCSSLinearGradientValue(this)->loadSubimages(document); | 217 toCSSLinearGradientValue(this)->loadSubimages(document); |
| 218 break; | 218 break; |
| 219 case PaintClass: | 219 case PaintClass: |
| 220 toCSSPaintValue(this)->loadSubimages(document); | 220 toCSSPaintValue(this)->loadSubimages(document); |
| 221 break; | 221 break; |
| 222 case RadialGradientClass: | 222 case RadialGradientClass: |
| 223 toCSSRadialGradientValue(this)->loadSubimages(document); | 223 toCSSRadialGradientValue(this)->loadSubimages(document); |
| 224 break; | 224 break; |
| 225 case ConicGradientClass: | 225 case ConicGradientClass: |
| 226 toCSSConicGradientValue(this)->loadSubimages(document); | 226 toCSSConicGradientValue(this)->loadSubimages(document); |
| 227 break; | 227 break; |
| 228 default: | 228 default: |
| 229 ASSERT_NOT_REACHED(); | 229 NOTREACHED(); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |