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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #include "sky/engine/core/css/StylePropertySet.h" | 32 #include "sky/engine/core/css/StylePropertySet.h" |
33 #include "sky/engine/core/css/resolver/StyleResolverState.h" | 33 #include "sky/engine/core/css/resolver/StyleResolverState.h" |
34 #include "sky/engine/core/rendering/style/RenderStyle.h" | 34 #include "sky/engine/core/rendering/style/RenderStyle.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 void CachedMatchedProperties::set(const RenderStyle* style, const RenderStyle* p
arentStyle, const MatchResult& matchResult) | 38 void CachedMatchedProperties::set(const RenderStyle* style, const RenderStyle* p
arentStyle, const MatchResult& matchResult) |
39 { | 39 { |
40 matchedProperties.appendVector(matchResult.matchedProperties); | 40 matchedProperties.appendVector(matchResult.matchedProperties); |
41 ranges = matchResult.ranges; | |
42 | 41 |
43 // Note that we don't cache the original RenderStyle instance. It may be fur
ther modified. | 42 // Note that we don't cache the original RenderStyle instance. It may be fur
ther modified. |
44 // The RenderStyle in the cache is really just a holder for the substructure
s and never used as-is. | 43 // The RenderStyle in the cache is really just a holder for the substructure
s and never used as-is. |
45 this->renderStyle = RenderStyle::clone(style); | 44 this->renderStyle = RenderStyle::clone(style); |
46 this->parentRenderStyle = RenderStyle::clone(parentStyle); | 45 this->parentRenderStyle = RenderStyle::clone(parentStyle); |
47 } | 46 } |
48 | 47 |
49 void CachedMatchedProperties::clear() | 48 void CachedMatchedProperties::clear() |
50 { | 49 { |
51 matchedProperties.clear(); | 50 matchedProperties.clear(); |
(...skipping 17 matching lines...) Expand all Loading... |
69 CachedMatchedProperties* cacheItem = it->value.get(); | 68 CachedMatchedProperties* cacheItem = it->value.get(); |
70 ASSERT(cacheItem); | 69 ASSERT(cacheItem); |
71 | 70 |
72 size_t size = matchResult.matchedProperties.size(); | 71 size_t size = matchResult.matchedProperties.size(); |
73 if (size != cacheItem->matchedProperties.size()) | 72 if (size != cacheItem->matchedProperties.size()) |
74 return 0; | 73 return 0; |
75 for (size_t i = 0; i < size; ++i) { | 74 for (size_t i = 0; i < size; ++i) { |
76 if (matchResult.matchedProperties[i] != cacheItem->matchedProperties[i]) | 75 if (matchResult.matchedProperties[i] != cacheItem->matchedProperties[i]) |
77 return 0; | 76 return 0; |
78 } | 77 } |
79 if (cacheItem->ranges != matchResult.ranges) | |
80 return 0; | |
81 return cacheItem; | 78 return cacheItem; |
82 } | 79 } |
83 | 80 |
84 void MatchedPropertiesCache::add(const RenderStyle* style, const RenderStyle* pa
rentStyle, unsigned hash, const MatchResult& matchResult) | 81 void MatchedPropertiesCache::add(const RenderStyle* style, const RenderStyle* pa
rentStyle, unsigned hash, const MatchResult& matchResult) |
85 { | 82 { |
86 static const unsigned maxAdditionsBetweenSweeps = 100; | 83 static const unsigned maxAdditionsBetweenSweeps = 100; |
87 if (++m_additionsSinceLastSweep >= maxAdditionsBetweenSweeps | 84 if (++m_additionsSinceLastSweep >= maxAdditionsBetweenSweeps |
88 && !m_sweepTimer.isActive()) { | 85 && !m_sweepTimer.isActive()) { |
89 static const unsigned sweepTimeInSeconds = 60; | 86 static const unsigned sweepTimeInSeconds = 60; |
90 m_sweepTimer.startOneShot(sweepTimeInSeconds, FROM_HERE); | 87 m_sweepTimer.startOneShot(sweepTimeInSeconds, FROM_HERE); |
(...skipping 28 matching lines...) Expand all Loading... |
119 } | 116 } |
120 | 117 |
121 void MatchedPropertiesCache::sweep(Timer<MatchedPropertiesCache>*) | 118 void MatchedPropertiesCache::sweep(Timer<MatchedPropertiesCache>*) |
122 { | 119 { |
123 // FIXME(sky): Do we still need this now that we removed PresentationAttribu
teStyle? | 120 // FIXME(sky): Do we still need this now that we removed PresentationAttribu
teStyle? |
124 Vector<unsigned, 16> toRemove; | 121 Vector<unsigned, 16> toRemove; |
125 Cache::iterator it = m_cache.begin(); | 122 Cache::iterator it = m_cache.begin(); |
126 Cache::iterator end = m_cache.end(); | 123 Cache::iterator end = m_cache.end(); |
127 for (; it != end; ++it) { | 124 for (; it != end; ++it) { |
128 CachedMatchedProperties* cacheItem = it->value.get(); | 125 CachedMatchedProperties* cacheItem = it->value.get(); |
129 Vector<MatchedProperties>& matchedProperties = cacheItem->matchedPropert
ies; | 126 Vector<RefPtr<StylePropertySet>>& matchedProperties = cacheItem->matched
Properties; |
130 for (size_t i = 0; i < matchedProperties.size(); ++i) { | 127 for (size_t i = 0; i < matchedProperties.size(); ++i) { |
131 if (matchedProperties[i].properties->hasOneRef()) { | 128 if (matchedProperties[i]->hasOneRef()) { |
132 toRemove.append(it->key); | 129 toRemove.append(it->key); |
133 break; | 130 break; |
134 } | 131 } |
135 } | 132 } |
136 } | 133 } |
137 m_cache.removeAll(toRemove); | 134 m_cache.removeAll(toRemove); |
138 m_additionsSinceLastSweep = 0; | 135 m_additionsSinceLastSweep = 0; |
139 } | 136 } |
140 | 137 |
141 bool MatchedPropertiesCache::isCacheable(const Element* element, const RenderSty
le* style, const RenderStyle* parentStyle) | 138 bool MatchedPropertiesCache::isCacheable(const Element* element, const RenderSty
le* style, const RenderStyle* parentStyle) |
142 { | 139 { |
143 if (style->unique() || (style->styleType() != NOPSEUDO && parentStyle->uniqu
e())) | 140 if (style->unique() || (style->styleType() != NOPSEUDO && parentStyle->uniqu
e())) |
144 return false; | 141 return false; |
145 if (style->hasCurrentColor()) | 142 if (style->hasCurrentColor()) |
146 return false; | 143 return false; |
147 // The cache assumes static knowledge about which properties are inherited. | 144 // The cache assumes static knowledge about which properties are inherited. |
148 if (parentStyle->hasExplicitlyInheritedProperties()) | 145 if (parentStyle->hasExplicitlyInheritedProperties()) |
149 return false; | 146 return false; |
150 return true; | 147 return true; |
151 } | 148 } |
152 | 149 |
153 } | 150 } |
OLD | NEW |