Chromium Code Reviews| 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 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1420 return attr->ownerElement()->isDefaultNamespace(namespaceURI); | 1420 return attr->ownerElement()->isDefaultNamespace(namespaceURI); |
| 1421 return false; | 1421 return false; |
| 1422 } | 1422 } |
| 1423 default: | 1423 default: |
| 1424 if (Element* ancestor = ancestorElement()) | 1424 if (Element* ancestor = ancestorElement()) |
| 1425 return ancestor->isDefaultNamespace(namespaceURI); | 1425 return ancestor->isDefaultNamespace(namespaceURI); |
| 1426 return false; | 1426 return false; |
| 1427 } | 1427 } |
| 1428 } | 1428 } |
| 1429 | 1429 |
| 1430 String Node::lookupPrefix(const AtomicString &namespaceURI) const | 1430 const AtomicString& Node::lookupPrefix(const AtomicString& namespaceURI) const |
| 1431 { | 1431 { |
| 1432 // Implemented according to | 1432 // Implemented according to |
| 1433 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori thms.html#lookupNamespacePrefixAlgo | 1433 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori thms.html#lookupNamespacePrefixAlgo |
| 1434 | 1434 |
| 1435 if (namespaceURI.isEmpty()) | 1435 if (namespaceURI.isEmpty()) |
| 1436 return String(); | 1436 return nullAtom; |
| 1437 | 1437 |
| 1438 switch (nodeType()) { | 1438 switch (nodeType()) { |
| 1439 case ELEMENT_NODE: | 1439 case ELEMENT_NODE: |
| 1440 return lookupNamespacePrefix(namespaceURI, toElement(this)); | 1440 return lookupNamespacePrefix(namespaceURI, toElement(this)); |
| 1441 case DOCUMENT_NODE: | 1441 case DOCUMENT_NODE: |
| 1442 if (Element* de = toDocument(this)->documentElement()) | 1442 if (Element* de = toDocument(this)->documentElement()) |
| 1443 return de->lookupPrefix(namespaceURI); | 1443 return de->lookupPrefix(namespaceURI); |
| 1444 return String(); | 1444 return nullAtom; |
| 1445 case ENTITY_NODE: | 1445 case ENTITY_NODE: |
| 1446 case NOTATION_NODE: | 1446 case NOTATION_NODE: |
| 1447 case DOCUMENT_FRAGMENT_NODE: | 1447 case DOCUMENT_FRAGMENT_NODE: |
| 1448 case DOCUMENT_TYPE_NODE: | 1448 case DOCUMENT_TYPE_NODE: |
| 1449 return String(); | 1449 return nullAtom; |
| 1450 case ATTRIBUTE_NODE: { | 1450 case ATTRIBUTE_NODE: { |
| 1451 const Attr *attr = static_cast<const Attr *>(this); | 1451 const Attr *attr = static_cast<const Attr *>(this); |
| 1452 if (attr->ownerElement()) | 1452 if (attr->ownerElement()) |
| 1453 return attr->ownerElement()->lookupPrefix(namespaceURI); | 1453 return attr->ownerElement()->lookupPrefix(namespaceURI); |
| 1454 return String(); | 1454 return nullAtom; |
| 1455 } | 1455 } |
| 1456 default: | 1456 default: |
| 1457 if (Element* ancestor = ancestorElement()) | 1457 if (Element* ancestor = ancestorElement()) |
| 1458 return ancestor->lookupPrefix(namespaceURI); | 1458 return ancestor->lookupPrefix(namespaceURI); |
| 1459 return String(); | 1459 return nullAtom; |
| 1460 } | 1460 } |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 String Node::lookupNamespaceURI(const String &prefix) const | 1463 const AtomicString& Node::lookupNamespaceURI(const String& prefix) const |
| 1464 { | 1464 { |
| 1465 // Implemented according to | 1465 // Implemented according to |
| 1466 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori thms.html#lookupNamespaceURIAlgo | 1466 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algori thms.html#lookupNamespaceURIAlgo |
| 1467 | 1467 |
| 1468 if (!prefix.isNull() && prefix.isEmpty()) | 1468 if (!prefix.isNull() && prefix.isEmpty()) |
| 1469 return String(); | 1469 return nullAtom; |
| 1470 | 1470 |
| 1471 switch (nodeType()) { | 1471 switch (nodeType()) { |
| 1472 case ELEMENT_NODE: { | 1472 case ELEMENT_NODE: { |
| 1473 const Element *elem = toElement(this); | 1473 const Element *elem = toElement(this); |
| 1474 | 1474 |
| 1475 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix) | 1475 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix) |
| 1476 return elem->namespaceURI(); | 1476 return elem->namespaceURI(); |
|
Inactive
2013/12/06 19:05:29
This returns a const AtomicString& already.
| |
| 1477 | 1477 |
| 1478 if (elem->hasAttributes()) { | 1478 if (elem->hasAttributes()) { |
| 1479 for (unsigned i = 0; i < elem->attributeCount(); i++) { | 1479 for (unsigned i = 0; i < elem->attributeCount(); i++) { |
| 1480 const Attribute* attr = elem->attributeItem(i); | 1480 const Attribute* attr = elem->attributeItem(i); |
| 1481 | 1481 |
| 1482 if (attr->prefix() == xmlnsAtom && attr->localName() == pref ix) { | 1482 if (attr->prefix() == xmlnsAtom && attr->localName() == pref ix) { |
| 1483 if (!attr->value().isEmpty()) | 1483 if (!attr->value().isEmpty()) |
| 1484 return attr->value(); | 1484 return attr->value(); |
|
Inactive
2013/12/06 19:05:29
Ditto.
| |
| 1485 | 1485 |
| 1486 return String(); | 1486 return nullAtom; |
| 1487 } else if (attr->localName() == xmlnsAtom && prefix.isNull() ) { | 1487 } else if (attr->localName() == xmlnsAtom && prefix.isNull() ) { |
| 1488 if (!attr->value().isEmpty()) | 1488 if (!attr->value().isEmpty()) |
| 1489 return attr->value(); | 1489 return attr->value(); |
|
Inactive
2013/12/06 19:05:29
Ditto.
| |
| 1490 | 1490 |
| 1491 return String(); | 1491 return nullAtom; |
| 1492 } | 1492 } |
| 1493 } | 1493 } |
| 1494 } | 1494 } |
| 1495 if (Element* ancestor = ancestorElement()) | 1495 if (Element* ancestor = ancestorElement()) |
| 1496 return ancestor->lookupNamespaceURI(prefix); | 1496 return ancestor->lookupNamespaceURI(prefix); |
| 1497 return String(); | 1497 return nullAtom; |
| 1498 } | 1498 } |
| 1499 case DOCUMENT_NODE: | 1499 case DOCUMENT_NODE: |
| 1500 if (Element* de = toDocument(this)->documentElement()) | 1500 if (Element* de = toDocument(this)->documentElement()) |
| 1501 return de->lookupNamespaceURI(prefix); | 1501 return de->lookupNamespaceURI(prefix); |
| 1502 return String(); | 1502 return nullAtom; |
| 1503 case ENTITY_NODE: | 1503 case ENTITY_NODE: |
| 1504 case NOTATION_NODE: | 1504 case NOTATION_NODE: |
| 1505 case DOCUMENT_TYPE_NODE: | 1505 case DOCUMENT_TYPE_NODE: |
| 1506 case DOCUMENT_FRAGMENT_NODE: | 1506 case DOCUMENT_FRAGMENT_NODE: |
| 1507 return String(); | 1507 return nullAtom; |
| 1508 case ATTRIBUTE_NODE: { | 1508 case ATTRIBUTE_NODE: { |
| 1509 const Attr *attr = static_cast<const Attr *>(this); | 1509 const Attr *attr = static_cast<const Attr *>(this); |
| 1510 | 1510 |
| 1511 if (attr->ownerElement()) | 1511 if (attr->ownerElement()) |
| 1512 return attr->ownerElement()->lookupNamespaceURI(prefix); | 1512 return attr->ownerElement()->lookupNamespaceURI(prefix); |
| 1513 else | 1513 else |
| 1514 return String(); | 1514 return nullAtom; |
| 1515 } | 1515 } |
| 1516 default: | 1516 default: |
| 1517 if (Element* ancestor = ancestorElement()) | 1517 if (Element* ancestor = ancestorElement()) |
| 1518 return ancestor->lookupNamespaceURI(prefix); | 1518 return ancestor->lookupNamespaceURI(prefix); |
| 1519 return String(); | 1519 return nullAtom; |
| 1520 } | 1520 } |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 String Node::lookupNamespacePrefix(const AtomicString &_namespaceURI, const Elem ent *originalElement) const | 1523 const AtomicString& Node::lookupNamespacePrefix(const AtomicString& _namespaceUR I, const Element* originalElement) const |
| 1524 { | 1524 { |
| 1525 if (_namespaceURI.isNull()) | 1525 if (_namespaceURI.isNull()) |
| 1526 return String(); | 1526 return nullAtom; |
| 1527 | 1527 |
| 1528 if (originalElement->lookupNamespaceURI(prefix()) == _namespaceURI) | 1528 if (originalElement->lookupNamespaceURI(prefix()) == _namespaceURI) |
| 1529 return prefix(); | 1529 return prefix(); |
|
Inactive
2013/12/06 19:05:29
This returns a const AtomicString& already.
| |
| 1530 | 1530 |
| 1531 ASSERT(isElementNode()); | 1531 ASSERT(isElementNode()); |
| 1532 const Element* thisElement = toElement(this); | 1532 const Element* thisElement = toElement(this); |
| 1533 if (thisElement->hasAttributes()) { | 1533 if (thisElement->hasAttributes()) { |
| 1534 for (unsigned i = 0; i < thisElement->attributeCount(); i++) { | 1534 for (unsigned i = 0; i < thisElement->attributeCount(); i++) { |
| 1535 const Attribute* attr = thisElement->attributeItem(i); | 1535 const Attribute* attr = thisElement->attributeItem(i); |
| 1536 | 1536 |
| 1537 if (attr->prefix() == xmlnsAtom && attr->value() == _namespaceURI | 1537 if (attr->prefix() == xmlnsAtom && attr->value() == _namespaceURI |
| 1538 && originalElement->lookupNamespaceURI(attr->localName()) == _namespaceURI) | 1538 && originalElement->lookupNamespaceURI(attr->localName()) == _namespaceURI) |
| 1539 return attr->localName(); | 1539 return attr->localName(); |
|
Inactive
2013/12/06 19:05:29
Ditto.
| |
| 1540 } | 1540 } |
| 1541 } | 1541 } |
| 1542 | 1542 |
| 1543 if (Element* ancestor = ancestorElement()) | 1543 if (Element* ancestor = ancestorElement()) |
| 1544 return ancestor->lookupNamespacePrefix(_namespaceURI, originalElement); | 1544 return ancestor->lookupNamespacePrefix(_namespaceURI, originalElement); |
| 1545 return String(); | 1545 return nullAtom; |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 static void appendTextContent(const Node* node, bool convertBRsToNewlines, bool& isNullString, StringBuilder& content) | 1548 static void appendTextContent(const Node* node, bool convertBRsToNewlines, bool& isNullString, StringBuilder& content) |
| 1549 { | 1549 { |
| 1550 switch (node->nodeType()) { | 1550 switch (node->nodeType()) { |
| 1551 case Node::TEXT_NODE: | 1551 case Node::TEXT_NODE: |
| 1552 case Node::CDATA_SECTION_NODE: | 1552 case Node::CDATA_SECTION_NODE: |
| 1553 case Node::COMMENT_NODE: | 1553 case Node::COMMENT_NODE: |
| 1554 isNullString = false; | 1554 isNullString = false; |
| 1555 content.append(toCharacterData(node)->data()); | 1555 content.append(toCharacterData(node)->data()); |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2670 node->showTreeForThis(); | 2670 node->showTreeForThis(); |
| 2671 } | 2671 } |
| 2672 | 2672 |
| 2673 void showNodePath(const WebCore::Node* node) | 2673 void showNodePath(const WebCore::Node* node) |
| 2674 { | 2674 { |
| 2675 if (node) | 2675 if (node) |
| 2676 node->showNodePathForThis(); | 2676 node->showNodePathForThis(); |
| 2677 } | 2677 } |
| 2678 | 2678 |
| 2679 #endif | 2679 #endif |
| OLD | NEW |