| OLD | NEW |
| 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 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 | 1316 |
| 1317 return true; | 1317 return true; |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 bool Node::isDefaultNamespace(const AtomicString& namespaceURIMaybeEmpty) const | 1320 bool Node::isDefaultNamespace(const AtomicString& namespaceURIMaybeEmpty) const |
| 1321 { | 1321 { |
| 1322 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt
om : namespaceURIMaybeEmpty; | 1322 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt
om : namespaceURIMaybeEmpty; |
| 1323 | 1323 |
| 1324 switch (nodeType()) { | 1324 switch (nodeType()) { |
| 1325 case ELEMENT_NODE: { | 1325 case ELEMENT_NODE: { |
| 1326 const Element* elem = toElement(this); | 1326 const Element& element = toElement(*this); |
| 1327 | 1327 |
| 1328 if (elem->prefix().isNull()) | 1328 if (element.prefix().isNull()) |
| 1329 return elem->namespaceURI() == namespaceURI; | 1329 return element.namespaceURI() == namespaceURI; |
| 1330 | 1330 |
| 1331 if (elem->hasAttributes()) { | 1331 if (element.hasAttributes()) { |
| 1332 unsigned attributeCount = elem->attributeCount(); | 1332 AttributeIteratorAccessor attributes = element.attributesIterato
r(); |
| 1333 for (unsigned i = 0; i < attributeCount; ++i) { | 1333 AttributeConstIterator end = attributes.end(); |
| 1334 const Attribute& attr = elem->attributeItem(i); | 1334 for (AttributeConstIterator it = attributes.begin(); it != end;
++it) { |
| 1335 | 1335 if (it->localName() == xmlnsAtom) |
| 1336 if (attr.localName() == xmlnsAtom) | 1336 return it->value() == namespaceURI; |
| 1337 return attr.value() == namespaceURI; | |
| 1338 } | 1337 } |
| 1339 } | 1338 } |
| 1340 | 1339 |
| 1341 if (Element* parent = parentElement()) | 1340 if (Element* parent = parentElement()) |
| 1342 return parent->isDefaultNamespace(namespaceURI); | 1341 return parent->isDefaultNamespace(namespaceURI); |
| 1343 | 1342 |
| 1344 return false; | 1343 return false; |
| 1345 } | 1344 } |
| 1346 case DOCUMENT_NODE: | 1345 case DOCUMENT_NODE: |
| 1347 if (Element* de = toDocument(this)->documentElement()) | 1346 if (Element* de = toDocument(this)->documentElement()) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 const AtomicString& Node::lookupNamespaceURI(const String& prefix) const | 1401 const AtomicString& Node::lookupNamespaceURI(const String& prefix) const |
| 1403 { | 1402 { |
| 1404 // Implemented according to | 1403 // Implemented according to |
| 1405 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori
thms.html#lookupNamespaceURIAlgo | 1404 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori
thms.html#lookupNamespaceURIAlgo |
| 1406 | 1405 |
| 1407 if (!prefix.isNull() && prefix.isEmpty()) | 1406 if (!prefix.isNull() && prefix.isEmpty()) |
| 1408 return nullAtom; | 1407 return nullAtom; |
| 1409 | 1408 |
| 1410 switch (nodeType()) { | 1409 switch (nodeType()) { |
| 1411 case ELEMENT_NODE: { | 1410 case ELEMENT_NODE: { |
| 1412 const Element *elem = toElement(this); | 1411 const Element& element = toElement(*this); |
| 1413 | 1412 |
| 1414 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix) | 1413 if (!element.namespaceURI().isNull() && element.prefix() == prefix) |
| 1415 return elem->namespaceURI(); | 1414 return element.namespaceURI(); |
| 1416 | 1415 |
| 1417 if (elem->hasAttributes()) { | 1416 if (element.hasAttributes()) { |
| 1418 unsigned attributeCount = elem->attributeCount(); | 1417 AttributeIteratorAccessor attributes = element.attributesIterato
r(); |
| 1419 for (unsigned i = 0; i < attributeCount; ++i) { | 1418 AttributeConstIterator end = attributes.end(); |
| 1420 const Attribute& attr = elem->attributeItem(i); | 1419 for (AttributeConstIterator it = attributes.begin(); it != end;
++it) { |
| 1421 | 1420 if (it->prefix() == xmlnsAtom && it->localName() == prefix)
{ |
| 1422 if (attr.prefix() == xmlnsAtom && attr.localName() == prefix
) { | 1421 if (!it->value().isEmpty()) |
| 1423 if (!attr.value().isEmpty()) | 1422 return it->value(); |
| 1424 return attr.value(); | |
| 1425 | |
| 1426 return nullAtom; | 1423 return nullAtom; |
| 1427 } | 1424 } |
| 1428 if (attr.localName() == xmlnsAtom && prefix.isNull()) { | 1425 if (it->localName() == xmlnsAtom && prefix.isNull()) { |
| 1429 if (!attr.value().isEmpty()) | 1426 if (!it->value().isEmpty()) |
| 1430 return attr.value(); | 1427 return it->value(); |
| 1431 | |
| 1432 return nullAtom; | 1428 return nullAtom; |
| 1433 } | 1429 } |
| 1434 } | 1430 } |
| 1435 } | 1431 } |
| 1436 if (Element* parent = parentElement()) | 1432 if (Element* parent = parentElement()) |
| 1437 return parent->lookupNamespaceURI(prefix); | 1433 return parent->lookupNamespaceURI(prefix); |
| 1438 return nullAtom; | 1434 return nullAtom; |
| 1439 } | 1435 } |
| 1440 case DOCUMENT_NODE: | 1436 case DOCUMENT_NODE: |
| 1441 if (Element* de = toDocument(this)->documentElement()) | 1437 if (Element* de = toDocument(this)->documentElement()) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 Vector<const Node*, 16> chain2; | 1570 Vector<const Node*, 16> chain2; |
| 1575 if (attr1) | 1571 if (attr1) |
| 1576 chain1.append(attr1); | 1572 chain1.append(attr1); |
| 1577 if (attr2) | 1573 if (attr2) |
| 1578 chain2.append(attr2); | 1574 chain2.append(attr2); |
| 1579 | 1575 |
| 1580 if (attr1 && attr2 && start1 == start2 && start1) { | 1576 if (attr1 && attr2 && start1 == start2 && start1) { |
| 1581 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. | 1577 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. |
| 1582 const Element* owner1 = attr1->ownerElement(); | 1578 const Element* owner1 = attr1->ownerElement(); |
| 1583 owner1->synchronizeAllAttributes(); | 1579 owner1->synchronizeAllAttributes(); |
| 1584 unsigned length = owner1->attributeCount(); | 1580 AttributeIteratorAccessor attributes = owner1->attributesIterator(); |
| 1585 for (unsigned i = 0; i < length; ++i) { | 1581 AttributeConstIterator end = attributes.end(); |
| 1582 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { |
| 1586 // If neither of the two determining nodes is a child node and nodeT
ype is the same for both determining nodes, then an | 1583 // If neither of the two determining nodes is a child node and nodeT
ype is the same for both determining nodes, then an |
| 1587 // implementation-dependent order between the determining nodes is r
eturned. This order is stable as long as no nodes of | 1584 // implementation-dependent order between the determining nodes is r
eturned. This order is stable as long as no nodes of |
| 1588 // the same nodeType are inserted into or removed from the direct co
ntainer. This would be the case, for example, | 1585 // the same nodeType are inserted into or removed from the direct co
ntainer. This would be the case, for example, |
| 1589 // when comparing two attributes of the same element, and inserting
or removing additional attributes might change | 1586 // when comparing two attributes of the same element, and inserting
or removing additional attributes might change |
| 1590 // the order between existing attributes. | 1587 // the order between existing attributes. |
| 1591 const Attribute& attribute = owner1->attributeItem(i); | 1588 if (attr1->qualifiedName() == it->name()) |
| 1592 if (attr1->qualifiedName() == attribute.name()) | |
| 1593 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_FOLLOWING; | 1589 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_FOLLOWING; |
| 1594 if (attr2->qualifiedName() == attribute.name()) | 1590 if (attr2->qualifiedName() == it->name()) |
| 1595 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_PRECEDING; | 1591 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_PRECEDING; |
| 1596 } | 1592 } |
| 1597 | 1593 |
| 1598 ASSERT_NOT_REACHED(); | 1594 ASSERT_NOT_REACHED(); |
| 1599 return DOCUMENT_POSITION_DISCONNECTED; | 1595 return DOCUMENT_POSITION_DISCONNECTED; |
| 1600 } | 1596 } |
| 1601 | 1597 |
| 1602 // If one node is in the document and the other is not, we must be disconnec
ted. | 1598 // If one node is in the document and the other is not, we must be disconnec
ted. |
| 1603 // If the nodes have different owning documents, they must be disconnected.
Note that we avoid | 1599 // If the nodes have different owning documents, they must be disconnected.
Note that we avoid |
| 1604 // comparing Attr nodes here, since they return false from inDocument() all
the time (which seems like a bug). | 1600 // comparing Attr nodes here, since they return false from inDocument() all
the time (which seems like a bug). |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2578 node->showTreeForThis(); | 2574 node->showTreeForThis(); |
| 2579 } | 2575 } |
| 2580 | 2576 |
| 2581 void showNodePath(const WebCore::Node* node) | 2577 void showNodePath(const WebCore::Node* node) |
| 2582 { | 2578 { |
| 2583 if (node) | 2579 if (node) |
| 2584 node->showNodePathForThis(); | 2580 node->showNodePathForThis(); |
| 2585 } | 2581 } |
| 2586 | 2582 |
| 2587 #endif | 2583 #endif |
| OLD | NEW |