OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 void MatchedPropertiesCache::clearViewportDependent() | 112 void MatchedPropertiesCache::clearViewportDependent() |
113 { | 113 { |
114 Vector<unsigned, 16> toRemove; | 114 Vector<unsigned, 16> toRemove; |
115 for (Cache::iterator it = m_cache.begin(); it != m_cache.end(); ++it) { | 115 for (Cache::iterator it = m_cache.begin(); it != m_cache.end(); ++it) { |
116 CachedMatchedProperties* cacheItem = it->value.get(); | 116 CachedMatchedProperties* cacheItem = it->value.get(); |
117 if (cacheItem->renderStyle->hasViewportUnits()) | 117 if (cacheItem->renderStyle->hasViewportUnits()) |
118 toRemove.append(it->key); | 118 toRemove.append(it->key); |
119 } | 119 } |
120 for (size_t i = 0; i < toRemove.size(); ++i) | 120 m_cache.removeAll(toRemove); |
121 m_cache.remove(toRemove[i]); | |
122 } | 121 } |
123 | 122 |
124 void MatchedPropertiesCache::sweep(Timer<MatchedPropertiesCache>*) | 123 void MatchedPropertiesCache::sweep(Timer<MatchedPropertiesCache>*) |
125 { | 124 { |
126 // Look for cache entries containing a style declaration with a single ref a
nd remove them. | 125 // Look for cache entries containing a style declaration with a single ref a
nd remove them. |
127 // This may happen when an element attribute mutation causes it to generate
a new inlineStyle() | 126 // This may happen when an element attribute mutation causes it to generate
a new inlineStyle() |
128 // or presentationAttributeStyle(), potentially leaving this cache with the
last ref on the old one. | 127 // or presentationAttributeStyle(), potentially leaving this cache with the
last ref on the old one. |
129 Vector<unsigned, 16> toRemove; | 128 Vector<unsigned, 16> toRemove; |
130 Cache::iterator it = m_cache.begin(); | 129 Cache::iterator it = m_cache.begin(); |
131 Cache::iterator end = m_cache.end(); | 130 Cache::iterator end = m_cache.end(); |
132 for (; it != end; ++it) { | 131 for (; it != end; ++it) { |
133 CachedMatchedProperties* cacheItem = it->value.get(); | 132 CachedMatchedProperties* cacheItem = it->value.get(); |
134 Vector<MatchedProperties>& matchedProperties = cacheItem->matchedPropert
ies; | 133 Vector<MatchedProperties>& matchedProperties = cacheItem->matchedPropert
ies; |
135 for (size_t i = 0; i < matchedProperties.size(); ++i) { | 134 for (size_t i = 0; i < matchedProperties.size(); ++i) { |
136 if (matchedProperties[i].properties->hasOneRef()) { | 135 if (matchedProperties[i].properties->hasOneRef()) { |
137 toRemove.append(it->key); | 136 toRemove.append(it->key); |
138 break; | 137 break; |
139 } | 138 } |
140 } | 139 } |
141 } | 140 } |
142 for (size_t i = 0; i < toRemove.size(); ++i) | 141 m_cache.removeAll(toRemove); |
143 m_cache.remove(toRemove[i]); | |
144 | |
145 m_additionsSinceLastSweep = 0; | 142 m_additionsSinceLastSweep = 0; |
146 } | 143 } |
147 | 144 |
148 bool MatchedPropertiesCache::isCacheable(const Element* element, const RenderSty
le* style, const RenderStyle* parentStyle) | 145 bool MatchedPropertiesCache::isCacheable(const Element* element, const RenderSty
le* style, const RenderStyle* parentStyle) |
149 { | 146 { |
150 // FIXME: CSSPropertyWebkitWritingMode modifies state when applying to docum
ent element. We can't skip the applying by caching. | 147 // FIXME: CSSPropertyWebkitWritingMode modifies state when applying to docum
ent element. We can't skip the applying by caching. |
151 if (element == element->document().documentElement() && element->document().
writingModeSetOnDocumentElement()) | 148 if (element == element->document().documentElement() && element->document().
writingModeSetOnDocumentElement()) |
152 return false; | 149 return false; |
153 if (style->unique() || (style->styleType() != NOPSEUDO && parentStyle->uniqu
e())) | 150 if (style->unique() || (style->styleType() != NOPSEUDO && parentStyle->uniqu
e())) |
154 return false; | 151 return false; |
155 if (style->hasAppearance()) | 152 if (style->hasAppearance()) |
156 return false; | 153 return false; |
157 if (style->zoom() != RenderStyle::initialZoom()) | 154 if (style->zoom() != RenderStyle::initialZoom()) |
158 return false; | 155 return false; |
159 if (style->writingMode() != RenderStyle::initialWritingMode()) | 156 if (style->writingMode() != RenderStyle::initialWritingMode()) |
160 return false; | 157 return false; |
161 if (style->hasCurrentColor()) | 158 if (style->hasCurrentColor()) |
162 return false; | 159 return false; |
163 // CSSPropertyInternalCallback sets the rule's selector name into the Render
Style, and that's not recalculated if the RenderStyle is loaded from the cache,
so don't cache it. | 160 // CSSPropertyInternalCallback sets the rule's selector name into the Render
Style, and that's not recalculated if the RenderStyle is loaded from the cache,
so don't cache it. |
164 if (!style->callbackSelectors().isEmpty()) | 161 if (!style->callbackSelectors().isEmpty()) |
165 return false; | 162 return false; |
166 // The cache assumes static knowledge about which properties are inherited. | 163 // The cache assumes static knowledge about which properties are inherited. |
167 if (parentStyle->hasExplicitlyInheritedProperties()) | 164 if (parentStyle->hasExplicitlyInheritedProperties()) |
168 return false; | 165 return false; |
169 return true; | 166 return true; |
170 } | 167 } |
171 | 168 |
172 } | 169 } |
OLD | NEW |