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

Side by Side Diff: third_party/WebKit/Source/core/xml/parser/XMLErrors.cpp

Issue 2002063003: Change "bool createdByParser" of createElement() to enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cestate
Patch Set: Add ImportNode Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp ('k') | no next file » | 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 10 *
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 m_errorMessages.appendLiteral(" on line "); 83 m_errorMessages.appendLiteral(" on line ");
84 m_errorMessages.appendNumber(position.m_line.oneBasedInt()); 84 m_errorMessages.appendNumber(position.m_line.oneBasedInt());
85 m_errorMessages.appendLiteral(" at column "); 85 m_errorMessages.appendLiteral(" at column ");
86 m_errorMessages.appendNumber(position.m_column.oneBasedInt()); 86 m_errorMessages.appendNumber(position.m_column.oneBasedInt());
87 m_errorMessages.appendLiteral(": "); 87 m_errorMessages.appendLiteral(": ");
88 m_errorMessages.append(message); 88 m_errorMessages.append(message);
89 } 89 }
90 90
91 static inline Element* createXHTMLParserErrorHeader(Document* doc, const String& errorMessages) 91 static inline Element* createXHTMLParserErrorHeader(Document* doc, const String& errorMessages)
92 { 92 {
93 Element* reportElement = doc->createElement(QualifiedName(nullAtom, "parsere rror", xhtmlNamespaceURI), true); 93 Element* reportElement = doc->createElement(QualifiedName(nullAtom, "parsere rror", xhtmlNamespaceURI), CreatedByParser);
94 94
95 Vector<Attribute> reportAttributes; 95 Vector<Attribute> reportAttributes;
96 reportAttributes.append(Attribute(styleAttr, "display: block; white-space: p re; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black")); 96 reportAttributes.append(Attribute(styleAttr, "display: block; white-space: p re; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"));
97 reportElement->parserSetAttributes(reportAttributes); 97 reportElement->parserSetAttributes(reportAttributes);
98 98
99 Element* h3 = doc->createElement(h3Tag, true); 99 Element* h3 = doc->createElement(h3Tag, CreatedByParser);
100 reportElement->parserAppendChild(h3); 100 reportElement->parserAppendChild(h3);
101 h3->parserAppendChild(doc->createTextNode("This page contains the following errors:")); 101 h3->parserAppendChild(doc->createTextNode("This page contains the following errors:"));
102 102
103 Element* fixed = doc->createElement(divTag, true); 103 Element* fixed = doc->createElement(divTag, CreatedByParser);
104 Vector<Attribute> fixedAttributes; 104 Vector<Attribute> fixedAttributes;
105 fixedAttributes.append(Attribute(styleAttr, "font-family:monospace;font-size :12px")); 105 fixedAttributes.append(Attribute(styleAttr, "font-family:monospace;font-size :12px"));
106 fixed->parserSetAttributes(fixedAttributes); 106 fixed->parserSetAttributes(fixedAttributes);
107 reportElement->parserAppendChild(fixed); 107 reportElement->parserAppendChild(fixed);
108 108
109 fixed->parserAppendChild(doc->createTextNode(errorMessages)); 109 fixed->parserAppendChild(doc->createTextNode(errorMessages));
110 110
111 h3 = doc->createElement(h3Tag, true); 111 h3 = doc->createElement(h3Tag, CreatedByParser);
112 reportElement->parserAppendChild(h3); 112 reportElement->parserAppendChild(h3);
113 h3->parserAppendChild(doc->createTextNode("Below is a rendering of the page up to the first error.")); 113 h3->parserAppendChild(doc->createTextNode("Below is a rendering of the page up to the first error."));
114 114
115 return reportElement; 115 return reportElement;
116 } 116 }
117 117
118 void XMLErrors::insertErrorMessageBlock() 118 void XMLErrors::insertErrorMessageBlock()
119 { 119 {
120 // One or more errors occurred during parsing of the code. Display an error block to the user above 120 // One or more errors occurred during parsing of the code. Display an error block to the user above
121 // the normal content (the DOM tree is created manually and includes line/co l info regarding 121 // the normal content (the DOM tree is created manually and includes line/co l info regarding
122 // where the errors are located) 122 // where the errors are located)
123 123
124 // Create elements for display 124 // Create elements for display
125 Element* documentElement = m_document->documentElement(); 125 Element* documentElement = m_document->documentElement();
126 if (!documentElement) { 126 if (!documentElement) {
127 Element* rootElement = m_document->createElement(htmlTag, true); 127 Element* rootElement = m_document->createElement(htmlTag, CreatedByParse r);
128 Element* body = m_document->createElement(bodyTag, true); 128 Element* body = m_document->createElement(bodyTag, CreatedByParser);
129 rootElement->parserAppendChild(body); 129 rootElement->parserAppendChild(body);
130 m_document->parserAppendChild(rootElement); 130 m_document->parserAppendChild(rootElement);
131 documentElement = body; 131 documentElement = body;
132 } else if (documentElement->namespaceURI() == SVGNames::svgNamespaceURI) { 132 } else if (documentElement->namespaceURI() == SVGNames::svgNamespaceURI) {
133 Element* rootElement = m_document->createElement(htmlTag, true); 133 Element* rootElement = m_document->createElement(htmlTag, CreatedByParse r);
134 Element* head = m_document->createElement(headTag, true); 134 Element* head = m_document->createElement(headTag, CreatedByParser);
135 Element* style = m_document->createElement(styleTag, true); 135 Element* style = m_document->createElement(styleTag, CreatedByParser);
136 head->parserAppendChild(style); 136 head->parserAppendChild(style);
137 style->parserAppendChild(m_document->createTextNode("html, body { height : 100% } parsererror + svg { width: 100%; height: 100% }")); 137 style->parserAppendChild(m_document->createTextNode("html, body { height : 100% } parsererror + svg { width: 100%; height: 100% }"));
138 style->finishParsingChildren(); 138 style->finishParsingChildren();
139 rootElement->parserAppendChild(head); 139 rootElement->parserAppendChild(head);
140 Element* body = m_document->createElement(bodyTag, true); 140 Element* body = m_document->createElement(bodyTag, CreatedByParser);
141 rootElement->parserAppendChild(body); 141 rootElement->parserAppendChild(body);
142 142
143 m_document->parserRemoveChild(*documentElement); 143 m_document->parserRemoveChild(*documentElement);
144 144
145 body->parserAppendChild(documentElement); 145 body->parserAppendChild(documentElement);
146 m_document->parserAppendChild(rootElement); 146 m_document->parserAppendChild(rootElement);
147 147
148 documentElement = body; 148 documentElement = body;
149 } 149 }
150 150
151 String errorMessages = m_errorMessages.toString(); 151 String errorMessages = m_errorMessages.toString();
152 Element* reportElement = createXHTMLParserErrorHeader(m_document, errorMessa ges); 152 Element* reportElement = createXHTMLParserErrorHeader(m_document, errorMessa ges);
153 153
154 if (DocumentXSLT::hasTransformSourceDocument(*m_document)) { 154 if (DocumentXSLT::hasTransformSourceDocument(*m_document)) {
155 Vector<Attribute> attributes; 155 Vector<Attribute> attributes;
156 attributes.append(Attribute(styleAttr, "white-space: normal")); 156 attributes.append(Attribute(styleAttr, "white-space: normal"));
157 Element* paragraph = m_document->createElement(pTag, true); 157 Element* paragraph = m_document->createElement(pTag, CreatedByParser);
158 paragraph->parserSetAttributes(attributes); 158 paragraph->parserSetAttributes(attributes);
159 paragraph->parserAppendChild(m_document->createTextNode("This document w as created as the result of an XSL transformation. The line and column numbers g iven are from the transformed result.")); 159 paragraph->parserAppendChild(m_document->createTextNode("This document w as created as the result of an XSL transformation. The line and column numbers g iven are from the transformed result."));
160 reportElement->parserAppendChild(paragraph); 160 reportElement->parserAppendChild(paragraph);
161 } 161 }
162 162
163 Node* firstChild = documentElement->firstChild(); 163 Node* firstChild = documentElement->firstChild();
164 if (firstChild) 164 if (firstChild)
165 documentElement->parserInsertBefore(reportElement, *firstChild); 165 documentElement->parserInsertBefore(reportElement, *firstChild);
166 else 166 else
167 documentElement->parserAppendChild(reportElement); 167 documentElement->parserAppendChild(reportElement);
168 168
169 // FIXME: Why do we need to call this manually? 169 // FIXME: Why do we need to call this manually?
170 m_document->updateStyleAndLayoutTree(); 170 m_document->updateStyleAndLayoutTree();
171 } 171 }
172 172
173 } // namespace blink 173 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698