Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: third_party/WebKit/Source/core/css/CSSImageGeneratorValue.cpp

Issue 2755493004: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/css/ (Closed)
Patch Set: Worked on Review Comments done Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 23 matching lines...) Expand all
119 switch (getClassType()) { 119 switch (getClassType()) {
120 case CrossfadeClass: 120 case CrossfadeClass:
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 default: 128 default:
129 ASSERT_NOT_REACHED(); 129 NOTREACHED();
130 } 130 }
131 return nullptr; 131 return nullptr;
132 } 132 }
133 133
134 bool CSSImageGeneratorValue::isFixedSize() const { 134 bool CSSImageGeneratorValue::isFixedSize() const {
135 switch (getClassType()) { 135 switch (getClassType()) {
136 case CrossfadeClass: 136 case CrossfadeClass:
137 return toCSSCrossfadeValue(this)->isFixedSize(); 137 return toCSSCrossfadeValue(this)->isFixedSize();
138 case LinearGradientClass: 138 case LinearGradientClass:
139 return toCSSLinearGradientValue(this)->isFixedSize(); 139 return toCSSLinearGradientValue(this)->isFixedSize();
140 case PaintClass: 140 case PaintClass:
141 return toCSSPaintValue(this)->isFixedSize(); 141 return toCSSPaintValue(this)->isFixedSize();
142 case RadialGradientClass: 142 case RadialGradientClass:
143 return toCSSRadialGradientValue(this)->isFixedSize(); 143 return toCSSRadialGradientValue(this)->isFixedSize();
144 default: 144 default:
145 ASSERT_NOT_REACHED(); 145 NOTREACHED();
146 } 146 }
147 return false; 147 return false;
148 } 148 }
149 149
150 IntSize CSSImageGeneratorValue::fixedSize(const LayoutObject& layoutObject, 150 IntSize CSSImageGeneratorValue::fixedSize(const LayoutObject& layoutObject,
151 const FloatSize& defaultObjectSize) { 151 const FloatSize& defaultObjectSize) {
152 switch (getClassType()) { 152 switch (getClassType()) {
153 case CrossfadeClass: 153 case CrossfadeClass:
154 return toCSSCrossfadeValue(this)->fixedSize(layoutObject, 154 return toCSSCrossfadeValue(this)->fixedSize(layoutObject,
155 defaultObjectSize); 155 defaultObjectSize);
156 case LinearGradientClass: 156 case LinearGradientClass:
157 return toCSSLinearGradientValue(this)->fixedSize(layoutObject); 157 return toCSSLinearGradientValue(this)->fixedSize(layoutObject);
158 case PaintClass: 158 case PaintClass:
159 return toCSSPaintValue(this)->fixedSize(layoutObject); 159 return toCSSPaintValue(this)->fixedSize(layoutObject);
160 case RadialGradientClass: 160 case RadialGradientClass:
161 return toCSSRadialGradientValue(this)->fixedSize(layoutObject); 161 return toCSSRadialGradientValue(this)->fixedSize(layoutObject);
162 default: 162 default:
163 ASSERT_NOT_REACHED(); 163 NOTREACHED();
164 } 164 }
165 return IntSize(); 165 return IntSize();
166 } 166 }
167 167
168 bool CSSImageGeneratorValue::isPending() const { 168 bool CSSImageGeneratorValue::isPending() const {
169 switch (getClassType()) { 169 switch (getClassType()) {
170 case CrossfadeClass: 170 case CrossfadeClass:
171 return toCSSCrossfadeValue(this)->isPending(); 171 return toCSSCrossfadeValue(this)->isPending();
172 case LinearGradientClass: 172 case LinearGradientClass:
173 return toCSSLinearGradientValue(this)->isPending(); 173 return toCSSLinearGradientValue(this)->isPending();
174 case PaintClass: 174 case PaintClass:
175 return toCSSPaintValue(this)->isPending(); 175 return toCSSPaintValue(this)->isPending();
176 case RadialGradientClass: 176 case RadialGradientClass:
177 return toCSSRadialGradientValue(this)->isPending(); 177 return toCSSRadialGradientValue(this)->isPending();
178 default: 178 default:
179 ASSERT_NOT_REACHED(); 179 NOTREACHED();
180 } 180 }
181 return false; 181 return false;
182 } 182 }
183 183
184 bool CSSImageGeneratorValue::knownToBeOpaque( 184 bool CSSImageGeneratorValue::knownToBeOpaque(
185 const LayoutObject& layoutObject) const { 185 const LayoutObject& layoutObject) const {
186 switch (getClassType()) { 186 switch (getClassType()) {
187 case CrossfadeClass: 187 case CrossfadeClass:
188 return toCSSCrossfadeValue(this)->knownToBeOpaque(layoutObject); 188 return toCSSCrossfadeValue(this)->knownToBeOpaque(layoutObject);
189 case LinearGradientClass: 189 case LinearGradientClass:
190 return toCSSLinearGradientValue(this)->knownToBeOpaque(layoutObject); 190 return toCSSLinearGradientValue(this)->knownToBeOpaque(layoutObject);
191 case PaintClass: 191 case PaintClass:
192 return toCSSPaintValue(this)->knownToBeOpaque(layoutObject); 192 return toCSSPaintValue(this)->knownToBeOpaque(layoutObject);
193 case RadialGradientClass: 193 case RadialGradientClass:
194 return toCSSRadialGradientValue(this)->knownToBeOpaque(layoutObject); 194 return toCSSRadialGradientValue(this)->knownToBeOpaque(layoutObject);
195 default: 195 default:
196 ASSERT_NOT_REACHED(); 196 NOTREACHED();
197 } 197 }
198 return false; 198 return false;
199 } 199 }
200 200
201 void CSSImageGeneratorValue::loadSubimages(const Document& document) { 201 void CSSImageGeneratorValue::loadSubimages(const Document& document) {
202 switch (getClassType()) { 202 switch (getClassType()) {
203 case CrossfadeClass: 203 case CrossfadeClass:
204 toCSSCrossfadeValue(this)->loadSubimages(document); 204 toCSSCrossfadeValue(this)->loadSubimages(document);
205 break; 205 break;
206 case LinearGradientClass: 206 case LinearGradientClass:
207 toCSSLinearGradientValue(this)->loadSubimages(document); 207 toCSSLinearGradientValue(this)->loadSubimages(document);
208 break; 208 break;
209 case PaintClass: 209 case PaintClass:
210 toCSSPaintValue(this)->loadSubimages(document); 210 toCSSPaintValue(this)->loadSubimages(document);
211 break; 211 break;
212 case RadialGradientClass: 212 case RadialGradientClass:
213 toCSSRadialGradientValue(this)->loadSubimages(document); 213 toCSSRadialGradientValue(this)->loadSubimages(document);
214 break; 214 break;
215 default: 215 default:
216 ASSERT_NOT_REACHED(); 216 NOTREACHED();
217 } 217 }
218 } 218 }
219 219
220 } // namespace blink 220 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698