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

Side by Side Diff: Source/core/editing/markup.cpp

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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/editing/htmlediting.cpp ('k') | Source/core/events/EventTarget.cpp » ('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) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2011 Igalia S.L. 4 * Copyright (C) 2011 Igalia S.L.
5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 { 936 {
937 StringBuilder markup; 937 StringBuilder markup;
938 markup.append("<a href=\""); 938 markup.append("<a href=\"");
939 markup.append(url.string()); 939 markup.append(url.string());
940 markup.append("\">"); 940 markup.append("\">");
941 MarkupAccumulator::appendCharactersReplacingEntities(markup, title, 0, title .length(), EntityMaskInPCDATA); 941 MarkupAccumulator::appendCharactersReplacingEntities(markup, title, 0, title .length(), EntityMaskInPCDATA);
942 markup.append("</a>"); 942 markup.append("</a>");
943 return markup.toString(); 943 return markup.toString();
944 } 944 }
945 945
946 PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String& marku p, Element* contextElement, ParserContentPolicy parserContentPolicy, const char* method, ExceptionState& es) 946 PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String& marku p, Element* contextElement, ParserContentPolicy parserContentPolicy, const char* method, ExceptionState& exceptionState)
947 { 947 {
948 Document& document = contextElement->hasTagName(templateTag) ? contextElemen t->document().ensureTemplateDocument() : contextElement->document(); 948 Document& document = contextElement->hasTagName(templateTag) ? contextElemen t->document().ensureTemplateDocument() : contextElement->document();
949 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); 949 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document);
950 950
951 if (document.isHTMLDocument()) { 951 if (document.isHTMLDocument()) {
952 fragment->parseHTML(markup, contextElement, parserContentPolicy); 952 fragment->parseHTML(markup, contextElement, parserContentPolicy);
953 return fragment; 953 return fragment;
954 } 954 }
955 955
956 bool wasValid = fragment->parseXML(markup, contextElement, parserContentPoli cy); 956 bool wasValid = fragment->parseXML(markup, contextElement, parserContentPoli cy);
957 if (!wasValid) { 957 if (!wasValid) {
958 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute(met hod, "Node", "The provided markup is invalid XML, and therefore cannot be insert ed into an XML document.")); 958 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT oExecute(method, "Node", "The provided markup is invalid XML, and therefore cann ot be inserted into an XML document."));
959 return 0; 959 return 0;
960 } 960 }
961 return fragment.release(); 961 return fragment.release();
962 } 962 }
963 963
964 PassRefPtr<DocumentFragment> createFragmentForTransformToFragment(const String& sourceString, const String& sourceMIMEType, Document& outputDoc) 964 PassRefPtr<DocumentFragment> createFragmentForTransformToFragment(const String& sourceString, const String& sourceMIMEType, Document& outputDoc)
965 { 965 {
966 RefPtr<DocumentFragment> fragment = outputDoc.createDocumentFragment(); 966 RefPtr<DocumentFragment> fragment = outputDoc.createDocumentFragment();
967 967
968 if (sourceMIMEType == "text/html") { 968 if (sourceMIMEType == "text/html") {
(...skipping 20 matching lines...) Expand all
989 { 989 {
990 RefPtr<Node> nextChild; 990 RefPtr<Node> nextChild;
991 for (RefPtr<Node> child = element->firstChild(); child; child = nextChild) { 991 for (RefPtr<Node> child = element->firstChild(); child; child = nextChild) {
992 nextChild = child->nextSibling(); 992 nextChild = child->nextSibling();
993 element->removeChild(child.get()); 993 element->removeChild(child.get());
994 fragment->insertBefore(child, element); 994 fragment->insertBefore(child, element);
995 } 995 }
996 fragment->removeChild(element); 996 fragment->removeChild(element);
997 } 997 }
998 998
999 PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, HTML Element* element, ParserContentPolicy parserContentPolicy, ExceptionState& es) 999 PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, HTML Element* element, ParserContentPolicy parserContentPolicy, ExceptionState& excep tionState)
1000 { 1000 {
1001 ASSERT(element); 1001 ASSERT(element);
1002 if (element->ieForbidsInsertHTML() || element->hasLocalName(colTag) || eleme nt->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag) 1002 if (element->ieForbidsInsertHTML() || element->hasLocalName(colTag) || eleme nt->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag)
1003 || element->hasLocalName(headTag) || element->hasLocalName(styleTag) || element->hasLocalName(titleTag)) { 1003 || element->hasLocalName(headTag) || element->hasLocalName(styleTag) || element->hasLocalName(titleTag)) {
1004 es.throwDOMException(NotSupportedError, ExceptionMessages::failedToExecu te("createContextualFragment", "Range", "The range's container is '" + element-> localName() + "', which is not supported.")); 1004 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f ailedToExecute("createContextualFragment", "Range", "The range's container is '" + element->localName() + "', which is not supported."));
1005 return 0; 1005 return 0;
1006 } 1006 }
1007 1007
1008 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, element, parserContentPolicy, "createContextualFragment", es); 1008 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, element, parserContentPolicy, "createContextualFragment", exceptionState);
1009 if (!fragment) 1009 if (!fragment)
1010 return 0; 1010 return 0;
1011 1011
1012 // We need to pop <html> and <body> elements and remove <head> to 1012 // We need to pop <html> and <body> elements and remove <head> to
1013 // accommodate folks passing complete HTML documents to make the 1013 // accommodate folks passing complete HTML documents to make the
1014 // child of an element. 1014 // child of an element.
1015 1015
1016 RefPtr<Node> nextNode; 1016 RefPtr<Node> nextNode;
1017 for (RefPtr<Node> node = fragment->firstChild(); node; node = nextNode) { 1017 for (RefPtr<Node> node = fragment->firstChild(); node; node = nextNode) {
1018 nextNode = node->nextSibling(); 1018 nextNode = node->nextSibling();
1019 if (isHTMLHtmlElement(node.get()) || node->hasTagName(headTag) || node-> hasTagName(bodyTag)) { 1019 if (isHTMLHtmlElement(node.get()) || node->hasTagName(headTag) || node-> hasTagName(bodyTag)) {
1020 HTMLElement* element = toHTMLElement(node); 1020 HTMLElement* element = toHTMLElement(node);
1021 if (Node* firstChild = element->firstChild()) 1021 if (Node* firstChild = element->firstChild())
1022 nextNode = firstChild; 1022 nextNode = firstChild;
1023 removeElementPreservingChildren(fragment, element); 1023 removeElementPreservingChildren(fragment, element);
1024 } 1024 }
1025 } 1025 }
1026 return fragment.release(); 1026 return fragment.release();
1027 } 1027 }
1028 1028
1029 void replaceChildrenWithFragment(ContainerNode* container, PassRefPtr<DocumentFr agment> fragment, ExceptionState& es) 1029 void replaceChildrenWithFragment(ContainerNode* container, PassRefPtr<DocumentFr agment> fragment, ExceptionState& exceptionState)
1030 { 1030 {
1031 ASSERT(container); 1031 ASSERT(container);
1032 RefPtr<ContainerNode> containerNode(container); 1032 RefPtr<ContainerNode> containerNode(container);
1033 1033
1034 ChildListMutationScope mutation(*containerNode); 1034 ChildListMutationScope mutation(*containerNode);
1035 1035
1036 if (!fragment->firstChild()) { 1036 if (!fragment->firstChild()) {
1037 containerNode->removeChildren(); 1037 containerNode->removeChildren();
1038 return; 1038 return;
1039 } 1039 }
1040 1040
1041 if (containerNode->hasOneTextChild() && fragment->hasOneTextChild()) { 1041 if (containerNode->hasOneTextChild() && fragment->hasOneTextChild()) {
1042 toText(containerNode->firstChild())->setData(toText(fragment->firstChild ())->data()); 1042 toText(containerNode->firstChild())->setData(toText(fragment->firstChild ())->data());
1043 return; 1043 return;
1044 } 1044 }
1045 1045
1046 if (containerNode->hasOneChild()) { 1046 if (containerNode->hasOneChild()) {
1047 containerNode->replaceChild(fragment, containerNode->firstChild(), es); 1047 containerNode->replaceChild(fragment, containerNode->firstChild(), excep tionState);
1048 return; 1048 return;
1049 } 1049 }
1050 1050
1051 containerNode->removeChildren(); 1051 containerNode->removeChildren();
1052 containerNode->appendChild(fragment, es); 1052 containerNode->appendChild(fragment, exceptionState);
1053 } 1053 }
1054 1054
1055 void replaceChildrenWithText(ContainerNode* container, const String& text, Excep tionState& es) 1055 void replaceChildrenWithText(ContainerNode* container, const String& text, Excep tionState& exceptionState)
1056 { 1056 {
1057 ASSERT(container); 1057 ASSERT(container);
1058 RefPtr<ContainerNode> containerNode(container); 1058 RefPtr<ContainerNode> containerNode(container);
1059 1059
1060 ChildListMutationScope mutation(*containerNode); 1060 ChildListMutationScope mutation(*containerNode);
1061 1061
1062 if (containerNode->hasOneTextChild()) { 1062 if (containerNode->hasOneTextChild()) {
1063 toText(containerNode->firstChild())->setData(text); 1063 toText(containerNode->firstChild())->setData(text);
1064 return; 1064 return;
1065 } 1065 }
1066 1066
1067 RefPtr<Text> textNode = Text::create(containerNode->document(), text); 1067 RefPtr<Text> textNode = Text::create(containerNode->document(), text);
1068 1068
1069 if (containerNode->hasOneChild()) { 1069 if (containerNode->hasOneChild()) {
1070 containerNode->replaceChild(textNode.release(), containerNode->firstChil d(), es); 1070 containerNode->replaceChild(textNode.release(), containerNode->firstChil d(), exceptionState);
1071 return; 1071 return;
1072 } 1072 }
1073 1073
1074 containerNode->removeChildren(); 1074 containerNode->removeChildren();
1075 containerNode->appendChild(textNode.release(), es); 1075 containerNode->appendChild(textNode.release(), exceptionState);
1076 } 1076 }
1077 1077
1078 void mergeWithNextTextNode(PassRefPtr<Node> node, ExceptionState& es) 1078 void mergeWithNextTextNode(PassRefPtr<Node> node, ExceptionState& exceptionState )
1079 { 1079 {
1080 ASSERT(node && node->isTextNode()); 1080 ASSERT(node && node->isTextNode());
1081 Node* next = node->nextSibling(); 1081 Node* next = node->nextSibling();
1082 if (!next || !next->isTextNode()) 1082 if (!next || !next->isTextNode())
1083 return; 1083 return;
1084 1084
1085 RefPtr<Text> textNode = toText(node.get()); 1085 RefPtr<Text> textNode = toText(node.get());
1086 RefPtr<Text> textNext = toText(next); 1086 RefPtr<Text> textNext = toText(next);
1087 textNode->appendData(textNext->data()); 1087 textNode->appendData(textNext->data());
1088 if (textNext->parentNode()) // Might have been removed by mutation event. 1088 if (textNext->parentNode()) // Might have been removed by mutation event.
1089 textNext->remove(es); 1089 textNext->remove(exceptionState);
1090 } 1090 }
1091 1091
1092 } 1092 }
OLDNEW
« no previous file with comments | « Source/core/editing/htmlediting.cpp ('k') | Source/core/events/EventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698