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

Side by Side Diff: Source/core/dom/Node.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/ElementData.cpp ('k') | Source/core/dom/PresentationAttributeStyle.cpp » ('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 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt om : namespaceURIMaybeEmpty; 1320 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt om : namespaceURIMaybeEmpty;
1321 1321
1322 switch (nodeType()) { 1322 switch (nodeType()) {
1323 case ELEMENT_NODE: { 1323 case ELEMENT_NODE: {
1324 const Element& element = toElement(*this); 1324 const Element& element = toElement(*this);
1325 1325
1326 if (element.prefix().isNull()) 1326 if (element.prefix().isNull())
1327 return element.namespaceURI() == namespaceURI; 1327 return element.namespaceURI() == namespaceURI;
1328 1328
1329 if (element.hasAttributes()) { 1329 if (element.hasAttributes()) {
1330 AttributeIteratorAccessor attributes = element.attributesIterato r(); 1330 AttributeCollection attributes = element.attributes();
1331 AttributeConstIterator end = attributes.end(); 1331 AttributeCollection::const_iterator end = attributes.end();
1332 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 1332 for (AttributeCollection::const_iterator it = attributes.begin() ; it != end; ++it) {
1333 if (it->localName() == xmlnsAtom) 1333 if (it->localName() == xmlnsAtom)
1334 return it->value() == namespaceURI; 1334 return it->value() == namespaceURI;
1335 } 1335 }
1336 } 1336 }
1337 1337
1338 if (Element* parent = parentElement()) 1338 if (Element* parent = parentElement())
1339 return parent->isDefaultNamespace(namespaceURI); 1339 return parent->isDefaultNamespace(namespaceURI);
1340 1340
1341 return false; 1341 return false;
1342 } 1342 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 return nullAtom; 1405 return nullAtom;
1406 1406
1407 switch (nodeType()) { 1407 switch (nodeType()) {
1408 case ELEMENT_NODE: { 1408 case ELEMENT_NODE: {
1409 const Element& element = toElement(*this); 1409 const Element& element = toElement(*this);
1410 1410
1411 if (!element.namespaceURI().isNull() && element.prefix() == prefix) 1411 if (!element.namespaceURI().isNull() && element.prefix() == prefix)
1412 return element.namespaceURI(); 1412 return element.namespaceURI();
1413 1413
1414 if (element.hasAttributes()) { 1414 if (element.hasAttributes()) {
1415 AttributeIteratorAccessor attributes = element.attributesIterato r(); 1415 AttributeCollection attributes = element.attributes();
1416 AttributeConstIterator end = attributes.end(); 1416 AttributeCollection::const_iterator end = attributes.end();
1417 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 1417 for (AttributeCollection::const_iterator it = attributes.begin() ; it != end; ++it) {
1418 if (it->prefix() == xmlnsAtom && it->localName() == prefix) { 1418 if (it->prefix() == xmlnsAtom && it->localName() == prefix) {
1419 if (!it->value().isEmpty()) 1419 if (!it->value().isEmpty())
1420 return it->value(); 1420 return it->value();
1421 return nullAtom; 1421 return nullAtom;
1422 } 1422 }
1423 if (it->localName() == xmlnsAtom && prefix.isNull()) { 1423 if (it->localName() == xmlnsAtom && prefix.isNull()) {
1424 if (!it->value().isEmpty()) 1424 if (!it->value().isEmpty())
1425 return it->value(); 1425 return it->value();
1426 return nullAtom; 1426 return nullAtom;
1427 } 1427 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 Vector<const Node*, 16> chain2; 1568 Vector<const Node*, 16> chain2;
1569 if (attr1) 1569 if (attr1)
1570 chain1.append(attr1); 1570 chain1.append(attr1);
1571 if (attr2) 1571 if (attr2)
1572 chain2.append(attr2); 1572 chain2.append(attr2);
1573 1573
1574 if (attr1 && attr2 && start1 == start2 && start1) { 1574 if (attr1 && attr2 && start1 == start2 && start1) {
1575 // We are comparing two attributes on the same node. Crawl our attribute map and see which one we hit first. 1575 // We are comparing two attributes on the same node. Crawl our attribute map and see which one we hit first.
1576 const Element* owner1 = attr1->ownerElement(); 1576 const Element* owner1 = attr1->ownerElement();
1577 owner1->synchronizeAllAttributes(); 1577 owner1->synchronizeAllAttributes();
1578 AttributeIteratorAccessor attributes = owner1->attributesIterator(); 1578 AttributeCollection attributes = owner1->attributes();
1579 AttributeConstIterator end = attributes.end(); 1579 AttributeCollection::const_iterator end = attributes.end();
1580 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 1580 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
1581 // If neither of the two determining nodes is a child node and nodeT ype is the same for both determining nodes, then an 1581 // If neither of the two determining nodes is a child node and nodeT ype is the same for both determining nodes, then an
1582 // implementation-dependent order between the determining nodes is r eturned. This order is stable as long as no nodes of 1582 // implementation-dependent order between the determining nodes is r eturned. This order is stable as long as no nodes of
1583 // the same nodeType are inserted into or removed from the direct co ntainer. This would be the case, for example, 1583 // the same nodeType are inserted into or removed from the direct co ntainer. This would be the case, for example,
1584 // when comparing two attributes of the same element, and inserting or removing additional attributes might change 1584 // when comparing two attributes of the same element, and inserting or removing additional attributes might change
1585 // the order between existing attributes. 1585 // the order between existing attributes.
1586 if (attr1->qualifiedName() == it->name()) 1586 if (attr1->qualifiedName() == it->name())
1587 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_FOLLOWING; 1587 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_FOLLOWING;
1588 if (attr2->qualifiedName() == it->name()) 1588 if (attr2->qualifiedName() == it->name())
1589 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_PRECEDING; 1589 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_PRECEDING;
1590 } 1590 }
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 node->showTreeForThis(); 2572 node->showTreeForThis();
2573 } 2573 }
2574 2574
2575 void showNodePath(const WebCore::Node* node) 2575 void showNodePath(const WebCore::Node* node)
2576 { 2576 {
2577 if (node) 2577 if (node)
2578 node->showNodePathForThis(); 2578 node->showNodePathForThis();
2579 } 2579 }
2580 2580
2581 #endif 2581 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/ElementData.cpp ('k') | Source/core/dom/PresentationAttributeStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698