Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 337753005: Make iterator for Element's attributes more lightweight (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Proper rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 void Element::setBooleanAttribute(const QualifiedName& name, bool value) 312 void Element::setBooleanAttribute(const QualifiedName& name, bool value)
313 { 313 {
314 if (value) 314 if (value)
315 setAttribute(name, emptyAtom); 315 setAttribute(name, emptyAtom);
316 else 316 else
317 removeAttribute(name); 317 removeAttribute(name);
318 } 318 }
319 319
320 NamedNodeMap* Element::attributes() const 320 NamedNodeMap* Element::attributesForBindings() const
321 { 321 {
322 ElementRareData& rareData = const_cast<Element*>(this)->ensureElementRareDat a(); 322 ElementRareData& rareData = const_cast<Element*>(this)->ensureElementRareDat a();
323 if (NamedNodeMap* attributeMap = rareData.attributeMap()) 323 if (NamedNodeMap* attributeMap = rareData.attributeMap())
324 return attributeMap; 324 return attributeMap;
325 325
326 rareData.setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this))); 326 rareData.setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this)));
327 return rareData.attributeMap(); 327 return rareData.attributeMap();
328 } 328 }
329 329
330 ActiveAnimations* Element::activeAnimations() const 330 ActiveAnimations* Element::activeAnimations() const
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 1204
1205 m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix); 1205 m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
1206 } 1206 }
1207 1207
1208 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace ToLocate) const 1208 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace ToLocate) const
1209 { 1209 {
1210 if (!prefix().isNull() && namespaceURI() == namespaceToLocate) 1210 if (!prefix().isNull() && namespaceURI() == namespaceToLocate)
1211 return prefix(); 1211 return prefix();
1212 1212
1213 if (hasAttributes()) { 1213 if (hasAttributes()) {
1214 AttributeIteratorAccessor attributes = attributesIterator(); 1214 AttributeCollection attributes = this->attributes();
1215 AttributeConstIterator end = attributes.end(); 1215 AttributeCollection::const_iterator end = attributes.end();
1216 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 1216 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
1217 if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate) 1217 if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate)
1218 return it->localName(); 1218 return it->localName();
1219 } 1219 }
1220 } 1220 }
1221 1221
1222 if (Element* parent = parentElement()) 1222 if (Element* parent = parentElement())
1223 return parent->locateNamespacePrefix(namespaceToLocate); 1223 return parent->locateNamespacePrefix(namespaceToLocate);
1224 1224
1225 return nullAtom; 1225 return nullAtom;
1226 } 1226 }
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3000 } 3000 }
3001 } 3001 }
3002 ASSERT_NOT_REACHED(); 3002 ASSERT_NOT_REACHED();
3003 } 3003 }
3004 3004
3005 void Element::detachAllAttrNodesFromElement() 3005 void Element::detachAllAttrNodesFromElement()
3006 { 3006 {
3007 AttrNodeList* list = this->attrNodeList(); 3007 AttrNodeList* list = this->attrNodeList();
3008 ASSERT(list); 3008 ASSERT(list);
3009 3009
3010 AttributeIteratorAccessor attributes = attributesIterator(); 3010 AttributeCollection attributes = this->attributes();
3011 AttributeConstIterator end = attributes.end(); 3011 AttributeCollection::const_iterator end = attributes.end();
3012 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 3012 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
3013 if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*list, it->na me())) 3013 if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*list, it->na me()))
3014 attrNode->detachFromElementWithValue(it->value()); 3014 attrNode->detachFromElementWithValue(it->value());
3015 } 3015 }
3016 3016
3017 removeAttrNodeList(); 3017 removeAttrNodeList();
3018 } 3018 }
3019 3019
3020 void Element::willRecalcStyle(StyleRecalcChange) 3020 void Element::willRecalcStyle(StyleRecalcChange)
3021 { 3021 {
3022 ASSERT(hasCustomStyleCallbacks()); 3022 ASSERT(hasCustomStyleCallbacks());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 if (other.m_elementData->isUnique() 3068 if (other.m_elementData->isUnique()
3069 && !ownerDocumentsHaveDifferentCaseSensitivity 3069 && !ownerDocumentsHaveDifferentCaseSensitivity
3070 && !other.m_elementData->presentationAttributeStyle()) 3070 && !other.m_elementData->presentationAttributeStyle())
3071 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem entData*>(other.m_elementData.get())->makeShareableCopy(); 3071 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem entData*>(other.m_elementData.get())->makeShareableCopy();
3072 3072
3073 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity && !needsURLResolutionForInlineStyle(other, other.document(), document() )) 3073 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity && !needsURLResolutionForInlineStyle(other, other.document(), document() ))
3074 m_elementData = other.m_elementData; 3074 m_elementData = other.m_elementData;
3075 else 3075 else
3076 m_elementData = other.m_elementData->makeUniqueCopy(); 3076 m_elementData = other.m_elementData->makeUniqueCopy();
3077 3077
3078 AttributeIteratorAccessor attributes = m_elementData->attributesIterator(); 3078 AttributeCollection attributes = m_elementData->attributes();
3079 AttributeConstIterator end = attributes.end(); 3079 AttributeCollection::const_iterator end = attributes.end();
3080 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) 3080 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it)
3081 attributeChangedFromParserOrByCloning(it->name(), it->value(), ModifiedB yCloning); 3081 attributeChangedFromParserOrByCloning(it->name(), it->value(), ModifiedB yCloning);
3082 } 3082 }
3083 3083
3084 void Element::cloneDataFromElement(const Element& other) 3084 void Element::cloneDataFromElement(const Element& other)
3085 { 3085 {
3086 cloneAttributesFromElement(other); 3086 cloneAttributesFromElement(other);
3087 copyNonAttributePropertiesFromElement(other); 3087 copyNonAttributePropertiesFromElement(other);
3088 } 3088 }
3089 3089
3090 void Element::createUniqueElementData() 3090 void Element::createUniqueElementData()
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 3316
3317 void Element::trace(Visitor* visitor) 3317 void Element::trace(Visitor* visitor)
3318 { 3318 {
3319 if (hasRareData()) 3319 if (hasRareData())
3320 visitor->trace(elementRareData()); 3320 visitor->trace(elementRareData());
3321 3321
3322 ContainerNode::trace(visitor); 3322 ContainerNode::trace(visitor);
3323 } 3323 }
3324 3324
3325 } // namespace WebCore 3325 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698