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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return true; | 177 return true; |
178 } | 178 } |
179 | 179 |
180 PassRefPtr<DocumentType> DOMImplementation::createDocumentType(const String& qua
lifiedName, | 180 PassRefPtr<DocumentType> DOMImplementation::createDocumentType(const String& qua
lifiedName, |
181 const String& publicId, const String& systemId, ExceptionState& es) | 181 const String& publicId, const String& systemId, ExceptionState& es) |
182 { | 182 { |
183 String prefix, localName; | 183 String prefix, localName; |
184 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, es)) | 184 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, es)) |
185 return 0; | 185 return 0; |
186 | 186 |
187 return DocumentType::create(0, qualifiedName, publicId, systemId); | 187 return DocumentType::create(m_document, qualifiedName, publicId, systemId); |
188 } | 188 } |
189 | 189 |
190 DOMImplementation* DOMImplementation::getInterface(const String& /*feature*/) | 190 DOMImplementation* DOMImplementation::getInterface(const String& /*feature*/) |
191 { | 191 { |
192 return 0; | 192 return 0; |
193 } | 193 } |
194 | 194 |
195 PassRefPtr<Document> DOMImplementation::createDocument(const String& namespaceUR
I, | 195 PassRefPtr<Document> DOMImplementation::createDocument(const String& namespaceUR
I, |
196 const String& qualifiedName, DocumentType* doctype, ExceptionState& es) | 196 const String& qualifiedName, DocumentType* doctype, ExceptionState& es) |
197 { | 197 { |
198 RefPtr<Document> doc; | 198 RefPtr<Document> doc; |
199 if (namespaceURI == SVGNames::svgNamespaceURI) | 199 if (namespaceURI == SVGNames::svgNamespaceURI) |
200 doc = SVGDocument::create(); | 200 doc = SVGDocument::create(); |
201 else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) | 201 else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) |
202 doc = Document::createXHTML(DocumentInit().withRegistrationContext(m_doc
ument->registrationContext())); | 202 doc = Document::createXHTML(DocumentInit().withRegistrationContext(m_doc
ument->registrationContext())); |
203 else | 203 else |
204 doc = Document::create(); | 204 doc = Document::create(); |
205 | 205 |
206 doc->setSecurityOrigin(m_document->securityOrigin()); | 206 doc->setSecurityOrigin(m_document->securityOrigin()); |
207 doc->setContextFeatures(m_document->contextFeatures()); | 207 doc->setContextFeatures(m_document->contextFeatures()); |
208 | 208 |
209 RefPtr<Node> documentElement; | 209 RefPtr<Node> documentElement; |
210 if (!qualifiedName.isEmpty()) { | 210 if (!qualifiedName.isEmpty()) { |
211 documentElement = doc->createElementNS(namespaceURI, qualifiedName, es); | 211 documentElement = doc->createElementNS(namespaceURI, qualifiedName, es); |
212 if (es.hadException()) | 212 if (es.hadException()) |
213 return 0; | 213 return 0; |
214 } | 214 } |
215 | 215 |
216 // WrongDocumentError: Raised if doctype has already been used with a differ
ent document or was | |
217 // created from a different implementation. | |
218 // Hixie's interpretation of the DOM Core spec suggests we should prefer | |
219 // other exceptions to WrongDocumentError (based on order mentioned in spec)
, | |
220 // but this matches the new DOM Core spec (http://www.w3.org/TR/domcore/). | |
221 if (doctype && doctype->document()) { | |
222 es.throwDOMException(WrongDocumentError); | |
223 return 0; | |
224 } | |
225 | |
226 if (doctype) | 216 if (doctype) |
227 doc->appendChild(doctype); | 217 doc->appendChild(doctype); |
228 if (documentElement) | 218 if (documentElement) |
229 doc->appendChild(documentElement.release()); | 219 doc->appendChild(documentElement.release()); |
230 | 220 |
231 return doc.release(); | 221 return doc.release(); |
232 } | 222 } |
233 | 223 |
234 PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&,
const String& media) | 224 PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&,
const String& media) |
235 { | 225 { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return TextDocument::create(DocumentInit(url, frame)); | 349 return TextDocument::create(DocumentInit(url, frame)); |
360 if (type == "image/svg+xml") | 350 if (type == "image/svg+xml") |
361 return SVGDocument::create(DocumentInit(url, frame)); | 351 return SVGDocument::create(DocumentInit(url, frame)); |
362 if (isXMLMIMEType(type)) | 352 if (isXMLMIMEType(type)) |
363 return Document::create(DocumentInit(url, frame)); | 353 return Document::create(DocumentInit(url, frame)); |
364 | 354 |
365 return HTMLDocument::create(DocumentInit(url, frame)); | 355 return HTMLDocument::create(DocumentInit(url, frame)); |
366 } | 356 } |
367 | 357 |
368 } | 358 } |
OLD | NEW |