From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/xml/DOMParser.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'Source/WebCore/xml/DOMParser.cpp') 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 +#include "SecurityOriginPolicy.h" namespace WebCore { -PassRefPtr 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 doc = DOMImplementation::createDocument(contentType, 0, URL(), false); - doc->setContent(str); - return doc.release(); +Ref DOMParser::create(Document& contextDocument) +{ + return adoptRef(*new DOMParser(contextDocument)); +} + +ExceptionOr> 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 -- cgit v1.2.1