| 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. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 computedStyle = nullptr; | 53 computedStyle = nullptr; |
| 54 parentComputedStyle = nullptr; | 54 parentComputedStyle = nullptr; |
| 55 } | 55 } |
| 56 | 56 |
| 57 MatchedPropertiesCache::MatchedPropertiesCache() {} | 57 MatchedPropertiesCache::MatchedPropertiesCache() {} |
| 58 | 58 |
| 59 const CachedMatchedProperties* MatchedPropertiesCache::find( | 59 const CachedMatchedProperties* MatchedPropertiesCache::find( |
| 60 unsigned hash, | 60 unsigned hash, |
| 61 const StyleResolverState& styleResolverState, | 61 const StyleResolverState& styleResolverState, |
| 62 const MatchedPropertiesVector& properties) { | 62 const MatchedPropertiesVector& properties) { |
| 63 ASSERT(hash); | 63 DCHECK(hash); |
| 64 | 64 |
| 65 Cache::iterator it = m_cache.find(hash); | 65 Cache::iterator it = m_cache.find(hash); |
| 66 if (it == m_cache.end()) | 66 if (it == m_cache.end()) |
| 67 return nullptr; | 67 return nullptr; |
| 68 CachedMatchedProperties* cacheItem = it->value.get(); | 68 CachedMatchedProperties* cacheItem = it->value.get(); |
| 69 ASSERT(cacheItem); | 69 DCHECK(cacheItem); |
| 70 | 70 |
| 71 size_t size = properties.size(); | 71 size_t size = properties.size(); |
| 72 if (size != cacheItem->matchedProperties.size()) | 72 if (size != cacheItem->matchedProperties.size()) |
| 73 return nullptr; | 73 return nullptr; |
| 74 if (cacheItem->computedStyle->insideLink() != | 74 if (cacheItem->computedStyle->insideLink() != |
| 75 styleResolverState.style()->insideLink()) | 75 styleResolverState.style()->insideLink()) |
| 76 return nullptr; | 76 return nullptr; |
| 77 for (size_t i = 0; i < size; ++i) { | 77 for (size_t i = 0; i < size; ++i) { |
| 78 if (properties[i] != cacheItem->matchedProperties[i]) | 78 if (properties[i] != cacheItem->matchedProperties[i]) |
| 79 return nullptr; | 79 return nullptr; |
| 80 } | 80 } |
| 81 return cacheItem; | 81 return cacheItem; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void MatchedPropertiesCache::add(const ComputedStyle& style, | 84 void MatchedPropertiesCache::add(const ComputedStyle& style, |
| 85 const ComputedStyle& parentStyle, | 85 const ComputedStyle& parentStyle, |
| 86 unsigned hash, | 86 unsigned hash, |
| 87 const MatchedPropertiesVector& properties) { | 87 const MatchedPropertiesVector& properties) { |
| 88 ASSERT(hash); | 88 DCHECK(hash); |
| 89 Cache::AddResult addResult = m_cache.insert(hash, nullptr); | 89 Cache::AddResult addResult = m_cache.insert(hash, nullptr); |
| 90 if (addResult.isNewEntry) | 90 if (addResult.isNewEntry) |
| 91 addResult.storedValue->value = new CachedMatchedProperties; | 91 addResult.storedValue->value = new CachedMatchedProperties; |
| 92 | 92 |
| 93 CachedMatchedProperties* cacheItem = addResult.storedValue->value.get(); | 93 CachedMatchedProperties* cacheItem = addResult.storedValue->value.get(); |
| 94 if (!addResult.isNewEntry) | 94 if (!addResult.isNewEntry) |
| 95 cacheItem->clear(); | 95 cacheItem->clear(); |
| 96 | 96 |
| 97 cacheItem->set(style, parentStyle, properties); | 97 cacheItem->set(style, parentStyle, properties); |
| 98 } | 98 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 if (style.hasVariableReferenceFromNonInheritedProperty()) | 137 if (style.hasVariableReferenceFromNonInheritedProperty()) |
| 138 return false; | 138 return false; |
| 139 return true; | 139 return true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 DEFINE_TRACE(MatchedPropertiesCache) { | 142 DEFINE_TRACE(MatchedPropertiesCache) { |
| 143 visitor->trace(m_cache); | 143 visitor->trace(m_cache); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace blink | 146 } // namespace blink |
| OLD | NEW |