summaryrefslogtreecommitdiff
path: root/Source/WebCore/xml/XSLTProcessor.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/XSLTProcessor.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/xml/XSLTProcessor.cpp')
-rw-r--r--Source/WebCore/xml/XSLTProcessor.cpp49
1 files changed, 29 insertions, 20 deletions
diff --git a/Source/WebCore/xml/XSLTProcessor.cpp b/Source/WebCore/xml/XSLTProcessor.cpp
index cf0c15ab6..a90b96500 100644
--- a/Source/WebCore/xml/XSLTProcessor.cpp
+++ b/Source/WebCore/xml/XSLTProcessor.cpp
@@ -33,16 +33,14 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameView.h"
-#include "HTMLBodyElement.h"
#include "HTMLDocument.h"
-#include "Page.h"
#include "SecurityOrigin.h"
+#include "SecurityOriginPolicy.h"
#include "Text.h"
#include "TextResourceDecoder.h"
+#include "XMLDocument.h"
#include "markup.h"
-
#include <wtf/Assertions.h>
-#include <wtf/Vector.h>
namespace WebCore {
@@ -67,7 +65,7 @@ XSLTProcessor::~XSLTProcessor()
ASSERT(!m_stylesheetRootNode || !m_stylesheet || m_stylesheet->hasOneRef());
}
-PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
+Ref<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)
{
Ref<Document> ownerDocument(sourceNode->document());
@@ -76,10 +74,10 @@ PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourc
RefPtr<Document> result;
if (sourceMIMEType == "text/plain") {
- result = Document::create(frame, sourceIsDocument ? ownerDocument->url() : URL());
+ result = XMLDocument::createXHTML(frame, sourceIsDocument ? ownerDocument->url() : URL());
transformTextStringToXHTMLDocumentString(documentSource);
} else
- result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL(), false);
+ result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL());
// Before parsing, we need to save & detach the old document and get the new document
// in place. We have to do this only if we're rendering the result document.
@@ -90,41 +88,43 @@ PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourc
if (Document* oldDocument = frame->document()) {
result->setTransformSourceDocument(oldDocument);
result->takeDOMWindowFrom(oldDocument);
- result->setSecurityOrigin(oldDocument->securityOrigin());
+ result->setSecurityOriginPolicy(oldDocument->securityOriginPolicy());
result->setCookieURL(oldDocument->cookieURL());
result->setFirstPartyForCookies(oldDocument->firstPartyForCookies());
+ result->setStrictMixedContentMode(oldDocument->isStrictMixedContentMode());
result->contentSecurityPolicy()->copyStateFrom(oldDocument->contentSecurityPolicy());
+ result->contentSecurityPolicy()->copyUpgradeInsecureRequestStateFrom(*oldDocument->contentSecurityPolicy());
}
- frame->setDocument(result);
+ frame->setDocument(result.copyRef());
}
RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(sourceMIMEType);
decoder->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : TextEncoding(sourceEncoding), TextResourceDecoder::EncodingFromXMLHeader);
- result->setDecoder(decoder.release());
+ result->setDecoder(WTFMove(decoder));
result->setContent(documentSource);
- return result.release();
+ return result.releaseNonNull();
}
-PassRefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
+RefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
{
if (!sourceNode)
- return 0;
+ return nullptr;
String resultMIMEType;
String resultString;
String resultEncoding;
if (!transformToString(*sourceNode, resultMIMEType, resultString, resultEncoding))
- return 0;
+ return nullptr;
return createDocumentFromSource(resultString, resultEncoding, resultMIMEType, sourceNode, 0);
}
-PassRefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode, Document* outputDoc)
+RefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode, Document* outputDoc)
{
if (!sourceNode || !outputDoc)
- return 0;
+ return nullptr;
String resultMIMEType;
String resultString;
@@ -135,12 +135,15 @@ PassRefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode
resultMIMEType = "text/html";
if (!transformToString(*sourceNode, resultMIMEType, resultString, resultEncoding))
- return 0;
- return createFragmentForTransformToFragment(resultString, resultMIMEType, outputDoc);
+ return nullptr;
+ return createFragmentForTransformToFragment(*outputDoc, resultString, resultMIMEType);
}
void XSLTProcessor::setParameter(const String& /*namespaceURI*/, const String& localName, const String& value)
{
+ if (localName.isNull() || value.isNull())
+ return;
+
// FIXME: namespace support?
// should make a QualifiedName here but we'd have to expose the impl
m_parameters.set(localName, value);
@@ -148,6 +151,9 @@ void XSLTProcessor::setParameter(const String& /*namespaceURI*/, const String& l
String XSLTProcessor::getParameter(const String& /*namespaceURI*/, const String& localName) const
{
+ if (localName.isNull())
+ return { };
+
// FIXME: namespace support?
// should make a QualifiedName here but we'd have to expose the impl
return m_parameters.get(localName);
@@ -155,14 +161,17 @@ String XSLTProcessor::getParameter(const String& /*namespaceURI*/, const String&
void XSLTProcessor::removeParameter(const String& /*namespaceURI*/, const String& localName)
{
+ if (localName.isNull())
+ return;
+
// FIXME: namespace support?
m_parameters.remove(localName);
}
void XSLTProcessor::reset()
{
- m_stylesheet.clear();
- m_stylesheetRootNode.clear();
+ m_stylesheet = nullptr;
+ m_stylesheetRootNode = nullptr;
m_parameters.clear();
}