Changeset 105999 in webkit
- Timestamp:
- Jan 26, 2012 6:56:34 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r105997 r105999 1 2012-01-23 Andreas Kling <awesomekling@apple.com> 2 3 Make elements that don't have attributes smaller. 4 <http://webkit.org/b/76876> 5 6 Reviewed by Antti Koivisto. 7 8 Move the inline style declaration from StyledElement to NamedNodeMap, since having 9 an inline style declaration also implies having a style attribute on the element. 10 This saves one CPU word per element that has no attributes. 11 12 This reduces memory consumption by 412 kB (on 64-bit) when viewing the full 13 HTML5 spec at <http://whatwg.org/c>. 14 15 * dom/NamedNodeMap.cpp: 16 (WebCore::NamedNodeMap::ensureInlineStyleDecl): 17 (WebCore::NamedNodeMap::destroyInlineStyleDecl): 18 (WebCore::NamedNodeMap::createInlineStyleDecl): 19 * dom/NamedNodeMap.h: 20 (WebCore::NamedNodeMap::inlineStyleDecl): 21 * dom/StyledElement.cpp: 22 (WebCore::StyledElement::updateStyleAttribute): 23 (WebCore::StyledElement::addSubresourceAttributeURLs): 24 * dom/StyledElement.h: 25 (WebCore::StyledElement::inlineStyleDecl): 26 (WebCore::StyledElement::ensureInlineStyleDecl): 27 (WebCore::StyledElement::destroyInlineStyleDecl): 28 1 29 2012-01-26 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> 2 30 -
trunk/Source/WebCore/dom/NamedNodeMap.cpp
r105773 r105999 28 28 #include "Attr.h" 29 29 #include "Document.h" 30 #include "Element.h"31 30 #include "ExceptionCode.h" 32 31 #include "HTMLNames.h" 32 #include "StyledElement.h" 33 33 34 34 namespace WebCore { … … 331 331 } 332 332 333 CSSMutableStyleDeclaration* NamedNodeMap::ensureInlineStyleDecl() 334 { 335 if (!m_inlineStyleDecl) 336 createInlineStyleDecl(); 337 return m_inlineStyleDecl.get(); 338 } 339 340 void NamedNodeMap::destroyInlineStyleDecl() 341 { 342 if (!m_inlineStyleDecl) 343 return; 344 m_inlineStyleDecl->clearParentElement(); 345 m_inlineStyleDecl = 0; 346 } 347 348 void NamedNodeMap::createInlineStyleDecl() 349 { 350 ASSERT(!m_inlineStyleDecl); 351 ASSERT(m_element->isStyledElement()); 352 m_inlineStyleDecl = CSSMutableStyleDeclaration::createInline(static_cast<StyledElement*>(m_element)); 353 m_inlineStyleDecl->setStrictParsing(m_element->isHTMLElement() && !m_element->document()->inQuirksMode()); 354 } 355 333 356 } // namespace WebCore -
trunk/Source/WebCore/dom/NamedNodeMap.h
r105773 r105999 102 102 103 103 size_t mappedAttributeCount() const; 104 105 CSSMutableStyleDeclaration* inlineStyleDecl() const { return m_inlineStyleDecl.get(); } 106 CSSMutableStyleDeclaration* ensureInlineStyleDecl(); 107 void destroyInlineStyleDecl(); 104 108 105 109 private: … … 117 121 void clearAttributes(); 118 122 void replaceAttribute(size_t index, PassRefPtr<Attribute>); 119 123 void createInlineStyleDecl(); 124 125 // FIXME: NamedNodeMap should be broken up into two classes, one containing data 126 // for elements with attributes, and one for exposure to the DOM. 127 // See <http://webkit.org/b/75069> for more information. 120 128 SpaceSplitString m_classNames; 121 129 Element* m_element; 122 130 Vector<RefPtr<Attribute>, 4> m_attributes; 123 131 AtomicString m_idForStyleResolution; 132 RefPtr<CSSMutableStyleDeclaration> m_inlineStyleDecl; 124 133 }; 125 134 -
trunk/Source/WebCore/dom/StyledElement.cpp
r105773 r105999 113 113 setIsStyleAttributeValid(); 114 114 setIsSynchronizingStyleAttribute(); 115 if ( m_inlineStyleDecl)116 const_cast<StyledElement*>(this)->setAttribute(styleAttr, m_inlineStyleDecl->cssText());115 if (CSSMutableStyleDeclaration* inlineStyle = inlineStyleDecl()) 116 const_cast<StyledElement*>(this)->setAttribute(styleAttr, inlineStyle->cssText()); 117 117 clearIsSynchronizingStyleAttribute(); 118 118 } … … 126 126 { 127 127 return Attribute::createMapped(name, value); 128 }129 130 void StyledElement::createInlineStyleDecl()131 {132 ASSERT(!m_inlineStyleDecl);133 m_inlineStyleDecl = CSSMutableStyleDeclaration::createInline(this);134 m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inQuirksMode());135 }136 137 void StyledElement::destroyInlineStyleDecl()138 {139 if (!m_inlineStyleDecl)140 return;141 m_inlineStyleDecl->clearParentElement();142 m_inlineStyleDecl = 0;143 128 } 144 129 … … 239 224 setNeedsStyleRecalc(); 240 225 } 241 }242 243 CSSMutableStyleDeclaration* StyledElement::ensureInlineStyleDecl()244 {245 if (!m_inlineStyleDecl)246 createInlineStyleDecl();247 return m_inlineStyleDecl.get();248 }249 250 CSSStyleDeclaration* StyledElement::style()251 {252 return ensureInlineStyleDecl();253 226 } 254 227 … … 444 417 void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 445 418 { 446 if (!m_inlineStyleDecl) 447 return; 448 m_inlineStyleDecl->addSubresourceStyleURLs(urls); 449 } 450 451 } 419 if (CSSMutableStyleDeclaration* inlineStyle = inlineStyleDecl()) 420 inlineStyle->addSubresourceStyleURLs(urls); 421 } 422 423 } -
trunk/Source/WebCore/dom/StyledElement.h
r105773 r105999 60 60 void invalidateStyleAttribute(); 61 61 62 CSSMutableStyleDeclaration* inlineStyleDecl() const { return m_inlineStyleDecl.get(); }63 CSSMutableStyleDeclaration* ensureInlineStyleDecl() ;64 virtual CSSStyleDeclaration* style() OVERRIDE ;62 CSSMutableStyleDeclaration* inlineStyleDecl() const { return attributeMap() ? attributeMap()->inlineStyleDecl() : 0; } 63 CSSMutableStyleDeclaration* ensureInlineStyleDecl() { return attributes(false)->ensureInlineStyleDecl(); } 64 virtual CSSStyleDeclaration* style() OVERRIDE { return ensureInlineStyleDecl(); } 65 65 66 66 const SpaceSplitString& classNames() const; … … 90 90 void createMappedDecl(Attribute*); 91 91 92 void createInlineStyleDecl();93 void destroyInlineStyleDecl();94 92 virtual void updateStyleAttribute() const; 95 96 RefPtr<CSSMutableStyleDeclaration> m_inlineStyleDecl; 93 void destroyInlineStyleDecl() { if (attributeMap()) attributeMap()->destroyInlineStyleDecl(); } 97 94 }; 98 95
Note: See TracChangeset
for help on using the changeset viewer.