Changeset 106863 in webkit
- Timestamp:
- Feb 6, 2012 3:14:11 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106862 r106863 1 2012-02-06 Andreas Kling <awesomekling@apple.com> 2 3 REGRESSION(r106756): 10% performance hit on DOM/Template. 4 <http://webkit.org/b/77831> 5 6 Reviewed by Ryosuke Niwa. 7 8 Let the StylePropertySet used for element attribute style have the element as its parent. 9 This is accomplished by adding an m_parentIsElement bit to StylePropertySet and sharing 10 some of the internal logic with inline styles. 11 12 In the end, this means that CSSParser will now pick up the document's CSSValuePool when 13 parsing properties for attribute styles, which fixes the perf regression from r106756. 14 15 * css/StylePropertySet.cpp: 16 (WebCore::StylePropertySet::StylePropertySet): 17 (WebCore::StylePropertySet::contextStyleSheet): 18 19 Find contextStyleSheet via the parentElement() when there is one. 20 21 (WebCore::StylePropertySet::setNeedsStyleRecalc): 22 23 Always set FullStyleChange for attribute style mutations. We can probably use the 24 same lighter invalidation as inline styles, but that's a topic for another patch. 25 26 * css/StylePropertySet.h: 27 (WebCore::StylePropertySet::createInline): 28 (WebCore::StylePropertySet::createAttributeStyle): 29 (WebCore::StylePropertySet::parentRuleInternal): 30 (WebCore::StylePropertySet::clearParentRule): 31 (StylePropertySet): 32 (WebCore::StylePropertySet::parentElement): 33 (WebCore::StylePropertySet::clearParentElement): 34 35 Added m_parentIsElement bit and update assertions as appropriate to not just 36 cover the inline style case. Added a createAttributeStyle() helper to create 37 a StylePropertySet for use as Element::attributeStyle(). 38 39 * dom/StyledElement.h: 40 * dom/ElementAttributeData.h: 41 * dom/ElementAttributeData.cpp: 42 (WebCore::ElementAttributeData::ensureAttributeStyle): 43 44 Use StylePropertySet::createAttributeStyle(). 45 46 * dom/StyledElement.cpp: 47 (WebCore::StyledElement::removeCSSProperties): 48 (WebCore::StyledElement::addCSSProperty): 49 (WebCore::StyledElement::addCSSImageProperty): 50 51 Remove setNeedsStyleRecalc() calls since that is now handled automatically by 52 StylePropertySet's mutation methods. 53 1 54 2012-02-06 Kentaro Hara <haraken@chromium.org> 2 55 -
trunk/Source/WebCore/css/StylePropertySet.cpp
r106695 r106863 170 170 StylePropertySet::StylePropertySet() 171 171 : m_strictParsing(false) 172 , m_parentIsElement(false) 172 173 , m_isInlineStyleDeclaration(false) 173 174 , m_parent(static_cast<CSSRule*>(0)) … … 177 178 StylePropertySet::StylePropertySet(CSSRule* parentRule) 178 179 : m_strictParsing(!parentRule || parentRule->useStrictParsing()) 180 , m_parentIsElement(false) 179 181 , m_isInlineStyleDeclaration(false) 180 182 , m_parent(parentRule) … … 185 187 : m_properties(properties) 186 188 , m_strictParsing(!parentRule || parentRule->useStrictParsing()) 189 , m_parentIsElement(false) 187 190 , m_isInlineStyleDeclaration(false) 188 191 , m_parent(parentRule) … … 193 196 StylePropertySet::StylePropertySet(CSSRule* parentRule, const CSSProperty* const * properties, int numProperties) 194 197 : m_strictParsing(!parentRule || parentRule->useStrictParsing()) 198 , m_parentIsElement(false) 195 199 , m_isInlineStyleDeclaration(false) 196 200 , m_parent(parentRule) … … 215 219 } 216 220 217 StylePropertySet::StylePropertySet(StyledElement* parentElement )221 StylePropertySet::StylePropertySet(StyledElement* parentElement, bool isInlineStyle) 218 222 : m_strictParsing(false) 219 , m_isInlineStyleDeclaration(true) 223 , m_parentIsElement(true) 224 , m_isInlineStyleDeclaration(isInlineStyle) 220 225 , m_parent(parentElement) 221 { 226 { 222 227 } 223 228 … … 240 245 CSSStyleSheet* StylePropertySet::contextStyleSheet() const 241 246 { 242 if (m_ isInlineStyleDeclaration) {247 if (m_parentIsElement) { 243 248 Document* document = m_parent.element ? m_parent.element->document() : 0; 244 249 return document ? document->elementSheet() : 0; … … 706 711 void StylePropertySet::setNeedsStyleRecalc() 707 712 { 708 if ( isInlineStyleDeclaration()) {713 if (m_parentIsElement) { 709 714 StyledElement* element = parentElement(); 710 715 if (!element) 711 716 return; 717 718 if (!m_isInlineStyleDeclaration) { 719 element->setNeedsStyleRecalc(); 720 return; 721 } 722 712 723 element->setNeedsStyleRecalc(InlineStyleChange); 713 724 element->invalidateStyleAttribute(); -
trunk/Source/WebCore/css/StylePropertySet.h
r106695 r106863 56 56 } 57 57 static PassRefPtr<StylePropertySet> createInline(StyledElement* element) 58 { 59 return adoptRef(new StylePropertySet(element)); 58 { 59 return adoptRef(new StylePropertySet(element, /*isInlineStyle*/ true)); 60 } 61 static PassRefPtr<StylePropertySet> createAttributeStyle(StyledElement* element) 62 { 63 return adoptRef(new StylePropertySet(element, /*isInlineStyle*/ false)); 60 64 } 61 65 … … 110 114 PassRefPtr<StylePropertySet> copyPropertiesInSet(const int* set, unsigned length) const; 111 115 112 CSSRule* parentRuleInternal() const { return m_ isInlineStyleDeclaration? 0 : m_parent.rule; }113 void clearParentRule() { ASSERT(!m_ isInlineStyleDeclaration); m_parent.rule = 0; }114 115 StyledElement* parentElement() const { ASSERT(m_ isInlineStyleDeclaration); return m_parent.element; }116 void clearParentElement() { ASSERT(m_ isInlineStyleDeclaration); m_parent.element = 0; }117 116 CSSRule* parentRuleInternal() const { return m_parentIsElement ? 0 : m_parent.rule; } 117 void clearParentRule() { ASSERT(!m_parentIsElement); m_parent.rule = 0; } 118 119 StyledElement* parentElement() const { ASSERT(m_parentIsElement); return m_parent.element; } 120 void clearParentElement() { ASSERT(m_parentIsElement); m_parent.element = 0; } 121 118 122 CSSStyleSheet* contextStyleSheet() const; 119 123 … … 127 131 StylePropertySet(CSSRule* parentRule, const Vector<CSSProperty>&); 128 132 StylePropertySet(CSSRule* parentRule, const CSSProperty* const *, int numProperties); 129 StylePropertySet(StyledElement* );133 StylePropertySet(StyledElement*, bool isInlineStyle); 130 134 131 135 void setNeedsStyleRecalc(); … … 156 160 157 161 bool m_strictParsing : 1; 162 bool m_parentIsElement : 1; 158 163 bool m_isInlineStyleDeclaration : 1; 159 164 -
trunk/Source/WebCore/dom/ElementAttributeData.cpp
r106819 r106863 54 54 } 55 55 56 StylePropertySet* ElementAttributeData::ensureAttributeStyle( )56 StylePropertySet* ElementAttributeData::ensureAttributeStyle(StyledElement* element) 57 57 { 58 if (!m_attributeStyle) { 59 m_attributeStyle = StylePropertySet::create(); 60 m_attributeStyle->setStrictParsing(false); 61 } 58 if (!m_attributeStyle) 59 m_attributeStyle = StylePropertySet::createAttributeStyle(element); 62 60 return m_attributeStyle.get(); 63 61 } -
trunk/Source/WebCore/dom/ElementAttributeData.h
r106819 r106863 48 48 49 49 StylePropertySet* attributeStyle() const { return m_attributeStyle.get(); } 50 StylePropertySet* ensureAttributeStyle( );50 StylePropertySet* ensureAttributeStyle(StyledElement*); 51 51 52 52 private: -
trunk/Source/WebCore/dom/StyledElement.cpp
r106769 r106863 111 111 return; 112 112 113 setNeedsStyleRecalc(FullStyleChange);114 115 113 ASSERT(id1 != CSSPropertyInvalid); 116 114 style->removeProperty(id1); … … 143 141 if (!ensureAttributeStyle()->setProperty(id, value)) 144 142 removeCSSProperty(id); 145 else146 setNeedsStyleRecalc(FullStyleChange);147 143 } 148 144 … … 150 146 { 151 147 ensureAttributeStyle()->setProperty(id, value); 152 setNeedsStyleRecalc(FullStyleChange);153 148 } 154 149 … … 156 151 { 157 152 ensureAttributeStyle()->setProperty(CSSProperty(id, CSSImageValue::create(url))); 158 setNeedsStyleRecalc(FullStyleChange);159 153 } 160 154 -
trunk/Source/WebCore/dom/StyledElement.h
r106819 r106863 53 53 54 54 StylePropertySet* attributeStyle() const { return attributeData() ? attributeData()->attributeStyle() : 0; } 55 StylePropertySet* ensureAttributeStyle() { return ensureAttributeData()->ensureAttributeStyle( ); }55 StylePropertySet* ensureAttributeStyle() { return ensureAttributeData()->ensureAttributeStyle(this); } 56 56 57 57 const SpaceSplitString& classNames() const;
Note: See TracChangeset
for help on using the changeset viewer.