| 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 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) | 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) |
| 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 * | 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "platform/weborigin/SecurityOrigin.h" | 58 #include "platform/weborigin/SecurityOrigin.h" |
| 59 #include "wtf/StdLibExtras.h" | 59 #include "wtf/StdLibExtras.h" |
| 60 | 60 |
| 61 namespace blink { | 61 namespace blink { |
| 62 | 62 |
| 63 DOMImplementation::DOMImplementation(Document& document) | 63 DOMImplementation::DOMImplementation(Document& document) |
| 64 : m_document(document) | 64 : m_document(document) |
| 65 { | 65 { |
| 66 } | 66 } |
| 67 | 67 |
| 68 PassRefPtrWillBeRawPtr<DocumentType> DOMImplementation::createDocumentType(const
AtomicString& qualifiedName, | 68 RawPtr<DocumentType> DOMImplementation::createDocumentType(const AtomicString& q
ualifiedName, |
| 69 const String& publicId, const String& systemId, ExceptionState& exceptionSta
te) | 69 const String& publicId, const String& systemId, ExceptionState& exceptionSta
te) |
| 70 { | 70 { |
| 71 AtomicString prefix, localName; | 71 AtomicString prefix, localName; |
| 72 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio
nState)) | 72 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio
nState)) |
| 73 return nullptr; | 73 return nullptr; |
| 74 | 74 |
| 75 return DocumentType::create(m_document, qualifiedName, publicId, systemId); | 75 return DocumentType::create(m_document, qualifiedName, publicId, systemId); |
| 76 } | 76 } |
| 77 | 77 |
| 78 PassRefPtrWillBeRawPtr<XMLDocument> DOMImplementation::createDocument(const Atom
icString& namespaceURI, | 78 RawPtr<XMLDocument> DOMImplementation::createDocument(const AtomicString& namesp
aceURI, |
| 79 const AtomicString& qualifiedName, DocumentType* doctype, ExceptionState& ex
ceptionState) | 79 const AtomicString& qualifiedName, DocumentType* doctype, ExceptionState& ex
ceptionState) |
| 80 { | 80 { |
| 81 RefPtrWillBeRawPtr<XMLDocument> doc = nullptr; | 81 RawPtr<XMLDocument> doc = nullptr; |
| 82 DocumentInit init = DocumentInit::fromContext(document().contextDocument()); | 82 DocumentInit init = DocumentInit::fromContext(document().contextDocument()); |
| 83 if (namespaceURI == SVGNames::svgNamespaceURI) { | 83 if (namespaceURI == SVGNames::svgNamespaceURI) { |
| 84 doc = XMLDocument::createSVG(init); | 84 doc = XMLDocument::createSVG(init); |
| 85 } else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) { | 85 } else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) { |
| 86 doc = XMLDocument::createXHTML(init.withRegistrationContext(document().r
egistrationContext())); | 86 doc = XMLDocument::createXHTML(init.withRegistrationContext(document().r
egistrationContext())); |
| 87 } else { | 87 } else { |
| 88 doc = XMLDocument::create(init); | 88 doc = XMLDocument::create(init); |
| 89 } | 89 } |
| 90 | 90 |
| 91 doc->setSecurityOrigin(document().securityOrigin()->isolatedCopy()); | 91 doc->setSecurityOrigin(document().securityOrigin()->isolatedCopy()); |
| 92 doc->setContextFeatures(document().contextFeatures()); | 92 doc->setContextFeatures(document().contextFeatures()); |
| 93 | 93 |
| 94 RefPtrWillBeRawPtr<Node> documentElement = nullptr; | 94 RawPtr<Node> documentElement = nullptr; |
| 95 if (!qualifiedName.isEmpty()) { | 95 if (!qualifiedName.isEmpty()) { |
| 96 documentElement = doc->createElementNS(namespaceURI, qualifiedName, exce
ptionState); | 96 documentElement = doc->createElementNS(namespaceURI, qualifiedName, exce
ptionState); |
| 97 if (exceptionState.hadException()) | 97 if (exceptionState.hadException()) |
| 98 return nullptr; | 98 return nullptr; |
| 99 } | 99 } |
| 100 | 100 |
| 101 if (doctype) | 101 if (doctype) |
| 102 doc->appendChild(doctype); | 102 doc->appendChild(doctype); |
| 103 if (documentElement) | 103 if (documentElement) |
| 104 doc->appendChild(documentElement.release()); | 104 doc->appendChild(documentElement.release()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 && !(equalIgnoringCase(mimeType, "text/html") | 189 && !(equalIgnoringCase(mimeType, "text/html") |
| 190 || equalIgnoringCase(mimeType, "text/xml") | 190 || equalIgnoringCase(mimeType, "text/xml") |
| 191 || equalIgnoringCase(mimeType, "text/xsl")); | 191 || equalIgnoringCase(mimeType, "text/xsl")); |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool DOMImplementation::isTextMIMEType(const String& mimeType) | 194 bool DOMImplementation::isTextMIMEType(const String& mimeType) |
| 195 { | 195 { |
| 196 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || isJSONMI
METype(mimeType) || isTextPlainType(mimeType); | 196 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || isJSONMI
METype(mimeType) || isTextPlainType(mimeType); |
| 197 } | 197 } |
| 198 | 198 |
| 199 PassRefPtrWillBeRawPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const
String& title) | 199 RawPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title) |
| 200 { | 200 { |
| 201 DocumentInit init = DocumentInit::fromContext(document().contextDocument()) | 201 DocumentInit init = DocumentInit::fromContext(document().contextDocument()) |
| 202 .withRegistrationContext(document().registrationContext()); | 202 .withRegistrationContext(document().registrationContext()); |
| 203 RefPtrWillBeRawPtr<HTMLDocument> d = HTMLDocument::create(init); | 203 RawPtr<HTMLDocument> d = HTMLDocument::create(init); |
| 204 d->open(); | 204 d->open(); |
| 205 d->write("<!doctype html><html><head></head><body></body></html>"); | 205 d->write("<!doctype html><html><head></head><body></body></html>"); |
| 206 if (!title.isNull()) { | 206 if (!title.isNull()) { |
| 207 HTMLHeadElement* headElement = d->head(); | 207 HTMLHeadElement* headElement = d->head(); |
| 208 ASSERT(headElement); | 208 ASSERT(headElement); |
| 209 RefPtrWillBeRawPtr<HTMLTitleElement> titleElement = HTMLTitleElement::cr
eate(*d); | 209 RawPtr<HTMLTitleElement> titleElement = HTMLTitleElement::create(*d); |
| 210 headElement->appendChild(titleElement); | 210 headElement->appendChild(titleElement); |
| 211 titleElement->appendChild(d->createTextNode(title), ASSERT_NO_EXCEPTION)
; | 211 titleElement->appendChild(d->createTextNode(title), ASSERT_NO_EXCEPTION)
; |
| 212 } | 212 } |
| 213 d->setSecurityOrigin(document().securityOrigin()->isolatedCopy()); | 213 d->setSecurityOrigin(document().securityOrigin()->isolatedCopy()); |
| 214 d->setContextFeatures(document().contextFeatures()); | 214 d->setContextFeatures(document().contextFeatures()); |
| 215 return d.release(); | 215 return d.release(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 PassRefPtrWillBeRawPtr<Document> DOMImplementation::createDocument(const String&
type, const DocumentInit& init, bool inViewSourceMode) | 218 RawPtr<Document> DOMImplementation::createDocument(const String& type, const Doc
umentInit& init, bool inViewSourceMode) |
| 219 { | 219 { |
| 220 if (inViewSourceMode) | 220 if (inViewSourceMode) |
| 221 return HTMLViewSourceDocument::create(init, type); | 221 return HTMLViewSourceDocument::create(init, type); |
| 222 | 222 |
| 223 // Plugins cannot take HTML and XHTML from us, and we don't even need to ini
tialize the plugin database for those. | 223 // Plugins cannot take HTML and XHTML from us, and we don't even need to ini
tialize the plugin database for those. |
| 224 if (type == "text/html") | 224 if (type == "text/html") |
| 225 return HTMLDocument::create(init); | 225 return HTMLDocument::create(init); |
| 226 if (type == "application/xhtml+xml") | 226 if (type == "application/xhtml+xml") |
| 227 return XMLDocument::createXHTML(init); | 227 return XMLDocument::createXHTML(init); |
| 228 | 228 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 255 | 255 |
| 256 return HTMLDocument::create(init); | 256 return HTMLDocument::create(init); |
| 257 } | 257 } |
| 258 | 258 |
| 259 DEFINE_TRACE(DOMImplementation) | 259 DEFINE_TRACE(DOMImplementation) |
| 260 { | 260 { |
| 261 visitor->trace(m_document); | 261 visitor->trace(m_document); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace blink | 264 } // namespace blink |
| OLD | NEW |