12012-04-13 Andreas Kling <kling@webkit.org>
2
3 Optimize Element attribute storage for the common case (no Attr objects.)
4 <http://webkit.org/b/83440>
5
6 Reviewed by NOBODY (OOPS!).
7
8 Reduce Attribute to its smallest possible size; a qname/value pair.
9 They are no-longer ref-counted, which allows us to store them in Vectors.
10
11 Refactored the Attr object to go with the new Attribute:
12 Attr now wraps either {element, qname} or {qname, value}. The latter is for
13 the case where a standalone Attr object is instantiated via DOM APIs.
14
15 ElementAttributeData.cpp manages a map of pair<element, qname> => Attr.
16 Each Element (well, ElementAttributeData) keeps track of how many Attr
17 objects are pointing to it. This is so we can avoid hash lookups during
18 common operations in the typical case where you have zero Attrs.
19
20 * CMakeLists.txt:
21 * GNUmakefile.list.am:
22 * Target.pri:
23 * WebCore.gypi:
24 * WebCore.vcproj/WebCore.vcproj:
25 * WebCore.xcodeproj/project.pbxproj:
26 * dom/Attr.cpp:
27 (WebCore::Attr::Attr):
28 (WebCore):
29 (WebCore::Attr::create):
30 (WebCore::Attr::~Attr):
31 (WebCore::Attr::createTextChild):
32 (WebCore::Attr::setPrefix):
33 (WebCore::Attr::setValue):
34 (WebCore::Attr::cloneNode):
35 (WebCore::Attr::childrenChanged):
36 (WebCore::Attr::style):
37 (WebCore::Attr::value):
38 (WebCore::Attr::elementAttribute):
39 (WebCore::Attr::detachFromElementWithValue):
40 (WebCore::Attr::attachToElement):
41 * dom/Attr.h:
42 (WebCore):
43 (Attr):
44 (WebCore::Attr::qualifiedName):
45 (WebCore::Attr::localName):
46 (WebCore::Attr::namespaceURI):
47 (WebCore::Attr::prefix):
48 * dom/Attribute.cpp: Removed.
49 * dom/Attribute.h:
50 (WebCore::Attribute::Attribute):
51 (Attribute):
52 * dom/Document.cpp:
53 (WebCore::Document::importNode):
54 (WebCore::Document::createAttributeNS):
55 * dom/Element.cpp:
56 (WebCore::Element::~Element):
57 (WebCore::Element::takeAttribute):
58 (WebCore):
59 (WebCore::Element::removeAttribute):
60 (WebCore::Element::setAttributeInternal):
61 (WebCore::Element::parserSetAttributes):
62 (WebCore::Element::setAttributeNode):
63 (WebCore::Element::removeAttributeNode):
64 (WebCore::Element::normalizeAttributes):
65 (WebCore::Element::didRemoveAttribute):
66 (WebCore::Element::getAttr):
67 (WebCore::Element::getOrCreateAttr):
68 * dom/Element.h:
69 (Element):
70 (WebCore::Element::getAttributeItemIndex):
71 * dom/ElementAttributeData.cpp:
72 (WebCore):
73 (WebCore::attrMap):
74 (WebCore::ElementAttributeData::getAttr):
75 (WebCore::ElementAttributeData::getOrCreateAttr):
76 (WebCore::ElementAttributeData::setAttr):
77 (WebCore::ElementAttributeData::removeAttr):
78 (WebCore::AttributeVector::removeAttribute):
79 (WebCore::ElementAttributeData::~ElementAttributeData):
80 (WebCore::ElementAttributeData::addAttribute):
81 (WebCore::ElementAttributeData::removeAttribute):
82 (WebCore::ElementAttributeData::isEquivalent):
83 (WebCore::ElementAttributeData::detachAttributesFromElement):
84 (WebCore::ElementAttributeData::getAttributeItemIndexSlowCase):
85 (WebCore::ElementAttributeData::setAttributes):
86 (WebCore::ElementAttributeData::clearAttributes):
87 (WebCore::ElementAttributeData::replaceAttribute):
88 (WebCore::ElementAttributeData::getAttributeNode):
89 * dom/ElementAttributeData.h:
90 (WebCore):
91 (WebCore::AttributeVector::AttributeVector):
92 (WebCore::AttributeVector::attributeItem):
93 (AttributeVector):
94 (WebCore::AttributeVector::getAttributeItem):
95 (WebCore::AttributeVector::getAttributeItemIndex):
96 (WebCore::AttributeVector::insertAttribute):
97 (ElementAttributeData):
98 (WebCore::ElementAttributeData::hasAttrs):
99 (WebCore::ElementAttributeData::didAddAttr):
100 (WebCore::ElementAttributeData::didRemoveAttr):
101 (WebCore::ElementAttributeData::ElementAttributeData):
102 (WebCore::ElementAttributeData::attributeVector):
103 (WebCore::ElementAttributeData::removeAttribute):
104 (WebCore::ElementAttributeData::getAttributeItem):
105 (WebCore::ElementAttributeData::getAttributeItemIndex):
106 * dom/NamedNodeMap.cpp:
107 (WebCore::NamedNodeMap::getNamedItem):
108 (WebCore::NamedNodeMap::getNamedItemNS):
109 (WebCore::NamedNodeMap::removeNamedItem):
110 (WebCore::NamedNodeMap::removeNamedItemNS):
111 (WebCore::NamedNodeMap::item):
112 * dom/Node.cpp:
113 (WebCore::Node::compareDocumentPosition):
114 * html/parser/HTMLConstructionSite.cpp:
115 (WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML):
116 (WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
117 (WebCore::HTMLConstructionSite::insertScriptElement):
118 (WebCore::HTMLConstructionSite::createElement):
119 (WebCore::HTMLConstructionSite::createHTMLElement):
120 (WebCore::HTMLConstructionSite::createHTMLElementFromSavedElement):
121 * html/parser/HTMLToken.h:
122 (WebCore::AtomicHTMLToken::AtomicHTMLToken):
123 * html/parser/HTMLTreeBuilder.cpp:
124 (WebCore::HTMLTreeBuilder::processFakeStartTag):
125 (WebCore::HTMLTreeBuilder::attributesForIsindexInput):
126 (WebCore::HTMLTreeBuilder::processIsindexStartTagForInBody):
127 (WebCore):
128 (WebCore::HTMLTreeBuilder::processStartTagForInBody):
129 * html/parser/HTMLTreeBuilder.h:
130 * html/parser/TextDocumentParser.cpp:
131 (WebCore::TextDocumentParser::insertFakePreElement):
132 * page/PageSerializer.cpp:
133 (WebCore::SerializerMarkupAccumulator::appendCustomAttributes):
134 * svg/SVGFitToViewBox.cpp:
135 * svg/properties/SVGAnimatedPropertySynchronizer.h:
136 * xml/XMLErrors.cpp:
137 (WebCore::createXHTMLParserErrorHeader):
138 (WebCore::XMLErrors::insertErrorMessageBlock):
139 * xml/XPathNodeSet.cpp:
140 (WebCore::XPath::NodeSet::traversalSort):
141 * xml/XPathStep.cpp:
142 (WebCore::XPath::Step::nodesInAxis):
143 * xml/parser/MarkupTokenBase.h:
144 (WebCore::AtomicMarkupTokenBase::AtomicMarkupTokenBase):
145 (WebCore::AtomicMarkupTokenBase::getAttributeItem):
146 (WebCore::AtomicMarkupTokenBase::attributes):
147 (AtomicMarkupTokenBase):
148 (WebCore::::initializeAttributes):
149 * xml/parser/XMLToken.h:
150 (WebCore::AtomicXMLToken::AtomicXMLToken):
151 * xml/parser/XMLTreeBuilder.cpp:
152 (WebCore::XMLTreeBuilder::processNamespaces):
153 (WebCore::XMLTreeBuilder::processAttributes):
154
1552012-04-13 Andreas Kling <kling@webkit.org>
156
157 Optimize Element attribute storage for the common case (no Attr objects.)
158 <http://webkit.org/b/83440>
159
160 Reviewed by NOBODY (OOPS!).
161
162 Reduce Attribute to its smallest possible size; a qname/value pair.
163 They are no-longer ref-counted, which allows us to store them in Vectors.
164
165 Refactored the Attr object to go with the new Attribute:
166 Attr now wraps either {element, qname} or {qname, value}. The latter is for
167 the case where a standalone Attr object is instantiated via DOM APIs.
168
169 ElementAttributeData.cpp manages a map of pair<element, qname> => Attr.
170 Each Element (well, ElementAttributeData) keeps track of how many Attr
171 objects are pointing to it. This is so we can avoid hash lookups during
172 common operations in the typical case where you have zero Attrs.
173
174 * CMakeLists.txt:
175 * GNUmakefile.list.am:
176 * Target.pri:
177 * WebCore.gypi:
178 * WebCore.vcproj/WebCore.vcproj:
179 * WebCore.xcodeproj/project.pbxproj:
180 * dom/Attr.cpp:
181 (WebCore::Attr::Attr):
182 (WebCore):
183 (WebCore::Attr::create):
184 (WebCore::Attr::~Attr):
185 (WebCore::Attr::createTextChild):
186 (WebCore::Attr::setPrefix):
187 (WebCore::Attr::setValue):
188 (WebCore::Attr::cloneNode):
189 (WebCore::Attr::childrenChanged):
190 (WebCore::Attr::style):
191 (WebCore::Attr::value):
192 (WebCore::Attr::elementAttribute):
193 (WebCore::Attr::detachWithValue):
194 (WebCore::Attr::attachToElement):
195 * dom/Attr.h:
196 (WebCore):
197 (Attr):
198 (WebCore::Attr::qualifiedName):
199 (WebCore::Attr::localName):
200 (WebCore::Attr::namespaceURI):
201 (WebCore::Attr::prefix):
202 * dom/Attribute.cpp: Removed.
203 * dom/Attribute.h:
204 (WebCore::Attribute::Attribute):
205 (Attribute):
206 * dom/Document.cpp:
207 (WebCore::Document::importNode):
208 (WebCore::Document::createAttributeNS):
209 * dom/Element.cpp:
210 (WebCore::Element::~Element):
211 (WebCore::Element::takeAttribute):
212 (WebCore):
213 (WebCore::Element::removeAttribute):
214 (WebCore::Element::setAttributeInternal):
215 (WebCore::Element::parserSetAttributes):
216 (WebCore::Element::setAttributeNode):
217 (WebCore::Element::removeAttributeNode):
218 (WebCore::Element::normalizeAttributes):
219 (WebCore::Element::didRemoveAttribute):
220 (WebCore::Element::getAttr):
221 (WebCore::Element::getOrCreateAttr):
222 * dom/Element.h:
223 (Element):
224 (WebCore::Element::getAttributeItemIndex):
225 * dom/ElementAttributeData.cpp:
226 (WebCore):
227 (WebCore::attrMap):
228 (WebCore::ElementAttributeData::getAttr):
229 (WebCore::ElementAttributeData::getOrCreateAttr):
230 (WebCore::ElementAttributeData::setAttr):
231 (WebCore::ElementAttributeData::removeAttr):
232 (WebCore::AttributeVector::removeAttribute):
233 (WebCore::ElementAttributeData::~ElementAttributeData):
234 (WebCore::ElementAttributeData::addAttribute):
235 (WebCore::ElementAttributeData::removeAttribute):
236 (WebCore::ElementAttributeData::isEquivalent):
237 (WebCore::ElementAttributeData::detachAttributesFromElement):
238 (WebCore::ElementAttributeData::getAttributeItemIndexSlowCase):
239 (WebCore::ElementAttributeData::setAttributes):
240 (WebCore::ElementAttributeData::clearAttributes):
241 (WebCore::ElementAttributeData::replaceAttribute):
242 (WebCore::ElementAttributeData::getAttributeNode):
243 * dom/ElementAttributeData.h:
244 (WebCore):
245 (WebCore::AttributeVector::AttributeVector):
246 (WebCore::AttributeVector::attributeItem):
247 (AttributeVector):
248 (WebCore::AttributeVector::getAttributeItem):
249 (WebCore::AttributeVector::getAttributeItemIndex):
250 (WebCore::AttributeVector::insertAttribute):
251 (ElementAttributeData):
252 (WebCore::ElementAttributeData::hasAttrs):
253 (WebCore::ElementAttributeData::didAddAttr):
254 (WebCore::ElementAttributeData::didRemoveAttr):
255 (WebCore::ElementAttributeData::ElementAttributeData):
256 (WebCore::ElementAttributeData::attributeVector):
257 (WebCore::ElementAttributeData::removeAttribute):
258 (WebCore::ElementAttributeData::getAttributeItem):
259 (WebCore::ElementAttributeData::getAttributeItemIndex):
260 * dom/NamedNodeMap.cpp:
261 (WebCore::NamedNodeMap::getNamedItem):
262 (WebCore::NamedNodeMap::getNamedItemNS):
263 (WebCore::NamedNodeMap::removeNamedItem):
264 (WebCore::NamedNodeMap::removeNamedItemNS):
265 (WebCore::NamedNodeMap::item):
266 * dom/Node.cpp:
267 (WebCore::Node::compareDocumentPosition):
268 * html/parser/HTMLConstructionSite.cpp:
269 (WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML):
270 (WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
271 (WebCore::HTMLConstructionSite::insertScriptElement):
272 (WebCore::HTMLConstructionSite::createElement):
273 (WebCore::HTMLConstructionSite::createHTMLElement):
274 (WebCore::HTMLConstructionSite::createHTMLElementFromSavedElement):
275 * html/parser/HTMLToken.h:
276 (WebCore::AtomicHTMLToken::AtomicHTMLToken):
277 * html/parser/HTMLTreeBuilder.cpp:
278 (WebCore::HTMLTreeBuilder::processFakeStartTag):
279 (WebCore::HTMLTreeBuilder::attributesForIsindexInput):
280 (WebCore::HTMLTreeBuilder::processIsindexStartTagForInBody):
281 (WebCore):
282 (WebCore::HTMLTreeBuilder::processStartTagForInBody):
283 * html/parser/HTMLTreeBuilder.h:
284 * html/parser/TextDocumentParser.cpp:
285 (WebCore::TextDocumentParser::insertFakePreElement):
286 * page/PageSerializer.cpp:
287 (WebCore::SerializerMarkupAccumulator::appendCustomAttributes):
288 * svg/SVGFitToViewBox.cpp:
289 * svg/properties/SVGAnimatedPropertySynchronizer.h:
290 * xml/XMLErrors.cpp:
291 (WebCore::createXHTMLParserErrorHeader):
292 (WebCore::XMLErrors::insertErrorMessageBlock):
293 * xml/XPathNodeSet.cpp:
294 (WebCore::XPath::NodeSet::traversalSort):
295 * xml/XPathStep.cpp:
296 (WebCore::XPath::Step::nodesInAxis):
297 * xml/parser/MarkupTokenBase.h:
298 (WebCore::AtomicMarkupTokenBase::AtomicMarkupTokenBase):
299 (WebCore::AtomicMarkupTokenBase::getAttributeItem):
300 (WebCore::AtomicMarkupTokenBase::attributes):
301 (AtomicMarkupTokenBase):
302 (WebCore::::initializeAttributes):
303 * xml/parser/XMLToken.h:
304 (WebCore::AtomicXMLToken::AtomicXMLToken):
305 * xml/parser/XMLTreeBuilder.cpp:
306 (WebCore::XMLTreeBuilder::processNamespaces):
307 (WebCore::XMLTreeBuilder::processAttributes):
308