| 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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 | 1300 |
| 1301 return true; | 1301 return true; |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 bool Node::isDefaultNamespace(const AtomicString& namespaceURIMaybeEmpty) const | 1304 bool Node::isDefaultNamespace(const AtomicString& namespaceURIMaybeEmpty) const |
| 1305 { | 1305 { |
| 1306 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt
om : namespaceURIMaybeEmpty; | 1306 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt
om : namespaceURIMaybeEmpty; |
| 1307 | 1307 |
| 1308 switch (nodeType()) { | 1308 switch (nodeType()) { |
| 1309 case ELEMENT_NODE: { | 1309 case ELEMENT_NODE: { |
| 1310 const Element* elem = toElement(this); | 1310 const Element& element = toElement(*this); |
| 1311 | 1311 |
| 1312 if (elem->prefix().isNull()) | 1312 if (element.prefix().isNull()) |
| 1313 return elem->namespaceURI() == namespaceURI; | 1313 return element.namespaceURI() == namespaceURI; |
| 1314 | 1314 |
| 1315 if (elem->hasAttributes()) { | 1315 if (element.hasAttributes()) { |
| 1316 unsigned attributeCount = elem->attributeCount(); | 1316 AttributeIteratorAccessor attributes = element.attributesIterato
r(); |
| 1317 for (unsigned i = 0; i < attributeCount; ++i) { | 1317 AttributeConstIterator end = attributes.end(); |
| 1318 const Attribute& attr = elem->attributeItem(i); | 1318 for (AttributeConstIterator it = attributes.begin(); it != end;
++it) { |
| 1319 | 1319 if (it->localName() == xmlnsAtom) |
| 1320 if (attr.localName() == xmlnsAtom) | 1320 return it->value() == namespaceURI; |
| 1321 return attr.value() == namespaceURI; | |
| 1322 } | 1321 } |
| 1323 } | 1322 } |
| 1324 | 1323 |
| 1325 if (Element* parent = parentElement()) | 1324 if (Element* parent = parentElement()) |
| 1326 return parent->isDefaultNamespace(namespaceURI); | 1325 return parent->isDefaultNamespace(namespaceURI); |
| 1327 | 1326 |
| 1328 return false; | 1327 return false; |
| 1329 } | 1328 } |
| 1330 case DOCUMENT_NODE: | 1329 case DOCUMENT_NODE: |
| 1331 if (Element* de = toDocument(this)->documentElement()) | 1330 if (Element* de = toDocument(this)->documentElement()) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 const AtomicString& Node::lookupNamespaceURI(const String& prefix) const | 1385 const AtomicString& Node::lookupNamespaceURI(const String& prefix) const |
| 1387 { | 1386 { |
| 1388 // Implemented according to | 1387 // Implemented according to |
| 1389 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori
thms.html#lookupNamespaceURIAlgo | 1388 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori
thms.html#lookupNamespaceURIAlgo |
| 1390 | 1389 |
| 1391 if (!prefix.isNull() && prefix.isEmpty()) | 1390 if (!prefix.isNull() && prefix.isEmpty()) |
| 1392 return nullAtom; | 1391 return nullAtom; |
| 1393 | 1392 |
| 1394 switch (nodeType()) { | 1393 switch (nodeType()) { |
| 1395 case ELEMENT_NODE: { | 1394 case ELEMENT_NODE: { |
| 1396 const Element *elem = toElement(this); | 1395 const Element& element = toElement(*this); |
| 1397 | 1396 |
| 1398 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix) | 1397 if (!element.namespaceURI().isNull() && element.prefix() == prefix) |
| 1399 return elem->namespaceURI(); | 1398 return element.namespaceURI(); |
| 1400 | 1399 |
| 1401 if (elem->hasAttributes()) { | 1400 if (element.hasAttributes()) { |
| 1402 unsigned attributeCount = elem->attributeCount(); | 1401 AttributeIteratorAccessor attributes = element.attributesIterato
r(); |
| 1403 for (unsigned i = 0; i < attributeCount; ++i) { | 1402 AttributeConstIterator end = attributes.end(); |
| 1404 const Attribute& attr = elem->attributeItem(i); | 1403 for (AttributeConstIterator it = attributes.begin(); it != end;
++it) { |
| 1405 | 1404 if (it->prefix() == xmlnsAtom && it->localName() == prefix)
{ |
| 1406 if (attr.prefix() == xmlnsAtom && attr.localName() == prefix
) { | 1405 if (!it->value().isEmpty()) |
| 1407 if (!attr.value().isEmpty()) | 1406 return it->value(); |
| 1408 return attr.value(); | |
| 1409 | |
| 1410 return nullAtom; | 1407 return nullAtom; |
| 1411 } | 1408 } |
| 1412 if (attr.localName() == xmlnsAtom && prefix.isNull()) { | 1409 if (it->localName() == xmlnsAtom && prefix.isNull()) { |
| 1413 if (!attr.value().isEmpty()) | 1410 if (!it->value().isEmpty()) |
| 1414 return attr.value(); | 1411 return it->value(); |
| 1415 | |
| 1416 return nullAtom; | 1412 return nullAtom; |
| 1417 } | 1413 } |
| 1418 } | 1414 } |
| 1419 } | 1415 } |
| 1420 if (Element* parent = parentElement()) | 1416 if (Element* parent = parentElement()) |
| 1421 return parent->lookupNamespaceURI(prefix); | 1417 return parent->lookupNamespaceURI(prefix); |
| 1422 return nullAtom; | 1418 return nullAtom; |
| 1423 } | 1419 } |
| 1424 case DOCUMENT_NODE: | 1420 case DOCUMENT_NODE: |
| 1425 if (Element* de = toDocument(this)->documentElement()) | 1421 if (Element* de = toDocument(this)->documentElement()) |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 Vector<const Node*, 16> chain2; | 1553 Vector<const Node*, 16> chain2; |
| 1558 if (attr1) | 1554 if (attr1) |
| 1559 chain1.append(attr1); | 1555 chain1.append(attr1); |
| 1560 if (attr2) | 1556 if (attr2) |
| 1561 chain2.append(attr2); | 1557 chain2.append(attr2); |
| 1562 | 1558 |
| 1563 if (attr1 && attr2 && start1 == start2 && start1) { | 1559 if (attr1 && attr2 && start1 == start2 && start1) { |
| 1564 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. | 1560 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. |
| 1565 const Element* owner1 = attr1->ownerElement(); | 1561 const Element* owner1 = attr1->ownerElement(); |
| 1566 owner1->synchronizeAllAttributes(); | 1562 owner1->synchronizeAllAttributes(); |
| 1567 unsigned length = owner1->attributeCount(); | 1563 AttributeIteratorAccessor attributes = owner1->attributesIterator(); |
| 1568 for (unsigned i = 0; i < length; ++i) { | 1564 AttributeConstIterator end = attributes.end(); |
| 1565 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { |
| 1569 // If neither of the two determining nodes is a child node and nodeT
ype is the same for both determining nodes, then an | 1566 // If neither of the two determining nodes is a child node and nodeT
ype is the same for both determining nodes, then an |
| 1570 // implementation-dependent order between the determining nodes is r
eturned. This order is stable as long as no nodes of | 1567 // implementation-dependent order between the determining nodes is r
eturned. This order is stable as long as no nodes of |
| 1571 // the same nodeType are inserted into or removed from the direct co
ntainer. This would be the case, for example, | 1568 // the same nodeType are inserted into or removed from the direct co
ntainer. This would be the case, for example, |
| 1572 // when comparing two attributes of the same element, and inserting
or removing additional attributes might change | 1569 // when comparing two attributes of the same element, and inserting
or removing additional attributes might change |
| 1573 // the order between existing attributes. | 1570 // the order between existing attributes. |
| 1574 const Attribute& attribute = owner1->attributeItem(i); | 1571 if (attr1->qualifiedName() == it->name()) |
| 1575 if (attr1->qualifiedName() == attribute.name()) | |
| 1576 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_FOLLOWING; | 1572 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_FOLLOWING; |
| 1577 if (attr2->qualifiedName() == attribute.name()) | 1573 if (attr2->qualifiedName() == it->name()) |
| 1578 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_PRECEDING; | 1574 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_PRECEDING; |
| 1579 } | 1575 } |
| 1580 | 1576 |
| 1581 ASSERT_NOT_REACHED(); | 1577 ASSERT_NOT_REACHED(); |
| 1582 return DOCUMENT_POSITION_DISCONNECTED; | 1578 return DOCUMENT_POSITION_DISCONNECTED; |
| 1583 } | 1579 } |
| 1584 | 1580 |
| 1585 // If one node is in the document and the other is not, we must be disconnec
ted. | 1581 // If one node is in the document and the other is not, we must be disconnec
ted. |
| 1586 // If the nodes have different owning documents, they must be disconnected.
Note that we avoid | 1582 // If the nodes have different owning documents, they must be disconnected.
Note that we avoid |
| 1587 // comparing Attr nodes here, since they return false from inDocument() all
the time (which seems like a bug). | 1583 // comparing Attr nodes here, since they return false from inDocument() all
the time (which seems like a bug). |
| (...skipping 990 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 |