Changeset 41120 in webkit
- Timestamp:
- Feb 20, 2009 4:15:33 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r41119 r41120 1 2009-02-20 Julien Chaffraix <jchaffraix@webkit.org> 2 3 Reviewed by Alexey Proskuryakov. 4 5 Bug 23940: Use Document::createElement(const QualifiedName&, bool) when creating a known element inside WebCore 6 7 Document::createElement(const QualifiedName&, bool) does not check for the prefix as opposed the the one taking an AtomicString 8 or Document::createElementNS. This is perfectly fine internally because we know the type of element created and the check is 9 unneeded. 10 11 It also removes the use of an ExceptionCode argument which was here only to check that the prefix check was fine. Finally it 12 enables us to use some generated QualifiedName. 13 14 * bindings/js/JSOptionConstructor.cpp: 15 (WebCore::constructHTMLOptionElement): 16 * dom/Document.cpp: 17 (WebCore::Document::setTitle): 18 * dom/XMLTokenizer.cpp: 19 (WebCore::createXHTMLParserErrorHeader): 20 (WebCore::XMLTokenizer::insertErrorMessageBlock): 21 * editing/CompositeEditCommand.cpp: 22 (WebCore::createBlockPlaceholderElement): 23 * editing/htmlediting.cpp: 24 (WebCore::createTabSpanElement): 25 * html/HTMLSelectElement.cpp: 26 (WebCore::HTMLSelectElement::setLength): 27 * loader/FTPDirectoryDocument.cpp: 28 (WebCore::FTPDirectoryTokenizer::appendEntry): 29 (WebCore::FTPDirectoryTokenizer::createTDForFilename): 30 (WebCore::FTPDirectoryTokenizer::loadDocumentTemplate): 31 (WebCore::FTPDirectoryTokenizer::createBasicDocument): 32 * loader/ImageDocument.cpp: 33 (WebCore::ImageDocument::createDocumentStructure): 34 * loader/MediaDocument.cpp: 35 (WebCore::MediaTokenizer::createDocumentStructure): 36 * loader/PluginDocument.cpp: 37 (WebCore::PluginTokenizer::createDocumentStructure): 38 * loader/TextDocument.cpp: 39 (WebCore::TextTokenizer::write): 40 * page/Frame.cpp: 41 (WebCore::Frame::selectionComputedStyle): 42 (WebCore::Frame::styleForSelectionStart): 43 Document::createElement(const AtomicString&, ...) to Document::createElement(const QualifiedName&, ...) switch. 44 45 * xml/XPathFunctions.cpp: 46 (WebCore::XPath::FunLang::evaluate): Re-use langAttr instead of creating a new attribute. 47 * page/DragController.cpp: 48 (WebCore::documentFragmentFromDragData): Use the HTMLAnchorElement directly to get rid of the static cast. 49 1 50 2009-02-19 Dimitri Glazkov <dglazkov@chromium.org> 2 51 -
trunk/WebCore/bindings/js/JSOptionConstructor.cpp
r40046 r41120 21 21 #include "JSOptionConstructor.h" 22 22 23 #include "HTMLNames.h" 23 24 #include "HTMLOptionElement.h" 24 25 #include "JSHTMLOptionElement.h" … … 47 48 Document* document = static_cast<JSOptionConstructor*>(constructor)->document(); 48 49 50 RefPtr<HTMLOptionElement> element = static_pointer_cast<HTMLOptionElement>(document->createElement(HTMLNames::optionTag, false)); 51 49 52 ExceptionCode ec = 0; 50 51 RefPtr<HTMLOptionElement> element = static_pointer_cast<HTMLOptionElement>(document->createElement("option", ec)); 52 RefPtr<Text> text; 53 if (ec == 0) 54 text = document->createTextNode(""); 55 if (ec == 0 && !args.at(exec, 0).isUndefined()) 53 RefPtr<Text> text = document->createTextNode(""); 54 if (!args.at(exec, 0).isUndefined()) 56 55 text->setData(args.at(exec, 0).toString(exec), ec); 57 56 if (ec == 0) -
trunk/WebCore/dom/Document.cpp
r41102 r41120 970 970 else if (!m_titleElement) { 971 971 if (HTMLElement* headElement = head()) { 972 m_titleElement = createElement(titleTag, false); 972 973 ExceptionCode ec = 0; 973 m_titleElement = createElement("title", ec);974 ASSERT(!ec);975 974 headElement->appendChild(m_titleElement, ec); 976 975 ASSERT(!ec); -
trunk/WebCore/dom/XMLTokenizer.cpp
r40087 r41120 65 65 namespace WebCore { 66 66 67 using namespace HTMLNames; 68 67 69 const int maxErrors = 25; 68 70 … … 201 203 static inline RefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const String& errorMessages) 202 204 { 205 RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), false); 206 reportElement->setAttribute(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"); 207 203 208 ExceptionCode ec = 0; 204 RefPtr<Element> reportElement = doc->createElementNS(HTMLNames::xhtmlNamespaceURI, "parsererror", ec); 205 reportElement->setAttribute(HTMLNames::styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"); 206 207 RefPtr<Element> h3 = doc->createElementNS(HTMLNames::xhtmlNamespaceURI, "h3", ec); 209 RefPtr<Element> h3 = doc->createElement(h3Tag, false); 208 210 reportElement->appendChild(h3.get(), ec); 209 211 h3->appendChild(doc->createTextNode("This page contains the following errors:"), ec); 210 211 RefPtr<Element> fixed = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "div", ec);212 213 RefPtr<Element> fixed = doc->createElement(divTag, false); 212 214 reportElement->appendChild(fixed.get(), ec); 213 fixed->setAttribute( HTMLNames::styleAttr, "font-family:monospace;font-size:12px");215 fixed->setAttribute(styleAttr, "font-family:monospace;font-size:12px"); 214 216 fixed->appendChild(doc->createTextNode(errorMessages), ec); 215 216 h3 = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "h3", ec);217 218 h3 = doc->createElement(h3Tag, false); 217 219 reportElement->appendChild(h3.get(), ec); 218 220 h3->appendChild(doc->createTextNode("Below is a rendering of the page up to the first error."), ec); … … 236 238 Node* documentElement = doc->documentElement(); 237 239 if (!documentElement) { 238 RefPtr<Node> rootElement = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "html", ec);240 RefPtr<Node> rootElement = doc->createElement(htmlTag, false); 239 241 doc->appendChild(rootElement, ec); 240 RefPtr<Node> body = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "body", ec);242 RefPtr<Node> body = doc->createElement(bodyTag, false); 241 243 rootElement->appendChild(body, ec); 242 244 documentElement = body.get(); … … 244 246 #if ENABLE(SVG) 245 247 else if (documentElement->namespaceURI() == SVGNames::svgNamespaceURI) { 246 RefPtr<Node> rootElement = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "html", ec);247 RefPtr<Node> body = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "body", ec);248 RefPtr<Node> rootElement = doc->createElement(htmlTag, false); 249 RefPtr<Node> body = doc->createElement(bodyTag, false); 248 250 rootElement->appendChild(body, ec); 249 251 body->appendChild(documentElement, ec); … … 254 256 #if ENABLE(WML) 255 257 else if (isWMLDocument()) { 256 RefPtr<Node> rootElement = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "html", ec);257 RefPtr<Node> body = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "body", ec);258 RefPtr<Node> rootElement = doc->createElement(htmlTag, false); 259 RefPtr<Node> body = doc->createElement(bodyTag, false); 258 260 rootElement->appendChild(body, ec); 259 261 body->appendChild(documentElement, ec); … … 267 269 #if ENABLE(XSLT) 268 270 if (doc->transformSourceDocument()) { 269 RefPtr<Element> par = doc->createElement NS(HTMLNames::xhtmlNamespaceURI, "p", ec);271 RefPtr<Element> par = doc->createElement(pTag, false); 270 272 reportElement->appendChild(par, ec); 271 par->setAttribute( HTMLNames::styleAttr, "white-space: normal");273 par->setAttribute(styleAttr, "white-space: normal"); 272 274 par->appendChild(doc->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."), ec); 273 275 } -
trunk/WebCore/editing/CompositeEditCommand.cpp
r41026 r41120 1034 1034 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) 1035 1035 { 1036 ExceptionCode ec = 0; 1037 RefPtr<Element> breakNode = document->createElementNS(xhtmlNamespaceURI, "br", ec); 1038 ASSERT(ec == 0); 1036 RefPtr<Element> breakNode = document->createElement(brTag, false); 1039 1037 return breakNode.release(); 1040 1038 } -
trunk/WebCore/editing/htmlediting.cpp
r40793 r41120 820 820 PassRefPtr<Element> createTabSpanElement(Document* document, PassRefPtr<Node> tabTextNode) 821 821 { 822 // make the span to hold the tab 823 ExceptionCode ec = 0; 824 RefPtr<Element> spanElement = document->createElementNS(xhtmlNamespaceURI, "span", ec); 825 ASSERT(ec == 0); 822 // Make the span to hold the tab. 823 RefPtr<Element> spanElement = document->createElement(spanTag, false); 826 824 spanElement->setAttribute(classAttr, AppleTabSpanClass); 827 825 spanElement->setAttribute(styleAttr, "white-space:pre"); 828 826 829 // add tab text to that span827 // Add tab text to that span. 830 828 if (!tabTextNode) 831 829 tabTextNode = document->createEditingTextNode("\t"); 830 831 ExceptionCode ec = 0; 832 832 spanElement->appendChild(tabTextNode, ec); 833 833 ASSERT(ec == 0); -
trunk/WebCore/html/HTMLSelectElement.cpp
r40804 r41120 1104 1104 if (diff < 0) { // add dummy elements 1105 1105 do { 1106 RefPtr<Element> option = document()->createElement("option", ec); 1107 if (!option) 1108 break; 1106 RefPtr<Element> option = document()->createElement(optionTag, false); 1107 ASSERT(option); 1109 1108 add(static_cast<HTMLElement*>(option.get()), 0, ec); 1110 1109 if (ec) -
trunk/WebCore/loader/FTPDirectoryDocument.cpp
r39601 r41120 118 118 rowElement->setAttribute("class", "ftpDirectoryEntryRow", ec); 119 119 120 RefPtr<Element> element = m_doc->createElement NS(xhtmlNamespaceURI, "td", ec);120 RefPtr<Element> element = m_doc->createElement(tdTag, false); 121 121 element->appendChild(new Text(m_doc, String(&noBreakSpace, 1)), ec); 122 122 if (isDirectory) … … 130 130 rowElement->appendChild(element, ec); 131 131 132 element = m_doc->createElement NS(xhtmlNamespaceURI, "td", ec);132 element = m_doc->createElement(tdTag, false); 133 133 element->appendChild(new Text(m_doc, date), ec); 134 134 element->setAttribute("class", "ftpDirectoryFileDate", ec); 135 135 rowElement->appendChild(element, ec); 136 136 137 element = m_doc->createElement NS(xhtmlNamespaceURI, "td", ec);137 element = m_doc->createElement(tdTag, false); 138 138 element->appendChild(new Text(m_doc, size), ec); 139 139 element->setAttribute("class", "ftpDirectoryFileSize", ec); … … 151 151 fullURL.append("/" + filename); 152 152 153 RefPtr<Element> anchorElement = m_doc->createElement NS(xhtmlNamespaceURI, "a", ec);153 RefPtr<Element> anchorElement = m_doc->createElement(aTag, false); 154 154 anchorElement->setAttribute("href", fullURL, ec); 155 155 anchorElement->appendChild(new Text(m_doc, filename), ec); 156 156 157 RefPtr<Element> tdElement = m_doc->createElement NS(xhtmlNamespaceURI, "td", ec);157 RefPtr<Element> tdElement = m_doc->createElement(tdTag, false); 158 158 tdElement->appendChild(anchorElement, ec); 159 159 … … 365 365 366 366 // Otherwise create one manually 367 tableElement = m_doc->createElement(tableTag, false); 368 m_tableElement = static_cast<HTMLTableElement*>(tableElement.get()); 367 369 ExceptionCode ec; 368 tableElement = m_doc->createElementNS(xhtmlNamespaceURI, "table", ec);369 m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());370 370 m_tableElement->setAttribute("id", "ftpDirectoryTable", ec); 371 371 … … 387 387 // FIXME: Make this "basic document" more acceptable 388 388 389 390 RefPtr<Element> bodyElement = m_doc->createElement(bodyTag, false); 391 389 392 ExceptionCode ec; 390 391 RefPtr<Element> bodyElement = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec);392 393 393 m_doc->appendChild(bodyElement, ec); 394 394 395 RefPtr<Element> tableElement = m_doc->createElement NS(xhtmlNamespaceURI, "table", ec);395 RefPtr<Element> tableElement = m_doc->createElement(tableTag, false); 396 396 m_tableElement = static_cast<HTMLTableElement*>(tableElement.get()); 397 397 m_tableElement->setAttribute("id", "ftpDirectoryTable", ec); -
trunk/WebCore/loader/ImageDocument.cpp
r39601 r41120 167 167 ExceptionCode ec; 168 168 169 RefPtr<Element> rootElement = createElementNS(xhtmlNamespaceURI, "html", ec);169 RefPtr<Element> rootElement = Document::createElement(htmlTag, false); 170 170 appendChild(rootElement, ec); 171 171 172 RefPtr<Element> body = createElementNS(xhtmlNamespaceURI, "body", ec);172 RefPtr<Element> body = Document::createElement(bodyTag, false); 173 173 body->setAttribute(styleAttr, "margin: 0px;"); 174 174 -
trunk/WebCore/loader/MediaDocument.cpp
r40675 r41120 78 78 { 79 79 ExceptionCode ec; 80 RefPtr<Element> rootElement = m_doc->createElement NS(xhtmlNamespaceURI, "html", ec);80 RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false); 81 81 m_doc->appendChild(rootElement, ec); 82 82 83 RefPtr<Element> body = m_doc->createElement NS(xhtmlNamespaceURI, "body", ec);83 RefPtr<Element> body = m_doc->createElement(bodyTag, false); 84 84 body->setAttribute(styleAttr, "background-color: rgb(38,38,38);"); 85 85 86 86 rootElement->appendChild(body, ec); 87 87 88 RefPtr<Element> mediaElement = m_doc->createElement NS(xhtmlNamespaceURI, "video", ec);88 RefPtr<Element> mediaElement = m_doc->createElement(videoTag, false); 89 89 90 90 m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get()); -
trunk/WebCore/loader/PluginDocument.cpp
r39601 r41120 73 73 { 74 74 ExceptionCode ec; 75 RefPtr<Element> rootElement = m_doc->createElement NS(xhtmlNamespaceURI, "html", ec);75 RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false); 76 76 m_doc->appendChild(rootElement, ec); 77 78 RefPtr<Element> body = m_doc->createElement NS(xhtmlNamespaceURI, "body", ec);77 78 RefPtr<Element> body = m_doc->createElement(bodyTag, false); 79 79 body->setAttribute(marginwidthAttr, "0"); 80 80 body->setAttribute(marginheightAttr, "0"); … … 83 83 rootElement->appendChild(body, ec); 84 84 85 RefPtr<Element> embedElement = m_doc->createElement NS(xhtmlNamespaceURI, "embed", ec);85 RefPtr<Element> embedElement = m_doc->createElement(embedTag, false); 86 86 87 87 m_embedElement = static_cast<HTMLEmbedElement*>(embedElement.get()); -
trunk/WebCore/loader/TextDocument.cpp
r39601 r41120 126 126 127 127 if (!m_preElement && !inViewSourceMode()) { 128 RefPtr<Element> rootElement = m_doc->createElement NS(xhtmlNamespaceURI, "html", ec);128 RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false); 129 129 m_doc->appendChild(rootElement, ec); 130 130 131 RefPtr<Element> body = m_doc->createElement NS(xhtmlNamespaceURI, "body", ec);131 RefPtr<Element> body = m_doc->createElement(bodyTag, false); 132 132 rootElement->appendChild(body, ec); 133 133 134 RefPtr<Element> preElement = m_doc->createElement NS(xhtmlNamespaceURI, "pre", ec);134 RefPtr<Element> preElement = m_doc->createElement(preTag, false); 135 135 preElement->setAttribute("style", "word-wrap: break-word; white-space: pre-wrap;", ec); 136 136 -
trunk/WebCore/page/DragController.cpp
r40793 r41120 108 108 String url = dragData->asURL(&title); 109 109 if (!url.isEmpty()) { 110 RefPtr<HTMLAnchorElement> anchor = new HTMLAnchorElement(document); 111 anchor->setHref(url); 110 112 ExceptionCode ec; 111 RefPtr<HTMLAnchorElement> anchor = static_cast<HTMLAnchorElement*>(document->createElement("a", ec).get());112 anchor->setHref(url);113 113 RefPtr<Node> anchorText = document->createTextNode(title); 114 114 anchor->appendChild(anchorText, ec); -
trunk/WebCore/page/Frame.cpp
r41066 r41120 953 953 954 954 if (m_typingStyle) { 955 styleElement = document()->createElementNS(xhtmlNamespaceURI, "span", ec); 956 ASSERT(ec == 0); 955 styleElement = document()->createElement(spanTag, false); 957 956 958 957 styleElement->setAttribute(styleAttr, m_typingStyle->cssText().impl(), ec); … … 1323 1322 return node->renderer()->style(); 1324 1323 1324 RefPtr<Element> styleElement = document()->createElement(spanTag, false); 1325 1325 1326 ExceptionCode ec = 0; 1326 RefPtr<Element> styleElement = document()->createElementNS(xhtmlNamespaceURI, "span", ec);1327 ASSERT(ec == 0);1328 1329 1327 String styleText = m_typingStyle->cssText() + " display: inline"; 1330 1328 styleElement->setAttribute(styleAttr, styleText.impl(), ec); -
trunk/WebCore/xml/XPathFunctions.cpp
r40484 r41120 540 540 NamedAttrMap* attrs = node->attributes(); 541 541 if (attrs) 542 languageAttribute = attrs->getAttributeItem( QualifiedName(nullAtom, "lang", XMLNames::xmlNamespaceURI));542 languageAttribute = attrs->getAttributeItem(XMLNames::langAttr); 543 543 if (languageAttribute) 544 544 break;
Note: See TracChangeset
for help on using the changeset viewer.