summaryrefslogtreecommitdiff
path: root/Source/WebCore/xml/DOMParser.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/xml/DOMParser.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/xml/DOMParser.cpp')
-rw-r--r--Source/WebCore/xml/DOMParser.cpp35
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