| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void MatchedPropertiesCache::ClearViewportDependent() { | 110 void MatchedPropertiesCache::ClearViewportDependent() { |
| 111 Vector<unsigned, 16> to_remove; | 111 Vector<unsigned, 16> to_remove; |
| 112 for (const auto& cache_entry : cache_) { | 112 for (const auto& cache_entry : cache_) { |
| 113 CachedMatchedProperties* cache_item = cache_entry.value.Get(); | 113 CachedMatchedProperties* cache_item = cache_entry.value.Get(); |
| 114 if (cache_item->computed_style->HasViewportUnits()) | 114 if (cache_item->computed_style->HasViewportUnits()) |
| 115 to_remove.push_back(cache_entry.key); | 115 to_remove.push_back(cache_entry.key); |
| 116 } | 116 } |
| 117 cache_.RemoveAll(to_remove); | 117 cache_.RemoveAll(to_remove); |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool MatchedPropertiesCache::IsStyleCacheable(const ComputedStyle& style) { |
| 121 // unique() styles are not cacheable. |
| 122 if (style.Unique()) |
| 123 return false; |
| 124 if (style.Zoom() != ComputedStyle::InitialZoom()) |
| 125 return false; |
| 126 if (style.GetWritingMode() != ComputedStyle::InitialWritingMode() || |
| 127 style.Direction() != ComputedStyle::InitialDirection()) |
| 128 return false; |
| 129 // styles with non inherited properties that reference variables are not |
| 130 // cacheable. |
| 131 if (style.HasVariableReferenceFromNonInheritedProperty()) |
| 132 return false; |
| 133 return true; |
| 134 } |
| 135 |
| 120 bool MatchedPropertiesCache::IsCacheable(const StyleResolverState& state) { | 136 bool MatchedPropertiesCache::IsCacheable(const StyleResolverState& state) { |
| 121 const ComputedStyle& style = *state.Style(); | 137 const ComputedStyle& style = *state.Style(); |
| 122 const ComputedStyle& parent_style = *state.ParentStyle(); | 138 const ComputedStyle& parent_style = *state.ParentStyle(); |
| 123 | 139 |
| 124 if (style.Unique() || | 140 if (!IsStyleCacheable(style)) |
| 125 (style.StyleType() != kPseudoIdNone && parent_style.Unique())) | |
| 126 return false; | 141 return false; |
| 127 if (style.Zoom() != ComputedStyle::InitialZoom()) | 142 if (style.StyleType() != kPseudoIdNone && parent_style.Unique()) |
| 128 return false; | |
| 129 if (style.GetWritingMode() != ComputedStyle::InitialWritingMode() || | |
| 130 style.Direction() != ComputedStyle::InitialDirection()) | |
| 131 return false; | 143 return false; |
| 132 // The cache assumes static knowledge about which properties are inherited. | 144 // The cache assumes static knowledge about which properties are inherited. |
| 133 // Without a flat tree parent, StyleBuilder::ApplyProperty will not | 145 // Without a flat tree parent, StyleBuilder::ApplyProperty will not |
| 134 // SetHasExplicitlyInheritedProperties on the parent style. | 146 // SetHasExplicitlyInheritedProperties on the parent style. |
| 135 if (!state.ParentNode() || parent_style.HasExplicitlyInheritedProperties()) | 147 if (!state.ParentNode() || parent_style.HasExplicitlyInheritedProperties()) |
| 136 return false; | 148 return false; |
| 137 if (style.HasVariableReferenceFromNonInheritedProperty()) | |
| 138 return false; | |
| 139 return true; | 149 return true; |
| 140 } | 150 } |
| 141 | 151 |
| 142 DEFINE_TRACE(MatchedPropertiesCache) { | 152 DEFINE_TRACE(MatchedPropertiesCache) { |
| 143 visitor->Trace(cache_); | 153 visitor->Trace(cache_); |
| 144 } | 154 } |
| 145 | 155 |
| 146 } // namespace blink | 156 } // namespace blink |
| OLD | NEW |