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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return; | 111 return; |
112 presentationAttributeCache().clear(); | 112 presentationAttributeCache().clear(); |
113 } | 113 } |
114 | 114 |
115 unsigned m_hitCount; | 115 unsigned m_hitCount; |
116 Timer<PresentationAttributeCacheCleaner> m_cleanTimer; | 116 Timer<PresentationAttributeCacheCleaner> m_cleanTimer; |
117 }; | 117 }; |
118 | 118 |
119 static bool attributeNameSort(const std::pair<StringImpl*, AtomicString>& p1, | 119 static bool attributeNameSort(const std::pair<StringImpl*, AtomicString>& p1, |
120 const std::pair<StringImpl*, AtomicString>& p2) { | 120 const std::pair<StringImpl*, AtomicString>& p2) { |
121 // Sort based on the attribute name pointers. It doesn't matter what the order
is as long as it is always the same. | 121 // Sort based on the attribute name pointers. It doesn't matter what the order |
| 122 // is as long as it is always the same. |
122 return p1.first < p2.first; | 123 return p1.first < p2.first; |
123 } | 124 } |
124 | 125 |
125 static void makePresentationAttributeCacheKey( | 126 static void makePresentationAttributeCacheKey( |
126 Element& element, | 127 Element& element, |
127 PresentationAttributeCacheKey& result) { | 128 PresentationAttributeCacheKey& result) { |
128 // FIXME: Enable for SVG. | 129 // FIXME: Enable for SVG. |
129 if (!element.isHTMLElement()) | 130 if (!element.isHTMLElement()) |
130 return; | 131 return; |
131 // Interpretation of the size attributes on <input> depends on the type attrib
ute. | 132 // Interpretation of the size attributes on <input> depends on the type |
| 133 // attribute. |
132 if (isHTMLInputElement(element)) | 134 if (isHTMLInputElement(element)) |
133 return; | 135 return; |
134 AttributeCollection attributes = element.attributesWithoutUpdate(); | 136 AttributeCollection attributes = element.attributesWithoutUpdate(); |
135 for (const Attribute& attr : attributes) { | 137 for (const Attribute& attr : attributes) { |
136 if (!element.isPresentationAttribute(attr.name())) | 138 if (!element.isPresentationAttribute(attr.name())) |
137 continue; | 139 continue; |
138 if (!attr.namespaceURI().isNull()) | 140 if (!attr.namespaceURI().isNull()) |
139 return; | 141 return; |
140 // FIXME: Background URL may depend on the base URL and can't be shared. Dis
allow caching. | 142 // FIXME: Background URL may depend on the base URL and can't be shared. |
| 143 // Disallow caching. |
141 if (attr.name() == backgroundAttr) | 144 if (attr.name() == backgroundAttr) |
142 return; | 145 return; |
143 result.attributesAndValues.append( | 146 result.attributesAndValues.append( |
144 std::make_pair(attr.localName().impl(), attr.value())); | 147 std::make_pair(attr.localName().impl(), attr.value())); |
145 } | 148 } |
146 if (result.attributesAndValues.isEmpty()) | 149 if (result.attributesAndValues.isEmpty()) |
147 return; | 150 return; |
148 // Attribute order doesn't matter. Sort for easy equality comparison. | 151 // Attribute order doesn't matter. Sort for easy equality comparison. |
149 std::sort(result.attributesAndValues.begin(), | 152 std::sort(result.attributesAndValues.begin(), |
150 result.attributesAndValues.end(), attributeNameSort); | 153 result.attributesAndValues.end(), attributeNameSort); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 presentationAttributeCache().clear(); | 215 presentationAttributeCache().clear(); |
213 presentationAttributeCache().set(cacheHash, newEntry); | 216 presentationAttributeCache().set(cacheHash, newEntry); |
214 } else { | 217 } else { |
215 cacheValue->value = newEntry; | 218 cacheValue->value = newEntry; |
216 } | 219 } |
217 | 220 |
218 return style; | 221 return style; |
219 } | 222 } |
220 | 223 |
221 } // namespace blink | 224 } // namespace blink |
OLD | NEW |