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

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

Issue 180723006: Have ElementData::attributeItem() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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/NamedNodeMap.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 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 switch (nodeType()) { 1336 switch (nodeType()) {
1337 case ELEMENT_NODE: { 1337 case ELEMENT_NODE: {
1338 const Element* elem = toElement(this); 1338 const Element* elem = toElement(this);
1339 1339
1340 if (elem->prefix().isNull()) 1340 if (elem->prefix().isNull())
1341 return elem->namespaceURI() == namespaceURI; 1341 return elem->namespaceURI() == namespaceURI;
1342 1342
1343 if (elem->hasAttributes()) { 1343 if (elem->hasAttributes()) {
1344 unsigned attributeCount = elem->attributeCount(); 1344 unsigned attributeCount = elem->attributeCount();
1345 for (unsigned i = 0; i < attributeCount; ++i) { 1345 for (unsigned i = 0; i < attributeCount; ++i) {
1346 const Attribute* attr = elem->attributeItem(i); 1346 const Attribute& attr = elem->attributeItem(i);
1347 1347
1348 if (attr->localName() == xmlnsAtom) 1348 if (attr.localName() == xmlnsAtom)
1349 return attr->value() == namespaceURI; 1349 return attr.value() == namespaceURI;
1350 } 1350 }
1351 } 1351 }
1352 1352
1353 if (Element* parent = parentElement()) 1353 if (Element* parent = parentElement())
1354 return parent->isDefaultNamespace(namespaceURI); 1354 return parent->isDefaultNamespace(namespaceURI);
1355 1355
1356 return false; 1356 return false;
1357 } 1357 }
1358 case DOCUMENT_NODE: 1358 case DOCUMENT_NODE:
1359 if (Element* de = toDocument(this)->documentElement()) 1359 if (Element* de = toDocument(this)->documentElement())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 switch (nodeType()) { 1422 switch (nodeType()) {
1423 case ELEMENT_NODE: { 1423 case ELEMENT_NODE: {
1424 const Element *elem = toElement(this); 1424 const Element *elem = toElement(this);
1425 1425
1426 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix) 1426 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix)
1427 return elem->namespaceURI(); 1427 return elem->namespaceURI();
1428 1428
1429 if (elem->hasAttributes()) { 1429 if (elem->hasAttributes()) {
1430 unsigned attributeCount = elem->attributeCount(); 1430 unsigned attributeCount = elem->attributeCount();
1431 for (unsigned i = 0; i < attributeCount; ++i) { 1431 for (unsigned i = 0; i < attributeCount; ++i) {
1432 const Attribute* attr = elem->attributeItem(i); 1432 const Attribute& attr = elem->attributeItem(i);
1433 1433
1434 if (attr->prefix() == xmlnsAtom && attr->localName() == pref ix) { 1434 if (attr.prefix() == xmlnsAtom && attr.localName() == prefix ) {
1435 if (!attr->value().isEmpty()) 1435 if (!attr.value().isEmpty())
1436 return attr->value(); 1436 return attr.value();
1437
1438 return nullAtom;
1439 } else if (attr->localName() == xmlnsAtom && prefix.isNull() ) {
1440 if (!attr->value().isEmpty())
1441 return attr->value();
1442 1437
1443 return nullAtom; 1438 return nullAtom;
1444 } 1439 }
1440 if (attr.localName() == xmlnsAtom && prefix.isNull()) {
1441 if (!attr.value().isEmpty())
1442 return attr.value();
1443
1444 return nullAtom;
1445 }
1445 } 1446 }
1446 } 1447 }
1447 if (Element* parent = parentElement()) 1448 if (Element* parent = parentElement())
1448 return parent->lookupNamespaceURI(prefix); 1449 return parent->lookupNamespaceURI(prefix);
1449 return nullAtom; 1450 return nullAtom;
1450 } 1451 }
1451 case DOCUMENT_NODE: 1452 case DOCUMENT_NODE:
1452 if (Element* de = toDocument(this)->documentElement()) 1453 if (Element* de = toDocument(this)->documentElement())
1453 return de->lookupNamespaceURI(prefix); 1454 return de->lookupNamespaceURI(prefix);
1454 return nullAtom; 1455 return nullAtom;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 // We are comparing two attributes on the same node. Crawl our attribute map and see which one we hit first. 1586 // We are comparing two attributes on the same node. Crawl our attribute map and see which one we hit first.
1586 const Element* owner1 = attr1->ownerElement(); 1587 const Element* owner1 = attr1->ownerElement();
1587 owner1->synchronizeAllAttributes(); 1588 owner1->synchronizeAllAttributes();
1588 unsigned length = owner1->attributeCount(); 1589 unsigned length = owner1->attributeCount();
1589 for (unsigned i = 0; i < length; ++i) { 1590 for (unsigned i = 0; i < length; ++i) {
1590 // If neither of the two determining nodes is a child node and nodeT ype is the same for both determining nodes, then an 1591 // If neither of the two determining nodes is a child node and nodeT ype is the same for both determining nodes, then an
1591 // implementation-dependent order between the determining nodes is r eturned. This order is stable as long as no nodes of 1592 // implementation-dependent order between the determining nodes is r eturned. This order is stable as long as no nodes of
1592 // the same nodeType are inserted into or removed from the direct co ntainer. This would be the case, for example, 1593 // the same nodeType are inserted into or removed from the direct co ntainer. This would be the case, for example,
1593 // when comparing two attributes of the same element, and inserting or removing additional attributes might change 1594 // when comparing two attributes of the same element, and inserting or removing additional attributes might change
1594 // the order between existing attributes. 1595 // the order between existing attributes.
1595 const Attribute* attribute = owner1->attributeItem(i); 1596 const Attribute& attribute = owner1->attributeItem(i);
1596 if (attr1->qualifiedName() == attribute->name()) 1597 if (attr1->qualifiedName() == attribute.name())
1597 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_FOLLOWING; 1598 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_FOLLOWING;
1598 if (attr2->qualifiedName() == attribute->name()) 1599 if (attr2->qualifiedName() == attribute.name())
1599 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_PRECEDING; 1600 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_PRECEDING;
1600 } 1601 }
1601 1602
1602 ASSERT_NOT_REACHED(); 1603 ASSERT_NOT_REACHED();
1603 return DOCUMENT_POSITION_DISCONNECTED; 1604 return DOCUMENT_POSITION_DISCONNECTED;
1604 } 1605 }
1605 1606
1606 // If one node is in the document and the other is not, we must be disconnec ted. 1607 // If one node is in the document and the other is not, we must be disconnec ted.
1607 // If the nodes have different owning documents, they must be disconnected. Note that we avoid 1608 // If the nodes have different owning documents, they must be disconnected. Note that we avoid
1608 // comparing Attr nodes here, since they return false from inDocument() all the time (which seems like a bug). 1609 // comparing Attr nodes here, since they return false from inDocument() all the time (which seems like a bug).
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 node->showTreeForThis(); 2557 node->showTreeForThis();
2557 } 2558 }
2558 2559
2559 void showNodePath(const WebCore::Node* node) 2560 void showNodePath(const WebCore::Node* node)
2560 { 2561 {
2561 if (node) 2562 if (node)
2562 node->showNodePathForThis(); 2563 node->showNodePathForThis();
2563 } 2564 }
2564 2565
2565 #endif 2566 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/NamedNodeMap.cpp ('k') | Source/core/dom/PresentationAttributeStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698