Changeset 132516 in webkit
- Timestamp:
- Oct 25, 2012, 12:34:56 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r132514 r132516 1 2012-10-25 Antti Koivisto <antti@apple.com> 2 3 Avoid unnecessary style recalcs on id attribute mutation. 4 https://bugs.webkit.org/show_bug.cgi?id=100395 5 6 Reviewed by Andreas Kling. 7 8 There is no need to invalidate element style on id attribute change if neither the old nor the new id were 9 mentioned in any stylesheet. This is similar to the optimization we already have for class attributes. 10 11 Recalculating element style is expensive. It seems id attribute mutation is often used in scripts for purposes other than styling. 12 13 * css/StyleResolver.cpp: 14 (WebCore::StyleResolver::hasSelectorForId): 15 (WebCore): 16 * css/StyleResolver.h: 17 * dom/Element.cpp: 18 (WebCore::makeIdForStyleResolution): 19 (WebCore): 20 (WebCore::Element::attributeChanged): 21 1 22 2012-10-25 Dominic Mazzoni <dmazzoni@google.com> 2 23 -
trunk/Source/WebCore/css/StyleResolver.cpp
r132416 r132516 4241 4241 } 4242 4242 4243 bool StyleResolver::hasSelectorForId(const AtomicString& idValue) const 4244 { 4245 if (idValue.isEmpty()) 4246 return false; 4247 return m_features.idsInRules.contains(idValue.impl()); 4248 } 4249 4243 4250 void StyleResolver::addViewportDependentMediaQueryResult(const MediaQueryExp* expr, bool result) 4244 4251 { -
trunk/Source/WebCore/css/StyleResolver.h
r132403 r132516 219 219 Color colorFromPrimitiveValue(CSSPrimitiveValue*, bool forVisitedLink = false) const; 220 220 221 bool hasSelectorForId(const AtomicString&) const; 221 222 bool hasSelectorForAttribute(const AtomicString&) const; 222 223 -
trunk/Source/WebCore/dom/Element.cpp
r132514 r132516 696 696 } 697 697 698 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, bool inQuirksMode) 699 { 700 if (inQuirksMode) 701 return value.lower(); 702 return value; 703 } 704 698 705 void Element::attributeChanged(const QualifiedName& name, const AtomicString& newValue) 699 706 { … … 703 710 704 711 if (isIdAttributeName(name)) { 705 if (newValue != attributeData()->idForStyleResolution()) { 706 if (newValue.isNull()) 707 attributeData()->setIdForStyleResolution(nullAtom); 708 else if (document()->inQuirksMode()) 709 attributeData()->setIdForStyleResolution(newValue.lower()); 710 else 711 attributeData()->setIdForStyleResolution(newValue); 712 setNeedsStyleRecalc(); 712 AtomicString oldId = attributeData()->idForStyleResolution(); 713 AtomicString newId = makeIdForStyleResolution(newValue, document()->inQuirksMode()); 714 if (newId != oldId) { 715 attributeData()->setIdForStyleResolution(newId); 716 StyleResolver* styleResolver = document()->styleResolverIfExists(); 717 if (attached() && (!styleResolver || (styleResolver->hasSelectorForId(newId) || styleResolver->hasSelectorForId(oldId)))) 718 setNeedsStyleRecalc(); 713 719 } 714 720 } else if (name == HTMLNames::nameAttr)
Note:
See TracChangeset
for help on using the changeset viewer.