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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 static void makePresentationAttributeCacheKey(Element& element, PresentationAttr
ibuteCacheKey& result) | 121 static void makePresentationAttributeCacheKey(Element& element, PresentationAttr
ibuteCacheKey& result) |
122 { | 122 { |
123 // FIXME: Enable for SVG. | 123 // FIXME: Enable for SVG. |
124 if (!element.isHTMLElement()) | 124 if (!element.isHTMLElement()) |
125 return; | 125 return; |
126 // Interpretation of the size attributes on <input> depends on the type attr
ibute. | 126 // Interpretation of the size attributes on <input> depends on the type attr
ibute. |
127 if (isHTMLInputElement(element)) | 127 if (isHTMLInputElement(element)) |
128 return; | 128 return; |
129 AttributeCollection attributes = element.attributesWithoutUpdate(); | 129 AttributeCollection attributes = element.attributesWithoutUpdate(); |
130 AttributeCollection::const_iterator end = attributes.end(); | 130 AttributeCollection::iterator end = attributes.end(); |
131 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { | 131 for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it)
{ |
132 if (!element.isPresentationAttribute(it->name())) | 132 if (!element.isPresentationAttribute(it->name())) |
133 continue; | 133 continue; |
134 if (!it->namespaceURI().isNull()) | 134 if (!it->namespaceURI().isNull()) |
135 return; | 135 return; |
136 // FIXME: Background URL may depend on the base URL and can't be shared.
Disallow caching. | 136 // FIXME: Background URL may depend on the base URL and can't be shared.
Disallow caching. |
137 if (it->name() == backgroundAttr) | 137 if (it->name() == backgroundAttr) |
138 return; | 138 return; |
139 result.attributesAndValues.append(std::make_pair(it->localName().impl(),
it->value())); | 139 result.attributesAndValues.append(std::make_pair(it->localName().impl(),
it->value())); |
140 } | 140 } |
141 if (result.attributesAndValues.isEmpty()) | 141 if (result.attributesAndValues.isEmpty()) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 cacheValue = 0; | 175 cacheValue = 0; |
176 } | 176 } |
177 | 177 |
178 RefPtrWillBeRawPtr<StylePropertySet> style = nullptr; | 178 RefPtrWillBeRawPtr<StylePropertySet> style = nullptr; |
179 if (cacheHash && cacheValue->value) { | 179 if (cacheHash && cacheValue->value) { |
180 style = cacheValue->value->value; | 180 style = cacheValue->value->value; |
181 cacheCleaner.didHitPresentationAttributeCache(); | 181 cacheCleaner.didHitPresentationAttributeCache(); |
182 } else { | 182 } else { |
183 style = MutableStylePropertySet::create(element.isSVGElement() ? SVGAttr
ibuteMode : HTMLAttributeMode); | 183 style = MutableStylePropertySet::create(element.isSVGElement() ? SVGAttr
ibuteMode : HTMLAttributeMode); |
184 AttributeCollection attributes = element.attributesWithoutUpdate(); | 184 AttributeCollection attributes = element.attributesWithoutUpdate(); |
185 AttributeCollection::const_iterator end = attributes.end(); | 185 AttributeCollection::iterator end = attributes.end(); |
186 for (AttributeCollection::const_iterator it = attributes.begin(); it !=
end; ++it) | 186 for (AttributeCollection::iterator it = attributes.begin(); it != end; +
+it) |
187 element.collectStyleForPresentationAttribute(it->name(), it->value()
, toMutableStylePropertySet(style)); | 187 element.collectStyleForPresentationAttribute(it->name(), it->value()
, toMutableStylePropertySet(style)); |
188 } | 188 } |
189 | 189 |
190 if (!cacheHash || cacheValue->value) | 190 if (!cacheHash || cacheValue->value) |
191 return style.release(); | 191 return style.release(); |
192 | 192 |
193 OwnPtrWillBeRawPtr<PresentationAttributeCacheEntry> newEntry = adoptPtrWillB
eNoop(new PresentationAttributeCacheEntry); | 193 OwnPtrWillBeRawPtr<PresentationAttributeCacheEntry> newEntry = adoptPtrWillB
eNoop(new PresentationAttributeCacheEntry); |
194 newEntry->key = cacheKey; | 194 newEntry->key = cacheKey; |
195 newEntry->value = style; | 195 newEntry->value = style; |
196 | 196 |
197 static const unsigned presentationAttributeCacheMaximumSize = 4096; | 197 static const unsigned presentationAttributeCacheMaximumSize = 4096; |
198 if (presentationAttributeCache().size() > presentationAttributeCacheMaximumS
ize) { | 198 if (presentationAttributeCache().size() > presentationAttributeCacheMaximumS
ize) { |
199 // FIXME: Discarding the entire cache when it gets too big is probably b
ad | 199 // FIXME: Discarding the entire cache when it gets too big is probably b
ad |
200 // since it creates a perf "cliff". Perhaps we should use an LRU? | 200 // since it creates a perf "cliff". Perhaps we should use an LRU? |
201 presentationAttributeCache().clear(); | 201 presentationAttributeCache().clear(); |
202 presentationAttributeCache().set(cacheHash, newEntry.release()); | 202 presentationAttributeCache().set(cacheHash, newEntry.release()); |
203 } else { | 203 } else { |
204 cacheValue->value = newEntry.release(); | 204 cacheValue->value = newEntry.release(); |
205 } | 205 } |
206 | 206 |
207 return style.release(); | 207 return style.release(); |
208 } | 208 } |
209 | 209 |
210 } // namespace blink | 210 } // namespace blink |
OLD | NEW |