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

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

Issue 739433003: Remove CDATASection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 10 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/Document.h ('k') | Source/core/dom/Document.idl » ('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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "core/css/StyleSheetContents.h" 53 #include "core/css/StyleSheetContents.h"
54 #include "core/css/StyleSheetList.h" 54 #include "core/css/StyleSheetList.h"
55 #include "core/css/invalidation/StyleInvalidator.h" 55 #include "core/css/invalidation/StyleInvalidator.h"
56 #include "core/css/parser/CSSParser.h" 56 #include "core/css/parser/CSSParser.h"
57 #include "core/css/resolver/FontBuilder.h" 57 #include "core/css/resolver/FontBuilder.h"
58 #include "core/css/resolver/StyleResolver.h" 58 #include "core/css/resolver/StyleResolver.h"
59 #include "core/css/resolver/StyleResolverStats.h" 59 #include "core/css/resolver/StyleResolverStats.h"
60 #include "core/dom/AXObjectCache.h" 60 #include "core/dom/AXObjectCache.h"
61 #include "core/dom/AddConsoleMessageTask.h" 61 #include "core/dom/AddConsoleMessageTask.h"
62 #include "core/dom/Attr.h" 62 #include "core/dom/Attr.h"
63 #include "core/dom/CDATASection.h"
64 #include "core/dom/ClientRect.h" 63 #include "core/dom/ClientRect.h"
65 #include "core/dom/Comment.h" 64 #include "core/dom/Comment.h"
66 #include "core/dom/ContextFeatures.h" 65 #include "core/dom/ContextFeatures.h"
67 #include "core/dom/DOMImplementation.h" 66 #include "core/dom/DOMImplementation.h"
68 #include "core/dom/DocumentFragment.h" 67 #include "core/dom/DocumentFragment.h"
69 #include "core/dom/DocumentLifecycleNotifier.h" 68 #include "core/dom/DocumentLifecycleNotifier.h"
70 #include "core/dom/DocumentLifecycleObserver.h" 69 #include "core/dom/DocumentLifecycleObserver.h"
71 #include "core/dom/DocumentMarkerController.h" 70 #include "core/dom/DocumentMarkerController.h"
72 #include "core/dom/DocumentType.h" 71 #include "core/dom/DocumentType.h"
73 #include "core/dom/Element.h" 72 #include "core/dom/Element.h"
(...skipping 13 matching lines...) Expand all
87 #include "core/dom/NodeRenderingTraversal.h" 86 #include "core/dom/NodeRenderingTraversal.h"
88 #include "core/dom/NodeTraversal.h" 87 #include "core/dom/NodeTraversal.h"
89 #include "core/dom/NodeWithIndex.h" 88 #include "core/dom/NodeWithIndex.h"
90 #include "core/dom/ProcessingInstruction.h" 89 #include "core/dom/ProcessingInstruction.h"
91 #include "core/dom/RequestAnimationFrameCallback.h" 90 #include "core/dom/RequestAnimationFrameCallback.h"
92 #include "core/dom/ScriptRunner.h" 91 #include "core/dom/ScriptRunner.h"
93 #include "core/dom/ScriptedAnimationController.h" 92 #include "core/dom/ScriptedAnimationController.h"
94 #include "core/dom/SelectorQuery.h" 93 #include "core/dom/SelectorQuery.h"
95 #include "core/dom/StaticNodeList.h" 94 #include "core/dom/StaticNodeList.h"
96 #include "core/dom/StyleEngine.h" 95 #include "core/dom/StyleEngine.h"
96 #include "core/dom/Text.h"
97 #include "core/dom/TouchList.h" 97 #include "core/dom/TouchList.h"
98 #include "core/dom/TransformSource.h" 98 #include "core/dom/TransformSource.h"
99 #include "core/dom/TreeWalker.h" 99 #include "core/dom/TreeWalker.h"
100 #include "core/dom/VisitedLinkState.h" 100 #include "core/dom/VisitedLinkState.h"
101 #include "core/dom/XMLDocument.h" 101 #include "core/dom/XMLDocument.h"
102 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" 102 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
103 #include "core/dom/custom/CustomElementRegistrationContext.h" 103 #include "core/dom/custom/CustomElementRegistrationContext.h"
104 #include "core/dom/shadow/ElementShadow.h" 104 #include "core/dom/shadow/ElementShadow.h"
105 #include "core/dom/shadow/ShadowRoot.h" 105 #include "core/dom/shadow/ShadowRoot.h"
106 #include "core/editing/Editor.h" 106 #include "core/editing/Editor.h"
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 PassRefPtrWillBeRawPtr<Text> Document::createTextNode(const String& data) 878 PassRefPtrWillBeRawPtr<Text> Document::createTextNode(const String& data)
879 { 879 {
880 return Text::create(*this, data); 880 return Text::create(*this, data);
881 } 881 }
882 882
883 PassRefPtrWillBeRawPtr<Comment> Document::createComment(const String& data) 883 PassRefPtrWillBeRawPtr<Comment> Document::createComment(const String& data)
884 { 884 {
885 return Comment::create(*this, data); 885 return Comment::create(*this, data);
886 } 886 }
887 887
888 PassRefPtrWillBeRawPtr<CDATASection> Document::createCDATASection(const String& data, ExceptionState& exceptionState)
889 {
890 if (isHTMLDocument()) {
891 exceptionState.throwDOMException(NotSupportedError, "This operation is n ot supported for HTML documents.");
892 return nullptr;
893 }
894 if (data.contains("]]>")) {
895 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c ontain ']]>' since that is the end delimiter of a CData section.");
896 return nullptr;
897 }
898 return CDATASection::create(*this, data);
899 }
900
901 PassRefPtrWillBeRawPtr<ProcessingInstruction> Document::createProcessingInstruct ion(const String& target, const String& data, ExceptionState& exceptionState) 888 PassRefPtrWillBeRawPtr<ProcessingInstruction> Document::createProcessingInstruct ion(const String& target, const String& data, ExceptionState& exceptionState)
902 { 889 {
903 if (!isValidName(target)) { 890 if (!isValidName(target)) {
904 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name."); 891 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name.");
905 return nullptr; 892 return nullptr;
906 } 893 }
907 if (data.contains("?>")) { 894 if (data.contains("?>")) {
908 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'."); 895 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'.");
909 return nullptr; 896 return nullptr;
910 } 897 }
(...skipping 17 matching lines...) Expand all
928 } 915 }
929 916
930 return true; 917 return true;
931 } 918 }
932 919
933 PassRefPtrWillBeRawPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionState& exceptionState) 920 PassRefPtrWillBeRawPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionState& exceptionState)
934 { 921 {
935 switch (importedNode->nodeType()) { 922 switch (importedNode->nodeType()) {
936 case TEXT_NODE: 923 case TEXT_NODE:
937 return createTextNode(importedNode->nodeValue()); 924 return createTextNode(importedNode->nodeValue());
938 case CDATA_SECTION_NODE:
939 return CDATASection::create(*this, importedNode->nodeValue());
940 case PROCESSING_INSTRUCTION_NODE: 925 case PROCESSING_INSTRUCTION_NODE:
941 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState); 926 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState);
942 case COMMENT_NODE: 927 case COMMENT_NODE:
943 return createComment(importedNode->nodeValue()); 928 return createComment(importedNode->nodeValue());
944 case DOCUMENT_TYPE_NODE: { 929 case DOCUMENT_TYPE_NODE: {
945 DocumentType* doctype = toDocumentType(importedNode); 930 DocumentType* doctype = toDocumentType(importedNode);
946 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId()); 931 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId());
947 } 932 }
948 case ELEMENT_NODE: { 933 case ELEMENT_NODE: {
949 Element* oldElement = toElement(importedNode); 934 Element* oldElement = toElement(importedNode);
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 updateHoverActiveState(request, result.innerElement(), &event); 3126 updateHoverActiveState(request, result.innerElement(), &event);
3142 3127
3143 return MouseEventWithHitTestResults(event, result); 3128 return MouseEventWithHitTestResults(event, result);
3144 } 3129 }
3145 3130
3146 // DOM Section 1.1.1 3131 // DOM Section 1.1.1
3147 bool Document::childTypeAllowed(NodeType type) const 3132 bool Document::childTypeAllowed(NodeType type) const
3148 { 3133 {
3149 switch (type) { 3134 switch (type) {
3150 case ATTRIBUTE_NODE: 3135 case ATTRIBUTE_NODE:
3151 case CDATA_SECTION_NODE:
3152 case DOCUMENT_FRAGMENT_NODE: 3136 case DOCUMENT_FRAGMENT_NODE:
3153 case DOCUMENT_NODE: 3137 case DOCUMENT_NODE:
3154 case TEXT_NODE: 3138 case TEXT_NODE:
3155 return false; 3139 return false;
3156 case COMMENT_NODE: 3140 case COMMENT_NODE:
3157 case PROCESSING_INSTRUCTION_NODE: 3141 case PROCESSING_INSTRUCTION_NODE:
3158 return true; 3142 return true;
3159 case DOCUMENT_TYPE_NODE: 3143 case DOCUMENT_TYPE_NODE:
3160 case ELEMENT_NODE: 3144 case ELEMENT_NODE:
3161 // Documents may contain no more than one of each of these. 3145 // Documents may contain no more than one of each of these.
(...skipping 30 matching lines...) Expand all
3192 default: 3176 default:
3193 break; 3177 break;
3194 } 3178 }
3195 } 3179 }
3196 3180
3197 // Then, see how many doctypes and elements might be added by the new child. 3181 // Then, see how many doctypes and elements might be added by the new child.
3198 if (newChild.isDocumentFragment()) { 3182 if (newChild.isDocumentFragment()) {
3199 for (Node& child : NodeTraversal::childrenOf(toDocumentFragment(newChild ))) { 3183 for (Node& child : NodeTraversal::childrenOf(toDocumentFragment(newChild ))) {
3200 switch (child.nodeType()) { 3184 switch (child.nodeType()) {
3201 case ATTRIBUTE_NODE: 3185 case ATTRIBUTE_NODE:
3202 case CDATA_SECTION_NODE:
3203 case DOCUMENT_FRAGMENT_NODE: 3186 case DOCUMENT_FRAGMENT_NODE:
3204 case DOCUMENT_NODE: 3187 case DOCUMENT_NODE:
3205 case TEXT_NODE: 3188 case TEXT_NODE:
3206 exceptionState.throwDOMException(HierarchyRequestError, "Nodes o f type '" + newChild.nodeName() + 3189 exceptionState.throwDOMException(HierarchyRequestError, "Nodes o f type '" + newChild.nodeName() +
3207 "' may not be inserted inside nodes of type '#document'."); 3190 "' may not be inserted inside nodes of type '#document'.");
3208 return false; 3191 return false;
3209 case COMMENT_NODE: 3192 case COMMENT_NODE:
3210 case PROCESSING_INSTRUCTION_NODE: 3193 case PROCESSING_INSTRUCTION_NODE:
3211 break; 3194 break;
3212 case DOCUMENT_TYPE_NODE: 3195 case DOCUMENT_TYPE_NODE:
3213 numDoctypes++; 3196 numDoctypes++;
3214 break; 3197 break;
3215 case ELEMENT_NODE: 3198 case ELEMENT_NODE:
3216 numElements++; 3199 numElements++;
3217 break; 3200 break;
3218 } 3201 }
3219 } 3202 }
3220 } else { 3203 } else {
3221 switch (newChild.nodeType()) { 3204 switch (newChild.nodeType()) {
3222 case ATTRIBUTE_NODE: 3205 case ATTRIBUTE_NODE:
3223 case CDATA_SECTION_NODE:
3224 case DOCUMENT_FRAGMENT_NODE: 3206 case DOCUMENT_FRAGMENT_NODE:
3225 case DOCUMENT_NODE: 3207 case DOCUMENT_NODE:
3226 case TEXT_NODE: 3208 case TEXT_NODE:
3227 exceptionState.throwDOMException(HierarchyRequestError, "Nodes of ty pe '" + newChild.nodeName() + 3209 exceptionState.throwDOMException(HierarchyRequestError, "Nodes of ty pe '" + newChild.nodeName() +
3228 "' may not be inserted inside nodes of type '#document'."); 3210 "' may not be inserted inside nodes of type '#document'.");
3229 return false; 3211 return false;
3230 case COMMENT_NODE: 3212 case COMMENT_NODE:
3231 case PROCESSING_INSTRUCTION_NODE: 3213 case PROCESSING_INSTRUCTION_NODE:
3232 return true; 3214 return true;
3233 case DOCUMENT_TYPE_NODE: 3215 case DOCUMENT_TYPE_NODE:
(...skipping 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after
5773 #ifndef NDEBUG 5755 #ifndef NDEBUG
5774 using namespace blink; 5756 using namespace blink;
5775 void showLiveDocumentInstances() 5757 void showLiveDocumentInstances()
5776 { 5758 {
5777 WeakDocumentSet& set = liveDocumentSet(); 5759 WeakDocumentSet& set = liveDocumentSet();
5778 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5760 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5779 for (Document* document : set) 5761 for (Document* document : set)
5780 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5762 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5781 } 5763 }
5782 #endif 5764 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698