| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) | 36 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType) |
| 37 : CSSValue(classType) | 37 : CSSValue(classType) |
| 38 { | 38 { |
| 39 } | 39 } |
| 40 | 40 |
| 41 CSSImageGeneratorValue::~CSSImageGeneratorValue() | 41 CSSImageGeneratorValue::~CSSImageGeneratorValue() |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 void CSSImageGeneratorValue::addClient(RenderObject* renderer, const IntSize& si
ze) | 45 void CSSImageGeneratorValue::addClient(LayoutObject* renderer, const IntSize& si
ze) |
| 46 { | 46 { |
| 47 ASSERT(renderer); | 47 ASSERT(renderer); |
| 48 #if !ENABLE(OILPAN) | 48 #if !ENABLE(OILPAN) |
| 49 ref(); | 49 ref(); |
| 50 #else | 50 #else |
| 51 if (m_clients.isEmpty()) { | 51 if (m_clients.isEmpty()) { |
| 52 ASSERT(!m_keepAlive); | 52 ASSERT(!m_keepAlive); |
| 53 m_keepAlive = adoptPtr(new Persistent<CSSImageGeneratorValue>(this)); | 53 m_keepAlive = adoptPtr(new Persistent<CSSImageGeneratorValue>(this)); |
| 54 } | 54 } |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 if (!size.isEmpty()) | 57 if (!size.isEmpty()) |
| 58 m_sizes.add(size); | 58 m_sizes.add(size); |
| 59 | 59 |
| 60 RenderObjectSizeCountMap::iterator it = m_clients.find(renderer); | 60 LayoutObjectSizeCountMap::iterator it = m_clients.find(renderer); |
| 61 if (it == m_clients.end()) | 61 if (it == m_clients.end()) |
| 62 m_clients.add(renderer, SizeAndCount(size, 1)); | 62 m_clients.add(renderer, SizeAndCount(size, 1)); |
| 63 else { | 63 else { |
| 64 SizeAndCount& sizeCount = it->value; | 64 SizeAndCount& sizeCount = it->value; |
| 65 ++sizeCount.count; | 65 ++sizeCount.count; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 void CSSImageGeneratorValue::removeClient(RenderObject* renderer) | 69 void CSSImageGeneratorValue::removeClient(LayoutObject* renderer) |
| 70 { | 70 { |
| 71 ASSERT(renderer); | 71 ASSERT(renderer); |
| 72 RenderObjectSizeCountMap::iterator it = m_clients.find(renderer); | 72 LayoutObjectSizeCountMap::iterator it = m_clients.find(renderer); |
| 73 ASSERT_WITH_SECURITY_IMPLICATION(it != m_clients.end()); | 73 ASSERT_WITH_SECURITY_IMPLICATION(it != m_clients.end()); |
| 74 | 74 |
| 75 IntSize removedImageSize; | 75 IntSize removedImageSize; |
| 76 SizeAndCount& sizeCount = it->value; | 76 SizeAndCount& sizeCount = it->value; |
| 77 IntSize size = sizeCount.size; | 77 IntSize size = sizeCount.size; |
| 78 if (!size.isEmpty()) { | 78 if (!size.isEmpty()) { |
| 79 m_sizes.remove(size); | 79 m_sizes.remove(size); |
| 80 if (!m_sizes.contains(size)) | 80 if (!m_sizes.contains(size)) |
| 81 m_images.remove(size); | 81 m_images.remove(size); |
| 82 } | 82 } |
| 83 | 83 |
| 84 if (!--sizeCount.count) | 84 if (!--sizeCount.count) |
| 85 m_clients.remove(renderer); | 85 m_clients.remove(renderer); |
| 86 | 86 |
| 87 #if !ENABLE(OILPAN) | 87 #if !ENABLE(OILPAN) |
| 88 deref(); | 88 deref(); |
| 89 #else | 89 #else |
| 90 if (m_clients.isEmpty()) { | 90 if (m_clients.isEmpty()) { |
| 91 ASSERT(m_keepAlive); | 91 ASSERT(m_keepAlive); |
| 92 m_keepAlive = nullptr; | 92 m_keepAlive = nullptr; |
| 93 } | 93 } |
| 94 #endif | 94 #endif |
| 95 } | 95 } |
| 96 | 96 |
| 97 Image* CSSImageGeneratorValue::getImage(RenderObject* renderer, const IntSize& s
ize) | 97 Image* CSSImageGeneratorValue::getImage(LayoutObject* renderer, const IntSize& s
ize) |
| 98 { | 98 { |
| 99 RenderObjectSizeCountMap::iterator it = m_clients.find(renderer); | 99 LayoutObjectSizeCountMap::iterator it = m_clients.find(renderer); |
| 100 if (it != m_clients.end()) { | 100 if (it != m_clients.end()) { |
| 101 SizeAndCount& sizeCount = it->value; | 101 SizeAndCount& sizeCount = it->value; |
| 102 IntSize oldSize = sizeCount.size; | 102 IntSize oldSize = sizeCount.size; |
| 103 if (oldSize != size) { | 103 if (oldSize != size) { |
| 104 #if !ENABLE_OILPAN | 104 #if !ENABLE_OILPAN |
| 105 RefPtr<CSSImageGeneratorValue> protect(this); | 105 RefPtr<CSSImageGeneratorValue> protect(this); |
| 106 #endif | 106 #endif |
| 107 removeClient(renderer); | 107 removeClient(renderer); |
| 108 addClient(renderer, size); | 108 addClient(renderer, size); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Don't generate an image for empty sizes. | 112 // Don't generate an image for empty sizes. |
| 113 if (size.isEmpty()) | 113 if (size.isEmpty()) |
| 114 return 0; | 114 return 0; |
| 115 | 115 |
| 116 // Look up the image in our cache. | 116 // Look up the image in our cache. |
| 117 return m_images.get(size); | 117 return m_images.get(size); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
ge) | 120 void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
ge) |
| 121 { | 121 { |
| 122 m_images.add(size, image); | 122 m_images.add(size, image); |
| 123 } | 123 } |
| 124 | 124 |
| 125 PassRefPtr<Image> CSSImageGeneratorValue::image(RenderObject* renderer, const In
tSize& size) | 125 PassRefPtr<Image> CSSImageGeneratorValue::image(LayoutObject* renderer, const In
tSize& size) |
| 126 { | 126 { |
| 127 switch (classType()) { | 127 switch (classType()) { |
| 128 case CanvasClass: | 128 case CanvasClass: |
| 129 return toCSSCanvasValue(this)->image(renderer, size); | 129 return toCSSCanvasValue(this)->image(renderer, size); |
| 130 case CrossfadeClass: | 130 case CrossfadeClass: |
| 131 return toCSSCrossfadeValue(this)->image(renderer, size); | 131 return toCSSCrossfadeValue(this)->image(renderer, size); |
| 132 case LinearGradientClass: | 132 case LinearGradientClass: |
| 133 return toCSSLinearGradientValue(this)->image(renderer, size); | 133 return toCSSLinearGradientValue(this)->image(renderer, size); |
| 134 case RadialGradientClass: | 134 case RadialGradientClass: |
| 135 return toCSSRadialGradientValue(this)->image(renderer, size); | 135 return toCSSRadialGradientValue(this)->image(renderer, size); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 149 case LinearGradientClass: | 149 case LinearGradientClass: |
| 150 return toCSSLinearGradientValue(this)->isFixedSize(); | 150 return toCSSLinearGradientValue(this)->isFixedSize(); |
| 151 case RadialGradientClass: | 151 case RadialGradientClass: |
| 152 return toCSSRadialGradientValue(this)->isFixedSize(); | 152 return toCSSRadialGradientValue(this)->isFixedSize(); |
| 153 default: | 153 default: |
| 154 ASSERT_NOT_REACHED(); | 154 ASSERT_NOT_REACHED(); |
| 155 } | 155 } |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 | 158 |
| 159 IntSize CSSImageGeneratorValue::fixedSize(const RenderObject* renderer) | 159 IntSize CSSImageGeneratorValue::fixedSize(const LayoutObject* renderer) |
| 160 { | 160 { |
| 161 switch (classType()) { | 161 switch (classType()) { |
| 162 case CanvasClass: | 162 case CanvasClass: |
| 163 return toCSSCanvasValue(this)->fixedSize(renderer); | 163 return toCSSCanvasValue(this)->fixedSize(renderer); |
| 164 case CrossfadeClass: | 164 case CrossfadeClass: |
| 165 return toCSSCrossfadeValue(this)->fixedSize(renderer); | 165 return toCSSCrossfadeValue(this)->fixedSize(renderer); |
| 166 case LinearGradientClass: | 166 case LinearGradientClass: |
| 167 return toCSSLinearGradientValue(this)->fixedSize(renderer); | 167 return toCSSLinearGradientValue(this)->fixedSize(renderer); |
| 168 case RadialGradientClass: | 168 case RadialGradientClass: |
| 169 return toCSSRadialGradientValue(this)->fixedSize(renderer); | 169 return toCSSRadialGradientValue(this)->fixedSize(renderer); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 183 case LinearGradientClass: | 183 case LinearGradientClass: |
| 184 return toCSSLinearGradientValue(this)->isPending(); | 184 return toCSSLinearGradientValue(this)->isPending(); |
| 185 case RadialGradientClass: | 185 case RadialGradientClass: |
| 186 return toCSSRadialGradientValue(this)->isPending(); | 186 return toCSSRadialGradientValue(this)->isPending(); |
| 187 default: | 187 default: |
| 188 ASSERT_NOT_REACHED(); | 188 ASSERT_NOT_REACHED(); |
| 189 } | 189 } |
| 190 return false; | 190 return false; |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool CSSImageGeneratorValue::knownToBeOpaque(const RenderObject* renderer) const | 193 bool CSSImageGeneratorValue::knownToBeOpaque(const LayoutObject* renderer) const |
| 194 { | 194 { |
| 195 switch (classType()) { | 195 switch (classType()) { |
| 196 case CrossfadeClass: | 196 case CrossfadeClass: |
| 197 return toCSSCrossfadeValue(this)->knownToBeOpaque(renderer); | 197 return toCSSCrossfadeValue(this)->knownToBeOpaque(renderer); |
| 198 case CanvasClass: | 198 case CanvasClass: |
| 199 return false; | 199 return false; |
| 200 case LinearGradientClass: | 200 case LinearGradientClass: |
| 201 return toCSSLinearGradientValue(this)->knownToBeOpaque(renderer); | 201 return toCSSLinearGradientValue(this)->knownToBeOpaque(renderer); |
| 202 case RadialGradientClass: | 202 case RadialGradientClass: |
| 203 return toCSSRadialGradientValue(this)->knownToBeOpaque(renderer); | 203 return toCSSRadialGradientValue(this)->knownToBeOpaque(renderer); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 221 break; | 221 break; |
| 222 case RadialGradientClass: | 222 case RadialGradientClass: |
| 223 toCSSRadialGradientValue(this)->loadSubimages(fetcher); | 223 toCSSRadialGradientValue(this)->loadSubimages(fetcher); |
| 224 break; | 224 break; |
| 225 default: | 225 default: |
| 226 ASSERT_NOT_REACHED(); | 226 ASSERT_NOT_REACHED(); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace blink | 230 } // namespace blink |
| OLD | NEW |