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

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

Issue 298253009: Add iterator object to iterate efficiently over an Element's attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/ElementData.h » ('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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 1234
1235 m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix); 1235 m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
1236 } 1236 }
1237 1237
1238 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace ToLocate) const 1238 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace ToLocate) const
1239 { 1239 {
1240 if (!prefix().isNull() && namespaceURI() == namespaceToLocate) 1240 if (!prefix().isNull() && namespaceURI() == namespaceToLocate)
1241 return prefix(); 1241 return prefix();
1242 1242
1243 if (hasAttributes()) { 1243 if (hasAttributes()) {
1244 unsigned attributeCount = this->attributeCount(); 1244 AttributeIteratorAccessor attributes = attributesIterator();
1245 for (unsigned i = 0; i < attributeCount; ++i) { 1245 AttributeConstIterator end = attributes.end();
1246 const Attribute& attr = attributeItem(i); 1246 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
1247 1247 if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate)
1248 if (attr.prefix() == xmlnsAtom && attr.value() == namespaceToLocate) 1248 return it->localName();
1249 return attr.localName();
1250 } 1249 }
1251 } 1250 }
1252 1251
1253 if (Element* parent = parentElement()) 1252 if (Element* parent = parentElement())
1254 return parent->locateNamespacePrefix(namespaceToLocate); 1253 return parent->locateNamespacePrefix(namespaceToLocate);
1255 1254
1256 return nullAtom; 1255 return nullAtom;
1257 } 1256 }
1258 1257
1259 KURL Element::baseURI() const 1258 KURL Element::baseURI() const
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 } 3005 }
3007 } 3006 }
3008 ASSERT_NOT_REACHED(); 3007 ASSERT_NOT_REACHED();
3009 } 3008 }
3010 3009
3011 void Element::detachAllAttrNodesFromElement() 3010 void Element::detachAllAttrNodesFromElement()
3012 { 3011 {
3013 AttrNodeList* attrNodeList = attrNodeListForElement(this); 3012 AttrNodeList* attrNodeList = attrNodeListForElement(this);
3014 ASSERT(attrNodeList); 3013 ASSERT(attrNodeList);
3015 3014
3016 unsigned attributeCount = this->attributeCount(); 3015 AttributeIteratorAccessor attributes = attributesIterator();
3017 for (unsigned i = 0; i < attributeCount; ++i) { 3016 AttributeConstIterator end = attributes.end();
3018 const Attribute& attribute = attributeItem(i); 3017 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
3019 if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*attrNodeList , attribute.name())) 3018 if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*attrNodeList , it->name()))
3020 attrNode->detachFromElementWithValue(attribute.value()); 3019 attrNode->detachFromElementWithValue(it->value());
3021 } 3020 }
3022 3021
3023 removeAttrNodeListForElement(this); 3022 removeAttrNodeListForElement(this);
3024 } 3023 }
3025 3024
3026 void Element::willRecalcStyle(StyleRecalcChange) 3025 void Element::willRecalcStyle(StyleRecalcChange)
3027 { 3026 {
3028 ASSERT(hasCustomStyleCallbacks()); 3027 ASSERT(hasCustomStyleCallbacks());
3029 } 3028 }
3030 3029
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 if (other.m_elementData->isUnique() 3073 if (other.m_elementData->isUnique()
3075 && !ownerDocumentsHaveDifferentCaseSensitivity 3074 && !ownerDocumentsHaveDifferentCaseSensitivity
3076 && !other.m_elementData->presentationAttributeStyle()) 3075 && !other.m_elementData->presentationAttributeStyle())
3077 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem entData*>(other.m_elementData.get())->makeShareableCopy(); 3076 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem entData*>(other.m_elementData.get())->makeShareableCopy();
3078 3077
3079 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity && !needsURLResolutionForInlineStyle(other, other.document(), document() )) 3078 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity && !needsURLResolutionForInlineStyle(other, other.document(), document() ))
3080 m_elementData = other.m_elementData; 3079 m_elementData = other.m_elementData;
3081 else 3080 else
3082 m_elementData = other.m_elementData->makeUniqueCopy(); 3081 m_elementData = other.m_elementData->makeUniqueCopy();
3083 3082
3084 unsigned length = m_elementData->length(); 3083 AttributeIteratorAccessor attributes = m_elementData->attributesIterator();
3085 for (unsigned i = 0; i < length; ++i) { 3084 AttributeConstIterator end = attributes.end();
3086 const Attribute& attribute = m_elementData->attributeItem(i); 3085 for (AttributeConstIterator it = attributes.begin(); it != end; ++it)
3087 attributeChangedFromParserOrByCloning(attribute.name(), attribute.value( ), ModifiedByCloning); 3086 attributeChangedFromParserOrByCloning(it->name(), it->value(), ModifiedB yCloning);
3088 }
3089 } 3087 }
3090 3088
3091 void Element::cloneDataFromElement(const Element& other) 3089 void Element::cloneDataFromElement(const Element& other)
3092 { 3090 {
3093 cloneAttributesFromElement(other); 3091 cloneAttributesFromElement(other);
3094 copyNonAttributePropertiesFromElement(other); 3092 copyNonAttributePropertiesFromElement(other);
3095 } 3093 }
3096 3094
3097 void Element::createUniqueElementData() 3095 void Element::createUniqueElementData()
3098 { 3096 {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
3325 3323
3326 void Element::trace(Visitor* visitor) 3324 void Element::trace(Visitor* visitor)
3327 { 3325 {
3328 if (hasRareData()) 3326 if (hasRareData())
3329 visitor->trace(elementRareData()); 3327 visitor->trace(elementRareData());
3330 3328
3331 ContainerNode::trace(visitor); 3329 ContainerNode::trace(visitor);
3332 } 3330 }
3333 3331
3334 } // namespace WebCore 3332 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/ElementData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698