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

Side by Side Diff: Source/core/dom/DOMImplementation.cpp

Issue 144063004: Add support for DOM4's XMLDocument interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove FIXME about XMLDocument.load() Created 6 years, 11 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 | « Source/core/dom/DOMImplementation.h ('k') | Source/core/dom/DOMImplementation.idl » ('j') | 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) 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 18 matching lines...) Expand all
29 #include "SVGNames.h" 29 #include "SVGNames.h"
30 #include "bindings/v8/ExceptionState.h" 30 #include "bindings/v8/ExceptionState.h"
31 #include "core/css/CSSStyleSheet.h" 31 #include "core/css/CSSStyleSheet.h"
32 #include "core/css/MediaList.h" 32 #include "core/css/MediaList.h"
33 #include "core/css/StyleSheetContents.h" 33 #include "core/css/StyleSheetContents.h"
34 #include "core/dom/ContextFeatures.h" 34 #include "core/dom/ContextFeatures.h"
35 #include "core/dom/DocumentInit.h" 35 #include "core/dom/DocumentInit.h"
36 #include "core/dom/DocumentType.h" 36 #include "core/dom/DocumentType.h"
37 #include "core/dom/Element.h" 37 #include "core/dom/Element.h"
38 #include "core/dom/ExceptionCode.h" 38 #include "core/dom/ExceptionCode.h"
39 #include "core/dom/XMLDocument.h"
39 #include "core/dom/custom/CustomElementRegistrationContext.h" 40 #include "core/dom/custom/CustomElementRegistrationContext.h"
40 #include "core/html/HTMLDocument.h" 41 #include "core/html/HTMLDocument.h"
41 #include "core/html/HTMLMediaElement.h" 42 #include "core/html/HTMLMediaElement.h"
42 #include "core/html/HTMLViewSourceDocument.h" 43 #include "core/html/HTMLViewSourceDocument.h"
43 #include "core/html/ImageDocument.h" 44 #include "core/html/ImageDocument.h"
44 #include "core/html/MediaDocument.h" 45 #include "core/html/MediaDocument.h"
45 #include "core/html/PluginDocument.h" 46 #include "core/html/PluginDocument.h"
46 #include "core/html/TextDocument.h" 47 #include "core/html/TextDocument.h"
47 #include "core/loader/FrameLoader.h" 48 #include "core/loader/FrameLoader.h"
48 #include "core/frame/Frame.h" 49 #include "core/frame/Frame.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return 0; 196 return 0;
196 197
197 return DocumentType::create(&m_document, qualifiedName, publicId, systemId); 198 return DocumentType::create(&m_document, qualifiedName, publicId, systemId);
198 } 199 }
199 200
200 DOMImplementation* DOMImplementation::getInterface(const String& /*feature*/) 201 DOMImplementation* DOMImplementation::getInterface(const String& /*feature*/)
201 { 202 {
202 return 0; 203 return 0;
203 } 204 }
204 205
205 PassRefPtr<Document> DOMImplementation::createDocument(const AtomicString& names paceURI, 206 PassRefPtr<XMLDocument> DOMImplementation::createDocument(const AtomicString& na mespaceURI,
206 const AtomicString& qualifiedName, DocumentType* doctype, ExceptionState& ex ceptionState) 207 const AtomicString& qualifiedName, DocumentType* doctype, ExceptionState& ex ceptionState)
207 { 208 {
208 RefPtr<Document> doc; 209 RefPtr<XMLDocument> doc;
209 DocumentInit init = DocumentInit::fromContext(m_document.contextDocument()); 210 DocumentInit init = DocumentInit::fromContext(m_document.contextDocument());
210 if (namespaceURI == SVGNames::svgNamespaceURI) { 211 if (namespaceURI == SVGNames::svgNamespaceURI) {
212 // FIXME: This should be an XMLDocument as per DOM4 but we need to get r id of SVGDocument first.
213 // SVGDocument no longer exists in SVG2.
211 doc = SVGDocument::create(init); 214 doc = SVGDocument::create(init);
212 } else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) { 215 } else if (namespaceURI == HTMLNames::xhtmlNamespaceURI) {
213 doc = Document::createXHTML(init.withRegistrationContext(m_document.regi strationContext())); 216 doc = XMLDocument::createXHTML(init.withRegistrationContext(m_document.r egistrationContext()));
214 } else { 217 } else {
215 doc = Document::create(init); 218 doc = XMLDocument::create(init);
216 } 219 }
217 220
218 doc->setSecurityOrigin(m_document.securityOrigin()->isolatedCopy()); 221 doc->setSecurityOrigin(m_document.securityOrigin()->isolatedCopy());
219 doc->setContextFeatures(m_document.contextFeatures()); 222 doc->setContextFeatures(m_document.contextFeatures());
220 223
221 RefPtr<Node> documentElement; 224 RefPtr<Node> documentElement;
222 if (!qualifiedName.isEmpty()) { 225 if (!qualifiedName.isEmpty()) {
223 documentElement = doc->createElementNS(namespaceURI, qualifiedName, exce ptionState); 226 documentElement = doc->createElementNS(namespaceURI, qualifiedName, exce ptionState);
224 if (exceptionState.hadException()) 227 if (exceptionState.hadException())
225 return 0; 228 return 0;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 356
354 PassRefPtr<Document> DOMImplementation::createDocument(const String& type, const DocumentInit& init, bool inViewSourceMode) 357 PassRefPtr<Document> DOMImplementation::createDocument(const String& type, const DocumentInit& init, bool inViewSourceMode)
355 { 358 {
356 if (inViewSourceMode) 359 if (inViewSourceMode)
357 return HTMLViewSourceDocument::create(init, type); 360 return HTMLViewSourceDocument::create(init, type);
358 361
359 // Plugins cannot take HTML and XHTML from us, and we don't even need to ini tialize the plugin database for those. 362 // Plugins cannot take HTML and XHTML from us, and we don't even need to ini tialize the plugin database for those.
360 if (type == "text/html") 363 if (type == "text/html")
361 return HTMLDocument::create(init); 364 return HTMLDocument::create(init);
362 if (type == "application/xhtml+xml") 365 if (type == "application/xhtml+xml")
363 return Document::createXHTML(init); 366 return XMLDocument::createXHTML(init);
364 367
365 PluginData* pluginData = 0; 368 PluginData* pluginData = 0;
366 if (init.frame() && init.frame()->page() && init.frame()->loader().allowPlug ins(NotAboutToInstantiatePlugin)) 369 if (init.frame() && init.frame()->page() && init.frame()->loader().allowPlug ins(NotAboutToInstantiatePlugin))
367 pluginData = init.frame()->page()->pluginData(); 370 pluginData = init.frame()->page()->pluginData();
368 371
369 // PDF is one image type for which a plugin can override built-in support. 372 // PDF is one image type for which a plugin can override built-in support.
370 // We do not want QuickTime to take over all image types, obviously. 373 // We do not want QuickTime to take over all image types, obviously.
371 if ((type == "application/pdf" || type == "text/pdf") && pluginData && plugi nData->supportsMimeType(type)) 374 if ((type == "application/pdf" || type == "text/pdf") && pluginData && plugi nData->supportsMimeType(type))
372 return PluginDocument::create(init); 375 return PluginDocument::create(init);
373 if (Image::supportsType(type)) 376 if (Image::supportsType(type))
374 return ImageDocument::create(init); 377 return ImageDocument::create(init);
375 378
376 // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument 379 // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument
377 if (HTMLMediaElement::supportsType(ContentType(type))) 380 if (HTMLMediaElement::supportsType(ContentType(type)))
378 return MediaDocument::create(init); 381 return MediaDocument::create(init);
379 382
380 // Everything else except text/plain can be overridden by plugins. In partic ular, Adobe SVG Viewer should be used for SVG, if installed. 383 // Everything else except text/plain can be overridden by plugins. In partic ular, Adobe SVG Viewer should be used for SVG, if installed.
381 // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle, 384 // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle,
382 // and also serves as an optimization to prevent loading the plug-in databas e in the common case. 385 // and also serves as an optimization to prevent loading the plug-in databas e in the common case.
383 if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type) ) 386 if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type) )
384 return PluginDocument::create(init); 387 return PluginDocument::create(init);
385 if (isTextMIMEType(type)) 388 if (isTextMIMEType(type))
386 return TextDocument::create(init); 389 return TextDocument::create(init);
387 if (type == "image/svg+xml") 390 if (type == "image/svg+xml")
388 return SVGDocument::create(init); 391 return SVGDocument::create(init);
389 if (isXMLMIMEType(type)) 392 if (isXMLMIMEType(type))
390 return Document::create(init); 393 return XMLDocument::create(init);
391 394
392 return HTMLDocument::create(init); 395 return HTMLDocument::create(init);
393 } 396 }
394 397
395 } 398 }
OLDNEW
« no previous file with comments | « Source/core/dom/DOMImplementation.h ('k') | Source/core/dom/DOMImplementation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698