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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 DOMImplementation* DOMImplementation::getInterface(const String& /*feature*/) | 248 DOMImplementation* DOMImplementation::getInterface(const String& /*feature*/) |
249 { | 249 { |
250 return 0; | 250 return 0; |
251 } | 251 } |
252 | 252 |
253 PassRefPtr<Document> DOMImplementation::createDocument(const String& namespaceUR
I, | 253 PassRefPtr<Document> DOMImplementation::createDocument(const String& namespaceUR
I, |
254 const String& qualifiedName, DocumentType* doctype, ExceptionCode& ec) | 254 const String& qualifiedName, DocumentType* doctype, ExceptionCode& ec) |
255 { | 255 { |
256 RefPtr<Document> doc; | 256 RefPtr<Document> doc; |
257 if (namespaceURI == SVGNames::svgNamespaceURI) | 257 if (namespaceURI == SVGNames::svgNamespaceURI) |
258 doc = SVGDocument::create(0, KURL()); | 258 doc = SVGDocument::create(); |
259 else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) | 259 else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) |
260 doc = Document::createXHTML(0, KURL()); | 260 doc = Document::createXHTML(); |
261 else | 261 else |
262 doc = Document::create(0, KURL()); | 262 doc = Document::create(); |
263 | 263 |
264 doc->setSecurityOrigin(m_document->securityOrigin()); | 264 doc->setSecurityOrigin(m_document->securityOrigin()); |
265 doc->setContextFeatures(m_document->contextFeatures()); | 265 doc->setContextFeatures(m_document->contextFeatures()); |
266 | 266 |
267 RefPtr<Node> documentElement; | 267 RefPtr<Node> documentElement; |
268 if (!qualifiedName.isEmpty()) { | 268 if (!qualifiedName.isEmpty()) { |
269 documentElement = doc->createElementNS(namespaceURI, qualifiedName, ec); | 269 documentElement = doc->createElementNS(namespaceURI, qualifiedName, ec); |
270 if (ec) | 270 if (ec) |
271 return 0; | 271 return 0; |
272 } | 272 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 || mimeType == "application/json" // Render JSON as text/plain. | 365 || mimeType == "application/json" // Render JSON as text/plain. |
366 || (mimeType.startsWith("text/") && mimeType != "text/html" | 366 || (mimeType.startsWith("text/") && mimeType != "text/html" |
367 && mimeType != "text/xml" && mimeType != "text/xsl")) | 367 && mimeType != "text/xml" && mimeType != "text/xsl")) |
368 return true; | 368 return true; |
369 | 369 |
370 return false; | 370 return false; |
371 } | 371 } |
372 | 372 |
373 PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& tit
le) | 373 PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& tit
le) |
374 { | 374 { |
375 RefPtr<HTMLDocument> d = HTMLDocument::create(0, KURL()); | 375 RefPtr<HTMLDocument> d = HTMLDocument::create(); |
376 d->open(); | 376 d->open(); |
377 d->write("<!doctype html><html><body></body></html>"); | 377 d->write("<!doctype html><html><body></body></html>"); |
378 if (!title.isNull()) | 378 if (!title.isNull()) |
379 d->setTitle(title); | 379 d->setTitle(title); |
380 d->setSecurityOrigin(m_document->securityOrigin()); | 380 d->setSecurityOrigin(m_document->securityOrigin()); |
381 d->setContextFeatures(m_document->contextFeatures()); | 381 d->setContextFeatures(m_document->contextFeatures()); |
382 return d.release(); | 382 return d.release(); |
383 } | 383 } |
384 | 384 |
385 PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
* frame, const KURL& url, bool inViewSourceMode) | 385 PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
* frame, const KURL& url, bool inViewSourceMode) |
386 { | 386 { |
387 if (inViewSourceMode) | 387 if (inViewSourceMode) |
388 return HTMLViewSourceDocument::create(frame, url, type); | 388 return HTMLViewSourceDocument::create(DocumentInit(url, frame), type); |
389 | 389 |
390 // Plugins cannot take HTML and XHTML from us, and we don't even need to ini
tialize the plugin database for those. | 390 // Plugins cannot take HTML and XHTML from us, and we don't even need to ini
tialize the plugin database for those. |
391 if (type == "text/html") | 391 if (type == "text/html") |
392 return HTMLDocument::create(frame, url); | 392 return HTMLDocument::create(DocumentInit(url, frame)); |
393 if (type == "application/xhtml+xml") | 393 if (type == "application/xhtml+xml") |
394 return Document::createXHTML(frame, url); | 394 return Document::createXHTML(DocumentInit(url, frame)); |
395 | 395 |
396 PluginData* pluginData = 0; | 396 PluginData* pluginData = 0; |
397 if (frame && frame->page() && frame->loader()->subframeLoader()->allowPlugin
s(NotAboutToInstantiatePlugin)) | 397 if (frame && frame->page() && frame->loader()->subframeLoader()->allowPlugin
s(NotAboutToInstantiatePlugin)) |
398 pluginData = frame->page()->pluginData(); | 398 pluginData = frame->page()->pluginData(); |
399 | 399 |
400 // PDF is one image type for which a plugin can override built-in support. | 400 // PDF is one image type for which a plugin can override built-in support. |
401 // We do not want QuickTime to take over all image types, obviously. | 401 // We do not want QuickTime to take over all image types, obviously. |
402 if ((type == "application/pdf" || type == "text/pdf") && pluginData && plugi
nData->supportsMimeType(type)) | 402 if ((type == "application/pdf" || type == "text/pdf") && pluginData && plugi
nData->supportsMimeType(type)) |
403 return PluginDocument::create(frame, url); | 403 return PluginDocument::create(DocumentInit(url, frame)); |
404 if (Image::supportsType(type)) | 404 if (Image::supportsType(type)) |
405 return ImageDocument::create(frame, url); | 405 return ImageDocument::create(DocumentInit(url, frame)); |
406 | 406 |
407 // Check to see if the type can be played by our MediaPlayer, if so create a
MediaDocument | 407 // Check to see if the type can be played by our MediaPlayer, if so create a
MediaDocument |
408 if (HTMLMediaElement::supportsType(ContentType(type))) | 408 if (HTMLMediaElement::supportsType(ContentType(type))) |
409 return MediaDocument::create(frame, url); | 409 return MediaDocument::create(DocumentInit(url, frame)); |
410 | 410 |
411 // Everything else except text/plain can be overridden by plugins. In partic
ular, Adobe SVG Viewer should be used for SVG, if installed. | 411 // Everything else except text/plain can be overridden by plugins. In partic
ular, Adobe SVG Viewer should be used for SVG, if installed. |
412 // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a
fundamental type that the browser is expected to handle, | 412 // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a
fundamental type that the browser is expected to handle, |
413 // and also serves as an optimization to prevent loading the plug-in databas
e in the common case. | 413 // and also serves as an optimization to prevent loading the plug-in databas
e in the common case. |
414 if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)
) | 414 if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)
) |
415 return PluginDocument::create(frame, url); | 415 return PluginDocument::create(DocumentInit(url, frame)); |
416 if (isTextMIMEType(type)) | 416 if (isTextMIMEType(type)) |
417 return TextDocument::create(frame, url); | 417 return TextDocument::create(DocumentInit(url, frame)); |
418 if (type == "image/svg+xml") | 418 if (type == "image/svg+xml") |
419 return SVGDocument::create(frame, url); | 419 return SVGDocument::create(DocumentInit(url, frame)); |
420 if (isXMLMIMEType(type)) | 420 if (isXMLMIMEType(type)) |
421 return Document::create(frame, url); | 421 return Document::create(DocumentInit(url, frame)); |
422 | 422 |
423 return HTMLDocument::create(frame, url); | 423 return HTMLDocument::create(DocumentInit(url, frame)); |
424 } | 424 } |
425 | 425 |
426 } | 426 } |
OLD | NEW |