Changeset 229332 in webkit
- Timestamp:
- Mar 6, 2018, 11:41:35 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
css/DocumentRuleSets.cpp (modified) (2 diffs)
-
css/DocumentRuleSets.h (modified) (2 diffs)
-
dom/StyledElement.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r229328 r229332 1 2018-03-06 Antti Koivisto <antti@apple.com> 2 3 Cache hasComplexSelectorsForStyleAttribute bit 4 https://bugs.webkit.org/show_bug.cgi?id=183363 5 6 Reviewed by Andreas Kling. 7 8 * css/DocumentRuleSets.cpp: 9 (WebCore::DocumentRuleSets::collectFeatures const): 10 (WebCore::DocumentRuleSets::hasComplexSelectorsForStyleAttribute const): 11 12 Cache the bit to avoid hash lookups. 13 14 * css/DocumentRuleSets.h: 15 * dom/StyledElement.cpp: 16 (WebCore::StyledElement::invalidateStyleAttribute): 17 (WebCore::shouldSynchronizeStyleAttributeImmediatelyForInvalidation): Deleted. 18 19 Move code to DocumentRuleSets. 20 1 21 2018-03-06 Myles C. Maxfield <mmaxfield@apple.com> 2 22 -
trunk/Source/WebCore/css/DocumentRuleSets.cpp
r228313 r229332 170 170 m_classInvalidationRuleSets.clear(); 171 171 m_attributeInvalidationRuleSets.clear(); 172 m_cachedHasComplexSelectorsForStyleAttribute = std::nullopt; 172 173 173 174 m_features.shrinkToFit(); … … 211 212 } 212 213 214 bool DocumentRuleSets::hasComplexSelectorsForStyleAttribute() const 215 { 216 auto compute = [&] { 217 auto* ruleSets = attributeInvalidationRuleSets(HTMLNames::styleAttr->localName()); 218 if (!ruleSets) 219 return false; 220 for (auto& ruleSet : *ruleSets) { 221 if (ruleSet.matchElement != MatchElement::Subject) 222 return true; 223 } 224 return false; 225 }; 226 227 if (!m_cachedHasComplexSelectorsForStyleAttribute) 228 m_cachedHasComplexSelectorsForStyleAttribute = compute(); 229 230 return *m_cachedHasComplexSelectorsForStyleAttribute; 231 } 232 213 233 } // namespace WebCore -
trunk/Source/WebCore/css/DocumentRuleSets.h
r228285 r229332 63 63 const Vector<InvalidationRuleSet>* attributeInvalidationRuleSets(const AtomicString& attributeName) const; 64 64 65 bool hasComplexSelectorsForStyleAttribute() const; 66 65 67 void setIsForShadowScope() { m_isForShadowScope = true; } 66 68 … … 95 97 mutable HashMap<AtomicString, std::unique_ptr<Vector<InvalidationRuleSet>>> m_classInvalidationRuleSets; 96 98 mutable HashMap<AtomicString, std::unique_ptr<Vector<InvalidationRuleSet>>> m_attributeInvalidationRuleSets; 99 mutable std::optional<bool> m_cachedHasComplexSelectorsForStyleAttribute; 97 100 }; 98 101 -
trunk/Source/WebCore/dom/StyledElement.cpp
r229307 r229332 147 147 } 148 148 149 static bool shouldSynchronizeStyleAttributeImmediatelyForInvalidation(StyledElement& element)150 {151 // In rare case there is a complex attribute selector targeting style attribute (like "[style] ~ div") we need to synchronize immediately.152 auto* ruleSets = element.styleResolver().ruleSets().attributeInvalidationRuleSets(styleAttr->localName());153 if (!ruleSets)154 return false;155 for (auto& ruleSet : *ruleSets) {156 if (ruleSet.matchElement != MatchElement::Subject)157 return true;158 }159 return false;160 }161 162 149 void StyledElement::invalidateStyleAttribute() 163 150 { … … 168 155 invalidateStyle(); 169 156 170 if (shouldSynchronizeStyleAttributeImmediatelyForInvalidation(*this)) { 157 // In the rare case of selectors like "[style] ~ div" we need to synchronize immediately to invalidate. 158 if (styleResolver().ruleSets().hasComplexSelectorsForStyleAttribute()) { 171 159 if (auto* inlineStyle = this->inlineStyle()) { 172 160 elementData()->setStyleAttributeIsDirty(false);
Note:
See TracChangeset
for help on using the changeset viewer.