[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
hausmann at webkit.org
hausmann at webkit.org
Thu Oct 29 20:35:11 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 06b7e555bd46c112597ea23b3aff0fcf5886a050
Author: hausmann at webkit.org <hausmann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Sep 28 20:11:36 2009 +0000
[Qt] Implement XSLT support with QtXmlPatterns.
https://bugs.webkit.org/show_bug.cgi?id=28303
Patch by Jakub Wieczorek <faw217 at gmail.com> on 2009-09-28
Reviewed by Simon Hausmann.
JavaScriptCore:
* wtf/Platform.h: Add a WTF_USE_QXMLQUERY #define.
WebCore:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCoreSources.bkl:
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::~Document):
(WebCore::Document::setTransformSource):
* dom/Document.h:
(WebCore::Document::transformSource):
* dom/TransformSource.h: Added.
(WebCore::TransformSource::platformSource):
* dom/TransformSourceLibxslt.cpp: Added.
(WebCore::TransformSource::TransformSource): Wraps a libxml2 document.
(WebCore::TransformSource::~TransformSource):
* dom/TransformSourceQt.cpp: Added.
(WebCore::TransformSource::TransformSource): Wraps a plain string.
(WebCore::TransformSource::~TransformSource):
* dom/XMLTokenizerLibxml2.cpp:
(WebCore::XMLTokenizer::doEnd):
* dom/XMLTokenizerQt.cpp:
(WebCore::XMLTokenizer::doEnd):
(WebCore::XMLTokenizer::parseProcessingInstruction):
* xml/XSLStyleSheet.h:
(WebCore::XSLStyleSheet::sheetString):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::document):
* xml/XSLStyleSheetQt.cpp: Added.
* xml/XSLTProcessor.h:
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::xmlDocPtrFromNode):
* xml/XSLTProcessorQt.cpp: Added.
(WebCore::XSLTMessageHandler::XSLTMessageHandler): A subclass of QAbstractMessageHandler.
(WebCore::XSLTMessageHandler::handleMessage): Forwards all processor messages to the Console.
(WebCore::XSLTProcessor::transformToString): Uses QXmlQuery.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48826 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 0286acd..671d8f1 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,12 @@
+2009-09-28 Jakub Wieczorek <faw217 at gmail.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Implement XSLT support with QtXmlPatterns.
+ https://bugs.webkit.org/show_bug.cgi?id=28303
+
+ * wtf/Platform.h: Add a WTF_USE_QXMLQUERY #define.
+
2009-09-28 Yongjun Zhang <yongjun.zhang at nokia.com>
Reviewed by Eric Seidel.
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h
index 576e986..9fbfa85 100644
--- a/JavaScriptCore/wtf/Platform.h
+++ b/JavaScriptCore/wtf/Platform.h
@@ -777,11 +777,11 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#define ENABLE_PAN_SCROLLING 1
#endif
-/* Use the QtXmlStreamReader implementation for XMLTokenizer */
+/* Use the QXmlStreamReader implementation for XMLTokenizer */
+/* Use the QXmlQuery implementation for XSLTProcessor */
#if PLATFORM(QT)
-#if !ENABLE(XSLT)
#define WTF_USE_QXMLSTREAM 1
-#endif
+#define WTF_USE_QXMLQUERY 1
#endif
#if !PLATFORM(QT)
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8623793..d8f07c1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2009-09-28 Jakub Wieczorek <faw217 at gmail.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Implement XSLT support with QtXmlPatterns.
+ https://bugs.webkit.org/show_bug.cgi?id=28303
+
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCoreSources.bkl:
+ * dom/Document.cpp:
+ (WebCore::Document::Document):
+ (WebCore::Document::~Document):
+ (WebCore::Document::setTransformSource):
+ * dom/Document.h:
+ (WebCore::Document::transformSource):
+ * dom/TransformSource.h: Added.
+ (WebCore::TransformSource::platformSource):
+ * dom/TransformSourceLibxslt.cpp: Added.
+ (WebCore::TransformSource::TransformSource): Wraps a libxml2 document.
+ (WebCore::TransformSource::~TransformSource):
+ * dom/TransformSourceQt.cpp: Added.
+ (WebCore::TransformSource::TransformSource): Wraps a plain string.
+ (WebCore::TransformSource::~TransformSource):
+ * dom/XMLTokenizerLibxml2.cpp:
+ (WebCore::XMLTokenizer::doEnd):
+ * dom/XMLTokenizerQt.cpp:
+ (WebCore::XMLTokenizer::doEnd):
+ (WebCore::XMLTokenizer::parseProcessingInstruction):
+ * xml/XSLStyleSheet.h:
+ (WebCore::XSLStyleSheet::sheetString):
+ * xml/XSLStyleSheetLibxslt.cpp:
+ (WebCore::XSLStyleSheet::document):
+ * xml/XSLStyleSheetQt.cpp: Added.
+ * xml/XSLTProcessor.h:
+ * xml/XSLTProcessorLibxslt.cpp:
+ (WebCore::xmlDocPtrFromNode):
+ * xml/XSLTProcessorQt.cpp: Added.
+ (WebCore::XSLTMessageHandler::XSLTMessageHandler): A subclass of QAbstractMessageHandler.
+ (WebCore::XSLTMessageHandler::handleMessage): Forwards all processor messages to the Console.
+ (WebCore::XSLTProcessor::transformToString): Uses QXmlQuery.
+
2009-09-28 Yongjun Zhang <yongjun.zhang at nokia.com>
Reviewed by Eric Seidel.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 77b9dd3..e6bd1ed 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -2410,6 +2410,8 @@ FEATURE_DEFINES_JAVASCRIPT += ENABLE_XSLT=1
webcore_cppflags += -DENABLE_XSLT=1
webcore_sources += \
+ WebCore/dom/TransformSourceLibxslt.cpp \
+ WebCore/dom/TransformSource.h \
WebCore/xml/XSLImportRule.cpp \
WebCore/xml/XSLImportRule.h \
WebCore/xml/XSLStyleSheetLibxslt.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 6836b75..6d03260 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1110,6 +1110,8 @@
'dom/TextEvent.cpp',
'dom/TextEvent.h',
'dom/Tokenizer.h',
+ 'dom/TransformSourceLibxslt.cpp',
+ 'dom/TransformSource.h',
'dom/Traversal.cpp',
'dom/Traversal.h',
'dom/TreeWalker.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index ff92afe..3af0827 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -127,7 +127,6 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
!contains(DEFINES, ENABLE_DASHBOARD_SUPPORT=.): DEFINES += ENABLE_DASHBOARD_SUPPORT=0
!contains(DEFINES, ENABLE_FILTERS=.): DEFINES += ENABLE_FILTERS=0
!contains(DEFINES, ENABLE_XPATH=.): DEFINES += ENABLE_XPATH=1
-!contains(DEFINES, ENABLE_XSLT=.): DEFINES += ENABLE_XSLT=0
#!contains(DEFINES, ENABLE_XBL=.): DEFINES += ENABLE_XBL=1
!contains(DEFINES, ENABLE_WCSS=.): DEFINES += ENABLE_WCSS=0
!contains(DEFINES, ENABLE_WML=.): DEFINES += ENABLE_WML=0
@@ -172,6 +171,12 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
# Web Socket support.
!contains(DEFINES, ENABLE_WEB_SOCKETS=.): DEFINES += ENABLE_WEB_SOCKETS=1
+# XSLT support with QtXmlPatterns
+!contains(DEFINES, ENABLE_XSLT=.) {
+ contains(QT_CONFIG, xmlpatterns):!lessThan(QT_MINOR_VERSION, 5):DEFINES += ENABLE_XSLT=1
+ else:DEFINES += ENABLE_XSLT=0
+}
+
DEFINES += WTF_USE_JAVASCRIPTCORE_BINDINGS=1 WTF_CHANGES=1
# Used to compute defaults for the build-webkit script
@@ -908,7 +913,6 @@ SOURCES += \
dom/WheelEvent.cpp \
dom/XMLTokenizer.cpp \
dom/XMLTokenizerQt.cpp \
- dom/XMLTokenizerScope.cpp \
dom/default/PlatformMessagePortChannel.cpp \
editing/AppendNodeCommand.cpp \
editing/ApplyStyleCommand.cpp \
@@ -1568,6 +1572,7 @@ HEADERS += \
dom/TagNodeList.h \
dom/TextEvent.h \
dom/Text.h \
+ dom/TransformSource.h \
dom/Traversal.h \
dom/TreeWalker.h \
dom/UIEvent.h \
@@ -1576,7 +1581,6 @@ HEADERS += \
dom/WebKitTransitionEvent.h \
dom/WheelEvent.h \
dom/XMLTokenizer.h \
- dom/XMLTokenizerScope.h \
editing/AppendNodeCommand.h \
editing/ApplyStyleCommand.h \
editing/BreakBlockquoteCommand.h \
@@ -2714,25 +2718,16 @@ unix:!mac:CONFIG += link_pkgconfig
contains(DEFINES, ENABLE_XSLT=1) {
FEATURE_DEFINES_JAVASCRIPT += ENABLE_XSLT=1
- PKGCONFIG += libxml-2.0 libxslt
- macx {
- INCLUDEPATH += /usr/include/libxml2
- LIBS += -lxml2 -lxslt
- }
-
- win32-msvc* {
- LIBS += -llibxml2 -llibxslt
- }
+ QT += xmlpatterns
SOURCES += \
bindings/js/JSXSLTProcessorConstructor.cpp \
bindings/js/JSXSLTProcessorCustom.cpp \
- xml/XSLImportRule.cpp \
- xml/XSLStyleSheet.cpp \
- xml/XSLTExtensions.cpp \
+ dom/TransformSourceQt.cpp \
+ xml/XSLStyleSheetQt.cpp \
xml/XSLTProcessor.cpp \
- xml/XSLTUnicodeSort.cpp
+ xml/XSLTProcessorQt.cpp
}
contains(DEFINES, ENABLE_XBL=1) {
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 3dd41cc..18e6462 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -24476,6 +24476,14 @@
>
</File>
<File
+ RelativePath="..\dom\TransformSourceLibxslt.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\dom\TransformSource.h"
+ >
+ </File>
+ <File
RelativePath="..\dom\Traversal.cpp"
>
</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 36387e2..a926deb 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1544,6 +1544,8 @@
854FE7370A2297BE0058D7AD /* Traversal.h in Headers */ = {isa = PBXBuildFile; fileRef = 854FE72D0A2297BE0058D7AD /* Traversal.h */; };
854FE7380A2297BE0058D7AD /* TreeWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */; };
854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = 854FE72F0A2297BE0058D7AD /* TreeWalker.h */; };
+ 854FE7400A2297BE0058D7AD /* TransformSourceLibxslt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 854FE72G0A2297BE0058D7AD /* TransformSourceLibxslt.cpp */; };
+ 854FE7410A2297BE0058D7AD /* TransformSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 854FE72H0A2297BE0058D7AD /* TransformSource.h */; };
855247CF0AD850B80012093B /* DOMHTMLAppletElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 855247CD0AD850B80012093B /* DOMHTMLAppletElementInternal.h */; };
855247D00AD850B80012093B /* DOMHTMLEmbedElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 855247CE0AD850B80012093B /* DOMHTMLEmbedElementInternal.h */; };
85526C370AB0A17E000302EA /* DOMNodeIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 85526C350AB0A17E000302EA /* DOMNodeIterator.h */; };
@@ -6773,6 +6775,8 @@
854FE72D0A2297BE0058D7AD /* Traversal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Traversal.h; sourceTree = "<group>"; };
854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TreeWalker.cpp; sourceTree = "<group>"; };
854FE72F0A2297BE0058D7AD /* TreeWalker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TreeWalker.h; sourceTree = "<group>"; };
+ 854FE72G0A2297BE0058D7AD /* TransformSourceLibxslt.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TransformSourceLibxslt.cpp; sourceTree = "<group>"; };
+ 854FE72H0A2297BE0058D7AD /* TransformSource.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TransformSource.h; sourceTree = "<group>"; };
855247CD0AD850B80012093B /* DOMHTMLAppletElementInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLAppletElementInternal.h; sourceTree = "<group>"; };
855247CE0AD850B80012093B /* DOMHTMLEmbedElementInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLEmbedElementInternal.h; sourceTree = "<group>"; };
85526C350AB0A17E000302EA /* DOMNodeIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMNodeIterator.h; sourceTree = "<group>"; };
@@ -15476,6 +15480,8 @@
854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */,
854FE72F0A2297BE0058D7AD /* TreeWalker.h */,
1A750D3C0A90DE35000FF215 /* TreeWalker.idl */,
+ 854FE72G0A2297BE0058D7AD /* TransformSourceLibxslt.cpp */,
+ 854FE72H0A2297BE0058D7AD /* TransformSource.h */,
85031B370A44EFC700F992E0 /* UIEvent.cpp */,
85031B380A44EFC700F992E0 /* UIEvent.h */,
141B94EE09EC425A000E9413 /* UIEvent.idl */,
@@ -19799,6 +19805,7 @@
49E911C30EF86D47009D0CAF /* TransformationMatrix.cpp in Sources */,
B27535580B053814002CE64F /* TransformationMatrixCG.cpp in Sources */,
49E911CF0EF86D47009D0CAF /* TransformOperations.cpp in Sources */,
+ 854FE7400A2297BE0058D7AD /* TransformSourceLibxslt.cpp in Sources */,
0F500AB10F54DB3100EEF928 /* TransformState.cpp in Sources */,
49E911D10EF86D47009D0CAF /* TranslateTransformOperation.cpp in Sources */,
854FE7360A2297BE0058D7AD /* Traversal.cpp in Sources */,
diff --git a/WebCore/WebCoreSources.bkl b/WebCore/WebCoreSources.bkl
index e78b804..30e1700 100644
--- a/WebCore/WebCoreSources.bkl
+++ b/WebCore/WebCoreSources.bkl
@@ -507,6 +507,7 @@ This file contains the list of files needed to build WebCore.
dom/TagNodeList.cpp
dom/Text.cpp
dom/TextEvent.cpp
+ dom/TransformSourceLibxslt.cpp
dom/Traversal.cpp
dom/TreeWalker.cpp
dom/UIEvent.cpp
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 174c0ee..7e7477d 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -116,6 +116,7 @@
#include "TextIterator.h"
#include "TextResourceDecoder.h"
#include "Timer.h"
+#include "TransformSource.h"
#include "TreeWalker.h"
#include "UIEvent.h"
#include "WebKitAnimationEvent.h"
@@ -321,9 +322,6 @@ Document::Document(Frame* frame, bool isXHTML)
, m_titleSetExplicitly(false)
, m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired)
, m_executeScriptSoonTimer(this, &Document::executeScriptSoonTimerFired)
-#if ENABLE(XSLT)
- , m_transformSource(0)
-#endif
, m_xmlVersion("1.0")
, m_xmlStandalone(false)
#if ENABLE(XBL)
@@ -487,10 +485,6 @@ Document::~Document()
m_renderArena = 0;
}
-#if ENABLE(XSLT)
- xmlFreeDoc((xmlDocPtr)m_transformSource);
-#endif
-
#if ENABLE(XBL)
delete m_bindingManager;
#endif
@@ -3850,13 +3844,11 @@ void Document::applyXSLTransform(ProcessingInstruction* pi)
processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, frame());
}
-void Document::setTransformSource(void* doc)
+void Document::setTransformSource(PassOwnPtr<TransformSource> source)
{
- if (doc == m_transformSource)
+ if (m_transformSource == source)
return;
-
- xmlFreeDoc((xmlDocPtr)m_transformSource);
- m_transformSource = doc;
+ m_transformSource = source;
}
#endif
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 2805562..f05c9f9 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -37,6 +37,8 @@
#include "ScriptExecutionContext.h"
#include "Timer.h"
#include <wtf/HashCountedSet.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
namespace WebCore {
@@ -103,6 +105,10 @@ namespace WebCore {
class SVGDocumentExtensions;
#endif
+#if ENABLE(XSLT)
+ class TransformSource;
+#endif
+
#if ENABLE(XBL)
class XBLBindingManager;
#endif
@@ -746,10 +752,11 @@ public:
#if ENABLE(XSLT)
void applyXSLTransform(ProcessingInstruction* pi);
- void setTransformSource(void* doc);
- const void* transformSource() { return m_transformSource; }
PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
+
+ void setTransformSource(PassOwnPtr<TransformSource>);
+ TransformSource* transformSource() const { return m_transformSource.get(); }
#endif
#if ENABLE(XBL)
@@ -1054,7 +1061,7 @@ private:
Timer<Document> m_executeScriptSoonTimer;
#if ENABLE(XSLT)
- void* m_transformSource;
+ OwnPtr<TransformSource> m_transformSource;
RefPtr<Document> m_transformSourceDocument;
#endif
diff --git a/WebCore/dom/TransformSource.h b/WebCore/dom/TransformSource.h
new file mode 100644
index 0000000..f97afcf
--- /dev/null
+++ b/WebCore/dom/TransformSource.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2009 Jakub Wieczorek <faw217 at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef TransformSource_h
+#define TransformSource_h
+
+#if ENABLE(XSLT)
+
+#include "PlatformString.h"
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+#if USE(QXMLQUERY)
+ typedef String PlatformTransformSource;
+#else
+ typedef void* PlatformTransformSource;
+#endif
+
+ class TransformSource : public Noncopyable {
+ public:
+ TransformSource(const PlatformTransformSource& source);
+ ~TransformSource();
+
+ PlatformTransformSource platformSource() const { return m_source; }
+
+ private:
+ PlatformTransformSource m_source;
+ };
+
+} // namespace WebCore
+
+#endif
+
+#endif // TransformSource_h
diff --git a/WebCore/dom/TransformSourceLibxslt.cpp b/WebCore/dom/TransformSourceLibxslt.cpp
new file mode 100644
index 0000000..33a85e8
--- /dev/null
+++ b/WebCore/dom/TransformSourceLibxslt.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TransformSource.h"
+
+#include <libxml/tree.h>
+
+namespace WebCore {
+
+TransformSource::TransformSource(const PlatformTransformSource& source)
+ : m_source(source)
+{
+}
+
+TransformSource::~TransformSource()
+{
+ xmlFreeDoc((xmlDocPtr)m_source);
+}
+
+}
diff --git a/WebCore/dom/TransformSourceQt.cpp b/WebCore/dom/TransformSourceQt.cpp
new file mode 100644
index 0000000..074f2cb
--- /dev/null
+++ b/WebCore/dom/TransformSourceQt.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Jakub Wieczorek <faw217 at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "TransformSource.h"
+
+namespace WebCore {
+
+TransformSource::TransformSource(const PlatformTransformSource& source)
+ : m_source(source)
+{
+}
+
+TransformSource::~TransformSource()
+{
+}
+
+}
diff --git a/WebCore/dom/XMLTokenizerLibxml2.cpp b/WebCore/dom/XMLTokenizerLibxml2.cpp
index da2f9b6..d3c6546 100644
--- a/WebCore/dom/XMLTokenizerLibxml2.cpp
+++ b/WebCore/dom/XMLTokenizerLibxml2.cpp
@@ -50,6 +50,7 @@
#include "ScriptSourceCode.h"
#include "ScriptValue.h"
#include "TextResourceDecoder.h"
+#include "TransformSource.h"
#include "XMLTokenizerScope.h"
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
@@ -1280,7 +1281,8 @@ void XMLTokenizer::doEnd()
{
#if ENABLE(XSLT)
if (m_sawXSLTransform) {
- m_doc->setTransformSource(xmlDocPtrForString(m_doc->docLoader(), m_originalSourceForTransform, m_doc->url().string()));
+ void* doc = xmlDocPtrForString(m_doc->docLoader(), m_originalSourceForTransform, m_doc->url().string());
+ m_doc->setTransformSource(new TransformSource(doc));
m_doc->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
m_doc->updateStyleSelector();
diff --git a/WebCore/dom/XMLTokenizerQt.cpp b/WebCore/dom/XMLTokenizerQt.cpp
index 799eef3..f745830 100644
--- a/WebCore/dom/XMLTokenizerQt.cpp
+++ b/WebCore/dom/XMLTokenizerQt.cpp
@@ -50,6 +50,7 @@
#include "ScriptSourceCode.h"
#include "ScriptValue.h"
#include "TextResourceDecoder.h"
+#include "TransformSource.h"
#include <QDebug>
#include <wtf/Platform.h>
#include <wtf/StringExtras.h>
@@ -248,45 +249,19 @@ void XMLTokenizer::initializeParserContext(const char* chunk)
void XMLTokenizer::doEnd()
{
#if ENABLE(XSLT)
- #warning Look at XMLTokenizerLibXml.cpp
-#endif
-
- if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError || (m_wroteText && !m_sawFirstElement)) {
- handleError(fatal, qPrintable(m_stream.errorString()), lineNumber(),
- columnNumber());
+ if (m_sawXSLTransform) {
+ m_doc->setTransformSource(new TransformSource(m_originalSourceForTransform));
+ m_doc->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
+ m_doc->updateStyleSelector();
+ m_doc->setParsing(true);
+ m_parserStopped = true;
}
-}
-
-#if ENABLE(XSLT)
-void* xmlDocPtrForString(DocLoader* docLoader, const String& source, const String& url)
-{
- if (source.isEmpty())
- return 0;
-
- // Parse in a single chunk into an xmlDocPtr
- // FIXME: Hook up error handlers so that a failure to parse the main document results in
- // good error messages.
- const UChar BOM = 0xFEFF;
- const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
-
- xmlGenericErrorFunc oldErrorFunc = xmlGenericError;
- void* oldErrorContext = xmlGenericErrorContext;
-
- setLoaderForLibXMLCallbacks(docLoader);
- xmlSetGenericErrorFunc(0, errorFunc);
-
- xmlDocPtr sourceDoc = xmlReadMemory(reinterpret_cast<const char*>(source.characters()),
- source.length() * sizeof(UChar),
- url.latin1().data(),
- BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE",
- XSLT_PARSE_OPTIONS);
-
- setLoaderForLibXMLCallbacks(0);
- xmlSetGenericErrorFunc(oldErrorContext, oldErrorFunc);
+#endif
- return sourceDoc;
+ if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError
+ || (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform))
+ handleError(fatal, qPrintable(m_stream.errorString()), lineNumber(), columnNumber());
}
-#endif
int XMLTokenizer::lineNumber() const
{
@@ -683,7 +658,7 @@ void XMLTokenizer::parseProcessingInstruction()
#if ENABLE(XSLT)
m_sawXSLTransform = !m_sawFirstElement && pi->isXSL();
- if (m_sawXSLTransform && !m_doc->transformSourceDocument()))
+ if (m_sawXSLTransform && !m_doc->transformSourceDocument())
stopParsing();
#endif
}
diff --git a/WebCore/xml/XSLStyleSheet.h b/WebCore/xml/XSLStyleSheet.h
index fe97b54..c9729bb 100644
--- a/WebCore/xml/XSLStyleSheet.h
+++ b/WebCore/xml/XSLStyleSheet.h
@@ -26,8 +26,12 @@
#if ENABLE(XSLT)
#include "StyleSheet.h"
+
+#if !USE(QXMLQUERY)
#include <libxml/parser.h>
#include <libxslt/transform.h>
+#endif
+
#include <wtf/PassRefPtr.h>
namespace WebCore {
@@ -38,10 +42,12 @@ class XSLImportRule;
class XSLStyleSheet : public StyleSheet {
public:
+#if !USE(QXMLQUERY)
static PassRefPtr<XSLStyleSheet> create(XSLImportRule* parentImport, const String& href)
{
return adoptRef(new XSLStyleSheet(parentImport, href));
}
+#endif
static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& href)
{
return adoptRef(new XSLStyleSheet(parentNode, href, false));
@@ -65,31 +71,41 @@ public:
void loadChildSheets();
void loadChildSheet(const String& href);
- xsltStylesheetPtr compileStyleSheet();
-
DocLoader* docLoader();
Document* ownerDocument() { return m_ownerDocument; }
void setParentStyleSheet(XSLStyleSheet* parent);
+#if USE(QXMLQUERY)
+ String sheetString() const { return m_sheetString; }
+#else
xmlDocPtr document();
+ xsltStylesheetPtr compileStyleSheet();
+ xmlDocPtr locateStylesheetSubResource(xmlDocPtr parentDoc, const xmlChar* uri);
+#endif
void clearDocuments();
- xmlDocPtr locateStylesheetSubResource(xmlDocPtr parentDoc, const xmlChar* uri);
-
void markAsProcessed();
bool processed() const { return m_processed; }
private:
XSLStyleSheet(Node* parentNode, const String& href, bool embedded);
+#if !USE(QXMLQUERY)
XSLStyleSheet(XSLImportRule* parentImport, const String& href);
+#endif
Document* m_ownerDocument;
- xmlDocPtr m_stylesheetDoc;
bool m_embedded;
bool m_processed;
+
+#if USE(QXMLQUERY)
+ String m_sheetString;
+#else
+ xmlDocPtr m_stylesheetDoc;
bool m_stylesheetDocTaken;
+#endif
+
XSLStyleSheet* m_parentStyleSheet;
};
diff --git a/WebCore/xml/XSLStyleSheetLibxslt.cpp b/WebCore/xml/XSLStyleSheetLibxslt.cpp
index ed2753d..2ae8b82 100644
--- a/WebCore/xml/XSLStyleSheetLibxslt.cpp
+++ b/WebCore/xml/XSLStyleSheetLibxslt.cpp
@@ -31,6 +31,7 @@
#include "Document.h"
#include "Frame.h"
#include "Node.h"
+#include "TransformSource.h"
#include "XMLTokenizer.h"
#include "XMLTokenizerScope.h"
#include "XSLImportRule.h"
@@ -57,9 +58,9 @@ namespace WebCore {
XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& href)
: StyleSheet(parentRule, href)
, m_ownerDocument(0)
- , m_stylesheetDoc(0)
, m_embedded(false)
, m_processed(false) // Child sheets get marked as processed when the libxslt engine has finally seen them.
+ , m_stylesheetDoc(0)
, m_stylesheetDocTaken(false)
, m_parentStyleSheet(0)
{
@@ -68,9 +69,9 @@ XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& href)
XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, bool embedded)
: StyleSheet(parentNode, href)
, m_ownerDocument(parentNode->document())
- , m_stylesheetDoc(0)
, m_embedded(embedded)
, m_processed(true) // The root sheet starts off processed.
+ , m_stylesheetDoc(0)
, m_stylesheetDocTaken(false)
, m_parentStyleSheet(0)
{
@@ -108,8 +109,8 @@ void XSLStyleSheet::checkLoaded()
xmlDocPtr XSLStyleSheet::document()
{
- if (m_embedded && ownerDocument())
- return (xmlDocPtr)ownerDocument()->transformSource();
+ if (m_embedded && ownerDocument() && ownerDocument()->transformSource())
+ return (xmlDocPtr)ownerDocument()->transformSource()->platformSource();
return m_stylesheetDoc;
}
diff --git a/WebCore/xml/XSLStyleSheetQt.cpp b/WebCore/xml/XSLStyleSheetQt.cpp
new file mode 100644
index 0000000..9fada0e
--- /dev/null
+++ b/WebCore/xml/XSLStyleSheetQt.cpp
@@ -0,0 +1,103 @@
+/*
+ * This file is part of the XSL implementation.
+ *
+ * Copyright (C) 2009 Jakub Wieczorek <faw217 at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "XSLStyleSheet.h"
+
+#if ENABLE(XSLT)
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Node.h"
+#include "NotImplemented.h"
+#include "XSLTProcessor.h"
+#include "loader.h"
+
+namespace WebCore {
+
+XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, bool embedded)
+ : StyleSheet(parentNode, href)
+ , m_ownerDocument(parentNode->document())
+ , m_embedded(embedded)
+{
+}
+
+XSLStyleSheet::~XSLStyleSheet()
+{
+}
+
+bool XSLStyleSheet::isLoading()
+{
+ notImplemented();
+ return false;
+}
+
+void XSLStyleSheet::checkLoaded()
+{
+ if (ownerNode())
+ ownerNode()->sheetLoaded();
+}
+
+void XSLStyleSheet::clearDocuments()
+{
+ notImplemented();
+}
+
+DocLoader* XSLStyleSheet::docLoader()
+{
+ if (!m_ownerDocument)
+ return 0;
+ return m_ownerDocument->docLoader();
+}
+
+bool XSLStyleSheet::parseString(const String& string, bool)
+{
+ // FIXME: Fix QXmlQuery so that it allows compiling the stylesheet before setting the document
+ // to be transformed. This way we could not only check if the stylesheet is correct before using it
+ // but also turn XSLStyleSheet::sheetString() into XSLStyleSheet::query() that returns a QXmlQuery.
+
+ m_sheetString = string;
+ return !m_sheetString.isEmpty();
+}
+
+void XSLStyleSheet::loadChildSheets()
+{
+ notImplemented();
+}
+
+void XSLStyleSheet::loadChildSheet(const String& href)
+{
+ notImplemented();
+}
+
+void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent)
+{
+ notImplemented();
+}
+
+void XSLStyleSheet::markAsProcessed()
+{
+ notImplemented();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(XSLT)
diff --git a/WebCore/xml/XSLTProcessor.h b/WebCore/xml/XSLTProcessor.h
index 4b90c16..9b91017 100644
--- a/WebCore/xml/XSLTProcessor.h
+++ b/WebCore/xml/XSLTProcessor.h
@@ -28,9 +28,12 @@
#include "Node.h"
#include "StringHash.h"
#include "XSLStyleSheet.h"
+#include <wtf/HashMap.h>
+
+#if !USE(QXMLQUERY)
#include <libxml/parserInternals.h>
#include <libxslt/documents.h>
-#include <wtf/HashMap.h>
+#endif
namespace WebCore {
@@ -58,12 +61,13 @@ public:
void reset();
+#if !USE(QXMLQUERY)
static void parseErrorFunc(void* userData, xmlError*);
static void genericErrorFunc(void* userData, const char* msg, ...);
-public:
// Only for libXSLT callbacks
XSLStyleSheet* xslStylesheet() const { return m_stylesheet.get(); }
+#endif
typedef HashMap<String, String> ParameterMap;
diff --git a/WebCore/xml/XSLTProcessorLibxslt.cpp b/WebCore/xml/XSLTProcessorLibxslt.cpp
index 6b2a0fd..200c56b 100644
--- a/WebCore/xml/XSLTProcessorLibxslt.cpp
+++ b/WebCore/xml/XSLTProcessorLibxslt.cpp
@@ -35,6 +35,7 @@
#include "ResourceHandle.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
+#include "TransformSource.h"
#include "XMLTokenizer.h"
#include "XSLStyleSheet.h"
#include "XSLTExtensions.h"
@@ -241,8 +242,8 @@ static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete)
bool sourceIsDocument = (sourceNode == ownerDocument.get());
xmlDocPtr sourceDoc = 0;
- if (sourceIsDocument)
- sourceDoc = (xmlDocPtr)ownerDocument->transformSource();
+ if (sourceIsDocument && ownerDocument->transformSource())
+ sourceDoc = (xmlDocPtr)ownerDocument->transformSource()->platformSource();
if (!sourceDoc) {
sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument->docLoader(), createMarkup(sourceNode),
sourceIsDocument ? ownerDocument->url().string() : String());
diff --git a/WebCore/xml/XSLTProcessorQt.cpp b/WebCore/xml/XSLTProcessorQt.cpp
new file mode 100644
index 0000000..523306a
--- /dev/null
+++ b/WebCore/xml/XSLTProcessorQt.cpp
@@ -0,0 +1,149 @@
+/*
+ * This file is part of the XSL implementation.
+ *
+ * Copyright (C) 2009 Jakub Wieczorek <faw217 at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(XSLT)
+
+#include "XSLTProcessor.h"
+
+#include "Console.h"
+#include "DOMWindow.h"
+#include "Frame.h"
+#include "TransformSource.h"
+#include "loader.h"
+#include "markup.h"
+#include <wtf/Assertions.h>
+#include <wtf/Platform.h>
+#include <wtf/Vector.h>
+
+#include <qabstractmessagehandler.h>
+#include <qbuffer.h>
+#include <qsourcelocation.h>
+#include <qxmlquery.h>
+
+namespace WebCore {
+
+class XSLTMessageHandler : public QAbstractMessageHandler {
+
+public:
+ XSLTMessageHandler(Document* document = 0);
+ virtual void handleMessage(QtMsgType type, const QString& description,
+ const QUrl& identifier, const QSourceLocation& sourceLocation);
+
+private:
+ Document* m_document;
+};
+
+XSLTMessageHandler::XSLTMessageHandler(Document* document)
+ : QAbstractMessageHandler()
+ , m_document(document)
+{
+}
+
+void XSLTMessageHandler::handleMessage(QtMsgType type, const QString& description,
+ const QUrl& identifier, const QSourceLocation& sourceLocation)
+{
+ if (!m_document->frame())
+ return;
+
+ MessageLevel level;
+ switch (type) {
+ case QtDebugMsg:
+ level = TipMessageLevel;
+ break;
+ case QtWarningMsg:
+ level = WarningMessageLevel;
+ break;
+ case QtCriticalMsg:
+ case QtFatalMsg:
+ level = ErrorMessageLevel;
+ break;
+ default:
+ level = LogMessageLevel;
+ break;
+ }
+
+ Console* console = m_document->frame()->domWindow()->console();
+ console->addMessage(XMLMessageSource, LogMessageType, level, description,
+ sourceLocation.line(), sourceLocation.uri().toString());
+}
+
+bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String& resultString, String& resultEncoding)
+{
+ bool success = false;
+
+ RefPtr<XSLStyleSheet> stylesheet = m_stylesheet;
+ if (!stylesheet && m_stylesheetRootNode) {
+ Node* node = m_stylesheetRootNode.get();
+ stylesheet = XSLStyleSheet::create(node->parent() ? node->parent() : node, node->document()->url().string());
+ stylesheet->parseString(createMarkup(node));
+ }
+
+ if (!stylesheet || stylesheet->sheetString().isEmpty())
+ return success;
+
+ RefPtr<Document> ownerDocument = sourceNode->document();
+ bool sourceIsDocument = (sourceNode == ownerDocument.get());
+
+ QXmlQuery query(QXmlQuery::XSLT20);
+
+ XSLTMessageHandler messageHandler(ownerDocument.get());
+ query.setMessageHandler(&messageHandler);
+
+ XSLTProcessor::ParameterMap::iterator end = m_parameters.end();
+ for (XSLTProcessor::ParameterMap::iterator it = m_parameters.begin(); it != end; ++it)
+ query.bindVariable(QString(it->first), QXmlItem(QVariant(it->second)));
+
+ QString source;
+ if (sourceIsDocument && ownerDocument->transformSource())
+ source = ownerDocument->transformSource()->platformSource();
+ if (!sourceIsDocument || source.isEmpty())
+ source = createMarkup(sourceNode);
+
+ QBuffer inputBuffer;
+ QBuffer styleSheetBuffer;
+ QBuffer outputBuffer;
+
+ inputBuffer.setData(source.toUtf8());
+ styleSheetBuffer.setData(QString(stylesheet->sheetString()).toUtf8());
+
+ inputBuffer.open(QIODevice::ReadOnly);
+ styleSheetBuffer.open(QIODevice::ReadOnly);
+ outputBuffer.open(QIODevice::ReadWrite);
+
+ query.setFocus(&inputBuffer);
+ query.setQuery(&styleSheetBuffer, QUrl(stylesheet->href()));
+ success = query.evaluateTo(&outputBuffer);
+ outputBuffer.reset();
+ resultString = QString::fromUtf8(outputBuffer.readAll()).trimmed();
+
+ if (m_stylesheet) {
+ m_stylesheet->clearDocuments();
+ m_stylesheet = 0;
+ }
+
+ return success;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(XSLT)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list