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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void Node::dumpStatistics() | 143 void Node::dumpStatistics() |
144 { | 144 { |
145 #if DUMP_NODE_STATISTICS | 145 #if DUMP_NODE_STATISTICS |
146 size_t nodesWithRareData = 0; | 146 size_t nodesWithRareData = 0; |
147 | 147 |
148 size_t elementNodes = 0; | 148 size_t elementNodes = 0; |
149 size_t attrNodes = 0; | 149 size_t attrNodes = 0; |
150 size_t textNodes = 0; | 150 size_t textNodes = 0; |
151 size_t cdataNodes = 0; | 151 size_t cdataNodes = 0; |
152 size_t commentNodes = 0; | 152 size_t commentNodes = 0; |
153 size_t entityReferenceNodes = 0; | |
154 size_t entityNodes = 0; | 153 size_t entityNodes = 0; |
155 size_t piNodes = 0; | 154 size_t piNodes = 0; |
156 size_t documentNodes = 0; | 155 size_t documentNodes = 0; |
157 size_t docTypeNodes = 0; | 156 size_t docTypeNodes = 0; |
158 size_t fragmentNodes = 0; | 157 size_t fragmentNodes = 0; |
159 size_t notationNodes = 0; | 158 size_t notationNodes = 0; |
160 size_t xpathNSNodes = 0; | 159 size_t xpathNSNodes = 0; |
161 size_t shadowRootNodes = 0; | 160 size_t shadowRootNodes = 0; |
162 | 161 |
163 HashMap<String, size_t> perTagCount; | 162 HashMap<String, size_t> perTagCount; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 break; | 209 break; |
211 } | 210 } |
212 case CDATA_SECTION_NODE: { | 211 case CDATA_SECTION_NODE: { |
213 ++cdataNodes; | 212 ++cdataNodes; |
214 break; | 213 break; |
215 } | 214 } |
216 case COMMENT_NODE: { | 215 case COMMENT_NODE: { |
217 ++commentNodes; | 216 ++commentNodes; |
218 break; | 217 break; |
219 } | 218 } |
220 case ENTITY_REFERENCE_NODE: { | |
221 ++entityReferenceNodes; | |
222 break; | |
223 } | |
224 case ENTITY_NODE: { | 219 case ENTITY_NODE: { |
225 ++entityNodes; | 220 ++entityNodes; |
226 break; | 221 break; |
227 } | 222 } |
228 case PROCESSING_INSTRUCTION_NODE: { | 223 case PROCESSING_INSTRUCTION_NODE: { |
229 ++piNodes; | 224 ++piNodes; |
230 break; | 225 break; |
231 } | 226 } |
232 case DOCUMENT_NODE: { | 227 case DOCUMENT_NODE: { |
233 ++documentNodes; | 228 ++documentNodes; |
(...skipping 23 matching lines...) Expand all Loading... |
257 | 252 |
258 printf("Number of Nodes: %d\n\n", liveNodeSet.size()); | 253 printf("Number of Nodes: %d\n\n", liveNodeSet.size()); |
259 printf("Number of Nodes with RareData: %zu\n\n", nodesWithRareData); | 254 printf("Number of Nodes with RareData: %zu\n\n", nodesWithRareData); |
260 | 255 |
261 printf("NodeType distribution:\n"); | 256 printf("NodeType distribution:\n"); |
262 printf(" Number of Element nodes: %zu\n", elementNodes); | 257 printf(" Number of Element nodes: %zu\n", elementNodes); |
263 printf(" Number of Attribute nodes: %zu\n", attrNodes); | 258 printf(" Number of Attribute nodes: %zu\n", attrNodes); |
264 printf(" Number of Text nodes: %zu\n", textNodes); | 259 printf(" Number of Text nodes: %zu\n", textNodes); |
265 printf(" Number of CDATASection nodes: %zu\n", cdataNodes); | 260 printf(" Number of CDATASection nodes: %zu\n", cdataNodes); |
266 printf(" Number of Comment nodes: %zu\n", commentNodes); | 261 printf(" Number of Comment nodes: %zu\n", commentNodes); |
267 printf(" Number of EntityReference nodes: %zu\n", entityReferenceNodes); | |
268 printf(" Number of Entity nodes: %zu\n", entityNodes); | 262 printf(" Number of Entity nodes: %zu\n", entityNodes); |
269 printf(" Number of ProcessingInstruction nodes: %zu\n", piNodes); | 263 printf(" Number of ProcessingInstruction nodes: %zu\n", piNodes); |
270 printf(" Number of Document nodes: %zu\n", documentNodes); | 264 printf(" Number of Document nodes: %zu\n", documentNodes); |
271 printf(" Number of DocumentType nodes: %zu\n", docTypeNodes); | 265 printf(" Number of DocumentType nodes: %zu\n", docTypeNodes); |
272 printf(" Number of DocumentFragment nodes: %zu\n", fragmentNodes); | 266 printf(" Number of DocumentFragment nodes: %zu\n", fragmentNodes); |
273 printf(" Number of Notation nodes: %zu\n", notationNodes); | 267 printf(" Number of Notation nodes: %zu\n", notationNodes); |
274 printf(" Number of XPathNS nodes: %zu\n", xpathNSNodes); | 268 printf(" Number of XPathNS nodes: %zu\n", xpathNSNodes); |
275 printf(" Number of ShadowRoot nodes: %zu\n", shadowRootNodes); | 269 printf(" Number of ShadowRoot nodes: %zu\n", shadowRootNodes); |
276 | 270 |
277 printf("Element tag name distibution:\n"); | 271 printf("Element tag name distibution:\n"); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 return 0; | 483 return 0; |
490 } | 484 } |
491 | 485 |
492 String Node::nodeValue() const | 486 String Node::nodeValue() const |
493 { | 487 { |
494 return String(); | 488 return String(); |
495 } | 489 } |
496 | 490 |
497 void Node::setNodeValue(const String& /*nodeValue*/, ExceptionCode& ec) | 491 void Node::setNodeValue(const String& /*nodeValue*/, ExceptionCode& ec) |
498 { | 492 { |
499 // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly | |
500 if (isReadOnlyNode()) { | |
501 ec = NO_MODIFICATION_ALLOWED_ERR; | |
502 return; | |
503 } | |
504 | |
505 // By default, setting nodeValue has no effect. | 493 // By default, setting nodeValue has no effect. |
506 } | 494 } |
507 | 495 |
508 PassRefPtr<NodeList> Node::childNodes() | 496 PassRefPtr<NodeList> Node::childNodes() |
509 { | 497 { |
510 return ensureRareData()->ensureNodeLists()->ensureChildNodeList(this); | 498 return ensureRareData()->ensureNodeLists()->ensureChildNodeList(this); |
511 } | 499 } |
512 | 500 |
513 Node *Node::lastDescendant() const | 501 Node *Node::lastDescendant() const |
514 { | 502 { |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 void Node::checkSetPrefix(const AtomicString& prefix, ExceptionCode& ec) | 1008 void Node::checkSetPrefix(const AtomicString& prefix, ExceptionCode& ec) |
1021 { | 1009 { |
1022 // Perform error checking as required by spec for setting Node.prefix. Used
by | 1010 // Perform error checking as required by spec for setting Node.prefix. Used
by |
1023 // Element::setPrefix() and Attr::setPrefix() | 1011 // Element::setPrefix() and Attr::setPrefix() |
1024 | 1012 |
1025 if (!prefix.isEmpty() && !Document::isValidName(prefix)) { | 1013 if (!prefix.isEmpty() && !Document::isValidName(prefix)) { |
1026 ec = INVALID_CHARACTER_ERR; | 1014 ec = INVALID_CHARACTER_ERR; |
1027 return; | 1015 return; |
1028 } | 1016 } |
1029 | 1017 |
1030 if (isReadOnlyNode()) { | |
1031 ec = NO_MODIFICATION_ALLOWED_ERR; | |
1032 return; | |
1033 } | |
1034 | |
1035 // FIXME: Raise NAMESPACE_ERR if prefix is malformed per the Namespaces in X
ML specification. | 1018 // FIXME: Raise NAMESPACE_ERR if prefix is malformed per the Namespaces in X
ML specification. |
1036 | 1019 |
1037 const AtomicString& nodeNamespaceURI = namespaceURI(); | 1020 const AtomicString& nodeNamespaceURI = namespaceURI(); |
1038 if ((nodeNamespaceURI.isEmpty() && !prefix.isEmpty()) | 1021 if ((nodeNamespaceURI.isEmpty() && !prefix.isEmpty()) |
1039 || (prefix == xmlAtom && nodeNamespaceURI != XMLNames::xmlNamespaceURI))
{ | 1022 || (prefix == xmlAtom && nodeNamespaceURI != XMLNames::xmlNamespaceURI))
{ |
1040 ec = NAMESPACE_ERR; | 1023 ec = NAMESPACE_ERR; |
1041 return; | 1024 return; |
1042 } | 1025 } |
1043 // Attribute-specific checks are in Attr::setPrefix(). | 1026 // Attribute-specific checks are in Attr::setPrefix(). |
1044 } | 1027 } |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 | 1664 |
1682 case Node::ELEMENT_NODE: | 1665 case Node::ELEMENT_NODE: |
1683 if (node->hasTagName(brTag) && convertBRsToNewlines) { | 1666 if (node->hasTagName(brTag) && convertBRsToNewlines) { |
1684 isNullString = false; | 1667 isNullString = false; |
1685 content.append('\n'); | 1668 content.append('\n'); |
1686 break; | 1669 break; |
1687 } | 1670 } |
1688 // Fall through. | 1671 // Fall through. |
1689 case Node::ATTRIBUTE_NODE: | 1672 case Node::ATTRIBUTE_NODE: |
1690 case Node::ENTITY_NODE: | 1673 case Node::ENTITY_NODE: |
1691 case Node::ENTITY_REFERENCE_NODE: | |
1692 case Node::DOCUMENT_FRAGMENT_NODE: | 1674 case Node::DOCUMENT_FRAGMENT_NODE: |
1693 isNullString = false; | 1675 isNullString = false; |
1694 for (Node* child = node->firstChild(); child; child = child->nextSibling
()) { | 1676 for (Node* child = node->firstChild(); child; child = child->nextSibling
()) { |
1695 if (child->nodeType() == Node::COMMENT_NODE || child->nodeType() ==
Node::PROCESSING_INSTRUCTION_NODE) | 1677 if (child->nodeType() == Node::COMMENT_NODE || child->nodeType() ==
Node::PROCESSING_INSTRUCTION_NODE) |
1696 continue; | 1678 continue; |
1697 appendTextContent(child, convertBRsToNewlines, isNullString, content
); | 1679 appendTextContent(child, convertBRsToNewlines, isNullString, content
); |
1698 } | 1680 } |
1699 break; | 1681 break; |
1700 | 1682 |
1701 case Node::DOCUMENT_NODE: | 1683 case Node::DOCUMENT_NODE: |
(...skipping 17 matching lines...) Expand all Loading... |
1719 switch (nodeType()) { | 1701 switch (nodeType()) { |
1720 case TEXT_NODE: | 1702 case TEXT_NODE: |
1721 case CDATA_SECTION_NODE: | 1703 case CDATA_SECTION_NODE: |
1722 case COMMENT_NODE: | 1704 case COMMENT_NODE: |
1723 case PROCESSING_INSTRUCTION_NODE: | 1705 case PROCESSING_INSTRUCTION_NODE: |
1724 setNodeValue(text, ec); | 1706 setNodeValue(text, ec); |
1725 return; | 1707 return; |
1726 case ELEMENT_NODE: | 1708 case ELEMENT_NODE: |
1727 case ATTRIBUTE_NODE: | 1709 case ATTRIBUTE_NODE: |
1728 case ENTITY_NODE: | 1710 case ENTITY_NODE: |
1729 case ENTITY_REFERENCE_NODE: | |
1730 case DOCUMENT_FRAGMENT_NODE: { | 1711 case DOCUMENT_FRAGMENT_NODE: { |
1731 RefPtr<ContainerNode> container = toContainerNode(this); | 1712 RefPtr<ContainerNode> container = toContainerNode(this); |
1732 ChildListMutationScope mutation(this); | 1713 ChildListMutationScope mutation(this); |
1733 container->removeChildren(); | 1714 container->removeChildren(); |
1734 if (!text.isEmpty()) | 1715 if (!text.isEmpty()) |
1735 container->appendChild(document()->createTextNode(text), ec); | 1716 container->appendChild(document()->createTextNode(text), ec); |
1736 return; | 1717 return; |
1737 } | 1718 } |
1738 case DOCUMENT_NODE: | 1719 case DOCUMENT_NODE: |
1739 case DOCUMENT_TYPE_NODE: | 1720 case DOCUMENT_TYPE_NODE: |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 node->showTreeForThis(); | 2770 node->showTreeForThis(); |
2790 } | 2771 } |
2791 | 2772 |
2792 void showNodePath(const WebCore::Node* node) | 2773 void showNodePath(const WebCore::Node* node) |
2793 { | 2774 { |
2794 if (node) | 2775 if (node) |
2795 node->showNodePathForThis(); | 2776 node->showNodePathForThis(); |
2796 } | 2777 } |
2797 | 2778 |
2798 #endif | 2779 #endif |
OLD | NEW |