Changeset 54009 in webkit
- Timestamp:
- Jan 28, 2010 12:27:38 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54008 r54009 1 2010-01-28 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Save additional memory in SVG*Element classes, by introducing SVGElementRareData 6 https://bugs.webkit.org/show_bug.cgi?id=34268 7 8 Introduce SVGElementRareData, to remove the need to store any members in SVGElement/SVGStyledElement. 9 This saves some additional MB for the svg-node-count-vs-scroll.xhtml testcase. 10 11 SVGElementRareData works just like NodeRareData. Unlike ElementRareData, we're not inheriting from 12 NodeRareData in SVG, as we don't need all the rare data stored there, unlike Element. 13 14 * GNUmakefile.am: Add SVGElementRareData.h to build. 15 * WebCore.gypi: Ditto. 16 * WebCore.pro: Ditto. 17 * WebCore.vcproj/WebCore.vcproj: Ditto. 18 * WebCore.xcodeproj/project.pbxproj: Ditto. 19 * dom/Node.cpp: Use Nodes bitfield to keep track wheter a SVGElement has a SVGElementRareData object associated. 20 (WebCore::Node::Node): 21 * dom/Node.h: Add m_hasRareSVGData flag, merged with the existing bitfield, 10 bits remaining now. 22 (WebCore::Node::hasRareSVGData): 23 * svg/SVGAnimateMotionElement.cpp: SVGElement::instancesForElement() now returns a const-reference to the HashMap instead of copying. 24 (WebCore::SVGAnimateMotionElement::applyResultsToTarget): 25 * svg/SVGAnimateTransformElement.cpp: Ditto. 26 (WebCore::SVGAnimateTransformElement::applyResultsToTarget): 27 * svg/SVGAnimationElement.cpp: Ditto. 28 (WebCore::SVGAnimationElement::setTargetAttributeAnimatedValue): 29 * svg/SVGElement.cpp: Move the element instances HashSet and two cursor-related pointers into SVGElementRareData. 30 (WebCore::SVGElement::SVGElement): 31 (WebCore::SVGElement::~SVGElement): 32 (WebCore::SVGElement::rareSVGData): Modelled just like Node::rareData(). 33 (WebCore::SVGElement::ensureRareSVGData): Dito. 34 (WebCore::SVGElement::accessDocumentSVGExtensions): 35 (WebCore::SVGElement::mapInstanceToElement): Route call through SVGElementRareData. 36 (WebCore::SVGElement::removeInstanceMapping): Ditto. 37 (WebCore::SVGElement::instancesForElement): Ditto. 38 (WebCore::SVGElement::setCursorElement): Ditto. 39 (WebCore::SVGElement::setCursorImageValue): Ditto. 40 * svg/SVGElement.h: 41 * svg/SVGElementInstance.cpp: Ditto. 42 (WebCore::SVGElementInstance::invalidateAllInstancesOfElement): 43 * svg/SVGElementRareData.h: Added. Based on NodeRareData - works exactly the same. 44 (WebCore::SVGElementRareData::SVGElementRareData): 45 (WebCore::SVGElementRareData::rareDataMap): 46 (WebCore::SVGElementRareData::rareDataFromMap): 47 (WebCore::SVGElementRareData::elementInstances): 48 (WebCore::SVGElementRareData::instanceUpdatesBlocked): 49 (WebCore::SVGElementRareData::setInstanceUpdatesBlocked): 50 (WebCore::SVGElementRareData::cursorElement): 51 (WebCore::SVGElementRareData::setCursorElement): 52 (WebCore::SVGElementRareData::cursorImageValue): 53 (WebCore::SVGElementRareData::setCursorImageValue): 54 * svg/SVGStyledElement.cpp: Move m_instancesUpdatesBlocked into SVGElementRareData. 55 (WebCore::SVGStyledElement::SVGStyledElement): 56 (WebCore::SVGStyledElement::instanceUpdatesBlocked): 57 (WebCore::SVGStyledElement::setInstanceUpdatesBlocked): 58 * svg/SVGStyledElement.h: 59 * svg/SVGUseElement.cpp: Adapt to element instances changes, now passed as const-reference. 60 (WebCore::dumpInstanceTree): 61 1 62 2010-01-28 Aaron Boodman <aa@chromium.org> 2 63 -
trunk/WebCore/GNUmakefile.am
r54003 r54009 3050 3050 WebCore/svg/SVGElementInstanceList.cpp \ 3051 3051 WebCore/svg/SVGElementInstanceList.h \ 3052 WebCore/svg/SVGElementRareData.h \ 3052 3053 WebCore/svg/SVGEllipseElement.cpp \ 3053 3054 WebCore/svg/SVGEllipseElement.h \ -
trunk/WebCore/WebCore.gypi
r54003 r54009 3346 3346 'svg/SVGElementInstanceList.cpp', 3347 3347 'svg/SVGElementInstanceList.h', 3348 'svg/SVGElementRareData.h', 3348 3349 'svg/SVGEllipseElement.cpp', 3349 3350 'svg/SVGEllipseElement.h', -
trunk/WebCore/WebCore.pro
r54003 r54009 1763 1763 svg/SVGElementInstance.h \ 1764 1764 svg/SVGElementInstanceList.h \ 1765 svg/SVGElementRareData.h \ 1765 1766 svg/SVGEllipseElement.h \ 1766 1767 svg/SVGExternalResourcesRequired.h \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r54003 r54009 40838 40838 </File> 40839 40839 <File 40840 RelativePath="..\svg\SVGElementRareData.h" 40841 > 40842 </File> 40843 <File 40840 40844 RelativePath="..\svg\SVGEllipseElement.h" 40841 40845 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r54003 r54009 55 55 0818AEE20EDB86BC00647B66 /* WMLEventHandlingElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0818AEE00EDB86BC00647B66 /* WMLEventHandlingElement.cpp */; }; 56 56 0818AEE30EDB86BC00647B66 /* WMLEventHandlingElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 0818AEE10EDB86BC00647B66 /* WMLEventHandlingElement.h */; }; 57 081AA8DA1111237E002AB06E /* SVGElementRareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 081AA8D91111237E002AB06E /* SVGElementRareData.h */; }; 57 58 081D81310EE0E74D00D73689 /* WMLTimerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 081D812F0EE0E74D00D73689 /* WMLTimerElement.cpp */; }; 58 59 081D81320EE0E74D00D73689 /* WMLTimerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 081D81300EE0E74D00D73689 /* WMLTimerElement.h */; }; … … 5323 5324 0818AEE00EDB86BC00647B66 /* WMLEventHandlingElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLEventHandlingElement.cpp; sourceTree = "<group>"; }; 5324 5325 0818AEE10EDB86BC00647B66 /* WMLEventHandlingElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLEventHandlingElement.h; sourceTree = "<group>"; }; 5326 081AA8D91111237E002AB06E /* SVGElementRareData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGElementRareData.h; sourceTree = "<group>"; }; 5325 5327 081D812F0EE0E74D00D73689 /* WMLTimerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLTimerElement.cpp; sourceTree = "<group>"; }; 5326 5328 081D81300EE0E74D00D73689 /* WMLTimerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLTimerElement.h; sourceTree = "<group>"; }; … … 13857 13859 B22278270D00BF1F0071B782 /* SVGElementInstanceList.h */, 13858 13860 B22278280D00BF1F0071B782 /* SVGElementInstanceList.idl */, 13861 081AA8D91111237E002AB06E /* SVGElementRareData.h */, 13859 13862 B22278290D00BF1F0071B782 /* SVGEllipseElement.cpp */, 13860 13863 B222782A0D00BF1F0071B782 /* SVGEllipseElement.h */, … … 18463 18466 59E842661109E5A2000305AD /* JNIBridgeJSC.h in Headers */, 18464 18467 E1A1470811102B1500EEC0F3 /* ContainerNodeAlgorithms.h in Headers */, 18468 081AA8DA1111237E002AB06E /* SVGElementRareData.h in Headers */, 18465 18469 ); 18466 18470 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/dom/Node.cpp
r53809 r54009 423 423 , m_areSVGAttributesValid(true) 424 424 , m_synchronizingSVGAttributes(false) 425 , m_hasRareSVGData(false) 425 426 #endif 426 427 { -
trunk/WebCore/dom/Node.h
r53809 r54009 572 572 573 573 bool hasRareData() const { return m_hasRareData; } 574 574 #if ENABLE(SVG) 575 bool hasRareSVGData() const { return m_hasRareSVGData; } 576 #endif 577 575 578 NodeRareData* rareData() const; 576 579 NodeRareData* ensureRareData(); … … 636 639 mutable bool m_areSVGAttributesValid : 1; // Element 637 640 mutable bool m_synchronizingSVGAttributes : 1; // SVGElement 638 #endif 639 640 // 11 bits remaining 641 bool m_hasRareSVGData : 1; // SVGElement 642 #endif 643 644 // 10 bits remaining 641 645 }; 642 646 -
trunk/WebCore/svg/SVGAnimateMotionElement.cpp
r43187 r54009 216 216 217 217 // ...except in case where we have additional instances in <use> trees. 218 HashSet<SVGElementInstance*>instances = targetElement->instancesForElement();219 HashSet<SVGElementInstance*>::iterator end = instances.end();220 for (HashSet<SVGElementInstance*>:: iterator it = instances.begin(); it != end; ++it) {218 const HashSet<SVGElementInstance*>& instances = targetElement->instancesForElement(); 219 const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); 220 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { 221 221 SVGElement* shadowTreeElement = (*it)->shadowTreeElement(); 222 222 ASSERT(shadowTreeElement); -
trunk/WebCore/svg/SVGAnimateTransformElement.cpp
r53879 r54009 164 164 165 165 // ...except in case where we have additional instances in <use> trees. 166 HashSet<SVGElementInstance*>instances = targetElement->instancesForElement();166 const HashSet<SVGElementInstance*>& instances = targetElement->instancesForElement(); 167 167 RefPtr<SVGTransformList> transformList = transformListFor(targetElement); 168 HashSet<SVGElementInstance*>::iterator end = instances.end();169 for (HashSet<SVGElementInstance*>:: iterator it = instances.begin(); it != end; ++it) {168 const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); 169 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { 170 170 SVGElement* shadowTreeElement = (*it)->shadowTreeElement(); 171 171 ASSERT(shadowTreeElement); -
trunk/WebCore/svg/SVGAnimationElement.cpp
r53879 r54009 317 317 318 318 // If the target element is used in an <use> instance tree, update that as well. 319 HashSet<SVGElementInstance*>instances = target->instancesForElement();320 HashSet<SVGElementInstance*>::iterator end = instances.end();321 for (HashSet<SVGElementInstance*>:: iterator it = instances.begin(); it != end; ++it) {319 const HashSet<SVGElementInstance*>& instances = target->instancesForElement(); 320 const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); 321 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { 322 322 SVGElement* shadowTreeElement = (*it)->shadowTreeElement(); 323 323 ASSERT(shadowTreeElement); -
trunk/WebCore/svg/SVGElement.cpp
r53879 r54009 40 40 #include "SVGCursorElement.h" 41 41 #include "SVGElementInstance.h" 42 #include "SVGElementRareData.h" 42 43 #include "SVGNames.h" 43 44 #include "SVGResource.h" … … 54 55 SVGElement::SVGElement(const QualifiedName& tagName, Document* document) 55 56 : StyledElement(tagName, document, CreateElementZeroRefCount) 56 , m_cursorElement(0)57 , m_cursorImageValue(0)58 57 { 59 58 } … … 66 65 SVGElement::~SVGElement() 67 66 { 68 if (m_cursorElement) 69 m_cursorElement->removeClient(this); 70 if (m_cursorImageValue) 71 m_cursorImageValue->removeReferencedElement(this); 67 if (!hasRareSVGData()) 68 ASSERT(!SVGElementRareData::rareDataMap().contains(this)); 69 else { 70 SVGElementRareData::SVGElementRareDataMap& rareDataMap = SVGElementRareData::rareDataMap(); 71 SVGElementRareData::SVGElementRareDataMap::iterator it = rareDataMap.find(this); 72 ASSERT(it != rareDataMap.end()); 73 74 SVGElementRareData* rareData = it->second; 75 if (SVGCursorElement* cursorElement = rareData->cursorElement()) 76 cursorElement->removeClient(this); 77 if (CSSCursorImageValue* cursorImageValue = rareData->cursorImageValue()) 78 cursorImageValue->removeReferencedElement(this); 79 80 delete rareData; 81 rareDataMap.remove(it); 82 } 83 } 84 85 SVGElementRareData* SVGElement::rareSVGData() const 86 { 87 ASSERT(hasRareSVGData()); 88 return SVGElementRareData::rareDataFromMap(this); 89 } 90 91 SVGElementRareData* SVGElement::ensureRareSVGData() 92 { 93 if (hasRareSVGData()) 94 return rareSVGData(); 95 96 ASSERT(!SVGElementRareData::rareDataMap().contains(this)); 97 SVGElementRareData* data = new SVGElementRareData; 98 SVGElementRareData::rareDataMap().set(this, data); 99 m_hasRareSVGData = true; 100 return data; 72 101 } 73 102 … … 117 146 SVGDocumentExtensions* SVGElement::accessDocumentSVGExtensions() const 118 147 { 119 120 148 // This function is provided for use by SVGAnimatedProperty to avoid 121 149 // global inclusion of Document.h in SVG code. … … 126 154 { 127 155 ASSERT(instance); 128 ASSERT(!m_elementInstances.contains(instance)); 129 m_elementInstances.add(instance); 156 157 HashSet<SVGElementInstance*>& instances = ensureRareSVGData()->elementInstances(); 158 ASSERT(!instances.contains(instance)); 159 160 instances.add(instance); 130 161 } 131 162 … … 133 164 { 134 165 ASSERT(instance); 135 ASSERT(m_elementInstances.contains(instance)); 136 m_elementInstances.remove(instance); 137 } 138 139 HashSet<SVGElementInstance*> SVGElement::instancesForElement() const 140 { 141 return m_elementInstances; 166 ASSERT(hasRareSVGData()); 167 168 HashSet<SVGElementInstance*>& instances = rareSVGData()->elementInstances(); 169 ASSERT(instances.contains(instance)); 170 171 instances.remove(instance); 172 } 173 174 const HashSet<SVGElementInstance*>& SVGElement::instancesForElement() const 175 { 176 if (!hasRareSVGData()) { 177 DEFINE_STATIC_LOCAL(HashSet<SVGElementInstance*>, emptyInstances, ()); 178 return emptyInstances; 179 } 180 return rareSVGData()->elementInstances(); 181 } 182 183 void SVGElement::setCursorElement(SVGCursorElement* cursorElement) 184 { 185 ensureRareSVGData()->setCursorElement(cursorElement); 186 } 187 188 void SVGElement::setCursorImageValue(CSSCursorImageValue* cursorImageValue) 189 { 190 ensureRareSVGData()->setCursorImageValue(cursorImageValue); 142 191 } 143 192 -
trunk/WebCore/svg/SVGElement.h
r53879 r54009 33 33 class SVGCursorElement; 34 34 class SVGElementInstance; 35 class SVGElementRareData; 35 36 class SVGSVGElement; 36 37 class TransformationMatrix; … … 74 75 void setSynchronizedSVGAttributes(bool value) { m_areSVGAttributesValid = value; } 75 76 76 HashSet<SVGElementInstance*>instancesForElement() const;77 const HashSet<SVGElementInstance*>& instancesForElement() const; 77 78 78 void setCursorElement(SVGCursorElement* cursorElement) { m_cursorElement = cursorElement; }79 void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; }79 void setCursorElement(SVGCursorElement*); 80 void setCursorImageValue(CSSCursorImageValue*); 80 81 81 82 protected: … … 86 87 virtual void attributeChanged(Attribute*, bool preserveDecls = false); 87 88 virtual void updateAnimatedSVGAttribute(const QualifiedName&) const; 89 90 SVGElementRareData* rareSVGData() const; 91 SVGElementRareData* ensureRareSVGData(); 88 92 89 93 private: … … 100 104 101 105 virtual bool haveLoadedRequiredResources(); 102 103 SVGCursorElement* m_cursorElement;104 CSSCursorImageValue* m_cursorImageValue;105 106 HashSet<SVGElementInstance*> m_elementInstances;107 106 }; 108 107 -
trunk/WebCore/svg/SVGElementInstance.cpp
r53564 r54009 96 96 return; 97 97 98 HashSet<SVGElementInstance*>set = element->instancesForElement();98 const HashSet<SVGElementInstance*>& set = element->instancesForElement(); 99 99 if (set.isEmpty()) 100 100 return; 101 101 102 102 // Mark all use elements referencing 'element' for rebuilding 103 HashSet<SVGElementInstance*>::const_iterator it = set.begin();104 103 const HashSet<SVGElementInstance*>::const_iterator end = set.end(); 105 106 for (; it != end; ++it) { 104 for (HashSet<SVGElementInstance*>::const_iterator it = set.begin(); it != end; ++it) { 107 105 ASSERT((*it)->correspondingElement() == element); 108 106 (*it)->correspondingUseElement()->invalidateShadowTree(); -
trunk/WebCore/svg/SVGStyledElement.cpp
r53879 r54009 35 35 #include "SVGElement.h" 36 36 #include "SVGElementInstance.h" 37 #include "SVGElementRareData.h" 37 38 #include "SVGNames.h" 38 39 #include "SVGRenderStyle.h" … … 56 57 SVGStyledElement::SVGStyledElement(const QualifiedName& tagName, Document* doc) 57 58 : SVGElement(tagName, doc) 58 , m_instanceUpdatesBlocked(false)59 59 { 60 60 } … … 306 306 SVGElement::detach(); 307 307 } 308 308 309 bool SVGStyledElement::instanceUpdatesBlocked() const 310 { 311 return hasRareSVGData() && rareSVGData()->instanceUpdatesBlocked(); 312 } 313 314 void SVGStyledElement::setInstanceUpdatesBlocked(bool value) 315 { 316 if (hasRareSVGData()) 317 rareSVGData()->setInstanceUpdatesBlocked(value); 318 } 319 309 320 } 310 321 -
trunk/WebCore/svg/SVGStyledElement.h
r53879 r54009 66 66 virtual void detach(); 67 67 68 bool instanceUpdatesBlocked() const { return m_instanceUpdatesBlocked; }69 void setInstanceUpdatesBlocked(bool value) { m_instanceUpdatesBlocked = value; }68 bool instanceUpdatesBlocked() const; 69 void setInstanceUpdatesBlocked(bool); 70 70 71 71 protected: … … 74 74 private: 75 75 DECLARE_ANIMATED_PROPERTY(SVGStyledElement, HTMLNames::classAttr, String, ClassName, className) 76 bool m_instanceUpdatesBlocked;77 76 }; 78 77 -
trunk/WebCore/svg/SVGUseElement.cpp
r53879 r54009 356 356 text += " "; 357 357 358 HashSet<SVGElementInstance*>elementInstances = element->instancesForElement();358 const HashSet<SVGElementInstance*>& elementInstances = element->instancesForElement(); 359 359 text += String::format("Corresponding element is associated with %i instance(s):\n", elementInstances.size()); 360 360 361 HashSet<SVGElementInstance*>::iterator end = elementInstances.end();362 for (HashSet<SVGElementInstance*>:: iterator it = elementInstances.begin(); it != end; ++it) {361 const HashSet<SVGElementInstance*>::const_iterator end = elementInstances.end(); 362 for (HashSet<SVGElementInstance*>::const_iterator it = elementInstances.begin(); it != end; ++it) { 363 363 for (unsigned int i = 0; i < depth; ++i) 364 364 text += " ";
Note: See TracChangeset
for help on using the changeset viewer.