OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 PresentationAttributeCache::ValueType* cacheValue; | 167 PresentationAttributeCache::ValueType* cacheValue; |
168 if (cacheHash) { | 168 if (cacheHash) { |
169 cacheValue = presentationAttributeCache().add(cacheHash, nullptr).stored
Value; | 169 cacheValue = presentationAttributeCache().add(cacheHash, nullptr).stored
Value; |
170 if (cacheValue->value && cacheValue->value->key != cacheKey) | 170 if (cacheValue->value && cacheValue->value->key != cacheKey) |
171 cacheHash = 0; | 171 cacheHash = 0; |
172 } else { | 172 } else { |
173 cacheValue = nullptr; | 173 cacheValue = nullptr; |
174 } | 174 } |
175 | 175 |
176 RawPtr<StylePropertySet> style = nullptr; | 176 StylePropertySet* style = nullptr; |
177 if (cacheHash && cacheValue->value) { | 177 if (cacheHash && cacheValue->value) { |
178 style = cacheValue->value->value; | 178 style = cacheValue->value->value; |
179 cacheCleaner.didHitPresentationAttributeCache(); | 179 cacheCleaner.didHitPresentationAttributeCache(); |
180 } else { | 180 } else { |
181 style = MutableStylePropertySet::create(element.isSVGElement() ? SVGAttr
ibuteMode : HTMLAttributeMode); | 181 style = MutableStylePropertySet::create(element.isSVGElement() ? SVGAttr
ibuteMode : HTMLAttributeMode); |
182 AttributeCollection attributes = element.attributesWithoutUpdate(); | 182 AttributeCollection attributes = element.attributesWithoutUpdate(); |
183 for (const Attribute& attr : attributes) | 183 for (const Attribute& attr : attributes) |
184 element.collectStyleForPresentationAttribute(attr.name(), attr.value
(), toMutableStylePropertySet(style)); | 184 element.collectStyleForPresentationAttribute(attr.name(), attr.value
(), toMutableStylePropertySet(style)); |
185 } | 185 } |
186 | 186 |
187 if (!cacheHash || cacheValue->value) | 187 if (!cacheHash || cacheValue->value) |
188 return style.release(); | 188 return style; |
189 | 189 |
190 RawPtr<PresentationAttributeCacheEntry> newEntry = new PresentationAttribute
CacheEntry; | 190 RawPtr<PresentationAttributeCacheEntry> newEntry = new PresentationAttribute
CacheEntry; |
191 newEntry->key = cacheKey; | 191 newEntry->key = cacheKey; |
192 newEntry->value = style; | 192 newEntry->value = style; |
193 | 193 |
194 static const unsigned presentationAttributeCacheMaximumSize = 4096; | 194 static const unsigned presentationAttributeCacheMaximumSize = 4096; |
195 if (presentationAttributeCache().size() > presentationAttributeCacheMaximumS
ize) { | 195 if (presentationAttributeCache().size() > presentationAttributeCacheMaximumS
ize) { |
196 // FIXME: Discarding the entire cache when it gets too big is probably b
ad | 196 // FIXME: Discarding the entire cache when it gets too big is probably b
ad |
197 // since it creates a perf "cliff". Perhaps we should use an LRU? | 197 // since it creates a perf "cliff". Perhaps we should use an LRU? |
198 presentationAttributeCache().clear(); | 198 presentationAttributeCache().clear(); |
199 presentationAttributeCache().set(cacheHash, newEntry.release()); | 199 presentationAttributeCache().set(cacheHash, newEntry.release()); |
200 } else { | 200 } else { |
201 cacheValue->value = newEntry.release(); | 201 cacheValue->value = newEntry.release(); |
202 } | 202 } |
203 | 203 |
204 return style.release(); | 204 return style; |
205 } | 205 } |
206 | 206 |
207 } // namespace blink | 207 } // namespace blink |
OLD | NEW |