From 43849667b2a8ffc6a84e92fea1415a9c69bb50b0 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 19 Apr 2024 22:46:03 -0500 Subject: [PATCH] Remove WebKit SVG renderer. --- src/MacAppBundle/CMakeLists.txt | 11 +- src/Mod/Web/web.dox | 2 +- src/Tools/embedded/PySide/mainwindow.py | 3 - src/Tools/embedded/PySide/mainwindow2.py | 3 - src/Tools/embedded/PySide/mainwindow3.py | 3 - src/Tools/plugins/imageformats/svg/main.cpp | 98 ------ .../imageformats/svg/qsvgiohandler.cpp | 311 ------------------ .../plugins/imageformats/svg/qsvgiohandler.h | 77 ----- src/Tools/plugins/imageformats/svg/svg.pro | 6 - tools/build/Docker/arch.sh | 4 +- tools/build/Docker/debian.sh | 2 +- tools/build/Docker/fedora.sh | 2 +- tools/build/Docker/manjaro.sh | 2 +- tools/build/Docker/ubuntu.sh | 2 +- 14 files changed, 8 insertions(+), 518 deletions(-) delete mode 100644 src/Tools/plugins/imageformats/svg/main.cpp delete mode 100644 src/Tools/plugins/imageformats/svg/qsvgiohandler.cpp delete mode 100644 src/Tools/plugins/imageformats/svg/qsvgiohandler.h delete mode 100644 src/Tools/plugins/imageformats/svg/svg.pro diff --git a/src/MacAppBundle/CMakeLists.txt b/src/MacAppBundle/CMakeLists.txt index 150a38a9ef..bab8d510c1 100644 --- a/src/MacAppBundle/CMakeLists.txt +++ b/src/MacAppBundle/CMakeLists.txt @@ -33,15 +33,6 @@ else() set(PYTHON_DIR ${PYTHON_DIR}/${PYTHON_DIR_BASENAME}) endif() -set(WEBKIT_FRAMEWORK_DIR "") -if (Qt5WebKitWidgets_FOUND) - #qtwebkitwidgets references qtwebkit with a relative path, - #so we need to add its location to the search paths - get_filename_component(WEBKIT_LIB_DIR ${Qt5WebKitWidgets_DIR} PATH) - get_filename_component(WEBKIT_LIB_DIR ${WEBKIT_LIB_DIR} PATH) - set(WEBKIT_FRAMEWORK_DIR "${WEBKIT_LIB_DIR}/QtWebKit.framework/Versions/5") -endif() - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYTHON_DIR} ${CMAKE_INSTALL_LIBDIR}/${PYTHON_DIR_BASENAME} )") @@ -128,7 +119,7 @@ install(CODE execute_process( COMMAND python3 ${CMAKE_SOURCE_DIR}/src/Tools/MakeMacBundleRelocatable.py - ${APP_PATH} ${HOMEBREW_PREFIX}${MACPORTS_PREFIX}/lib ${CONFIG_ICU} ${CONFIG_LLVM} ${CONFIG_GCC} /usr/local/opt ${CONFIG_NGLIB} ${Qt5Core_DIR}/../../.. ${XCTEST_PATH} ${WEBKIT_FRAMEWORK_DIR} + ${APP_PATH} ${HOMEBREW_PREFIX}${MACPORTS_PREFIX}/lib ${CONFIG_ICU} ${CONFIG_LLVM} ${CONFIG_GCC} /usr/local/opt ${CONFIG_NGLIB} ${Qt5Core_DIR}/../../.. ${XCTEST_PATH} )" ) diff --git a/src/Mod/Web/web.dox b/src/Mod/Web/web.dox index ea2fd864e6..2fcbc5cb4e 100644 --- a/src/Mod/Web/web.dox +++ b/src/Mod/Web/web.dox @@ -1,6 +1,6 @@ /** \defgroup WEB Web * \ingroup CWORKBENCHES - * \brief The webkit-based web browser of FreeCAD + * \brief A simple remote-access server for FreeCAD See \ref src/Mod/Draft/draft.dox as an example of how to populate this page diff --git a/src/Tools/embedded/PySide/mainwindow.py b/src/Tools/embedded/PySide/mainwindow.py index c1cf86c20e..9503a53c79 100644 --- a/src/Tools/embedded/PySide/mainwindow.py +++ b/src/Tools/embedded/PySide/mainwindow.py @@ -13,9 +13,6 @@ class MainWindow(QtGui.QMainWindow): super(MainWindow, self).__init__(parent) from PySide import QtNetwork - # Webkit is used to create icons from SVG files. This could cause a deadlock - # when setting up the internally used network interface. Doing this before - # creating the icons fixes the issue. QtNetwork.QNetworkConfigurationManager() def showEvent(self, event): diff --git a/src/Tools/embedded/PySide/mainwindow2.py b/src/Tools/embedded/PySide/mainwindow2.py index 974f2f301b..907a38d7ea 100644 --- a/src/Tools/embedded/PySide/mainwindow2.py +++ b/src/Tools/embedded/PySide/mainwindow2.py @@ -11,9 +11,6 @@ class MainWindow(QtGui.QMainWindow): super(MainWindow, self).__init__(parent) from PySide import QtNetwork - # Webkit is used to create icons from SVG files. This could cause a deadlock - # when setting up the internally used network interface. Doing this before - # creating the icons fixes the issue. QtNetwork.QNetworkConfigurationManager() def showEvent(self, event): diff --git a/src/Tools/embedded/PySide/mainwindow3.py b/src/Tools/embedded/PySide/mainwindow3.py index 8f43fac3db..dc414e9eb0 100644 --- a/src/Tools/embedded/PySide/mainwindow3.py +++ b/src/Tools/embedded/PySide/mainwindow3.py @@ -14,9 +14,6 @@ class MainWindow(QtGui.QMainWindow): super(MainWindow, self).__init__(parent) from PySide import QtNetwork - # Webkit is used to create icons from SVG files. This could cause a deadlock - # when setting up the internally used network interface. Doing this before - # creating the icons fixes the issue. QtNetwork.QNetworkConfigurationManager() @QtCore.Slot() diff --git a/src/Tools/plugins/imageformats/svg/main.cpp b/src/Tools/plugins/imageformats/svg/main.cpp deleted file mode 100644 index 89f5ce111a..0000000000 --- a/src/Tools/plugins/imageformats/svg/main.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#if !defined(QT_NO_IMAGEFORMATPLUGIN) && !defined(QT_NO_SVGRENDERER) - -#include "qsvgiohandler.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QSvgPlugin: public QImageIOPlugin -{ -public: - QStringList keys() const; - Capabilities capabilities(QIODevice* device, const QByteArray& format) const; - QImageIOHandler* create(QIODevice* device, const QByteArray& format = QByteArray()) const; -}; - -QStringList QSvgPlugin::keys() const -{ - return QStringList() << QLatin1String("svg") << QLatin1String("svgz"); -} - -QImageIOPlugin::Capabilities QSvgPlugin::capabilities(QIODevice* device, - const QByteArray& format) const -{ - if (format == "svg" || format == "svgz") { - return Capabilities(CanRead); - } - if (!format.isEmpty()) { - return 0; - } - - Capabilities cap; - if (device->isReadable() && QSvgIOHandler::canRead(device)) { - cap |= CanRead; - } - return cap; -} - -QImageIOHandler* QSvgPlugin::create(QIODevice* device, const QByteArray& format) const -{ - QSvgIOHandler* hand = new QSvgIOHandler(); - hand->setDevice(device); - hand->setFormat(format); - return hand; -} - -Q_EXPORT_STATIC_PLUGIN(QSvgPlugin) -Q_EXPORT_PLUGIN2(qsvg, QSvgPlugin) - -QT_END_NAMESPACE - -#endif // !QT_NO_IMAGEFORMATPLUGIN diff --git a/src/Tools/plugins/imageformats/svg/qsvgiohandler.cpp b/src/Tools/plugins/imageformats/svg/qsvgiohandler.cpp deleted file mode 100644 index cbbb1d071c..0000000000 --- a/src/Tools/plugins/imageformats/svg/qsvgiohandler.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Changes: Use Webkit engine instead of SVG renderer - -#include "qsvgiohandler.h" - -#ifndef QT_NO_SVGRENDERER - -#include "qbuffer.h" -#include "qdebug.h" -#include "qimage.h" -#include "qpainter.h" -#include "qpixmap.h" -#include "qvariant.h" -#include "qwebframe.h" -#include "qwebview.h" -#include "qxmlstream.h" - -QT_BEGIN_NAMESPACE - -class QSvgIOHandlerPrivate -{ -public: - QSvgIOHandlerPrivate(QSvgIOHandler* qq) - : q(qq) - , loaded(false) - , readDone(false) - , backColor(Qt::transparent) - { - QPalette pal = webView.palette(); - pal.setColor(QPalette::Background, backColor); - webView.setPalette(pal); - } - - bool load(QIODevice* device); - - QSvgIOHandler* q; - QWebView webView; - QXmlStreamReader xmlReader; - QSize defaultSize; - QRect clipRect; - QSize scaledSize; - QRect scaledClipRect; - bool loaded; - bool readDone; - QColor backColor; -}; - - -bool QSvgIOHandlerPrivate::load(QIODevice* device) -{ - if (loaded) { - return true; - } - if (q->format().isEmpty()) { - q->canRead(); - } - - // # The SVG renderer doesn't handle trailing, unrelated data, so we must - // assume that all available data in the device is to be read. - bool res = false; -#if 0 - QBuffer *buf = qobject_cast(device); - if (buf) { - const QByteArray &ba = buf->data(); - res = r.load(QByteArray::fromRawData(ba.constData() + buf->pos(), ba.size() - buf->pos())); - buf->seek(ba.size()); - } else if (q->format() == "svgz") { - res = r.load(device->readAll()); - } else { - xmlReader.setDevice(device); - res = r.load(&xmlReader); - } - - if (res) { - defaultSize = QSize(r.viewBox().width(), r.viewBox().height()); - loaded = true; - } -#else - webView.setContent(device->readAll(), QString::fromLatin1("image/svg+xml")); - QString node = QString::fromLatin1("document.rootElement.nodeName"); - QString root = webView.page()->mainFrame()->evaluateJavaScript(node).toString(); - - if (!root.isEmpty() && root.compare(QLatin1String("svg"), Qt::CaseInsensitive) == 0) { - QString w = QString::fromLatin1("document.rootElement.width.baseVal.value"); - QString h = QString::fromLatin1("document.rootElement.height.baseVal.value"); - double ww = webView.page()->mainFrame()->evaluateJavaScript(w).toDouble(); - double hh = webView.page()->mainFrame()->evaluateJavaScript(h).toDouble(); - - defaultSize = QSize(ww, hh); - loaded = true; - res = true; - } -#endif - - return loaded; -} - - -QSvgIOHandler::QSvgIOHandler() - : d(new QSvgIOHandlerPrivate(this)) -{} - - -QSvgIOHandler::~QSvgIOHandler() -{ - delete d; -} - - -bool QSvgIOHandler::canRead() const -{ - if (!device()) { - return false; - } - if (d->loaded && !d->readDone) { - return true; // Will happen if we have been asked for the size - } - - QByteArray buf = device()->peek(8); - if (buf.startsWith("\x1f\x8b")) { - setFormat("svgz"); - return true; - } - else if (buf.contains("readDone && d->load(device())) { - bool xform = - (d->clipRect.isValid() || d->scaledSize.isValid() || d->scaledClipRect.isValid()); - QSize finalSize = d->defaultSize; - QRectF bounds; - if (xform && !d->defaultSize.isEmpty()) { - bounds = QRectF(QPointF(0, 0), QSizeF(d->defaultSize)); - QPoint tr1, tr2; - QSizeF sc(1, 1); - if (d->clipRect.isValid()) { - tr1 = -d->clipRect.topLeft(); - finalSize = d->clipRect.size(); - } - if (d->scaledSize.isValid()) { - sc = QSizeF(qreal(d->scaledSize.width()) / finalSize.width(), - qreal(d->scaledSize.height()) / finalSize.height()); - finalSize = d->scaledSize; - } - if (d->scaledClipRect.isValid()) { - tr2 = -d->scaledClipRect.topLeft(); - finalSize = d->scaledClipRect.size(); - } - QTransform t; - t.translate(tr2.x(), tr2.y()); - t.scale(sc.width(), sc.height()); - t.translate(tr1.x(), tr1.y()); - bounds = t.mapRect(bounds); - } - *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied); - if (!finalSize.isEmpty()) { - image->fill(d->backColor.rgba()); - QPainter p(image); -#if 0 - d->r.render(&p, bounds); -#else - // qreal xs = size.isValid() ? size.width() / ww : 1.0; - // qreal ys = size.isValid() ? size.height() / hh : 1.0; - // p.scale(xs, ys); - - // the best quality - p.setRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::TextAntialiasing); - p.setRenderHint(QPainter::SmoothPixmapTransform); - p.setOpacity(0); // important to keep transparent background - d->webView.page()->mainFrame()->render(&p); -#endif - p.end(); - } - d->readDone = true; - return true; - } - - return false; -} - - -QVariant QSvgIOHandler::option(ImageOption option) const -{ - switch (option) { - case ImageFormat: - return QImage::Format_ARGB32_Premultiplied; - break; - case Size: - d->load(device()); - return d->defaultSize; - break; - case ClipRect: - return d->clipRect; - break; - case ScaledSize: - return d->scaledSize; - break; - case ScaledClipRect: - return d->scaledClipRect; - break; - case BackgroundColor: - return d->backColor; - break; - default: - break; - } - return QVariant(); -} - - -void QSvgIOHandler::setOption(ImageOption option, const QVariant& value) -{ - switch (option) { - case ClipRect: - d->clipRect = value.toRect(); - break; - case ScaledSize: - d->scaledSize = value.toSize(); - break; - case ScaledClipRect: - d->scaledClipRect = value.toRect(); - break; - case BackgroundColor: - d->backColor = value.value(); - break; - default: - break; - } -} - - -bool QSvgIOHandler::supportsOption(ImageOption option) const -{ - switch (option) { - case ImageFormat: - case Size: - case ClipRect: - case ScaledSize: - case ScaledClipRect: - case BackgroundColor: - return true; - default: - break; - } - return false; -} - - -bool QSvgIOHandler::canRead(QIODevice* device) -{ - QByteArray buf = device->peek(8); - return buf.startsWith("\x1f\x8b") || buf.contains(" - -#ifndef QT_NO_SVGRENDERER - -QT_BEGIN_NAMESPACE - -class QImage; -class QByteArray; -class QIODevice; -class QVariant; -class QSvgIOHandlerPrivate; - -class QSvgIOHandler: public QImageIOHandler -{ -public: - QSvgIOHandler(); - ~QSvgIOHandler(); - virtual bool canRead() const; - virtual QByteArray name() const; - virtual bool read(QImage* image); - static bool canRead(QIODevice* device); - virtual QVariant option(ImageOption option) const; - virtual void setOption(ImageOption option, const QVariant& value); - virtual bool supportsOption(ImageOption option) const; - -private: - QSvgIOHandlerPrivate* d; -}; - -QT_END_NAMESPACE - -#endif // QT_NO_SVGRENDERER -#endif // QSVGIOHANDLER_H diff --git a/src/Tools/plugins/imageformats/svg/svg.pro b/src/Tools/plugins/imageformats/svg/svg.pro deleted file mode 100644 index 8451fc4260..0000000000 --- a/src/Tools/plugins/imageformats/svg/svg.pro +++ /dev/null @@ -1,6 +0,0 @@ -TARGET = freecad_svg - -HEADERS += qsvgiohandler.h -SOURCES += main.cpp \ - qsvgiohandler.cpp -QT += xml webkit diff --git a/tools/build/Docker/arch.sh b/tools/build/Docker/arch.sh index b0bab1c06c..9856bbe308 100644 --- a/tools/build/Docker/arch.sh +++ b/tools/build/Docker/arch.sh @@ -2,6 +2,6 @@ pacman --noconfirm --sync boost boost-libs cmake coin curl desktop-file-utils doxygen \ eigen gc gcc-fortran git glew gnu-free-fonts guile hicolor-icon-theme jsoncpp \ libspnav libtool make med opencascade openmpi pyside2 pyside2-tools \ - python-matplotlib python-netcdf4 python-pivy qt5-svg qt5-tools qt5-webengine \ - qt5-webkit shared-mime-info shiboken2 swig texinfo xerces-c + python-matplotlib python-netcdf4 python-pivy qt5-svg qt5-tools \ + shared-mime-info shiboken2 swig texinfo xerces-c diff --git a/tools/build/Docker/debian.sh b/tools/build/Docker/debian.sh index c0be1bc08d..4418def875 100755 --- a/tools/build/Docker/debian.sh +++ b/tools/build/Docker/debian.sh @@ -7,7 +7,7 @@ apt-get install --no-install-recommends --yes build-essential cmake doxygen \ libkdtree++-dev libkml-dev libmedc-dev libocct-data-exchange-dev \ libocct-draw-dev libocct-foundation-dev libocct-modeling-algorithms-dev \ libocct-modeling-data-dev libocct-ocaf-dev libocct-visualization-dev \ - libopencv-dev libproj-dev libpyside2-dev libqt5svg5-dev libqt5webkit5-dev \ + libopencv-dev libproj-dev libpyside2-dev libqt5svg5-dev \ libshiboken2-dev libvtk9-dev libvtk9-qt-dev \ libvtk-dicom-dev libx11-dev libxerces-c-dev libxmu-dev libxmuu-dev \ libzipios++-dev netgen netgen-headers pyside2-tools python3-dev \ diff --git a/tools/build/Docker/fedora.sh b/tools/build/Docker/fedora.sh index 3d06e6812e..7178d294a3 100644 --- a/tools/build/Docker/fedora.sh +++ b/tools/build/Docker/fedora.sh @@ -5,5 +5,5 @@ dnf --assumeyes install boost-devel cmake Coin3 Coin3-devel desktop-file-utils d opencv-devel openmpi-devel pcl-devel pyside2-tools python3 python3-devel \ python3-matplotlib python3-pivy python3-pyside2-devel qt5-qtsvg-devel \ qt5-qttools-static qt-devel \ - qt-webkit-devel smesh-devel SoQt-devel swig tbb-devel vtk xerces-c xerces-c-devel + smesh-devel SoQt-devel swig tbb-devel vtk xerces-c xerces-c-devel diff --git a/tools/build/Docker/manjaro.sh b/tools/build/Docker/manjaro.sh index 15cc7d0ccd..3d8cbc190a 100755 --- a/tools/build/Docker/manjaro.sh +++ b/tools/build/Docker/manjaro.sh @@ -2,6 +2,6 @@ pacman --noconfirm --sync boost boost-libs cmake coin curl desktop-file-utils doxygen \ eigen gc gcc-fortran git glew gnu-free-fonts guile hicolor-icon-theme jsoncpp \ libspnav libtool make med opencascade pyside2 pyside2-tools python-matplotlib \ - python-netcdf4 python-pivy qt5-svg qt5-tools qt5-webengine qt5-webkit \ + python-netcdf4 python-pivy qt5-svg qt5-tools \ shared-mime-info shiboken2 swig texinfo xerces-c diff --git a/tools/build/Docker/ubuntu.sh b/tools/build/Docker/ubuntu.sh index 2be80893d8..99fbc715c2 100644 --- a/tools/build/Docker/ubuntu.sh +++ b/tools/build/Docker/ubuntu.sh @@ -7,7 +7,7 @@ apt-get install --no-install-recommends --yes build-essential cmake doxygen git libgts-dev libkdtree++-dev libkml-dev libmedc-dev libocct-data-exchange-dev \ libocct-draw-dev libocct-foundation-dev libocct-modeling-algorithms-dev \ libocct-modeling-data-dev libocct-ocaf-dev libocct-visualization-dev \ - libopencv-dev libproj-dev libpyside2-dev libqt5svg5-dev libqt5webkit5-dev \ + libopencv-dev libproj-dev libpyside2-dev libqt5svg5-dev\ libshiboken2-dev libvtk9-dev libvtk9-qt-dev \ libvtk-dicom-dev libx11-dev libxerces-c-dev libxmu-dev libxmuu-dev \ libzipios++-dev netgen netgen-headers pyside2-tools python3-dev \