diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/xml/DOMParser.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/xml/DOMParser.cpp')
-rw-r--r-- | Source/WebCore/xml/DOMParser.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/Source/WebCore/xml/DOMParser.cpp b/Source/WebCore/xml/DOMParser.cpp index 3e20d97eb..2f941e9d2 100644 --- a/Source/WebCore/xml/DOMParser.cpp +++ b/Source/WebCore/xml/DOMParser.cpp @@ -21,24 +21,33 @@ #include "DOMImplementation.h" #include "ExceptionCode.h" -#include <wtf/text/WTFString.h> +#include "SecurityOriginPolicy.h" namespace WebCore { -PassRefPtr<Document> DOMParser::parseFromString(const String& str, const String& contentType, ExceptionCode& ec) +inline DOMParser::DOMParser(Document& contextDocument) + : m_contextDocument(contextDocument.createWeakPtr()) { - if (contentType != "text/html" - && contentType != "text/xml" - && contentType != "application/xml" - && contentType != "application/xhtml+xml" - && contentType != "image/svg+xml") { - ec = TypeError; - return 0; - } +} - RefPtr<Document> doc = DOMImplementation::createDocument(contentType, 0, URL(), false); - doc->setContent(str); - return doc.release(); +Ref<DOMParser> DOMParser::create(Document& contextDocument) +{ + return adoptRef(*new DOMParser(contextDocument)); +} + +ExceptionOr<Ref<Document>> DOMParser::parseFromString(const String& string, const String& contentType) +{ + if (contentType != "text/html" && contentType != "text/xml" && contentType != "application/xml" && contentType != "application/xhtml+xml" && contentType != "image/svg+xml") + return Exception { TypeError }; + auto document = DOMImplementation::createDocument(contentType, nullptr, URL { }); + if (m_contextDocument) + document->setContextDocument(*m_contextDocument.get()); + document->setContent(string); + if (m_contextDocument) { + document->setURL(m_contextDocument->url()); + document->setSecurityOriginPolicy(m_contextDocument->securityOriginPolicy()); + } + return WTFMove(document); } } // namespace WebCore |