From 473a02ad433844a7f2f26675e9e17f3dc16dd1b5 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sat, 31 Dec 2022 22:14:43 -0500 Subject: [PATCH 01/58] fix deprecations in QLocale and QFlags --- Source/WebCore/bridge/qt/qt_runtime.cpp | 24 +++++++++++++++++------ Tools/DumpRenderTree/qt/EventSenderQt.cpp | 18 ++++++++--------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp index 5f3d086ca58ae..8d52143689220 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime.cpp @@ -559,9 +559,13 @@ QVariant convertValueToQVariant(JSContextRef context, JSValueRef value, QMetaTyp if (!dt.isValid()) dt = QDateTime::fromString(qstring, Qt::TextDate); if (!dt.isValid()) - dt = QDateTime::fromString(qstring, Qt::SystemLocaleDate); + dt = QLocale::system().toDateTime(qstring, QLocale::ShortFormat); if (!dt.isValid()) - dt = QDateTime::fromString(qstring, Qt::LocaleDate); + dt = QLocale::system().toDateTime(qstring, QLocale::LongFormat); + if (!dt.isValid()) + dt = QLocale().toDateTime(qstring, QLocale::ShortFormat); + if (!dt.isValid()) + dt = QLocale().toDateTime(qstring, QLocale::LongFormat); if (dt.isValid()) { ret = dt; dist = 2; @@ -571,9 +575,13 @@ QVariant convertValueToQVariant(JSContextRef context, JSValueRef value, QMetaTyp if (!dt.isValid()) dt = QDate::fromString(qstring, Qt::TextDate); if (!dt.isValid()) - dt = QDate::fromString(qstring, Qt::SystemLocaleDate); + dt = QLocale::system().toDate(qstring, QLocale::ShortFormat); + if (!dt.isValid()) + dt = QLocale::system().toDate(qstring, QLocale::LongFormat); if (!dt.isValid()) - dt = QDate::fromString(qstring, Qt::LocaleDate); + dt = QLocale().toDate(qstring, QLocale::ShortFormat); + if (!dt.isValid()) + dt = QLocale().toDate(qstring, QLocale::LongFormat); if (dt.isValid()) { ret = dt; dist = 3; @@ -583,9 +591,13 @@ QVariant convertValueToQVariant(JSContextRef context, JSValueRef value, QMetaTyp if (!dt.isValid()) dt = QTime::fromString(qstring, Qt::TextDate); if (!dt.isValid()) - dt = QTime::fromString(qstring, Qt::SystemLocaleDate); + dt = QLocale::system().toTime(qstring, QLocale::ShortFormat); + if (!dt.isValid()) + dt = QLocale::system().toTime(qstring, QLocale::LongFormat); + if (!dt.isValid()) + dt = QLocale().toTime(qstring, QLocale::ShortFormat); if (!dt.isValid()) - dt = QTime::fromString(qstring, Qt::LocaleDate); + dt = QLocale().toTime(qstring, QLocale::LongFormat); if (dt.isValid()) { ret = dt; dist = 3; diff --git a/Tools/DumpRenderTree/qt/EventSenderQt.cpp b/Tools/DumpRenderTree/qt/EventSenderQt.cpp index 563286526687a..6852785368be8 100644 --- a/Tools/DumpRenderTree/qt/EventSenderQt.cpp +++ b/Tools/DumpRenderTree/qt/EventSenderQt.cpp @@ -73,7 +73,7 @@ EventSender::EventSender(QWebPage* parent) startOfQueue = 0; m_eventLoop = 0; m_currentButton = 0; - m_currentDragActionsAllowed = 0; + m_currentDragActionsAllowed = { }; resetClickCount(); m_page->view()->installEventFilter(this); // This is a hack that works because we normally scroll 60 pixels (3*20) per tick, but Apple scrolls 120. @@ -83,7 +83,7 @@ EventSender::EventSender(QWebPage* parent) static Qt::KeyboardModifiers getModifiers(const QStringList& modifiers) { - Qt::KeyboardModifiers modifs = 0; + Qt::KeyboardModifiers modifs = { }; for (int i = 0; i < modifiers.size(); ++i) { const QString& m = modifiers.at(i); if (m == "ctrlKey") @@ -107,14 +107,14 @@ void EventSender::mouseDown(int button, const QStringList& modifiers) mouseButton = Qt::LeftButton; break; case 1: - mouseButton = Qt::MidButton; + mouseButton = Qt::MiddleButton; break; case 2: mouseButton = Qt::RightButton; break; case 3: // fast/events/mouse-click-events expects the 4th button to be treated as the middle button - mouseButton = Qt::MidButton; + mouseButton = Qt::MiddleButton; break; default: mouseButton = Qt::LeftButton; @@ -159,14 +159,14 @@ void EventSender::mouseUp(int button) mouseButton = Qt::LeftButton; break; case 1: - mouseButton = Qt::MidButton; + mouseButton = Qt::MiddleButton; break; case 2: mouseButton = Qt::RightButton; break; case 3: // fast/events/mouse-click-events expects the 4th button to be treated as the middle button - mouseButton = Qt::MidButton; + mouseButton = Qt::MiddleButton; break; default: mouseButton = Qt::LeftButton; @@ -309,7 +309,7 @@ void EventSender::keyDown(const QString& string, const QStringList& modifiers, u // position. Allows us to pass emacs-ctrl-o.html s = QLatin1String("\n"); code = '\n'; - modifs = 0; + modifs = { }; QKeyEvent event(QEvent::KeyPress, code, modifs, s); sendEvent(m_page, &event); QKeyEvent event2(QEvent::KeyRelease, code, modifs, s); @@ -325,7 +325,7 @@ void EventSender::keyDown(const QString& string, const QStringList& modifiers, u } else if (code == 'a' && modifs == Qt::ControlModifier) { s = QString(); code = Qt::Key_Home; - modifs = 0; + modifs = { }; } else if (code == KEYCODE_LEFTARROW) { s = QString(); code = Qt::Key_Left; @@ -357,7 +357,7 @@ void EventSender::keyDown(const QString& string, const QStringList& modifiers, u } else if (code == 'a' && modifs == Qt::ControlModifier) { s = QString(); code = Qt::Key_Home; - modifs = 0; + modifs = { }; } else code = string.unicode()->toUpper().unicode(); } else { From b887deb97d8615ad15394c0de492e1250ead5109 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 13:03:33 -0500 Subject: [PATCH 02/58] QUrl::topLevelDomain() is deprecated, use private qTopLevelDomain() for now --- Source/WebCore/platform/network/qt/PublicSuffixQt.cpp | 2 +- Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp b/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp index 620acebafae3a..3492d5c7fb218 100644 --- a/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp +++ b/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp @@ -73,7 +73,7 @@ String topPrivatelyControlledDomain(const String& domain) QString tld = qTopLevelDomain(qLowercaseDomain); auto privateLabels = qLowercaseDomain.leftRef(qLowercaseDomain.length() - tld.length()); - auto topPrivateLabel = privateLabels.split(QLatin1Char('.'), QString::SkipEmptyParts).last(); + auto topPrivateLabel = privateLabels.split(QLatin1Char('.'), Qt::SkipEmptyParts).last(); return QString(topPrivateLabel + tld); } diff --git a/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp b/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp index b83638ebd574c..39b81d3d5eefb 100644 --- a/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp +++ b/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp @@ -28,6 +28,11 @@ #include #include #include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +Q_NETWORK_EXPORT QString qTopLevelDomain(QString domain); +#endif namespace WebCore { @@ -39,8 +44,8 @@ inline void removeTopLevelDomain(QString* domain, const QString& topLevelDomain) static bool urlsShareSameDomain(const QUrl& url, const QUrl& firstPartyUrl) { - QString firstPartyTLD = firstPartyUrl.topLevelDomain(); - QString requestTLD = url.topLevelDomain(); + QString firstPartyTLD = qTopLevelDomain(firstPartyUrl.host()); + QString requestTLD = qTopLevelDomain(url.host()); if (firstPartyTLD != requestTLD) return false; @@ -88,4 +93,3 @@ bool thirdPartyCookiePolicyPermits(const NetworkStorageSession* storageSession, } } -// vim: ts=4 sw=4 et From 77c19e8a3ee81ef0bb2ddd376b2c4bd555b06d05 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 13:08:34 -0500 Subject: [PATCH 03/58] qt6 deprecations around QNetworkRequest and QFontMetrics --- Source/WebCore/platform/network/qt/ResourceRequestQt.cpp | 2 +- Source/WebCore/platform/qt/RenderThemeQt.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp index b1e7d7e2e4d82..21ceac57fe9b0 100644 --- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -98,7 +98,7 @@ QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) co static const auto params = createHttp2Configuration(); request.setHttp2Configuration(params); #endif - request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true); + request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true); } #endif // USE(HTTP2) diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp index 8363608c11401..cae1a6ae75e12 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp @@ -272,7 +272,7 @@ int RenderThemeQt::minimumMenuListSize(const RenderStyle&) const { // FIXME: Later we need a way to query the UI process for the dpi const QFontMetrics fm(QGuiApplication::font()); - return fm.width(QLatin1Char('x')); + return fm.horizontalAdvance(QLatin1Char('x')); } void RenderThemeQt::setCheckboxSize(RenderStyle& style) const From 89d30c4f12c6c21b97fa2aefc05e9f0f69880800 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 20:54:19 -0500 Subject: [PATCH 04/58] more deprecations --- Source/WebKitLegacy/qt/Api/qwebelement.cpp | 2 +- Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WebKitLegacy/qt/Api/qwebelement.cpp b/Source/WebKitLegacy/qt/Api/qwebelement.cpp index 74ebf86831da3..535e573334b2b 100644 --- a/Source/WebKitLegacy/qt/Api/qwebelement.cpp +++ b/Source/WebKitLegacy/qt/Api/qwebelement.cpp @@ -816,7 +816,7 @@ QStringList QWebElement::classes() const if (!hasAttribute(QLatin1String("class"))) return QStringList(); - QStringList classes = attribute(QLatin1String("class")).simplified().split(QLatin1Char(' '), QString::SkipEmptyParts); + QStringList classes = attribute(QLatin1String("class")).simplified().split(QLatin1Char(' '), Qt::SkipEmptyParts); classes.removeDuplicates(); return classes; } diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp index cec7009d58957..2160df3f9dcdf 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp @@ -75,7 +75,7 @@ static void mouseEventTypeAndMouseButtonFromQEvent(const QEvent* event, Platform mouseButton = LeftButton; else if (mouseButtons & Qt::RightButton) mouseButton = RightButton; - else if (mouseButtons & Qt::MidButton) + else if (mouseButtons & Qt::MiddleButton) mouseButton = MiddleButton; else mouseButton = NoButton; From 23f7ddb53ac81801bcf391fcbe913905357ee3f5 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 20:55:06 -0500 Subject: [PATCH 05/58] QRegion::rects() deprecated; use iterator instead --- .../qt/WebCoreSupport/QWebFrameAdapter.cpp | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp index 4a55f5df0f810..b3b42a161d9c8 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp @@ -458,30 +458,28 @@ QString QWebFrameAdapter::uniqueName() const return frame->tree().uniqueName().string(); } -// This code is copied from ChromeClientGtk.cpp. -static void coalesceRectsIfPossible(const QRect& clipRect, QVector& rects) +// This code is loosely copied from ChromeClientGtk.cpp. +static bool shouldCoalesceRects(const QRegion& clip) { const int rectThreshold = 10; const float wastedSpaceThreshold = 0.75f; - bool useUnionedRect = (rects.size() <= 1) || (rects.size() > rectThreshold); + + bool useUnionedRect = (clip.rectCount() <= 1) || (clip.rectCount() > rectThreshold); if (!useUnionedRect) { // Attempt to guess whether or not we should use the unioned rect or the individual rects. // We do this by computing the percentage of "wasted space" in the union. If that wasted space // is too large, then we will do individual rect painting instead. - float unionPixels = (clipRect.width() * clipRect.height()); + float unionPixels = (clip.boundingRect().width() * clip.boundingRect().height()); float singlePixels = 0; - for (auto& rect : rects) + for (const QRect& rect : clip) singlePixels += rect.width() * rect.height(); + float wastedSpace = 1 - (singlePixels / unionPixels); if (wastedSpace <= wastedSpaceThreshold) - useUnionedRect = true; + return true; } - if (!useUnionedRect) - return; - - rects.clear(); - rects.append(clipRect); + return useUnionedRect; } void QWebFrameAdapter::renderRelativeCoords(QPainter* painter, int layers, const QRegion& clip) @@ -493,8 +491,7 @@ void QWebFrameAdapter::renderRelativeCoords(QPainter* painter, int layers, const if (!frame->view() || !frame->contentRenderer()) return; - QVector vector = clip.rects(); - if (vector.isEmpty()) + if (clip.rectCount() == 0) return; WebCore::FrameView* view = frame->view(); @@ -502,10 +499,7 @@ void QWebFrameAdapter::renderRelativeCoords(QPainter* painter, int layers, const if (layers & ContentsLayer) { QRect clipBoundingRect = clip.boundingRect(); - coalesceRectsIfPossible(clipBoundingRect, vector); - for (int i = 0; i < vector.size(); ++i) { - const QRect& clipRect = vector.at(i); - + for (const QRect &clipRect : shouldCoalesceRects(clip) ? clipBoundingRect : clip) { QRect rect = clipRect.intersected(view->frameRect()); context.save(); @@ -544,10 +538,7 @@ void QWebFrameAdapter::renderFrameExtras(GraphicsContext& context, int layers, c return; QPainter* painter = context.platformContext()->painter(); WebCore::FrameView* view = frame->view(); - QVector vector = clip.rects(); - for (int i = 0; i < vector.size(); ++i) { - const QRect& clipRect = vector.at(i); - + for (const QRect& clipRect : clip) { QRect intersectedRect = clipRect.intersected(view->frameRect()); painter->save(); From ba3b92869b40b0d042ed063badad29006fbad52c Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 21:43:40 -0500 Subject: [PATCH 06/58] replace sprintf with qstring arg()s --- .../WebCoreSupport/DumpRenderTreeSupportQt.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index 52e7a527fea08..51e427e486aa5 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -457,16 +457,13 @@ QString DumpRenderTreeSupportQt::viewportAsText(QWebPageAdapter* adapter, int de WebCore::restrictMinimumScaleFactorToViewportSize(conf, availableSize, devicePixelRatio); WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(conf); - QString res; - res = res.sprintf("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", - static_cast(conf.layoutSize.width()), - static_cast(conf.layoutSize.height()), - conf.initialScale, - conf.minimumScale, - conf.maximumScale, - conf.userScalable); - - return res; + return QLatin1String("viewport size %1x%2 scale %3 with limits [%4, %5] and userScalable %6\n") + .arg(static_cast(conf.layoutSize.width())) + .arg(static_cast(conf.layoutSize.height())) + .arg(conf.initialScale) + .arg(conf.minimumScale) + .arg(conf.maximumScale) + .arg(conf.userScalable); } void DumpRenderTreeSupportQt::scalePageBy(QWebFrameAdapter* adapter, float scalefactor, const QPoint& origin) From 95f0c4df08d9cf6dbb162f9443cfe9747cf3df55 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 21:46:00 -0500 Subject: [PATCH 07/58] constant deprecations --- Source/WebKitLegacy/qt/WebCoreSupport/QWebPageAdapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/QWebPageAdapter.cpp index daeac1120cb6e..9bba2c3a4148a 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/QWebPageAdapter.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/QWebPageAdapter.cpp @@ -811,7 +811,7 @@ QVariant QWebPageAdapter::inputMethodQuery(Qt::InputMethodQuery property) const renderTextControl = downcast(renderer); switch (property) { - case Qt::ImMicroFocus: { + case Qt::ImCursorRectangle: { WebCore::FrameView* view = frame->view(); if (view && view->needsLayout()) { // We can't access absoluteCaretBounds() while the view needs to layout. From 754b2f934c03c5ebb4146524d40aaee7762abfb7 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 21:49:40 -0500 Subject: [PATCH 08/58] use QGuiApplication::screens() to determine desktop size --- Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp b/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp index 8442d9f45dc8c..a6fdf4225ebb6 100644 --- a/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp +++ b/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp @@ -2079,18 +2079,18 @@ static int getintenv(const char* variable) static QSize queryDeviceSizeForScreenContainingWidget(const QWidget* widget) { - QDesktopWidget* desktop = QApplication::desktop(); - if (!desktop) - return QSize(); - - QSize size; - + QScreen* screen; if (widget) { - // Returns the available geometry of the screen which contains widget. - // NOTE: this must be the the full screen size including any fixed status areas etc. - size = desktop->availableGeometry(widget).size(); + screen = QGuiApplication::screenAt(widget->pos()); } else - size = desktop->availableGeometry().size(); + screen = QGuiApplication::screens().at(0); + + if (!screen) + return QSize(); + + // Returns the available geometry of the screen which contains widget. + // NOTE: this must be the the full screen size including any fixed status areas etc. + QSize size = screen->size(); // This must be in portrait mode, adjust if not. if (size.width() > size.height()) { From c6c21452ee1ede6cc8bbb87c89c1576a610c8f62 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 22:50:07 -0500 Subject: [PATCH 09/58] lastResortFamily() is deprecated; use what they hardcoded: helvetica --- Source/WebCore/platform/graphics/qt/FontCacheQt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp index 0725c6ca5a64c..d81e0017e1dbc 100644 --- a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp @@ -91,7 +91,7 @@ bool FontCache::isSystemFontForbiddenForEditing(const String&) Ref FontCache::lastResortFallbackFont(const FontDescription& fontDescription) { - const AtomString fallbackFamily = AtomString(QFont(/*fontDescription.firstFamily()*/).lastResortFamily()); // FIXME + const AtomString fallbackFamily = AtomString("helvetica"_s); // FIXME FontPlatformData platformData(fontDescription, fallbackFamily); return fontForPlatformData(platformData); } From 4c017332f5986569a2eb3c97a4571d93f965f481 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 1 Jan 2023 22:52:00 -0500 Subject: [PATCH 10/58] deprecations --- Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp | 4 ++-- Tools/QtTestBrowser/launcherwindow.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp index 3c0371857a7cf..cdb0385913702 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp +++ b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp @@ -405,7 +405,7 @@ void QStyleFacadeImp::paintProgressBar(QPainter* painter, const QStyleFacadeOpti // we simulate one square animating across the progress bar. style()->drawControl(QStyle::CE_ProgressBarGroove, &option, painter, widget); int chunkWidth = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option); - QColor color = (option.palette.highlight() == option.palette.background()) ? option.palette.color(QPalette::Active, QPalette::Highlight) : option.palette.color(QPalette::Highlight); + QColor color = (option.palette.highlight() == option.palette.window()) ? option.palette.color(QPalette::Active, QPalette::Highlight) : option.palette.color(QPalette::Highlight); if (option.direction == Qt::RightToLeft) painter->fillRect(option.rect.right() - chunkWidth - animationProgress * option.rect.width(), 0, chunkWidth, option.rect.height(), color); else @@ -464,7 +464,7 @@ void QStyleFacadeImp::paintScrollBar(QPainter *painter, const QStyleFacadeOption opt.styleObject = 0; } - painter->fillRect(opt.rect, opt.palette.background()); + painter->fillRect(opt.rect, opt.palette.window()); const QPoint topLeft = opt.rect.topLeft(); painter->translate(topLeft); diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp index 4ef7b201e512c..d3952c800726e 100644 --- a/Tools/QtTestBrowser/launcherwindow.cpp +++ b/Tools/QtTestBrowser/launcherwindow.cpp @@ -1154,7 +1154,7 @@ void LauncherWindow::showUserAgentDialog() #ifndef QT_NO_COMBOBOX QComboBox* combo = new QComboBox(dialog); - combo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); + combo->setSizeAdjustPolicy(QComboBox::AdjustToContents); combo->setEditable(true); combo->insertItems(0, items); layout->addWidget(combo); From 728d0ec17577a1534a24a0cf7c2d0aa433ca1b0e Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 2 Jan 2023 00:02:21 -0500 Subject: [PATCH 11/58] Update QtWebkit to Qt 6 Many things are broken and/or disabled, but it may serve as a basis for a proper and complete update. --- Source/JavaScriptCore/PlatformQt.cmake | 4 +- Source/PlatformQt.cmake | 100 ++++++++--------- Source/Qt5WebKitConfig.cmake.in | 13 --- Source/Qt5WebKitWidgetsConfig.cmake.in | 12 --- Source/Qt6WebKitConfig.cmake.in | 13 +++ Source/Qt6WebKitWidgetsConfig.cmake.in | 12 +++ Source/WTF/wtf/PlatformQt.cmake | 4 +- Source/WTF/wtf/text/WTFString.h | 3 +- Source/WTF/wtf/text/qt/StringQt.cpp | 7 +- Source/WebCore/PlatformQt.cmake | 32 +++--- Source/WebCore/bridge/qt/qt_class.cpp | 2 +- Source/WebCore/bridge/qt/qt_instance.cpp | 6 +- Source/WebCore/bridge/qt/qt_runtime.cpp | 50 +++++---- .../WebCore/platform/LegacySchemeRegistry.h | 2 +- .../platform/graphics/qt/FontCascadeQt.cpp | 2 +- .../network/qt/NetworkStateNotifierQt.cpp | 31 +++--- .../platform/network/qt/PublicSuffixQt.cpp | 18 +++- .../network/qt/QNetworkReplyHandler.cpp | 2 +- .../platform/network/qt/QtMIMETypeSniffer.cpp | 2 +- .../platform/network/qt/SharedCookieJarQt.cpp | 4 +- Source/WebCore/platform/qt/DragDataQt.cpp | 4 +- .../WebCore/platform/qt/RenderThemeQStyle.cpp | 1 + Source/WebInspectorUI/PlatformQt.cmake | 2 +- .../NetworkProcess/qt/NetworkDataTaskQt.cpp | 3 +- Source/WebKit/PlatformQt.cmake | 12 +-- Source/WebKit/PlatformWPE.cmake | 6 +- Source/WebKit/Shared/NativeWebKeyboardEvent.h | 5 +- .../Shared/qt/NativeWebKeyboardEventQt.cpp | 8 +- Source/WebKit/Shared/qt/WebEventFactory.h | 6 +- Source/WebKit/Shared/qt/WebEventFactoryQt.cpp | 27 +++-- .../API/qt/qquickurlschemedelegate.cpp | 2 +- .../WebKit/UIProcess/API/qt/qquickwebpage.cpp | 4 +- .../WebKit/UIProcess/API/qt/qquickwebview.cpp | 99 ++++++++--------- .../WebKit/UIProcess/API/qt/qquickwebview_p.h | 8 +- .../UIProcess/API/qt/qwebdownloaditem_p_p.h | 2 +- .../API/qt/qwebiconimageprovider.cpp | 2 +- .../WebKit/UIProcess/API/qt/qwebkittest.cpp | 52 +++++---- .../API/qt/qwebnavigationrequest.cpp | 2 +- .../UIProcess/API/qt/qwebpreferences.cpp | 62 +++++------ .../UIProcess/API/qt/tests/CMakeLists.txt | 14 +-- .../DrawingAreaProxyCoordinatedGraphics.cpp | 2 +- .../Launcher/qt/ProcessLauncherQt.cpp | 7 +- .../UIProcess/qt/ColorChooserContextObject.h | 4 +- .../UIProcess/qt/DialogContextObjects.h | 24 ++--- .../qt/ItemSelectorContextObject.cpp | 12 +-- .../UIProcess/qt/ItemSelectorContextObject.h | 4 +- .../WebKit/UIProcess/qt/QtDownloadManager.cpp | 8 +- Source/WebKit/UIProcess/qt/QtPageClient.cpp | 4 +- .../UIProcess/qt/QtTapGestureRecognizer.cpp | 4 +- Source/WebKit/UIProcess/qt/QtWebContext.cpp | 10 +- .../UIProcess/qt/QtWebIconDatabaseClient.cpp | 2 +- .../UIProcess/qt/QtWebPagePolicyClient.cpp | 2 +- .../WebKit/UIProcess/qt/QtWebPageUIClient.cpp | 4 +- .../WebKit/UIProcess/qt/WebPreferencesQt.cpp | 1 + Source/WebKitLegacy/CMakeLists.txt | 2 +- Source/WebKitLegacy/PlatformQt.cmake | 64 +++++------ Source/WebKitLegacy/qt/Api/qwebsettings.cpp | 5 +- .../qt/WebCoreSupport/ChromeClientQt.cpp | 4 +- .../qt/WebCoreSupport/EditorClientQt.cpp | 4 +- .../qt/WebCoreSupport/FrameLoaderClientQt.cpp | 8 +- .../ProgressTrackerClientQt.cpp | 2 +- .../qt/WebCoreSupport/QWebFrameAdapter.cpp | 2 +- .../qt/WebCoreSupport/WebEventConversion.cpp | 19 ++-- .../qt/WidgetApi/qgraphicswebview.cpp | 4 +- .../WebKitLegacy/qt/WidgetApi/qwebframe.cpp | 22 ++-- Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp | 73 +++++++------ .../WebKitLegacy/qt/WidgetApi/qwebpage_p.cpp | 4 +- .../qt/WidgetSupport/PageClientQt.cpp | 17 --- .../qt/WidgetSupport/QStyleFacadeImp.cpp | 2 +- .../qt/WidgetSupport/QtFallbackWebPopup.cpp | 2 +- .../qt/WidgetSupport/QtWebComboBox.cpp | 2 +- .../qt/declarative/CMakeLists.txt | 6 +- .../declarative/experimental/CMakeLists.txt | 2 +- Source/WebKitLegacy/qt/tests/CMakeLists.txt | 14 +-- Source/cmake/ECMGeneratePkgConfigFile.cmake | 2 +- Source/cmake/ECMGeneratePriFile.cmake | 2 +- Source/cmake/ECMQueryQmake.cmake | 10 +- Source/cmake/KDEInstallDirs.cmake | 10 -- Source/cmake/OptionsQt.cmake | 102 ++++++++++++------ Source/cmake/OptionsWPE.cmake | 5 +- Tools/DumpRenderTree/PlatformQt.cmake | 16 +-- Tools/ImageDiff/PlatformQt.cmake | 4 +- Tools/MiniBrowser/qt/BrowserWindow.cpp | 21 ++-- Tools/MiniBrowser/qt/BrowserWindow.h | 2 +- Tools/MiniBrowser/qt/CMakeLists.txt | 8 +- .../MiniBrowser/qt/MiniBrowserApplication.cpp | 81 +++++++------- Tools/MiniBrowser/qt/MiniBrowserApplication.h | 7 +- Tools/MiniBrowser/qt/UrlLoader.cpp | 8 +- Tools/MiniBrowser/wpe/qt/CMakeLists.txt | 2 +- Tools/QtTestBrowser/CMakeLists.txt | 26 +++-- Tools/QtTestBrowser/cookiejar.cpp | 4 +- Tools/QtTestBrowser/launcherwindow.cpp | 102 ++++++------------ Tools/QtTestBrowser/launcherwindow.h | 9 +- Tools/QtTestBrowser/qttestbrowser.cpp | 14 +-- Tools/QtTestBrowser/urlloader.cpp | 4 +- Tools/QtTestBrowser/webinspector.h | 4 +- Tools/QtTestBrowser/webview.cpp | 2 +- Tools/Scripts/webkitdirs.pm | 2 +- Tools/Scripts/webkitpy/port/qt.py | 2 +- Tools/TestWebKitAPI/PlatformQt.cmake | 2 +- Tools/TestWebKitAPI/glib/CMakeLists.txt | 6 +- Tools/WebKitTestRunner/PlatformQt.cmake | 22 ++-- Tools/qmake/projects/run_cmake.pro | 2 +- Tools/qt/QtBinaryChecklist.txt | 68 ++++++------ tests/webkitqml/CMakeLists.txt | 14 +-- tests/webkitwidgets/CMakeLists.txt | 14 +-- tests/webkitwidgets/cmake/CMakeLists.txt | 6 +- 107 files changed, 794 insertions(+), 775 deletions(-) delete mode 100644 Source/Qt5WebKitConfig.cmake.in delete mode 100644 Source/Qt5WebKitWidgetsConfig.cmake.in create mode 100644 Source/Qt6WebKitConfig.cmake.in create mode 100644 Source/Qt6WebKitWidgetsConfig.cmake.in diff --git a/Source/JavaScriptCore/PlatformQt.cmake b/Source/JavaScriptCore/PlatformQt.cmake index f94f928739ca2..87d49322332fe 100644 --- a/Source/JavaScriptCore/PlatformQt.cmake +++ b/Source/JavaScriptCore/PlatformQt.cmake @@ -15,11 +15,11 @@ list(APPEND JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS ) list(APPEND JavaScriptCore_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Core_INCLUDE_DIRS} + ${Qt6Core_INCLUDE_DIRS} ) list(APPEND JavaScriptCore_LIBRARIES - ${Qt5Core_LIBRARIES} + ${Qt6Core_LIBRARIES} ) if (QT_STATIC_BUILD) diff --git a/Source/PlatformQt.cmake b/Source/PlatformQt.cmake index c70afacb1e801..bc5baabcd069e 100644 --- a/Source/PlatformQt.cmake +++ b/Source/PlatformQt.cmake @@ -132,35 +132,35 @@ endmacro () set(_package_footer_template " ####### Expanded from QTWEBKIT_PACKAGE_FOOTER variable ####### -set(Qt5@MODULE_NAME@_LIBRARIES Qt5::@MODULE_NAME@) -set(Qt5@MODULE_NAME@_VERSION_STRING \${Qt5@MODULE_NAME@_VERSION}) -set(Qt5@MODULE_NAME@_EXECUTABLE_COMPILE_FLAGS \"\") -set(Qt5@MODULE_NAME@_PRIVATE_INCLUDE_DIRS \"\") # FIXME: Support private headers - -get_target_property(Qt5@MODULE_NAME@_INCLUDE_DIRS Qt5::@FULL_MODULE_NAME@ INTERFACE_INCLUDE_DIRECTORIES) -get_target_property(Qt5@MODULE_NAME@_COMPILE_DEFINITIONS Qt5::@FULL_MODULE_NAME@ INTERFACE_COMPILE_DEFINITIONS) - -foreach (_module_dep \${_Qt5@MODULE_NAME@_MODULE_DEPENDENCIES}) - list(APPEND Qt5@MODULE_NAME@_INCLUDE_DIRS \${Qt5\${_module_dep}_INCLUDE_DIRS}) - list(APPEND Qt5@MODULE_NAME@_PRIVATE_INCLUDE_DIRS \${Qt5\${_module_dep}_PRIVATE_INCLUDE_DIRS}) - list(APPEND Qt5@MODULE_NAME@_DEFINITIONS \${Qt5\${_module_dep}_DEFINITIONS}) - list(APPEND Qt5@MODULE_NAME@_COMPILE_DEFINITIONS \${Qt5\${_module_dep}_COMPILE_DEFINITIONS}) - list(APPEND Qt5@MODULE_NAME@_EXECUTABLE_COMPILE_FLAGS \${Qt5\${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) +set(Qt6@MODULE_NAME@_LIBRARIES Qt6::@MODULE_NAME@) +set(Qt6@MODULE_NAME@_VERSION_STRING \${Qt6@MODULE_NAME@_VERSION}) +set(Qt6@MODULE_NAME@_EXECUTABLE_COMPILE_FLAGS \"\") +set(Qt6@MODULE_NAME@_PRIVATE_INCLUDE_DIRS \"\") # FIXME: Support private headers + +get_target_property(Qt6@MODULE_NAME@_INCLUDE_DIRS Qt6::@FULL_MODULE_NAME@ INTERFACE_INCLUDE_DIRECTORIES) +get_target_property(Qt6@MODULE_NAME@_COMPILE_DEFINITIONS Qt6::@FULL_MODULE_NAME@ INTERFACE_COMPILE_DEFINITIONS) + +foreach (_module_dep \${_Qt6@MODULE_NAME@_MODULE_DEPENDENCIES}) + list(APPEND Qt6@MODULE_NAME@_INCLUDE_DIRS \${Qt6\${_module_dep}_INCLUDE_DIRS}) + list(APPEND Qt6@MODULE_NAME@_PRIVATE_INCLUDE_DIRS \${Qt6\${_module_dep}_PRIVATE_INCLUDE_DIRS}) + list(APPEND Qt6@MODULE_NAME@_DEFINITIONS \${Qt6\${_module_dep}_DEFINITIONS}) + list(APPEND Qt6@MODULE_NAME@_COMPILE_DEFINITIONS \${Qt6\${_module_dep}_COMPILE_DEFINITIONS}) + list(APPEND Qt6@MODULE_NAME@_EXECUTABLE_COMPILE_FLAGS \${Qt6\${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) endforeach () -list(REMOVE_DUPLICATES Qt5@MODULE_NAME@_INCLUDE_DIRS) -list(REMOVE_DUPLICATES Qt5@MODULE_NAME@_PRIVATE_INCLUDE_DIRS) -list(REMOVE_DUPLICATES Qt5@MODULE_NAME@_DEFINITIONS) -list(REMOVE_DUPLICATES Qt5@MODULE_NAME@_COMPILE_DEFINITIONS) -list(REMOVE_DUPLICATES Qt5@MODULE_NAME@_EXECUTABLE_COMPILE_FLAGS) +list(REMOVE_DUPLICATES Qt6@MODULE_NAME@_INCLUDE_DIRS) +list(REMOVE_DUPLICATES Qt6@MODULE_NAME@_PRIVATE_INCLUDE_DIRS) +list(REMOVE_DUPLICATES Qt6@MODULE_NAME@_DEFINITIONS) +list(REMOVE_DUPLICATES Qt6@MODULE_NAME@_COMPILE_DEFINITIONS) +list(REMOVE_DUPLICATES Qt6@MODULE_NAME@_EXECUTABLE_COMPILE_FLAGS) # Fixup order of configurations to match behavior of other Qt modules # See also https://bugreports.qt.io/browse/QTBUG-29186 -get_target_property(_configurations Qt5::@FULL_MODULE_NAME@ IMPORTED_CONFIGURATIONS) +get_target_property(_configurations Qt6::@FULL_MODULE_NAME@ IMPORTED_CONFIGURATIONS) list(FIND _configurations RELEASE _index) if (\${_index} GREATER -1) list(REMOVE_AT _configurations \${_index}) list(INSERT _configurations 0 RELEASE) - set_property(TARGET Qt5::@FULL_MODULE_NAME@ PROPERTY IMPORTED_CONFIGURATIONS \"\${_configurations}\") + set_property(TARGET Qt6::@FULL_MODULE_NAME@ PROPERTY IMPORTED_CONFIGURATIONS \"\${_configurations}\") endif () unset(_configurations) unset(_index) @@ -169,73 +169,73 @@ unset(_index) set(MODULE_NAME WebKit) set(FULL_MODULE_NAME WebKitLegacy) string(CONFIGURE ${_package_footer_template} QTWEBKIT_PACKAGE_FOOTER @ONLY) -ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Qt5WebKitConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitConfig.cmake" - INSTALL_DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKit" +ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Qt6WebKitConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitConfig.cmake" + INSTALL_DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt6WebKit" ) set(MODULE_NAME WebKitWidgets) set(FULL_MODULE_NAME WebKitWidgets) string(CONFIGURE ${_package_footer_template} QTWEBKIT_PACKAGE_FOOTER @ONLY) -ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Qt5WebKitWidgetsConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitWidgetsConfig.cmake" - INSTALL_DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKitWidgets" +ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Qt6WebKitWidgetsConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitWidgetsConfig.cmake" + INSTALL_DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt6WebKitWidgets" ) unset(MODULE_NAME) unset(FULL_MODULE_NAME) unset(QTWEBKIT_PACKAGE_FOOTER) -write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitConfigVersion.cmake" +write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) -write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitWidgetsConfigVersion.cmake" +write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitWidgetsConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitConfigVersion.cmake" - DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKit" + "${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitConfigVersion.cmake" + DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt6WebKit" COMPONENT Data ) install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitWidgetsConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/Qt5WebKitWidgetsConfigVersion.cmake" - DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKitWidgets" + "${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitWidgetsConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/Qt6WebKitWidgetsConfigVersion.cmake" + DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt6WebKitWidgets" COMPONENT Data ) # We need to install separate config files for debug and release, so use "Code" component install(EXPORT WebKitTargets FILE WebKitTargets.cmake - NAMESPACE Qt5:: - DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKit" + NAMESPACE Qt6:: + DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt6WebKit" COMPONENT Code ) -install(EXPORT Qt5WebKitWidgetsTargets - FILE Qt5WebKitWidgetsTargets.cmake - NAMESPACE Qt5:: - DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt5WebKitWidgets" +install(EXPORT Qt6WebKitWidgetsTargets + FILE Qt6WebKitWidgetsTargets.cmake + NAMESPACE Qt6:: + DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/Qt6WebKitWidgets" COMPONENT Code ) # Documentation -if (NOT TARGET Qt5::qdoc) - add_executable(Qt5::qdoc IMPORTED) +if (NOT TARGET Qt6::qdoc) + add_executable(Qt6::qdoc IMPORTED) query_qmake(QDOC_EXECUTABLE QT_INSTALL_BINS) set(QDOC_EXECUTABLE "${QDOC_EXECUTABLE}/qdoc") - set_target_properties(Qt5::qdoc PROPERTIES + set_target_properties(Qt6::qdoc PROPERTIES IMPORTED_LOCATION ${QDOC_EXECUTABLE} ) endif () -if (NOT TARGET Qt5::qhelpgenerator) - add_executable(Qt5::qhelpgenerator IMPORTED) +if (NOT TARGET Qt6::qhelpgenerator) + add_executable(Qt6::qhelpgenerator IMPORTED) query_qmake(QHELPGENERATOR_EXECUTABLE QT_INSTALL_BINS) set(QHELPGENERATOR_EXECUTABLE "${QHELPGENERATOR_EXECUTABLE}/qhelpgenerator") - set_target_properties(Qt5::qhelpgenerator PROPERTIES + set_target_properties(Qt6::qhelpgenerator PROPERTIES IMPORTED_LOCATION ${QHELPGENERATOR_EXECUTABLE} ) endif () @@ -272,13 +272,13 @@ set(EXPORT_VARS_COMMANDS add_custom_target(prepare_docs ${NEED_ALL} ${EXPORT_VARS_COMMANDS} - COMMAND Qt5::qdoc ${QDOC_CONFIG} -prepare -outputdir "${DOC_OUTPUT_DIR}/qtwebkit" -installdir ${DOC_INSTALL_DIR} -indexdir ${QT_INSTALL_DOCS} -no-link-errors + COMMAND Qt6::qdoc ${QDOC_CONFIG} -prepare -outputdir "${DOC_OUTPUT_DIR}/qtwebkit" -installdir ${DOC_INSTALL_DIR} -indexdir ${QT_INSTALL_DOCS} -no-link-errors VERBATIM ) add_custom_target(generate_docs ${NEED_ALL} ${EXPORT_VARS_COMMANDS} - COMMAND Qt5::qdoc ${QDOC_CONFIG} -generate -outputdir "${DOC_OUTPUT_DIR}/qtwebkit" -installdir ${DOC_INSTALL_DIR} -indexdir ${QT_INSTALL_DOCS} + COMMAND Qt6::qdoc ${QDOC_CONFIG} -generate -outputdir "${DOC_OUTPUT_DIR}/qtwebkit" -installdir ${DOC_INSTALL_DIR} -indexdir ${QT_INSTALL_DOCS} VERBATIM ) add_dependencies(generate_docs prepare_docs) @@ -287,7 +287,7 @@ add_custom_target(html_docs) add_dependencies(html_docs generate_docs) add_custom_target(qch_docs ${NEED_ALL} - COMMAND Qt5::qhelpgenerator "${DOC_OUTPUT_DIR}/qtwebkit/qtwebkit.qhp" -o "${DOC_OUTPUT_DIR}/qtwebkit.qch" + COMMAND Qt6::qhelpgenerator "${DOC_OUTPUT_DIR}/qtwebkit/qtwebkit.qhp" -o "${DOC_OUTPUT_DIR}/qtwebkit.qch" VERBATIM ) add_dependencies(qch_docs html_docs) diff --git a/Source/Qt5WebKitConfig.cmake.in b/Source/Qt5WebKitConfig.cmake.in deleted file mode 100644 index a50d0353fd588..0000000000000 --- a/Source/Qt5WebKitConfig.cmake.in +++ /dev/null @@ -1,13 +0,0 @@ -@PACKAGE_INIT@ -@QTWEBKIT_PACKAGE_INIT@ - -find_dependency_with_major_and_minor(Qt5Core @Qt5_VERSION_MAJOR@ @Qt5_VERSION_MINOR@) -find_dependency_with_major_and_minor(Qt5Gui @Qt5_VERSION_MAJOR@ @Qt5_VERSION_MINOR@) -find_dependency_with_major_and_minor(Qt5Network @Qt5_VERSION_MAJOR@ @Qt5_VERSION_MINOR@) - -include("${CMAKE_CURRENT_LIST_DIR}/WebKitTargets.cmake") - -set(_Qt5WebKit_MODULE_DEPENDENCIES "Gui;Network;Core") -set(Qt5WebKit_DEFINITIONS -DQT_WEBKIT_LIB) - -@QTWEBKIT_PACKAGE_FOOTER@ diff --git a/Source/Qt5WebKitWidgetsConfig.cmake.in b/Source/Qt5WebKitWidgetsConfig.cmake.in deleted file mode 100644 index ef1c42956f4c3..0000000000000 --- a/Source/Qt5WebKitWidgetsConfig.cmake.in +++ /dev/null @@ -1,12 +0,0 @@ -@PACKAGE_INIT@ -@QTWEBKIT_PACKAGE_INIT@ - -find_dependency(Qt5WebKit @PROJECT_VERSION_STRING@ EXACT) -find_dependency_with_major_and_minor(Qt5Widgets @Qt5_VERSION_MAJOR@ @Qt5_VERSION_MINOR@) - -include("${CMAKE_CURRENT_LIST_DIR}/Qt5WebKitWidgetsTargets.cmake") - -set(_Qt5WebKitWidgets_MODULE_DEPENDENCIES "WebKit;Widgets;Gui;Network;Core") -set(Qt5WebKitWidgets_DEFINITIONS -DQT_WEBKITWIDGETS_LIB) - -@QTWEBKIT_PACKAGE_FOOTER@ diff --git a/Source/Qt6WebKitConfig.cmake.in b/Source/Qt6WebKitConfig.cmake.in new file mode 100644 index 0000000000000..538523ae50794 --- /dev/null +++ b/Source/Qt6WebKitConfig.cmake.in @@ -0,0 +1,13 @@ +@PACKAGE_INIT@ +@QTWEBKIT_PACKAGE_INIT@ + +find_dependency_with_major_and_minor(Qt6Core @Qt6_VERSION_MAJOR@ @Qt6_VERSION_MINOR@) +find_dependency_with_major_and_minor(Qt6Gui @Qt6_VERSION_MAJOR@ @Qt6_VERSION_MINOR@) +find_dependency_with_major_and_minor(Qt6Network @Qt6_VERSION_MAJOR@ @Qt6_VERSION_MINOR@) + +include("${CMAKE_CURRENT_LIST_DIR}/WebKitTargets.cmake") + +set(_Qt6WebKit_MODULE_DEPENDENCIES "Gui;Network;Core") +set(Qt6WebKit_DEFINITIONS -DQT_WEBKIT_LIB) + +@QTWEBKIT_PACKAGE_FOOTER@ diff --git a/Source/Qt6WebKitWidgetsConfig.cmake.in b/Source/Qt6WebKitWidgetsConfig.cmake.in new file mode 100644 index 0000000000000..d0c040d45334d --- /dev/null +++ b/Source/Qt6WebKitWidgetsConfig.cmake.in @@ -0,0 +1,12 @@ +@PACKAGE_INIT@ +@QTWEBKIT_PACKAGE_INIT@ + +find_dependency(Qt6WebKit @PROJECT_VERSION_STRING@ EXACT) +find_dependency_with_major_and_minor(Qt6Widgets @Qt6_VERSION_MAJOR@ @Qt6_VERSION_MINOR@) + +include("${CMAKE_CURRENT_LIST_DIR}/Qt6WebKitWidgetsTargets.cmake") + +set(_Qt6WebKitWidgets_MODULE_DEPENDENCIES "WebKit;Widgets;Gui;Network;Core") +set(Qt6WebKitWidgets_DEFINITIONS -DQT_WEBKITWIDGETS_LIB) + +@QTWEBKIT_PACKAGE_FOOTER@ diff --git a/Source/WTF/wtf/PlatformQt.cmake b/Source/WTF/wtf/PlatformQt.cmake index bebd5156e438f..90854fe0fc06d 100644 --- a/Source/WTF/wtf/PlatformQt.cmake +++ b/Source/WTF/wtf/PlatformQt.cmake @@ -52,11 +52,11 @@ if (USE_MACH_PORTS) endif() list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Core_INCLUDE_DIRS} + ${Qt6Core_INCLUDE_DIRS} ) list(APPEND WTF_LIBRARIES - ${Qt5Core_LIBRARIES} + ${Qt6Core_LIBRARIES} Threads::Threads ) diff --git a/Source/WTF/wtf/text/WTFString.h b/Source/WTF/wtf/text/WTFString.h index c68e820d8b128..a4b2b976ec77e 100644 --- a/Source/WTF/wtf/text/WTFString.h +++ b/Source/WTF/wtf/text/WTFString.h @@ -38,6 +38,7 @@ #if PLATFORM(QT) QT_BEGIN_NAMESPACE class QString; +class QStringView; QT_END_NAMESPACE #endif @@ -263,7 +264,7 @@ class String final { #if PLATFORM(QT) WTF_EXPORT_PRIVATE String(const QString&); - WTF_EXPORT_PRIVATE String(const QStringRef&); + WTF_EXPORT_PRIVATE String(QStringView); WTF_EXPORT_PRIVATE operator QString() const; #endif diff --git a/Source/WTF/wtf/text/qt/StringQt.cpp b/Source/WTF/wtf/text/qt/StringQt.cpp index 4c7392536f6e5..af9f95d63b389 100644 --- a/Source/WTF/wtf/text/qt/StringQt.cpp +++ b/Source/WTF/wtf/text/qt/StringQt.cpp @@ -26,6 +26,7 @@ #include "config.h" #include +#include #include #include @@ -39,11 +40,11 @@ String::String(const QString& qstr) m_impl = StringImpl::create(reinterpret_cast_ptr(qstr.constData()), qstr.length()); } -String::String(const QStringRef& ref) +String::String(QStringView view) { - if (!ref.string()) + if (view.isNull()) return; - m_impl = StringImpl::create(reinterpret_cast_ptr(ref.unicode()), ref.length()); + m_impl = StringImpl::create(reinterpret_cast_ptr(view.utf16()), view.length()); } String::operator QString() const diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake index 2e86a0fcf1ef7..0b8c9e909d02b 100644 --- a/Source/WebCore/PlatformQt.cmake +++ b/Source/WebCore/PlatformQt.cmake @@ -281,7 +281,7 @@ endif () # Do it in the WebCore to support SHARED_CORE since WebKitWidgets won't load WebKitLegacy in that case. # This should match the opposite statement in WebKitLegacy/PlatformQt.cmake if (SHARED_CORE) - qt5_add_resources(WebCore_SOURCES + qt6_add_resources(WebCore_SOURCES WebCore.qrc ) @@ -293,18 +293,19 @@ if (SHARED_CORE) endif () endif () -# Note: Qt5Network_INCLUDE_DIRS includes Qt5Core_INCLUDE_DIRS +# Note: Qt6Network_INCLUDE_DIRS includes Qt6Core_INCLUDE_DIRS list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES ${HARFBUZZ_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS} ${HYPHEN_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${LIBXSLT_INCLUDE_DIR} - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${Qt5Network_INCLUDE_DIRS} - ${Qt5Network_PRIVATE_INCLUDE_DIRS} - ${Qt5Sensors_INCLUDE_DIRS} + ${Qt6Gui_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6Network_INCLUDE_DIRS} + ${Qt6Network_PRIVATE_INCLUDE_DIRS} + ${Qt6Sensors_INCLUDE_DIRS} + ${Qt6Core5Compat_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ) @@ -316,10 +317,11 @@ list(APPEND WebCore_LIBRARIES ${HYPHEN_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} - ${Qt5Core_LIBRARIES} - ${Qt5Gui_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${Qt5Sensors_LIBRARIES} + ${Qt6Core_LIBRARIES} + ${Qt6Gui_LIBRARIES} + ${Qt6Network_LIBRARIES} + ${Qt6Sensors_LIBRARIES} + ${Qt6Core5Compat_LIBRARIES} ${SQLITE_LIBRARIES} ${X11_X11_LIB} ${ZLIB_LIBRARIES} @@ -354,14 +356,14 @@ if (ENABLE_OPENGL) platform/graphics/qt/QFramebufferPaintDevice.cpp ) - if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GLESv2) + if (${Qt6Gui_OPENGL_IMPLEMENTATION} STREQUAL GLESv2) list(APPEND WebCore_SOURCES platform/graphics/opengl/Extensions3DOpenGLES.cpp platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp ) list(APPEND WebCore_LIBRARIES - ${Qt5Gui_EGL_LIBRARIES} - ${Qt5Gui_OPENGL_LIBRARIES} + ${Qt6Gui_EGL_LIBRARIES} + ${Qt6Gui_OPENGL_LIBRARIES} ) else () list(APPEND WebCore_SOURCES @@ -409,7 +411,7 @@ if (USE_QT_MULTIMEDIA) platform/graphics/qt/MediaPlayerPrivateQt.cpp ) list(APPEND WebCore_LIBRARIES - ${Qt5Multimedia_LIBRARIES} + ${Qt6Multimedia_LIBRARIES} ) QTWEBKIT_GENERATE_MOC_FILES_H(WebCore platform/graphics/qt/MediaPlayerPrivateQt.h) endif () diff --git a/Source/WebCore/bridge/qt/qt_class.cpp b/Source/WebCore/bridge/qt/qt_class.cpp index 1d4796892acbf..b760fadd216b7 100644 --- a/Source/WebCore/bridge/qt/qt_class.cpp +++ b/Source/WebCore/bridge/qt/qt_class.cpp @@ -175,7 +175,7 @@ Field* QtClass::fieldNamed(PropertyName identifier, Instance* instance) const if (index >= 0) { const QMetaProperty prop = m_metaObject->property(index); - if (prop.isScriptable(obj)) { + if (prop.isScriptable()) { f = new QtField(prop); qtinst->m_fields.insert(name, f); return f; diff --git a/Source/WebCore/bridge/qt/qt_instance.cpp b/Source/WebCore/bridge/qt/qt_instance.cpp index 6a7c5cc9fb34a..fde72b17e2fe4 100644 --- a/Source/WebCore/bridge/qt/qt_instance.cpp +++ b/Source/WebCore/bridge/qt/qt_instance.cpp @@ -120,7 +120,7 @@ RefPtr QtInstance::getQtInstance(QObject* o, RootObject* rootObject, { JSLockHolder lock(WebCore::commonVM()); - foreach (QtInstance* instance, cachedInstances.values(o)) + Q_FOREACH (QtInstance* instance, cachedInstances.values(o)) if (instance->rootObject() == rootObject) { // The garbage collector removes instances, but it may happen that the wrapped // QObject dies before the gc kicks in. To handle that case we have to do an additional @@ -197,7 +197,7 @@ void QtInstance::getPropertyNames(JSGlobalObject* lexicalGlobalObject, PropertyN #ifndef QT_NO_PROPERTIES QList dynProps = obj->dynamicPropertyNames(); - foreach (const QByteArray& ba, dynProps) + Q_FOREACH (const QByteArray& ba, dynProps) array.add(Identifier::fromString(vm, String::fromUTF8(ba.constData()))); #endif @@ -255,7 +255,7 @@ JSValue QtInstance::stringValue(JSGlobalObject* lexicalGlobalObject) const && m.methodType() != QMetaMethod::Signal && m.parameterCount() == 0 && m.returnType() != QMetaType::Void) { - QVariant ret(m.returnType(), (void*)0); + QVariant ret(m.returnMetaType(), (void*)0); void * qargs[1]; qargs[0] = ret.data(); diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp index 8d52143689220..7ca14814bc034 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime.cpp @@ -1042,7 +1042,7 @@ static int findMethodIndex(JSContextRef context, QVector tooFewArgs; QVector conversionFailed; - foreach(int index, matchingIndices) { + Q_FOREACH(int index, matchingIndices) { QMetaMethod method = meta->method(index); QVector types; @@ -1112,7 +1112,7 @@ static int findMethodIndex(JSContextRef context, QtMethodMatchType retType = types[0]; if (retType.typeId() != QMetaType::Void) - args[0] = QVariant(retType.typeId(), (void *)0); // the return value + args[0] = QVariant(QMetaType(retType.typeId()), (void *)0); // the return value bool converted = true; int matchDistance = 0; @@ -1471,7 +1471,7 @@ JSValueRef QtRuntimeMethod::connectOrDisconnect(JSContextRef context, JSObjectRe // Now to find our previous connection object. QList conns = QtConnectionObject::connections.values(sender); - foreach (QtConnectionObject* conn, conns) { + Q_FOREACH (QtConnectionObject* conn, conns) { // Is this the right connection? if (!conn->match(context, sender, signalIndex, targetObject, targetFunction)) continue; @@ -1518,19 +1518,18 @@ QtConnectionObject::~QtConnectionObject() // Begin moc-generated code -- modify with care! Check "HAND EDIT" parts struct qt_meta_stringdata_QtConnectionObject_t { - QByteArrayData data[3]; - char stringdata[44]; + const uint offsetsAndSize[6]; + char stringdata0[44]; }; -#define QT_MOC_LITERAL(idx, ofs, len) { \ - Q_REFCOUNT_INITIALIZE_STATIC, len, 0, 0, \ - offsetof(qt_meta_stringdata_QtConnectionObject_t, stringdata) + ofs \ - - idx * sizeof(QByteArrayData) \ - } + +#define QT_MOC_LITERAL(ofs, len) \ + uint(offsetof(qt_meta_stringdata_QtConnectionObject_t, stringdata0) + ofs), len + static const qt_meta_stringdata_QtConnectionObject_t qt_meta_stringdata_QtConnectionObject = { { -QT_MOC_LITERAL(0, 0, 33), -QT_MOC_LITERAL(1, 34, 7), -QT_MOC_LITERAL(2, 42, 0) +QT_MOC_LITERAL(0, 33), +QT_MOC_LITERAL(34, 7), +QT_MOC_LITERAL(42, 0) }, "JSC::Bindings::QtConnectionObject\0" "execute\0\0" @@ -1571,10 +1570,23 @@ void QtConnectionObject::qt_static_metacall(QObject *_o, QMetaObject::Call _c, i } } -const QMetaObject QtConnectionObject::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_QtConnectionObject.data, - qt_meta_data_QtConnectionObject, qt_static_metacall, 0, 0 } -}; +//const QMetaObject QtConnectionObject::staticMetaObject = { +// { &QObject::staticMetaObject, qt_meta_stringdata_QtConnectionObject.data, +// qt_meta_data_QtConnectionObject, qt_static_metacall, 0, 0 } +//}; + +const QMetaObject QtConnectionObject::staticMetaObject = { { + QMetaObject::SuperData::link(), + qt_meta_stringdata_QtConnectionObject.offsetsAndSize, + qt_meta_data_QtConnectionObject, + qt_static_metacall, + nullptr, +qt_incomplete_metaTypeArray +, QtPrivate::TypeAndForceComplete +>, + nullptr +} }; const QMetaObject *QtConnectionObject::metaObject() const { @@ -1584,7 +1596,7 @@ const QMetaObject *QtConnectionObject::metaObject() const void *QtConnectionObject::qt_metacast(const char *_clname) { if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_QtConnectionObject.stringdata)) + if (!strcmp(_clname, qt_meta_stringdata_QtConnectionObject.stringdata0)) return static_cast(const_cast(this)); return QObject::qt_metacast(_clname); } @@ -1616,7 +1628,7 @@ void QtConnectionObject::execute(void** argv) WTF::Vector args(argc); for (int i = 0; i < argc; i++) { - int argType = method.parameterType(i); + QMetaType argType = QMetaType(method.parameterType(i)); args[i] = convertQVariantToValue(m_context, m_rootObject.get(), QVariant(argType, argv[i+1]), ignoredException); } diff --git a/Source/WebCore/platform/LegacySchemeRegistry.h b/Source/WebCore/platform/LegacySchemeRegistry.h index 7370540139c8c..3801bcd0c9ca2 100644 --- a/Source/WebCore/platform/LegacySchemeRegistry.h +++ b/Source/WebCore/platform/LegacySchemeRegistry.h @@ -32,7 +32,7 @@ #if PLATFORM(QT) QT_BEGIN_NAMESPACE -class QStringList; +using QStringList = class QList; QT_END_NAMESPACE #endif diff --git a/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp b/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp index 45dc2c6092a13..eba966fe34317 100644 --- a/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp @@ -339,7 +339,7 @@ QFont FontCascade::syntheticFont() const QFont f(rawFont.familyName()); if (rawFont.pixelSize()) f.setPixelSize(rawFont.pixelSize()); - f.setWeight(rawFont.weight()); + f.setWeight(QFont::Weight(rawFont.weight())); f.setStyle(rawFont.style()); if (m_letterSpacing) f.setLetterSpacing(QFont::AbsoluteSpacing, m_letterSpacing); diff --git a/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp b/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp index ad2e2bfe58e6a..a46cc9343bc1f 100644 --- a/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp +++ b/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp @@ -26,7 +26,11 @@ #include #include +#endif + namespace WebCore { + +#ifndef QT_NO_BEARERMANAGEMENT NetworkStateNotifierPrivate::NetworkStateNotifierPrivate(NetworkStateNotifier& notifier) : m_online(false) @@ -69,32 +73,25 @@ void NetworkStateNotifierPrivate::initialize() NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate() = default; -void NetworkStateNotifier::updateStateWithoutNotifying() +void NetworkStateNotifier::setNetworkAccessAllowed(bool isAllowed) { - m_isOnLine = p->effectivelyOnline(); + p->setNetworkAccessAllowed(isAllowed); } -void NetworkStateNotifier::startObserving() +#endif + +void NetworkStateNotifier::updateStateWithoutNotifying() { - p = std::make_unique(*this); - m_isOnLine = p->effectivelyOnline(); + // Qt 6 : always online + m_isOnLine = true; } -void NetworkStateNotifier::setNetworkAccessAllowed(bool isAllowed) +void NetworkStateNotifier::startObserving() { - p->setNetworkAccessAllowed(isAllowed); + // Qt 6 : always online + m_isOnLine = true; } } // namespace WebCore #include "moc_NetworkStateNotifierPrivate.cpp" - -#else - -namespace WebCore { - -void NetworkStateNotifier::updateStateWithoutNotifying() { } -void NetworkStateNotifier::startObserving() { } -} - -#endif diff --git a/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp b/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp index 3492d5c7fb218..00cfe285a8c68 100644 --- a/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp +++ b/Source/WebCore/platform/network/qt/PublicSuffixQt.cpp @@ -56,6 +56,22 @@ bool isPublicSuffix(StringView domain) return qIsEffectiveTLD(fromAce(domain)); } +static QString qTopLevelDomain(const QString &domain) +{ + const QString domainLower = domain.toLower(); + QVector sections = domainLower.split(QLatin1Char('.'), Qt::SkipEmptyParts); + if (sections.isEmpty()) + return QString(); + + QString level, tld; + for (int j = sections.count() - 1; j >= 0; --j) { + level.prepend(QLatin1Char('.') + sections.at(j)); + if (qIsEffectiveTLD(level.right(level.size() - 1))) + tld = level; + } + return tld; +} + String topPrivatelyControlledDomain(const String& domain) { if (domain.isEmpty()) @@ -72,7 +88,7 @@ String topPrivatelyControlledDomain(const String& domain) return String(); QString tld = qTopLevelDomain(qLowercaseDomain); - auto privateLabels = qLowercaseDomain.leftRef(qLowercaseDomain.length() - tld.length()); + auto privateLabels = qLowercaseDomain.left(qLowercaseDomain.length() - tld.length()); auto topPrivateLabel = privateLabels.split(QLatin1Char('.'), Qt::SkipEmptyParts).last(); return QString(topPrivateLabel + tld); } diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index da849a7a38631..42df3241cf99f 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -625,7 +625,7 @@ void QNetworkReplyHandler::sendResponseIfNeeded() response.setHTTPStatusText(AtomString::fromLatin1(m_replyWrapper->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData())); // Add remaining headers. Qt may send a header with multiple values newline-separated; replace with comma. - foreach (const QNetworkReply::RawHeaderPair& pair, m_replyWrapper->reply()->rawHeaderPairs()) + Q_FOREACH (const QNetworkReply::RawHeaderPair& pair, m_replyWrapper->reply()->rawHeaderPairs()) response.setHTTPHeaderField(String(pair.first.constData(), pair.first.size()), makeStringByReplacingAll(StringView(pair.second.constData(), pair.second.size()), '\n', ',')); } diff --git a/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp b/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp index 37eb4558811f7..616df71c046a3 100644 --- a/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp +++ b/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp @@ -66,7 +66,7 @@ void QtMIMETypeSniffer::trySniffing() m_reply->disconnect(this); QCoreApplication::removePostedEvents(this, QEvent::MetaCall); m_isFinished = true; - emit finished(); + Q_EMIT finished(); } #include "moc_QtMIMETypeSniffer.cpp" diff --git a/Source/WebCore/platform/network/qt/SharedCookieJarQt.cpp b/Source/WebCore/platform/network/qt/SharedCookieJarQt.cpp index 2b30cb2b6e8e4..0cff09bfc3750 100644 --- a/Source/WebCore/platform/network/qt/SharedCookieJarQt.cpp +++ b/Source/WebCore/platform/network/qt/SharedCookieJarQt.cpp @@ -61,7 +61,7 @@ void SharedCookieJarQt::destroy() void SharedCookieJarQt::getHostnamesWithCookies(HashSet& hostnames) { QList cookies = allCookies(); - foreach (const QNetworkCookie& networkCookie, cookies) + Q_FOREACH (const QNetworkCookie& networkCookie, cookies) hostnames.add(networkCookie.domain()); } @@ -179,7 +179,7 @@ bool SharedCookieJarQt::setCookiesFromUrl(const QList& cookieLis SQLiteTransaction transaction(m_database); transaction.begin(); - foreach (const QNetworkCookie &cookie, cookiesForUrl(url)) { + Q_FOREACH (const QNetworkCookie &cookie, cookiesForUrl(url)) { if (cookie.isSessionCookie()) continue; sqlQuery->bindText(1, String(cookie.domain().append(QLatin1String(cookie.name())))); diff --git a/Source/WebCore/platform/qt/DragDataQt.cpp b/Source/WebCore/platform/qt/DragDataQt.cpp index 99e3dc2ff009d..68fc11c466a5b 100644 --- a/Source/WebCore/platform/qt/DragDataQt.cpp +++ b/Source/WebCore/platform/qt/DragDataQt.cpp @@ -56,7 +56,7 @@ bool DragData::containsFiles() const if (!m_platformDragData) return false; QList urls = m_platformDragData->urls(); - foreach (const QUrl &url, urls) { + Q_FOREACH (const QUrl &url, urls) { if (!url.toLocalFile().isEmpty()) return true; } @@ -74,7 +74,7 @@ Vector DragData::asFilenames() const if (!m_platformDragData) return result; QList urls = m_platformDragData->urls(); - foreach (const QUrl &url, urls) { + Q_FOREACH (const QUrl &url, urls) { QString file = url.toLocalFile(); if (!file.isEmpty()) result.append(file); diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp index dc20e4ca92b4e..8395b055b5c11 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp @@ -49,6 +49,7 @@ #include "UserAgentStyleSheets.h" #include +#include namespace WebCore { diff --git a/Source/WebInspectorUI/PlatformQt.cmake b/Source/WebInspectorUI/PlatformQt.cmake index 966bdf19decc0..2a996a841d416 100644 --- a/Source/WebInspectorUI/PlatformQt.cmake +++ b/Source/WebInspectorUI/PlatformQt.cmake @@ -1,4 +1,4 @@ -get_target_property(RCC_EXECUTABLE ${Qt5Core_RCC_EXECUTABLE} IMPORTED_LOCATION) +get_target_property(RCC_EXECUTABLE ${Qt6Core_RCC_EXECUTABLE} IMPORTED_LOCATION) if (NOT DEFINED InspectorFiles) # QTFIXME: Must be kept in sync with CMakeLists.txt; probably a better way? diff --git a/Source/WebKit/NetworkProcess/qt/NetworkDataTaskQt.cpp b/Source/WebKit/NetworkProcess/qt/NetworkDataTaskQt.cpp index 0c9e6c1245cf1..cd52ccd4fd6ec 100644 --- a/Source/WebKit/NetworkProcess/qt/NetworkDataTaskQt.cpp +++ b/Source/WebKit/NetworkProcess/qt/NetworkDataTaskQt.cpp @@ -120,7 +120,8 @@ QNetworkReply* NetworkDataTaskQt::sendNetworkRequest(const ResourceRequest& requ const QUrl url = m_qRequest.url(); - m_qRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); + // Qt6: the default is NoLessSafeRedirectPolicy + // m_qRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); if (m_method == QNetworkAccessManager::PostOperation && (!url.toLocalFile().isEmpty() || url.scheme() == QLatin1String("data"))) m_method = QNetworkAccessManager::GetOperation; diff --git a/Source/WebKit/PlatformQt.cmake b/Source/WebKit/PlatformQt.cmake index a3770cf3d072c..e3a5093aaa3dd 100644 --- a/Source/WebKit/PlatformQt.cmake +++ b/Source/WebKit/PlatformQt.cmake @@ -251,15 +251,15 @@ endif () list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES ${GLIB_INCLUDE_DIRS} ${GSTREAMER_INCLUDE_DIRS} - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5Quick_PRIVATE_INCLUDE_DIRS} + ${Qt6Quick_INCLUDE_DIRS} + ${Qt6Quick_PRIVATE_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIR} ) list(APPEND WebKit_LIBRARIES - ${Qt5Positioning_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5WebChannel_LIBRARIES} + ${Qt6Positioning_LIBRARIES} + ${Qt6Quick_LIBRARIES} + ${Qt6WebChannel_LIBRARIES} ${X11_X11_LIB} ) @@ -290,7 +290,7 @@ endif () # FIXME: Allow building without widgets list(APPEND WebProcess_LIBRARIES - Qt5::Widgets + Qt6::Widgets WebKitWidgets ) diff --git a/Source/WebKit/PlatformWPE.cmake b/Source/WebKit/PlatformWPE.cmake index 0e63cf33c439b..71ea22769ef6d 100644 --- a/Source/WebKit/PlatformWPE.cmake +++ b/Source/WebKit/PlatformWPE.cmake @@ -450,7 +450,7 @@ if (ENABLE_WPE_QT_API) ) set(qtwpe_LIBRARIES - Qt5::Core Qt5::Quick + Qt6::Core Qt6::Quick WebKit ${GLIB_GOBJECT_LIBRARIES} ${GLIB_LIBRARIES} @@ -463,8 +463,8 @@ if (ENABLE_WPE_QT_API) ${JavaScriptCoreGLib_FRAMEWORK_HEADERS_DIR} ${CMAKE_BINARY_DIR} ${GLIB_INCLUDE_DIRS} - ${Qt5_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} ${LIBEPOXY_INCLUDE_DIRS} ${LIBSOUP_INCLUDE_DIRS} ${WPE_INCLUDE_DIRS} diff --git a/Source/WebKit/Shared/NativeWebKeyboardEvent.h b/Source/WebKit/Shared/NativeWebKeyboardEvent.h index f3ea97487c9f8..76ea4c4afd904 100644 --- a/Source/WebKit/Shared/NativeWebKeyboardEvent.h +++ b/Source/WebKit/Shared/NativeWebKeyboardEvent.h @@ -71,6 +71,7 @@ class NativeWebKeyboardEvent : public WebKeyboardEvent { // FIXME: Share iOS's HandledByInputMethod enum here instead of passing a boolean. NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, bool replacesSoftSpace, const Vector&); #elif PLATFORM(QT) + NativeWebKeyboardEvent(const NativeWebKeyboardEvent&); explicit NativeWebKeyboardEvent(QKeyEvent*); #elif PLATFORM(GTK) NativeWebKeyboardEvent(const NativeWebKeyboardEvent&); @@ -90,7 +91,7 @@ class NativeWebKeyboardEvent : public WebKeyboardEvent { #if USE(APPKIT) NSEvent *nativeEvent() const { return m_nativeEvent.get(); } #elif PLATFORM(QT) - const QKeyEvent* nativeEvent() const { return &m_nativeEvent; } + const QKeyEvent* nativeEvent() const { return m_nativeEvent.get(); } #elif PLATFORM(GTK) GdkEvent* nativeEvent() const { return m_nativeEvent.get(); } #elif PLATFORM(IOS_FAMILY) @@ -108,7 +109,7 @@ class NativeWebKeyboardEvent : public WebKeyboardEvent { #elif PLATFORM(GTK) && USE(GTK4) GRefPtr m_nativeEvent; #elif PLATFORM(QT) - QKeyEvent m_nativeEvent; + std::unique_ptr m_nativeEvent; #elif PLATFORM(GTK) GUniquePtr m_nativeEvent; #elif PLATFORM(IOS_FAMILY) diff --git a/Source/WebKit/Shared/qt/NativeWebKeyboardEventQt.cpp b/Source/WebKit/Shared/qt/NativeWebKeyboardEventQt.cpp index 996b98ae2f8b3..fd17aee0a7140 100644 --- a/Source/WebKit/Shared/qt/NativeWebKeyboardEventQt.cpp +++ b/Source/WebKit/Shared/qt/NativeWebKeyboardEventQt.cpp @@ -30,9 +30,15 @@ namespace WebKit { +NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& other) + : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(other.nativeEvent())) + , m_nativeEvent(other.nativeEvent()->clone()) +{ +} + NativeWebKeyboardEvent::NativeWebKeyboardEvent(QKeyEvent* event) : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event)) - , m_nativeEvent(*event) + , m_nativeEvent(event->clone()) { } diff --git a/Source/WebKit/Shared/qt/WebEventFactory.h b/Source/WebKit/Shared/qt/WebEventFactory.h index e5e3a101b3727..4faab9ade8544 100644 --- a/Source/WebKit/Shared/qt/WebEventFactory.h +++ b/Source/WebKit/Shared/qt/WebEventFactory.h @@ -46,9 +46,9 @@ namespace WebKit { class WebEventFactory { public: - static WebMouseEvent createWebMouseEvent(QMouseEvent*, const QTransform& fromItemTransform, int eventClickCount); - static WebWheelEvent createWebWheelEvent(QWheelEvent*, const QTransform& fromItemTransform); - static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent*); + static WebMouseEvent createWebMouseEvent(const QMouseEvent*, const QTransform& fromItemTransform, int eventClickCount); + static WebWheelEvent createWebWheelEvent(const QWheelEvent*, const QTransform& fromItemTransform); + static WebKeyboardEvent createWebKeyboardEvent(const QKeyEvent*); #if ENABLE(TOUCH_EVENTS) static WebTouchEvent createWebTouchEvent(const QTouchEvent*, const QTransform& fromItemTransform); #endif diff --git a/Source/WebKit/Shared/qt/WebEventFactoryQt.cpp b/Source/WebKit/Shared/qt/WebEventFactoryQt.cpp index b1e9ba7b8522f..1974c625b15bc 100644 --- a/Source/WebKit/Shared/qt/WebEventFactoryQt.cpp +++ b/Source/WebKit/Shared/qt/WebEventFactoryQt.cpp @@ -52,7 +52,7 @@ static inline WallTime currentTimeForEvent(const QInputEvent* event) return WTF::WallTime::now(); } -static inline unsigned short buttonsForEvent(QMouseEvent* event) +static inline unsigned short buttonsForEvent(const QMouseEvent* event) { unsigned short buttons = 0; @@ -68,13 +68,13 @@ static inline unsigned short buttonsForEvent(QMouseEvent* event) return buttons; } -static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event) +static WebMouseEvent::Button mouseButtonForEvent(const QMouseEvent *event) { if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton)) return WebMouseEvent::LeftButton; if (event->button() == Qt::RightButton || (event->buttons() & Qt::RightButton)) return WebMouseEvent::RightButton; - if (event->button() == Qt::MidButton || (event->buttons() & Qt::MidButton)) + if (event->button() == Qt::MiddleButton || (event->buttons() & Qt::MiddleButton)) return WebMouseEvent::MiddleButton; return WebMouseEvent::NoButton; } @@ -127,7 +127,7 @@ static inline OptionSet modifiersForEvent(Qt::KeyboardModifi return result; } -WebMouseEvent WebEventFactory::createWebMouseEvent(QMouseEvent* event, const QTransform& fromItemTransform, int eventClickCount) +WebMouseEvent WebEventFactory::createWebMouseEvent(const QMouseEvent* event, const QTransform& fromItemTransform, int eventClickCount) { static FloatPoint lastPos = FloatPoint(0, 0); @@ -144,7 +144,7 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(QMouseEvent* event, const QTr return WebMouseEvent(type, button, buttons, fromItemTransform.map(event->localPos()).toPoint(), event->screenPos().toPoint(), deltaX, deltaY, 0.0f, clickCount, modifiers, timestamp); } - WebWheelEvent WebEventFactory::createWebWheelEvent(QWheelEvent* e, const QTransform& fromItemTransform) + WebWheelEvent WebEventFactory::createWebWheelEvent(const QWheelEvent* e, const QTransform& fromItemTransform) { float deltaX = 0; float deltaY = 0; @@ -154,13 +154,10 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(QMouseEvent* event, const QTr OptionSet modifiers = modifiersForEvent(e->modifiers()); WallTime timestamp = currentTimeForEvent(e); - if (e->orientation() == Qt::Horizontal) { - deltaX = e->delta(); - wheelTicksX = deltaX / 120.0f; - } else { - deltaY = e->delta(); - wheelTicksY = deltaY / 120.0f; - } + deltaX = e->angleDelta().x(); + wheelTicksX = deltaX / 120.0f; + deltaY = e->angleDelta().y(); + wheelTicksY = deltaY / 120.0f; // Since we report the scroll by the pixel, convert the delta to pixel distance using standard scroll step. // Use the same single scroll step as QTextEdit (in QTextEditPrivate::init [h,v]bar->setSingleStep) @@ -171,15 +168,15 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(QMouseEvent* event, const QTr deltaY = wheelTicksY * wheelScrollLines * cDefaultQtScrollStep; // Transform the position and the pixel scrolling distance. - QLineF transformedScroll = fromItemTransform.map(QLineF(e->posF(), e->posF() + QPointF(deltaX, deltaY))); + QLineF transformedScroll = fromItemTransform.map(QLineF(e->position(), e->position() + QPointF(deltaX, deltaY))); IntPoint transformedPoint = transformedScroll.p1().toPoint(); - IntPoint globalPoint = e->globalPosF().toPoint(); + IntPoint globalPoint = e->globalPosition().toPoint(); FloatSize transformedDelta(transformedScroll.dx(), transformedScroll.dy()); FloatSize wheelTicks(wheelTicksX, wheelTicksY); return WebWheelEvent(WebEvent::Wheel, transformedPoint, globalPoint, transformedDelta, wheelTicks, granularity, modifiers, timestamp); } -WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(QKeyEvent* event) +WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const QKeyEvent* event) { const int state = event->modifiers(); WebEvent::Type type = webEventTypeForEvent(event); diff --git a/Source/WebKit/UIProcess/API/qt/qquickurlschemedelegate.cpp b/Source/WebKit/UIProcess/API/qt/qquickurlschemedelegate.cpp index 49f474e6156fc..c8d095bb1db18 100644 --- a/Source/WebKit/UIProcess/API/qt/qquickurlschemedelegate.cpp +++ b/Source/WebKit/UIProcess/API/qt/qquickurlschemedelegate.cpp @@ -45,7 +45,7 @@ QString QQuickUrlSchemeDelegate::scheme() const void QQuickUrlSchemeDelegate::setScheme(const QString& scheme) { m_scheme = scheme; - emit schemeChanged(); + Q_EMIT schemeChanged(); } QQuickNetworkRequest* QQuickUrlSchemeDelegate::request() const diff --git a/Source/WebKit/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit/UIProcess/API/qt/qquickwebpage.cpp index 75e68656f8dc7..2e4990c044df1 100644 --- a/Source/WebKit/UIProcess/API/qt/qquickwebpage.cpp +++ b/Source/WebKit/UIProcess/API/qt/qquickwebpage.cpp @@ -87,7 +87,7 @@ void QQuickWebPage::setContentsSize(const QSizeF& size) d->contentsSize = size; d->updateSize(); - emit d->viewportItem->experimental()->test()->contentsSizeChanged(); + Q_EMIT d->viewportItem->experimental()->test()->contentsSizeChanged(); } const QSizeF& QQuickWebPage::contentsSize() const @@ -100,7 +100,7 @@ void QQuickWebPage::setContentsScale(qreal scale) ASSERT(scale > 0); d->contentsScale = scale; d->updateSize(); - emit d->viewportItem->experimental()->test()->contentsScaleChanged(); + Q_EMIT d->viewportItem->experimental()->test()->contentsScaleChanged(); } qreal QQuickWebPage::contentsScale() const diff --git a/Source/WebKit/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit/UIProcess/API/qt/qquickwebview.cpp index a0c9a15265518..e2eccf67bdda2 100644 --- a/Source/WebKit/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit/UIProcess/API/qt/qquickwebview.cpp @@ -201,7 +201,8 @@ static void javaScriptCallback(WKSerializedScriptValueRef valueRef, WKErrorRef, JSValueRef exception = 0; JSValueRef value = WKSerializedScriptValueDeserialize(valueRef, context, &exception); - var = buildQJSValue(function.engine(), context, value, /* depth */ 0); + // Qt 6 error: ‘class QJSValue’ has no member named ‘engine’ + var = buildQJSValue(qjsEngine(closure->receiver), context, value, /* depth */ 0); JSGlobalContextRelease(context); } @@ -235,8 +236,8 @@ QQuickWebViewPrivate::FlickableAxisLocker::FlickableAxisLocker() QVector2D QQuickWebViewPrivate::FlickableAxisLocker::touchVelocity(const QTouchEvent* event) { - static bool touchVelocityAvailable = event->device()->capabilities().testFlag(QTouchDevice::Velocity); - const QTouchEvent::TouchPoint& touchPoint = event->touchPoints().first(); + static bool touchVelocityAvailable = event->device()->capabilities().testFlag(QInputDevice::Capability::Velocity); + const QTouchEvent::TouchPoint& touchPoint = event->points().first(); if (touchVelocityAvailable) return touchPoint.velocity(); @@ -415,7 +416,7 @@ void QQuickWebViewPrivate::didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef q->emitUrlChangeIfNeeded(); QWebLoadRequest loadRequest(WKURLCopyQUrl(url.get()), QQuickWebView::LoadStartedStatus); - emit q->loadingChanged(&loadRequest); + Q_EMIT q->loadingChanged(&loadRequest); } void QQuickWebViewPrivate::didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) @@ -437,7 +438,7 @@ void QQuickWebViewPrivate::didFailLoad(WKPageRef, WKFrameRef frame, WKErrorRef e QtWebError error(errorRef); if (error.isCancellation()) { QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadStoppedStatus); - emit q->loadingChanged(&loadRequest); + Q_EMIT q->loadingChanged(&loadRequest); return; } @@ -445,7 +446,7 @@ void QQuickWebViewPrivate::didFailLoad(WKPageRef, WKFrameRef frame, WKErrorRef e if (errorCode == kWKErrorCodeFrameLoadInterruptedByPolicyChange || errorCode == kWKErrorCodePlugInWillHandleLoad) { QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadSucceededStatus); q->emitUrlChangeIfNeeded(); - emit q->loadingChanged(&loadRequest); + Q_EMIT q->loadingChanged(&loadRequest); return; } @@ -460,7 +461,7 @@ void QQuickWebViewPrivate::didFailLoad(WKPageRef, WKFrameRef frame, WKErrorRef e toImpl(frame)->setUnreachableURL(URL(error.url())); q->emitUrlChangeIfNeeded(); QWebLoadRequest loadRequest(error.url(), QQuickWebView::LoadFailedStatus, error.description(), static_cast(error.type()), errorCode); - emit q->loadingChanged(&loadRequest); + Q_EMIT q->loadingChanged(&loadRequest); } void QQuickWebViewPrivate::didCommitLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) @@ -476,8 +477,8 @@ void QQuickWebViewPrivate::didCommitLoadForFrame(WKPageRef, WKFrameRef frame, WK QQuickWebView* const q = d->q_func(); ASSERT(q->loading()); d->m_betweenLoadCommitAndFirstFrame = true; - emit q->navigationHistoryChanged(); - emit q->titleChanged(); + Q_EMIT q->navigationHistoryChanged(); + Q_EMIT q->titleChanged(); } void QQuickWebViewPrivate::didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) @@ -489,7 +490,7 @@ void QQuickWebViewPrivate::didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WK ASSERT(!q->loading()); QWebLoadRequest loadRequest(q->url(), QQuickWebView::LoadSucceededStatus); - emit q->loadingChanged(&loadRequest); + Q_EMIT q->loadingChanged(&loadRequest); } void QQuickWebViewPrivate::didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void* clientInfo) @@ -498,14 +499,14 @@ void QQuickWebViewPrivate::didSameDocumentNavigationForFrame(WKPageRef, WKFrameR return; QQuickWebView* const q = toQQuickWebViewPrivate(clientInfo)->q_func(); q->emitUrlChangeIfNeeded(); - emit q->navigationHistoryChanged(); + Q_EMIT q->navigationHistoryChanged(); } void QQuickWebViewPrivate::didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef frame, WKTypeRef, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - emit toQQuickWebViewPrivate(clientInfo)->q_func()->titleChanged(); + Q_EMIT toQQuickWebViewPrivate(clientInfo)->q_func()->titleChanged(); } void QQuickWebViewPrivate::didStartProgress(WKPageRef, const void* clientInfo) @@ -545,7 +546,7 @@ void QQuickWebViewPrivate::loadProgressDidChange(int loadProgress) m_loadProgress = loadProgress; - emit q->loadProgressChanged(); + Q_EMIT q->loadProgressChanged(); } void QQuickWebViewPrivate::handleMouseEvent(QMouseEvent* event) @@ -589,7 +590,7 @@ void QQuickWebViewPrivate::didRenderFrame() { Q_Q(QQuickWebView); if (m_betweenLoadCommitAndFirstFrame) { - emit q->experimental()->loadVisuallyCommitted(); + Q_EMIT q->experimental()->loadVisuallyCommitted(); m_betweenLoadCommitAndFirstFrame = false; } } @@ -609,10 +610,10 @@ void QQuickWebViewPrivate::processDidCrash(WKPageRef, const void* clientInfo) QWebLoadRequest loadRequest(url, QQuickWebView::LoadFailedStatus, QStringLiteral("The web process crashed."), QQuickWebView::InternalErrorDomain, 0); d->loadProgressDidChange(100); - emit q->loadingChanged(&loadRequest); + Q_EMIT q->loadingChanged(&loadRequest); } - emit q->experimental()->processDidCrash(); + Q_EMIT q->experimental()->processDidCrash(); } void QQuickWebViewPrivate::didRelaunchProcess() @@ -630,21 +631,21 @@ void QQuickWebViewPrivate::didRelaunchProcess() updateSchemeDelegates(); } - emit q->experimental()->didRelaunchProcess(); + Q_EMIT q->experimental()->didRelaunchProcess(); } void QQuickWebViewPrivate::processDidBecomeUnresponsive(WKPageRef, const void* clientInfo) { QQuickWebView* q = toQQuickWebViewPrivate(clientInfo)->q_ptr; - emit q->experimental()->processDidBecomeUnresponsive(); + Q_EMIT q->experimental()->processDidBecomeUnresponsive(); } void QQuickWebViewPrivate::processDidBecomeResponsive(WKPageRef, const void* clientInfo) { QQuickWebView* q = toQQuickWebViewPrivate(clientInfo)->q_ptr; - emit q->experimental()->processDidBecomeResponsive(); + Q_EMIT q->experimental()->processDidBecomeResponsive(); } void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download) @@ -699,18 +700,18 @@ void QQuickWebViewPrivate::updateIcon() return; m_iconUrl = iconUrl; - emit q->iconChanged();*/ + Q_EMIT q->iconChanged();*/ } void QQuickWebViewPrivate::_q_onReceivedResponseFromDownload(QWebDownloadItem* downloadItem) { - // Now that our downloadItem has everything we need we can emit downloadRequested. + // Now that our downloadItem has everything we need we can Q_EMIT downloadRequested. if (!downloadItem) return; Q_Q(QQuickWebView); QQmlEngine::setObjectOwnership(downloadItem, QQmlEngine::JavaScriptOwnership); - emit q->experimental()->downloadRequested(downloadItem); + Q_EMIT q->experimental()->downloadRequested(downloadItem); } void QQuickWebViewPrivate::runJavaScriptAlert(const QString& alertText) @@ -842,7 +843,7 @@ void QQuickWebViewAttached::setView(QQuickWebView* view) if (m_view == view) return; m_view = view; - emit viewChanged(); + Q_EMIT viewChanged(); } QQuickWebViewAttached* QQuickWebView::qmlAttachedProperties(QObject* object) @@ -987,7 +988,7 @@ void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(WKStringRef me QVariantMap variantMap; variantMap.insert(QLatin1String("data"), WKStringCopyQString(message)); variantMap.insert(QLatin1String("origin"), q_ptr->url()); - emit q_ptr->experimental()->messageReceived(variantMap); + Q_EMIT q_ptr->experimental()->messageReceived(variantMap); } #if ENABLE(QT_WEBCHANNEL) @@ -1210,7 +1211,7 @@ void QQuickWebViewExperimental::setPreferredMinimumContentsWidth(int width) return; webPreferences.setLayoutFallbackWidth(width); - emit preferredMinimumContentsWidthChanged(); + Q_EMIT preferredMinimumContentsWidthChanged(); } void QQuickWebViewExperimental::setFlickableViewportEnabled(bool enable) @@ -1242,7 +1243,7 @@ void QQuickWebViewExperimental::setWebChannel(QQmlWebChannel* channel) if (m_webChannel) m_webChannel->connectTo(m_webChannelTransport); - emit webChannelChanged(channel); + Q_EMIT webChannelChanged(channel); } #endif @@ -1288,7 +1289,7 @@ void QQuickWebViewExperimental::setAlertDialog(QQmlComponent* alertDialog) if (d->alertDialog == alertDialog) return; d->alertDialog = alertDialog; - emit alertDialogChanged(); + Q_EMIT alertDialogChanged(); } QQmlComponent* QQuickWebViewExperimental::confirmDialog() const @@ -1303,7 +1304,7 @@ void QQuickWebViewExperimental::setConfirmDialog(QQmlComponent* confirmDialog) if (d->confirmDialog == confirmDialog) return; d->confirmDialog = confirmDialog; - emit confirmDialogChanged(); + Q_EMIT confirmDialogChanged(); } QWebNavigationHistory* QQuickWebViewExperimental::navigationHistory() const @@ -1331,7 +1332,7 @@ void QQuickWebViewExperimental::setPromptDialog(QQmlComponent* promptDialog) if (d->promptDialog == promptDialog) return; d->promptDialog = promptDialog; - emit promptDialogChanged(); + Q_EMIT promptDialogChanged(); } QQmlComponent* QQuickWebViewExperimental::authenticationDialog() const @@ -1346,7 +1347,7 @@ void QQuickWebViewExperimental::setAuthenticationDialog(QQmlComponent* authentic if (d->authenticationDialog == authenticationDialog) return; d->authenticationDialog = authenticationDialog; - emit authenticationDialogChanged(); + Q_EMIT authenticationDialogChanged(); } QQmlComponent* QQuickWebViewExperimental::proxyAuthenticationDialog() const @@ -1361,7 +1362,7 @@ void QQuickWebViewExperimental::setProxyAuthenticationDialog(QQmlComponent* prox if (d->proxyAuthenticationDialog == proxyAuthenticationDialog) return; d->proxyAuthenticationDialog = proxyAuthenticationDialog; - emit proxyAuthenticationDialogChanged(); + Q_EMIT proxyAuthenticationDialogChanged(); } QQmlComponent* QQuickWebViewExperimental::certificateVerificationDialog() const { @@ -1375,7 +1376,7 @@ void QQuickWebViewExperimental::setCertificateVerificationDialog(QQmlComponent* if (d->certificateVerificationDialog == certificateVerificationDialog) return; d->certificateVerificationDialog = certificateVerificationDialog; - emit certificateVerificationDialogChanged(); + Q_EMIT certificateVerificationDialogChanged(); } QQmlComponent* QQuickWebViewExperimental::itemSelector() const @@ -1390,7 +1391,7 @@ void QQuickWebViewExperimental::setItemSelector(QQmlComponent* itemSelector) if (d->itemSelector == itemSelector) return; d->itemSelector = itemSelector; - emit itemSelectorChanged(); + Q_EMIT itemSelectorChanged(); } QQmlComponent* QQuickWebViewExperimental::filePicker() const @@ -1405,7 +1406,7 @@ void QQuickWebViewExperimental::setFilePicker(QQmlComponent* filePicker) if (d->filePicker == filePicker) return; d->filePicker = filePicker; - emit filePickerChanged(); + Q_EMIT filePickerChanged(); } QQmlComponent* QQuickWebViewExperimental::databaseQuotaDialog() const @@ -1420,7 +1421,7 @@ void QQuickWebViewExperimental::setDatabaseQuotaDialog(QQmlComponent* databaseQu if (d->databaseQuotaDialog == databaseQuotaDialog) return; d->databaseQuotaDialog = databaseQuotaDialog; - emit databaseQuotaDialogChanged(); + Q_EMIT databaseQuotaDialogChanged(); } QQmlComponent* QQuickWebViewExperimental::colorChooser() const @@ -1436,7 +1437,7 @@ void QQuickWebViewExperimental::setColorChooser(QQmlComponent* colorChooser) return; d->colorChooser = colorChooser; - emit colorChooserChanged(); + Q_EMIT colorChooserChanged(); } QString QQuickWebViewExperimental::userAgent() const @@ -1454,7 +1455,7 @@ void QQuickWebViewExperimental::setUserAgent(const QString& userAgent) return; d->webPageProxy->setCustomUserAgent(newUserAgent); - emit userAgentChanged(); + Q_EMIT userAgentChanged(); } /*! @@ -1478,7 +1479,7 @@ void QQuickWebViewExperimental::setDeviceWidth(int value) { Q_D(QQuickWebView); d->webPageProxy->pageGroup().preferences().setDeviceWidth(qMax(0, value)); - emit deviceWidthChanged(); + Q_EMIT deviceWidthChanged(); } /*! @@ -1502,7 +1503,7 @@ void QQuickWebViewExperimental::setDeviceHeight(int value) { Q_D(QQuickWebView); d->webPageProxy->pageGroup().preferences().setDeviceHeight(qMax(0, value)); - emit deviceHeightChanged(); + Q_EMIT deviceHeightChanged(); } /*! @@ -1562,7 +1563,7 @@ void QQuickWebViewExperimental::setUserScripts(const QList& userScripts) return; d->userScripts = userScripts; d->updateUserScripts(); - emit userScriptsChanged(); + Q_EMIT userScriptsChanged(); } QList QQuickWebViewExperimental::userStyleSheets() const @@ -1578,7 +1579,7 @@ void QQuickWebViewExperimental::setUserStyleSheets(const QList& userStyleS return; d->userStyleSheets = userStyleSheets; d->updateUserStyleSheets(); - emit userStyleSheetsChanged(); + Q_EMIT userStyleSheetsChanged(); } QUrl QQuickWebViewExperimental::remoteInspectorUrl() const @@ -1590,7 +1591,7 @@ QUrl QQuickWebViewExperimental::remoteInspectorUrl() const #endif } -QQuickUrlSchemeDelegate* QQuickWebViewExperimental::schemeDelegates_At(QQmlListProperty* property, int index) +QQuickUrlSchemeDelegate* QQuickWebViewExperimental::schemeDelegates_At(QQmlListProperty* property, qsizetype index) { const QObjectList children = property->object->children(); if (index < children.count()) @@ -1616,7 +1617,7 @@ void QQuickWebViewExperimental::schemeDelegates_Append(QQmlListPropertywebPageProxy->registerApplicationScheme(scheme->scheme()); } -int QQuickWebViewExperimental::schemeDelegates_Count(QQmlListProperty* property) +qsizetype QQuickWebViewExperimental::schemeDelegates_Count(QQmlListProperty* property) { return property->object->children().count(); } @@ -1660,7 +1661,7 @@ void QQuickWebViewExperimental::invokeApplicationSchemeHandler(Refscheme().compare(QString(req->data().m_scheme), Qt::CaseInsensitive)) { delegate->request()->setNetworkRequestData(WTFMove(req)); delegate->reply()->setNetworkRequestData(WTFMove(req)); - emit delegate->receivedRequest(); + Q_EMIT delegate->receivedRequest(); return; } } @@ -1887,7 +1888,7 @@ void QQuickWebView::setUrl(const QUrl& url) emitUrlChangeIfNeeded(); } -// Make sure we don't emit urlChanged unless it actually changed +// Make sure we don't Q_EMIT urlChanged unless it actually changed void QQuickWebView::emitUrlChangeIfNeeded() { Q_D(QQuickWebView); @@ -1895,7 +1896,7 @@ void QQuickWebView::emitUrlChangeIfNeeded() QString activeUrl = d->webPageProxy->pageLoadState().activeURL(); if (activeUrl != d->m_currentUrl) { d->m_currentUrl = activeUrl; - emit urlChanged(); + Q_EMIT urlChanged(); } } @@ -2099,10 +2100,10 @@ bool QQuickWebView::childMouseEventFilter(QQuickItem* item, QEvent* event) return QQuickFlickable::childMouseEventFilter(item, event); } -void QQuickWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) +void QQuickWebView::geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) { Q_D(QQuickWebView); - QQuickFlickable::geometryChanged(newGeometry, oldGeometry); + QQuickFlickable::geometryChange(newGeometry, oldGeometry); if (newGeometry.size() != oldGeometry.size()) d->updateViewportSize(); } @@ -2376,7 +2377,7 @@ void QQuickWebView::setAllowAnyHTTPSCertificateForLocalHost(bool allow) void QQuickWebViewPrivate::didFindString(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo) { QQuickWebView* q = toQQuickWebViewPrivate(clientInfo)->q_ptr; - emit q->experimental()->textFound(matchCount); + Q_EMIT q->experimental()->textFound(matchCount); } void QQuickWebViewPrivate::didFailToFindString(WKPageRef page, WKStringRef string, const void* clientInfo) diff --git a/Source/WebKit/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit/UIProcess/API/qt/qquickwebview_p.h index d07e5e3d4f358..2c52634620a73 100644 --- a/Source/WebKit/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit/UIProcess/API/qt/qquickwebview_p.h @@ -174,7 +174,7 @@ public Q_SLOTS: protected: bool childMouseEventFilter(QQuickItem*, QEvent*) Q_DECL_OVERRIDE; - void geometryChanged(const QRectF&, const QRectF&) Q_DECL_OVERRIDE; + void geometryChange(const QRectF&, const QRectF&) Q_DECL_OVERRIDE; void componentComplete() Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE; void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE; @@ -338,9 +338,9 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject { QWebNavigationHistory* navigationHistory() const; QQuickWebPage* page(); - static QQuickUrlSchemeDelegate* schemeDelegates_At(QQmlListProperty*, int index); + static QQuickUrlSchemeDelegate* schemeDelegates_At(QQmlListProperty*, qsizetype index); static void schemeDelegates_Append(QQmlListProperty*, QQuickUrlSchemeDelegate*); - static int schemeDelegates_Count(QQmlListProperty*); + static qsizetype schemeDelegates_Count(QQmlListProperty*); static void schemeDelegates_Clear(QQmlListProperty*); QQmlListProperty schemeDelegates(); void invokeApplicationSchemeHandler(WTF::Ref&&); @@ -372,7 +372,7 @@ public Q_SLOTS: void goForwardTo(int index); void postMessage(const QString&); void evaluateJavaScript(const QString& script, const QJSValue& value = QJSValue()); - void findText(const QString& string, FindFlags options = 0); + void findText(const QString& string, FindFlags options = {}); Q_SIGNALS: void loadVisuallyCommitted(); diff --git a/Source/WebKit/UIProcess/API/qt/qwebdownloaditem_p_p.h b/Source/WebKit/UIProcess/API/qt/qwebdownloaditem_p_p.h index 780848be6130e..33310652ce598 100644 --- a/Source/WebKit/UIProcess/API/qt/qwebdownloaditem_p_p.h +++ b/Source/WebKit/UIProcess/API/qt/qwebdownloaditem_p_p.h @@ -33,7 +33,7 @@ class QWebDownloadItemPrivate : public QObject { public: QWebDownloadItemPrivate(QWebDownloadItem*); - void didReceiveResponse(QWebDownloadItem* download) { emit receivedResponse(download); } + void didReceiveResponse(QWebDownloadItem* download) { Q_EMIT receivedResponse(download); } QWebDownloadItem* q; diff --git a/Source/WebKit/UIProcess/API/qt/qwebiconimageprovider.cpp b/Source/WebKit/UIProcess/API/qt/qwebiconimageprovider.cpp index 00ec6bc8316f6..cf56f125a33eb 100644 --- a/Source/WebKit/UIProcess/API/qt/qwebiconimageprovider.cpp +++ b/Source/WebKit/UIProcess/API/qt/qwebiconimageprovider.cpp @@ -64,7 +64,7 @@ QUrl QWebIconImageProvider::iconURLForPageURLInContext(const QString &pageURL, Q QImage QWebIconImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize) { - QString pageURL = QString::fromUtf8(QByteArray::fromBase64(id.midRef(id.indexOf('#') + 1).toLatin1())); + QString pageURL = QString::fromUtf8(QByteArray::fromBase64(id.mid(id.indexOf('#') + 1).toLatin1())); QtWebIconDatabaseClient* iconDatabase = QtWebContext::defaultContext()->iconDatabase(); Q_ASSERT(iconDatabase); diff --git a/Source/WebKit/UIProcess/API/qt/qwebkittest.cpp b/Source/WebKit/UIProcess/API/qt/qwebkittest.cpp index 6a07d4567414e..5e74ea845a92f 100644 --- a/Source/WebKit/UIProcess/API/qt/qwebkittest.cpp +++ b/Source/WebKit/UIProcess/API/qt/qwebkittest.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include using namespace WebKit; @@ -39,34 +40,32 @@ QWebKitTest::~QWebKitTest() { } -static QTouchEvent::TouchPoint touchPoint(qreal x, qreal y) +static QMutableEventPoint touchPoint(qreal x, qreal y) { QPointF localPos(x, y); - QTouchEvent::TouchPoint point; + QMutableEventPoint point; point.setId(1); - point.setLastPos(localPos); - QRectF touchRect(0, 0, 40, 40); - touchRect.moveCenter(localPos); - point.setRect(touchRect); + point.setEllipseDiameters({40, 40}); + point.setPosition(localPos); point.setPressure(1); return point; } -bool QWebKitTest::sendTouchEvent(QQuickWebView* window, QEvent::Type type, const QList& points, ulong timestamp) +bool QWebKitTest::sendTouchEvent(QQuickWebView* window, QEvent::Type type, const QList& points, ulong timestamp) { ASSERT(window); - static QTouchDevice* device = 0; + static QPointingDevice* device = nullptr; if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); + device = new QPointingDevice; + device->setType(QInputDevice::DeviceType::TouchScreen); + QWindowSystemInterface::registerInputDevice(device); } - Qt::TouchPointStates touchPointStates = 0; - foreach (const QTouchEvent::TouchPoint& touchPoint, points) + QEventPoint::States touchPointStates{}; + Q_FOREACH (const QEventPoint& touchPoint, points) touchPointStates |= touchPoint.state(); QTouchEvent event(type, device, Qt::NoModifier, touchPointStates, points); @@ -90,14 +89,13 @@ bool QWebKitTest::touchTap(QObject* item, qreal x, qreal y, int delay) // FIXME: implement delay using QTest::qWait() or similar. Q_UNUSED(delay); - QList points; - points.append(touchPoint(x, y)); + QMutableEventPoint point{touchPoint(x, y)}; - points[0].setState(Qt::TouchPointPressed); - sendTouchEvent(window, QEvent::TouchBegin, points, QDateTime::currentMSecsSinceEpoch()); + point.setState(QEventPoint::State::Pressed); + sendTouchEvent(window, QEvent::TouchBegin, {point}, QDateTime::currentMSecsSinceEpoch()); - points[0].setState(Qt::TouchPointReleased); - sendTouchEvent(window, QEvent::TouchEnd, points, QDateTime::currentMSecsSinceEpoch()); + point.setState(QEventPoint::State::Released); + sendTouchEvent(window, QEvent::TouchEnd, {point}, QDateTime::currentMSecsSinceEpoch()); return true; } @@ -121,8 +119,20 @@ bool QWebKitTest::wheelEvent(QObject* item, qreal x, qreal y, int delta, Qt::Ori qWarning("Wheel event not accepted by receiving item"); return false; } - - QWheelEvent event(QPointF(x, y), delta, Qt::NoButton, Qt::NoModifier, orient); + + QPointF position{x, y}; + QPointF globalPosition = QCursor::pos(); + QPoint pixelDelta{}; + QPoint angleDelta; + if (orient == Qt::Vertical) + angleDelta = QPoint(0, delta); + else + angleDelta = QPoint(delta, 0); + Qt::MouseButtons buttons = Qt::NoButton; + Qt::KeyboardModifiers modifiers = Qt::NoModifier; + Qt::ScrollPhase phase = Qt::NoScrollPhase; + bool inverted = false; + QWheelEvent event(position, globalPosition, pixelDelta, angleDelta, buttons, modifiers, phase, inverted); event.setTimestamp(QDateTime::currentMSecsSinceEpoch()); event.setAccepted(false); diff --git a/Source/WebKit/UIProcess/API/qt/qwebnavigationrequest.cpp b/Source/WebKit/UIProcess/API/qt/qwebnavigationrequest.cpp index 4d835fa2c62de..e36306d4d62cb 100644 --- a/Source/WebKit/UIProcess/API/qt/qwebnavigationrequest.cpp +++ b/Source/WebKit/UIProcess/API/qt/qwebnavigationrequest.cpp @@ -63,7 +63,7 @@ void QWebNavigationRequest::setAction(QQuickWebView::NavigationRequestAction act return; d->action = action; - emit actionChanged(); + Q_EMIT actionChanged(); } QUrl QWebNavigationRequest::url() const diff --git a/Source/WebKit/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit/UIProcess/API/qt/qwebpreferences.cpp index 82a3db9520fde..9d86fca9da0f6 100644 --- a/Source/WebKit/UIProcess/API/qt/qwebpreferences.cpp +++ b/Source/WebKit/UIProcess/API/qt/qwebpreferences.cpp @@ -296,7 +296,7 @@ bool QWebPreferences::autoLoadImages() const void QWebPreferences::setAutoLoadImages(bool enable) { d->setAttribute(QWebPreferencesPrivate::AutoLoadImages, enable); - emit autoLoadImagesChanged(); + Q_EMIT autoLoadImagesChanged(); } bool QWebPreferences::fullScreenEnabled() const @@ -312,7 +312,7 @@ void QWebPreferences::setFullScreenEnabled(bool enable) { #if ENABLE(FULLSCREEN_API) d->setAttribute(QWebPreferencesPrivate::FullScreenEnabled, enable); - emit fullScreenEnabledChanged(); + Q_EMIT fullScreenEnabledChanged(); #else UNUSED_PARAM(enable); #endif @@ -326,7 +326,7 @@ bool QWebPreferences::javascriptEnabled() const void QWebPreferences::setJavascriptEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::JavascriptEnabled, enable); - emit javascriptEnabledChanged(); + Q_EMIT javascriptEnabledChanged(); } bool QWebPreferences::pluginsEnabled() const @@ -337,7 +337,7 @@ bool QWebPreferences::pluginsEnabled() const void QWebPreferences::setPluginsEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::PluginsEnabled, enable); - emit pluginsEnabledChanged(); + Q_EMIT pluginsEnabledChanged(); } bool QWebPreferences::offlineWebApplicationCacheEnabled() const @@ -348,7 +348,7 @@ bool QWebPreferences::offlineWebApplicationCacheEnabled() const void QWebPreferences::setOfflineWebApplicationCacheEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::OfflineWebApplicationCacheEnabled, enable); - emit offlineWebApplicationCacheEnabledChanged(); + Q_EMIT offlineWebApplicationCacheEnabledChanged(); } bool QWebPreferences::localStorageEnabled() const @@ -359,7 +359,7 @@ bool QWebPreferences::localStorageEnabled() const void QWebPreferences::setLocalStorageEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::LocalStorageEnabled, enable); - emit localStorageEnabledChanged(); + Q_EMIT localStorageEnabledChanged(); } bool QWebPreferences::xssAuditingEnabled() const @@ -370,7 +370,7 @@ bool QWebPreferences::xssAuditingEnabled() const void QWebPreferences::setXssAuditingEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::XSSAuditingEnabled, enable); - emit xssAuditingEnabledChanged(); + Q_EMIT xssAuditingEnabledChanged(); } bool QWebPreferences::privateBrowsingEnabled() const @@ -381,7 +381,7 @@ bool QWebPreferences::privateBrowsingEnabled() const void QWebPreferences::setPrivateBrowsingEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::PrivateBrowsingEnabled, enable); - emit privateBrowsingEnabledChanged(); + Q_EMIT privateBrowsingEnabledChanged(); } bool QWebPreferences::dnsPrefetchEnabled() const @@ -392,7 +392,7 @@ bool QWebPreferences::dnsPrefetchEnabled() const void QWebPreferences::setDnsPrefetchEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::DnsPrefetchEnabled, enable); - emit dnsPrefetchEnabledChanged(); + Q_EMIT dnsPrefetchEnabledChanged(); } bool QWebPreferences::developerExtrasEnabled() const @@ -403,7 +403,7 @@ bool QWebPreferences::developerExtrasEnabled() const void QWebPreferences::setDeveloperExtrasEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::DeveloperExtrasEnabled, enable); - emit developerExtrasEnabledChanged(); + Q_EMIT developerExtrasEnabledChanged(); } bool QWebPreferences::navigatorQtObjectEnabled() const @@ -416,7 +416,7 @@ void QWebPreferences::setNavigatorQtObjectEnabled(bool enable) if (enable == navigatorQtObjectEnabled()) return; d->webViewPrivate->setNavigatorQtObjectEnabled(enable); - emit navigatorQtObjectEnabledChanged(); + Q_EMIT navigatorQtObjectEnabledChanged(); } bool QWebPreferences::frameFlatteningEnabled() const @@ -427,7 +427,7 @@ bool QWebPreferences::frameFlatteningEnabled() const void QWebPreferences::setFrameFlatteningEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::FrameFlatteningEnabled, enable); - emit frameFlatteningEnabledChanged(); + Q_EMIT frameFlatteningEnabledChanged(); } QString QWebPreferences::standardFontFamily() const @@ -438,7 +438,7 @@ QString QWebPreferences::standardFontFamily() const void QWebPreferences::setStandardFontFamily(const QString& family) { d->setFontFamily(QWebPreferencesPrivate::StandardFont, family); - emit standardFontFamilyChanged(); + Q_EMIT standardFontFamilyChanged(); } QString QWebPreferences::fixedFontFamily() const @@ -449,7 +449,7 @@ QString QWebPreferences::fixedFontFamily() const void QWebPreferences::setFixedFontFamily(const QString& family) { d->setFontFamily(QWebPreferencesPrivate::FixedFont, family); - emit fixedFontFamilyChanged(); + Q_EMIT fixedFontFamilyChanged(); } QString QWebPreferences::serifFontFamily() const @@ -460,7 +460,7 @@ QString QWebPreferences::serifFontFamily() const void QWebPreferences::setSerifFontFamily(const QString& family) { d->setFontFamily(QWebPreferencesPrivate::SerifFont, family); - emit serifFontFamilyChanged(); + Q_EMIT serifFontFamilyChanged(); } QString QWebPreferences::sansSerifFontFamily() const @@ -471,7 +471,7 @@ QString QWebPreferences::sansSerifFontFamily() const void QWebPreferences::setSansSerifFontFamily(const QString& family) { d->setFontFamily(QWebPreferencesPrivate::SansSerifFont, family); - emit sansSerifFontFamilyChanged(); + Q_EMIT sansSerifFontFamilyChanged(); } QString QWebPreferences::cursiveFontFamily() const @@ -482,7 +482,7 @@ QString QWebPreferences::cursiveFontFamily() const void QWebPreferences::setCursiveFontFamily(const QString& family) { d->setFontFamily(QWebPreferencesPrivate::CursiveFont, family); - emit cursiveFontFamilyChanged(); + Q_EMIT cursiveFontFamilyChanged(); } QString QWebPreferences::fantasyFontFamily() const @@ -493,7 +493,7 @@ QString QWebPreferences::fantasyFontFamily() const void QWebPreferences::setFantasyFontFamily(const QString& family) { d->setFontFamily(QWebPreferencesPrivate::FantasyFont, family); - emit fantasyFontFamilyChanged(); + Q_EMIT fantasyFontFamilyChanged(); } unsigned QWebPreferences::minimumFontSize() const @@ -504,7 +504,7 @@ unsigned QWebPreferences::minimumFontSize() const void QWebPreferences::setMinimumFontSize(unsigned size) { d->setFontSize(QWebPreferencesPrivate::MinimumFontSize, size); - emit minimumFontSizeChanged(); + Q_EMIT minimumFontSizeChanged(); } unsigned QWebPreferences::defaultFontSize() const @@ -515,7 +515,7 @@ unsigned QWebPreferences::defaultFontSize() const void QWebPreferences::setDefaultFontSize(unsigned size) { d->setFontSize(QWebPreferencesPrivate::DefaultFontSize, size); - emit defaultFontSizeChanged(); + Q_EMIT defaultFontSizeChanged(); } unsigned QWebPreferences::defaultFixedFontSize() const @@ -526,7 +526,7 @@ unsigned QWebPreferences::defaultFixedFontSize() const void QWebPreferences::setDefaultFixedFontSize(unsigned size) { d->setFontSize(QWebPreferencesPrivate::DefaultFixedFontSize, size); - emit defaultFixedFontSizeChanged(); + Q_EMIT defaultFixedFontSizeChanged(); } bool QWebPreferences::webGLEnabled() const @@ -542,7 +542,7 @@ void QWebPreferences::setWebGLEnabled(bool enable) { #if ENABLE(WEBGL) d->setAttribute(QWebPreferencesPrivate::WebGLEnabled, enable); - emit webGLEnabledChanged(); + Q_EMIT webGLEnabledChanged(); #else UNUSED_PARAM(enable); #endif @@ -561,7 +561,7 @@ void QWebPreferences::setWebAudioEnabled(bool enable) { #if ENABLE(WEB_AUDIO) d->setAttribute(QWebPreferencesPrivate::WebAudioEnabled, enable); - emit webAudioEnabledChanged(); + Q_EMIT webAudioEnabledChanged(); #else UNUSED_PARAM(enable); #endif @@ -575,7 +575,7 @@ bool QWebPreferences::caretBrowsingEnabled() const void QWebPreferences::setCaretBrowsingEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::CaretBrowsingEnabled, enable); - emit caretBrowsingEnabledChanged(); + Q_EMIT caretBrowsingEnabledChanged(); } bool QWebPreferences::notificationsEnabled() const @@ -586,7 +586,7 @@ bool QWebPreferences::notificationsEnabled() const void QWebPreferences::setNotificationsEnabled(bool enable) { d->setAttribute(QWebPreferencesPrivate::NotificationsEnabled, enable); - emit notificationsEnabledChanged(); + Q_EMIT notificationsEnabledChanged(); } bool QWebPreferences::universalAccessFromFileURLsAllowed() const @@ -599,7 +599,7 @@ void QWebPreferences::setUniversalAccessFromFileURLsAllowed(bool enable) if (universalAccessFromFileURLsAllowed() == enable) return; d->setAttribute(QWebPreferencesPrivate::UniversalAccessFromFileURLsAllowed, enable); - emit universalAccessFromFileURLsAllowedChanged(); + Q_EMIT universalAccessFromFileURLsAllowedChanged(); } bool QWebPreferences::fileAccessFromFileURLsAllowed() const @@ -612,7 +612,7 @@ void QWebPreferences::setFileAccessFromFileURLsAllowed(bool enable) if (fileAccessFromFileURLsAllowed() == enable) return; d->setAttribute(QWebPreferencesPrivate::FileAccessFromFileURLsAllowed, enable); - emit fileAccessFromFileURLsAllowedChanged(); + Q_EMIT fileAccessFromFileURLsAllowedChanged(); } bool QWebPreferences::spatialNavigationEnabled() const @@ -625,7 +625,7 @@ void QWebPreferences::setSpatialNavigationEnabled(bool enable) if (spatialNavigationEnabled() == enable) return; d->setAttribute(QWebPreferencesPrivate::SpatialNavigationEnabled, enable); - emit spatialNavigationEnabledChanged(); + Q_EMIT spatialNavigationEnabledChanged(); } bool QWebPreferences::linksIncludedInFocusChain() const @@ -638,7 +638,7 @@ void QWebPreferences::setLinksIncludedInFocusChain(bool enable) if (linksIncludedInFocusChain() == enable) return; d->setAttribute(QWebPreferencesPrivate::LinksIncludedInFocusChain, enable); - emit linksIncludedInFocusChainChanged(); + Q_EMIT linksIncludedInFocusChainChanged(); } bool QWebPreferences::logsPageMessagesToSystemConsoleEnabled() const @@ -651,7 +651,7 @@ void QWebPreferences::setLogsPageMessagesToSystemConsoleEnabled(bool enable) if (logsPageMessagesToSystemConsoleEnabled() == enable) return; d->setAttribute(QWebPreferencesPrivate::LogsPageMessagesToSystemConsoleEnabled, enable); - emit logsPageMessagesToSystemConsoleEnabledChanged(); + Q_EMIT logsPageMessagesToSystemConsoleEnabledChanged(); } bool QWebPreferences::webSecurityEnabled() const @@ -664,7 +664,7 @@ void QWebPreferences::setWebSecurityEnabled(bool enable) if (webSecurityEnabled() == enable) return; d->setAttribute(QWebPreferencesPrivate::WebSecurityEnabled, enable); - emit webSecurityEnabledChanged(); + Q_EMIT webSecurityEnabledChanged(); } QWebPreferencesPrivate* QWebPreferencesPrivate::get(QWebPreferences* preferences) diff --git a/Source/WebKit/UIProcess/API/qt/tests/CMakeLists.txt b/Source/WebKit/UIProcess/API/qt/tests/CMakeLists.txt index 210342ef5bdc9..195e5f079253f 100644 --- a/Source/WebKit/UIProcess/API/qt/tests/CMakeLists.txt +++ b/Source/WebKit/UIProcess/API/qt/tests/CMakeLists.txt @@ -5,9 +5,9 @@ include_directories( ) include_directories(SYSTEM - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5Quick_PRIVATE_INCLUDE_DIRS} - ${Qt5QuickTest_INCLUDE_DIRS} + ${Qt6Quick_INCLUDE_DIRS} + ${Qt6Quick_PRIVATE_INCLUDE_DIRS} + ${Qt6QuickTest_INCLUDE_DIRS} ) set(tst_qmltests_DEFINITIONS @@ -75,13 +75,13 @@ set(qmltests_SOURCES ${qmltests_QML_SOURCES} ) -qt5_add_resources(qmltests_SOURCES qmltests/resources.qrc) +qt_add_resources(qmltests_SOURCES qmltests/resources.qrc) set(qmltests_LIBRARIES WebKit - ${Qt5Quick_LIBRARIES} - ${Qt5QuickTest_LIBRARIES} - ${Qt5Test_LIBRARIES} + ${Qt6Quick_LIBRARIES} + ${Qt6QuickTest_LIBRARIES} + ${Qt6Test_LIBRARIES} ) if (SHARED_CORE) diff --git a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp index c69c58dd6a416..2694cde7a6134 100644 --- a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp +++ b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp @@ -408,7 +408,7 @@ DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::~DrawingMonitor() int DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::webViewDrawCallback(DrawingAreaProxyCoordinatedGraphics::DrawingMonitor* monitor) { monitor->didDraw(); - return false; + return 0; } void DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start(WTF::Function&& callback) diff --git a/Source/WebKit/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit/UIProcess/Launcher/qt/ProcessLauncherQt.cpp index 51bc190d498b6..8ff91f8270251 100644 --- a/Source/WebKit/UIProcess/Launcher/qt/ProcessLauncherQt.cpp +++ b/Source/WebKit/UIProcess/Launcher/qt/ProcessLauncherQt.cpp @@ -86,13 +86,14 @@ class QtWebProcess final : public QProcess { QtWebProcess(QObject* parent = 0) : QProcess(parent) { + setChildProcessModifier(&QtWebProcess::processModifier); } protected: - void setupChildProcess() final; + static void processModifier(); }; -void QtWebProcess::setupChildProcess() +void QtWebProcess::processModifier() { #if defined(Q_OS_LINUX) #ifndef NDEBUG @@ -226,7 +227,7 @@ void ProcessLauncher::launchProcess() return; } #if OS(UNIX) - setpriority(PRIO_PROCESS, webProcessOrSUIDHelper->pid(), 10); + setpriority(PRIO_PROCESS, webProcessOrSUIDHelper->processId(), 10); #endif m_processObject = webProcessOrSUIDHelper; RefPtr protector(this); diff --git a/Source/WebKit/UIProcess/qt/ColorChooserContextObject.h b/Source/WebKit/UIProcess/qt/ColorChooserContextObject.h index 0af685b61f0eb..fa65c896c9564 100644 --- a/Source/WebKit/UIProcess/qt/ColorChooserContextObject.h +++ b/Source/WebKit/UIProcess/qt/ColorChooserContextObject.h @@ -42,8 +42,8 @@ class ColorChooserContextObject : public QObject { QColor currentColor() const { return m_currentColor; } QRectF elementRect() const { return m_rect; } - Q_INVOKABLE void accept(const QColor& color) { emit accepted(color); } - Q_INVOKABLE void reject() { emit rejected(); } + Q_INVOKABLE void accept(const QColor& color) { Q_EMIT accepted(color); } + Q_INVOKABLE void reject() { Q_EMIT rejected(); } Q_SIGNALS: void accepted(const QColor&); diff --git a/Source/WebKit/UIProcess/qt/DialogContextObjects.h b/Source/WebKit/UIProcess/qt/DialogContextObjects.h index c6257125e8b49..591039e835510 100644 --- a/Source/WebKit/UIProcess/qt/DialogContextObjects.h +++ b/Source/WebKit/UIProcess/qt/DialogContextObjects.h @@ -48,7 +48,7 @@ public Q_SLOTS: void dismiss() { m_dismissed = true; - emit dismissed(); + Q_EMIT dismissed(); } Q_SIGNALS: @@ -79,8 +79,8 @@ class DialogContextObject : public DialogContextBase { QString defaultValue() const { return m_defaultValue; } public Q_SLOTS: - void accept(const QString& result = QString()) { emit accepted(result); } - void reject() { emit rejected(); } + void accept(const QString& result = QString()) { Q_EMIT accepted(result); } + void reject() { Q_EMIT rejected(); } Q_SIGNALS: void accepted(const QString& result); @@ -110,8 +110,8 @@ class BaseAuthenticationContextObject : public DialogContextBase { QString prefilledUsername() const { return m_prefilledUsername; } public Q_SLOTS: - void accept(const QString& username, const QString& password) { emit accepted(username, password); } - void reject() { emit rejected(); } + void accept(const QString& username, const QString& password) { Q_EMIT accepted(username, password); } + void reject() { Q_EMIT rejected(); } Q_SIGNALS: void accepted(const QString& username, const QString& password); @@ -172,8 +172,8 @@ class CertificateVerificationDialogContextObject : public DialogContextBase { QString hostname() const { return m_hostname; } public Q_SLOTS: - void accept() { emit accepted(); } - void reject() { emit rejected(); } + void accept() { Q_EMIT accepted(); } + void reject() { Q_EMIT rejected(); } Q_SIGNALS: void accepted(); @@ -202,20 +202,20 @@ class FilePickerContextObject : public DialogContextBase { bool allowMultipleFiles() const { return m_allowMultiple;} public Q_SLOTS: - void reject() { emit rejected();} + void reject() { Q_EMIT rejected();} void accept(const QVariant& path) { QStringList filesPath = path.toStringList(); if (filesPath.isEmpty()) { - emit rejected(); + Q_EMIT rejected(); return; } // For single file upload, send only the first element if there are more than one file paths if (!m_allowMultiple && filesPath.count() > 1) filesPath = QStringList(filesPath.at(0)); - emit fileSelected(filesPath); + Q_EMIT fileSelected(filesPath); } Q_SIGNALS: @@ -267,8 +267,8 @@ class DatabaseQuotaDialogContextObject : public DialogContextBase { QtWebSecurityOrigin* securityOrigin() { return &m_securityOrigin; } public Q_SLOTS: - void accept(quint64 size) { emit accepted(size); } - void reject() { emit rejected(); } + void accept(quint64 size) { Q_EMIT accepted(size); } + void reject() { Q_EMIT rejected(); } Q_SIGNALS: void accepted(quint64 size); diff --git a/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.cpp b/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.cpp index a78fe496426be..897545fcb09f1 100644 --- a/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.cpp +++ b/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.cpp @@ -51,7 +51,7 @@ void ItemSelectorContextObject::onIndexUpdate() { // Send the update for multi-select list. if (m_items.multiple()) - emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex()); + Q_EMIT acceptedWithOriginalIndex(m_items.selectedOriginalIndex()); } @@ -60,11 +60,11 @@ void ItemSelectorContextObject::accept(int index) // If the index is not valid for multi-select lists, just hide the pop up as the selected indices have // already been sent. if ((index == -1) && m_items.multiple()) - emit done(); + Q_EMIT done(); else { if (index != -1) m_items.toggleItem(index); - emit acceptedWithOriginalIndex(m_items.selectedOriginalIndex()); + Q_EMIT acceptedWithOriginalIndex(m_items.selectedOriginalIndex()); } } @@ -126,7 +126,7 @@ QVariant PopupMenuItemModel::data(const QModelIndex& index, int role) const void PopupMenuItemModel::select(int index) { toggleItem(index); - emit indexUpdated(); + Q_EMIT indexUpdated(); } void PopupMenuItemModel::toggleItem(int index) @@ -148,11 +148,11 @@ void PopupMenuItemModel::toggleItem(int index) if (oldIndex != -1) { Item& oldItem = m_items[oldIndex]; oldItem.selected = false; - emit dataChanged(this->index(oldIndex), this->index(oldIndex)); + Q_EMIT dataChanged(this->index(oldIndex), this->index(oldIndex)); } } - emit dataChanged(this->index(index), this->index(index)); + Q_EMIT dataChanged(this->index(index), this->index(index)); } int PopupMenuItemModel::selectedOriginalIndex() const diff --git a/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.h b/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.h index ad63893d63191..305156e93658a 100644 --- a/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.h +++ b/Source/WebKit/UIProcess/qt/ItemSelectorContextObject.h @@ -101,8 +101,8 @@ class ItemSelectorContextObject : public QObject { bool allowMultiSelect() { return m_items.multiple(); } Q_INVOKABLE void accept(int index = -1); - Q_INVOKABLE void reject() { emit done(); } - Q_INVOKABLE void dismiss() { emit done(); } + Q_INVOKABLE void reject() { Q_EMIT done(); } + Q_INVOKABLE void dismiss() { Q_EMIT done(); } Q_SIGNALS: void acceptedWithOriginalIndex(int); diff --git a/Source/WebKit/UIProcess/qt/QtDownloadManager.cpp b/Source/WebKit/UIProcess/qt/QtDownloadManager.cpp index 4255ace5f91b3..d3b789f99e873 100644 --- a/Source/WebKit/UIProcess/qt/QtDownloadManager.cpp +++ b/Source/WebKit/UIProcess/qt/QtDownloadManager.cpp @@ -83,7 +83,7 @@ void QtDownloadManager::didCreateDestination(WKContextRef, WKDownloadRef downloa QWebDownloadItem* downloadItem = q->m_downloads.value(WKDownloadGetID(download)); ASSERT(downloadItem); downloadItem->d->destinationPath = WKStringCopyQString(path); - emit downloadItem->destinationFileCreated(downloadItem->d->destinationPath); + Q_EMIT downloadItem->destinationFileCreated(downloadItem->d->destinationPath); } void QtDownloadManager::didFinishDownload(WKContextRef, WKDownloadRef download, const void *clientInfo) @@ -93,7 +93,7 @@ void QtDownloadManager::didFinishDownload(WKContextRef, WKDownloadRef download, // Will be called when download finishes with success. QWebDownloadItem* downloadItem = q->m_downloads.take(WKDownloadGetID(download)); ASSERT(downloadItem); - emit downloadItem->succeeded(); + Q_EMIT downloadItem->succeeded(); } void QtDownloadManager::didFailDownload(WKContextRef, WKDownloadRef download, WKErrorRef error, const void* clientInfo) @@ -114,7 +114,7 @@ void QtDownloadManager::didFailDownload(WKContextRef, WKDownloadRef download, WK } QtWebError qtError(error); - emit downloadItem->failed(qtError.errorCodeAsDownloadError(), qtError.url(), qtError.description()); + Q_EMIT downloadItem->failed(qtError.errorCodeAsDownloadError(), qtError.url(), qtError.description()); } void QtDownloadManager::didReceiveDataForDownload(WKContextRef, WKDownloadRef download, uint64_t length, const void* clientInfo) @@ -125,7 +125,7 @@ void QtDownloadManager::didReceiveDataForDownload(WKContextRef, WKDownloadRef do QWebDownloadItem* downloadItem = q->m_downloads.value(WKDownloadGetID(download)); ASSERT(downloadItem); downloadItem->d->totalBytesReceived += length; - emit downloadItem->totalBytesReceivedChanged(length); + Q_EMIT downloadItem->totalBytesReceivedChanged(length); } } // namespace WebKit diff --git a/Source/WebKit/UIProcess/qt/QtPageClient.cpp b/Source/WebKit/UIProcess/qt/QtPageClient.cpp index fd7e1ae47d7df..82eb67fe37b33 100644 --- a/Source/WebKit/UIProcess/qt/QtPageClient.cpp +++ b/Source/WebKit/UIProcess/qt/QtPageClient.cpp @@ -262,7 +262,7 @@ void QtPageClient::enterFullScreen() WebFullScreenManagerProxy* manager = m_eventHandler->webPageProxy()->fullScreenManager(); manager->willEnterFullScreen(); - emit m_webView->experimental()->enterFullScreenRequested(); + Q_EMIT m_webView->experimental()->enterFullScreenRequested(); manager->didEnterFullScreen(); } @@ -270,7 +270,7 @@ void QtPageClient::exitFullScreen() { WebFullScreenManagerProxy* manager = m_eventHandler->webPageProxy()->fullScreenManager(); manager->willExitFullScreen(); - emit m_webView->experimental()->exitFullScreenRequested(); + Q_EMIT m_webView->experimental()->exitFullScreenRequested(); manager->didExitFullScreen(); } diff --git a/Source/WebKit/UIProcess/qt/QtTapGestureRecognizer.cpp b/Source/WebKit/UIProcess/qt/QtTapGestureRecognizer.cpp index eea6385bb5bb0..8a40629f96b06 100644 --- a/Source/WebKit/UIProcess/qt/QtTapGestureRecognizer.cpp +++ b/Source/WebKit/UIProcess/qt/QtTapGestureRecognizer.cpp @@ -160,7 +160,9 @@ void QtTapGestureRecognizer::reset() m_eventHandler->deactivateTapHighlight(); m_candidate = SingleTapCandidate; - m_lastTouchPoint.setId(-1); + // Qt 6 error: ‘using TouchPoint = class QEventPoint’ {aka ‘class QEventPoint’} has no member named ‘setId’ + //m_lastTouchPoint.setId(-1); + m_lastTouchPoint = {}; // ? m_highlightTimer.stop(); m_doubleTapTimer.stop(); m_tapAndHoldTimer.stop(); diff --git a/Source/WebKit/UIProcess/qt/QtWebContext.cpp b/Source/WebKit/UIProcess/qt/QtWebContext.cpp index 76c97bfc840c4..8737a494fbe09 100644 --- a/Source/WebKit/UIProcess/qt/QtWebContext.cpp +++ b/Source/WebKit/UIProcess/qt/QtWebContext.cpp @@ -183,19 +183,19 @@ QString QtWebContext::preparedStoragePath(StorageType type) QString path; switch (type) { case ApplicationCacheStorage: - path = defaultLocation(QStandardPaths::DataLocation) % QStringLiteral("Applications"); + path = defaultLocation(QStandardPaths::AppLocalDataLocation) % QStringLiteral("Applications"); QDir::root().mkpath(path); break; case DatabaseStorage: - path = defaultLocation(QStandardPaths::DataLocation) % QStringLiteral("Databases"); + path = defaultLocation(QStandardPaths::AppLocalDataLocation) % QStringLiteral("Databases"); QDir::root().mkpath(path); break; case LocalStorage: - path = defaultLocation(QStandardPaths::DataLocation) % QStringLiteral("LocalStorage"); + path = defaultLocation(QStandardPaths::AppLocalDataLocation) % QStringLiteral("LocalStorage"); QDir::root().mkpath(path); break; case CookieStorage: - path = defaultLocation(QStandardPaths::DataLocation); + path = defaultLocation(QStandardPaths::AppLocalDataLocation); QDir::root().mkpath(path); break; case DiskCacheStorage: @@ -207,7 +207,7 @@ QString QtWebContext::preparedStoragePath(StorageType type) QDir::root().mkpath(path); break; case IconDatabaseStorage: - path = defaultLocation(QStandardPaths::DataLocation); + path = defaultLocation(QStandardPaths::AppLocalDataLocation); QDir::root().mkpath(path); path += QStringLiteral("WebpageIcons.db"); break; diff --git a/Source/WebKit/UIProcess/qt/QtWebIconDatabaseClient.cpp b/Source/WebKit/UIProcess/qt/QtWebIconDatabaseClient.cpp index b641ab7f1aa2a..841cbb9ca40dd 100644 --- a/Source/WebKit/UIProcess/qt/QtWebIconDatabaseClient.cpp +++ b/Source/WebKit/UIProcess/qt/QtWebIconDatabaseClient.cpp @@ -71,7 +71,7 @@ unsigned QtWebIconDatabaseClient::updateID() void QtWebIconDatabaseClient::didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURL, const void* clientInfo) { ++s_updateId; - emit toQtWebIconDatabaseClient(clientInfo)->iconChangedForPageURL(WKURLCopyQString(pageURL)); + Q_EMIT toQtWebIconDatabaseClient(clientInfo)->iconChangedForPageURL(WKURLCopyQString(pageURL)); } QImage QtWebIconDatabaseClient::iconImageForPageURL(const QString& pageURL) diff --git a/Source/WebKit/UIProcess/qt/QtWebPagePolicyClient.cpp b/Source/WebKit/UIProcess/qt/QtWebPagePolicyClient.cpp index 2f5eb94c10e2f..c8cc742fe0896 100644 --- a/Source/WebKit/UIProcess/qt/QtWebPagePolicyClient.cpp +++ b/Source/WebKit/UIProcess/qt/QtWebPagePolicyClient.cpp @@ -50,7 +50,7 @@ void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, Qt: // NOTE: even though the C API (and the WebKit2 IPC) supports an asynchronous answer, this is not currently working. // We are expected to call the listener immediately. See the patch for https://bugs.webkit.org/show_bug.cgi?id=53785. QWebNavigationRequest navigationRequest(url, mouseButton, keyboardModifiers, navigationType, isMainFrame); - emit m_webView->navigationRequested(&navigationRequest); + Q_EMIT m_webView->navigationRequested(&navigationRequest); switch (navigationRequest.action()) { case QQuickWebView::IgnoreRequest: diff --git a/Source/WebKit/UIProcess/qt/QtWebPageUIClient.cpp b/Source/WebKit/UIProcess/qt/QtWebPageUIClient.cpp index f0c45a8d9a9d7..70987c3859707 100644 --- a/Source/WebKit/UIProcess/qt/QtWebPageUIClient.cpp +++ b/Source/WebKit/UIProcess/qt/QtWebPageUIClient.cpp @@ -84,13 +84,13 @@ void QtWebPageUIClient::mouseDidMoveOverElement(const QUrl& linkURL, const QStri return; m_lastHoveredURL = linkURL; m_lastHoveredTitle = linkTitle; - emit m_webView->linkHovered(m_lastHoveredURL, m_lastHoveredTitle); + Q_EMIT m_webView->linkHovered(m_lastHoveredURL, m_lastHoveredTitle); } void QtWebPageUIClient::permissionRequest(QWebPermissionRequest* request) { request->setParent(m_webView); - emit m_webView->experimental()->permissionRequested(request); + Q_EMIT m_webView->experimental()->permissionRequested(request); } static QtWebPageUIClient* toQtWebPageUIClient(const void* clientInfo) diff --git a/Source/WebKit/UIProcess/qt/WebPreferencesQt.cpp b/Source/WebKit/UIProcess/qt/WebPreferencesQt.cpp index 4250719647f40..538943d85cde1 100644 --- a/Source/WebKit/UIProcess/qt/WebPreferencesQt.cpp +++ b/Source/WebKit/UIProcess/qt/WebPreferencesQt.cpp @@ -28,6 +28,7 @@ #include "WebPreferencesKeys.h" #include +#include #include namespace WebKit { diff --git a/Source/WebKitLegacy/CMakeLists.txt b/Source/WebKitLegacy/CMakeLists.txt index cf4a565e3da2d..97387a62be71f 100644 --- a/Source/WebKitLegacy/CMakeLists.txt +++ b/Source/WebKitLegacy/CMakeLists.txt @@ -93,7 +93,7 @@ if (${PORT} STREQUAL "Qt") if (USE_LINKER_VERSION_SCRIPT) set(VERSION_SCRIPT "${CMAKE_BINARY_DIR}/QtWebKit.version") add_custom_command(TARGET WebKitLegacy PRE_LINK - COMMAND ${PERL_EXECUTABLE} ${TOOLS_DIR}/qt/generate-version-script.pl ${Qt5_VERSION} > ${VERSION_SCRIPT} + COMMAND ${PERL_EXECUTABLE} ${TOOLS_DIR}/qt/generate-version-script.pl ${Qt6_VERSION} > ${VERSION_SCRIPT} VERBATIM ) set_target_properties(WebKitLegacy PROPERTIES LINK_FLAGS -Wl,--version-script,${VERSION_SCRIPT}) diff --git a/Source/WebKitLegacy/PlatformQt.cmake b/Source/WebKitLegacy/PlatformQt.cmake index ab789ff0cdb7c..f772f58975a36 100644 --- a/Source/WebKitLegacy/PlatformQt.cmake +++ b/Source/WebKitLegacy/PlatformQt.cmake @@ -99,12 +99,12 @@ list(APPEND WebKitLegacy_SOURCES qt/WebCoreSupport/WebEventConversion.cpp ) -# Note: Qt5Network_INCLUDE_DIRS includes Qt5Core_INCLUDE_DIRS +# Note: Qt6Network_INCLUDE_DIRS includes Qt6Core_INCLUDE_DIRS list(APPEND WebKitLegacy_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${Qt5Network_INCLUDE_DIRS} - ${Qt5Positioning_INCLUDE_DIRS} + ${Qt6Gui_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6Network_INCLUDE_DIRS} + ${Qt6Positioning_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIR} ) # Build the include path with duplicates removed @@ -126,21 +126,21 @@ endif () list(APPEND WebKitLegacy_LIBRARIES PRIVATE ${WEBKIT_LIBRARY} - ${Qt5Quick_LIBRARIES} - ${Qt5WebChannel_LIBRARIES} + ${Qt6Quick_LIBRARIES} + ${Qt6WebChannel_LIBRARIES} ) list(APPEND WebKitLegacy_LIBRARIES PRIVATE ${ICU_LIBRARIES} - ${Qt5Positioning_LIBRARIES} + ${Qt6Positioning_LIBRARIES} ${X11_X11_LIB} ${X11_Xcomposite_LIB} ${X11_Xrender_LIB} PUBLIC - ${Qt5Core_LIBRARIES} - ${Qt5Gui_LIBRARIES} - ${Qt5Network_LIBRARIES} + ${Qt6Core_LIBRARIES} + ${Qt6Gui_LIBRARIES} + ${Qt6Network_LIBRARIES} ) if (ENABLE_GEOLOCATION) @@ -179,7 +179,7 @@ endif () # Resources have to be included directly in the final binary. # The linker won't pick them from a static library since they aren't referenced. if (NOT SHARED_CORE) - qt5_add_resources(WebKitLegacy_SOURCES + qt6_add_resources(WebKitLegacy_SOURCES "${WEBCORE_DIR}/WebCore.qrc" ) @@ -290,7 +290,7 @@ install( COMPONENT Data ) -set(WEBKIT_PKGCONFIG_DEPS "Qt5Core Qt5Gui Qt5Network") +set(WEBKIT_PKGCONFIG_DEPS "Qt6Core Qt6Gui Qt6Network") set(WEBKIT_PRI_DEPS "core gui network") set(WEBKIT_PRI_EXTRA_LIBS "") set(WEBKIT_PRI_RUNTIME_DEPS "core_private gui_private") @@ -311,15 +311,15 @@ if (USE_MEDIA_FOUNDATION) set(WEBKIT_PRI_EXTRA_LIBS "-lmfuuid -lstrmiids ${WEBKIT_PRI_EXTRA_LIBS}") endif () if (USE_QT_MULTIMEDIA) - set(WEBKIT_PKGCONFIG_DEPS "${WEBKIT_PKGCONFIG_DEPS} Qt5Multimedia") + set(WEBKIT_PKGCONFIG_DEPS "${WEBKIT_PKGCONFIG_DEPS} Qt6Multimedia") set(WEBKIT_PRI_RUNTIME_DEPS "multimedia ${WEBKIT_PRI_RUNTIME_DEPS}") endif () -set(WEBKITWIDGETS_PKGCONFIG_DEPS "${WEBKIT_PKGCONFIG_DEPS} Qt5Widgets Qt5WebKit") +set(WEBKITWIDGETS_PKGCONFIG_DEPS "${WEBKIT_PKGCONFIG_DEPS} Qt6Widgets Qt6WebKit") set(WEBKITWIDGETS_PRI_DEPS "${WEBKIT_PRI_DEPS} widgets webkit") set(WEBKITWIDGETS_PRI_RUNTIME_DEPS "${WEBKIT_PRI_RUNTIME_DEPS} widgets_private") -if (Qt5OpenGL_FOUND) +if (Qt6OpenGL_FOUND) set(WEBKITWIDGETS_PRI_RUNTIME_DEPS "${WEBKITWIDGETS_PRI_RUNTIME_DEPS} opengl") endif () @@ -328,12 +328,12 @@ if (ENABLE_PRINT_SUPPORT) endif () if (USE_QT_MULTIMEDIA) - set(WEBKITWIDGETS_PKGCONFIG_DEPS "${WEBKITWIDGETS_PKGCONFIG_DEPS} Qt5MultimediaWidgets") + set(WEBKITWIDGETS_PKGCONFIG_DEPS "${WEBKITWIDGETS_PKGCONFIG_DEPS} Qt6MultimediaWidgets") set(WEBKITWIDGETS_PRI_RUNTIME_DEPS "${WEBKITWIDGETS_PRI_RUNTIME_DEPS} multimediawidgets") endif () if (QT_STATIC_BUILD) - set(WEBKITWIDGETS_PKGCONFIG_DEPS "${WEBKITWIDGETS_PKGCONFIG_DEPS} Qt5PrintSupport") + set(WEBKITWIDGETS_PKGCONFIG_DEPS "${WEBKITWIDGETS_PKGCONFIG_DEPS} Qt6PrintSupport") set(WEBKITWIDGETS_PRI_DEPS "${WEBKITWIDGETS_PRI_DEPS} printsupport") set(EXTRA_LIBS_NAMES WebCore JavaScriptCore WTF) append_lib_names_to_list(EXTRA_LIBS_NAMES ${LIBXML2_LIBRARIES} ${SQLITE_LIBRARIES} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) @@ -361,7 +361,7 @@ endif () if (NOT MACOS_BUILD_FRAMEWORKS) ecm_generate_pkgconfig_file( - BASE_NAME Qt5WebKit + BASE_NAME Qt6WebKit DESCRIPTION "Qt WebKit module" INCLUDE_INSTALL_DIR "${KDE_INSTALL_INCLUDEDIR}/QtWebKit" DEPS "${WEBKIT_PKGCONFIG_DEPS}" @@ -430,7 +430,7 @@ list(APPEND QtWebKit_Private_PRI_ARGUMENTS MODULE_CONFIG "internal_module no_lin if (MACOS_BUILD_FRAMEWORKS) set(WebKitLegacy_OUTPUT_NAME QtWebKit) else () - set(WebKitLegacy_OUTPUT_NAME Qt5WebKit) + set(WebKitLegacy_OUTPUT_NAME Qt6WebKit) endif () ecm_generate_pri_file( @@ -514,9 +514,10 @@ set(WebKitWidgets_SOURCES ) set(WebKitWidgets_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Network_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} + ${Qt6Gui_INCLUDE_DIRS} + ${Qt6Network_INCLUDE_DIRS} + ${Qt6Widgets_INCLUDE_DIRS} + ${Qt6OpenGLWidgets_INCLUDE_DIRS} ) if (APPLE) @@ -527,10 +528,11 @@ endif () set(WebKitWidgets_LIBRARIES PRIVATE - ${Qt5MultimediaWidgets_LIBRARIES} - ${Qt5PrintSupport_LIBRARIES} + ${Qt6MultimediaWidgets_LIBRARIES} + ${Qt6PrintSupport_LIBRARIES} + ${Qt6OpenGLWidgets_LIBRARIES} PUBLIC - ${Qt5Widgets_LIBRARIES} + ${Qt6Widgets_LIBRARIES} WebKitLegacy ) @@ -540,7 +542,7 @@ if (USE_QT_MULTIMEDIA) qt/WidgetSupport/FullScreenVideoWidget.cpp ) list(APPEND WebKitWidgets_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5MultimediaWidgets_INCLUDE_DIRS} + ${Qt6MultimediaWidgets_INCLUDE_DIRS} ) endif () @@ -625,7 +627,7 @@ install( if (NOT MACOS_BUILD_FRAMEWORKS) ecm_generate_pkgconfig_file( - BASE_NAME Qt5WebKitWidgets + BASE_NAME Qt6WebKitWidgets DESCRIPTION "Qt WebKitWidgets module" INCLUDE_INSTALL_DIR "${KDE_INSTALL_INCLUDEDIR}/QtWebKitWidgets" DEPS "${WEBKITWIDGETS_PKGCONFIG_DEPS}" @@ -688,7 +690,7 @@ list(APPEND WebKitWidgets_Private_PRI_ARGUMENTS MODULE_CONFIG "internal_module n if (MACOS_BUILD_FRAMEWORKS) set(WebKitWidgets_OUTPUT_NAME QtWebKitWidgets) else () - set(WebKitWidgets_OUTPUT_NAME Qt5WebKitWidgets) + set(WebKitWidgets_OUTPUT_NAME Qt6WebKitWidgets) endif () ecm_generate_pri_file( @@ -747,7 +749,7 @@ WEBKIT_COPY_FILES(WebKitWidgets_CopyHeaders WEBKIT_FRAMEWORK(WebKitWidgets) add_dependencies(WebKitWidgets WebKitLegacy) set_target_properties(WebKitWidgets PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) -install(TARGETS WebKitWidgets EXPORT Qt5WebKitWidgetsTargets +install(TARGETS WebKitWidgets EXPORT Qt6WebKitWidgetsTargets DESTINATION "${LIB_INSTALL_DIR}" RUNTIME DESTINATION "${BIN_INSTALL_DIR}" ) @@ -775,7 +777,7 @@ endif () if (USE_LINKER_VERSION_SCRIPT) set(VERSION_SCRIPT "${CMAKE_BINARY_DIR}/QtWebKitWidgets.version") add_custom_command(TARGET WebKitWidgets PRE_LINK - COMMAND ${PERL_EXECUTABLE} ${TOOLS_DIR}/qt/generate-version-script.pl ${Qt5_VERSION} > ${VERSION_SCRIPT} + COMMAND ${PERL_EXECUTABLE} ${TOOLS_DIR}/qt/generate-version-script.pl ${Qt6_VERSION} > ${VERSION_SCRIPT} VERBATIM ) set_target_properties(WebKitWidgets PROPERTIES LINK_FLAGS -Wl,--version-script,${VERSION_SCRIPT}) diff --git a/Source/WebKitLegacy/qt/Api/qwebsettings.cpp b/Source/WebKitLegacy/qt/Api/qwebsettings.cpp index d3c7ba116bb74..7e0e307972d70 100644 --- a/Source/WebKitLegacy/qt/Api/qwebsettings.cpp +++ b/Source/WebKitLegacy/qt/Api/qwebsettings.cpp @@ -1170,7 +1170,8 @@ QString QWebSettings::localStoragePath() const Enables WebKit data persistence and sets the path to \a path. If \a path is empty, the user-specific data location specified by - \l{QDesktopServices::DataLocation}{DataLocation} will be used instead. + \l{QDesktopServices::AppLocalDataLocation}{AppLocalDataLocation} + will be used instead. This method will simultaneously set and enable the iconDatabasePath(), localStoragePath(), offlineStoragePath() and offlineWebApplicationCachePath(). @@ -1185,7 +1186,7 @@ void QWebSettings::enablePersistentStorage(const QString& path) if (path.isEmpty()) { - storagePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); + storagePath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); if (storagePath.isEmpty()) storagePath = FileSystem::pathByAppendingComponent(String(QDir::homePath()), String(QCoreApplication::applicationName())); } else diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.cpp index d4595a23ae173..296c5ed37734b 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.cpp @@ -169,7 +169,7 @@ void ChromeClientQt::takeFocus(FocusDirection) void ChromeClientQt::focusedElementChanged(Element* element) { - emit m_webPage->focusedElementChanged(QWebElement(element)); + Q_EMIT m_webPage->focusedElementChanged(QWebElement(element)); } void ChromeClientQt::focusedFrameChanged(Frame*) @@ -481,7 +481,7 @@ void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsign void ChromeClientQt::print(Frame& frame, const StringWithDirection&) { - emit m_webPage->printRequested(QWebFrameAdapter::kit(frame)); + Q_EMIT m_webPage->printRequested(QWebFrameAdapter::kit(frame)); } void ChromeClientQt::exceededDatabaseQuota(Frame& frame, const String& databaseName, DatabaseDetails) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/EditorClientQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/EditorClientQt.cpp index 7f2e3eccd6885..ea8eb65f463b2 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/EditorClientQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/EditorClientQt.cpp @@ -204,7 +204,7 @@ void EditorClientQt::respondToChangedSelection(Frame* frame) m_page->respondToChangedSelection(); if (!frame->editor().ignoreSelectionChanges()) // QTFIXME: check - emit m_page->microFocusChanged(); + Q_EMIT m_page->microFocusChanged(); } void EditorClientQt::didEndEditing() @@ -622,7 +622,7 @@ void EditorClientQt::setInputMethodState(WebCore::Element* element) webPageClient->setInputMethodHints(hints); webPageClient->setInputMethodEnabled(active); } - emit m_page->microFocusChanged(); + Q_EMIT m_page->microFocusChanged(); } bool EditorClientQt::supportsGlobalSelection() diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/FrameLoaderClientQt.cpp index e92c18470bb32..a42ebbb0231a3 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -429,7 +429,7 @@ void FrameLoaderClientQt::dispatchDidReceiveTitle(const StringWithDirection& tit if (!m_webFrame) return; - emit titleChanged(title.string); + Q_EMIT titleChanged(title.string); } @@ -447,13 +447,13 @@ void FrameLoaderClientQt::dispatchDidCommitLoad(std::optionalpage()->mainFrame()); if (!isMainFrame) return; - emit m_webFrame->pageAdapter->emitViewportChangeRequested(); + Q_EMIT m_webFrame->pageAdapter->emitViewportChangeRequested(); } @@ -854,7 +854,7 @@ void FrameLoaderClientQt::convertMainResourceLoadToDownload(DocumentLoader* docu QNetworkReply* reply = handler->release(); if (reply) { if (m_webFrame->pageAdapter->forwardUnsupportedContent) { - emit unsupportedContent(reply); + Q_EMIT unsupportedContent(reply); } else { reply->abort(); reply->deleteLater(); diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/ProgressTrackerClientQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/ProgressTrackerClientQt.cpp index d7fba801a74d8..c101a197dc69e 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/ProgressTrackerClientQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/ProgressTrackerClientQt.cpp @@ -62,7 +62,7 @@ void ProgressTrackerClientQt::progressStarted(Frame& originatingProgressFrame) void ProgressTrackerClientQt::progressEstimateChanged(Frame& originatingProgressFrame) { ASSERT(m_webPage == QWebFrameAdapter::kit(&originatingProgressFrame)->pageAdapter); - emit loadProgress(qRound(originatingProgressFrame.page()->progress().estimatedProgress() * 100)); + Q_EMIT loadProgress(qRound(originatingProgressFrame.page()->progress().estimatedProgress() * 100)); } void ProgressTrackerClientQt::progressFinished(Frame& originatingProgressFrame) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp index b3b42a161d9c8..942902695a085 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp @@ -276,7 +276,7 @@ void QWebFrameAdapter::setHtml(const QString &html, const QUrl &baseUrl) QMultiMap QWebFrameAdapter::metaData() const { if (!frame->document()) - return QMap(); + return {}; QMultiMap map; Document* doc = frame->document(); diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp index 2160df3f9dcdf..e72e5fd17e73d 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/WebEventConversion.cpp @@ -125,18 +125,13 @@ class WebKitPlatformWheelEvent : public PlatformWheelEvent { WebKitPlatformWheelEvent(QWheelEvent*, int wheelScrollLines); private: - void applyDelta(int delta, Qt::Orientation, int wheelScrollLines); + void applyDelta(QPoint delta, int wheelScrollLines); }; -void WebKitPlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation, int wheelScrollLines) +void WebKitPlatformWheelEvent::applyDelta(QPoint angleDelta, int wheelScrollLines) { - if (orientation == Qt::Horizontal) { - m_deltaX = delta; - m_deltaY = 0; - } else { - m_deltaX = 0; - m_deltaY = delta; - } + m_deltaX = angleDelta.x(); + m_deltaY = angleDelta.y(); m_wheelTicksX = m_deltaX / 120.0f; m_wheelTicksY = m_deltaY / 120.0f; @@ -151,11 +146,11 @@ WebKitPlatformWheelEvent::WebKitPlatformWheelEvent(QWheelEvent* e, int wheelScro { m_timestamp = WallTime::now(); m_modifiers = mouseEventModifiersFromQtKeyboardModifiers(e->modifiers()); - m_position = e->pos(); - m_globalPosition = e->globalPos(); + m_position = e->position().toPoint(); + m_globalPosition = e->globalPosition().toPoint(); m_granularity = ScrollByPixelWheelEvent; m_directionInvertedFromDevice = false; - applyDelta(e->delta(), e->orientation(), wheelScrollLines); + applyDelta(e->angleDelta(), wheelScrollLines); } #if ENABLE(TOUCH_EVENTS) diff --git a/Source/WebKitLegacy/qt/WidgetApi/qgraphicswebview.cpp b/Source/WebKitLegacy/qt/WidgetApi/qgraphicswebview.cpp index 8bcb5e6c55442..c332f14965c1b 100644 --- a/Source/WebKitLegacy/qt/WidgetApi/qgraphicswebview.cpp +++ b/Source/WebKitLegacy/qt/WidgetApi/qgraphicswebview.cpp @@ -92,9 +92,9 @@ void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) { // If the page had no title, still make sure it gets the signal if (q->title().isEmpty()) - emit q->urlChanged(q->url()); + Q_EMIT q->urlChanged(q->url()); - emit q->loadFinished(success); + Q_EMIT q->loadFinished(success); } void QGraphicsWebViewPrivate::_q_pageDestroyed() diff --git a/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp b/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp index 34034341b4e05..08b18b7e10e92 100644 --- a/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp +++ b/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp @@ -57,23 +57,23 @@ void QWebFramePrivate::setPage(QWebPage* newPage) page = newPage; pageAdapter = newPage->handle(); - emit q->pageChanged(); + Q_EMIT q->pageChanged(); } void QWebFramePrivate::emitUrlChanged() { url = coreFrameUrl(); - emit q->urlChanged(url); + Q_EMIT q->urlChanged(url); } void QWebFramePrivate::didStartProvisionalLoad() { - emit q->provisionalLoad(); + Q_EMIT q->provisionalLoad(); } void QWebFramePrivate::didClearWindowObject() { - emit q->javaScriptWindowObjectCleared(); + Q_EMIT q->javaScriptWindowObjectCleared(); } bool QWebFramePrivate::handleProgressFinished(QPoint *localPos) @@ -87,26 +87,26 @@ bool QWebFramePrivate::handleProgressFinished(QPoint *localPos) void QWebFramePrivate::emitInitialLayoutCompleted() { - emit q->initialLayoutCompleted(); + Q_EMIT q->initialLayoutCompleted(); } void QWebFramePrivate::emitIconChanged() { - emit q->iconChanged(); + Q_EMIT q->iconChanged(); } void QWebFramePrivate::emitLoadStarted(bool originatingLoad) { if (page && originatingLoad) - emit page->loadStarted(); - emit q->loadStarted(); + Q_EMIT page->loadStarted(); + Q_EMIT q->loadStarted(); } void QWebFramePrivate::emitLoadFinished(bool originatingLoad, bool ok) { if (page && originatingLoad) - emit page->loadFinished(ok); - emit q->loadFinished(ok); + Q_EMIT page->loadFinished(ok); + Q_EMIT q->loadFinished(ok); } QWebFrameAdapter* QWebFramePrivate::createChildFrame(QWebFrameData* frameData) @@ -117,7 +117,7 @@ QWebFrameAdapter* QWebFramePrivate::createChildFrame(QWebFrameData* frameData) void QWebFramePrivate::contentsSizeDidChange(const QSize &size) { - emit q->contentsSizeChanged(size); + Q_EMIT q->contentsSizeChanged(size); } int QWebFramePrivate::scrollBarPolicy(Qt::Orientation orientation) const diff --git a/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp b/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp index a6fdf4225ebb6..4ebc765962030 100644 --- a/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp +++ b/Source/WebKitLegacy/qt/WidgetApi/qwebpage.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -255,7 +254,7 @@ void QWebPagePrivate::unfocus() void QWebPagePrivate::setWindowRect(const QRect &rect) { - emit q->geometryChangeRequested(rect); + Q_EMIT q->geometryChangeRequested(rect); } QSize QWebPagePrivate::viewportSize() const @@ -276,7 +275,7 @@ QWebPageAdapter *QWebPagePrivate::createWindow(bool dialog) void QWebPagePrivate::consoleMessageReceived(MessageSource source, MessageLevel level, const QString& message, int lineNumber, const QString& sourceID) { q->javaScriptConsoleMessage(message, lineNumber, sourceID); - emit q->consoleMessageReceived(QWebPage::MessageSource(source), QWebPage::MessageLevel(level), message, lineNumber, sourceID); + Q_EMIT q->consoleMessageReceived(QWebPage::MessageSource(source), QWebPage::MessageLevel(level), message, lineNumber, sourceID); } void QWebPagePrivate::javaScriptAlert(QWebFrameAdapter* frame, const QString& msg) @@ -301,17 +300,17 @@ bool QWebPagePrivate::shouldInterruptJavaScript() void QWebPagePrivate::printRequested(QWebFrameAdapter *frame) { - emit q->printRequested(QWebFramePrivate::kit(frame)); + Q_EMIT q->printRequested(QWebFramePrivate::kit(frame)); } void QWebPagePrivate::databaseQuotaExceeded(QWebFrameAdapter* frame, const QString& databaseName) { - emit q->databaseQuotaExceeded(QWebFramePrivate::kit(frame), databaseName); + Q_EMIT q->databaseQuotaExceeded(QWebFramePrivate::kit(frame), databaseName); } void QWebPagePrivate::applicationCacheQuotaExceeded(QWebSecurityOrigin *origin, quint64 defaultOriginQuota, quint64 c) { - emit q->applicationCacheQuotaExceeded(origin, defaultOriginQuota, c); + Q_EMIT q->applicationCacheQuotaExceeded(origin, defaultOriginQuota, c); } void QWebPagePrivate::setToolTip(const QString &tip) @@ -378,22 +377,22 @@ bool QWebPagePrivate::acceptNavigationRequest(QWebFrameAdapter *frameAdapter, co void QWebPagePrivate::emitRestoreFrameStateRequested(QWebFrameAdapter *frame) { - emit q->restoreFrameStateRequested(QWebFramePrivate::kit(frame)); + Q_EMIT q->restoreFrameStateRequested(QWebFramePrivate::kit(frame)); } void QWebPagePrivate::emitSaveFrameStateRequested(QWebFrameAdapter *frame, QWebHistoryItem *item) { - emit q->saveFrameStateRequested(QWebFramePrivate::kit(frame), item); + Q_EMIT q->saveFrameStateRequested(QWebFramePrivate::kit(frame), item); } void QWebPagePrivate::emitDownloadRequested(const QNetworkRequest &request) { - emit q->downloadRequested(request); + Q_EMIT q->downloadRequested(request); } void QWebPagePrivate::emitFrameCreated(QWebFrameAdapter *frame) { - emit q->frameCreated(QWebFramePrivate::kit(frame)); + Q_EMIT q->frameCreated(QWebFramePrivate::kit(frame)); } bool QWebPagePrivate::errorPageExtension(QWebPageAdapter::ErrorPageOption *opt, QWebPageAdapter::ErrorPageReturn *out) @@ -442,7 +441,7 @@ void QWebPagePrivate::createMainFrame() { if (!mainFrame) { mainFrame = new QWebFrame(q); - emit q->frameCreated(mainFrame.data()); + Q_EMIT q->frameCreated(mainFrame.data()); } } @@ -695,7 +694,7 @@ QStringList QWebPagePrivate::menuActionsAsText() void QWebPagePrivate::emitViewportChangeRequested() { - emit q->viewportChangeRequested(); + Q_EMIT q->viewportChangeRequested(); } void QWebPagePrivate::updateEditorActions() @@ -1846,7 +1845,7 @@ void QWebPage::triggerAction(WebAction action, bool) case RequestClose: { bool success = d->tryClosePage(); if (success) - emit windowCloseRequested(); + Q_EMIT windowCloseRequested(); break; } default: @@ -1888,40 +1887,40 @@ QRect QWebPagePrivate::viewRectRelativeToWindow() void QWebPagePrivate::geolocationPermissionRequested(QWebFrameAdapter* frame) { - emit q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Geolocation); + Q_EMIT q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Geolocation); } void QWebPagePrivate::geolocationPermissionRequestCancelled(QWebFrameAdapter* frame) { - emit q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Geolocation); + Q_EMIT q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Geolocation); } void QWebPagePrivate::notificationsPermissionRequested(QWebFrameAdapter* frame) { - emit q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Notifications); + Q_EMIT q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Notifications); } void QWebPagePrivate::notificationsPermissionRequestCancelled(QWebFrameAdapter* frame) { - emit q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Notifications); + Q_EMIT q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Notifications); } void QWebPagePrivate::respondToChangedContents() { updateEditorActions(); - emit q->contentsChanged(); + Q_EMIT q->contentsChanged(); } void QWebPagePrivate::respondToChangedSelection() { updateEditorActions(); - emit q->selectionChanged(); + Q_EMIT q->selectionChanged(); } void QWebPagePrivate::microFocusChanged() { - emit q->microFocusChanged(); + Q_EMIT q->microFocusChanged(); } void QWebPagePrivate::triggerCopyAction() @@ -2079,18 +2078,26 @@ static int getintenv(const char* variable) static QSize queryDeviceSizeForScreenContainingWidget(const QWidget* widget) { - QScreen* screen; + QScreen *screen = nullptr; + if (widget) { - screen = QGuiApplication::screenAt(widget->pos()); - } else - screen = QGuiApplication::screens().at(0); - - if (!screen) - return QSize(); + QWindow *window = widget->window()->windowHandle(); + if (window) { + screen = window->screen(); + } + } + + if (!screen) { + screen = QGuiApplication::screens().first(); + } + + if (!screen) { + return {}; + } // Returns the available geometry of the screen which contains widget. // NOTE: this must be the the full screen size including any fixed status areas etc. - QSize size = screen->size(); + QSize size = screen->availableGeometry().size(); // This must be in portrait mode, adjust if not. if (size.width() > size.height()) { @@ -2245,11 +2252,11 @@ bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest & return true; if (QWebPageAdapter::treatSchemeAsLocal(request.url().scheme())) return true; - emit linkClicked(request.url()); + Q_EMIT linkClicked(request.url()); return false; case DelegateAllLinks: - emit linkClicked(request.url()); + Q_EMIT linkClicked(request.url()); return false; } } @@ -2664,7 +2671,11 @@ bool QWebPage::event(QEvent *ev) #if !defined(QT_NO_GRAPHICSVIEW) case QEvent::GraphicsSceneWheel: { QGraphicsSceneWheelEvent *gsEv = static_cast(ev); - QWheelEvent dummyEvent(gsEv->pos(), gsEv->screenPos(), gsEv->delta(), gsEv->buttons(), gsEv->modifiers(), gsEv->orientation()); + QPoint angleDelta { + (gsEv->orientation() == Qt::Horizontal ? 1 : 0) * gsEv->delta(), + (gsEv->orientation() == Qt::Vertical ? 1 : 0) * gsEv->delta(), + }; + QWheelEvent dummyEvent(gsEv->pos(), gsEv->screenPos(), gsEv->pixelDelta(), angleDelta, gsEv->buttons(), gsEv->modifiers(), gsEv->phase(), gsEv->isInverted()); d->wheelEvent(&dummyEvent, QApplication::wheelScrollLines()); ev->setAccepted(dummyEvent.isAccepted()); break; diff --git a/Source/WebKitLegacy/qt/WidgetApi/qwebpage_p.cpp b/Source/WebKitLegacy/qt/WidgetApi/qwebpage_p.cpp index 7c2f15d0998b6..5918f90f98b6e 100644 --- a/Source/WebKitLegacy/qt/WidgetApi/qwebpage_p.cpp +++ b/Source/WebKitLegacy/qt/WidgetApi/qwebpage_p.cpp @@ -62,10 +62,10 @@ void QWebPagePrivate::fullScreenRequested(QWebFullScreenRequest request) void QWebPagePrivate::recentlyAudibleChanged(bool recentlyAudible) { - emit q->recentlyAudibleChanged(recentlyAudible); + Q_EMIT q->recentlyAudibleChanged(recentlyAudible); } void QWebPagePrivate::focusedElementChanged(const QWebElement& element) { - emit q->focusedElementChanged(element); + Q_EMIT q->focusedElementChanged(element); } diff --git a/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp b/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp index d89f53ddebb36..d020df7382d61 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp +++ b/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp @@ -27,9 +27,6 @@ #include #endif -#ifdef QT_OPENGL_LIB -#include -#endif #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include #endif @@ -187,14 +184,6 @@ bool PageClientQGraphicsWidget::makeOpenGLContextCurrentIfAvailable() QGraphicsView* graphicsView = firstGraphicsView(); if (graphicsView && graphicsView->viewport()) { QWidget* widget = graphicsView->viewport(); -#if defined(QT_OPENGL_LIB) - if (widget->inherits("QGLWidget")) { - QGLWidget* glWidget = static_cast(widget); - // The GL context belonging to the QGLWidget viewport must be current when TextureMapper is being created. - glWidget->makeCurrent(); - return true; - } -#endif #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) if (widget->inherits("QOpenGLWidget")) { QOpenGLWidget* qoglWidget = static_cast(widget); @@ -213,12 +202,6 @@ QOpenGLContext* PageClientQGraphicsWidget::openGLContextIfAvailable() QGraphicsView* graphicsView = firstGraphicsView(); if (graphicsView && graphicsView->viewport()) { QWidget* widget = graphicsView->viewport(); -#if defined(QT_OPENGL_LIB) - if (widget->inherits("QGLWidget")) { - QGLWidget* glWidget = static_cast(widget); - return glWidget->context()->contextHandle(); - } -#endif #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) if (widget->inherits("QOpenGLWidget")) { QOpenGLWidget* qoglWidget = static_cast(widget); diff --git a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp index cdb0385913702..7fd6020eae997 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp +++ b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp @@ -68,7 +68,7 @@ static QStyle::SubControl convertToQStyleSubControl(QStyleFacade::SubControl sc) static void initGenericStyleOption(QStyleOption* option, QWidget* widget, const QStyleFacadeOption& facadeOption) { if (widget) - option->init(widget); + option->initFrom(widget); else // If a widget is not directly available for rendering, we fallback to default // value for an active widget. diff --git a/Source/WebKitLegacy/qt/WidgetSupport/QtFallbackWebPopup.cpp b/Source/WebKitLegacy/qt/WidgetSupport/QtFallbackWebPopup.cpp index 67d89925bb50e..381aa2e47faf2 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/QtFallbackWebPopup.cpp +++ b/Source/WebKitLegacy/qt/WidgetSupport/QtFallbackWebPopup.cpp @@ -123,7 +123,7 @@ void QtFallbackWebPopup::activeChanged(int index) if (index < 0) return; - emit selectItem(index, false, false); + Q_EMIT selectItem(index, false, false); } void QtFallbackWebPopup::deleteComboBox() diff --git a/Source/WebKitLegacy/qt/WidgetSupport/QtWebComboBox.cpp b/Source/WebKitLegacy/qt/WidgetSupport/QtWebComboBox.cpp index 5b1a36375b984..033a8977ee6ed 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/QtWebComboBox.cpp +++ b/Source/WebKitLegacy/qt/WidgetSupport/QtWebComboBox.cpp @@ -48,7 +48,7 @@ bool QtWebComboBox::eventFilter(QObject* watched, QEvent* event) { Q_ASSERT(watched == view()); if (event->type() == QEvent::Hide) - emit didHide(); + Q_EMIT didHide(); return false; } diff --git a/Source/WebKitLegacy/qt/declarative/CMakeLists.txt b/Source/WebKitLegacy/qt/declarative/CMakeLists.txt index acbb53c7aca56..957ba75c12db3 100644 --- a/Source/WebKitLegacy/qt/declarative/CMakeLists.txt +++ b/Source/WebKitLegacy/qt/declarative/CMakeLists.txt @@ -15,13 +15,13 @@ include_directories( ) include_directories(SYSTEM ${ICU_INCLUDE_DIRS} - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5Quick_PRIVATE_INCLUDE_DIRS} + ${Qt6Quick_INCLUDE_DIRS} + ${Qt6Quick_PRIVATE_INCLUDE_DIRS} ) add_library(qmlwebkitplugin MODULE plugin.cpp) target_link_libraries(qmlwebkitplugin - WebKit Qt5::Quick) + WebKit Qt6::Quick) set(qmlwebkit_output_dir "${CMAKE_BINARY_DIR}/imports/QtWebKit") set(qmlwebkit_install_dir "${QML_INSTALL_DIR}/QtWebKit") diff --git a/Source/WebKitLegacy/qt/declarative/experimental/CMakeLists.txt b/Source/WebKitLegacy/qt/declarative/experimental/CMakeLists.txt index c2b0efad9262e..02e31acddbfd3 100644 --- a/Source/WebKitLegacy/qt/declarative/experimental/CMakeLists.txt +++ b/Source/WebKitLegacy/qt/declarative/experimental/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(qmlwebkitexperimentalplugin MODULE plugin.cpp) target_link_libraries(qmlwebkitexperimentalplugin - WebKit Qt5::Quick) + WebKit Qt6::Quick) set(qmlwebkitexperimental_output_dir "${CMAKE_BINARY_DIR}/imports/QtWebKit/experimental") set(qmlwebkitexperimental_install_dir "${QML_INSTALL_DIR}/QtWebKit/experimental") diff --git a/Source/WebKitLegacy/qt/tests/CMakeLists.txt b/Source/WebKitLegacy/qt/tests/CMakeLists.txt index 66079eed2d928..cbf9cd2b87ce4 100644 --- a/Source/WebKitLegacy/qt/tests/CMakeLists.txt +++ b/Source/WebKitLegacy/qt/tests/CMakeLists.txt @@ -7,10 +7,10 @@ if (ENABLE_TEST_SUPPORT) endif () set(QtWK1ApiTests_LIBRARIES - ${Qt5Gui_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${Qt5Test_LIBRARIES} - ${Qt5Widgets_LIBRARIES} + ${Qt6Gui_LIBRARIES} + ${Qt6Network_LIBRARIES} + ${Qt6Test_LIBRARIES} + ${Qt6Widgets_LIBRARIES} WebKitWidgets ) @@ -34,12 +34,12 @@ set(QtWK1ApiTests ) set(tst_hybridPixmap_SOURCES hybridPixmap/widget.cpp) -qt5_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui) +qt_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui) foreach (testName ${QtWK1ApiTests}) list(APPEND tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}/tst_${testName}.qrc") - qt5_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) + qt_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) endif () add_executable(tst_${testName} ${tst_${testName}_SOURCES}) @@ -52,7 +52,7 @@ foreach (testName ${QtWK1ApiTests}) ) target_include_directories(tst_${testName} SYSTEM PRIVATE - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} ) target_link_libraries(tst_${testName} ${QtWK1ApiTests_LIBRARIES}) diff --git a/Source/cmake/ECMGeneratePkgConfigFile.cmake b/Source/cmake/ECMGeneratePkgConfigFile.cmake index 09d7e2b476d27..776d8c870d494 100644 --- a/Source/cmake/ECMGeneratePkgConfigFile.cmake +++ b/Source/cmake/ECMGeneratePkgConfigFile.cmake @@ -65,7 +65,7 @@ # # ecm_generate_pkgconfig_file( # BASE_NAME KF5Archive -# DEPS Qt5Core +# DEPS Qt6Core # FILENAME_VAR pkgconfig_filename # INSTALL # ) diff --git a/Source/cmake/ECMGeneratePriFile.cmake b/Source/cmake/ECMGeneratePriFile.cmake index d74eabc708f5d..f0f598d1f4f64 100644 --- a/Source/cmake/ECMGeneratePriFile.cmake +++ b/Source/cmake/ECMGeneratePriFile.cmake @@ -9,7 +9,7 @@ # This assumes Qt and the current project are both installed to the same # non-system prefix. Packagers who use ``-DCMAKE_INSTALL_PREFIX=/usr`` will # certainly want to set ``ECM_MKSPECS_INSTALL_DIR`` to something like -# ``share/qt5/mkspecs/modules``. +# ``share/Qt6/mkspecs/modules``. # # The main thing is that this should be the ``modules`` subdirectory of either # the default qmake ``mkspecs`` directory or of a directory that will be in the diff --git a/Source/cmake/ECMQueryQmake.cmake b/Source/cmake/ECMQueryQmake.cmake index 8f4cf177ac418..1db845760f569 100644 --- a/Source/cmake/ECMQueryQmake.cmake +++ b/Source/cmake/ECMQueryQmake.cmake @@ -1,11 +1,11 @@ -find_package(Qt5Core QUIET) +find_package(Qt6 REQUIRED COMPONENTS Core QUIET) -set(_qmake_executable_default "qmake-qt5") -if (TARGET Qt5::qmake) - get_target_property(_qmake_executable_default Qt5::qmake LOCATION) +set(_qmake_executable_default "qmake-Qt6") +if (TARGET Qt6::qmake) + get_target_property(_qmake_executable_default Qt6::qmake LOCATION) endif() set(QMAKE_EXECUTABLE ${_qmake_executable_default} - CACHE FILEPATH "Location of the Qt5 qmake executable") + CACHE FILEPATH "Location of the Qt6 qmake executable") # This is not public API (yet)! function(query_qmake result_variable qt_variable) diff --git a/Source/cmake/KDEInstallDirs.cmake b/Source/cmake/KDEInstallDirs.cmake index 2834c1842ca8d..a1e29b698f142 100644 --- a/Source/cmake/KDEInstallDirs.cmake +++ b/Source/cmake/KDEInstallDirs.cmake @@ -460,12 +460,6 @@ if(KDE_INSTALL_USE_QT_SYS_PATHS) "Qt plugins" QT_PLUGIN_INSTALL_DIR) - query_qmake(qt_imports_dir QT_INSTALL_IMPORTS) - - _define_absolute(QTQUICKIMPORTSDIR ${qt_imports_dir} - "QtQuick1 imports" - IMPORTS_INSTALL_DIR) - query_qmake(qt_qml_dir QT_INSTALL_QML) _define_absolute(QMLDIR ${qt_qml_dir} @@ -476,10 +470,6 @@ else() "Qt plugins" QT_PLUGIN_INSTALL_DIR) - _define_relative(QTQUICKIMPORTSDIR QTPLUGINDIR "imports" - "QtQuick1 imports" - IMPORTS_INSTALL_DIR) - _define_relative(QMLDIR LIBDIR "qml" "QtQuick2 imports" QML_INSTALL_DIR) diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index 36ce5cf89b552..d63595d996954 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -5,7 +5,7 @@ include(ECMPackageConfigHelpers) set(ECM_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR}) -set(PROJECT_VERSION_MAJOR 5) +set(PROJECT_VERSION_MAJOR 6) set(PROJECT_VERSION_MINOR 212) set(PROJECT_VERSION_PATCH 0) set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) @@ -59,8 +59,8 @@ if (EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE}) endif () macro(CONVERT_PRL_LIBS_TO_CMAKE _qt_component) - if (TARGET Qt5::${_qt_component}) - get_target_property(_lib_location Qt5::${_qt_component} LOCATION) + if (TARGET Qt6::${_qt_component}) + get_target_property(_lib_location Qt6::${_qt_component} LOCATION) execute_process(COMMAND ${PERL_EXECUTABLE} ${TOOLS_DIR}/qt/convert-prl-libs-to-cmake.pl --lib ${_lib_location} --out ${STATIC_DEPENDENCIES_CMAKE_FILE} @@ -70,27 +70,27 @@ macro(CONVERT_PRL_LIBS_TO_CMAKE _qt_component) endif () endmacro() -macro(CHECK_QT5_PRIVATE_INCLUDE_DIRS _qt_component _header) +macro(CHECK_Qt6_PRIVATE_INCLUDE_DIRS _qt_component _header) set(INCLUDE_TEST_SOURCE " #include <${_header}> int main() { return 0; } " ) - set(CMAKE_REQUIRED_INCLUDES ${Qt5${_qt_component}_PRIVATE_INCLUDE_DIRS}) - set(CMAKE_REQUIRED_LIBRARIES Qt5::${_qt_component}) + set(CMAKE_REQUIRED_INCLUDES ${Qt6${_qt_component}_PRIVATE_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES Qt6::${_qt_component}) # Avoid check_include_file_cxx() because it performs linking but doesn't support CMAKE_REQUIRED_LIBRARIES (doh!) - check_cxx_source_compiles("${INCLUDE_TEST_SOURCE}" Qt5${_qt_component}_PRIVATE_HEADER_FOUND) + check_cxx_source_compiles("${INCLUDE_TEST_SOURCE}" Qt6${_qt_component}_PRIVATE_HEADER_FOUND) unset(INCLUDE_TEST_SOURCE) unset(CMAKE_REQUIRED_INCLUDES) unset(CMAKE_REQUIRED_LIBRARIES) - if (NOT Qt5${_qt_component}_PRIVATE_HEADER_FOUND) + if (NOT Qt6${_qt_component}_PRIVATE_HEADER_FOUND) message(FATAL_ERROR "Header ${_header} is not found. Please make sure that: - 1. Private headers of Qt5${_qt_component} are installed - 2. Qt5${_qt_component}_PRIVATE_INCLUDE_DIRS is correctly defined in Qt5${_qt_component}Config.cmake") + 1. Private headers of Qt6${_qt_component} are installed + 2. Qt6${_qt_component}_PRIVATE_INCLUDE_DIRS is correctly defined in Qt6${_qt_component}Config.cmake") endif () endmacro() @@ -118,7 +118,7 @@ macro(QTWEBKIT_GENERATE_MOC_FILES_CPP _target) endif () get_filename_component(_name_we ${_file} NAME_WE) set(_moc_name "${CMAKE_CURRENT_BINARY_DIR}/${_name_we}.moc") - qt5_generate_moc(${_file} ${_moc_name} TARGET ${_target}) + qt_generate_moc(${_file} ${_moc_name} TARGET ${_target}) WEBKIT_ADD_SOURCE_DEPENDENCIES(${_file} ${_moc_name}) endforeach () endmacro() @@ -131,7 +131,7 @@ macro(QTWEBKIT_GENERATE_MOC_FILE_H _target _header _source) endif () get_filename_component(_name_we ${_header} NAME_WE) set(_moc_name "${CMAKE_CURRENT_BINARY_DIR}/moc_${_name_we}.cpp") - qt5_generate_moc(${_header} ${_moc_name} TARGET ${_target}) + qt_generate_moc(${_header} ${_moc_name} TARGET ${_target}) WEBKIT_ADD_SOURCE_DEPENDENCIES(${_source} ${_moc_name}) endmacro() @@ -183,6 +183,8 @@ add_definitions(-DQT_USE_QSTRINGBUILDER) add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS) add_definitions(-DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000) add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) +add_definitions(-DQT_NO_KEYWORDS) +add_definitions(-DQT_NO_BEARERMANAGEMENT) # We use -fno-rtti with GCC and Clang, see OptionsCommon.cmake if (COMPILER_IS_GCC_OR_CLANG) @@ -240,10 +242,30 @@ if (WIN32) endif () # FIXME: Move Qt handling here -set(REQUIRED_QT_VERSION 5.2.0) -find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui QUIET) - -get_target_property(QT_CORE_TYPE Qt5::Core TYPE) +set(REQUIRED_QT_VERSION 6.0.0) + +## Qt 6 : Qt's cmake file don't seem to locate OpenGL on my system +find_package(OpenGL) +add_library(OpenGL::GL INTERFACE IMPORTED) +set_target_properties(OpenGL::GL PROPERTIES + IMPORTED_LOCATION "${OPENGL_LIBRARIES}") + +find_package(Qt6 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Core5Compat) +message("OPENGL_FOUND: ${OPENGL_FOUND}") +message("OPENGL_GLU_FOUND: ${OPENGL_GLU_FOUND}") +message("OpenGL_OpenGL_FOUND: ${OpenGL_OpenGL_FOUND}") +message("OpenGL_GLX_FOUND: ${OpenGL_GLX_FOUND}") +message("OPENGL_XMESA_FOUND: ${OPENGL_XMESA_FOUND}") +message("OpenGL_EGL_FOUND: ${OpenGL_EGL_FOUND}") +message("OPENGL_opengl_LIBRARY: ${OPENGL_opengl_LIBRARY}") +message("OPENGL_gl_LIBRARY: ${OPENGL_gl_LIBRARY}") +message("OPENGL_glx_LIBRARY: ${OPENGL_glx_LIBRARY}") +message("OPENGL_INCLUDE_DIR: ${OPENGL_INCLUDE_DIR}") +message("OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}") +include(CMakePrintHelpers) +cmake_print_properties(TARGETS OpenGL::GL PROPERTIES IMPORTED_LOCATION) + +get_target_property(QT_CORE_TYPE Qt6::Core TYPE) if (QT_CORE_TYPE MATCHES STATIC) set(QT_STATIC_BUILD ON) set(SHARED_CORE OFF) @@ -263,7 +285,7 @@ else () set(ENABLE_WEBKIT_DEFAULT ON) endif () -if (UNIX AND TARGET Qt5::QXcbIntegrationPlugin AND NOT APPLE) +if (UNIX AND TARGET Qt6::QXcbIntegrationPlugin AND NOT APPLE) set(ENABLE_X11_TARGET_DEFAULT ON) else () set(ENABLE_X11_TARGET_DEFAULT OFF) @@ -506,6 +528,12 @@ if (ENABLE_API_TESTS OR ENABLE_TEST_SUPPORT) endif () endif () +if (ENABLE_WEBKIT_LEGACY) + list(APPEND QT_REQUIRED_COMPONENTS + StateMachine + ) +endif () + if (ENABLE_GEOLOCATION) list(APPEND QT_REQUIRED_COMPONENTS Positioning) SET_AND_EXPOSE_TO_BUILD(HAVE_QTPOSITIONING 1) @@ -516,10 +544,14 @@ if (ENABLE_DEVICE_ORIENTATION) SET_AND_EXPOSE_TO_BUILD(HAVE_QTSENSORS 1) endif () +# Qt6 : QOpenGLWidget is now in its separate library +# It seem to be required even when building with ENABLE_OPENGL=OFF +list(APPEND QT_REQUIRED_COMPONENTS OpenGLWidgets) + if (ENABLE_OPENGL) # Note: Gui module is already found # Warning: quotes are sinificant here! - if (NOT DEFINED Qt5Gui_OPENGL_IMPLEMENTATION OR "${Qt5Gui_OPENGL_IMPLEMENTATION}" STREQUAL "") + if (NOT DEFINED Qt6Gui_OPENGL_IMPLEMENTATION OR "${Qt6Gui_OPENGL_IMPLEMENTATION}" STREQUAL "") message(FATAL_ERROR "Qt with OpenGL support is required for ENABLE_OPENGL") endif () @@ -528,19 +560,19 @@ if (ENABLE_OPENGL) if (WIN32) include(CheckCXXSymbolExists) - set(CMAKE_REQUIRED_INCLUDES ${Qt5Gui_INCLUDE_DIRS}) - set(CMAKE_REQUIRED_FLAGS ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}) + set(CMAKE_REQUIRED_INCLUDES ${Qt6Gui_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_FLAGS ${Qt6Gui_EXECUTABLE_COMPILE_FLAGS}) check_cxx_symbol_exists(QT_OPENGL_DYNAMIC qopenglcontext.h HAVE_QT_OPENGL_DYNAMIC) if (HAVE_QT_OPENGL_DYNAMIC) - set(Qt5Gui_OPENGL_IMPLEMENTATION DynamicGL) + set(Qt6Gui_OPENGL_IMPLEMENTATION DynamicGL) endif () unset(CMAKE_REQUIRED_INCLUDES) unset(CMAKE_REQUIRED_FLAGS) endif () - message(STATUS "Qt OpenGL implementation: ${Qt5Gui_OPENGL_IMPLEMENTATION}") - message(STATUS "Qt OpenGL libraries: ${Qt5Gui_OPENGL_LIBRARIES}") - message(STATUS "Qt EGL libraries: ${Qt5Gui_EGL_LIBRARIES}") + message(STATUS "Qt OpenGL implementation: ${Qt6Gui_OPENGL_IMPLEMENTATION}") + message(STATUS "Qt OpenGL libraries: ${Qt6Gui_OPENGL_LIBRARIES}") + message(STATUS "Qt EGL libraries: ${Qt6Gui_EGL_LIBRARIES}") endif () if (ENABLE_PRINT_SUPPORT) @@ -575,14 +607,14 @@ else () set(WebKit_LIBRARY_TYPE STATIC) endif () -find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS ${QT_REQUIRED_COMPONENTS}) +find_package(Qt6 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS ${QT_REQUIRED_COMPONENTS}) -CHECK_QT5_PRIVATE_INCLUDE_DIRS(Gui private/qhexstring_p.h) -if (Qt5_VERSION VERSION_GREATER 5.10.1) - CHECK_QT5_PRIVATE_INCLUDE_DIRS(Network private/http2protocol_p.h) +CHECK_Qt6_PRIVATE_INCLUDE_DIRS(Gui private/qhexstring_p.h) +if (Qt6_VERSION VERSION_GREATER 5.10.1) + CHECK_Qt6_PRIVATE_INCLUDE_DIRS(Network private/http2protocol_p.h) endif () if (ENABLE_WEBKIT) - CHECK_QT5_PRIVATE_INCLUDE_DIRS(Quick private/qsgrendernode_p.h) + CHECK_Qt6_PRIVATE_INCLUDE_DIRS(Quick private/qsgrendernode_p.h) endif () if (QT_STATIC_BUILD) @@ -591,11 +623,11 @@ if (QT_STATIC_BUILD) endforeach () # HACK: We must explicitly add LIB path of the Qt installation # to correctly find qtpcre - link_directories(${_qt5_install_prefix}/../) + link_directories(${_Qt6_install_prefix}/../) endif () foreach (qt_module ${QT_OPTIONAL_COMPONENTS}) - find_package("Qt5${qt_module}" ${REQUIRED_QT_VERSION} PATHS ${_qt5_install_prefix} NO_DEFAULT_PATH) + find_package("Qt6${qt_module}" ${REQUIRED_QT_VERSION} PATHS ${_Qt6_install_prefix} NO_DEFAULT_PATH) if (QT_STATIC_BUILD) CONVERT_PRL_LIBS_TO_CMAKE(${qt_module}) endif () @@ -610,7 +642,7 @@ if (QT_STATIC_BUILD) endif () if (COMPILER_IS_GCC_OR_CLANG AND UNIX) - if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android" OR ${Qt5_VERSION} VERSION_LESS 5.6) + if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android" OR ${Qt6_VERSION} VERSION_LESS 5.6) set(USE_LINKER_VERSION_SCRIPT_DEFAULT OFF) else () set(USE_LINKER_VERSION_SCRIPT_DEFAULT ON) @@ -720,9 +752,9 @@ if (NOT ENABLE_VIDEO) endif () if (USE_QT_MULTIMEDIA) - find_package(Qt5Multimedia ${REQUIRED_QT_VERSION} REQUIRED PATHS ${_qt5_install_prefix} NO_DEFAULT_PATH) + find_package(Qt6Multimedia ${REQUIRED_QT_VERSION} REQUIRED PATHS ${_Qt6_install_prefix} NO_DEFAULT_PATH) # FIXME: Allow building w/o widgets - find_package(Qt5MultimediaWidgets ${REQUIRED_QT_VERSION} REQUIRED PATHS ${_qt5_install_prefix} NO_DEFAULT_PATH) + find_package(Qt6MultimediaWidgets ${REQUIRED_QT_VERSION} REQUIRED PATHS ${_Qt6_install_prefix} NO_DEFAULT_PATH) endif () if (ENABLE_WEB_CRYPTO) @@ -900,7 +932,7 @@ if (NOT RUBY_FOUND AND RUBY_EXECUTABLE AND NOT RUBY_VERSION VERSION_LESS 1.9) endif () set_package_properties(Ruby PROPERTIES TYPE REQUIRED) -set_package_properties(Qt5PrintSupport PROPERTIES PURPOSE "Required for ENABLE_PRINT_SUPPORT=ON") +set_package_properties(Qt6PrintSupport PROPERTIES PURPOSE "Required for ENABLE_PRINT_SUPPORT=ON") feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake index 12bed350a4657..464b9853ed96d 100644 --- a/Source/cmake/OptionsWPE.cmake +++ b/Source/cmake/OptionsWPE.cmake @@ -100,6 +100,7 @@ WEBKIT_OPTION_DEFINE(USE_LCMS "Whether to enable support for image color managem WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON) WEBKIT_OPTION_DEFINE(USE_SOUP2 "Whether to enable usage of Soup 2 instead of Soup 3." PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON) +WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt6/QML plugin" PUBLIC OFF) # Private options specific to the WPE port. WEBKIT_OPTION_DEFINE(USE_GSTREAMER_HOLEPUNCH "Whether to enable GStreamer holepunch" PRIVATE OFF) @@ -259,8 +260,8 @@ if (ENABLE_XSLT) endif () if (ENABLE_WPE_QT_API) - find_package(Qt5 REQUIRED COMPONENTS Core Quick Gui) - find_package(Qt5Test REQUIRED) + find_package(Qt6 REQUIRED COMPONENTS Core Quick Gui) + find_package(Qt6Test REQUIRED) endif () if (ENABLE_WPE_QT_API OR USE_WPE_VIDEO_PLANE_DISPLAY_DMABUF) diff --git a/Tools/DumpRenderTree/PlatformQt.cmake b/Tools/DumpRenderTree/PlatformQt.cmake index 045865e3d82f7..c9c289ab7dc78 100644 --- a/Tools/DumpRenderTree/PlatformQt.cmake +++ b/Tools/DumpRenderTree/PlatformQt.cmake @@ -23,20 +23,20 @@ list(APPEND DumpRenderTree_SOURCES qt/UIScriptControllerQt.cpp ) -qt5_add_resources(DumpRenderTree_SOURCES +Qt6_add_resources(DumpRenderTree_SOURCES qt/DumpRenderTree.qrc ) list(APPEND DumpRenderTree_SYSTEM_INCLUDE_DIRECTORIES ${ICU_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6Widgets_INCLUDE_DIRS} ) list(APPEND DumpRenderTree_LIBRARIES - ${Qt5PrintSupport_LIBRARIES} - ${Qt5Test_LIBRARIES} - ${Qt5Widgets_LIBRARIES} + ${Qt6PrintSupport_LIBRARIES} + ${Qt6Test_LIBRARIES} + ${Qt6Widgets_LIBRARIES} WebKitWidgets ) @@ -47,10 +47,10 @@ list(APPEND DumpRenderTree_FRAMEWORKS if (USE_QT_MULTIMEDIA) list(APPEND DumpRenderTree_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Multimedia_INCLUDE_DIRS} + ${Qt6Multimedia_INCLUDE_DIRS} ) list(APPEND DumpRenderTree_LIBRARIES - ${Qt5Multimedia_LIBRARIES} + ${Qt6Multimedia_LIBRARIES} ) endif () diff --git a/Tools/ImageDiff/PlatformQt.cmake b/Tools/ImageDiff/PlatformQt.cmake index 377d898cd0f8f..96c403d3cd945 100644 --- a/Tools/ImageDiff/PlatformQt.cmake +++ b/Tools/ImageDiff/PlatformQt.cmake @@ -3,9 +3,9 @@ set(ImageDiff_SOURCES ) list(APPEND ImageDiff_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Gui_INCLUDE_DIRS} + ${Qt6Gui_INCLUDE_DIRS} ) set(ImageDiff_LIBRARIES - ${Qt5Gui_LIBRARIES} + ${Qt6Gui_LIBRARIES} ) diff --git a/Tools/MiniBrowser/qt/BrowserWindow.cpp b/Tools/MiniBrowser/qt/BrowserWindow.cpp index 8472d5cfd0c3a..2c3d846d38a0a 100644 --- a/Tools/MiniBrowser/qt/BrowserWindow.cpp +++ b/Tools/MiniBrowser/qt/BrowserWindow.cpp @@ -116,17 +116,17 @@ BrowserWindow* BrowserWindow::newWindow(const QString& url) return window; } -void BrowserWindow::updateVisualMockTouchPoints(const QList& touchPoints) +void BrowserWindow::updateVisualMockTouchPoints(const QList& touchPoints) { if (touchPoints.isEmpty()) { // Hide all touch indicator items. - foreach (QQuickItem* item, m_activeMockComponents.values()) + Q_FOREACH (QQuickItem* item, m_activeMockComponents.values()) item->setProperty("pressed", false); return; } - foreach (const QTouchEvent::TouchPoint& touchPoint, touchPoints) { + Q_FOREACH (const QEventPoint& touchPoint, touchPoints) { QQuickItem* mockTouchPointItem = m_activeMockComponents.value(touchPoint.id()); if (!mockTouchPointItem) { @@ -139,12 +139,11 @@ void BrowserWindow::updateVisualMockTouchPoints(const QListsetParentItem(rootObject()); } - QRectF touchRect = touchPoint.rect(); - mockTouchPointItem->setX(touchRect.center().x()); - mockTouchPointItem->setY(touchRect.center().y()); - mockTouchPointItem->setWidth(touchRect.width()); - mockTouchPointItem->setHeight(touchRect.height()); - mockTouchPointItem->setProperty("pressed", QVariant(touchPoint.state() != Qt::TouchPointReleased)); + mockTouchPointItem->setX(touchPoint.position().x()); + mockTouchPointItem->setY(touchPoint.position().y()); + mockTouchPointItem->setWidth(touchPoint.ellipseDiameters().width()); + mockTouchPointItem->setHeight(touchPoint.ellipseDiameters().height()); + mockTouchPointItem->setProperty("pressed", QVariant(touchPoint.state() != QEventPoint::Released)); } } @@ -197,8 +196,8 @@ void BrowserWindow::keyPressEvent(QKeyEvent* event) void BrowserWindow::wheelEvent(QWheelEvent* event) { - if (event->modifiers() & Qt::ControlModifier && event->orientation() == Qt::Vertical) { - if (event->delta() > 0) + if (event->modifiers() & Qt::ControlModifier && qAbs(event->angleDelta().y()) > 0) { + if (event->angleDelta().y() > 0) zoomIn(); else zoomOut(); diff --git a/Tools/MiniBrowser/qt/BrowserWindow.h b/Tools/MiniBrowser/qt/BrowserWindow.h index 2ecfc1453a328..f6a4a4bc516f9 100644 --- a/Tools/MiniBrowser/qt/BrowserWindow.h +++ b/Tools/MiniBrowser/qt/BrowserWindow.h @@ -49,7 +49,7 @@ class BrowserWindow : public QQuickView { QQuickWebView* webView() const; QQuickWebViewExperimental* webViewExperimental() const; - void updateVisualMockTouchPoints(const QList& touchPoints); + void updateVisualMockTouchPoints(const QList& touchPoints); public Q_SLOTS: BrowserWindow* newWindow(const QString& url = "about:blank"); diff --git a/Tools/MiniBrowser/qt/CMakeLists.txt b/Tools/MiniBrowser/qt/CMakeLists.txt index 68dd13c8b703a..9d3eb6606d022 100644 --- a/Tools/MiniBrowser/qt/CMakeLists.txt +++ b/Tools/MiniBrowser/qt/CMakeLists.txt @@ -39,18 +39,18 @@ set(MiniBrowser_SOURCES ${MiniBrowser_QML_SOURCES} ) -qt5_add_resources(MiniBrowser_SOURCES +qt_add_resources(MiniBrowser_SOURCES MiniBrowser.qrc ) set(MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5Quick_PRIVATE_INCLUDE_DIRS} + ${Qt6Quick_INCLUDE_DIRS} + ${Qt6Quick_PRIVATE_INCLUDE_DIRS} ) set(MiniBrowser_LIBRARIES WebKit - ${Qt5Quick_LIBRARIES} + ${Qt6Quick_LIBRARIES} ) if (SHARED_CORE) diff --git a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp index f36621922291b..34066f5364e04 100644 --- a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp +++ b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp @@ -37,18 +37,11 @@ #endif #include "private/qquickwebview_p.h" #include "utils.h" -#include +#include #include #include #include -static inline QRectF touchRectForPosition(QPointF centerPoint) -{ - QRectF touchRect(0, 0, 40, 40); - touchRect.moveCenter(centerPoint); - return touchRect; -} - static inline bool isTouchEvent(const QEvent* event) { switch (event->type()) { @@ -133,12 +126,12 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) } if (event->type() == QEvent::KeyRelease && static_cast(event)->key() == Qt::Key_Control) { - foreach (int id, m_heldTouchPoints) + Q_FOREACH (int id, m_heldTouchPoints) if (m_touchPoints.contains(id) && !QGuiApplication::mouseButtons().testFlag(Qt::MouseButton(id))) { - m_touchPoints[id].setState(Qt::TouchPointReleased); + m_touchPoints[id].setState(QEventPoint::Released); m_heldTouchPoints.remove(id); } else - m_touchPoints[id].setState(Qt::TouchPointStationary); + m_touchPoints[id].setState(QEventPoint::Stationary); sendTouchEvent(browserWindow, m_heldTouchPoints.isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate, static_cast(event)->timestamp()); } @@ -146,7 +139,7 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) if (isMouseEvent(event)) { const QMouseEvent* const mouseEvent = static_cast(event); - QTouchEvent::TouchPoint touchPoint; + QMutableEventPoint touchPoint; touchPoint.setPressure(1); QEvent::Type touchType = QEvent::None; @@ -155,10 +148,10 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) case QEvent::MouseButtonPress: touchPoint.setId(mouseEvent->button()); if (m_touchPoints.contains(touchPoint.id())) { - touchPoint.setState(Qt::TouchPointMoved); + touchPoint.setState(QEventPoint::Updated); touchType = QEvent::TouchUpdate; } else { - touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setState(QEventPoint::Pressed); // Check if more buttons are held down than just the event triggering one. if (mouseEvent->buttons() > mouseEvent->button()) touchType = QEvent::TouchUpdate; @@ -177,7 +170,7 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) } touchType = QEvent::TouchUpdate; touchPoint.setId(mouseEvent->buttons()); - touchPoint.setState(Qt::TouchPointMoved); + touchPoint.setState(QEventPoint::Updated); break; case QEvent::MouseButtonRelease: // Check if any buttons are still held down after this event. @@ -186,7 +179,7 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) else touchType = QEvent::TouchEnd; touchPoint.setId(mouseEvent->button()); - touchPoint.setState(Qt::TouchPointReleased); + touchPoint.setState(QEventPoint::Released); break; case QEvent::MouseButtonDblClick: // Eat double-clicks, their accompanying press event is all we need. @@ -199,12 +192,12 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) // A move can have resulted in multiple buttons, so we need check them individually. if (touchPoint.id() & Qt::LeftButton) updateTouchPoint(mouseEvent, touchPoint, Qt::LeftButton); - if (touchPoint.id() & Qt::MidButton) - updateTouchPoint(mouseEvent, touchPoint, Qt::MidButton); + if (touchPoint.id() & Qt::MiddleButton) + updateTouchPoint(mouseEvent, touchPoint, Qt::MiddleButton); if (touchPoint.id() & Qt::RightButton) updateTouchPoint(mouseEvent, touchPoint, Qt::RightButton); - if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) { + if (m_holdingControl && touchPoint.state() == QEventPoint::Released) { // We avoid sending the release event because the Flickable is // listening to mouse events and would start a bounce-back // animation if it received a mouse release. @@ -213,9 +206,9 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) } // Update states for all other touch-points - for (QHash::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) { + for (QHash::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) { if (!(it.value().id() & touchPoint.id())) - it.value().setState(Qt::TouchPointStationary); + it.value().setState(QEventPoint::Stationary); } Q_ASSERT(touchType != QEvent::None); @@ -230,14 +223,14 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) return QGuiApplication::notify(target, event); } -void MiniBrowserApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QTouchEvent::TouchPoint touchPoint, Qt::MouseButton mouseButton) +void MiniBrowserApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QMutableEventPoint touchPoint, Qt::MouseButton mouseButton) { // Ignore inserting additional touch points if Ctrl isn't held because it produces // inconsistent touch events and results in assers in the gesture recognizers. if (!m_holdingControl && m_touchPoints.size() && !m_touchPoints.contains(mouseButton)) return; - if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) { + if (m_holdingControl && touchPoint.state() == QEventPoint::Released) { m_heldTouchPoints.insert(mouseButton); return; } @@ -246,16 +239,16 @@ void MiniBrowserApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QTo // but since the canvas translates touch events we actually need to pass // the screen position as the scene position to deliver the appropriate // coordinates to the target. - touchPoint.setRect(touchRectForPosition(mouseEvent->localPos())); - touchPoint.setSceneRect(touchRectForPosition(mouseEvent->screenPos())); + touchPoint.setPosition(mouseEvent->localPos()); + touchPoint.setScenePosition(mouseEvent->screenPos()); + touchPoint.setEllipseDiameters({40, 40}); - if (touchPoint.state() == Qt::TouchPointPressed) - touchPoint.setStartScenePos(mouseEvent->screenPos()); + if (touchPoint.state() == QEventPoint::Pressed) + touchPoint.setGlobalPressPosition(mouseEvent->globalPosition()); else { - const QTouchEvent::TouchPoint& oldTouchPoint = m_touchPoints[mouseButton]; - touchPoint.setStartScenePos(oldTouchPoint.startScenePos()); - touchPoint.setLastPos(oldTouchPoint.pos()); - touchPoint.setLastScenePos(oldTouchPoint.scenePos()); + const QMutableEventPoint& oldTouchPoint = m_touchPoints[mouseButton]; + touchPoint.setGlobalPressPosition(oldTouchPoint.globalPressPosition()); + touchPoint.setGlobalLastPosition(oldTouchPoint.globalPosition()); } // Update current touch-point. @@ -266,19 +259,21 @@ void MiniBrowserApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QTo bool MiniBrowserApplication::sendTouchEvent(BrowserWindow* browserWindow, QEvent::Type type, ulong timestamp) { - static QTouchDevice* device = 0; + static QPointingDevice* device = nullptr; if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); + device = new QPointingDevice; + device->setType(QInputDevice::DeviceType::TouchScreen); + QWindowSystemInterface::registerInputDevice(device); } m_pendingFakeTouchEventCount++; - const QList& currentTouchPoints = m_touchPoints.values(); - Qt::TouchPointStates touchPointStates = 0; - foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) + QList currentTouchPoints; + QEventPoint::States touchPointStates{}; + Q_FOREACH (const QMutableEventPoint& touchPoint, m_touchPoints.values()) { + currentTouchPoints.append(touchPoint); touchPointStates |= touchPoint.state(); + } QTouchEvent event(type, device, Qt::NoModifier, touchPointStates, currentTouchPoints); event.setTimestamp(timestamp); @@ -287,11 +282,11 @@ bool MiniBrowserApplication::sendTouchEvent(BrowserWindow* browserWindow, QEvent QGuiApplication::notify(browserWindow, &event); if (QQuickWebViewExperimental::flickableViewportEnabled()) - browserWindow->updateVisualMockTouchPoints(m_holdingControl ? currentTouchPoints : QList()); + browserWindow->updateVisualMockTouchPoints(m_holdingControl ? currentTouchPoints : QList()); // Get rid of touch-points that are no longer valid - foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) { - if (touchPoint.state() == Qt::TouchPointReleased) + Q_FOREACH (const QEventPoint& touchPoint, currentTouchPoints) { + if (touchPoint.state() == QEventPoint::Released) m_touchPoints.remove(touchPoint.id()); } @@ -344,7 +339,7 @@ void MiniBrowserApplication::handleUserOptions() if (args.contains("--window-size")) { QString value = takeOptionValue(&args, "--window-size"); - QStringList list = value.split(QRegExp("\\D+"), QString::SkipEmptyParts); + QStringList list = value.split(QRegularExpression("\\D+"), Qt::SkipEmptyParts); if (list.length() == 2) m_windowOptions.setRequestedWindowSize(QSize(list.at(0).toInt(), list.at(1).toInt())); } @@ -376,7 +371,7 @@ void MiniBrowserApplication::handleUserOptions() } else { int urlArg; - while ((urlArg = args.indexOf(QRegExp("^[^-].*"))) != -1) + while ((urlArg = args.indexOf(QRegularExpression("^[^-].*"))) != -1) m_urls += args.takeAt(urlArg); } diff --git a/Tools/MiniBrowser/qt/MiniBrowserApplication.h b/Tools/MiniBrowser/qt/MiniBrowserApplication.h index 3dc380aec4dfe..aed5caa18ae2a 100644 --- a/Tools/MiniBrowser/qt/MiniBrowserApplication.h +++ b/Tools/MiniBrowser/qt/MiniBrowserApplication.h @@ -37,6 +37,7 @@ #include #include #include +#include class BrowserWindow; @@ -71,7 +72,7 @@ class WindowOptions : public QObject { { if (enabled != m_touchMockingEnabled) { m_touchMockingEnabled = enabled; - emit touchMockingEnabledChanged(); + Q_EMIT touchMockingEnabledChanged(); } } @@ -101,7 +102,7 @@ class MiniBrowserApplication : public QGuiApplication { virtual bool notify(QObject*, QEvent*); private: - void updateTouchPoint(const QMouseEvent*, QTouchEvent::TouchPoint, Qt::MouseButton); + void updateTouchPoint(const QMouseEvent*, QMutableEventPoint, Qt::MouseButton); bool sendTouchEvent(BrowserWindow*, QEvent::Type, ulong timestamp); void handleUserOptions(); @@ -113,7 +114,7 @@ class MiniBrowserApplication : public QGuiApplication { int m_robotExtraTimeSeconds; QStringList m_urls; - QHash m_touchPoints; + QHash m_touchPoints; QSet m_heldTouchPoints; WindowOptions m_windowOptions; diff --git a/Tools/MiniBrowser/qt/UrlLoader.cpp b/Tools/MiniBrowser/qt/UrlLoader.cpp index a0658e983cd92..1b34d0e5aebdd 100644 --- a/Tools/MiniBrowser/qt/UrlLoader.cpp +++ b/Tools/MiniBrowser/qt/UrlLoader.cpp @@ -73,7 +73,7 @@ void UrlLoader::loadNext() if (getUrl(qstr)) { QUrl url(qstr, QUrl::StrictMode); if (url.isValid()) { - m_stdOut << "Loading " << qstr << " ......" << ++m_loaded << endl; + m_stdOut << "Loading " << qstr << " ......" << ++m_loaded << Qt::endl; m_browserWindow->load(url.toString()); } else loadNext(); @@ -84,7 +84,7 @@ void UrlLoader::loadNext() void UrlLoader::checkIfFinished() { if (!m_numFramesLoading) - emit pageLoadFinished(); + Q_EMIT pageLoadFinished(); } void UrlLoader::frameLoadStarted() @@ -135,13 +135,13 @@ void UrlLoader::loadingChanged(QWebLoadRequest* loadRequest) { switch (loadRequest->status()) { case QQuickWebView::LoadStartedStatus: - emit loadStarted(); + Q_EMIT loadStarted(); break; case QQuickWebView::LoadStoppedStatus: case QQuickWebView::LoadSucceededStatus: case QQuickWebView::LoadFailedStatus: default: - emit loadFinished(); + Q_EMIT loadFinished(); break; } } diff --git a/Tools/MiniBrowser/wpe/qt/CMakeLists.txt b/Tools/MiniBrowser/wpe/qt/CMakeLists.txt index 518684358211d..751514eb635f6 100644 --- a/Tools/MiniBrowser/wpe/qt/CMakeLists.txt +++ b/Tools/MiniBrowser/wpe/qt/CMakeLists.txt @@ -8,6 +8,6 @@ if (ENABLE_WPE_QT_API) endif () add_executable(qt-wpe-mini-browser "main.cpp" "qml.qrc") - target_link_libraries(qt-wpe-mini-browser Qt5::Core Qt5::Quick) + target_link_libraries(qt-wpe-mini-browser Qt6::Core Qt6::Quick) install(TARGETS qt-wpe-mini-browser DESTINATION "${LIBEXEC_INSTALL_DIR}") endif () diff --git a/Tools/QtTestBrowser/CMakeLists.txt b/Tools/QtTestBrowser/CMakeLists.txt index 1619dd4d5fd39..56a956d8ef3c5 100644 --- a/Tools/QtTestBrowser/CMakeLists.txt +++ b/Tools/QtTestBrowser/CMakeLists.txt @@ -35,30 +35,34 @@ if (NOT USE_SYSTEM_MALLOC) endif () set(QtTestBrowser_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Network_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} + ${Qt6Gui_INCLUDE_DIRS} + ${Qt6Network_INCLUDE_DIRS} + ${Qt6Widgets_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6StateMachine_INCLUDE_DIRS} ) set(QtTestBrowser_LIBRARIES - ${Qt5Gui_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5PrintSupport_LIBRARIES} + ${Qt6Gui_LIBRARIES} + ${Qt6Network_LIBRARIES} + ${Qt6Widgets_LIBRARIES} + ${Qt6PrintSupport_LIBRARIES} + ${Qt6OpenGLWidgets_LIBRARIES} + ${Qt6StateMachine_LIBRARIES} WebKitWidgets ${STATIC_LIB_DEPENDENCIES} ) -qt5_add_resources(QtTestBrowser_SOURCES +qt_add_resources(QtTestBrowser_SOURCES QtTestBrowser.qrc ) -if (Qt5OpenGL_FOUND) +if (Qt6OpenGL_FOUND) list(APPEND QtTestBrowser_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5OpenGL_INCLUDE_DIRS} + ${Qt6OpenGL_INCLUDE_DIRS} ) list(APPEND QtTestBrowser_LIBRARIES - ${Qt5OpenGL_LIBRARIES} + ${Qt6OpenGL_LIBRARIES} ) endif () diff --git a/Tools/QtTestBrowser/cookiejar.cpp b/Tools/QtTestBrowser/cookiejar.cpp index 7ac51089273eb..1051898187219 100644 --- a/Tools/QtTestBrowser/cookiejar.cpp +++ b/Tools/QtTestBrowser/cookiejar.cpp @@ -92,7 +92,7 @@ void TestBrowserCookieJar::extractRawCookies() QList cookies = allCookies(); m_rawCookies.clear(); - foreach (const QNetworkCookie &cookie, cookies) { + Q_FOREACH (const QNetworkCookie &cookie, cookies) { if (!cookie.isSessionCookie()) m_rawCookies.append(cookie.toRawForm()); } @@ -104,7 +104,7 @@ void TestBrowserCookieJar::saveToDisk() if (m_file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream out(&m_file); - foreach (const QByteArray &cookie, m_rawCookies) + Q_FOREACH (const QByteArray &cookie, m_rawCookies) out << cookie + "\n"; m_file.close(); } else diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp index d3952c800726e..76ada57522b8d 100644 --- a/Tools/QtTestBrowser/launcherwindow.cpp +++ b/Tools/QtTestBrowser/launcherwindow.cpp @@ -38,6 +38,7 @@ #include "cookiejar.h" #include "urlloader.h" +#include #include #include #include @@ -170,14 +171,6 @@ void LauncherWindow::initializeView() } else { WebViewGraphicsBased* view = new WebViewGraphicsBased(splitter); m_view = view; -#ifndef QT_NO_OPENGL - if (!m_windowOptions.useQOpenGLWidgetViewport) - toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport); -#ifdef QT_OPENGL_LIB - if (!m_windowOptions.useQGLWidgetViewport) - toggleQOpenGLWidgetViewport(m_windowOptions.useQOpenGLWidgetViewport); -#endif // QT_OPENGL_LIB -#endif view->setPage(page()); connect(view, SIGNAL(currentFPSUpdated(int)), this, SLOT(updateFPS(int))); @@ -223,7 +216,7 @@ void LauncherWindow::applyPrefs() QWebSettings* settings = page()->settings(); #ifndef QT_NO_OPENGL settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, m_windowOptions.useCompositing - && (m_windowOptions.useQGLWidgetViewport || m_windowOptions.useQOpenGLWidgetViewport)); + && m_windowOptions.useQOpenGLWidgetViewport); #endif settings->setAttribute(QWebSettings::TiledBackingStoreEnabled, m_windowOptions.useTiledBackingStore); settings->setAttribute(QWebSettings::FrameFlatteningEnabled, m_windowOptions.useFrameFlattening); @@ -439,20 +432,11 @@ void LauncherWindow::createChrome() toggleTiledBackingStore->setEnabled(isGraphicsBased()); toggleTiledBackingStore->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool))); -#ifndef QT_NO_OPENGL - QAction* toggleQGLWidgetViewport = graphicsViewMenu->addAction("Toggle use of QGLWidget Viewport", this, SLOT(toggleQGLWidgetViewport(bool))); - toggleQGLWidgetViewport->setCheckable(true); - toggleQGLWidgetViewport->setChecked(m_windowOptions.useQGLWidgetViewport); - toggleQGLWidgetViewport->setEnabled(isGraphicsBased()); - toggleQGLWidgetViewport->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool))); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QAction* toggleQOpenGLWidgetViewport = graphicsViewMenu->addAction("Toggle use of QOpenGLWidget Viewport", this, SLOT(toggleQOpenGLWidgetViewport(bool))); toggleQOpenGLWidgetViewport->setCheckable(true); toggleQOpenGLWidgetViewport->setChecked(m_windowOptions.useQOpenGLWidgetViewport); toggleQOpenGLWidgetViewport->setEnabled(isGraphicsBased()); toggleQOpenGLWidgetViewport->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool))); -#endif -#endif QMenu* viewportUpdateMenu = graphicsViewMenu->addMenu("Change Viewport Update Mode"); viewportUpdateMenu->setEnabled(isGraphicsBased()); @@ -491,7 +475,7 @@ void LauncherWindow::createChrome() connect(boundingRectUpdate, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(noUpdate, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(changeViewportUpdateMode(int))); + connect(signalMapper, &QSignalMapper::mappedInt, this, &LauncherWindow::changeViewportUpdateMode); QActionGroup* viewportUpdateModeActions = new QActionGroup(viewportUpdateMenu); viewportUpdateModeActions->addAction(fullUpdate); @@ -600,7 +584,7 @@ void LauncherWindow::createChrome() connect(findWrapAround, SIGNAL(stateChanged(int)), findSignalMapper, SLOT(map())); connect(findHighLightAll, SIGNAL(stateChanged(int)), findSignalMapper, SLOT(map())); - connect(findSignalMapper, SIGNAL(mapped(int)), this, SLOT(find(int))); + connect(findSignalMapper, &QSignalMapper::mappedInt, this, &LauncherWindow::find); m_findBar->addWidget(findClose); m_findBar->addWidget(m_lineEdit); @@ -637,20 +621,25 @@ void LauncherWindow::sendTouchEvent() QEvent::Type type = QEvent::TouchUpdate; if (m_touchPoints.size() == 1) { - if (m_touchPoints[0].state() == Qt::TouchPointReleased) + if (m_touchPoints[0].state() == QEventPoint::Released) type = QEvent::TouchEnd; - else if (m_touchPoints[0].state() == Qt::TouchPointPressed) + else if (m_touchPoints[0].state() == QEventPoint::Pressed) type = QEvent::TouchBegin; } - QTouchEvent touchEv(type); - touchEv.setTouchPoints(m_touchPoints); + const QPointingDevice *device = nullptr; + Qt::KeyboardModifiers modifiers = Qt::NoModifier; + QList touchPoints; + for (const QMutableEventPoint & ep: m_touchPoints) { + touchPoints.append(ep); + } + QTouchEvent touchEv(type, device, modifiers, touchPoints); QCoreApplication::sendEvent(page(), &touchEv); // After sending the event, remove all touchpoints that were released - if (m_touchPoints[0].state() == Qt::TouchPointReleased) + if (m_touchPoints[0].state() == QEventPoint::Released) m_touchPoints.removeAt(0); - if (m_touchPoints.size() > 1 && m_touchPoints[1].state() == Qt::TouchPointReleased) + if (m_touchPoints.size() > 1 && m_touchPoints[1].state() == QEventPoint::Released) m_touchPoints.removeAt(1); } @@ -664,7 +653,7 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) && ev->pos().x() > (width() - gExitClickArea) && ev->pos().y() > (height() - gExitClickArea)) { - emit enteredFullScreenMode(false); + Q_EMIT enteredFullScreenMode(false); } } @@ -681,18 +670,17 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) && !(ev->buttons() & Qt::LeftButton)) return false; - QTouchEvent::TouchPoint touchPoint; - touchPoint.setState(Qt::TouchPointMoved); + int pointId = 0; + QEventPoint::State state = QEventPoint::Updated; if ((ev->type() == QEvent::MouseButtonPress || ev->type() == QEvent::MouseButtonDblClick)) - touchPoint.setState(Qt::TouchPointPressed); + state = QEventPoint::Pressed; else if (ev->type() == QEvent::MouseButtonRelease) - touchPoint.setState(Qt::TouchPointReleased); - - touchPoint.setId(0); - touchPoint.setScreenPos(ev->globalPos()); - touchPoint.setPos(ev->pos()); - touchPoint.setPressure(1); + state = QEventPoint::Released; + QPointF scenePosition = ev->scenePosition(); + QPointF globalPosition = ev->globalPosition(); + QMutableEventPoint touchPoint(pointId, state, scenePosition, globalPosition); + //touchPoint.setPressure(1); // If the point already exists, update it. Otherwise create it. if (m_touchPoints.size() > 0 && !m_touchPoints[0].id()) @@ -710,14 +698,14 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) // If the keyboard point is already pressed, release it. // Otherwise create it and append to m_touchPoints. if (m_touchPoints.size() > 0 && m_touchPoints[0].id() == 1) { - m_touchPoints[0].setState(Qt::TouchPointReleased); + m_touchPoints[0].setState(QEventPoint::Released); sendTouchEvent(); } else if (m_touchPoints.size() > 1 && m_touchPoints[1].id() == 1) { - m_touchPoints[1].setState(Qt::TouchPointReleased); + m_touchPoints[1].setState(QEventPoint::Released); sendTouchEvent(); } else { - QTouchEvent::TouchPoint touchPoint; - touchPoint.setState(Qt::TouchPointPressed); + QMutableEventPoint touchPoint; + touchPoint.setState(QEventPoint::Pressed); touchPoint.setId(1); touchPoint.setScreenPos(QCursor::pos()); touchPoint.setPos(m_view->mapFromGlobal(QCursor::pos())); @@ -726,7 +714,7 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) sendTouchEvent(); // After sending the event, change the touchpoint state to stationary - m_touchPoints.last().setState(Qt::TouchPointStationary); + m_touchPoints.last().setState(QEventPoint::Stationary); } } @@ -850,13 +838,6 @@ void LauncherWindow::screenshot() label->setWindowTitle(QString("Screenshot - Saved at %1").arg(fileName)); } #endif - -#ifndef QT_NO_OPENGL - if (!m_windowOptions.useQOpenGLWidgetViewport) - toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport); - if (!m_windowOptions.useQGLWidgetViewport) - toggleQOpenGLWidgetViewport(m_windowOptions.useQOpenGLWidgetViewport); -#endif } void LauncherWindow::setEditable(bool on) @@ -870,9 +851,9 @@ void LauncherWindow::setEditable(bool on) /* void LauncherWindow::dumpPlugins() { QList plugins = QWebSettings::pluginDatabase()->plugins(); - foreach (const QWebPluginInfo plugin, plugins) { + Q_FOREACH(const QWebPluginInfo plugin, plugins) { qDebug() << "Plugin:" << plugin.name(); - foreach (const QWebPluginInfo::MimeType mime, plugin.mimeTypes()) { + Q_FOREACH(const QWebPluginInfo::MimeType mime, plugin.mimeTypes()) { qDebug() << " " << mime.name; } } @@ -894,7 +875,7 @@ void LauncherWindow::selectElements() if (ok && !str.isEmpty()) { clearSelection(); QWebElementCollection result = page()->mainFrame()->findAllElements(str); - foreach (QWebElement e, result) { + Q_FOREACH(QWebElement e, result) { HighlightedElement el = { e, e.styleProperty("background-color", QWebElement::InlineStyle) }; m_highlightedElements.append(el); e.setStyleProperty("background-color", "yellow"); @@ -1064,32 +1045,15 @@ void LauncherWindow::togglePlugins(bool enable) } #ifndef QT_NO_OPENGL -void LauncherWindow::toggleQGLWidgetViewport(bool enable) -{ - if (!isGraphicsBased()) - return; - - if (enable) - m_windowOptions.useQOpenGLWidgetViewport = false; - m_windowOptions.useQGLWidgetViewport = enable; - - WebViewGraphicsBased* view = static_cast(m_view); - view->setViewport(enable ? new QGLWidget() : 0); -} - void LauncherWindow::toggleQOpenGLWidgetViewport(bool enable) { if (!isGraphicsBased()) return; -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) - if (enable) - m_windowOptions.useQGLWidgetViewport = false; m_windowOptions.useQOpenGLWidgetViewport = enable; WebViewGraphicsBased* view = static_cast(m_view); view->setViewport(enable ? new QOpenGLWidget() : 0); -#endif } #endif @@ -1214,7 +1178,7 @@ void LauncherWindow::loadURLListFromFile() void LauncherWindow::printURL(const QUrl& url) { QTextStream output(stdout); - output << "Loaded: " << url.toString() << endl; + output << "Loaded: " << url.toString() << Qt::endl; } #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX) diff --git a/Tools/QtTestBrowser/launcherwindow.h b/Tools/QtTestBrowser/launcherwindow.h index 066687724cd80..4ee9858c2dc9e 100644 --- a/Tools/QtTestBrowser/launcherwindow.h +++ b/Tools/QtTestBrowser/launcherwindow.h @@ -35,9 +35,6 @@ #include -#ifndef QT_NO_OPENGL -#include -#endif #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include #endif @@ -46,6 +43,8 @@ #include #include +#include +#include #include #include #include @@ -86,7 +85,6 @@ class WindowOptions { bool useDiskCookies { true }; bool enableScrollAnimator { false }; quint64 offlineStorageDefaultQuotaSize { 0 }; - bool useQGLWidgetViewport { false }; bool useQOpenGLWidgetViewport { false }; bool printLoadedUrls { false }; QUrl inspectorUrl; @@ -162,7 +160,6 @@ protected Q_SLOTS: void find(int mode); #endif #ifndef QT_NO_OPENGL - void toggleQGLWidgetViewport(bool enable); void toggleQOpenGLWidgetViewport(bool enable); #endif void toggleForcedAntialiasing(bool enable); @@ -222,7 +219,7 @@ public Q_SLOTS: #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX) QNetworkReply* m_reply { nullptr }; #endif - QList m_touchPoints; + QList m_touchPoints; QList m_highlightedElements; bool m_touchMocking; diff --git a/Tools/QtTestBrowser/qttestbrowser.cpp b/Tools/QtTestBrowser/qttestbrowser.cpp index eb75369cba141..ca0a1aac66f0d 100644 --- a/Tools/QtTestBrowser/qttestbrowser.cpp +++ b/Tools/QtTestBrowser/qttestbrowser.cpp @@ -47,7 +47,7 @@ WindowOptions windowOptions; #include #include #include -#include +#include int launcherMain(const QApplication& app) { @@ -239,18 +239,12 @@ void LauncherApplication::handleUserOptions() windowOptions.viewportUpdateMode = static_cast(idx); } -#ifdef QT_OPENGL_LIB - if (args.contains("-gl-viewport") || defaultForAnimations) { - requiresGraphicsView("-gl-viewport"); - windowOptions.useQGLWidgetViewport = true; - } -#endif if (args.contains("-webgl")) { windowOptions.useWebGL = true; } - if (args.contains("-opengl-viewport")) { + if (args.contains("-opengl-viewport") || defaultForAnimations) { requiresGraphicsView("-opengl-viewport"); windowOptions.useQOpenGLWidgetViewport = true; } @@ -285,7 +279,7 @@ void LauncherApplication::handleUserOptions() m_isRobotized = true; m_urls = QStringList(listFile); } else { - int lastArg = args.lastIndexOf(QRegExp("^-.*")); + int lastArg = args.lastIndexOf(QRegularExpression("^-.*")); m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1); } @@ -322,7 +316,7 @@ int main(int argc, char **argv) } LauncherWindow* window = 0; - foreach (QString url, urls) { + Q_FOREACH (QString url, urls) { LauncherWindow* newWindow; if (!window) newWindow = window = new LauncherWindow(&windowOptions); diff --git a/Tools/QtTestBrowser/urlloader.cpp b/Tools/QtTestBrowser/urlloader.cpp index 2ae722bd9899c..f3cbace391a5c 100644 --- a/Tools/QtTestBrowser/urlloader.cpp +++ b/Tools/QtTestBrowser/urlloader.cpp @@ -71,7 +71,7 @@ void UrlLoader::loadNext() if (getUrl(qstr)) { QUrl url(qstr, QUrl::StrictMode); if (url.isValid()) { - m_stdOut << "Loading " << qstr << " ......" << ++m_loaded << endl; + m_stdOut << "Loading " << qstr << " ......" << ++m_loaded << Qt::endl; m_frame->load(url); } else loadNext(); @@ -82,7 +82,7 @@ void UrlLoader::loadNext() void UrlLoader::checkIfFinished() { if (!m_numFramesLoading) - emit pageLoadFinished(); + Q_EMIT pageLoadFinished(); } void UrlLoader::frameLoadStarted() diff --git a/Tools/QtTestBrowser/webinspector.h b/Tools/QtTestBrowser/webinspector.h index 72a3a3b4829ea..76ea7f8046410 100644 --- a/Tools/QtTestBrowser/webinspector.h +++ b/Tools/QtTestBrowser/webinspector.h @@ -43,12 +43,12 @@ class WebInspector final : public QWebInspector { void showEvent(QShowEvent* event) final { QWebInspector::showEvent(event); - emit visibleChanged(true); + Q_EMIT visibleChanged(true); } void hideEvent(QHideEvent* event) final { QWebInspector::hideEvent(event); - emit visibleChanged(false); + Q_EMIT visibleChanged(false); } }; diff --git a/Tools/QtTestBrowser/webview.cpp b/Tools/QtTestBrowser/webview.cpp index 4faccbd58349a..3549a0b43871b 100644 --- a/Tools/QtTestBrowser/webview.cpp +++ b/Tools/QtTestBrowser/webview.cpp @@ -176,7 +176,7 @@ void WebViewGraphicsBased::updateFrameRate() int frames = m_fpsTimer.numFrames(interval); int current = interval ? frames * 1000 / interval : 0; - emit currentFPSUpdated(current); + Q_EMIT currentFPSUpdated(current); m_lastConsultTime = now; } diff --git a/Tools/Scripts/webkitdirs.pm b/Tools/Scripts/webkitdirs.pm index 10714c84efc4c..bdd38a888ba9b 100755 --- a/Tools/Scripts/webkitdirs.pm +++ b/Tools/Scripts/webkitdirs.pm @@ -1402,7 +1402,7 @@ sub builtDylibPathForName if (isDarwin()) { $libraryName = "QtWebKitWidgets"; } else { - $libraryName = "Qt5WebKitWidgets"; + $libraryName = "Qt6WebKitWidgets"; } my $result; if (isDarwin() and -d "$configurationProductDir/lib/$libraryName.framework") { diff --git a/Tools/Scripts/webkitpy/port/qt.py b/Tools/Scripts/webkitpy/port/qt.py index 1f18ec8b9d7ad..a9131df1fbbab 100644 --- a/Tools/Scripts/webkitpy/port/qt.py +++ b/Tools/Scripts/webkitpy/port/qt.py @@ -110,7 +110,7 @@ def _path_to_webcore_library(self): if self.operating_system() == 'mac': return self._build_path('lib/QtWebKitWidgets.framework/QtWebKitWidgets') else: - return self._build_path('lib/libQt5WebKitWidgets.so') + return self._build_path('lib/libQt6WebKitWidgets.so') def _modules_to_search_for_symbols(self): # We search in every library to be reliable in the case of building with CONFIG+=force_static_libs_as_shared. diff --git a/Tools/TestWebKitAPI/PlatformQt.cmake b/Tools/TestWebKitAPI/PlatformQt.cmake index 41eff04c95090..d4f91ec178baf 100644 --- a/Tools/TestWebKitAPI/PlatformQt.cmake +++ b/Tools/TestWebKitAPI/PlatformQt.cmake @@ -18,7 +18,7 @@ set(test_main_SOURCES ) list(APPEND TestWTF_LIBRARIES - Qt5::Gui + Qt6::Gui ) target_sources(TestWTF PRIVATE diff --git a/Tools/TestWebKitAPI/glib/CMakeLists.txt b/Tools/TestWebKitAPI/glib/CMakeLists.txt index 908951d3fa24b..b735465a7de67 100644 --- a/Tools/TestWebKitAPI/glib/CMakeLists.txt +++ b/Tools/TestWebKitAPI/glib/CMakeLists.txt @@ -191,13 +191,13 @@ if (PORT STREQUAL "WPE" AND ENABLE_WPE_QT_API) ${JavaScriptCoreGLib_FRAMEWORK_HEADERS_DIR} ${GLIB_INCLUDE_DIRS} ${LIBSOUP_INCLUDE_DIRS} - ${Qt5Test_INCLUDE_DIRS} - ${Qt5_INCLUDE_DIRS} + ${Qt6Test_INCLUDE_DIRS} + ${Qt6_INCLUDE_DIRS} ${TOOLS_DIR}/TestWebKitAPI ) set(WPEQtAPITest_LIBRARIES ${WebKitAPITest_LIBRARIES} - Qt5::Test qtwpe + Qt6::Test qtwpe ) ADD_WPE_QT_TEST(TestLoad ${TOOLS_DIR}/TestWebKitAPI/Tests/WPEQt/TestLoad.cpp) ADD_WPE_QT_TEST(TestLoadHtml ${TOOLS_DIR}/TestWebKitAPI/Tests/WPEQt/TestLoadHtml.cpp) diff --git a/Tools/WebKitTestRunner/PlatformQt.cmake b/Tools/WebKitTestRunner/PlatformQt.cmake index 87e5b997ba9b1..21e0e0e9c4b35 100644 --- a/Tools/WebKitTestRunner/PlatformQt.cmake +++ b/Tools/WebKitTestRunner/PlatformQt.cmake @@ -24,26 +24,26 @@ list(APPEND WebKitTestRunner_INCLUDE_DIRECTORIES ) list(APPEND WebKitTestRunner_SYSTEM_INCLUDE_DIRECTORIES - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5Quick_PRIVATE_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} + ${Qt6Gui_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6Quick_INCLUDE_DIRS} + ${Qt6Quick_PRIVATE_INCLUDE_DIRS} + ${Qt6Widgets_INCLUDE_DIRS} + ${Qt6Widgets_PRIVATE_INCLUDE_DIRS} ) list(APPEND WebKitTestRunner_LIBRARIES WebCore - ${Qt5Core_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5Test_LIBRARIES} + ${Qt6Core_LIBRARIES} + ${Qt6Widgets_LIBRARIES} + ${Qt6Quick_LIBRARIES} + ${Qt6Test_LIBRARIES} ) set(WebKitTestRunnerInjectedBundle_LIBRARIES WebCoreTestSupport WebKit - ${Qt5Quick_LIBRARIES} + ${Qt6Quick_LIBRARIES} ) list(APPEND WebKitTestRunnerInjectedBundle_SOURCES diff --git a/Tools/qmake/projects/run_cmake.pro b/Tools/qmake/projects/run_cmake.pro index 71872664b33b0..90d16a96f1d5e 100644 --- a/Tools/qmake/projects/run_cmake.pro +++ b/Tools/qmake/projects/run_cmake.pro @@ -27,7 +27,7 @@ build_pass|!debug_and_release { !isEmpty(_QMAKE_SUPER_CACHE_) { CMAKE_CONFIG += CMAKE_PREFIX_PATH=\"$$ROOT_QT_BUILD_DIR/qtbase;$$ROOT_QT_BUILD_DIR/qtlocation;$$ROOT_QT_BUILD_DIR/qtsensors;$$ROOT_QT_BUILD_DIR/qtdeclarative;$$ROOT_QT_BUILD_DIR/qtwebchannel\" } else { - CMAKE_CONFIG += Qt5_DIR=\"$$[QT_INSTALL_LIBS]/cmake/Qt5\" + CMAKE_CONFIG += Qt6_DIR=\"$$[QT_INSTALL_LIBS]/cmake/Qt6\" } static: CMAKE_CONFIG += USE_THIN_ARCHIVES=OFF diff --git a/Tools/qt/QtBinaryChecklist.txt b/Tools/qt/QtBinaryChecklist.txt index 25c4a0c2876b4..e6477bbbf9a13 100644 --- a/Tools/qt/QtBinaryChecklist.txt +++ b/Tools/qt/QtBinaryChecklist.txt @@ -82,36 +82,36 @@ include/QtWebKitWidgets/qwebframe.h include/QtWebKitWidgets/qwebinspector.h include/QtWebKitWidgets/qwebpage.h include/QtWebKitWidgets/qwebview.h -lib/cmake/Qt5WebKit/Qt5WebKitConfig.cmake -lib/cmake/Qt5WebKit/Qt5WebKitConfigVersion.cmake -lib/cmake/Qt5WebKit/WebKitTargets.cmake -lib/cmake/Qt5WebKitWidgets/Qt5WebKitWidgetsConfig.cmake -lib/cmake/Qt5WebKitWidgets/Qt5WebKitWidgetsConfigVersion.cmake -lib/cmake/Qt5WebKitWidgets/Qt5WebKitWidgetsTargets.cmake +lib/cmake/Qt6WebKit/Qt6WebKitConfig.cmake +lib/cmake/Qt6WebKit/Qt6WebKitConfigVersion.cmake +lib/cmake/Qt6WebKit/WebKitTargets.cmake +lib/cmake/Qt6WebKitWidgets/Qt6WebKitWidgetsConfig.cmake +lib/cmake/Qt6WebKitWidgets/Qt6WebKitWidgetsConfigVersion.cmake +lib/cmake/Qt6WebKitWidgets/Qt6WebKitWidgetsTargets.cmake mkspecs/modules/qt_lib_webkit.pri mkspecs/modules/qt_lib_webkit_private.pri mkspecs/modules/qt_lib_webkitwidgets.pri mkspecs/modules/qt_lib_webkitwidgets_private.pri {% if release %} - lib/cmake/Qt5WebKit/WebKitTargets-release.cmake - lib/cmake/Qt5WebKitWidgets/Qt5WebKitWidgetsTargets-release.cmake + lib/cmake/Qt6WebKit/WebKitTargets-release.cmake + lib/cmake/Qt6WebKitWidgets/Qt6WebKitWidgetsTargets-release.cmake {% endif %} {% if os=="linux" %} {% if release %} - lib/libQt5WebKit.so - lib/libQt5WebKit.so.{{major}} - lib/libQt5WebKit.so.{{version}} - lib/libQt5WebKitWidgets.so - lib/libQt5WebKitWidgets.so.{{major}} - lib/libQt5WebKitWidgets.so.{{version}} + lib/libQt6WebKit.so + lib/libQt6WebKit.so.{{major}} + lib/libQt6WebKit.so.{{version}} + lib/libQt6WebKitWidgets.so + lib/libQt6WebKitWidgets.so.{{major}} + lib/libQt6WebKitWidgets.so.{{version}} libexec/QtWebPluginProcess {% endif %} {% if force_debug_info %} - lib/libQt5WebKit.so.{{version}}.debug - lib/libQt5WebKitWidgets.so.{{version}}.debug + lib/libQt6WebKit.so.{{version}}.debug + lib/libQt6WebKitWidgets.so.{{version}}.debug {% endif %} {% elif os=="macos" %} @@ -228,20 +228,20 @@ mkspecs/modules/qt_lib_webkitwidgets_private.pri {% endif %} {% if release %} - bin/Qt5WebKit.dll - bin/Qt5WebKitWidgets.dll + bin/Qt6WebKit.dll + bin/Qt6WebKitWidgets.dll {% if force_debug_info and toolchain=="msvc" %} - bin/Qt5WebKit.pdb - bin/Qt5WebKitWidgets.pdb + bin/Qt6WebKit.pdb + bin/Qt6WebKitWidgets.pdb {% endif %} {% if toolchain=="msvc" %} - lib/Qt5WebKit.lib - lib/Qt5WebKitWidgets.lib + lib/Qt6WebKit.lib + lib/Qt6WebKitWidgets.lib {% elif toolchain=="mingw" %} - lib/libQt5WebKitWidgets.a - lib/libQt5WebKit.a + lib/libQt6WebKitWidgets.a + lib/libQt6WebKit.a {% endif %} qml/QtWebKit/experimental/qmlwebkitexperimentalplugin.dll @@ -249,22 +249,22 @@ mkspecs/modules/qt_lib_webkitwidgets_private.pri {% endif %} {% if debug %} - lib/cmake/Qt5WebKit/WebKitTargets-debug.cmake - lib/cmake/Qt5WebKitWidgets/Qt5WebKitWidgetsTargets-debug.cmake + lib/cmake/Qt6WebKit/WebKitTargets-debug.cmake + lib/cmake/Qt6WebKitWidgets/Qt6WebKitWidgetsTargets-debug.cmake {% if toolchain=="msvc" %} - bin/Qt5WebKitWidgetsd.dll - bin/Qt5WebKitd.dll + bin/Qt6WebKitWidgetsd.dll + bin/Qt6WebKitd.dll {% endif %} {% if force_debug_info and toolchain=="msvc" %} - bin/Qt5WebKitd.pdb - bin/Qt5WebKitWidgetsd.pdb + bin/Qt6WebKitd.pdb + bin/Qt6WebKitWidgetsd.pdb {% endif %} {% if toolchain=="msvc" %} - lib/Qt5WebKitd.lib - lib/Qt5WebKitWidgetsd.lib + lib/Qt6WebKitd.lib + lib/Qt6WebKitWidgetsd.lib qml/QtWebKit/experimental/qmlwebkitexperimentalplugind.dll qml/QtWebKit/qmlwebkitplugind.dll {% endif %} @@ -285,6 +285,6 @@ mkspecs/modules/qt_lib_webkitwidgets_private.pri {% endif %} {% if os=="linux" or os=="windows" %} - lib/pkgconfig/Qt5WebKit.pc - lib/pkgconfig/Qt5WebKitWidgets.pc + lib/pkgconfig/Qt6WebKit.pc + lib/pkgconfig/Qt6WebKitWidgets.pc {% endif %} diff --git a/tests/webkitqml/CMakeLists.txt b/tests/webkitqml/CMakeLists.txt index 210342ef5bdc9..195e5f079253f 100644 --- a/tests/webkitqml/CMakeLists.txt +++ b/tests/webkitqml/CMakeLists.txt @@ -5,9 +5,9 @@ include_directories( ) include_directories(SYSTEM - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5Quick_PRIVATE_INCLUDE_DIRS} - ${Qt5QuickTest_INCLUDE_DIRS} + ${Qt6Quick_INCLUDE_DIRS} + ${Qt6Quick_PRIVATE_INCLUDE_DIRS} + ${Qt6QuickTest_INCLUDE_DIRS} ) set(tst_qmltests_DEFINITIONS @@ -75,13 +75,13 @@ set(qmltests_SOURCES ${qmltests_QML_SOURCES} ) -qt5_add_resources(qmltests_SOURCES qmltests/resources.qrc) +qt_add_resources(qmltests_SOURCES qmltests/resources.qrc) set(qmltests_LIBRARIES WebKit - ${Qt5Quick_LIBRARIES} - ${Qt5QuickTest_LIBRARIES} - ${Qt5Test_LIBRARIES} + ${Qt6Quick_LIBRARIES} + ${Qt6QuickTest_LIBRARIES} + ${Qt6Test_LIBRARIES} ) if (SHARED_CORE) diff --git a/tests/webkitwidgets/CMakeLists.txt b/tests/webkitwidgets/CMakeLists.txt index 66079eed2d928..cbf9cd2b87ce4 100644 --- a/tests/webkitwidgets/CMakeLists.txt +++ b/tests/webkitwidgets/CMakeLists.txt @@ -7,10 +7,10 @@ if (ENABLE_TEST_SUPPORT) endif () set(QtWK1ApiTests_LIBRARIES - ${Qt5Gui_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${Qt5Test_LIBRARIES} - ${Qt5Widgets_LIBRARIES} + ${Qt6Gui_LIBRARIES} + ${Qt6Network_LIBRARIES} + ${Qt6Test_LIBRARIES} + ${Qt6Widgets_LIBRARIES} WebKitWidgets ) @@ -34,12 +34,12 @@ set(QtWK1ApiTests ) set(tst_hybridPixmap_SOURCES hybridPixmap/widget.cpp) -qt5_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui) +qt_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui) foreach (testName ${QtWK1ApiTests}) list(APPEND tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}/tst_${testName}.qrc") - qt5_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) + qt_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) endif () add_executable(tst_${testName} ${tst_${testName}_SOURCES}) @@ -52,7 +52,7 @@ foreach (testName ${QtWK1ApiTests}) ) target_include_directories(tst_${testName} SYSTEM PRIVATE - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} ) target_link_libraries(tst_${testName} ${QtWK1ApiTests_LIBRARIES}) diff --git a/tests/webkitwidgets/cmake/CMakeLists.txt b/tests/webkitwidgets/cmake/CMakeLists.txt index 8f266fccb48c2..ffbd643b049c8 100644 --- a/tests/webkitwidgets/cmake/CMakeLists.txt +++ b/tests/webkitwidgets/cmake/CMakeLists.txt @@ -5,11 +5,11 @@ project(qmake_cmake_files) enable_testing() -find_package(Qt5Core REQUIRED) +find_package(Qt6 COMPONENTS Core REQUIRED) -include("${_Qt5CTestMacros}") +include("${_Qt6CTestMacros}") -set(Qt5_MODULE_TEST_DEPENDS Widgets) +set(Qt6_MODULE_TEST_DEPENDS Widgets) test_module_includes( WebKit QWebElement From 007b73c75b1bf8b80aab5a04e9b42b1eef664589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sun, 20 Feb 2022 10:34:14 +0100 Subject: [PATCH 12/58] Update to the new bincrafters URL in build-qtwebkit-conan.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Brooke --- Tools/qt/build-qtwebkit-conan.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/qt/build-qtwebkit-conan.py b/Tools/qt/build-qtwebkit-conan.py index c83800ee5600d..91acdc9b611a3 100755 --- a/Tools/qt/build-qtwebkit-conan.py +++ b/Tools/qt/build-qtwebkit-conan.py @@ -135,7 +135,8 @@ def create_profile(compiler, arch): print("Path of build directory:" + build_directory) -run_command("conan remote add -f bincrafters https://api.bintray.com/conan/bincrafters/public-conan") +run_command("conan remote add -f bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan") +run_command("conan config set general.revisions_enabled=1") run_command("conan remote add -f qtproject https://api.bintray.com/conan/qtproject/conan") run_command("conan remote add -f qtproject-testing https://api.bintray.com/conan/qtproject/conan-testing") From b9a2d1612d982176d9721cb0c8c36b3882a11468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sun, 20 Feb 2022 10:56:14 +0100 Subject: [PATCH 13/58] Remove dead "qtproject" conan repositories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Brooke --- Tools/qt/build-qtwebkit-conan.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tools/qt/build-qtwebkit-conan.py b/Tools/qt/build-qtwebkit-conan.py index 91acdc9b611a3..3987ea6783b0b 100755 --- a/Tools/qt/build-qtwebkit-conan.py +++ b/Tools/qt/build-qtwebkit-conan.py @@ -137,8 +137,6 @@ def create_profile(compiler, arch): run_command("conan remote add -f bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan") run_command("conan config set general.revisions_enabled=1") -run_command("conan remote add -f qtproject https://api.bintray.com/conan/qtproject/conan") -run_command("conan remote add -f qtproject-testing https://api.bintray.com/conan/qtproject/conan-testing") if args.profile and args.compiler: sys.exit("Error: --compiler and --profile cannot be specified at the same time") From ddcfb68e6cc8bb5841282f2adcf0f1314286eeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sun, 20 Feb 2022 11:07:16 +0100 Subject: [PATCH 14/58] Remove all "qtproject/stable" references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Brooke --- Tools/qt/conanfile.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tools/qt/conanfile.py b/Tools/qt/conanfile.py index 806ac58074f14..f7ffd2cf7af8d 100644 --- a/Tools/qt/conanfile.py +++ b/Tools/qt/conanfile.py @@ -90,27 +90,27 @@ def build_requirements(self): def requirements(self): # TODO: Handle case when custom ICU is needed (AppStore etc., MACOS_USE_SYSTEM_ICU=OFF in CMake) if self.settings.os == 'Windows': - self.requires("icu/65.1@qtproject/stable") - self.requires("libxml2/2.9.10@qtproject/stable") - self.requires("libxslt/1.1.34@qtproject/stable") + self.requires("icu/65.1") + self.requires("libxml2/2.9.10") + self.requires("libxslt/1.1.34") self.requires("zlib/1.2.11") - self.requires("libtasn1/4.16.0@qtproject/stable") - self.requires("libgcrypt/1.8.4@qtproject/stable") + self.requires("libtasn1/4.16.0") + self.requires("libgcrypt/1.8.4") if self.settings.os == 'Windows' or self.settings.os == 'Macos': # FIXME: Pass Qt version, handle more versions qt_version = "5.15.1" if qt_version == "5.14.1": self.requires("sqlite3/3.30.1") - self.requires("libjpeg-turbo/2.0.3@qtproject/stable") + self.requires("libjpeg-turbo/2.0.3") self.requires("libpng/1.6.37") if qt_version == "5.15.1": self.requires("sqlite3/3.32.3") - self.requires("libjpeg-turbo/2.0.5@qtproject/stable") + self.requires("libjpeg-turbo/2.0.5") self.requires("libpng/1.6.37") self.requires("libwebp/1.1.0") - self.requires("woff2/1.0.2@qtproject/stable") + self.requires("woff2/1.0.2") def build(self): cmake = CMake(self, set_cmake_flags=True) From 65d5f36e9c9dc277c8d4de092d4c775cc7e61dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sun, 20 Feb 2022 11:14:50 +0100 Subject: [PATCH 15/58] Add Qt version 6.2.3 in Conan file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Brooke --- Tools/qt/conanfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tools/qt/conanfile.py b/Tools/qt/conanfile.py index f7ffd2cf7af8d..8ef4a0776a3a2 100644 --- a/Tools/qt/conanfile.py +++ b/Tools/qt/conanfile.py @@ -99,7 +99,7 @@ def requirements(self): if self.settings.os == 'Windows' or self.settings.os == 'Macos': # FIXME: Pass Qt version, handle more versions - qt_version = "5.15.1" + qt_version = "6.2.3" if qt_version == "5.14.1": self.requires("sqlite3/3.30.1") self.requires("libjpeg-turbo/2.0.3") @@ -108,6 +108,10 @@ def requirements(self): self.requires("sqlite3/3.32.3") self.requires("libjpeg-turbo/2.0.5") self.requires("libpng/1.6.37") + if qt_version == "6.2.3": + self.requires("sqlite3/3.37.2") + self.requires("libjpeg-turbo/2.1.2") + self.requires("libpng/1.6.37") self.requires("libwebp/1.1.0") self.requires("woff2/1.0.2") From 6e15c3455a9af8984b7be4cf994148b6e151d838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sun, 20 Feb 2022 11:15:39 +0100 Subject: [PATCH 16/58] Remove woff2 dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Brooke --- Tools/qt/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Tools/qt/conanfile.py b/Tools/qt/conanfile.py index 8ef4a0776a3a2..cbab0115f7219 100644 --- a/Tools/qt/conanfile.py +++ b/Tools/qt/conanfile.py @@ -114,7 +114,6 @@ def requirements(self): self.requires("libpng/1.6.37") self.requires("libwebp/1.1.0") - self.requires("woff2/1.0.2") def build(self): cmake = CMake(self, set_cmake_flags=True) From e6dd187f18dd9d6d813c7e2a8262cde87e9532ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sun, 20 Feb 2022 11:51:12 +0100 Subject: [PATCH 17/58] Rename Qt5 to Qt6 in conan files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Brooke --- Tools/qt/conanfile.py | 6 +++--- Tools/qt/convert-prl-libs-to-cmake.pl | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tools/qt/conanfile.py b/Tools/qt/conanfile.py index cbab0115f7219..acf74f64d586a 100644 --- a/Tools/qt/conanfile.py +++ b/Tools/qt/conanfile.py @@ -127,9 +127,9 @@ def build(self): # cmake.definitions["CMAKE_CXX_COMPILER_LAUNCHER"] = "ccache" if self.options.qt: - cmake.definitions["Qt5_DIR"] = os.path.join( - str(self.options.qt), "lib", "cmake", "Qt5") - print("Qt5 directory:" + cmake.definitions["Qt5_DIR"]) + cmake.definitions["Qt6_DIR"] = os.path.join( + str(self.options.qt), "lib", "cmake", "Qt6") + print("Qt6 directory:" + cmake.definitions["Qt6_DIR"]) if self.options.build_type: cmake.build_type = str(self.options.build_type) diff --git a/Tools/qt/convert-prl-libs-to-cmake.pl b/Tools/qt/convert-prl-libs-to-cmake.pl index 40fab403c740e..5612178229509 100755 --- a/Tools/qt/convert-prl-libs-to-cmake.pl +++ b/Tools/qt/convert-prl-libs-to-cmake.pl @@ -73,17 +73,17 @@ sub processArgs { my $prl_libs = squash_prl_libs(shellwords($qmake_prl_libs)); my $template = <<'END_CMAKE'; -get_target_property(_link_libs Qt5::${_component} INTERFACE_LINK_LIBRARIES) +get_target_property(_link_libs Qt6::${_component} INTERFACE_LINK_LIBRARIES) if (_link_libs) set(_list_sep ";") else () set(_list_sep "") endif () -set_target_properties(Qt5::${_component} PROPERTIES +set_target_properties(Qt6::${_component} PROPERTIES "INTERFACE_LINK_LIBRARIES" "${_link_libs}${_list_sep}${_libs}") -set(Qt5${_component}_STATIC_LIB_DEPENDENCIES "${_libs}") +set(Qt6${_component}_STATIC_LIB_DEPENDENCIES "${_libs}") list(APPEND STATIC_LIB_DEPENDENCIES - ${Qt5${_component}_STATIC_LIB_DEPENDENCIES} + ${Qt6${_component}_STATIC_LIB_DEPENDENCIES} ) unset(_component) unset(_libs) From c9c188087a0b6c99337bca2360a3e28b7238bf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sun, 27 Mar 2022 10:47:51 +0200 Subject: [PATCH 18/58] Fix Qt 6 build with ENABLE_PRINT_SUPPORT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Brooke --- Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp b/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp index 08b18b7e10e92..6c3c6507aa48d 100644 --- a/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp +++ b/Source/WebKitLegacy/qt/WidgetApi/qwebframe.cpp @@ -824,19 +824,19 @@ void QWebFrame::print(QPrinter *printer) const const qreal zoomFactorX = (qreal)printer->logicalDpiX() / qt_defaultDpi(); const qreal zoomFactorY = (qreal)printer->logicalDpiY() / qt_defaultDpi(); - QRect qprinterRect = printer->pageRect(); + QRectF qprinterRect = printer->pageRect(QPrinter::DevicePixel); - QRect pageRect(0, 0, int(qprinterRect.width() / zoomFactorX), int(qprinterRect.height() / zoomFactorY)); + QRectF pageRect(0, 0, qprinterRect.width() / zoomFactorX, qprinterRect.height() / zoomFactorY); - QtPrintContext printContext(&painter, pageRect, d); + QtPrintContext printContext(&painter, pageRect.toRect(), d); int docCopies; int pageCopies; if (printer->collateCopies()) { docCopies = 1; - pageCopies = printer->numCopies(); + pageCopies = printer->copyCount(); } else { - docCopies = printer->numCopies(); + docCopies = printer->copyCount(); pageCopies = 1; } From d3ca4c6bbb45fc1863d7e014a2230d82b53e9942 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 22:23:17 -0500 Subject: [PATCH 19/58] qt6 no longer has bearermanagement --- Source/WTF/wtf/Platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h index 9a813371ccf61..beda8126c9c51 100644 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -168,7 +168,7 @@ #endif // QT_VERSION >= QT_VERSION_CHECK(5,8,0) #include -#if !QT_CONFIG(bearermanagement) +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) || !QT_CONFIG(bearermanagement) #ifndef QT_NO_BEARERMANAGEMENT #define QT_NO_BEARERMANAGEMENT #endif // QT_NO_BEARERMANAGEMENT From 3afdaaebe001357955ac01899479c6cef4eb6459 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:48:40 -0500 Subject: [PATCH 20/58] QStringRef deprecated in favor of QStringView --- Source/WTF/wtf/text/AtomString.h | 2 +- Source/WTF/wtf/text/WTFString.h | 7 ++++++- Source/WTF/wtf/text/qt/AtomStringQt.cpp | 6 +++--- Source/WTF/wtf/text/qt/StringQt.cpp | 11 +++++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Source/WTF/wtf/text/AtomString.h b/Source/WTF/wtf/text/AtomString.h index df244b7d5e444..fae3b510c6917 100644 --- a/Source/WTF/wtf/text/AtomString.h +++ b/Source/WTF/wtf/text/AtomString.h @@ -125,7 +125,7 @@ class AtomString final { #if PLATFORM(QT) WTF_EXPORT_PRIVATE AtomString(const QString&); - WTF_EXPORT_PRIVATE AtomString(const QStringRef&); + WTF_EXPORT_PRIVATE AtomString(const QStringView&); #endif #if OS(WINDOWS) diff --git a/Source/WTF/wtf/text/WTFString.h b/Source/WTF/wtf/text/WTFString.h index a4b2b976ec77e..e53e1666b3eec 100644 --- a/Source/WTF/wtf/text/WTFString.h +++ b/Source/WTF/wtf/text/WTFString.h @@ -264,8 +264,13 @@ class String final { #if PLATFORM(QT) WTF_EXPORT_PRIVATE String(const QString&); - WTF_EXPORT_PRIVATE String(QStringView); + WTF_EXPORT_PRIVATE String(const QLatin1StringView&); + WTF_EXPORT_PRIVATE explicit String(const QStringView&); WTF_EXPORT_PRIVATE operator QString() const; + + // String(QStringView) makes for an ambiguous constructor, so we need to make these explicit + ALWAYS_INLINE String(Vector characters) : String(characters.data(), characters.size()) {} + ALWAYS_INLINE String(Vector characters) : String(characters.data(), characters.size()) {} #endif #if OS(WINDOWS) diff --git a/Source/WTF/wtf/text/qt/AtomStringQt.cpp b/Source/WTF/wtf/text/qt/AtomStringQt.cpp index a1ad6ff48238d..66c61e400bb0f 100644 --- a/Source/WTF/wtf/text/qt/AtomStringQt.cpp +++ b/Source/WTF/wtf/text/qt/AtomStringQt.cpp @@ -12,10 +12,10 @@ AtomString::AtomString(const QString& qstr) return; } -AtomString::AtomString(const QStringRef& ref) - : m_string(AtomStringImpl::add(reinterpret_cast_ptr(ref.unicode()), ref.length())) +AtomString::AtomString(const QStringView& view) + : m_string(AtomStringImpl::add(reinterpret_cast_ptr(view.constData()), view.length())) { - if (!ref.string()) + if (view.isNull()) return; } diff --git a/Source/WTF/wtf/text/qt/StringQt.cpp b/Source/WTF/wtf/text/qt/StringQt.cpp index af9f95d63b389..64af257ebd00c 100644 --- a/Source/WTF/wtf/text/qt/StringQt.cpp +++ b/Source/WTF/wtf/text/qt/StringQt.cpp @@ -40,11 +40,18 @@ String::String(const QString& qstr) m_impl = StringImpl::create(reinterpret_cast_ptr(qstr.constData()), qstr.length()); } -String::String(QStringView view) +String::String(const QLatin1StringView& view) { if (view.isNull()) return; - m_impl = StringImpl::create(reinterpret_cast_ptr(view.utf16()), view.length()); + m_impl = StringImpl::create(reinterpret_cast_ptr(view.data()), view.length()); +} + +String::String(const QStringView& view) +{ + if (view.isNull()) + return; + m_impl = StringImpl::create(reinterpret_cast_ptr(view.data()), view.length()); } String::operator QString() const From 11b5b65e56b34071944a0bf8445a881f4513417d Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:50:04 -0500 Subject: [PATCH 21/58] QURL::topLevelDomain() was removed; we can now use webkit's RegistrableDomain instead --- .../platform/qt/ThirdPartyCookiesQt.cpp | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp b/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp index 39b81d3d5eefb..1aff04352b9ff 100644 --- a/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp +++ b/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp @@ -23,45 +23,14 @@ #include "Document.h" #include "NetworkStorageSession.h" +#include "RegistrableDomain.h" #include -#include #include #include -#include - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -Q_NETWORK_EXPORT QString qTopLevelDomain(QString domain); -#endif namespace WebCore { -inline void removeTopLevelDomain(QString* domain, const QString& topLevelDomain) -{ - domain->remove(domain->length() - topLevelDomain.length(), topLevelDomain.length()); - domain->prepend(QLatin1Char('.')); -} - -static bool urlsShareSameDomain(const QUrl& url, const QUrl& firstPartyUrl) -{ - QString firstPartyTLD = qTopLevelDomain(firstPartyUrl.host()); - QString requestTLD = qTopLevelDomain(url.host()); - - if (firstPartyTLD != requestTLD) - return false; - - QString firstPartyDomain = QString(firstPartyUrl.host().toLower()); - QString requestDomain = QString(url.host().toLower()); - - removeTopLevelDomain(&firstPartyDomain, firstPartyTLD); - removeTopLevelDomain(&requestDomain, requestTLD); - - if (firstPartyDomain.section(QLatin1Char('.'), -1) == requestDomain.section(QLatin1Char('.'), -1)) - return true; - - return false; -} - bool thirdPartyCookiePolicyPermits(const NetworkStorageSession* storageSession, const QUrl& url, const QUrl& firstPartyUrl) { if (!storageSession) @@ -74,7 +43,7 @@ bool thirdPartyCookiePolicyPermits(const NetworkStorageSession* storageSession, if (firstPartyUrl.isEmpty()) return true; - if (urlsShareSameDomain(url, firstPartyUrl)) + if (RegistrableDomain(URL(url)).matches(firstPartyUrl)) return true; switch (storageSession->thirdPartyCookiePolicy()) { From 8c254fad39c6a59a1299985c4206c1349dde057b Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:50:43 -0500 Subject: [PATCH 22/58] qt6 cmake target rcc --- Source/WebInspectorUI/PlatformQt.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WebInspectorUI/PlatformQt.cmake b/Source/WebInspectorUI/PlatformQt.cmake index 2a996a841d416..c8471f35c0a06 100644 --- a/Source/WebInspectorUI/PlatformQt.cmake +++ b/Source/WebInspectorUI/PlatformQt.cmake @@ -1,4 +1,4 @@ -get_target_property(RCC_EXECUTABLE ${Qt6Core_RCC_EXECUTABLE} IMPORTED_LOCATION) +get_target_property(RCC_EXECUTABLE Qt6::rcc IMPORTED_LOCATION) if (NOT DEFINED InspectorFiles) # QTFIXME: Must be kept in sync with CMakeLists.txt; probably a better way? From a53d8170b5fdb9b1e55acf611e8007dd76837922 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:51:39 -0500 Subject: [PATCH 23/58] cmake now seems to find OpenGL::GLX, so webkit's FindOpenGL should check first --- Source/cmake/FindOpenGL.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmake/FindOpenGL.cmake b/Source/cmake/FindOpenGL.cmake index b37747346e820..1fc0b78f652d1 100644 --- a/Source/cmake/FindOpenGL.cmake +++ b/Source/cmake/FindOpenGL.cmake @@ -118,7 +118,7 @@ else () check_include_files("GL/glx.h" OpenGL_GLX_FOUND) CMAKE_POP_CHECK_STATE() - if (OpenGL_GLX_FOUND) + if (OpenGL_GLX_FOUND AND NOT TARGET OpenGL::GLX) # XXX: Should this actually check that the OpenGL library contains the GLX symbols? add_library(OpenGL::GLX INTERFACE IMPORTED GLOBAL) set_property(TARGET OpenGL::GLX PROPERTY From c6b064a5f67f70303037752aab18df7f60d8148d Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:52:57 -0500 Subject: [PATCH 24/58] more qt deprecations --- .../qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp | 4 ++-- Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index 51e427e486aa5..9f15a6eb6af0f 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -458,8 +458,8 @@ QString DumpRenderTreeSupportQt::viewportAsText(QWebPageAdapter* adapter, int de WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(conf); return QLatin1String("viewport size %1x%2 scale %3 with limits [%4, %5] and userScalable %6\n") - .arg(static_cast(conf.layoutSize.width())) - .arg(static_cast(conf.layoutSize.height())) + .arg(QByteArray::number(conf.layoutSize.width())) + .arg(QByteArray::number(conf.layoutSize.height())) .arg(conf.initialScale) .arg(conf.minimumScale) .arg(conf.maximumScale) diff --git a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 8101b453f04dd..a6ebbb090d3bf 100644 --- a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -64,7 +64,7 @@ #include #endif #include -#include +#include #include #include #include @@ -723,7 +723,7 @@ void DumpRenderTree::processLine(const QString &input) // Try to be smart about where the test is located if (currentDir.dirName() == QLatin1String("LayoutTests")) - fi = QFileInfo(currentDir, pathOrURL.replace(QRegExp(".*?LayoutTests/(.*)"), "\\1")); + fi = QFileInfo(currentDir, pathOrURL.replace(QRegularExpression(".*?LayoutTests/(.*)"), "\\1")); else if (!pathOrURL.contains(QLatin1String("LayoutTests"))) fi = QFileInfo(currentDir, pathOrURL.prepend(QLatin1String("LayoutTests/"))); From 5efa1c50da248e905185123a91eb03037478d7b4 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:54:39 -0500 Subject: [PATCH 25/58] remove remaining uses of foreach --- Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp | 16 ++++++++-------- Tools/DumpRenderTree/qt/EventSenderQt.cpp | 2 +- Tools/DumpRenderTree/qt/TestRunnerQt.cpp | 10 +++++----- Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index a6ebbb090d3bf..cc46d16a71831 100644 --- a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -95,7 +95,7 @@ void NetworkAccessManager::sslErrorsEncountered(QNetworkReply* reply, const QLis bool ignore = true; // Accept any HTTPS certificate. - foreach (const QSslError& error, errors) { + for (const QSslError& error : errors) { if (error.error() < QSslError::UnableToGetIssuerCertificate || error.error() > QSslError::HostNameMismatch) { ignore = false; break; @@ -260,7 +260,7 @@ void WebPage::permissionSet(QWebPage::Feature feature) case Geolocation: { Q_ASSERT(m_drt->testRunner()->isGeolocationPermissionSet()); - foreach (QWebFrame* frame, m_pendingGeolocationRequests) + for (QWebFrame* frame : m_pendingGeolocationRequests) if (m_drt->testRunner()->geolocationPermission()) setFeaturePermission(frame, feature, PermissionGrantedByUser); else @@ -743,7 +743,7 @@ void DumpRenderTree::processLine(const QString &input) void DumpRenderTree::closeRemainingWindows() { - foreach (QObject* widget, windows) + for (QObject* widget : windows) delete widget; windows.clear(); } @@ -902,7 +902,7 @@ static QString dumpHistoryItem(const QWebHistoryItem& item, int indent, bool cur result.append(QLatin1String("\n")); QMap children = DumpRenderTreeSupportQt::getChildHistoryItems(item); - foreach (QWebHistoryItem item, children) + for (QWebHistoryItem item : children) result += dumpHistoryItem(item, 12, false); return result; @@ -921,7 +921,7 @@ QString DumpRenderTree::dumpBackForwardList(QWebPage* page) int maxItems = history->maximumItemCount(); - foreach (const QWebHistoryItem item, history->backItems(maxItems)) { + for (const QWebHistoryItem item : history->backItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); @@ -931,7 +931,7 @@ QString DumpRenderTree::dumpBackForwardList(QWebPage* page) if (item.isValid()) result.append(dumpHistoryItem(item, 8, true)); - foreach (const QWebHistoryItem item, history->forwardItems(maxItems)) { + for (const QWebHistoryItem item : history->forwardItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); @@ -993,7 +993,7 @@ void DumpRenderTree::dump() if (m_jscController->dumpBackForwardList()) { fprintf(stdout, "%s", dumpBackForwardList(webPage()).toUtf8().constData()); - foreach (QObject* widget, windows) { + for (QObject* widget : windows) { QWebPage* page = qobject_cast(widget->findChild()); fprintf(stdout, "%s", dumpBackForwardList(page).toUtf8().constData()); } @@ -1225,7 +1225,7 @@ QList DumpRenderTree::getAllPages() const { QList pages; pages.append(m_page); - foreach (QObject* widget, windows) { + for (QObject* widget : windows) { if (WebPage* page = widget->findChild()) pages.append(page); } diff --git a/Tools/DumpRenderTree/qt/EventSenderQt.cpp b/Tools/DumpRenderTree/qt/EventSenderQt.cpp index 6852785368be8..ec7695015a459 100644 --- a/Tools/DumpRenderTree/qt/EventSenderQt.cpp +++ b/Tools/DumpRenderTree/qt/EventSenderQt.cpp @@ -225,7 +225,7 @@ void EventSender::beginDragWithFiles(const QStringList& files) m_currentDragData.clear(); QList fileUrls; QUrl baseUrl = m_page->mainFrame()->baseUrl(); - foreach (const QString& file, files) { + for (const QString& file : files) { QUrl resolvedUrl = baseUrl.resolved(file); fileUrls.append(resolvedUrl); } diff --git a/Tools/DumpRenderTree/qt/TestRunnerQt.cpp b/Tools/DumpRenderTree/qt/TestRunnerQt.cpp index b426b71260208..dbdc140021281 100644 --- a/Tools/DumpRenderTree/qt/TestRunnerQt.cpp +++ b/Tools/DumpRenderTree/qt/TestRunnerQt.cpp @@ -694,7 +694,7 @@ void TestRunnerQt::setIconDatabaseEnabled(bool enable) void TestRunnerQt::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) { QList pages = m_drt->getAllPages(); - foreach (WebPage* page, pages) + for (WebPage* page : pages) DumpRenderTreeSupportQt::setMockDeviceOrientation(page->handle(), canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); } @@ -702,7 +702,7 @@ void TestRunnerQt::setGeolocationPermission(bool allow) { setGeolocationPermissionCommon(allow); QList pages = m_drt->getAllPages(); - foreach (WebPage* page, pages) + for (WebPage* page : pages) DumpRenderTreeSupportQt::setMockGeolocationPermission(page->handle(), allow); } @@ -710,7 +710,7 @@ int TestRunnerQt::numberOfPendingGeolocationPermissionRequests() { int pendingPermissionCount = 0; QList pages = m_drt->getAllPages(); - foreach (WebPage* page, pages) + for (WebPage* page : pages) pendingPermissionCount += DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(page->handle()); return pendingPermissionCount; @@ -725,14 +725,14 @@ void TestRunnerQt::setGeolocationPermissionCommon(bool allow) void TestRunnerQt::setMockGeolocationPositionUnavailableError(const QString& message) { QList pages = m_drt->getAllPages(); - foreach (WebPage* page, pages) + for (WebPage* page : pages) DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(page->handle(), message); } void TestRunnerQt::setMockGeolocationPosition(double latitude, double longitude, double accuracy) { QList pages = m_drt->getAllPages(); - foreach (WebPage* page, pages) + for (WebPage* page : pages) DumpRenderTreeSupportQt::setMockGeolocationPosition(page->handle(), latitude, longitude, accuracy); } diff --git a/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp b/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp index fab02d81031dc..005d5cee6f5b0 100644 --- a/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp +++ b/Tools/DumpRenderTree/qt/WorkQueueItemQt.cpp @@ -38,7 +38,7 @@ QWebFrame* findFrameNamed(const QString& frameName, QWebFrame* frame) if (frame->frameName() == frameName) return frame; - foreach (QWebFrame* childFrame, frame->childFrames()) + for (QWebFrame* childFrame : frame->childFrames()) if (QWebFrame* f = findFrameNamed(frameName, childFrame)) return f; From aaa4096c7a708756636b5c1367047122c7470fb1 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:55:36 -0500 Subject: [PATCH 26/58] Q_EMIT is a preprocessor directive now --- Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp | 10 +++++----- Tools/DumpRenderTree/qt/TestRunnerQt.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index cc46d16a71831..31df8810ddcf3 100644 --- a/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -654,7 +654,7 @@ void DumpRenderTree::readLine() m_stdin->open(stdin, QFile::ReadOnly); if (!m_stdin->isReadable()) { - emit quit(); + Q_EMIT quit(); return; } } @@ -662,7 +662,7 @@ void DumpRenderTree::readLine() QByteArray line = m_stdin->readLine().trimmed(); if (line.isEmpty()) { - emit quit(); + Q_EMIT quit(); return; } @@ -696,7 +696,7 @@ void DumpRenderTree::processArgsLine(const QStringList &args) void DumpRenderTree::loadNextTestInStandAloneMode() { if (m_standAloneModeTestList.isEmpty()) { - emit quit(); + Q_EMIT quit(); return; } QString first = m_standAloneModeTestList.takeFirst(); @@ -728,7 +728,7 @@ void DumpRenderTree::processLine(const QString &input) fi = QFileInfo(currentDir, pathOrURL.prepend(QLatin1String("LayoutTests/"))); if (!fi.exists()) { - emit ready(); + Q_EMIT ready(); return; } } @@ -1093,7 +1093,7 @@ void DumpRenderTree::dump() fflush(stdout); fflush(stderr); - emit ready(); + Q_EMIT ready(); } void DumpRenderTree::titleChanged(const QString &s) diff --git a/Tools/DumpRenderTree/qt/TestRunnerQt.cpp b/Tools/DumpRenderTree/qt/TestRunnerQt.cpp index dbdc140021281..e094fdf915336 100644 --- a/Tools/DumpRenderTree/qt/TestRunnerQt.cpp +++ b/Tools/DumpRenderTree/qt/TestRunnerQt.cpp @@ -97,7 +97,7 @@ void TestRunnerQt::reset() removeAllWebNotificationPermissions(); // The default state for DRT is to block third-party cookies, mimicing the Mac port setAlwaysAcceptCookies(false); - emit hidePage(); + Q_EMIT hidePage(); } void TestRunnerQt::dumpNotifications() @@ -111,7 +111,7 @@ void TestRunnerQt::processWork() // if we didn't start a new load, then we finished all the commands, so we're ready to dump state if (DRT::WorkQueue::singleton().processWork() && !shouldWaitUntilDone()) { - emit done(); + Q_EMIT done(); m_hasDumped = true; } } @@ -143,7 +143,7 @@ void TestRunnerQt::maybeDump(bool /*success*/) if (DRT::WorkQueue::singleton().count()) QTimer::singleShot(0, this, SLOT(processWork())); else if (!shouldWaitUntilDone()) { - emit done(); + Q_EMIT done(); m_hasDumped = true; } } @@ -196,7 +196,7 @@ void TestRunnerQt::notifyDone() if (!m_loadFinished) return; - emit done(); + Q_EMIT done(); // FIXME: investigate why always resetting these result in timeouts m_hasDumped = true; @@ -238,7 +238,7 @@ void TestRunnerQt::simulateLegacyWebNotificationClick(const QString& title) void TestRunnerQt::display() { DumpRenderTreeSupportQt::setTrackRepaintRects(m_topLoadingFrame->handle(), true); - emit showPage(); + Q_EMIT showPage(); } void TestRunnerQt::displayInvalidatedRegion() From 87ec20791f616b3b5a57f73c6957561ba83f19b6 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 3 Jan 2023 23:56:53 -0500 Subject: [PATCH 27/58] qt6 qevent updates --- Tools/DumpRenderTree/qt/EventSenderQt.cpp | 69 +++++++++++++++-------- Tools/QtTestBrowser/launcherwindow.cpp | 21 ++----- Tools/QtTestBrowser/launcherwindow.h | 2 +- 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/Tools/DumpRenderTree/qt/EventSenderQt.cpp b/Tools/DumpRenderTree/qt/EventSenderQt.cpp index ec7695015a459..baf4052d8fb2a 100644 --- a/Tools/DumpRenderTree/qt/EventSenderQt.cpp +++ b/Tools/DumpRenderTree/qt/EventSenderQt.cpp @@ -34,6 +34,11 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#include +#endif + #define KEYCODE_DEL 127 #define KEYCODE_BACKSPACE 8 #define KEYCODE_LEFTARROW 0xf702 @@ -251,13 +256,20 @@ void EventSender::continuousMouseScrollBy(int x, int y) // A wheel delta of 120 (in 1/8 degrees) corresponds to one wheel tick, and we scroll tickStep pixels per wheel tick. const int tickStep = QApplication::wheelScrollLines() * 20; + QPointF globalPosition = QCursor::pos(); + if (x) { QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel, m_mousePos, m_mousePos, (x * 120) / tickStep, Qt::NoModifier, Qt::Horizontal); - } else - event = new QWheelEvent(m_mousePos, m_mousePos, (x * 120) / tickStep, m_mouseButtons, Qt::NoModifier, Qt::Horizontal); + } else { + QPoint pixelDelta { }; + QPoint angleDelta { (x * 120) / tickStep, 0 }; + Qt::ScrollPhase phase = Qt::NoScrollPhase; + bool inverted = false; + event = new QWheelEvent(m_mousePos, globalPosition, pixelDelta, angleDelta, m_mouseButtons, Qt::NoModifier, phase, inverted); + } sendOrQueueEvent(event); } @@ -266,8 +278,13 @@ void EventSender::continuousMouseScrollBy(int x, int y) if (isGraphicsBased()) { event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel, m_mousePos, m_mousePos, (y * 120) / tickStep, Qt::NoModifier, Qt::Vertical); - } else - event = new QWheelEvent(m_mousePos, m_mousePos, (y * 120) / tickStep, m_mouseButtons, Qt::NoModifier, Qt::Vertical); + } else { + QPoint pixelDelta { }; + QPoint angleDelta { 0, (y * 120) / tickStep }; + Qt::ScrollPhase phase = Qt::NoScrollPhase; + bool inverted = false; + event = new QWheelEvent(m_mousePos, globalPosition, pixelDelta, angleDelta, m_mouseButtons, Qt::NoModifier, phase, inverted); + } sendOrQueueEvent(event); } @@ -447,11 +464,13 @@ void EventSender::addTouchPoint(int x, int y) const int id = m_touchPoints.isEmpty() ? 0 : m_touchPoints.last().id() + 1; const QPointF pos(x, y); QTouchEvent::TouchPoint point(id); - point.setPos(pos); - point.setStartPos(pos); - point.setState(Qt::TouchPointPressed); - if (!m_touchPointRadius.isNull()) - point.setRect(QRectF(pos - m_touchPointRadius, pos + m_touchPointRadius)); + QMutableEventPoint::setPosition(point, pos); + QMutableEventPoint::setScenePosition(point, pos); + QMutableEventPoint::setState(point, QEventPoint::Pressed); + + // FIXME: points no longer have rects? + //if (!m_touchPointRadius.isNull()) + // point.setRect(QRectF(pos - m_touchPointRadius, pos + m_touchPointRadius)); m_touchPoints.append(point); } @@ -462,10 +481,12 @@ void EventSender::updateTouchPoint(int index, int x, int y) const QPointF pos(x, y); QTouchEvent::TouchPoint &point = m_touchPoints[index]; - point.setPos(pos); - point.setState(Qt::TouchPointMoved); - if (!m_touchPointRadius.isNull()) - point.setRect(QRectF(pos - m_touchPointRadius, pos + m_touchPointRadius)); + QMutableEventPoint::setPosition(point, pos); + QMutableEventPoint::setState(point, QEventPoint::Updated); + + // FIXME: points no longer have rects? + //if (!m_touchPointRadius.isNull()) + // point.setRect(QRectF(pos - m_touchPointRadius, pos + m_touchPointRadius)); } void EventSender::setTouchModifier(const QString &modifier, bool enable) @@ -508,7 +529,7 @@ void EventSender::touchMove() void EventSender::touchEnd() { for (int i = 0; i < m_touchPoints.count(); ++i) - if (m_touchPoints[i].state() != Qt::TouchPointReleased) { + if (m_touchPoints[i].state() != QEventPoint::Released) { sendTouchEvent(QEvent::TouchUpdate); return; } @@ -535,7 +556,7 @@ void EventSender::releaseTouchPoint(int index) if (index < 0 || index >= m_touchPoints.count()) return; - m_touchPoints[index].setState(Qt::TouchPointReleased); + QMutableEventPoint::setState(m_touchPoints[index], QEventPoint::Released); } void EventSender::cancelTouchPoint(int index) @@ -548,22 +569,24 @@ void EventSender::cancelTouchPoint(int index) void EventSender::sendTouchEvent(QEvent::Type type) { - static QTouchDevice* device = 0; + static QPointingDevice* device = 0; if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); + QInputDevice::Capabilities capabilities = QInputDevice::Capability::Position + | QInputDevice::Capability::Area + | QInputDevice::Capability::NormalizedPosition; + device = new QPointingDevice(QLatin1String("touchscreen"), 0, QInputDevice::DeviceType::TouchScreen, + QPointingDevice::PointerType::Finger, capabilities, 5, 1); + QWindowSystemInterface::registerInputDevice(device); } - QTouchEvent event(type, device, m_touchModifiers); - event.setTouchPoints(m_touchPoints); + QTouchEvent event(type, device, m_touchModifiers, m_touchPoints); sendEvent(m_page, &event); QList::Iterator it = m_touchPoints.begin(); while (it != m_touchPoints.end()) { - if (it->state() == Qt::TouchPointReleased) + if (it->state() == QEventPoint::Released) it = m_touchPoints.erase(it); else { - it->setState(Qt::TouchPointStationary); + QMutableEventPoint::setState(*it, QEventPoint::Stationary); ++it; } } diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp index 76ada57522b8d..d94c942159ef0 100644 --- a/Tools/QtTestBrowser/launcherwindow.cpp +++ b/Tools/QtTestBrowser/launcherwindow.cpp @@ -629,11 +629,7 @@ void LauncherWindow::sendTouchEvent() const QPointingDevice *device = nullptr; Qt::KeyboardModifiers modifiers = Qt::NoModifier; - QList touchPoints; - for (const QMutableEventPoint & ep: m_touchPoints) { - touchPoints.append(ep); - } - QTouchEvent touchEv(type, device, modifiers, touchPoints); + QTouchEvent touchEv(type, device, modifiers, m_touchPoints); QCoreApplication::sendEvent(page(), &touchEv); // After sending the event, remove all touchpoints that were released @@ -679,7 +675,7 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) state = QEventPoint::Released; QPointF scenePosition = ev->scenePosition(); QPointF globalPosition = ev->globalPosition(); - QMutableEventPoint touchPoint(pointId, state, scenePosition, globalPosition); + QEventPoint touchPoint(pointId, state, scenePosition, globalPosition); //touchPoint.setPressure(1); // If the point already exists, update it. Otherwise create it. @@ -698,23 +694,18 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event) // If the keyboard point is already pressed, release it. // Otherwise create it and append to m_touchPoints. if (m_touchPoints.size() > 0 && m_touchPoints[0].id() == 1) { - m_touchPoints[0].setState(QEventPoint::Released); + QMutableEventPoint::setState(m_touchPoints[0], QEventPoint::Released); sendTouchEvent(); } else if (m_touchPoints.size() > 1 && m_touchPoints[1].id() == 1) { - m_touchPoints[1].setState(QEventPoint::Released); + QMutableEventPoint::setState(m_touchPoints[1], QEventPoint::Released); sendTouchEvent(); } else { - QMutableEventPoint touchPoint; - touchPoint.setState(QEventPoint::Pressed); - touchPoint.setId(1); - touchPoint.setScreenPos(QCursor::pos()); - touchPoint.setPos(m_view->mapFromGlobal(QCursor::pos())); - touchPoint.setPressure(1); + QEventPoint touchPoint(1, QEventPoint::Pressed, m_view->mapFromGlobal(QCursor::pos()), QCursor::pos()); m_touchPoints.append(touchPoint); sendTouchEvent(); // After sending the event, change the touchpoint state to stationary - m_touchPoints.last().setState(QEventPoint::Stationary); + QMutableEventPoint::setState(m_touchPoints.last(), QEventPoint::Stationary); } } diff --git a/Tools/QtTestBrowser/launcherwindow.h b/Tools/QtTestBrowser/launcherwindow.h index 4ee9858c2dc9e..b66015c74f32d 100644 --- a/Tools/QtTestBrowser/launcherwindow.h +++ b/Tools/QtTestBrowser/launcherwindow.h @@ -219,7 +219,7 @@ public Q_SLOTS: #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX) QNetworkReply* m_reply { nullptr }; #endif - QList m_touchPoints; + QList m_touchPoints; QList m_highlightedElements; bool m_touchMocking; From ec0a53e18eee3d3859a343d24bae546a92ec9d3f Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Fri, 6 Jan 2023 09:18:33 -0500 Subject: [PATCH 28/58] remove dependency on Qt6Core5Compat --- Source/WebCore/PlatformQt.cmake | 2 -- Source/WebCore/platform/qt/PasteboardQt.cpp | 5 +++-- Source/cmake/OptionsQt.cmake | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake index 0b8c9e909d02b..6e0254ee263e6 100644 --- a/Source/WebCore/PlatformQt.cmake +++ b/Source/WebCore/PlatformQt.cmake @@ -305,7 +305,6 @@ list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES ${Qt6Network_INCLUDE_DIRS} ${Qt6Network_PRIVATE_INCLUDE_DIRS} ${Qt6Sensors_INCLUDE_DIRS} - ${Qt6Core5Compat_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ) @@ -321,7 +320,6 @@ list(APPEND WebCore_LIBRARIES ${Qt6Gui_LIBRARIES} ${Qt6Network_LIBRARIES} ${Qt6Sensors_LIBRARIES} - ${Qt6Core5Compat_LIBRARIES} ${SQLITE_LIBRARIES} ${X11_X11_LIB} ${ZLIB_LIBRARIES} diff --git a/Source/WebCore/platform/qt/PasteboardQt.cpp b/Source/WebCore/platform/qt/PasteboardQt.cpp index b802c7daed214..6052a784c4978 100644 --- a/Source/WebCore/platform/qt/PasteboardQt.cpp +++ b/Source/WebCore/platform/qt/PasteboardQt.cpp @@ -42,8 +42,8 @@ #include #include #include +#include #include -#include #include namespace WebCore { @@ -333,7 +333,8 @@ String Pasteboard::readString(const String& type) return data->text(); QByteArray rawData = data->data(mimeType); - QString stringData = QTextCodec::codecForName("UTF-16")->toUnicode(rawData); + auto toUtf16 = QStringDecoder(QStringDecoder::Utf8); + QString stringData = toUtf16(rawData); return stringData; } diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index d63595d996954..57cb817449271 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -250,7 +250,7 @@ add_library(OpenGL::GL INTERFACE IMPORTED) set_target_properties(OpenGL::GL PROPERTIES IMPORTED_LOCATION "${OPENGL_LIBRARIES}") -find_package(Qt6 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Core5Compat) +find_package(Qt6 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui) message("OPENGL_FOUND: ${OPENGL_FOUND}") message("OPENGL_GLU_FOUND: ${OPENGL_GLU_FOUND}") message("OpenGL_OpenGL_FOUND: ${OpenGL_OpenGL_FOUND}") From f02ba5744c321e90f4d160b21a351253295e2d3f Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sat, 7 Jan 2023 13:04:24 -0500 Subject: [PATCH 29/58] implement stubbed RunLoop::TimerBase::secondsUntilFire --- Source/WTF/wtf/qt/RunLoopQt.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/WTF/wtf/qt/RunLoopQt.cpp b/Source/WTF/wtf/qt/RunLoopQt.cpp index e7695932e09c4..6de0c5d322d83 100644 --- a/Source/WTF/wtf/qt/RunLoopQt.cpp +++ b/Source/WTF/wtf/qt/RunLoopQt.cpp @@ -242,6 +242,12 @@ bool RunLoop::TimerBase::isActive() const return m_isActive; } +Seconds RunLoop::TimerBase::secondsUntilFire() const +{ + // FIXME: implement for WebKit + return 0_s; +} + #include "RunLoopQt.moc" } // namespace WTF From d058e04a5978ecd1e39898ab11e525f1b9941e88 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sat, 7 Jan 2023 13:05:23 -0500 Subject: [PATCH 30/58] qt tests moved to root-level tests; need to eventually get rid of Source/WebKitLegacy/qt/tests --- Source/WebKitLegacy/PlatformQt.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/WebKitLegacy/PlatformQt.cmake b/Source/WebKitLegacy/PlatformQt.cmake index f772f58975a36..337e53b1e6880 100644 --- a/Source/WebKitLegacy/PlatformQt.cmake +++ b/Source/WebKitLegacy/PlatformQt.cmake @@ -804,10 +804,6 @@ if (COMPILER_IS_GCC_OR_CLANG) ) endif () -if (ENABLE_API_TESTS) - add_subdirectory(qt/tests) -endif () - if (ENABLE_WEBKIT) add_subdirectory(qt/declarative) endif () From e480f32edd9dbcf3b33c175c1d507ce81e577fc9 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sat, 7 Jan 2023 13:38:01 -0500 Subject: [PATCH 31/58] make StateMachine optional now that it has moved out of qt core --- Source/cmake/OptionsQt.cmake | 3 ++- Tools/QtTestBrowser/CMakeLists.txt | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index 57cb817449271..7fab089a6dd84 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -529,7 +529,8 @@ if (ENABLE_API_TESTS OR ENABLE_TEST_SUPPORT) endif () if (ENABLE_WEBKIT_LEGACY) - list(APPEND QT_REQUIRED_COMPONENTS + # Without StateMachine, some animations will be disabled + list(APPEND QT_OPTIONAL_COMPONENTS StateMachine ) endif () diff --git a/Tools/QtTestBrowser/CMakeLists.txt b/Tools/QtTestBrowser/CMakeLists.txt index 56a956d8ef3c5..4e670650ccaf0 100644 --- a/Tools/QtTestBrowser/CMakeLists.txt +++ b/Tools/QtTestBrowser/CMakeLists.txt @@ -70,6 +70,10 @@ if (ENABLE_TEST_SUPPORT) add_definitions(-DHAVE_QTTESTSUPPORT) endif () +if (NOT TARGET Qt6::StateMachine) + add_definitions(-DQT_NO_ANIMATION) +endif () + include_directories(${QtTestBrowser_INCLUDE_DIRECTORIES}) include_directories(SYSTEM ${QtTestBrowser_SYSTEM_INCLUDE_DIRECTORIES}) add_executable(QtTestBrowser ${QtTestBrowser_SOURCES}) From 962beed79eafdaee5c918ccdcb77f9dc39dfbac4 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sat, 7 Jan 2023 13:38:28 -0500 Subject: [PATCH 32/58] fix compilation errors in tests (they do not pass yet) --- Tools/TestWebKitAPI/Utilities.cpp | 2 + tests/webkitwidgets/hybridPixmap/widget.cpp | 10 +- .../qgraphicswebview/tst_qgraphicswebview.cpp | 11 +- .../qobjectbridge/tst_qobjectbridge.cpp | 50 +- .../qwebelement/tst_qwebelement.cpp | 4 +- .../webkitwidgets/qwebframe/tst_qwebframe.cpp | 28 +- tests/webkitwidgets/qwebpage/tst_qwebpage.cpp | 431 +++--------------- .../tst_qwebsecurityorigin.cpp | 26 +- tests/webkitwidgets/qwebview/tst_qwebview.cpp | 40 +- 9 files changed, 109 insertions(+), 493 deletions(-) diff --git a/Tools/TestWebKitAPI/Utilities.cpp b/Tools/TestWebKitAPI/Utilities.cpp index f1c0edbea8759..d532ebab79959 100644 --- a/Tools/TestWebKitAPI/Utilities.cpp +++ b/Tools/TestWebKitAPI/Utilities.cpp @@ -32,6 +32,7 @@ namespace TestWebKitAPI::Util { #if !PLATFORM(COCOA) +#if !PLATFORM(QT) void run(bool* done) { while (!*done) @@ -43,6 +44,7 @@ void spinRunLoop(uint64_t count) while (count--) RunLoop::current().cycle(); } +#endif bool runFor(bool* done, Seconds duration) { diff --git a/tests/webkitwidgets/hybridPixmap/widget.cpp b/tests/webkitwidgets/hybridPixmap/widget.cpp index 6c4d2cd494961..c26ccaa92966a 100644 --- a/tests/webkitwidgets/hybridPixmap/widget.cpp +++ b/tests/webkitwidgets/hybridPixmap/widget.cpp @@ -47,11 +47,11 @@ void Widget::start() void Widget::completeTest() { - QCOMPARE(ui->lbl1->pixmap()->size(), ui->lbl2->size()); - QCOMPARE(ui->lbl3->size(), ui->lbl4->pixmap()->size()); + QCOMPARE(ui->lbl1->pixmap().size(), ui->lbl2->size()); + QCOMPARE(ui->lbl3->size(), ui->lbl4->pixmap().size()); QCOMPARE(ui->lbl2->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img1").evaluateJavaScript("this.width").toInt()); QCOMPARE(ui->lbl3->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img2").evaluateJavaScript("this.width").toInt()); - emit testComplete(); + Q_EMIT testComplete(); } void Widget::setPixmap(const QPixmap& p) @@ -111,13 +111,13 @@ void Widget::compare(const QVariant& a, const QVariant& b) void Widget::imageSlot(const QImage& img) { QCOMPARE(img.size(), ui->lbl3->size()); - emit pixmapSignal(QPixmap::fromImage(img)); + Q_EMIT pixmapSignal(QPixmap::fromImage(img)); } void Widget::pixmapSlot(const QPixmap& pxm) { QCOMPARE(pxm.size(), ui->lbl2->size()); - emit imageSignal(ui->lbl4->pixmap()->toImage()); + Q_EMIT imageSignal(ui->lbl4->pixmap().toImage()); } void Widget::randomSlot(const QPixmap& pxm) diff --git a/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp b/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp index 0e8577d8c6fcc..8155112012e19 100644 --- a/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/tests/webkitwidgets/qgraphicswebview/tst_qgraphicswebview.cpp @@ -286,12 +286,12 @@ void tst_QGraphicsWebView::microFocusCoordinates() page->mainFrame()->setFocus(); - QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImCursorRectangle); QVERIFY(initialMicroFocus.isValid()); page->mainFrame()->scroll(0,300); - QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImCursorRectangle); QVERIFY(currentMicroFocus.isValid()); QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-300)), currentMicroFocus.toRect()); @@ -506,30 +506,25 @@ void tst_QGraphicsWebView::renderHints() QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::Antialiasing, true); QVERIFY(webView.renderHints() & QPainter::Antialiasing); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::Antialiasing, false); QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::SmoothPixmapTransform, true); QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::SmoothPixmapTransform, false); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); } class GraphicsView : public QGraphicsView { @@ -645,7 +640,7 @@ public Q_SLOTS: void receiveResize(int width, int height) { m_size = QSize(width, height); - emit resized(); + Q_EMIT resized(); } QSize size() const diff --git a/tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp b/tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp index 232c148309e90..41b7706c2c9d2 100644 --- a/tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp +++ b/tests/webkitwidgets/qobjectbridge/tst_qobjectbridge.cpp @@ -397,7 +397,7 @@ class MyQObject : public QObject { Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString& arg2 = QString()) { m_qtFunctionInvoked = 47; - m_actuals << QVariant::fromValue(arg1) << qVariantFromValue(arg2); + m_actuals << QVariant::fromValue(arg1) << QVariant::fromValue(arg2); } Q_INVOKABLE QObject& myInvokableReturningRef() { @@ -424,23 +424,23 @@ class MyQObject : public QObject { void emitMySignal() { - emit mySignal(); + Q_EMIT mySignal(); } void emitMySignalWithIntArg(int arg) { - emit mySignalWithIntArg(arg); + Q_EMIT mySignalWithIntArg(arg); } void emitMySignal2(bool arg) { - emit mySignal2(arg); + Q_EMIT mySignal2(arg); } void emitMySignal2() { - emit mySignal2(); + Q_EMIT mySignal2(); } void emitMySignalWithDateTimeArg(QDateTime dt) { - emit mySignalWithDateTimeArg(dt); + Q_EMIT mySignalWithDateTimeArg(dt); } public Q_SLOTS: @@ -641,7 +641,6 @@ private Q_SLOTS: void qObjectWrapperWithSameIdentity(); void introspectQtMethods_data(); void introspectQtMethods(); - void scriptablePlugin(); void exceptionInSlot(); private: @@ -1008,10 +1007,6 @@ void tst_QObjectBridge::getSetChildren() QCOMPARE(evalJS("typeof myObject.child == 'undefined'"), sTrue); } -Q_DECLARE_METATYPE(QVector) -Q_DECLARE_METATYPE(QVector) -Q_DECLARE_METATYPE(QVector) - void tst_QObjectBridge::callQtInvokable() { qRegisterMetaType(); @@ -2196,15 +2191,6 @@ void tst_QObjectBridge::webElementSlotOnly() QCOMPARE(evalJS("myWebElementSlotObject.tagName"), QString("BODY")); } -class TestPluginWidget : public QWidget { - Q_OBJECT -public: - TestPluginWidget() { } - -public Q_SLOTS: - int slotWithReturnValue() { return 42; } -}; - class TestWebPage : public QWebPage { Q_OBJECT public: @@ -2214,32 +2200,8 @@ class TestWebPage : public QWebPage { { } int creationCount; - -protected: - virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) - { - creationCount++; - return new TestPluginWidget; - } }; -void tst_QObjectBridge::scriptablePlugin() -{ -//#if !PLUGIN_VIEW_IS_BROKEN - QWebView view; - TestWebPage* page = new TestWebPage; - view.setPage(page); - page->setParent(&view); - view.settings()->setAttribute(QWebSettings::PluginsEnabled, true); - - page->mainFrame()->setHtml(""); - QCOMPARE(page->creationCount, 1); - - QVariant result = page->mainFrame()->evaluateJavaScript("document.querySelector(\"object\").slotWithReturnValue()"); - QCOMPARE(result.toString(), QLatin1String("42")); -//#endif -} - class WebPageWithConsoleCapture : public QWebPage { public: diff --git a/tests/webkitwidgets/qwebelement/tst_qwebelement.cpp b/tests/webkitwidgets/qwebelement/tst_qwebelement.cpp index 4ca5fe5f96c46..8470b32634285 100644 --- a/tests/webkitwidgets/qwebelement/tst_qwebelement.cpp +++ b/tests/webkitwidgets/qwebelement/tst_qwebelement.cpp @@ -284,7 +284,7 @@ void tst_QWebElement::iteration() QList referenceList = paras.toList(); QList foreachList; - foreach(QWebElement p, paras) { + for(QWebElement p : paras) { foreachList.append(p); } QVERIFY(foreachList.count() == 2); @@ -346,7 +346,7 @@ void tst_QWebElement::foreachManipulation() m_mainFrame->setHtml(html); QWebElement body = m_mainFrame->documentElement(); - foreach(QWebElement p, body.findAll("p")) { + for(QWebElement p : body.findAll("p")) { p.setInnerXml("
foo
bar
"); } diff --git a/tests/webkitwidgets/qwebframe/tst_qwebframe.cpp b/tests/webkitwidgets/qwebframe/tst_qwebframe.cpp index d635f8e2c855b..e8c1be46ca8df 100644 --- a/tests/webkitwidgets/qwebframe/tst_qwebframe.cpp +++ b/tests/webkitwidgets/qwebframe/tst_qwebframe.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #ifndef QT_NO_OPENSSL #include #endif @@ -243,14 +243,14 @@ class FakeReply : public QNetworkReply { private Q_SLOTS: void continueRedirect() { - emit metaDataChanged(); - emit finished(); + Q_EMIT metaDataChanged(); + Q_EMIT finished(); } void continueError() { - emit error(this->error()); - emit finished(); + Q_EMIT errorOccurred(this->error()); + Q_EMIT finished(); } }; @@ -271,7 +271,7 @@ class FakeNetworkManager : public QNetworkAccessManager { if (url == "qrc:/fake-ssl-error.html") { FakeReply* reply = new FakeReply(request, this); QList errors; - emit sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError)); + Q_EMIT sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError)); return reply; } #endif @@ -617,7 +617,7 @@ void tst_QWebFrame::popupFocus() // open the popup by clicking. check if focus is on the popup const QWebElement webCombo = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("select[name=select]")); - QTest::mouseClick(&view, Qt::LeftButton, 0, webCombo.geometry().center()); + QTest::mouseClick(&view, Qt::LeftButton, { }, webCombo.geometry().center()); QComboBox* combo = view.findChild(); QVERIFY(combo != 0); @@ -647,7 +647,7 @@ void tst_QWebFrame::inputFieldFocus() bool autoSipEnabled = qApp->autoSipEnabled(); qApp->setAutoSipEnabled(false); const QWebElement inputElement = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("input[type=text]")); - QTest::mouseClick(&view, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&view, Qt::LeftButton, { }, inputElement.geometry().center()); m_inputFieldsTestView = &view; view.installEventFilter( this ); QTest::qWait(delay); @@ -898,25 +898,20 @@ void tst_QWebFrame::renderHints() page.mainFrame()->render(&painter); QVERIFY(!(buffer.renderHints() & QPainter::TextAntialiasing)); QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); painter.setRenderHint(QPainter::TextAntialiasing, true); page.mainFrame()->render(&painter); QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); page.mainFrame()->render(&painter); QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); - painter.setRenderHint(QPainter::HighQualityAntialiasing, true); page.mainFrame()->render(&painter); QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(buffer.renderHints() & QPainter::HighQualityAntialiasing); } void tst_QWebFrame::scrollPosition() @@ -1056,14 +1051,11 @@ void tst_QWebFrame::setContent_data() QString str = QString::fromUtf8("ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει"); QTest::newRow("UTF-8 plain text") << "text/plain; charset=utf-8" << str.toUtf8() << str; - QTextCodec *utf16 = QTextCodec::codecForName("UTF-16"); - if (utf16) - QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << utf16->fromUnicode(str) << str; + auto toUtf16 = QStringEncoder(QStringEncoder::Utf16); + QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << toUtf16(str) << str; str = QString::fromUtf8("Une chaîne de caractères à sa façon."); QTest::newRow("latin-1 plain text") << "text/plain; charset=iso-8859-1" << str.toLatin1() << str; - - } void tst_QWebFrame::setContent() diff --git a/tests/webkitwidgets/qwebpage/tst_qwebpage.cpp b/tests/webkitwidgets/qwebpage/tst_qwebpage.cpp index 69bb035e0d311..ceaf277577120 100644 --- a/tests/webkitwidgets/qwebpage/tst_qwebpage.cpp +++ b/tests/webkitwidgets/qwebpage/tst_qwebpage.cpp @@ -28,8 +28,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -137,13 +136,6 @@ private Q_SLOTS: void contextMenuCrash(); void updatePositionDependentActionsCrash(); void database(); - void createPluginWithPluginsEnabled(); - void createPluginWithPluginsDisabled(); - void destroyPlugin_data(); - void destroyPlugin(); - void createViewlessPlugin_data(); - void createViewlessPlugin(); - void graphicsWidgetPlugin(); #ifdef HAVE_QTTESTSUPPORT void multiplePageGroupsAndLocalStorage(); @@ -157,10 +149,6 @@ private Q_SLOTS: void requestCache(); void loadCachedPage(); -#ifdef HAVE_QTTESTSUPPORT - void protectBindingsRuntimeObjectsFromCollector(); -#endif - void localURLSchemes(); void testOptionalJSObjects(); void testLocalStorageVisibility(); @@ -317,41 +305,47 @@ void tst_QWebPage::domainSpecificKeyEvent() "window.onkeyup = keyEvent; window.onkeypress = keyEvent; window.onkeydown = keyEvent;" "test")); + { // Enable settings to use nativeVirtualKey as DOM key value. webView.page()->setProperty("_q_useNativeVirtualKeyAsDOMKey", true); // Simulate domain specific keyevent to WebKit by passing it as nativeVirtualKey in QKeyEvent. // Qt::Key_Pause --> 0x51 QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); QApplication::sendEvent(&webView, &keyEvent); - keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); - QApplication::sendEvent(&webView, &keyEvent); + QKeyEvent releaseKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); + QApplication::sendEvent(&webView, &releaseKeyEvent); const QLatin1String expectedReceivedKeyArray1("keydown:81:0,keyup:81:0"); QString receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); QVERIFY(receivedKeyArray == expectedReceivedKeyArray1); + } + { // Normal PC keyboard key converstion flow shouldn't be affected when sending nativeVirtual key as 0. // Qt::Key_Pause --> VK_PAUSE(0x13) webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray = new Array()")); // Reset - keyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); - QApplication::sendEvent(&webView, &keyEvent); - keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); + QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); QApplication::sendEvent(&webView, &keyEvent); + QKeyEvent releaseKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 0, 0); + QApplication::sendEvent(&webView, &releaseKeyEvent); const QLatin1String expectedReceivedKeyArray2("keydown:19:0,keyup:19:0"); - receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); + QString receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); QVERIFY(receivedKeyArray == expectedReceivedKeyArray2); + } + { // Negative case. // Disable settings to use nativeVirtualKey as DOM key value. webView.page()->setProperty("_q_useNativeVirtualKeyAsDOMKey", false); // Qt::Key_Pause --> VK_PAUSE(0x13) webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray = new Array()")); // Reset - keyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); - QApplication::sendEvent(&webView, &keyEvent); - keyEvent = QKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); + QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); QApplication::sendEvent(&webView, &keyEvent); + QKeyEvent releaseKeyEvent(QEvent::KeyRelease, Qt::Key_Pause, Qt::NoModifier, 0, 81, 0); + QApplication::sendEvent(&webView, &releaseKeyEvent); const QLatin1String expectedReceivedKeyArray3("keydown:19:0,keyup:19:0"); - receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); + QString receivedKeyArray = webView.page()->mainFrame()->evaluateJavaScript(QLatin1String("receivedKeyArray")).toStringList().join(","); QVERIFY(receivedKeyArray == expectedReceivedKeyArray3); + } } class JSTestPage : public QWebPage @@ -727,7 +721,7 @@ void tst_QWebPage::updatePositionDependentActionsCrash() QPoint pos(0, 0); view.page()->updatePositionDependentActions(pos); QMenu* contextMenu = 0; - foreach (QObject* child, view.children()) { + for (QObject* child : view.children()) { contextMenu = qobject_cast(child); if (contextMenu) break; @@ -745,7 +739,7 @@ void tst_QWebPage::contextMenuCrash() view.page()->swallowContextMenuEvent(&event); view.page()->updatePositionDependentActions(pos); QMenu* contextMenu = 0; - foreach (QObject* child, view.children()) { + for (QObject* child : view.children()) { contextMenu = qobject_cast(child); if (contextMenu) break; @@ -808,305 +802,6 @@ void tst_QWebPage::database() QVERIFY(!origin.databases().size()); } -class PluginPage : public QWebPage -{ -public: - PluginPage(QObject *parent = 0) - : QWebPage(parent) {} - - struct CallInfo - { - CallInfo(const QString &c, const QUrl &u, - const QStringList &pn, const QStringList &pv, - QObject *r) - : classid(c), url(u), paramNames(pn), - paramValues(pv), returnValue(r) - {} - QString classid; - QUrl url; - QStringList paramNames; - QStringList paramValues; - QObject *returnValue; - }; - - QList calls; - -protected: - virtual QObject *createPlugin(const QString &classid, const QUrl &url, - const QStringList ¶mNames, - const QStringList ¶mValues) - { - QObject *result = 0; - if (classid == "pushbutton") - result = new QPushButton(); -#ifndef QT_NO_INPUTDIALOG - else if (classid == "lineedit") - result = new QLineEdit(); -#endif - else if (classid == "graphicswidget") - result = new QGraphicsWidget(); - if (result) - result->setObjectName(classid); - calls.append(CallInfo(classid, url, paramNames, paramValues, result)); - return result; - } -}; - -static void createPlugin(QWebView *view) -{ - QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(view); - view->setPage(newPage); - - // type has to be application/x-qt-plugin - view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - QCOMPARE(newPage->calls.count(), 0); - - view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(newPage->calls.count(), 1); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QPushButton")); - } - // test JS bindings - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("document.getElementById('mybutton').toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mybutton.objectName").toString(), - QString::fromLatin1("string")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.objectName").toString(), - QString::fromLatin1("pushbutton")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mybutton.clicked").toString(), - QString::fromLatin1("function")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.clicked.toString()").toString(), - QString::fromLatin1("function clicked() {\n [native code]\n}")); - - view->setHtml(QString("" - "" - "" - "
"), QUrl("http://foo.bar.baz")); - QTRY_COMPARE(loadSpy.count(), 3); - QCOMPARE(newPage->calls.count(), 2); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("lineedit")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("lineedit")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("myedit")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QLineEdit")); - } - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QPushButton")); - } -} - -void tst_QWebPage::graphicsWidgetPlugin() -{ - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - QGraphicsWebView webView; - - QSignalSpy loadSpy(&webView, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(&webView); - webView.setPage(newPage); - - // type has to be application/x-qt-plugin - webView.setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - QCOMPARE(newPage->calls.count(), 0); - - webView.setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(newPage->calls.count(), 1); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("graphicswidget")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("graphicswidget")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mygraphicswidget")); - QVERIFY(ci.returnValue); - QVERIFY(ci.returnValue->inherits("QGraphicsWidget")); - } - // test JS bindings - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("document.getElementById('mygraphicswidget').toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mygraphicswidget.objectName").toString(), - QString::fromLatin1("string")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.objectName").toString(), - QString::fromLatin1("graphicswidget")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("typeof mygraphicswidget.geometryChanged").toString(), - QString::fromLatin1("function")); - QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mygraphicswidget.geometryChanged.toString()").toString(), - QString::fromLatin1("function geometryChanged() {\n [native code]\n}")); -} - -void tst_QWebPage::createPluginWithPluginsEnabled() -{ - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - createPlugin(m_view); -} - -void tst_QWebPage::createPluginWithPluginsDisabled() -{ - // Qt Plugins should be loaded by QtWebKit even when PluginsEnabled is - // false. The client decides whether a Qt plugin is enabled or not when - // it decides whether or not to instantiate it. - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, false); - createPlugin(m_view); -} - -// Standard base class for template PluginTracerPage. In tests it is used as interface. -class PluginCounterPage : public QWebPage { -public: - int m_count; - QPointer m_widget; - QObject* m_pluginParent; - PluginCounterPage(QObject* parent = 0) - : QWebPage(parent) - , m_count(0) - , m_pluginParent(0) - { - settings()->setAttribute(QWebSettings::PluginsEnabled, true); - } - ~PluginCounterPage() - { - if (m_pluginParent) - m_pluginParent->deleteLater(); - } -}; - -template -class PluginTracerPage : public PluginCounterPage { -public: - PluginTracerPage(QObject* parent = 0) - : PluginCounterPage(parent) - { - // this is a dummy parent object for the created plugin - m_pluginParent = new T; - } - virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) - { - m_count++; - m_widget = new T; - // need a cast to the specific type, as QObject::setParent cannot be called, - // because it is not virtual. Instead it is necesary to call QWidget::setParent, - // which also takes a QWidget* instead of a QObject*. Therefore we need to - // upcast to T*, which is a QWidget. - static_cast(m_widget.data())->setParent(static_cast(m_pluginParent)); - return m_widget.data(); - } -}; - -class PluginFactory { -public: - enum FactoredType {QWidgetType, QGraphicsWidgetType}; - static PluginCounterPage* create(FactoredType type, QObject* parent = 0) - { - PluginCounterPage* result = 0; - switch (type) { - case QWidgetType: - result = new PluginTracerPage(parent); - break; - case QGraphicsWidgetType: - result = new PluginTracerPage(parent); - break; - default: {/*Oops*/}; - } - return result; - } - - static void prepareTestData() - { - QTest::addColumn("type"); - QTest::newRow("QWidget") << (int)PluginFactory::QWidgetType; - QTest::newRow("QGraphicsWidget") << (int)PluginFactory::QGraphicsWidgetType; - } -}; - -void tst_QWebPage::destroyPlugin_data() -{ - PluginFactory::prepareTestData(); -} - -void tst_QWebPage::destroyPlugin() -{ - QFETCH(int, type); - PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type, m_view); - m_view->setPage(page); - - // we create the plugin, so the widget should be constructed - QString content(""); - m_view->setHtml(content); - QVERIFY(page->m_widget); - QCOMPARE(page->m_count, 1); - - // navigate away, the plugin widget should be destructed - m_view->setHtml("Hi"); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!page->m_widget); -} - -void tst_QWebPage::createViewlessPlugin_data() -{ - PluginFactory::prepareTestData(); -} - -void tst_QWebPage::createViewlessPlugin() -{ - QFETCH(int, type); - PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type); - QString content(""); - page->mainFrame()->setHtml(content); - QCOMPARE(page->m_count, 1); - QVERIFY(page->m_widget); - QVERIFY(page->m_pluginParent); - QVERIFY(page->m_widget.data()->parent() == page->m_pluginParent); - delete page; - -} - #ifdef HAVE_QTTESTSUPPORT void tst_QWebPage::multiplePageGroupsAndLocalStorage() { @@ -1192,8 +887,7 @@ void tst_QWebPage::cursorMovements() page->mainFrame()->evaluateJavaScript(script); QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); - QRegExp regExp(" style=\".*\""); - regExp.setMinimal(true); + QRegularExpression regExp(" style=\"(.*?)\""); QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("

The quick brown fox

")); // these actions must exist @@ -1425,8 +1119,7 @@ void tst_QWebPage::textSelection() "getSelection().addRange(range);"; page->mainFrame()->evaluateJavaScript(selectScript); QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); - QRegExp regExp(" style=\".*\""); - regExp.setMinimal(true); + QRegularExpression regExp(" style=\"(.*?)\""); QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("

The quick brown fox

")); // Make sure hasSelection returns true, since there is selected text now... @@ -1660,7 +1353,7 @@ void tst_QWebPage::backActionUpdate() QTRY_COMPARE(loadSpy.count(), 1); QEXPECT_FAIL("", "https://github.com/qtwebkit/qtwebkit/issues/913", Continue); QVERIFY(!action->isEnabled()); - QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(10, 10)); + QTest::mouseClick(&view, Qt::LeftButton, { }, QPoint(10, 10)); QTRY_COMPARE(loadSpy.count(), 2); QVERIFY(action->isEnabled()); @@ -1793,7 +1486,7 @@ void tst_QWebPage::inputMethods() QVERIFY(testContext.isInputPanelVisible()); //ImMicroFocus - QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus); + QVariant variant = page->inputMethodQuery(Qt::ImCursorRectangle); QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft())); // We assigned the serif font famility to be the same as the fixef font family. @@ -2471,30 +2164,6 @@ void tst_QWebPage::inputMethodsTextFormat() delete view; } -#ifdef HAVE_QTTESTSUPPORT -void tst_QWebPage::protectBindingsRuntimeObjectsFromCollector() -{ - QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(m_view); - m_view->setPage(newPage); - - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - - m_view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - - newPage->mainFrame()->evaluateJavaScript("function testme(text) { var lineedit = document.getElementById('mylineedit'); lineedit.setText(text); lineedit.selectAll(); }"); - - newPage->mainFrame()->evaluateJavaScript("testme('foo')"); - - DumpRenderTreeSupportQt::garbageCollectorCollect(); - - // don't crash! - newPage->mainFrame()->evaluateJavaScript("testme('bar')"); -} -#endif - void tst_QWebPage::localURLSchemes() { int i = QWebSecurityOrigin::localSchemes().size(); @@ -2835,8 +2504,6 @@ void tst_QWebPage::screenshot_data() { QTest::addColumn("html"); QTest::newRow("WithoutPlugin") << "text"; - QTest::newRow("WindowedPlugin") << QString("text"); - QTest::newRow("WindowlessPlugin") << QString("text"); } void tst_QWebPage::screenshot() @@ -2848,7 +2515,6 @@ void tst_QWebPage::screenshot() QFETCH(QString, html); QWebPage* page = new QWebPage; - page->settings()->setAttribute(QWebSettings::PluginsEnabled, true); QWebFrame* mainFrame = page->mainFrame(); mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR)); ::waitForSignal(mainFrame, SIGNAL(loadFinished(bool)), 2000); @@ -3065,7 +2731,7 @@ void tst_QWebPage::findText() QVERIFY(m_page->selectedText().isEmpty()); QVERIFY(m_page->selectedHtml().isEmpty()); QStringList words = (QStringList() << "foo" << "bar"); - foreach (QString subString, words) { + for (QString subString : words) { m_page->findText(subString, QWebPage::FindWrapsAroundDocument); QCOMPARE(m_page->selectedText(), subString); QVERIFY(m_page->selectedHtml().contains(subString)); @@ -3410,38 +3076,49 @@ void tst_QWebPage::renderOnRepaintRequestedShouldNotRecurse() QVERIFY(::waitForSignal(&r, SIGNAL(finished()))); } -class SpyForLoadSignalsOrder : public QStateMachine { +class SpyForLoadSignalsOrder : public QObject { Q_OBJECT public: - SpyForLoadSignalsOrder(QWebPage* page, QObject* parent = 0) - : QStateMachine(parent) + SpyForLoadSignalsOrder(QWebPage* page, QObject* parent = 0) : QObject(parent) { - connect(page, SIGNAL(loadProgress(int)), SLOT(onLoadProgress(int))); - - QState* waitingForLoadStarted = new QState(this); - QState* waitingForLastLoadProgress = new QState(this); - QState* waitingForLoadFinished = new QState(this); - QFinalState* final = new QFinalState(this); + connect(page, &QWebPage::loadStarted, this, &SpyForLoadSignalsOrder::onLoadStarted); + connect(page, &QWebPage::loadProgress, this, &SpyForLoadSignalsOrder::onLoadProgress); + connect(page, &QWebPage::loadFinished, this, &SpyForLoadSignalsOrder::onLoadFinished); + } - waitingForLoadStarted->addTransition(page, SIGNAL(loadStarted()), waitingForLastLoadProgress); - waitingForLastLoadProgress->addTransition(this, SIGNAL(lastLoadProgress()), waitingForLoadFinished); - waitingForLoadFinished->addTransition(page, SIGNAL(loadFinished(bool)), final); + enum class State { WaitingForLoadStarted, WaitingForLastLoadProgress, WaitingForLoadFinished, Finished }; + State currentState = State::WaitingForLoadStarted; - setInitialState(waitingForLoadStarted); - start(); - } bool isFinished() const { - return !isRunning(); + return currentState == State::Finished; } + public Q_SLOTS: + void onLoadStarted() + { + QVERIFY(currentState == State::WaitingForLoadStarted); + currentState = State::WaitingForLastLoadProgress; + Q_EMIT started(); + } + void onLoadProgress(int progress) { - if (progress == 100) - emit lastLoadProgress(); + QVERIFY(currentState == State::WaitingForLastLoadProgress); + + if (progress < 100) + currentState = State::WaitingForLastLoadProgress; + else + currentState = State::WaitingForLoadFinished; + } + + void onLoadFinished() + { + QVERIFY(currentState == State::WaitingForLoadFinished); + currentState = State::Finished; } Q_SIGNALS: - void lastLoadProgress(); + void started(); }; void tst_QWebPage::loadSignalsOrder_data() diff --git a/tests/webkitwidgets/qwebsecurityorigin/tst_qwebsecurityorigin.cpp b/tests/webkitwidgets/qwebsecurityorigin/tst_qwebsecurityorigin.cpp index 225c42d0afd09..f3d9e969aae0f 100644 --- a/tests/webkitwidgets/qwebsecurityorigin/tst_qwebsecurityorigin.cpp +++ b/tests/webkitwidgets/qwebsecurityorigin/tst_qwebsecurityorigin.cpp @@ -32,11 +32,11 @@ class tst_QWebSecurityOrigin : public QObject { tst_QWebSecurityOrigin(); virtual ~tst_QWebSecurityOrigin(); -private slots: +private Q_SLOTS: void init(); void cleanup(); - void whiteList_data(); - void whiteList(); + void allowList_data(); + void allowList(); private: QWebView* m_view { nullptr }; QWebPage* m_page { nullptr }; @@ -61,7 +61,7 @@ void tst_QWebSecurityOrigin::cleanup() delete m_view; } -void tst_QWebSecurityOrigin::whiteList_data() +void tst_QWebSecurityOrigin::allowList_data() { QTest::addColumn("source"); QTest::addColumn("scheme"); @@ -114,16 +114,16 @@ class CannedResponseNetworkReply: public QNetworkReply { return m_buffer.bytesAvailable(); } -private slots: +private Q_SLOTS: void emitReadyRead() { - emit readyRead(); + Q_EMIT readyRead(); } void emitReadChannelFinished() { - emit readChannelFinished(); - emit finished(); + Q_EMIT readChannelFinished(); + Q_EMIT finished(); } void abort() { }; @@ -134,8 +134,8 @@ private slots: setError(QNetworkReply::NoError, ""); setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200); setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, QString("Ok").toLatin1()); - emit metaDataChanged(); - emit readyRead(); + Q_EMIT metaDataChanged(); + Q_EMIT readyRead(); } public: QBuffer m_buffer; @@ -154,7 +154,7 @@ class CannedResponseNetworkAccessManager: public QNetworkAccessManager { static const char cannedResponse[] = "Test"; -void tst_QWebSecurityOrigin::whiteList() +void tst_QWebSecurityOrigin::allowList() { QFETCH(QString, source); QFETCH(QString, scheme); @@ -179,9 +179,9 @@ void tst_QWebSecurityOrigin::whiteList() m_view->page()->setNetworkAccessManager(&manager); QString testJS="runTest(\"" + testUrl + "\")"; QCOMPARE(m_view->page()->mainFrame()->evaluateJavaScript(testJS), QVariant(successBeforeAdd)); - origin->addAccessWhitelistEntry(scheme, host, subdomainSetting); + origin->addAccessAllowlistEntry(scheme, host, subdomainSetting); QCOMPARE(m_view->page()->mainFrame()->evaluateJavaScript(testJS), QVariant(successAfterAdd)); - origin->removeAccessWhitelistEntry(scheme, host, subdomainSetting); + origin->removeAccessAllowlistEntry(scheme, host, subdomainSetting); QCOMPARE(m_view->page()->mainFrame()->evaluateJavaScript(testJS), QVariant(successAfterRemove)); m_view->page()->setNetworkAccessManager(0); } diff --git a/tests/webkitwidgets/qwebview/tst_qwebview.cpp b/tests/webkitwidgets/qwebview/tst_qwebview.cpp index e793d3fbf786b..8805f01d42e1f 100644 --- a/tests/webkitwidgets/qwebview/tst_qwebview.cpp +++ b/tests/webkitwidgets/qwebview/tst_qwebview.cpp @@ -92,30 +92,25 @@ void tst_QWebView::renderHints() QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::Antialiasing, true); QVERIFY(webView.renderHints() & QPainter::Antialiasing); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::Antialiasing, false); QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::SmoothPixmapTransform, true); QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::SmoothPixmapTransform, false); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); } void tst_QWebView::getWebKitVersion() @@ -127,8 +122,6 @@ void tst_QWebView::reusePage_data() { QTest::addColumn("html"); QTest::newRow("WithoutPlugin") << "text"; - QTest::newRow("WindowedPlugin") << QString("text"); - QTest::newRow("WindowlessPlugin") << QString("text"); } void tst_QWebView::reusePage() @@ -142,13 +135,8 @@ void tst_QWebView::reusePage() QWebView* view1 = new QWebView; QPointer page = new QWebPage; view1->setPage(page.data()); - page.data()->settings()->setAttribute(QWebSettings::PluginsEnabled, true); QWebFrame* mainFrame = page.data()->mainFrame(); mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR)); - if (html.contains("")) { - // some reasonable time for the PluginStream to feed test.swf to flash and start painting - waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000); - } view1->show(); QTest::qWaitForWindowExposed(view1); @@ -222,12 +210,12 @@ void tst_QWebView::microFocusCoordinates() page->mainFrame()->setFocus(); - QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImCursorRectangle); QVERIFY(initialMicroFocus.isValid()); page->mainFrame()->scroll(0,50); - QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus); + QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImCursorRectangle); QVERIFY(currentMicroFocus.isValid()); QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-50)), currentMicroFocus.toRect()); @@ -248,61 +236,61 @@ void tst_QWebView::focusInputTypes() // 'text' type QWebElement inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); QVERIFY(webView.inputMethodHints() == Qt::ImhNone); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'tel' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=tel]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhDialableCharactersOnly); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'number' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=number]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhDigitsOnly); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'email' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=email]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhEmailCharactersOnly); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'url' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=url]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhUrlCharactersOnly); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'text' type inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); QVERIFY(webView.inputMethodHints() == Qt::ImhNone); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); VERIFY_INPUTMETHOD_HINTS(webView.inputMethodHints(), Qt::ImhHiddenText); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'text area' field inputElement = mainFrame->documentElement().findFirst(QLatin1String("textarea")); - QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QTest::mouseClick(&webView, Qt::LeftButton, { }, inputElement.geometry().center()); QVERIFY(webView.inputMethodHints() == Qt::ImhNone); QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); } @@ -324,11 +312,11 @@ void tst_QWebView::horizontalScrollbarTest() QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); // Note: The test below assumes that the layout direction is Qt::LeftToRight. - QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(550, 595)); + QTest::mouseClick(&webView, Qt::LeftButton, { }, QPoint(550, 595)); QVERIFY(webView.page()->mainFrame()->scrollPosition().x() > 0); // Note: The test below assumes that the layout direction is Qt::LeftToRight. - QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(20, 595)); + QTest::mouseClick(&webView, Qt::LeftButton, { }, QPoint(20, 595)); QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); } From e3b7365998d8904923865ba9bae4281b4b8abbc0 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 8 Jan 2023 13:25:28 -0500 Subject: [PATCH 33/58] allow for building without QtOpenGLWidgets --- Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp | 10 +++------- Source/cmake/OptionsQt.cmake | 9 +++++---- Tools/QtTestBrowser/launcherwindow.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp b/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp index d020df7382d61..43ff8ba2189b8 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp +++ b/Source/WebKitLegacy/qt/WidgetSupport/PageClientQt.cpp @@ -27,7 +27,7 @@ #include #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +#ifndef QT_NO_OPENGL #include #endif @@ -180,17 +180,15 @@ void PageClientQGraphicsWidget::repaintViewport() bool PageClientQGraphicsWidget::makeOpenGLContextCurrentIfAvailable() { -#if USE(TEXTURE_MAPPER_GL) +#ifndef QT_NO_OPENGL QGraphicsView* graphicsView = firstGraphicsView(); if (graphicsView && graphicsView->viewport()) { QWidget* widget = graphicsView->viewport(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) if (widget->inherits("QOpenGLWidget")) { QOpenGLWidget* qoglWidget = static_cast(widget); qoglWidget->makeCurrent(); return true; } -#endif } #endif return false; @@ -198,16 +196,14 @@ bool PageClientQGraphicsWidget::makeOpenGLContextCurrentIfAvailable() QOpenGLContext* PageClientQGraphicsWidget::openGLContextIfAvailable() { -#if USE(TEXTURE_MAPPER_GL) +#ifndef QT_NO_OPENGL QGraphicsView* graphicsView = firstGraphicsView(); if (graphicsView && graphicsView->viewport()) { QWidget* widget = graphicsView->viewport(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) if (widget->inherits("QOpenGLWidget")) { QOpenGLWidget* qoglWidget = static_cast(widget); return qoglWidget->context(); } -#endif } #endif return 0; diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index 7fab089a6dd84..062716727c198 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -545,11 +545,10 @@ if (ENABLE_DEVICE_ORIENTATION) SET_AND_EXPOSE_TO_BUILD(HAVE_QTSENSORS 1) endif () -# Qt6 : QOpenGLWidget is now in its separate library -# It seem to be required even when building with ENABLE_OPENGL=OFF -list(APPEND QT_REQUIRED_COMPONENTS OpenGLWidgets) - if (ENABLE_OPENGL) + # Qt6 : QOpenGLWidget is now in its separate library + list(APPEND QT_REQUIRED_COMPONENTS OpenGLWidgets) + # Note: Gui module is already found # Warning: quotes are sinificant here! if (NOT DEFINED Qt6Gui_OPENGL_IMPLEMENTATION OR "${Qt6Gui_OPENGL_IMPLEMENTATION}" STREQUAL "") @@ -574,6 +573,8 @@ if (ENABLE_OPENGL) message(STATUS "Qt OpenGL implementation: ${Qt6Gui_OPENGL_IMPLEMENTATION}") message(STATUS "Qt OpenGL libraries: ${Qt6Gui_OPENGL_LIBRARIES}") message(STATUS "Qt EGL libraries: ${Qt6Gui_EGL_LIBRARIES}") +else () + add_definitions(-DQT_NO_OPENGL) endif () if (ENABLE_PRINT_SUPPORT) diff --git a/Tools/QtTestBrowser/launcherwindow.h b/Tools/QtTestBrowser/launcherwindow.h index b66015c74f32d..c70c0a80a5bd0 100644 --- a/Tools/QtTestBrowser/launcherwindow.h +++ b/Tools/QtTestBrowser/launcherwindow.h @@ -35,7 +35,7 @@ #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +#ifndef QT_NO_OPENGL #include #endif From 1eef4f525db1aacf22f0bd56cc5f9d9a320e56e7 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 8 Jan 2023 22:13:46 -0500 Subject: [PATCH 34/58] Fix FileSystemQt method signature --- Source/WTF/wtf/FileSystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WTF/wtf/FileSystem.h b/Source/WTF/wtf/FileSystem.h index 83ba12e8dd796..a5db224a5d342 100644 --- a/Source/WTF/wtf/FileSystem.h +++ b/Source/WTF/wtf/FileSystem.h @@ -76,7 +76,7 @@ const PlatformFileHandle invalidPlatformFileHandle = -1; #endif // PlatformFileID -#if USE(GLIB) && !OS(WINDOWS) +#if USE(GLIB) && !OS(WINDOWS) && !PLATFORM(QT) typedef CString PlatformFileID; #elif OS(WINDOWS) typedef FILE_ID_128 PlatformFileID; From 3708e31960d4607919aac747c8591c8bdc3d8ac1 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 8 Jan 2023 22:16:00 -0500 Subject: [PATCH 35/58] ImageGStreamer qt method signature --- .../platform/graphics/gstreamer/ImageGStreamerQt.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerQt.cpp b/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerQt.cpp index 834501f9ab8a4..90f4d129831af 100644 --- a/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerQt.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerQt.cpp @@ -30,9 +30,10 @@ namespace WebCore { -ImageGStreamer::ImageGStreamer(GstSample* sample) +ImageGStreamer::ImageGStreamer(GRefPtr&& sample) + : m_sample(WTFMove(sample)) { - GstCaps* caps = gst_sample_get_caps(sample); + GstCaps* caps = gst_sample_get_caps(m_sample.get()); GstVideoInfo videoInfo; gst_video_info_init(&videoInfo); if (!gst_video_info_from_caps(&videoInfo, caps)) @@ -42,7 +43,7 @@ ImageGStreamer::ImageGStreamer(GstSample* sample) // Right now the TextureMapper only supports chromas with one plane ASSERT(GST_VIDEO_INFO_N_PLANES(&videoInfo) == 1); - GstBuffer* buffer = gst_sample_get_buffer(sample); + GstBuffer* buffer = gst_sample_get_buffer(m_sample.get()); if (UNLIKELY(!GST_IS_BUFFER(buffer))) return; From 19dbe62c0ea00782845043556eb7385cfdc99ab1 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Fri, 14 Jul 2023 20:53:16 -0400 Subject: [PATCH 36/58] ensure explicit String(Vector) --- Source/WTF/wtf/text/WTFString.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/WTF/wtf/text/WTFString.h b/Source/WTF/wtf/text/WTFString.h index dc3935a6984eb..14a5a71bc7590 100644 --- a/Source/WTF/wtf/text/WTFString.h +++ b/Source/WTF/wtf/text/WTFString.h @@ -266,10 +266,11 @@ class String final { #if PLATFORM(QT) WTF_EXPORT_PRIVATE String(const QString&); WTF_EXPORT_PRIVATE String(const QLatin1StringView&); - WTF_EXPORT_PRIVATE explicit String(const QStringView&); + WTF_EXPORT_PRIVATE String(const QStringView&); WTF_EXPORT_PRIVATE operator QString() const; // String(QStringView) makes for an ambiguous constructor, so we need to make these explicit + ALWAYS_INLINE String(Vector characters) : String(characters.data(), characters.size()) {} ALWAYS_INLINE String(Vector characters) : String(characters.data(), characters.size()) {} ALWAYS_INLINE String(Vector characters) : String(characters.data(), characters.size()) {} #endif From 4d494b00a548f78a36e874f0bff3ebdd2a715ed4 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 27 Nov 2023 19:13:25 -0500 Subject: [PATCH 37/58] resurrect RenderThemeQStyle; it is no longer page-dependent --- Source/WebCore/PlatformQt.cmake | 3 +++ .../WebCore/platform/qt/RenderThemeQStyle.cpp | 17 +++++--------- .../WebCore/platform/qt/RenderThemeQStyle.h | 5 ++--- Source/WebCore/platform/qt/RenderThemeQt.cpp | 5 ++--- Source/WebCore/platform/qt/RenderThemeQt.h | 2 +- .../platform/qt/RenderThemeQtMobile.cpp | 7 +++--- .../WebCore/platform/qt/RenderThemeQtMobile.h | 2 +- .../platform/qt/ScrollbarThemeQStyle.cpp | 2 +- .../qt/WebCoreSupport/InitWebCoreQt.cpp | 22 +++++++++---------- .../qt/WebCoreSupport/InitWebCoreQt.h | 2 +- .../qt/WidgetSupport/QStyleFacadeImp.cpp | 13 ++--------- .../qt/WidgetSupport/QStyleFacadeImp.h | 6 ++--- 12 files changed, 36 insertions(+), 50 deletions(-) diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake index a1b79e493d46b..c3e0f92d66d58 100644 --- a/Source/WebCore/PlatformQt.cmake +++ b/Source/WebCore/PlatformQt.cmake @@ -84,6 +84,9 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS platform/qt/QStyleFacade.h platform/qt/QStyleHelpers.h platform/qt/QWebPageClient.h + platform/qt/RenderThemeQt.h + platform/qt/RenderThemeQStyle.h + platform/qt/ScrollbarThemeQStyle.h platform/qt/ThirdPartyCookiesQt.h platform/qt/UserAgentQt.h diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp index c12983f779a33..48450a605dec7 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp @@ -39,10 +39,10 @@ #include "HTMLInputElement.h" #include "HTMLNames.h" #include "NotImplemented.h" -#include "Page.h" #include "PaintInfo.h" -#include "QWebPageClient.h" #include "RenderBox.h" +#include "RenderBoxInlines.h" +#include "RenderStyleSetters.h" #include "RenderProgress.h" #include "ScrollbarThemeQStyle.h" #include "StyleResolver.h" @@ -110,7 +110,7 @@ void StylePainterQStyle::setupStyleOption() RenderTheme& RenderThemeQStyle::singleton() { - static NeverDestroyed theme(nullptr); + static NeverDestroyed theme; return theme; } @@ -126,9 +126,9 @@ QtStyleFactoryFunction RenderThemeQStyle::styleFactory() return styleFactoryFunction; } -RenderThemeQStyle::RenderThemeQStyle(Page* page) - : RenderThemeQt(page) - , m_qStyle(styleFactoryFunction(page)) +RenderThemeQStyle::RenderThemeQStyle() + : RenderThemeQt() + , m_qStyle(styleFactoryFunction()) { int buttonPixelSize = 0; m_qStyle->getButtonMetrics(&m_buttonFontFamily, &buttonPixelSize); @@ -143,11 +143,6 @@ RenderThemeQStyle::~RenderThemeQStyle() void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) const { - if (!m_page) - return; - - if (QWebPageClient* pageClient = m_page->chrome().client().platformPageClient()) - palette = pageClient->palette(); } QRect RenderThemeQStyle::indicatorRect(QStyleFacade::ButtonType part, const QRect& originalRect) const diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.h b/Source/WebCore/platform/qt/RenderThemeQStyle.h index 312abd2cff2cb..fa0a011b99344 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.h +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.h @@ -28,18 +28,17 @@ namespace WebCore { class ScrollbarThemeQStyle; -class Page; class QStyleFacade; struct QStyleFacadeOption; -typedef QStyleFacade* (*QtStyleFactoryFunction)(Page*); +typedef QStyleFacade* (*QtStyleFactoryFunction)(); class RenderThemeQStyle final : public RenderThemeQt { private: friend class StylePainterQStyle; public: - RenderThemeQStyle(Page*); + RenderThemeQStyle(); ~RenderThemeQStyle(); static RenderTheme& singleton(); diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp index daf9ca794e2d8..7f4db0dc73da5 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp @@ -43,9 +43,9 @@ #include "HTMLNames.h" #include "LocalizedStrings.h" #include "NotImplemented.h" -#include "Page.h" #include "PaintInfo.h" #include "RenderBox.h" +#include "RenderBoxInlines.h" #include "RenderProgress.h" #include "RenderTheme.h" #include "RenderThemeQtMobile.h" @@ -77,9 +77,8 @@ static const float maxCancelButtonSize = 21; static QtThemeFactoryFunction themeFactory; static ScrollbarTheme* scrollbarTheme; -RenderThemeQt::RenderThemeQt(Page* page) +RenderThemeQt::RenderThemeQt() : RenderTheme() - , m_page(page) { m_buttonFontFamily = QGuiApplication::font().family(); } diff --git a/Source/WebCore/platform/qt/RenderThemeQt.h b/Source/WebCore/platform/qt/RenderThemeQt.h index 12a907feea4ab..48cf9c61cc1d4 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.h +++ b/Source/WebCore/platform/qt/RenderThemeQt.h @@ -50,7 +50,7 @@ using QtThemeFactoryFunction = std::add_pointer_t; class RenderThemeQt : public RenderTheme { public: - RenderThemeQt(Page*); + RenderThemeQt(); static void setCustomTheme(QtThemeFactoryFunction factory, ScrollbarTheme* customScrollbarTheme); static ScrollbarTheme* customScrollbarTheme(); diff --git a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp index 8358ba2fc2bc2..16f9e30be2c64 100644 --- a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp @@ -30,7 +30,6 @@ #include "HTMLInputElement.h" #include "HTMLNames.h" #include "HTMLSelectElement.h" -#include "Page.h" #include "PaintInfo.h" #include "RenderBox.h" #include "RenderProgress.h" @@ -634,12 +633,12 @@ void StylePainterMobile::drawSliderThumb(const QRect & rect, bool pressed) const RenderTheme& RenderThemeQtMobile::singleton() { - static NeverDestroyed theme(nullptr); + static NeverDestroyed theme; return theme; } -RenderThemeQtMobile::RenderThemeQtMobile(Page* page) - : RenderThemeQt(page) +RenderThemeQtMobile::RenderThemeQtMobile() + : RenderThemeQt() { } diff --git a/Source/WebCore/platform/qt/RenderThemeQtMobile.h b/Source/WebCore/platform/qt/RenderThemeQtMobile.h index 563a2f2f7587b..eae615163e84a 100644 --- a/Source/WebCore/platform/qt/RenderThemeQtMobile.h +++ b/Source/WebCore/platform/qt/RenderThemeQtMobile.h @@ -39,7 +39,7 @@ namespace WebCore { class RenderThemeQtMobile final : public RenderThemeQt { public: - RenderThemeQtMobile(Page*); + RenderThemeQtMobile(); ~RenderThemeQtMobile(); static RenderTheme& singleton(); diff --git a/Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp b/Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp index f345d0fb3b2bd..b4731a8e3010f 100644 --- a/Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp @@ -41,7 +41,7 @@ namespace WebCore { ScrollbarThemeQStyle::ScrollbarThemeQStyle() { - m_qStyle = std::unique_ptr(RenderThemeQStyle::styleFactory()(/*page*/ 0)); + m_qStyle = std::unique_ptr(RenderThemeQStyle::styleFactory()()); } ScrollbarThemeQStyle::~ScrollbarThemeQStyle() diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.cpp index 0a542578d314e..aedb794d096d5 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.cpp @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include namespace WebKit { @@ -50,22 +53,19 @@ Q_DECL_EXPORT void setWebKitWidgetsInitCallback(QtStyleFacadeFactoryFunction cal initCallback = callback; } -//static WebCore::QStyleFacade* createStyleForPage(WebCore::Page* page) -//{ -// QWebPageAdapter* pageAdapter = 0; -// if (page) -// pageAdapter = static_cast(page->chrome().client()).m_webPage; -// return initCallback(pageAdapter); -//} +static WebCore::QStyleFacade* createStyleForPage() +{ + return initCallback(); +} // Called also from WebKit2's WebProcess Q_DECL_EXPORT void initializeWebKitQt() { // QTFIXME -// if (initCallback) { -// WebCore::RenderThemeQStyle::setStyleFactoryFunction(createStyleForPage); -// WebCore::RenderThemeQt::setCustomTheme(WebCore::RenderThemeQStyle::create, new WebCore::ScrollbarThemeQStyle); -// } + if (initCallback) { + WebCore::RenderThemeQStyle::setStyleFactoryFunction(createStyleForPage); + WebCore::RenderThemeQt::setCustomTheme(WebCore::RenderThemeQStyle::singleton, new WebCore::ScrollbarThemeQStyle); + } } Q_DECL_EXPORT void setImagePlatformResource(const char* name, const QPixmap& pixmap) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.h b/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.h index 5913999933891..6d9051fa7e080 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.h +++ b/Source/WebKitLegacy/qt/WebCoreSupport/InitWebCoreQt.h @@ -38,7 +38,7 @@ class QStyleFacade; } class QWebPageAdapter; -typedef WebCore::QStyleFacade* (*QtStyleFacadeFactoryFunction)(QWebPageAdapter*); +typedef WebCore::QStyleFacade* (*QtStyleFacadeFactoryFunction)(); namespace WebKit { diff --git a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp index 7fd6020eae997..90f09b3598729 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp +++ b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.cpp @@ -31,9 +31,6 @@ #include #include -#include -#include - using namespace WebCore; namespace WebKit { @@ -136,9 +133,8 @@ static QStyleFacade::SubControl convertToQStyleFacadeSubControl(QStyle::SubContr #undef CONVERT_SUBCONTROL } -QStyleFacadeImp::QStyleFacadeImp(QWebPageAdapter* page) - : m_page(page) - , m_style(0) +QStyleFacadeImp::QStyleFacadeImp() + : m_style(0) { m_fallbackStyle = QStyleFactory::create(QLatin1String("windows")); m_ownFallbackStyle = true; @@ -488,11 +484,6 @@ QStyle* QStyleFacadeImp::style() const if (m_style) return m_style; - if (m_page) { - if (QWebPageClient* pageClient = m_page->client.data()) - m_style = pageClient->style(); - } - if (!m_style) m_style = QApplication::style(); diff --git a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.h b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.h index eead17a53661d..7a666cd2dd3eb 100644 --- a/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.h +++ b/Source/WebKitLegacy/qt/WidgetSupport/QStyleFacadeImp.h @@ -41,11 +41,11 @@ namespace WebKit { class QStyleFacadeImp : public WebCore::QStyleFacade { public: - QStyleFacadeImp(QWebPageAdapter* = 0); + QStyleFacadeImp(); ~QStyleFacadeImp() override; - static WebCore::QStyleFacade* create(QWebPageAdapter* page) - { return new QStyleFacadeImp(page); } + static WebCore::QStyleFacade* create() + { return new QStyleFacadeImp(); } QRect buttonSubElementRect(ButtonSubElement, State, const QRect& originalRect) const override; From de93ad1c5e46f8535d4497b5df5daae9d23d5108 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 27 Nov 2023 19:16:35 -0500 Subject: [PATCH 38/58] misc warnings fixes --- .../WebCore/platform/graphics/qt/FontCascadeQt.cpp | 4 ++-- .../platform/graphics/qt/FontPlatformDataQt.cpp | 4 ++-- .../WebCore/platform/graphics/qt/GraphicsContextQt.h | 12 ++++++------ .../platform/network/qt/QtMIMETypeSniffer.cpp | 2 +- .../WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.h | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp b/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp index 8182b22753054..a1f9e507c1e97 100644 --- a/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp @@ -263,7 +263,7 @@ void FontCascade::initFormatForTextLayout(QTextLayout* layout, const TextRun& ru // To avoid word-spacing on any leading spaces, we exclude them from FormatRange which // word-spacing along with other options would be applied to. This is safe since the other // formatting options does not affect spaces. - unsigned length = run.length(); + int length = run.length(); for (range.start = 0; range.start < length && treatAsSpace(run[range.start]); ++range.start) { } range.length = length - range.start; @@ -314,7 +314,7 @@ void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const G float width = 0; - for (int i = 0; i < numGlyphs; ++i) { + for (unsigned i = 0; i < numGlyphs; ++i) { Glyph glyph = glyphs[i]; float advance = advances[i].x(); diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp index 6ab711b16cfc8..437adfe1f681b 100644 --- a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp @@ -75,7 +75,7 @@ void FontPlatformDataPrivate::platformDataInit(FontPlatformData& q, float size, q.updateSize(size); } -FontPlatformData::FontPlatformData(const FontDescription& description, const AtomString& familyName, const FontCustomPlatformData* customPlatformData) +FontPlatformData::FontPlatformData(const FontDescription& description, const AtomString& familyName, const FontCustomPlatformData*) { QFont font; auto requestedSize = description.computedSize(); @@ -97,7 +97,7 @@ FontPlatformData::FontPlatformData(const FontDescription& description, const Ato FontPlatformDataPrivate::platformDataInit(*this, size, QRawFont::fromFont(font, QFontDatabase::Any)); } -FontPlatformData::FontPlatformData(const QRawFont& rawFont, const FontCustomPlatformData* customPlatformData) +FontPlatformData::FontPlatformData(const QRawFont& rawFont, const FontCustomPlatformData*) { FontPlatformDataPrivate::platformDataInit(*this, rawFont.pixelSize(), rawFont); } diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.h b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.h index de3be3b5739c8..0d80d5e5a0c3d 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.h +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.h @@ -43,7 +43,7 @@ class WEBCORE_EXPORT GraphicsContextQt final : public GraphicsContext { void save(GraphicsContextState::Purpose = GraphicsContextState::Purpose::SaveRestore) final; void restore(GraphicsContextState::Purpose = GraphicsContextState::Purpose::SaveRestore) final; - void didUpdateState(GraphicsContextState&); + void didUpdateState(GraphicsContextState&) final; void drawRect(const FloatRect&, float borderThickness = 1) final; void drawLine(const FloatPoint&, const FloatPoint&) final; @@ -55,7 +55,7 @@ class WEBCORE_EXPORT GraphicsContextQt final : public GraphicsContext { using GraphicsContext::fillRect; void fillRect(const FloatRect&) final; void fillRect(const FloatRect&, const Color&) final; - void fillRect(const FloatRect&, Gradient&); + void fillRect(const FloatRect&, Gradient&) final; void fillRoundedRectImpl(const FloatRoundedRect&, const Color&) final; void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&) final; @@ -77,9 +77,9 @@ class WEBCORE_EXPORT GraphicsContextQt final : public GraphicsContext { void resetClip() final; void clipPath(const Path&, WindRule = WindRule::EvenOdd) final; - void clipToImageBuffer(ImageBuffer& buffer, const FloatRect& destRect); + void clipToImageBuffer(ImageBuffer& buffer, const FloatRect& destRect) final; - void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint&, FontSmoothingMode); + void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint&, FontSmoothingMode) final; void drawLinesForText(const FloatPoint&, float thickness, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle) final; void drawLineForText(const FloatRect&, bool printing, bool doubleLines = false, StrokeStyle = StrokeStyle::SolidStroke); @@ -88,7 +88,7 @@ class WEBCORE_EXPORT GraphicsContextQt final : public GraphicsContext { void drawFocusRing(const Vector&, float outlineOffset, float outlineWidth, const Color&) final; void drawFocusRing(const Path&, float outlineWidth, const Color&) final; - void setURLForRect(const URL& url, const FloatRect& rect); + void setURLForRect(const URL& url, const FloatRect& rect) final; RenderingMode renderingMode() const final; using GraphicsContext::scale; @@ -98,7 +98,7 @@ class WEBCORE_EXPORT GraphicsContextQt final : public GraphicsContext { void concatCTM(const AffineTransform&) final; void setCTM(const AffineTransform&) override; - IntRect clipBounds() const; + IntRect clipBounds() const final; AffineTransform getCTM(IncludeDeviceScale = PossiblyIncludeDeviceScale) const override; diff --git a/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp b/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp index 616df71c046a3..abb2cfa11f109 100644 --- a/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp +++ b/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp @@ -48,7 +48,7 @@ bool QtMIMETypeSniffer::sniff() // See QNetworkReplyWrapper::setFinished(). const bool isReplyFinished = m_reply->property("_q_isFinished").toBool(); - if (!isReplyFinished && m_reply->bytesAvailable() < m_sniffer.dataSize()) + if (!isReplyFinished && static_cast(m_reply->bytesAvailable()) < m_sniffer.dataSize()) return false; QByteArray data = m_reply->peek(m_sniffer.dataSize()); diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.h index 1cf06cd4bdb36..21548a27a026f 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.h +++ b/Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.h @@ -207,11 +207,11 @@ class ChromeClientQt final : public ChromeClient { void requestCookieConsent(CompletionHandler&&) final; - IntPoint accessibilityScreenToRootView(const IntPoint&) const; - IntRect rootViewToAccessibilityScreen(const IntRect&) const; - void didFinishLoadingImageForElement(HTMLImageElement&); - void intrinsicContentsSizeChanged(const IntSize&) const; - RefPtr createIconForFiles(const Vector&); + IntPoint accessibilityScreenToRootView(const IntPoint&) const final; + IntRect rootViewToAccessibilityScreen(const IntRect&) const final; + void didFinishLoadingImageForElement(HTMLImageElement&) final; + void intrinsicContentsSizeChanged(const IntSize&) const final; + RefPtr createIconForFiles(const Vector&) final; QWebFullScreenVideoHandler* createFullScreenVideoHandler(); From 894578c45f012f54bcf512208017ce5187540e51 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 27 Nov 2023 19:20:14 -0500 Subject: [PATCH 39/58] use style.effectiveAppearance() to convert Auto to real appearance --- Source/WebCore/platform/qt/RenderThemeQStyle.cpp | 8 ++++---- Source/WebCore/platform/qt/RenderThemeQt.cpp | 12 ++++++------ Source/WebCore/platform/qt/RenderThemeQtMobile.cpp | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp index 48450a605dec7..94547c5b736e1 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp @@ -214,7 +214,7 @@ void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle& renderStyle) const QSize size(0, 0); const QFontMetrics fm(renderStyle.fontCascade().syntheticFont()); - switch (renderStyle.appearance()) { + switch (renderStyle.effectiveAppearance()) { case StyleAppearance::TextArea: case StyleAppearance::SearchField: case StyleAppearance::TextField: { @@ -233,7 +233,7 @@ void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle& renderStyle) const if (!renderStyle.width().isIntrinsicOrAuto() && !renderStyle.height().isAuto()) return; - switch (renderStyle.appearance()) { + switch (renderStyle.effectiveAppearance()) { case StyleAppearance::Checkbox: { int checkBoxWidth = m_qStyle->simplePixelMetric(QStyleFacade::PM_IndicatorWidth, QStyleFacade::State_Small); checkBoxWidth *= renderStyle.effectiveZoom(); @@ -286,7 +286,7 @@ void RenderThemeQStyle::adjustButtonStyle(RenderStyle& style, const Element*) co style.resetBorder(); #ifdef Q_OS_MACOS - if (style.appearance() == StyleAppearance::PushButton) { + if (style.effectiveAppearance() == StyleAppearance::PushButton) { // The Mac ports ignore the specified height for elements // unless a border and/or background CSS property is also specified. style.setHeight(Length(LengthType::Auto)); @@ -621,7 +621,7 @@ StyleAppearance RenderThemeQStyle::initializeCommonQStyleOptions(QStyleFacadeOpt const RenderStyle& style = o.style(); - StyleAppearance result = style.appearance(); + StyleAppearance result = style.effectiveAppearance(); if (supportsFocus(result) && isFocused(o)) { option.state |= QStyleFacade::State_HasFocus; option.state |= QStyleFacade::State_KeyboardFocusChange; diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp index 7f4db0dc73da5..99f4783a6841a 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp @@ -104,7 +104,7 @@ RenderTheme& RenderTheme::singleton() // Remove this when SearchFieldPart is style-able in RenderTheme::isControlStyled() bool RenderThemeQt::isControlStyled(const RenderStyle& style, const RenderStyle& userAgentStyle) const { - switch (style.appearance()) { + switch (style.effectiveAppearance()) { case StyleAppearance::SearchField: // Test the style to see if the UA border and background match. return (style.border() != userAgentStyle.border() @@ -135,7 +135,7 @@ bool RenderThemeQt::supportsHover(const RenderStyle&) const bool RenderThemeQt::supportsFocusRing(const RenderStyle& style) const { - switch (style.appearance()) { + switch (style.effectiveAppearance()) { case StyleAppearance::Checkbox: case StyleAppearance::Radio: case StyleAppearance::PushButton: @@ -164,7 +164,7 @@ int RenderThemeQt::baselinePosition(const RenderBox& o) const if (!o.isRenderBox()) return 0; - if (o.style().appearance() == StyleAppearance::Checkbox || o.style().appearance() == StyleAppearance::Radio) + if (o.style().effectiveAppearance() == StyleAppearance::Checkbox || o.style().appearance() == StyleAppearance::Radio) return o.marginTop() + o.height() - 2; // Same as in old khtml return RenderTheme::baselinePosition(o); } @@ -175,7 +175,7 @@ bool RenderThemeQt::controlSupportsTints(const RenderObject& o) const return false; // Checkboxes only have tint when checked. - if (o.style().appearance() == StyleAppearance::Checkbox) + if (o.style().effectiveAppearance() == StyleAppearance::Checkbox) return isChecked(o); // For now assume other controls have tint if enabled. @@ -207,7 +207,7 @@ void RenderThemeQt::computeControlRect(QStyleFacade::ButtonType, FloatRect&) con void RenderThemeQt::adjustRepaintRect(const RenderObject& o, FloatRect& rect) { - switch (o.style().appearance()) { + switch (o.style().effectiveAppearance()) { case StyleAppearance::Checkbox: computeControlRect(QStyleFacade::CheckBox, rect); break; @@ -595,7 +595,7 @@ static bool mediaElementCanPlay(RenderObject& o) return mediaElement->readyState() > HTMLMediaElement::HAVE_METADATA || (mediaElement->readyState() == HTMLMediaElement::HAVE_NOTHING - && o.style().appearance() == StyleAppearance::MediaPlayButton && mediaElement->preload() == "none"); + && o.style().effectiveAppearance() == StyleAppearance::MediaPlayButton && mediaElement->preload() == "none"); } QColor RenderThemeQt::getMediaControlForegroundColor(RenderObject& o) const diff --git a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp index 16f9e30be2c64..011cc5dee2429 100644 --- a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp @@ -648,7 +648,7 @@ RenderThemeQtMobile::~RenderThemeQtMobile() bool RenderThemeQtMobile::isControlStyled(const RenderStyle& style, const RenderStyle& userAgentStyle) const { - switch (style.appearance()) { + switch (style.effectiveAppearance()) { case StyleAppearance::Checkbox: case StyleAppearance::Radio: return false; @@ -666,7 +666,7 @@ void RenderThemeQtMobile::computeSizeBasedOnStyle(RenderStyle& renderStyle) cons { QSize size(0, 0); - switch (renderStyle.appearance()) { + switch (renderStyle.effectiveAppearance()) { case StyleAppearance::TextArea: case StyleAppearance::SearchField: case StyleAppearance::TextField: { @@ -685,7 +685,7 @@ void RenderThemeQtMobile::computeSizeBasedOnStyle(RenderStyle& renderStyle) cons if (!renderStyle.width().isIntrinsicOrAuto() && !renderStyle.height().isAuto()) return; - switch (renderStyle.appearance()) { + switch (renderStyle.effectiveAppearance()) { case StyleAppearance::Checkbox: { const int w = checkBoxWidth * renderStyle.effectiveZoom(); size = QSize(w, w); @@ -747,7 +747,7 @@ bool RenderThemeQtMobile::paintButton(const RenderObject& o, const PaintInfo& i, if (!p.isValid()) return true; - StyleAppearance appearance = o.style().appearance(); + StyleAppearance appearance = o.style().effectiveAppearance(); if (appearance == StyleAppearance::PushButton || appearance == StyleAppearance::Button) { p.drawPushButton(r, isPressed(o), isEnabled(o)); } else if (appearance == StyleAppearance::Radio) @@ -783,7 +783,7 @@ bool RenderThemeQtMobile::paintTextField(const RenderObject& o, const PaintInfo& if (!p.isValid()) return true; - StyleAppearance appearance = o.style().appearance(); + StyleAppearance appearance = o.style().effectiveAppearance(); if (appearance != StyleAppearance::TextField && appearance != StyleAppearance::SearchField && appearance != StyleAppearance::TextArea) @@ -893,7 +893,7 @@ bool RenderThemeQtMobile::paintSliderTrack(const RenderObject& o, const PaintInf const double progress = (max - min > 0) ? (slider->valueAsNumber() - min) / (max - min) : 0; QRect rect(r); - const bool vertical = (o.style().appearance() == StyleAppearance::SliderVertical); + const bool vertical = (o.style().effectiveAppearance() == StyleAppearance::SliderVertical); const int groovePadding = vertical ? r.width() * sliderGrooveBorderRatio : r.height() * sliderGrooveBorderRatio; if (vertical) { rect.adjust(groovePadding, 0, -groovePadding, 0); @@ -928,7 +928,7 @@ bool RenderThemeQtMobile::checkMultiple(const RenderObject& o) const void RenderThemeQtMobile::adjustSliderThumbSize(RenderStyle& style, const Element* element) const { - const StyleAppearance part = style.appearance(); + const StyleAppearance part = style.effectiveAppearance(); if (part == StyleAppearance::SliderThumbHorizontal || part == StyleAppearance::SliderThumbVertical) { const int size = sliderSize * style.effectiveZoom(); style.setWidth(Length(size, LengthType::Fixed)); From e4bbd3497391fbae31a40b090622f514141404f5 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 27 Nov 2023 19:58:22 -0500 Subject: [PATCH 40/58] fix crash due to styleResolver change --- Source/WebCore/platform/qt/RenderThemeQStyle.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp index 94547c5b736e1..f2013fcd1a367 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp @@ -280,7 +280,7 @@ void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle& renderStyle) const -void RenderThemeQStyle::adjustButtonStyle(RenderStyle& style, const Element*) const +void RenderThemeQStyle::adjustButtonStyle(RenderStyle& style, const Element* element) const { // Ditch the border. style.resetBorder(); @@ -308,10 +308,8 @@ void RenderThemeQStyle::adjustButtonStyle(RenderStyle& style, const Element*) co families.append(m_buttonFontFamily); fontDescription.setFamilies(families); style.setFontDescription(WTFMove(fontDescription)); - // TODO: address no longer having styleResolver reference here - // style.fontCascade().update(&styleResolver.document().fontSelector()); + style.fontCascade().update(&element->document().fontSelector()); style.setLineHeight(RenderStyle::initialLineHeight()); - // QTFIXME: setButtonSize() was removed setButtonPadding(style); } From 464862824f6c7bfa8c40f37d770fc19ec4f5c6d7 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 27 Nov 2023 20:01:14 -0500 Subject: [PATCH 41/58] slightly more attractive styling for mobile theme --- Source/WebCore/platform/qt/RenderThemeQtMobile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp index 011cc5dee2429..99498dae1f886 100644 --- a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp @@ -63,7 +63,7 @@ static const float buttonPaddingTop = 2; static const float buttonPaddingBottom = 3; static const float menuListPadding = 9; static const float textFieldPadding = 10; -static const float radiusFactor = 0.36; +static const float radiusFactor = 0.16; static const float progressBarChunkPercentage = 0.2; static const int progressAnimationGranularity = 2; static const float sliderGrooveBorderRatio = 0.2; @@ -799,7 +799,7 @@ bool RenderThemeQtMobile::paintTextField(const RenderObject& o, const PaintInfo& p.painter->drawRoundedRect(r, radius, radius); if (isFocused(o)) { - QPen focusPen(highlightColor, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen focusPen(highlightColor, 2.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); p.painter->setPen(focusPen); p.painter->setBrush(Qt::NoBrush); p.painter->drawRoundedRect(r, radius, radius); From 68f7f9060c6331abd53e24de08a58c7343edbbfe Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 27 Nov 2023 20:03:50 -0500 Subject: [PATCH 42/58] remove unused include from styleresolver removal --- Source/WebCore/platform/qt/RenderThemeQt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/WebCore/platform/qt/RenderThemeQt.h b/Source/WebCore/platform/qt/RenderThemeQt.h index 48cf9c61cc1d4..144e70436c486 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.h +++ b/Source/WebCore/platform/qt/RenderThemeQt.h @@ -23,7 +23,6 @@ #define RenderThemeQt_h #include "QStyleFacade.h" -#include "StyleResolver.h" #include "RenderTheme.h" #include From f1200e6966370362c5af1c4488eea1f097d09140 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Mon, 27 Nov 2023 20:05:11 -0500 Subject: [PATCH 43/58] QtTestBrowser: resolve black location bar during loading This seems somehow related to QPalette not being able to draw a gradient, for some reason. --- Tools/QtTestBrowser/locationedit.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tools/QtTestBrowser/locationedit.cpp b/Tools/QtTestBrowser/locationedit.cpp index fd86650b5f2c9..20f15483efb2c 100644 --- a/Tools/QtTestBrowser/locationedit.cpp +++ b/Tools/QtTestBrowser/locationedit.cpp @@ -27,6 +27,7 @@ */ #include "locationedit.h" +#include #ifndef QT_NO_INPUTDIALOG @@ -99,6 +100,7 @@ void LocationEdit::updateInternalGeometry() void LocationEdit::paintEvent(QPaintEvent* ev) { + QPainter painter(this); QColor backgroundColor = QApplication::palette().color(QPalette::Base); QColor progressColor = QColor(120, 180, 240); QPalette p = palette(); @@ -111,7 +113,8 @@ void LocationEdit::paintEvent(QPaintEvent* ev) gradient.setColorAt(((double) m_progress) / 100, progressColor); if (m_progress != 100) gradient.setColorAt((double) m_progress / 100 + 0.001, backgroundColor); - p.setBrush(QPalette::Base, gradient); + p.setBrush(QPalette::Base, QColor(Qt::transparent)); + painter.fillRect(rect(), gradient); } setPalette(p); From efaa5095034a172797854cc53761b06b5f9c56f0 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Thu, 30 Nov 2023 19:38:15 -0500 Subject: [PATCH 44/58] revert gstreamer version, to support focal for a short while longer --- Source/cmake/GStreamerChecks.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmake/GStreamerChecks.cmake b/Source/cmake/GStreamerChecks.cmake index 5380617afc9c5..1a4a6fb625fda 100644 --- a/Source/cmake/GStreamerChecks.cmake +++ b/Source/cmake/GStreamerChecks.cmake @@ -12,7 +12,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO) SET_AND_EXPOSE_TO_BUILD(USE_GSTREAMER TRUE) if (USE_GSTREAMER_FULL) - find_package(GStreamer 1.18.4 REQUIRED COMPONENTS full) + find_package(GStreamer 1.16.2 REQUIRED COMPONENTS full) if (NOT PC_GSTREAMER_FULL_FOUND) message(FATAL_ERROR "GStreamer static library libgstreamer-full-1.0 not found") else () @@ -36,7 +36,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO) list(APPEND GSTREAMER_COMPONENTS webrtc) endif () - find_package(GStreamer 1.18.4 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS}) + find_package(GStreamer 1.16.2 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS}) if (ENABLE_WEB_AUDIO) if (NOT PC_GSTREAMER_AUDIO_FOUND OR NOT PC_GSTREAMER_FFT_FOUND) From 9fbea79d2b052b351fd47b1e0fca17be394341b8 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Fri, 1 Dec 2023 17:26:10 +0000 Subject: [PATCH 45/58] more fallout from TEXTURE_MAPPER and TEXTURE_MAPPER_GL merge --- .../gstreamer/GStreamerVideoFrameHolder.cpp | 2 +- .../gstreamer/GStreamerVideoFrameHolder.h | 2 +- .../gstreamer/MediaPlayerPrivateGStreamer.cpp | 18 +++++++++--------- .../gstreamer/MediaPlayerPrivateGStreamer.h | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.cpp index 271ca069b52a9..6c3b61254c9af 100644 --- a/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.cpp @@ -20,7 +20,7 @@ #include "config.h" -#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(TEXTURE_MAPPER) +#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(TEXTURE_MAPPER) && !PLATFORM(QT) #include "GStreamerVideoFrameHolder.h" #include "BitmapTexture.h" diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.h b/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.h index 5d83e9ab4edfe..9dbf9a4c9c5e1 100644 --- a/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.h +++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerVideoFrameHolder.h @@ -20,7 +20,7 @@ #pragma once -#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(TEXTURE_MAPPER) +#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(TEXTURE_MAPPER) && !PLATFORM(QT) #include "MediaPlayerPrivateGStreamer.h" #include "TextureMapperPlatformLayerBuffer.h" diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index 2bcf24f69e729..107ca93825b0a 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -111,7 +111,7 @@ #include "GLVideoSinkGStreamer.h" #endif // USE(GSTREAMER_GL) -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) #include "BitmapTexture.h" #include "BitmapTexturePool.h" #include "GStreamerVideoFrameHolder.h" @@ -151,7 +151,7 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player) , m_maxTimeLoadedAtLastDidLoadingProgress(MediaTime::zeroTime()) , m_drawTimer(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::repaint) , m_readyTimerHandler(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::readyTimerFired) -#if USE(TEXTURE_MAPPER) && !USE(NICOSIA) +#if USE(TEXTURE_MAPPER) && !USE(NICOSIA) && !PLATFORM(QT) , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxyGL)) #endif #if !RELEASE_LOG_DISABLED @@ -168,7 +168,7 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player) #endif m_isPlayerShuttingDown.store(false); -#if USE(TEXTURE_MAPPER) && USE(NICOSIA) +#if USE(TEXTURE_MAPPER) && USE(NICOSIA) && !PLATFORM(QT) m_nicosiaLayer = Nicosia::ContentLayer::create(*this, [&]() -> Ref { #if USE(TEXTURE_MAPPER_DMABUF) @@ -219,7 +219,7 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer() if (m_videoDecoderPlatform == GstVideoDecoderPlatform::Video4Linux) flushCurrentBuffer(); #endif -#if USE(TEXTURE_MAPPER) && USE(NICOSIA) +#if USE(TEXTURE_MAPPER) && USE(NICOSIA) && !PLATFORM(QT) m_nicosiaLayer->invalidateClient(); #endif @@ -3102,7 +3102,7 @@ void MediaPlayerPrivateGStreamer::configureVideoDecoder(GstElement* decoder) if (gstObjectHasProperty(decoder, "max-threads")) g_object_set(decoder, "max-threads", 2, nullptr); } -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) updateTextureMapperFlags(); #endif @@ -3215,7 +3215,7 @@ void MediaPlayerPrivateGStreamer::isLoopingChanged() ensureSeekFlags(); } -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) PlatformLayer* MediaPlayerPrivateGStreamer::platformLayer() const { #if USE(NICOSIA) @@ -3753,7 +3753,7 @@ void MediaPlayerPrivateGStreamer::triggerRepaint(GRefPtr&& sample) return; } -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) if (m_isUsingFallbackVideoSink) { Locker locker { m_drawLock }; auto proxyOperation = @@ -3928,13 +3928,13 @@ bool MediaPlayerPrivateGStreamer::setVideoSourceOrientation(ImageOrientation ori return false; m_videoSourceOrientation = orientation; -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) updateTextureMapperFlags(); #endif return true; } -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) void MediaPlayerPrivateGStreamer::updateTextureMapperFlags() { switch (m_videoSourceOrientation.orientation()) { diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h index 010e76829d135..c93e7b24cc3ce 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h @@ -60,7 +60,7 @@ typedef struct _GstMpegtsSection GstMpegtsSection; #undef GST_USE_UNSTABLE_API #endif -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) #if USE(NICOSIA) #include "NicosiaContentLayer.h" #else @@ -84,7 +84,7 @@ class GraphicsContextGL; class IntSize; class IntRect; -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) class TextureMapperPlatformLayerProxy; #endif @@ -112,7 +112,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface #if !RELEASE_LOG_DISABLED , private LoggerHelper #endif -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) #if USE(NICOSIA) , public Nicosia::ContentLayer::Client #else @@ -189,7 +189,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface bool performTaskAtMediaTime(Function&&, const MediaTime&) override; void isLoopingChanged() final; -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) PlatformLayer* platformLayer() const override; #if PLATFORM(WIN) // FIXME: Accelerated rendering has not been implemented for WinCairo yet. @@ -287,7 +287,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface GstElement* createVideoSinkGL(); #endif -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) void pushTextureToCompositor(); #if USE(NICOSIA) void swapBuffersIfNeeded() final; @@ -335,7 +335,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface void loadingFailed(MediaPlayer::NetworkState, MediaPlayer::ReadyState = MediaPlayer::ReadyState::HaveNothing, bool forceNotifications = false); void loadStateChanged(); -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) void updateTextureMapperFlags(); #endif @@ -375,7 +375,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface GRefPtr m_source { nullptr }; bool m_areVolumeAndMuteInitialized { false }; -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) OptionSet m_textureMapperFlags; #endif @@ -546,7 +546,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface Lock m_drawLock; RunLoop::Timer m_drawTimer WTF_GUARDED_BY_LOCK(m_drawLock); RunLoop::Timer m_readyTimerHandler; -#if USE(TEXTURE_MAPPER) +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) #if USE(NICOSIA) RefPtr m_nicosiaLayer; #else From eaa71310f4234e89e3519bdefd631cbd74f850c0 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Fri, 1 Dec 2023 17:29:21 +0000 Subject: [PATCH 46/58] fix include for WebAudioSourceProvider --- .../platform/audio/gstreamer/AudioSourceProviderGStreamer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.h b/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.h index be04997c8d340..1a8f2ddbe1969 100644 --- a/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.h +++ b/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.h @@ -24,6 +24,7 @@ #include "AudioSourceProviderClient.h" #include "GRefPtrGStreamer.h" #include "MainThreadNotifier.h" +#include "WebAudioSourceProvider.h" #include #include #include @@ -32,7 +33,6 @@ #if ENABLE(MEDIA_STREAM) #include "GStreamerAudioStreamDescription.h" #include "MediaStreamTrackPrivate.h" -#include "WebAudioSourceProvider.h" #endif typedef struct _GstAdapter GstAdapter; From 47c76efabfcc632d1bf91d82c49574a1eff60c06 Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Tue, 5 Dec 2023 23:06:39 -0500 Subject: [PATCH 47/58] ensure qt6 qnam does not auto follow redirects --- Source/WebCore/platform/network/qt/ResourceRequestQt.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp index 21ceac57fe9b0..b2a7db673bb8b 100644 --- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -90,6 +90,8 @@ QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) co const URL& originalUrl = url(); request.setUrl(toQUrl(originalUrl)); request.setOriginatingObject(context ? context->originatingObject() : 0); + // Qt6 now defaults to following redirects + request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy); #if USE(HTTP2) static const bool NegotiateHttp2ForHttps = alpnIsSupported(); From 617563fe59f5823d2c8cdab6a24b12662d324c2d Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Wed, 6 Dec 2023 08:58:00 -0500 Subject: [PATCH 48/58] QStringView should not be passed as a const ref --- Source/WTF/wtf/text/AtomString.h | 4 ++-- Source/WTF/wtf/text/WTFString.h | 4 ++-- Source/WTF/wtf/text/qt/AtomStringQt.cpp | 2 +- Source/WTF/wtf/text/qt/StringQt.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/WTF/wtf/text/AtomString.h b/Source/WTF/wtf/text/AtomString.h index 841f1f66ee8c1..374d26acebefc 100644 --- a/Source/WTF/wtf/text/AtomString.h +++ b/Source/WTF/wtf/text/AtomString.h @@ -126,7 +126,7 @@ class AtomString final { #if PLATFORM(QT) WTF_EXPORT_PRIVATE AtomString(const QString&); - WTF_EXPORT_PRIVATE AtomString(const QStringView&); + WTF_EXPORT_PRIVATE AtomString(QStringView); #endif #if OS(WINDOWS) @@ -160,7 +160,7 @@ static_assert(sizeof(AtomString) == sizeof(String), "AtomString and String must inline bool operator==(const AtomString& a, const AtomString& b) { return a.impl() == b.impl(); } inline bool operator==(const AtomString& a, ASCIILiteral b) { return WTF::equal(a.impl(), b); } -inline bool operator==(const AtomString& a, const Vector& b) { return a.impl() && equal(a.impl(), b.data(), b.size()); } +inline bool operator==(const AtomString& a, const Vector& b) { return a.impl() && equal(a.impl(), b.data(), b.size()); } inline bool operator==(const AtomString& a, const String& b) { return equal(a.impl(), b.impl()); } inline bool operator==(const String& a, const AtomString& b) { return equal(a.impl(), b.impl()); } inline bool operator==(const Vector& a, const AtomString& b) { return b == a; } diff --git a/Source/WTF/wtf/text/WTFString.h b/Source/WTF/wtf/text/WTFString.h index 851c6a35cb1e0..27d4b32b7eb98 100644 --- a/Source/WTF/wtf/text/WTFString.h +++ b/Source/WTF/wtf/text/WTFString.h @@ -261,8 +261,8 @@ class String final { #if PLATFORM(QT) WTF_EXPORT_PRIVATE String(const QString&); - WTF_EXPORT_PRIVATE String(const QLatin1StringView&); - WTF_EXPORT_PRIVATE String(const QStringView&); + WTF_EXPORT_PRIVATE String(QLatin1StringView); + WTF_EXPORT_PRIVATE String(QStringView); WTF_EXPORT_PRIVATE operator QString() const; // String(QStringView) makes for an ambiguous constructor, so we need to make these explicit diff --git a/Source/WTF/wtf/text/qt/AtomStringQt.cpp b/Source/WTF/wtf/text/qt/AtomStringQt.cpp index 66c61e400bb0f..8edc6ca19a3c9 100644 --- a/Source/WTF/wtf/text/qt/AtomStringQt.cpp +++ b/Source/WTF/wtf/text/qt/AtomStringQt.cpp @@ -12,7 +12,7 @@ AtomString::AtomString(const QString& qstr) return; } -AtomString::AtomString(const QStringView& view) +AtomString::AtomString(QStringView view) : m_string(AtomStringImpl::add(reinterpret_cast_ptr(view.constData()), view.length())) { if (view.isNull()) diff --git a/Source/WTF/wtf/text/qt/StringQt.cpp b/Source/WTF/wtf/text/qt/StringQt.cpp index 64af257ebd00c..ab6458677f146 100644 --- a/Source/WTF/wtf/text/qt/StringQt.cpp +++ b/Source/WTF/wtf/text/qt/StringQt.cpp @@ -40,14 +40,14 @@ String::String(const QString& qstr) m_impl = StringImpl::create(reinterpret_cast_ptr(qstr.constData()), qstr.length()); } -String::String(const QLatin1StringView& view) +String::String(QLatin1StringView view) { if (view.isNull()) return; m_impl = StringImpl::create(reinterpret_cast_ptr(view.data()), view.length()); } -String::String(const QStringView& view) +String::String(QStringView view) { if (view.isNull()) return; From 5cf632234c6e42e24177f1677e5c7fd3295ba22a Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Wed, 6 Dec 2023 22:11:01 -0500 Subject: [PATCH 49/58] remove extra allocation in QWebFrameAdapter --- Source/WTF/wtf/text/WTFString.h | 1 + Source/WTF/wtf/text/qt/StringQt.cpp | 7 +++++++ Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/WTF/wtf/text/WTFString.h b/Source/WTF/wtf/text/WTFString.h index 27d4b32b7eb98..a07c5e013347e 100644 --- a/Source/WTF/wtf/text/WTFString.h +++ b/Source/WTF/wtf/text/WTFString.h @@ -263,6 +263,7 @@ class String final { WTF_EXPORT_PRIVATE String(const QString&); WTF_EXPORT_PRIVATE String(QLatin1StringView); WTF_EXPORT_PRIVATE String(QStringView); + WTF_EXPORT_PRIVATE String(QByteArrayView); WTF_EXPORT_PRIVATE operator QString() const; // String(QStringView) makes for an ambiguous constructor, so we need to make these explicit diff --git a/Source/WTF/wtf/text/qt/StringQt.cpp b/Source/WTF/wtf/text/qt/StringQt.cpp index ab6458677f146..962f821a6cf03 100644 --- a/Source/WTF/wtf/text/qt/StringQt.cpp +++ b/Source/WTF/wtf/text/qt/StringQt.cpp @@ -54,6 +54,13 @@ String::String(QStringView view) m_impl = StringImpl::create(reinterpret_cast_ptr(view.data()), view.length()); } +String::String(QByteArrayView view) +{ + if (view.isNull()) + return; + m_impl = StringImpl::create(reinterpret_cast_ptr(view.data()), view.length()); +} + String::operator QString() const { if (!m_impl) diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp index ce4fffe7c469f..c91ff86720dd1 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp @@ -147,7 +147,7 @@ void QWebFrameAdapter::load(const QNetworkRequest& req, QNetworkAccessManager::O QList httpHeaders = req.rawHeaderList(); for (int i = 0; i < httpHeaders.size(); ++i) { const QByteArray &headerName = httpHeaders.at(i); - request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName))); + request.addHTTPHeaderField(QByteArrayView(headerName), QByteArrayView(req.rawHeader(headerName))); } if (!body.isEmpty()) From bc5d7d3f72cb55a7c57d8eb1b4db6c0c24cba04a Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Sun, 17 Dec 2023 18:15:14 +0000 Subject: [PATCH 50/58] re-add (now non-functional) plugin APIs, to keep compatibility with qtwebkit 5.212.0 --- Source/WebKitLegacy/PlatformQt.cmake | 7 +- .../qt/Api/qwebplugindatabase.cpp | 308 ++++++++++++++++++ .../qt/Api/qwebplugindatabase_p.h | 92 ++++++ .../WebKitLegacy/qt/Api/qwebpluginfactory.cpp | 34 ++ .../qt/Api/qwebsecurityorigin.cpp | 4 +- .../WebKitLegacy/qt/Api/qwebsecurityorigin.h | 4 +- Source/WebKitLegacy/qt/Api/qwebsettings.cpp | 63 ++++ Source/WebKitLegacy/qt/Api/qwebsettings.h | 8 + .../DumpRenderTreeSupportQt.cpp | 5 + .../WebCoreSupport/DumpRenderTreeSupportQt.h | 1 + 10 files changed, 521 insertions(+), 5 deletions(-) create mode 100644 Source/WebKitLegacy/qt/Api/qwebplugindatabase.cpp create mode 100644 Source/WebKitLegacy/qt/Api/qwebplugindatabase_p.h diff --git a/Source/WebKitLegacy/PlatformQt.cmake b/Source/WebKitLegacy/PlatformQt.cmake index 2f4157c95f39f..c98c7d4e25f00 100644 --- a/Source/WebKitLegacy/PlatformQt.cmake +++ b/Source/WebKitLegacy/PlatformQt.cmake @@ -72,6 +72,8 @@ list(APPEND WebKitLegacy_SOURCES qt/Api/qwebhistoryinterface.cpp qt/Api/qwebkitglobal.cpp qt/Api/qwebkitplatformplugin.h + qt/Api/qwebplugindatabase.cpp + qt/Api/qwebpluginfactory.cpp qt/Api/qwebscriptworld.cpp qt/Api/qwebsecurityorigin.cpp qt/Api/qwebsettings.cpp @@ -213,6 +215,7 @@ set(QtWebKit_PUBLIC_FRAMEWORK_HEADERS qt/Api/qwebhistoryinterface.h qt/Api/qwebkitglobal.h qt/Api/qwebkitplatformplugin.h + qt/Api/qwebpluginfactory.h qt/Api/qwebscriptworld.h qt/Api/qwebsecurityorigin.h qt/Api/qwebsettings.h @@ -232,7 +235,8 @@ ecm_generate_headers( QWebFullScreenRequest QWebHistory,QWebHistoryItem QWebHistoryInterface - QWebKitPlatformPlugin,QWebFullScreenVideoHandler,QWebNotificationData,QWebNotificationPresenter,QWebSelectData,QWebSelectMethod,QWebSpellChecker,QWebTouchModifier + QWebKitPlatformPlugin,QWebHapticFeedbackPlayer,QWebFullScreenVideoHandler,QWebNotificationData,QWebNotificationPresenter,QWebSelectData,QWebSelectMethod,QWebSpellChecker,QWebTouchModifier + QWebPluginFactory QWebSecurityOrigin QWebSettings COMMON_HEADER @@ -804,6 +808,7 @@ if (COMPILER_IS_GCC_OR_CLANG) qt/Api/qwebfullscreenrequest.cpp qt/Api/qwebhistory.cpp qt/Api/qwebhistoryinterface.cpp + qt/Api/qwebpluginfactory.cpp qt/Api/qwebscriptworld.cpp qt/Api/qwebsecurityorigin.cpp qt/Api/qwebsettings.cpp diff --git a/Source/WebKitLegacy/qt/Api/qwebplugindatabase.cpp b/Source/WebKitLegacy/qt/Api/qwebplugindatabase.cpp new file mode 100644 index 0000000000000..92ccbd3837edb --- /dev/null +++ b/Source/WebKitLegacy/qt/Api/qwebplugindatabase.cpp @@ -0,0 +1,308 @@ +/* + Copyright (C) 2009 Jakub Wieczorek + + 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 "qwebplugindatabase_p.h" + +using namespace WebCore; + +/*! + \internal + \typedef QWebPluginInfo::MimeType + \since 4.6 + \brief Represents a single MIME type supported by a plugin. +*/ + +/*! + \class QWebPluginInfo + \internal + \since 4.6 + \brief The QWebPluginInfo class represents a single Netscape plugin. + + A QWebPluginInfo object represents a Netscape plugin picked up by WebKit + and included in the plugin database. This class contains information about + the plugin, such as its name(), description(), a list of MIME types that it + supports (can be accessed with mimeTypes()) and the path of the plugin + file. + + Plugins can be enabled and disabled with setEnabled(). If a plugin is + disabled, it will not be used by WebKit to handle supported MIME types. To + check if a plugin is enabled or not, use enabled(). + + \sa QWebPluginDatabase + + \deprecated Plugins have been removed from WebKit. +*/ + +/*! + Constructs a null QWebPluginInfo. + + \deprecated Plugins have been removed from WebKit. +*/ +QWebPluginInfo::QWebPluginInfo() +{ +} + + +/*! + Contructs a copy of \a other. + + \deprecated Plugins have been removed from WebKit. +*/ +QWebPluginInfo::QWebPluginInfo(const QWebPluginInfo& other) +{ +} + +/*! + Destroys the plugin info. + + \deprecated Plugins have been removed from WebKit. +*/ +QWebPluginInfo::~QWebPluginInfo() +{ +} + +/*! + Returns the name of the plugin. + + \sa description() + + \deprecated Plugins have been removed from WebKit. +*/ +QString QWebPluginInfo::name() const +{ + return QString(); +} + +/*! + Returns the description of the plugin. + + \sa name() + + \deprecated Plugins have been removed from WebKit. +*/ +QString QWebPluginInfo::description() const +{ + return QString(); +} + +/*! + Returns a list of MIME types supported by the plugin. + + \sa supportsMimeType() + + \deprecated Plugins have been removed from WebKit. +*/ +QList QWebPluginInfo::mimeTypes() const +{ + return m_mimeTypes; +} + +/*! + Returns true if the plugin supports a specific \a mimeType; otherwise + returns false. + + \sa mimeTypes() + + \deprecated Plugins have been removed from WebKit. +*/ +bool QWebPluginInfo::supportsMimeType(const QString& mimeType) const +{ + return false; +} + +/*! + Returns an absolute path to the plugin file. + + \deprecated Plugins have been removed from WebKit. +*/ +QString QWebPluginInfo::path() const +{ + return QString(); +} + +/*! + Returns true if the plugin is a null plugin; otherwise returns false. + + \deprecated Plugins have been removed from WebKit. +*/ +bool QWebPluginInfo::isNull() const +{ + return true; +} + +/*! + Enables or disables the plugin, depending on the \a enabled parameter. + + Disabled plugins will not be picked up by WebKit when looking for a plugin + supporting a particular MIME type. + + \sa isEnabled() + + \deprecated Plugins have been removed from WebKit. +*/ +void QWebPluginInfo::setEnabled(bool enabled) +{ + return; +} + +/*! + Returns true if the plugin is enabled; otherwise returns false. + + \sa setEnabled() + + \deprecated Plugins have been removed from WebKit. +*/ +bool QWebPluginInfo::isEnabled() const +{ + return false; +} + +/*! + Returns true if this plugin info is the same as the \a other plugin info. + + \deprecated Plugins have been removed from WebKit. +*/ +bool QWebPluginInfo::operator==(const QWebPluginInfo& other) const +{ + return false; +} + +/*! + Returns true if this plugin info is different from the \a other plugin info. + + \deprecated Plugins have been removed from WebKit. +*/ +bool QWebPluginInfo::operator!=(const QWebPluginInfo& other) const +{ + return true; +} + +/*! + Assigns the \a other plugin info to this plugin info, and returns a reference + to this plugin info. + + \deprecated Plugins have been removed from WebKit. +*/ +QWebPluginInfo &QWebPluginInfo::operator=(const QWebPluginInfo& other) +{ + if (this == &other) + return *this; + + m_mimeTypes = other.m_mimeTypes; + + return *this; +} + +/*! + \class QWebPluginDatabase + \internal + \since 4.6 + \brief The QWebPluginDatabase class provides an interface for managing + Netscape plugins used by WebKit in QWebPages. + + The QWebPluginDatabase class is a database of Netscape plugins that are used + by WebKit. The plugins are picked up by WebKit by looking up a set of search paths. + The default set can be accessed using defaultSearchPaths(). The search paths + can be changed, see searchPaths() and setSearchPaths(). Additional search paths + can also be added using addSearchPath(). + + The plugins that have been detected are exposed by the plugins() method. + The list contains QWebPlugin objects that hold both the metadata and the MIME + types that are supported by particular plugins. + + WebKit specifies a plugin for a MIME type by looking for the first plugin that + supports the specific MIME type. To get a plugin, that is used by WebKit to + handle a specific MIME type, you can use the pluginForMimeType() function. + + To change the way of resolving MIME types ambiguity, you can explicitly set + a preferred plugin for a specific MIME type, using setPreferredPluginForMimeType(). + + \sa QWebPluginInfo, QWebSettings::pluginDatabase() + + \deprecated Plugins have been removed from WebKit. +*/ + +QWebPluginDatabase::QWebPluginDatabase(QObject* parent) + : QObject(parent) +{ + qWarning("Plugins have been removed from WebKit."); +} + +QWebPluginDatabase::~QWebPluginDatabase() +{ +} + +/*! + Returns a list of plugins installed in the search paths. + + This list will contain disabled plugins, although they will not be used by + WebKit. + + \sa pluginForMimeType() + + \deprecated Plugins have been removed from WebKit. +*/ +QList QWebPluginDatabase::plugins() const +{ + qWarning("Plugins have been removed from WebKit."); + QList qwebplugins; + return qwebplugins; +} + +/*! + Refreshes the plugin database, adds new plugins that have been found and removes + the ones that are no longer available in the search paths. + + You can call this function when the set of plugins installed in the search paths + changes. You do not need to call this function when changing search paths, + in that case WebKit automatically refreshes the database. + + \deprecated Plugins have been removed from WebKit. +*/ +void QWebPluginDatabase::refresh() +{ + qWarning("Plugins have been removed from WebKit."); +} + +/*! + Returns the plugin that is currently used by WebKit for a given \a mimeType. + + \sa setPreferredPluginForMimeType() + + \deprecated Plugins have been removed from WebKit. +*/ +QWebPluginInfo QWebPluginDatabase::pluginForMimeType(const QString& mimeType) +{ + qWarning("Plugins have been removed from WebKit."); + return QWebPluginInfo(); +} + +/*! + Changes the preferred plugin for a given \a mimeType to \a plugin. The \a plugin + has to support the given \a mimeType, otherwise the setting will have no effect. + + Calling the function with a null \a plugin resets the setting. + + \sa pluginForMimeType() + + \deprecated Plugins have been removed from WebKit. +*/ +void QWebPluginDatabase::setPreferredPluginForMimeType(const QString& mimeType, const QWebPluginInfo& plugin) +{ +} diff --git a/Source/WebKitLegacy/qt/Api/qwebplugindatabase_p.h b/Source/WebKitLegacy/qt/Api/qwebplugindatabase_p.h new file mode 100644 index 0000000000000..ee3ec4677727f --- /dev/null +++ b/Source/WebKitLegacy/qt/Api/qwebplugindatabase_p.h @@ -0,0 +1,92 @@ +/* + Copyright (C) 2009 Jakub Wieczorek + + 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 QWEBPLUGINDATABASE_H +#define QWEBPLUGINDATABASE_H + +#include "qwebkitglobal.h" +#include "qwebpluginfactory.h" + +#include +#include + +namespace WebCore { + class PluginDatabase; + class PluginPackage; +} + +class QWebPluginInfoPrivate; +class QWEBKIT_EXPORT QWebPluginInfo { +public: + QWebPluginInfo(); + QWebPluginInfo(const QWebPluginInfo& other); + QWebPluginInfo &operator=(const QWebPluginInfo& other); + ~QWebPluginInfo(); + +private: + QWebPluginInfo(WebCore::PluginPackage* package); + +public: + typedef QWebPluginFactory::MimeType MimeType; + + QString name() const; + QString description() const; + QList mimeTypes() const; + bool supportsMimeType(const QString& mimeType) const; + QString path() const; + + bool isNull() const; + + void setEnabled(bool enabled); + bool isEnabled() const; + + bool operator==(const QWebPluginInfo& other) const; + bool operator!=(const QWebPluginInfo& other) const; + + friend class QWebPluginDatabase; + +private: + QWebPluginInfoPrivate* d; + WebCore::PluginPackage* m_package; + mutable QList m_mimeTypes; +}; + +class QWebPluginDatabasePrivate; +class QWEBKIT_EXPORT QWebPluginDatabase : public QObject { + Q_OBJECT + +private: + QWebPluginDatabase(QObject* parent = 0); + ~QWebPluginDatabase(); + +public: + QList plugins() const; + + void refresh(); + + QWebPluginInfo pluginForMimeType(const QString& mimeType); + void setPreferredPluginForMimeType(const QString& mimeType, const QWebPluginInfo& plugin); + + friend class QWebSettings; + +private: + QWebPluginDatabasePrivate* d; +}; + +#endif // QWEBPLUGINDATABASE_H diff --git a/Source/WebKitLegacy/qt/Api/qwebpluginfactory.cpp b/Source/WebKitLegacy/qt/Api/qwebpluginfactory.cpp index 84d4fbdc82403..9dc9fbd96d112 100644 --- a/Source/WebKitLegacy/qt/Api/qwebpluginfactory.cpp +++ b/Source/WebKitLegacy/qt/Api/qwebpluginfactory.cpp @@ -56,6 +56,7 @@ The plugins themselves are subclasses of QObject, but currently only plugins based on either QWidget or QGraphicsWidget are supported. + \deprecated Plugins have been removed from WebKit. */ @@ -70,16 +71,22 @@ /*! \variable QWebPluginFactory::Plugin::name The name of the plugin. + + \deprecated Plugins have been removed from WebKit. */ /*! \variable QWebPluginFactory::Plugin::description The description of the plugin. + + \deprecated Plugins have been removed from WebKit. */ /*! \variable QWebPluginFactory::Plugin::mimeTypes The list of mime types supported by the plugin. + + \deprecated Plugins have been removed from WebKit. */ /*! @@ -92,6 +99,8 @@ /*! Returns true if this mimetype is the same as the \a other mime type. + + \deprecated Plugins have been removed from WebKit. */ bool QWebPluginFactory::MimeType::operator==(const MimeType& other) const { @@ -104,17 +113,23 @@ bool QWebPluginFactory::MimeType::operator==(const MimeType& other) const \fn bool QWebPluginFactory::MimeType::operator!=(const MimeType& other) const Returns true if this mimetype is different from the \a other mime type. + + \deprecated Plugins have been removed from WebKit. */ /*! \variable QWebPluginFactory::MimeType::name The full name of the MIME type; e.g., \c{text/plain} or \c{image/png}. + + \deprecated Plugins have been removed from WebKit. */ /*! \variable QWebPluginFactory::MimeType::description The description of the mime type. + + \deprecated Plugins have been removed from WebKit. */ /*! @@ -122,14 +137,19 @@ bool QWebPluginFactory::MimeType::operator==(const MimeType& other) const The list of file extensions that are used by this mime type. For example, a mime type for PDF documents would return "pdf" as its file extension. + + \deprecated Plugins have been removed from WebKit. */ /*! Constructs a QWebPluginFactory with parent \a parent. + + \deprecated Plugins have been removed from WebKit. */ QWebPluginFactory::QWebPluginFactory(QObject *parent) : QObject(parent) { + qWarning("Plugins have been removed from WebKit."); } /*! @@ -147,11 +167,15 @@ QWebPluginFactory::~QWebPluginFactory() \note Currently, this function is only called when JavaScript programs access the global \c plugins or \c mimetypes objects. + + \deprecated Plugins have been removed from WebKit. */ /*! This function is called to refresh the list of supported plugins. It may be called after a new plugin has been installed in the system. + + \deprecated Plugins have been removed from WebKit. */ void QWebPluginFactory::refreshPlugins() { @@ -203,6 +227,8 @@ void QWebPluginFactory::refreshPlugins() should verify that the extension is supported by calling supportsExtension(). Currently there are no extensions. + + \deprecated Plugins have been removed from WebKit. */ /*! @@ -214,6 +240,8 @@ void QWebPluginFactory::refreshPlugins() \inmodule QtWebKit \sa QWebPluginFactory::extension() + + \deprecated Plugins have been removed from WebKit. */ /*! @@ -225,6 +253,8 @@ void QWebPluginFactory::refreshPlugins() \inmodule QtWebKit \sa QWebPluginFactory::extension() + + \deprecated Plugins have been removed from WebKit. */ /*! @@ -240,6 +270,8 @@ void QWebPluginFactory::refreshPlugins() By default, no extensions are supported, and this function returns false. \sa supportsExtension(), Extension + + \deprecated Plugins have been removed from WebKit. */ bool QWebPluginFactory::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) { @@ -255,6 +287,8 @@ bool QWebPluginFactory::extension(Extension extension, const ExtensionOption *op \internal \sa extension() + + \deprecated Plugins have been removed from WebKit. */ bool QWebPluginFactory::supportsExtension(Extension extension) const { diff --git a/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.cpp b/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.cpp index cbe6c1d606132..d1787151da278 100644 --- a/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.cpp +++ b/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.cpp @@ -262,7 +262,7 @@ QWebSecurityOrigin::QWebSecurityOrigin(const QUrl& url) Such cross origin requests are otherwise restricted as per the same-origin-policy. */ -void QWebSecurityOrigin::addAccessAllowlistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting) +void QWebSecurityOrigin::addAccessWhitelistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting) { Ref sourceOrigin(SecurityOrigin::create(d->origin.protocol(), d->origin.host(), d->origin.port())); SecurityPolicy::addOriginAccessAllowlistEntry(sourceOrigin, scheme, host, subdomainSetting == AllowSubdomains); @@ -272,7 +272,7 @@ void QWebSecurityOrigin::addAccessAllowlistEntry(const QString& scheme, const QS Removes the origin's allowlisted access to the specified \a host using the specified \a scheme as per the specified \a subdomainSetting. */ -void QWebSecurityOrigin::removeAccessAllowlistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting) +void QWebSecurityOrigin::removeAccessWhitelistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting) { Ref sourceOrigin(SecurityOrigin::create(d->origin.protocol(), d->origin.host(), d->origin.port())); SecurityPolicy::removeOriginAccessAllowlistEntry(sourceOrigin, scheme, host, subdomainSetting == AllowSubdomains); diff --git a/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.h b/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.h index 72d6c3f66e41c..7142e62b58621 100644 --- a/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.h +++ b/Source/WebKitLegacy/qt/Api/qwebsecurityorigin.h @@ -46,8 +46,8 @@ class QWEBKIT_EXPORT QWebSecurityOrigin { static void removeLocalScheme(const QString& scheme); static QStringList localSchemes(); - void addAccessAllowlistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting); - void removeAccessAllowlistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting); + void addAccessWhitelistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting); + void removeAccessWhitelistEntry(const QString& scheme, const QString& host, SubdomainSetting subdomainSetting); explicit QWebSecurityOrigin(const QUrl& url); ~QWebSecurityOrigin(); diff --git a/Source/WebKitLegacy/qt/Api/qwebsettings.cpp b/Source/WebKitLegacy/qt/Api/qwebsettings.cpp index 974982abec8c5..871248ddb8f85 100644 --- a/Source/WebKitLegacy/qt/Api/qwebsettings.cpp +++ b/Source/WebKitLegacy/qt/Api/qwebsettings.cpp @@ -21,6 +21,7 @@ #include "qwebsettings.h" #include "InitWebCoreQt.h" +#include "qwebplugindatabase_p.h" #include #include @@ -322,6 +323,10 @@ QWebSettings* QWebSettings::globalSettings() cache, icon database, local database storage and offline applications storage. + \section1 Enabling Plugins + + Support for browser plugins has been removed. + \section1 Web Application Support WebKit provides support for features specified in \l{HTML 5} that improve the @@ -385,6 +390,7 @@ QWebSettings* QWebSettings::globalSettings() This enums describes the standard graphical elements used in webpages. \value MissingImageGraphic The replacement graphic shown when an image could not be loaded. + \value MissingPluginGraphic The replacement graphic shown when a plugin could not be loaded. \value DefaultFrameIconGraphic The default icon for QWebFrame::icon(). \value TextAreaSizeGripCornerGraphic The graphic shown for the size grip of text areas. \value DeleteButtonGraphic The graphic shown for the WebKit-Editing-Delete-Button in Deletion UI. @@ -406,6 +412,8 @@ QWebSettings* QWebSettings::globalSettings() programs. This is enabled by default \value JavaEnabled Enables or disables Java applets. Currently Java applets are not supported. + \value PluginsEnabled Enables or disables plugins in Web pages (e.g. using NPAPI). Qt plugins + with a mimetype such as "application/x-qt-plugin" are not affected by this setting. This is disabled by default. \value PrivateBrowsingEnabled Private browsing prevents WebKit from recording visited pages in the history and storing web page icons. This is disabled by default. \value JavascriptCanOpenWindows Specifies whether JavaScript programs @@ -756,10 +764,53 @@ QIcon QWebSettings::iconForUrl(const QUrl& url) return QIcon(); } +/*! + Changes the NPAPI plugin search paths to \a paths. + + \sa pluginSearchPaths() + + \deprecated Plugins have been removed from WebKit. +*/ +void QWebSettings::setPluginSearchPaths(const QStringList& paths) +{ + qWarning("Plugins have been removed from WebKit."); + WebCore::initializeWebCoreQt(); +} + +/*! + Returns a list of search paths that are used by WebKit to look for NPAPI plugins. + + \sa setPluginSearchPaths() + + \deprecated Plugins have been removed from WebKit. +*/ +QStringList QWebSettings::pluginSearchPaths() +{ + qWarning("Plugins have been removed from WebKit."); + WebCore::initializeWebCoreQt(); + + QStringList paths; + return paths; +} + +/* + Returns the plugin database object. + +QWebPluginDatabase *QWebSettings::pluginDatabase() +{ + WebCore::initializeWebCoreQt(); + static QWebPluginDatabase* database = 0; + if (!database) + database = new QWebPluginDatabase(); + return database; +} +*/ + static const char* resourceNameForWebGraphic(QWebSettings::WebGraphic type) { switch (type) { case QWebSettings::MissingImageGraphic: return "missingImage"; + case QWebSettings::MissingPluginGraphic: return "nullPlugin"; case QWebSettings::DefaultFrameIconGraphic: return "urlIcon"; case QWebSettings::TextAreaSizeGripCornerGraphic: return "textAreaResizeCorner"; case QWebSettings::DeleteButtonGraphic: return "deleteButton"; @@ -1198,6 +1249,18 @@ void QWebSettings::enablePersistentStorage(const QString& path) QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); +#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) + // All applications can share the common QtWebkit cache file(s). + // Path is not configurable and uses QDesktopServices::CacheLocation by default. + QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + WebCore::makeAllDirectories(cachePath); + + QFileInfo info(cachePath); + if (info.isDir() && info.isWritable()) { + WebCore::PluginDatabase::setPersistentMetadataCacheEnabled(true); + WebCore::PluginDatabase::setPersistentMetadataCachePath(cachePath); + } +#endif #endif } diff --git a/Source/WebKitLegacy/qt/Api/qwebsettings.h b/Source/WebKitLegacy/qt/Api/qwebsettings.h index edca513757da2..2c22fb46e6771 100644 --- a/Source/WebKitLegacy/qt/Api/qwebsettings.h +++ b/Source/WebKitLegacy/qt/Api/qwebsettings.h @@ -32,6 +32,7 @@ class Page; } class QWebPage; +class QWebPluginDatabase; class QWebSettingsPrivate; QT_BEGIN_NAMESPACE class QUrl; @@ -53,6 +54,7 @@ class QWEBKIT_EXPORT QWebSettings { AutoLoadImages, JavascriptEnabled, JavaEnabled, + PluginsEnabled, PrivateBrowsingEnabled, JavascriptCanOpenWindows, JavascriptCanAccessClipboard, @@ -95,6 +97,7 @@ class QWEBKIT_EXPORT QWebSettings { }; enum WebGraphic { MissingImageGraphic, + MissingPluginGraphic, DefaultFrameIconGraphic, TextAreaSizeGripCornerGraphic, DeleteButtonGraphic, @@ -139,6 +142,11 @@ class QWEBKIT_EXPORT QWebSettings { static void clearIconDatabase(); static QIcon iconForUrl(const QUrl &url); + static void setPluginSearchPaths(const QStringList& paths); + static QStringList pluginSearchPaths(); + + //static QWebPluginDatabase *pluginDatabase(); + static void setWebGraphic(WebGraphic type, const QPixmap &graphic); static QPixmap webGraphic(WebGraphic type); diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index 132acd118b18b..86ac7c0a29106 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -183,6 +183,11 @@ void DumpRenderTreeSupportQt::initialize() QtDRTNodeRuntime::initialize(); } +void DumpRenderTreeSupportQt::overwritePluginDirectories() +{ + qWarning("Plugins have been removed from WebKit."); +} + void DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(bool b) { QWebPageAdapter::drtRun = b; diff --git a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index a94b31e788ff3..960bb15f6e287 100644 --- a/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -117,6 +117,7 @@ class QWEBKIT_EXPORT DumpRenderTreeSupportQt { static QString webPageGroupName(QWebPageAdapter*); static void webPageSetGroupName(QWebPageAdapter*, const QString& groupName); static void clearFrameName(QWebFrameAdapter*); + static void overwritePluginDirectories(); static bool hasDocumentElement(QWebFrameAdapter*); static void setWindowsBehaviorAsEditingBehavior(QWebPageAdapter*); From 0414388e162eafbc0b509fe2e785162fda3c64bb Mon Sep 17 00:00:00 2001 From: Michael Nutt Date: Fri, 22 Dec 2023 08:37:16 -0500 Subject: [PATCH 51/58] enable new layer based svg engine --- .../MediaPlayerPrivateGStreamer.cpp.orig | 4543 +++++++++++++++++ .../MediaPlayerPrivateGStreamer.h.orig | 660 +++ .../qt/WebCoreSupport/ChromeClientQt.h.orig | 255 + Source/cmake/OptionsQt.cmake | 1 + 4 files changed, 5459 insertions(+) create mode 100644 Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp.orig create mode 100644 Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h.orig create mode 100644 Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.h.orig diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp.orig b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp.orig new file mode 100644 index 0000000000000..0a48bd1f70baa --- /dev/null +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp.orig @@ -0,0 +1,4543 @@ +/* + * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007 Collabora Ltd. All rights reserved. + * Copyright (C) 2007 Alp Toker + * Copyright (C) 2009 Gustavo Noronha Silva + * Copyright (C) 2014 Cable Television Laboratories, Inc. + * Copyright (C) 2009, 2019 Igalia S.L + * Copyright (C) 2015, 2019 Metrological Group B.V. + * + * 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 + * aint 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 "MediaPlayerPrivateGStreamer.h" +#include "VideoFrameGStreamer.h" + +#if ENABLE(VIDEO) && USE(GSTREAMER) + +#include "GraphicsContext.h" +#include "GStreamerAudioMixer.h" +#include "GStreamerCommon.h" +#include "GStreamerRegistryScanner.h" +#include "HTTPHeaderNames.h" +#include "ImageGStreamer.h" +#include "ImageOrientation.h" +#include "IntRect.h" +#include "Logging.h" +#include "MediaPlayer.h" +#include "MIMETypeRegistry.h" +#include "NotImplemented.h" +#include "OriginAccessPatterns.h" +#include "SecurityOrigin.h" +#include "TimeRanges.h" +#include "VideoSinkGStreamer.h" +#include "WebKitAudioSinkGStreamer.h" +#include "WebKitWebSourceGStreamer.h" +#include "AudioTrackPrivateGStreamer.h" +#include "InbandMetadataTextTrackPrivateGStreamer.h" +#include "InbandTextTrackPrivateGStreamer.h" +#include "TextCombinerGStreamer.h" +#include "TextSinkGStreamer.h" +#include "VideoFrameMetadataGStreamer.h" +#include "VideoTrackPrivateGStreamer.h" + +#if ENABLE(MEDIA_STREAM) +#include "GStreamerMediaStreamSource.h" +#include "MediaStreamPrivate.h" +#endif + +#if ENABLE(MEDIA_SOURCE) +#include "MediaSource.h" +#include "WebKitMediaSourceGStreamer.h" +#endif + +#if ENABLE(ENCRYPTED_MEDIA) +#include "CDMInstance.h" +#include "GStreamerEMEUtilities.h" +#include "SharedBuffer.h" +#include "WebKitCommonEncryptionDecryptorGStreamer.h" +#endif + +#if ENABLE(WEB_AUDIO) +#include "AudioSourceProviderGStreamer.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if USE(GSTREAMER_MPEGTS) +#define GST_USE_UNSTABLE_API +#include +#undef GST_USE_UNSTABLE_API +#endif // ENABLE(VIDEO) && USE(GSTREAMER_MPEGTS) + +#if USE(GSTREAMER_GL) +#include "GLVideoSinkGStreamer.h" +#endif // USE(GSTREAMER_GL) + +#if USE(TEXTURE_MAPPER) && !PLATFORM(QT) +#include "BitmapTexture.h" +#include "BitmapTexturePool.h" +#include "GStreamerVideoFrameHolder.h" +#include "TextureMapperPlatformLayerBuffer.h" +#include "TextureMapperPlatformLayerProxyGL.h" +#endif // USE(TEXTURE_MAPPER) + +#if USE(TEXTURE_MAPPER_DMABUF) +#include "DMABufFormat.h" +#include "DMABufObject.h" +#include "DMABufVideoSinkGStreamer.h" +#include "GBMBufferSwapchain.h" +#include "TextureMapperPlatformLayerProxyDMABuf.h" +#include +#include +#endif // USE(TEXTURE_MAPPER_DMABUF) + +GST_DEBUG_CATEGORY(webkit_media_player_debug); +#define GST_CAT_DEFAULT webkit_media_player_debug + +namespace WebCore { +using namespace std; + +#if USE(GSTREAMER_HOLEPUNCH) +static const FloatSize s_holePunchDefaultFrameSize(1280, 720); +#endif + +MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player) + : m_notifier(MainThreadNotifier::create()) + , m_player(player) + , m_referrer(player->referrer()) + , m_cachedDuration(MediaTime::invalidTime()) + , m_timeOfOverlappingSeek(MediaTime::invalidTime()) + , m_fillTimer(*this, &MediaPlayerPrivateGStreamer::fillTimerFired) + , m_maxTimeLoaded(MediaTime::zeroTime()) + , m_preload(player->preload()) + , m_maxTimeLoadedAtLastDidLoadingProgress(MediaTime::zeroTime()) + , m_drawTimer(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::repaint) +<<<<<<< HEAD + , m_readyTimerHandler(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::readyTimerFired) +#if USE(TEXTURE_MAPPER) && !USE(NICOSIA) && !PLATFORM(QT) +======= + , m_pausedTimerHandler(RunLoop::main(), this, &MediaPlayerPrivateGStreamer::pausedTimerFired) +#if USE(TEXTURE_MAPPER) && !USE(NICOSIA) +>>>>>>> merge-upstream-2023-12-18 + , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxyGL)) +#endif +#if !RELEASE_LOG_DISABLED + , m_logger(player->mediaPlayerLogger()) + , m_logIdentifier(player->mediaPlayerLogIdentifier()) +#endif +#if USE(TEXTURE_MAPPER_DMABUF) + , m_swapchain(adoptRef(new GBMBufferSwapchain(GBMBufferSwapchain::BufferSwapchainSize::Eight))) +#endif + , m_loader(player->createResourceLoader()) +{ +#if USE(GLIB) && !PLATFORM(QT) + m_pausedTimerHandler.setPriority(G_PRIORITY_DEFAULT_IDLE); +#endif + m_isPlayerShuttingDown.store(false); + +#if USE(TEXTURE_MAPPER) && USE(NICOSIA) && !PLATFORM(QT) + m_nicosiaLayer = Nicosia::ContentLayer::create(*this, + [&]() -> Ref { +#if USE(TEXTURE_MAPPER_DMABUF) + if (webKitDMABufVideoSinkIsEnabled() && webKitDMABufVideoSinkProbePlatform()) + return adoptRef(*new TextureMapperPlatformLayerProxyDMABuf); +#endif + return adoptRef(*new TextureMapperPlatformLayerProxyGL); + }()); +#endif + + ensureGStreamerInitialized(); + m_audioSink = createAudioSink(); + ensureSeekFlags(); +} + +MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer() +{ + GST_DEBUG_OBJECT(pipeline(), "Disposing player"); + m_isPlayerShuttingDown.store(true); + + m_sinkTaskQueue.startAborting(); + + for (auto& track : m_audioTracks.values()) + track->disconnect(); + + for (auto& track : m_textTracks.values()) + track->disconnect(); + + for (auto& track : m_videoTracks.values()) + track->disconnect(); + + if (m_fillTimer.isActive()) + m_fillTimer.stop(); + + m_pausedTimerHandler.stop(); + + if (m_videoSink) { + GRefPtr videoSinkPad = adoptGRef(gst_element_get_static_pad(m_videoSink.get(), "sink")); + g_signal_handlers_disconnect_matched(videoSinkPad.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); + } + + if (m_pipeline) { + disconnectSimpleBusMessageCallback(m_pipeline.get()); + g_signal_handlers_disconnect_matched(m_pipeline.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); + } + +#if USE(GSTREAMER_GL) + if (m_videoDecoderPlatform == GstVideoDecoderPlatform::Video4Linux) + flushCurrentBuffer(); +#endif +#if USE(TEXTURE_MAPPER) && USE(NICOSIA) && !PLATFORM(QT) + m_nicosiaLayer->invalidateClient(); +#endif + + if (m_videoSink) + g_signal_handlers_disconnect_matched(m_videoSink.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); + + if (m_volumeElement) + g_signal_handlers_disconnect_matched(m_volumeElement.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); + + // This will release the GStreamer thread from m_drawCondition in non AC mode in case there's an ongoing triggerRepaint call + // waiting there, and ensure that any triggerRepaint call reaching the lock won't wait on m_drawCondition. + cancelRepaint(true); + +#if ENABLE(ENCRYPTED_MEDIA) + { + Locker cdmAttachmentLocker { m_cdmAttachmentLock }; + m_cdmAttachmentCondition.notifyAll(); + } +#endif + + // The change to GST_STATE_NULL state is always synchronous. So after this gets executed we don't need to worry + // about handlers running in the GStreamer thread. + if (m_pipeline) + gst_element_set_state(m_pipeline.get(), GST_STATE_NULL); + + m_player = nullptr; + m_notifier->invalidate(); +} + +bool MediaPlayerPrivateGStreamer::isAvailable() +{ + return true; +} + +class MediaPlayerFactoryGStreamer final : public MediaPlayerFactory { +private: + MediaPlayerEnums::MediaEngineIdentifier identifier() const final { return MediaPlayerEnums::MediaEngineIdentifier::GStreamer; }; + + Ref createMediaEnginePlayer(MediaPlayer* player) const final + { + return adoptRef(*new MediaPlayerPrivateGStreamer(player)); + } + + void getSupportedTypes(HashSet& types) const final + { + return MediaPlayerPrivateGStreamer::getSupportedTypes(types); + } + + MediaPlayer::SupportsType supportsTypeAndCodecs(const MediaEngineSupportParameters& parameters) const final + { + return MediaPlayerPrivateGStreamer::supportsType(parameters); + } + + bool supportsKeySystem(const String& keySystem, const String& mimeType) const final + { + return MediaPlayerPrivateGStreamer::supportsKeySystem(keySystem, mimeType); + } +}; + +void MediaPlayerPrivateGStreamer::registerMediaEngine(MediaEngineRegistrar registrar) +{ + static std::once_flag onceFlag; + std::call_once(onceFlag, [] { + GST_DEBUG_CATEGORY_INIT(webkit_media_player_debug, "webkitmediaplayer", 0, "WebKit media player"); + }); + registrar(makeUnique()); +} + +void MediaPlayerPrivateGStreamer::load(const String& urlString) +{ + URL url { urlString }; + if (url.protocolIsAbout()) { + loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true); + return; + } + + if (!ensureGStreamerInitialized()) { + loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true); + return; + } + + RefPtr player = m_player.get(); + if (!player) { + loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true); + return; + } + + registerWebKitGStreamerElements(); + + if (!m_pipeline) + createGSTPlayBin(url); + syncOnClock(true); + if (m_fillTimer.isActive()) + m_fillTimer.stop(); + + ASSERT(m_pipeline); + setVisibleInViewport(player->isVisibleInViewport()); + setPlaybinURL(url); + + GST_DEBUG_OBJECT(pipeline(), "preload: %s", convertEnumerationToString(m_preload).utf8().data()); + if (m_preload == MediaPlayer::Preload::None && !isMediaSource()) { + GST_INFO_OBJECT(pipeline(), "Delaying load."); + m_isDelayingLoad = true; + } + + // Reset network and ready states. Those will be set properly once + // the pipeline pre-rolled. + m_networkState = MediaPlayer::NetworkState::Loading; + player->networkStateChanged(); + m_readyState = MediaPlayer::ReadyState::HaveNothing; + player->readyStateChanged(); + m_areVolumeAndMuteInitialized = false; + + if (!m_isDelayingLoad) + commitLoad(); +} + +#if ENABLE(MEDIA_SOURCE) +void MediaPlayerPrivateGStreamer::load(const URL&, const ContentType&, MediaSourcePrivateClient&) +{ + // Properly fail so the global MediaPlayer tries to fallback to the next MediaPlayerPrivate. + m_networkState = MediaPlayer::NetworkState::FormatError; + if (RefPtr player = m_player.get()) + player->networkStateChanged(); +} +#endif + +#if ENABLE(MEDIA_STREAM) +void MediaPlayerPrivateGStreamer::load(MediaStreamPrivate& stream) +{ + m_streamPrivate = &stream; + load(makeString("mediastream://", stream.id())); + syncOnClock(false); + + if (RefPtr player = m_player.get()) + player->play(); +} +#endif + +void MediaPlayerPrivateGStreamer::cancelLoad() +{ + if (m_networkState < MediaPlayer::NetworkState::Loading || m_networkState == MediaPlayer::NetworkState::Loaded) + return; + + if (m_pipeline) + changePipelineState(GST_STATE_READY); +} + +void MediaPlayerPrivateGStreamer::prepareToPlay() +{ + GST_DEBUG_OBJECT(pipeline(), "Prepare to play"); + m_preload = MediaPlayer::Preload::Auto; + if (m_isDelayingLoad) { + m_isDelayingLoad = false; + commitLoad(); + } +} + +void MediaPlayerPrivateGStreamer::play() +{ + if (isMediaStreamPlayer()) { + m_pausedTime = MediaTime::invalidTime(); + if (m_startTime.isInvalid()) + m_startTime = MediaTime::createWithDouble(MonotonicTime::now().secondsSinceEpoch().value()); + } + + if (!m_playbackRate) { + if (m_playbackRatePausedState == PlaybackRatePausedState::ManuallyPaused) + m_playbackRatePausedState = PlaybackRatePausedState::RatePaused; + return; + } + + if (changePipelineState(GST_STATE_PLAYING)) { + m_isEndReached = false; + m_isDelayingLoad = false; + m_preload = MediaPlayer::Preload::Auto; + updateDownloadBufferingFlag(); + GST_INFO_OBJECT(pipeline(), "Play"); + RefPtr player = m_player.get(); + if (player && player->isLooping()) { + GST_DEBUG_OBJECT(pipeline(), "Scheduling initial SEGMENT seek"); + doSeek(SeekTarget { playbackPosition() }, m_playbackRate); + } + } else + loadingFailed(MediaPlayer::NetworkState::Empty); +} + +void MediaPlayerPrivateGStreamer::pause() +{ + if (isMediaStreamPlayer()) + m_pausedTime = currentMediaTime(); + + m_playbackRatePausedState = PlaybackRatePausedState::ManuallyPaused; + GstState currentState, pendingState; + gst_element_get_state(m_pipeline.get(), ¤tState, &pendingState, 0); + if (currentState < GST_STATE_PAUSED && pendingState <= GST_STATE_PAUSED) + return; + + if (changePipelineState(GST_STATE_PAUSED)) + GST_INFO_OBJECT(pipeline(), "Pause"); + else + loadingFailed(MediaPlayer::NetworkState::Empty); +} + +bool MediaPlayerPrivateGStreamer::paused() const +{ + if (!m_pipeline) + return true; + + if (m_isEndReached) { + GST_DEBUG_OBJECT(pipeline(), "Ignoring pause at EOS"); + return true; + } + + if (m_playbackRatePausedState == PlaybackRatePausedState::RatePaused + || m_playbackRatePausedState == PlaybackRatePausedState::ShouldMoveToPlaying) { + GST_DEBUG_OBJECT(pipeline(), "Playback rate is 0, simulating PAUSED state"); + return false; + } + + GstState state, pending; + auto stateChange = gst_element_get_state(m_pipeline.get(), &state, &pending, 0); + bool paused = state <= GST_STATE_PAUSED || (stateChange == GST_STATE_CHANGE_ASYNC && pending == GST_STATE_PAUSED); + GST_LOG_OBJECT(pipeline(), "Paused: %s (state %s, pending %s, state change %s)", boolForPrinting(paused), + gst_element_state_get_name(state), gst_element_state_get_name(pending), gst_element_state_change_return_get_name(stateChange)); + return paused; +} + +bool MediaPlayerPrivateGStreamer::doSeek(const SeekTarget& target, float rate) +{ + RefPtr player = m_player.get(); + + // Default values for rate >= 0. + MediaTime startTime = target.time, endTime = MediaTime::invalidTime(); + + if (rate < 0) { + startTime = MediaTime::zeroTime(); + // If we are at beginning of media, start from the end to avoid immediate EOS. + endTime = target.time <= MediaTime::zeroTime() ? durationMediaTime() : target.time; + } + + if (!rate) + rate = 1.0; + + if (m_hasWebKitWebSrcSentEOS && m_downloadBuffer) { + GST_DEBUG_OBJECT(pipeline(), "Setting high-percent=0 on GstDownloadBuffer to force 100%% buffered reporting"); + g_object_set(m_downloadBuffer.get(), "high-percent", 0, nullptr); + } + + if (paused() && !m_isEndReached && player && player->isLooping()) { + GST_DEBUG_OBJECT(pipeline(), "Segment non-flushing seek attempt not supported on a paused pipeline, enabling flush"); + m_seekFlags = static_cast((m_seekFlags | GST_SEEK_FLAG_FLUSH) & ~GST_SEEK_FLAG_SEGMENT); + } + + if (rate && player && player->isLooping() && startTime >= durationMediaTime()) { + didEnd(); + return true; + } + + auto seekStart = toGstClockTime(startTime); + auto seekStop = toGstClockTime(endTime); + GST_DEBUG_OBJECT(pipeline(), "[Seek] Performing actual seek to %" GST_TIMEP_FORMAT " (endTime: %" GST_TIMEP_FORMAT ") at rate %f", &seekStart, &seekStop, rate); + return gst_element_seek(m_pipeline.get(), rate, GST_FORMAT_TIME, m_seekFlags, GST_SEEK_TYPE_SET, seekStart, GST_SEEK_TYPE_SET, seekStop); +} + +void MediaPlayerPrivateGStreamer::seekToTarget(const SeekTarget& inTarget) +{ + if (!m_pipeline || m_didErrorOccur || isMediaStreamPlayer()) + return; + + GST_INFO_OBJECT(pipeline(), "[Seek] seek attempt to %s", toString(inTarget.time).utf8().data()); + + // Avoid useless seeking. + if (inTarget.time == currentMediaTime()) { + GST_DEBUG_OBJECT(pipeline(), "[Seek] Already at requested position. Aborting."); + timeChanged(inTarget.time); + return; + } + + if (m_isLiveStream.value_or(false)) { + GST_DEBUG_OBJECT(pipeline(), "[Seek] Live stream seek unhandled"); + return; + } + + RefPtr player = m_player.get(); + if (!player) { + GST_DEBUG_OBJECT(pipeline(), "[Seek] m_player is nullptr"); + return; + } + + auto target = inTarget; + target.time = std::min(inTarget.time, durationMediaTime()); + GST_INFO_OBJECT(pipeline(), "[Seek] seeking to %s", toString(target.time).utf8().data()); + + if (m_isSeeking) { + m_timeOfOverlappingSeek = target.time; + if (m_isSeekPending) { + m_seekTarget = target; + return; + } + } + + GstState state; + GstStateChangeReturn getStateResult = gst_element_get_state(m_pipeline.get(), &state, nullptr, 0); + if (getStateResult == GST_STATE_CHANGE_FAILURE || getStateResult == GST_STATE_CHANGE_NO_PREROLL) { + GST_DEBUG_OBJECT(pipeline(), "[Seek] cannot seek, current state change is %s", gst_element_state_change_return_get_name(getStateResult)); + return; + } + + if (player->isLooping() && isSeamlessSeekingEnabled() && state > GST_STATE_PAUSED) { + // Segment seeking is synchronous, the pipeline state has not changed, no flush is done. + GST_DEBUG_OBJECT(pipeline(), "Performing segment seek"); + m_isSeeking = true; + if (!doSeek(target, player->rate())) { + GST_DEBUG_OBJECT(pipeline(), "[Seek] seeking to %s failed", toString(target.time).utf8().data()); + return; + } + m_isEndReached = false; + m_isSeeking = false; + m_cachedPosition = MediaTime::zeroTime(); + timeChanged(target.time); + return; + } + + if (getStateResult == GST_STATE_CHANGE_ASYNC || state < GST_STATE_PAUSED || m_isEndReached) { + m_isSeekPending = true; + if (m_isEndReached && (!player->isLooping() || !isSeamlessSeekingEnabled())) { + GST_DEBUG_OBJECT(pipeline(), "[Seek] reset pipeline"); + m_shouldResetPipeline = true; + if (!changePipelineState(GST_STATE_PAUSED)) + loadingFailed(MediaPlayer::NetworkState::Empty); + } + } else { + // We can seek now. + if (!doSeek(target, player->rate())) { + GST_DEBUG_OBJECT(pipeline(), "[Seek] seeking to %s failed", toString(target.time).utf8().data()); + return; + } + } + + m_isSeeking = true; + m_seekTarget = target; + m_isEndReached = false; +} + +void MediaPlayerPrivateGStreamer::updatePlaybackRate() +{ + if (isMediaStreamPlayer() || !m_isChangingRate) + return; + + GST_INFO_OBJECT(pipeline(), "Set playback rate to %f", m_playbackRate); + + // Mute the sound if the playback rate is negative or too extreme and audio pitch is not adjusted. + bool mute = m_playbackRate <= 0 || (!m_shouldPreservePitch && (m_playbackRate < 0.8 || m_playbackRate > 2)); + + GST_INFO_OBJECT(pipeline(), mute ? "Need to mute audio" : "Do not need to mute audio"); + + if (m_lastPlaybackRate != m_playbackRate) { + if (doSeek(SeekTarget { playbackPosition() }, m_playbackRate)) { + g_object_set(m_pipeline.get(), "mute", mute, nullptr); + m_lastPlaybackRate = m_playbackRate; + } else { + GST_ERROR_OBJECT(pipeline(), "Set rate to %f failed", m_playbackRate); + m_playbackRate = m_lastPlaybackRate; + } + } + + m_isChangingRate = false; + if (RefPtr player = m_player.get()) + player->rateChanged(); +} + +MediaTime MediaPlayerPrivateGStreamer::durationMediaTime() const +{ + if (isMediaStreamPlayer()) + return MediaTime::positiveInfiniteTime(); + + GST_TRACE_OBJECT(pipeline(), "Cached duration: %s", m_cachedDuration.toString().utf8().data()); + if (m_cachedDuration.isValid()) + return m_cachedDuration; + + MediaTime duration = platformDuration(); + if (!duration || duration.isInvalid()) + return MediaTime::zeroTime(); + + m_cachedDuration = duration; + + return m_cachedDuration; +} + +MediaTime MediaPlayerPrivateGStreamer::currentMediaTime() const +{ + if (isMediaStreamPlayer()) { + if (m_pausedTime) + return m_pausedTime; + + return MediaTime::createWithDouble(MonotonicTime::now().secondsSinceEpoch().value()) - m_startTime; + } + + if (!m_pipeline || m_didErrorOccur) + return MediaTime::invalidTime(); + + GST_TRACE_OBJECT(pipeline(), "seeking: %s, seekTarget: %s", boolForPrinting(m_isSeeking), m_seekTarget.toString().utf8().data()); + if (m_isSeeking) + return m_seekTarget.time; + + return playbackPosition(); +} + +void MediaPlayerPrivateGStreamer::setRate(float rate) +{ + RefPtr player = m_player.get(); + + float rateClamped = clampTo(rate, -20.0, 20.0); + if (rateClamped != rate) + GST_WARNING_OBJECT(pipeline(), "Clamping original rate (%f) to [-20, 20] (%f), higher rates cause crashes", rate, rateClamped); + + GST_DEBUG_OBJECT(pipeline(), "Setting playback rate to %f", rateClamped); + // Avoid useless playback rate update. + if (m_playbackRate == rateClamped) { + // And make sure that upper layers were notified if rate was set. + + if (!m_isChangingRate && player && player->rate() != m_playbackRate) + player->rateChanged(); + return; + } + + if (m_isLiveStream.value_or(false)) { + // Notify upper layers that we cannot handle passed rate. + m_isChangingRate = false; + if (player) + player->rateChanged(); + return; + } + + m_playbackRate = rateClamped; + m_isChangingRate = true; + + if (!rateClamped) { + m_isChangingRate = false; + if (m_playbackRatePausedState == PlaybackRatePausedState::Playing || m_playbackRatePausedState == PlaybackRatePausedState::ShouldMoveToPlaying) { + m_playbackRatePausedState = PlaybackRatePausedState::RatePaused; + updateStates(); + } + return; + } else if (m_playbackRatePausedState == PlaybackRatePausedState::RatePaused) { + m_playbackRatePausedState = PlaybackRatePausedState::ShouldMoveToPlaying; + updateStates(); + } + + GstState state, pending; + gst_element_get_state(m_pipeline.get(), &state, &pending, 0); + if ((state != GST_STATE_PLAYING && state != GST_STATE_PAUSED) + || (pending == GST_STATE_PAUSED)) + return; + + updatePlaybackRate(); +} + +double MediaPlayerPrivateGStreamer::rate() const +{ + return m_playbackRate; +} + +void MediaPlayerPrivateGStreamer::setPreservesPitch(bool preservesPitch) +{ + GST_DEBUG_OBJECT(pipeline(), "Preserving audio pitch: %s", boolForPrinting(preservesPitch)); + m_shouldPreservePitch = preservesPitch; +} + +void MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload) +{ + if (isMediaStreamPlayer()) + return; + + GST_DEBUG_OBJECT(pipeline(), "Setting preload to %s", convertEnumerationToString(preload).utf8().data()); + if (preload == MediaPlayer::Preload::Auto && m_isLiveStream.value_or(false)) + return; + + m_preload = preload; + updateDownloadBufferingFlag(); + + if (m_isDelayingLoad && m_preload != MediaPlayer::Preload::None) { + m_isDelayingLoad = false; + commitLoad(); + } +} + +const PlatformTimeRanges& MediaPlayerPrivateGStreamer::buffered() const +{ + if (m_didErrorOccur || m_isLiveStream.value_or(false)) + return PlatformTimeRanges::emptyRanges(); + + MediaTime mediaDuration = durationMediaTime(); + if (!mediaDuration || mediaDuration.isPositiveInfinite()) + return PlatformTimeRanges::emptyRanges(); + + GRefPtr query = adoptGRef(gst_query_new_buffering(GST_FORMAT_PERCENT)); + + if (!gst_element_query(m_pipeline.get(), query.get())) + return PlatformTimeRanges::emptyRanges(); + + m_buffered.clear(); + unsigned numBufferingRanges = gst_query_get_n_buffering_ranges(query.get()); + for (unsigned index = 0; index < numBufferingRanges; index++) { + gint64 rangeStart = 0, rangeStop = 0; + if (gst_query_parse_nth_buffering_range(query.get(), index, &rangeStart, &rangeStop)) { + uint64_t startTime = gst_util_uint64_scale_int_round(toGstUnsigned64Time(mediaDuration), rangeStart, GST_FORMAT_PERCENT_MAX); + uint64_t stopTime = gst_util_uint64_scale_int_round(toGstUnsigned64Time(mediaDuration), rangeStop, GST_FORMAT_PERCENT_MAX); + m_buffered.add(MediaTime(startTime, GST_SECOND), MediaTime(stopTime, GST_SECOND)); + } + } + + // Fallback to the more general maxTimeLoaded() if no range has been found. + if (!m_buffered.length()) { + MediaTime loaded = maxTimeLoaded(); + if (loaded.isValid() && loaded) + m_buffered.add(MediaTime::zeroTime(), loaded); + } + + return m_buffered; +} + +MediaTime MediaPlayerPrivateGStreamer::maxMediaTimeSeekable() const +{ + GST_TRACE_OBJECT(pipeline(), "errorOccured: %s, isLiveStream: %s", boolForPrinting(m_didErrorOccur), boolForPrinting(m_isLiveStream)); + if (m_didErrorOccur) + return MediaTime::zeroTime(); + + if (m_isLiveStream.value_or(false)) + return MediaTime::zeroTime(); + + if (isMediaStreamPlayer()) + return MediaTime::zeroTime(); + + MediaTime duration = durationMediaTime(); + GST_DEBUG_OBJECT(pipeline(), "maxMediaTimeSeekable, duration: %s", toString(duration).utf8().data()); + // Infinite duration means live stream. + if (duration.isPositiveInfinite()) + return MediaTime::zeroTime(); + + return duration; +} + +MediaTime MediaPlayerPrivateGStreamer::maxTimeLoaded() const +{ + if (m_didErrorOccur) + return MediaTime::zeroTime(); + + MediaTime loaded = m_maxTimeLoaded; + if (m_isEndReached) + loaded = durationMediaTime(); + GST_LOG_OBJECT(pipeline(), "maxTimeLoaded: %s", toString(loaded).utf8().data()); + return loaded; +} + +bool MediaPlayerPrivateGStreamer::didLoadingProgress() const +{ + if (m_didErrorOccur || m_loadingStalled) + return false; + + if (WEBKIT_IS_WEB_SRC(m_source.get())) { + GST_LOG_OBJECT(pipeline(), "Last network read position: %" G_GUINT64_FORMAT ", current: %" G_GUINT64_FORMAT, m_readPositionAtLastDidLoadingProgress, m_networkReadPosition); + bool didLoadingProgress = m_readPositionAtLastDidLoadingProgress < m_networkReadPosition; + m_readPositionAtLastDidLoadingProgress = m_networkReadPosition; + GST_LOG_OBJECT(pipeline(), "didLoadingProgress: %s", boolForPrinting(didLoadingProgress)); + return didLoadingProgress; + } + + if (UNLIKELY(!m_pipeline || !durationMediaTime() || (!isMediaSource() && !totalBytes()))) + return false; + + MediaTime currentMaxTimeLoaded = maxTimeLoaded(); + bool didLoadingProgress = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress; + m_maxTimeLoadedAtLastDidLoadingProgress = currentMaxTimeLoaded; + GST_LOG_OBJECT(pipeline(), "didLoadingProgress: %s", boolForPrinting(didLoadingProgress)); + return didLoadingProgress; +} + +unsigned long long MediaPlayerPrivateGStreamer::totalBytes() const +{ + if (m_didErrorOccur || !m_source || m_isLiveStream.value_or(false) || isMediaStreamPlayer()) + return 0; + + if (m_totalBytes) + return m_totalBytes; + + GstFormat fmt = GST_FORMAT_BYTES; + gint64 length = 0; + if (gst_element_query_duration(m_source.get(), fmt, &length)) { + GST_INFO_OBJECT(pipeline(), "totalBytes %" G_GINT64_FORMAT, length); + m_totalBytes = static_cast(length); + m_isLiveStream = !length; + return m_totalBytes; + } + + // Fall back to querying the source pads manually. See also https://bugzilla.gnome.org/show_bug.cgi?id=638749 + GstIterator* iter = gst_element_iterate_src_pads(m_source.get()); + bool done = false; + while (!done) { + GValue item = G_VALUE_INIT; + switch (gst_iterator_next(iter, &item)) { + case GST_ITERATOR_OK: { + GstPad* pad = static_cast(g_value_get_object(&item)); + gint64 padLength = 0; + if (gst_pad_query_duration(pad, fmt, &padLength) && padLength > length) + length = padLength; + break; + } + case GST_ITERATOR_RESYNC: + gst_iterator_resync(iter); + break; + case GST_ITERATOR_ERROR: + FALLTHROUGH; + case GST_ITERATOR_DONE: + done = true; + break; + } + + g_value_unset(&item); + } + + gst_iterator_free(iter); + + GST_INFO_OBJECT(pipeline(), "totalBytes %" G_GINT64_FORMAT, length); + m_totalBytes = static_cast(length); + m_isLiveStream = !length; + return m_totalBytes; +} + +std::optional MediaPlayerPrivateGStreamer::isCrossOrigin(const SecurityOrigin& origin) const +{ + if (WEBKIT_IS_WEB_SRC(m_source.get())) + return webKitSrcIsCrossOrigin(WEBKIT_WEB_SRC(m_source.get()), origin); + return false; +} + +void MediaPlayerPrivateGStreamer::simulateAudioInterruption() +{ + GstMessage* message = gst_message_new_request_state(GST_OBJECT(m_pipeline.get()), GST_STATE_PAUSED); + gst_element_post_message(m_pipeline.get(), message); +} + +#if ENABLE(WEB_AUDIO) +void MediaPlayerPrivateGStreamer::ensureAudioSourceProvider() +{ + if (!m_audioSourceProvider) + m_audioSourceProvider = AudioSourceProviderGStreamer::create(); +} + +AudioSourceProvider* MediaPlayerPrivateGStreamer::audioSourceProvider() +{ + ensureAudioSourceProvider(); + return m_audioSourceProvider.get(); +} +#endif + +void MediaPlayerPrivateGStreamer::durationChanged() +{ + MediaTime previousDuration = durationMediaTime(); + m_cachedDuration = MediaTime::invalidTime(); + + // Avoid emitting durationChanged in the case where the previous + // duration was 0 because that case is already handled by the + // HTMLMediaElement. + if (previousDuration && durationMediaTime() != previousDuration) { + if (RefPtr player = m_player.get()) + player->durationChanged(); + } +} + +void MediaPlayerPrivateGStreamer::sourceSetup(GstElement* sourceElement) +{ + GST_DEBUG_OBJECT(pipeline(), "Source element set-up for %s", GST_ELEMENT_NAME(sourceElement)); + + m_source = sourceElement; + + if (WEBKIT_IS_WEB_SRC(m_source.get())) { + auto* source = WEBKIT_WEB_SRC_CAST(m_source.get()); + webKitWebSrcSetReferrer(source, m_referrer); + webKitWebSrcSetResourceLoader(source, m_loader); +#if ENABLE(MEDIA_STREAM) + } else if (WEBKIT_IS_MEDIA_STREAM_SRC(sourceElement)) { + RefPtr player = m_player.get(); + auto stream = m_streamPrivate.get(); + ASSERT(stream); + webkitMediaStreamSrcSetStream(WEBKIT_MEDIA_STREAM_SRC(sourceElement), stream, player && player->isVideoPlayer()); +#endif + } +} + +void MediaPlayerPrivateGStreamer::sourceSetupCallback(MediaPlayerPrivateGStreamer* player, GstElement* sourceElement) +{ + player->sourceSetup(sourceElement); +} + +bool MediaPlayerPrivateGStreamer::changePipelineState(GstState newState) +{ + ASSERT(m_pipeline); + + if (!m_isVisibleInViewport && newState > GST_STATE_PAUSED) { + GST_DEBUG_OBJECT(pipeline(), "Saving state for when player becomes visible: %s", gst_element_state_get_name(newState)); + m_invisiblePlayerState = newState; + return true; + } + + GstState currentState, pending; + gst_element_get_state(m_pipeline.get(), ¤tState, &pending, 0); + GST_DEBUG_OBJECT(pipeline(), "Changing state change to %s from %s with %s pending", gst_element_state_get_name(newState), + gst_element_state_get_name(currentState), gst_element_state_get_name(pending)); + + GstStateChangeReturn setStateResult = gst_element_set_state(m_pipeline.get(), newState); + GstState pausedOrPlaying = newState == GST_STATE_PLAYING ? GST_STATE_PAUSED : GST_STATE_PLAYING; + if (currentState != pausedOrPlaying && setStateResult == GST_STATE_CHANGE_FAILURE) + return false; + + // Create a timer when entering the READY state so that we can free resources if we stay for too long on READY. + // Also lets remove the timer if we request a state change for any state other than READY. See also https://bugs.webkit.org/show_bug.cgi?id=117354 + if (RefPtr player = m_player.get(); newState == GST_STATE_PAUSED && m_isEndReached && player && !player->isLooping() + && !isMediaSource() && !m_pausedTimerHandler.isActive()) { + // Max interval in seconds to stay in the PAUSED state after video finished on manual state change requests. + static const Seconds readyStateTimerDelay { 5_min }; + m_pausedTimerHandler.startOneShot(readyStateTimerDelay); + } else if (newState != GST_STATE_PAUSED) + m_pausedTimerHandler.stop(); + + return true; +} + +void MediaPlayerPrivateGStreamer::setPlaybinURL(const URL& url) +{ + // Clean out everything after file:// url path. + String cleanURLString(url.string()); + if (url.protocolIsFile()) + cleanURLString = cleanURLString.left(url.pathEnd()); + + m_url = URL { cleanURLString }; + GST_INFO_OBJECT(pipeline(), "Load %s", m_url.string().utf8().data()); + g_object_set(m_pipeline.get(), "uri", m_url.string().utf8().data(), nullptr); +} + +static void setSyncOnClock(GstElement *element, bool sync) +{ + if (!element) + return; + + if (!GST_IS_BIN(element)) { + g_object_set(element, "sync", sync, nullptr); + return; + } + + GUniquePtr iterator(gst_bin_iterate_sinks(GST_BIN_CAST(element))); + while (gst_iterator_foreach(iterator.get(), static_cast([](const GValue* item, void* syncPtr) { + bool* sync = static_cast(syncPtr); + setSyncOnClock(GST_ELEMENT_CAST(g_value_get_object(item)), *sync); + }), &sync) == GST_ITERATOR_RESYNC) + gst_iterator_resync(iterator.get()); +} + +void MediaPlayerPrivateGStreamer::syncOnClock(bool sync) +{ +#if !USE(WESTEROS_SINK) + setSyncOnClock(videoSink(), sync); + setSyncOnClock(audioSink(), sync); +#endif +} + +template +void MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() +{ + if (UNLIKELY(!m_pipeline || !m_source)) + return; + + RefPtr player = m_player.get(); + if (!player) + return; + + ASSERT(m_isLegacyPlaybin); + + using TrackType = TrackPrivateBaseGStreamer::TrackType; + std::variant>*, HashMap>*, HashMap>*> variantTracks = static_cast>*>(0); + auto type(static_cast(variantTracks.index())); + const char* typeName; + bool* hasType; + switch (type) { + case TrackType::Audio: + typeName = "audio"; + hasType = &m_hasAudio; + variantTracks = &m_audioTracks; + break; + case TrackType::Video: + typeName = "video"; + hasType = &m_hasVideo; + variantTracks = &m_videoTracks; + break; + case TrackType::Text: + typeName = "text"; + hasType = nullptr; + variantTracks = &m_textTracks; + break; + default: + ASSERT_NOT_REACHED(); + } + auto& tracks = *std::get>*>(variantTracks); + + // Ignore notifications after a EOS. We don't want the tracks to disappear when the video is finished. + if (m_isEndReached && (type == TrackType::Audio || type == TrackType::Video)) + return; + + unsigned numberOfTracks = 0; + StringPrintStream numberOfTracksProperty; + numberOfTracksProperty.printf("n-%s", typeName); + g_object_get(m_pipeline.get(), numberOfTracksProperty.toCString().data(), &numberOfTracks, nullptr); + + GST_INFO_OBJECT(pipeline(), "Media has %d %s tracks", numberOfTracks, typeName); + + if (hasType) { + bool oldHasType = *hasType; + *hasType = numberOfTracks > 0; + if (oldHasType != *hasType) + player->characteristicChanged(); + + if (*hasType && type == TrackType::Video) + player->sizeChanged(); + } + + Vector validStreams; + StringPrintStream getPadProperty; + getPadProperty.printf("get-%s-pad", typeName); + + bool changed = false; + for (unsigned i = 0; i < numberOfTracks; ++i) { + GRefPtr pad; + g_signal_emit_by_name(m_pipeline.get(), getPadProperty.toCString().data(), i, &pad.outPtr(), nullptr); + ASSERT(pad); + if (!pad) + continue; + + AtomString streamId(TrackPrivateBaseGStreamer::trackIdFromPadStreamStartOrUniqueID(type, i, pad)); + + if (i < tracks.size()) { + RefPtr existingTrack = tracks.get(streamId); + if (existingTrack) { + ASSERT(existingTrack->index() == i); + // TODO: Position of index should remain the same on replay. + existingTrack->setIndex(i); + // If the video has been played twice, the track is still there, but we need + // to update the pad pointer. + if (existingTrack->pad() != pad) + existingTrack->setPad(GRefPtr(pad)); + continue; + } + } + + auto track = TrackPrivateType::create(*this, i, GRefPtr(pad)); + ASSERT(track->stringId() == streamId); + validStreams.append(track->stringId()); + if (!track->trackIndex() && (type == TrackType::Audio || type == TrackType::Video)) + track->setActive(true); + + std::variant variantTrack(&track.get()); + switch (variantTrack.index()) { + case TrackType::Audio: + player->addAudioTrack(*std::get(variantTrack)); + break; + case TrackType::Video: + player->addVideoTrack(*std::get(variantTrack)); + break; + case TrackType::Text: + player->addTextTrack(*std::get(variantTrack)); + break; + } + tracks.add(track->stringId(), WTFMove(track)); + changed = true; + } + + // Purge invalid tracks + changed = changed || tracks.removeIf([validStreams](auto& keyAndValue) { + return !validStreams.contains(keyAndValue.key); + }); + + if (changed) + player->mediaEngineUpdated(); +} + +bool MediaPlayerPrivateGStreamer::hasFirstVideoSampleReachedSink() const +{ + Locker sampleLocker { m_sampleMutex }; + return !!m_sample; +} + +void MediaPlayerPrivateGStreamer::videoSinkCapsChanged(GstPad* videoSinkPad) +{ + GRefPtr caps = adoptGRef(gst_pad_get_current_caps(videoSinkPad)); + if (!caps) { + // This can happen when downgrading the state of the pipeline, which causes the caps to be unset. + return; + } + // We're in videoSinkPad streaming thread. + ASSERT(!isMainThread()); + GST_DEBUG_OBJECT(videoSinkPad, "Received new caps: %" GST_PTR_FORMAT, caps.get()); + + if (!hasFirstVideoSampleReachedSink()) { + // We want to wait for the sink to receive the first buffer before emitting dimensions, since only by then we + // are guaranteed that any potential tag event with a rotation has been handled. + GST_DEBUG_OBJECT(videoSinkPad, "Ignoring notify::caps until the first buffer reaches the sink."); + return; + } + + RunLoop::main().dispatch([weakThis = WeakPtr { *this }, this, caps = WTFMove(caps)] { + if (!weakThis) + return; + updateVideoSizeAndOrientationFromCaps(caps.get()); + }); +} + +void MediaPlayerPrivateGStreamer::handleTextSample(GstSample* sample, const char* streamId) +{ + for (auto& track : m_textTracks.values()) { + if (!strcmp(track->stringId().string().utf8().data(), streamId)) { + track->handleSample(sample); + return; + } + } + + GST_WARNING_OBJECT(m_pipeline.get(), "Got sample with unknown stream ID %s.", streamId); +} + +MediaTime MediaPlayerPrivateGStreamer::platformDuration() const +{ + if (!m_pipeline) + return MediaTime::invalidTime(); + + if (isMediaStreamPlayer()) + return MediaTime::positiveInfiniteTime(); + + GST_TRACE_OBJECT(pipeline(), "errorOccured: %s, pipeline state: %s", boolForPrinting(m_didErrorOccur), gst_element_state_get_name(GST_STATE(m_pipeline.get()))); + if (m_didErrorOccur) + return MediaTime::invalidTime(); + + // The duration query would fail on a not-prerolled pipeline. + if (GST_STATE(m_pipeline.get()) < GST_STATE_PAUSED) + return MediaTime::invalidTime(); + + int64_t duration = 0; + if (!gst_element_query_duration(m_pipeline.get(), GST_FORMAT_TIME, &duration) || !GST_CLOCK_TIME_IS_VALID(duration)) { + GST_DEBUG_OBJECT(pipeline(), "Time duration query failed for %s", m_url.string().utf8().data()); + // https://www.w3.org/TR/2011/WD-html5-20110113/video.html#getting-media-metadata + // In order to be strict with the spec, consider that not "enough of the media data has been fetched to determine + // the duration of the media resource" and therefore return invalidTime only when we know for sure that the + // stream isn't live (treating empty value as unsure). + return m_isLiveStream.value_or(true) ? MediaTime::positiveInfiniteTime() : MediaTime::invalidTime(); + } + + GST_LOG_OBJECT(pipeline(), "Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(duration)); + return MediaTime(duration, GST_SECOND); +} + +bool MediaPlayerPrivateGStreamer::isMuted() const +{ + GST_INFO_OBJECT(pipeline(), "Player is muted: %s", boolForPrinting(m_isMuted)); + return m_isMuted; +} + +void MediaPlayerPrivateGStreamer::commitLoad() +{ + ASSERT(!m_isDelayingLoad); + GST_DEBUG_OBJECT(pipeline(), "Committing load."); + + // GStreamer needs to have the pipeline set to a paused state to + // start providing anything useful. + changePipelineState(GST_STATE_PAUSED); + + updateDownloadBufferingFlag(); + updateStates(); +} + +void MediaPlayerPrivateGStreamer::fillTimerFired() +{ + if (m_didErrorOccur) { + GST_DEBUG_OBJECT(pipeline(), "[Buffering] An error occurred, disabling the fill timer"); + m_fillTimer.stop(); + return; + } + + GRefPtr query = adoptGRef(gst_query_new_buffering(GST_FORMAT_PERCENT)); + double fillStatus = 100.0; + GstBufferingMode mode = GST_BUFFERING_DOWNLOAD; + + if (gst_element_query(pipeline(), query.get())) { + gst_query_parse_buffering_stats(query.get(), &mode, nullptr, nullptr, nullptr); + + int percentage; + gst_query_parse_buffering_percent(query.get(), nullptr, &percentage); + fillStatus = percentage; + } else if (m_httpResponseTotalSize) { + GST_DEBUG_OBJECT(pipeline(), "[Buffering] Query failed, falling back to network read position estimation"); + fillStatus = 100.0 * (static_cast(m_networkReadPosition) / static_cast(m_httpResponseTotalSize)); + } else { + GST_DEBUG_OBJECT(pipeline(), "[Buffering] Unable to determine on-disk buffering status"); + return; + } + + updateBufferingStatus(mode, fillStatus); +} + +void MediaPlayerPrivateGStreamer::loadStateChanged() +{ + updateStates(); +} + +void MediaPlayerPrivateGStreamer::timeChanged(const MediaTime& seekedTime) +{ + updateStates(); + GST_DEBUG_OBJECT(pipeline(), "Emitting timeChanged notification (seekCompleted:%d)", seekedTime.isValid()); + if (RefPtr player = m_player.get()) { + if (seekedTime.isValid()) + player->seeked(seekedTime); + player->timeChanged(); + } +} + +void MediaPlayerPrivateGStreamer::loadingFailed(MediaPlayer::NetworkState networkError, MediaPlayer::ReadyState readyState, bool forceNotifications) +{ + GST_WARNING("Loading failed, error: %s", convertEnumerationToString(networkError).utf8().data()); + + RefPtr player = m_player.get(); + + m_didErrorOccur = true; + if (forceNotifications || m_networkState != networkError) { + m_networkState = networkError; + if (player) + player->networkStateChanged(); + } + if (forceNotifications || m_readyState != readyState) { + m_readyState = readyState; + if (player) + player->readyStateChanged(); + } + + // Loading failed, remove ready timer. + m_pausedTimerHandler.stop(); +} + +GstElement* MediaPlayerPrivateGStreamer::createAudioSink() +{ +#if PLATFORM(BROADCOM) || USE(WESTEROS_SINK) || PLATFORM(AMLOGIC) || PLATFORM(REALTEK) + // If audio is being controlled by an another pipeline, creating sink here may interfere with + // audio playback. Instead, check if an audio sink was setup in handleMessage and use it. + return nullptr; +#endif + + RefPtr player = m_player.get(); + if (!player) + return nullptr; + + // For platform specific audio sinks, they need to be properly upranked so that they get properly autoplugged. + + auto role = player->isVideoPlayer() ? "video"_s : "music"_s; + GstElement* audioSink = createPlatformAudioSink(role); + RELEASE_ASSERT(audioSink); + if (!audioSink) + return nullptr; + +#if ENABLE(WEB_AUDIO) + GstElement* audioSinkBin = gst_bin_new("audio-sink"); + ensureAudioSourceProvider(); + m_audioSourceProvider->configureAudioBin(audioSinkBin, audioSink); + return audioSinkBin; +#else + return audioSink; +#endif +} + +bool MediaPlayerPrivateGStreamer::isMediaStreamPlayer() const +{ +#if ENABLE(MEDIA_STREAM) + if (m_source) + return WEBKIT_IS_MEDIA_STREAM_SRC(m_source.get()); +#endif + return m_url.protocolIs("mediastream"_s); +} + +GstClockTime MediaPlayerPrivateGStreamer::gstreamerPositionFromSinks() const +{ + gint64 gstreamerPosition = GST_CLOCK_TIME_NONE; + // Asking directly to the sinks and choosing the highest value is faster than asking to the pipeline. + GST_TRACE_OBJECT(pipeline(), "Querying position to audio sink (if any)."); + GRefPtr query = adoptGRef(gst_query_new_position(GST_FORMAT_TIME)); + if (m_audioSink && gst_element_query(m_audioSink.get(), query.get())) { + gint64 audioPosition = GST_CLOCK_TIME_NONE; + gst_query_parse_position(query.get(), 0, &audioPosition); + if (GST_CLOCK_TIME_IS_VALID(audioPosition)) + gstreamerPosition = audioPosition; + GST_TRACE_OBJECT(pipeline(), "Audio position %" GST_TIME_FORMAT, GST_TIME_ARGS(audioPosition)); + query = adoptGRef(gst_query_new_position(GST_FORMAT_TIME)); + } + GST_TRACE_OBJECT(pipeline(), "Querying position to video sink (if any)."); + RefPtr player = m_player.get(); + if (player && player->isVideoPlayer() && m_videoSink && gst_element_query(m_videoSink.get(), query.get())) { + gint64 videoPosition = GST_CLOCK_TIME_NONE; + gst_query_parse_position(query.get(), 0, &videoPosition); + GST_TRACE_OBJECT(pipeline(), "Video position %" GST_TIME_FORMAT, GST_TIME_ARGS(videoPosition)); + if (GST_CLOCK_TIME_IS_VALID(videoPosition) && (!GST_CLOCK_TIME_IS_VALID(gstreamerPosition) + || (m_playbackRate >= 0 && videoPosition > gstreamerPosition) + || (m_playbackRate < 0 && videoPosition < gstreamerPosition))) + gstreamerPosition = videoPosition; + } + return static_cast(gstreamerPosition); +} + +MediaTime MediaPlayerPrivateGStreamer::playbackPosition() const +{ + GST_TRACE_OBJECT(pipeline(), "isEndReached: %s, seeking: %s, seekTime: %s", boolForPrinting(m_isEndReached), boolForPrinting(m_isSeeking), m_seekTarget.time.toString().utf8().data()); + +#if ENABLE(MEDIA_STREAM) + RefPtr player = m_player.get(); + if (m_streamPrivate && player && player->isVideoPlayer() && !hasFirstVideoSampleReachedSink()) + return MediaTime::zeroTime(); +#endif + + if (m_isSeeking) + return m_seekTarget.time; + if (m_isEndReached) + return m_playbackRate > 0 ? durationMediaTime() : MediaTime::zeroTime(); + + if (m_isCachedPositionValid) { + GST_TRACE_OBJECT(pipeline(), "Returning cached position: %s", m_cachedPosition.toString().utf8().data()); + return m_cachedPosition; + } + + GstClockTime gstreamerPosition = gstreamerPositionFromSinks(); + GST_TRACE_OBJECT(pipeline(), "Position %" GST_TIME_FORMAT ", canFallBackToLastFinishedSeekPosition: %s", GST_TIME_ARGS(gstreamerPosition), boolForPrinting(m_canFallBackToLastFinishedSeekPosition)); + + // Cached position is marked as non valid here but we might fail to get a new one so initializing to this as "educated guess". + MediaTime playbackPosition = m_cachedPosition; + + if (GST_CLOCK_TIME_IS_VALID(gstreamerPosition)) + playbackPosition = MediaTime(gstreamerPosition, GST_SECOND); + else if (m_canFallBackToLastFinishedSeekPosition) + playbackPosition = m_seekTarget.time; + + setCachedPosition(playbackPosition); + invalidateCachedPositionOnNextIteration(); + return playbackPosition; +} + +void MediaPlayerPrivateGStreamer::updateEnabledVideoTrack() +{ + VideoTrackPrivateGStreamer* wantedTrack = nullptr; + for (auto& pair : m_videoTracks) { + auto& track = pair.value.get(); + if (track.selected()) { + wantedTrack = &track; + break; + } + } + + // No active track, no changes. + if (!wantedTrack) + return; + + if (m_isLegacyPlaybin) { + GST_DEBUG_OBJECT(m_pipeline.get(), "Setting playbin2 current-video=%d", wantedTrack->trackIndex()); + g_object_set(m_pipeline.get(), "current-video", wantedTrack->trackIndex(), nullptr); + } else { + m_wantedVideoStreamId = wantedTrack->stringId(); + playbin3SendSelectStreamsIfAppropriate(); + } +} + +void MediaPlayerPrivateGStreamer::updateEnabledAudioTrack() +{ + AudioTrackPrivateGStreamer* wantedTrack = nullptr; + for (auto& pair : m_audioTracks) { + auto& track = pair.value.get(); + if (track.enabled()) { + wantedTrack = &track; + break; + } + } + + // No active track, no changes. + if (!wantedTrack) + return; + + if (m_isLegacyPlaybin) { + GST_DEBUG_OBJECT(m_pipeline.get(), "Setting playbin2 current-audio=%d", wantedTrack->trackIndex()); + g_object_set(m_pipeline.get(), "current-audio", wantedTrack->trackIndex(), nullptr); + } else { + m_wantedAudioStreamId = wantedTrack->stringId(); + playbin3SendSelectStreamsIfAppropriate(); + } +} + +void MediaPlayerPrivateGStreamer::playbin3SendSelectStreamsIfAppropriate() +{ + ASSERT(!m_isLegacyPlaybin); + + bool haveDifferentStreamIds = (m_wantedAudioStreamId != m_currentAudioStreamId || m_wantedVideoStreamId != m_currentVideoStreamId); + bool shouldSendSelectStreams = !m_waitingForStreamsSelectedEvent && haveDifferentStreamIds && m_currentState == GST_STATE_PLAYING; + GST_DEBUG_OBJECT(m_pipeline.get(), "Checking if to send SELECT_STREAMS, m_waitingForStreamsSelectedEvent = %s, haveDifferentStreamIds = %s, m_currentState = %s... shouldSendSelectStreams = %s", + boolForPrinting(m_waitingForStreamsSelectedEvent), boolForPrinting(haveDifferentStreamIds), gst_element_state_get_name(m_currentState), boolForPrinting(shouldSendSelectStreams)); + if (!shouldSendSelectStreams) + return; + + GList* streams = nullptr; + if (!m_wantedVideoStreamId.isNull()) { + m_requestedVideoStreamId = m_wantedVideoStreamId; + streams = g_list_append(streams, g_strdup(m_wantedVideoStreamId.string().utf8().data())); + } + if (!m_wantedAudioStreamId.isNull()) { + m_requestedAudioStreamId = m_wantedAudioStreamId; + streams = g_list_append(streams, g_strdup(m_wantedAudioStreamId.string().utf8().data())); + } + if (!m_wantedTextStreamId.isNull()) { + m_requestedTextStreamId = m_wantedTextStreamId; + streams = g_list_append(streams, g_strdup(m_wantedTextStreamId.string().utf8().data())); + } + + if (!streams) + return; + + m_waitingForStreamsSelectedEvent = true; + gst_element_send_event(m_pipeline.get(), gst_event_new_select_streams(streams)); + g_list_free_full(streams, reinterpret_cast(g_free)); +} + +void MediaPlayerPrivateGStreamer::updateTracks(const GRefPtr& collectionOwner) +{ + ASSERT(!m_isLegacyPlaybin); + + bool oldHasAudio = m_hasAudio; + bool oldHasVideo = m_hasVideo; + + RefPtr player = m_player.get(); + + // fast/mediastream/MediaStream-video-element-remove-track.html expects audio tracks gone, not deactivated. + if (player) { + for (auto& track : m_audioTracks.values()) + player->removeAudioTrack(track); + } + m_audioTracks.clear(); + + for (auto& track : m_videoTracks.values()) + track->setActive(false); + for (auto& track : m_textTracks.values()) + track->setActive(false); + + auto scopeExit = makeScopeExit([oldHasAudio, oldHasVideo, protectedThis = WeakPtr { *this }, this] { + if (!protectedThis) + return; + + RefPtr player = m_player.get(); + + m_hasAudio = !m_audioTracks.isEmpty(); + m_hasVideo = false; + + for (auto& track : m_videoTracks.values()) { + if (track->selected()) { + m_hasVideo = true; + break; + } + } + + if (player) { + if (oldHasVideo != m_hasVideo || oldHasAudio != m_hasAudio) + player->characteristicChanged(); + + if (!oldHasVideo && m_hasVideo) + player->sizeChanged(); + + player->mediaEngineUpdated(); + } + + if (!m_hasAudio && !m_hasVideo) + didEnd(); + }); + + if (!m_streamCollection) + return; + + using TextTrackPrivateGStreamer = InbandTextTrackPrivateGStreamer; +#define CREATE_OR_SELECT_TRACK(type, Type) G_STMT_START { \ + bool isTrackCached = m_##type##Tracks.contains(streamId); \ + if (!isTrackCached) { \ + auto track = Type##TrackPrivateGStreamer::create(*this, type##TrackIndex, stream); \ + if (player) \ + player->add##Type##Track(track); \ + m_##type##Tracks.add(streamId, WTFMove(track)); \ + } \ + auto track = m_##type##Tracks.get(streamId); \ + if (isTrackCached) \ + track->updateConfigurationFromCaps(WTFMove(caps)); \ + auto trackId = track->stringId(); \ + if (!type##TrackIndex) { \ + m_wanted##Type##StreamId = trackId; \ + m_requested##Type##StreamId = trackId; \ + track->setActive(true); \ + } \ + type##TrackIndex++; \ + } G_STMT_END + + bool useMediaSource = isMediaSource(); + unsigned audioTrackIndex = 0; + unsigned videoTrackIndex = 0; + unsigned textTrackIndex = 0; + unsigned length = gst_stream_collection_get_size(m_streamCollection.get()); + GST_DEBUG_OBJECT(pipeline(), "Received STREAM_COLLECTION message with upstream id \"%s\" from %" GST_PTR_FORMAT " defining the following streams:", gst_stream_collection_get_upstream_id(m_streamCollection.get()), collectionOwner.get()); + for (unsigned i = 0; i < length; i++) { + auto* stream = gst_stream_collection_get_stream(m_streamCollection.get(), i); + RELEASE_ASSERT(stream); + auto streamId = AtomString::fromLatin1(gst_stream_get_stream_id(stream)); + auto type = gst_stream_get_stream_type(stream); + auto caps = adoptGRef(gst_stream_get_caps(stream)); + + GST_DEBUG_OBJECT(pipeline(), "#%u %s track with ID %s and caps %" GST_PTR_FORMAT, i, gst_stream_type_get_name(type), streamId.string().ascii().data(), caps.get()); + + if (type & GST_STREAM_TYPE_AUDIO) { + CREATE_OR_SELECT_TRACK(audio, Audio); + configureMediaStreamAudioTracks(); + } else if (type & GST_STREAM_TYPE_VIDEO && player && player->isVideoPlayer()) + CREATE_OR_SELECT_TRACK(video, Video); + else if (type & GST_STREAM_TYPE_TEXT && !useMediaSource) + CREATE_OR_SELECT_TRACK(text, Text); + else + GST_WARNING("Unknown track type found for stream %s", streamId.string().ascii().data()); + } +#undef CREATE_OR_SELECT_TRACK +} + +void MediaPlayerPrivateGStreamer::handleStreamCollectionMessage(GstMessage* message) +{ + if (m_isLegacyPlaybin) + return; + + if (!m_source) + return; + + // GStreamer workaround: Unfortunately, when we have a stream-collection aware source (like + // WebKitMediaSrc) parsebin and decodebin3 emit their own stream-collection messages, but late, + // and sometimes with duplicated streams. Let's only listen for stream-collection messages from + // the source to avoid these issues. + if (!(g_str_has_prefix(GST_OBJECT_NAME(m_source.get()), "filesrc") || WEBKIT_IS_WEB_SRC(m_source.get())) && GST_MESSAGE_SRC(message) != GST_OBJECT(m_source.get())) { + GST_DEBUG_OBJECT(pipeline(), "Ignoring redundant STREAM_COLLECTION from %" GST_PTR_FORMAT, message->src); + return; + } + + ASSERT(GST_MESSAGE_TYPE(message) == GST_MESSAGE_STREAM_COLLECTION); + gst_message_parse_stream_collection(message, &m_streamCollection.outPtr()); + + auto callback = [player = WeakPtr { *this }, owner = GRefPtr(GST_MESSAGE_SRC(message))] { + if (player) + player->updateTracks(owner); + }; + + GST_DEBUG_OBJECT(pipeline(), "Updating tracks"); + callOnMainThreadAndWait(WTFMove(callback)); + GST_DEBUG_OBJECT(pipeline(), "Updating tracks DONE"); +} + +bool MediaPlayerPrivateGStreamer::handleNeedContextMessage(GstMessage* message) +{ + ASSERT(GST_MESSAGE_TYPE(message) == GST_MESSAGE_NEED_CONTEXT); + + const gchar* contextType; + if (!gst_message_parse_context_type(message, &contextType)) + return false; + + GST_DEBUG_OBJECT(pipeline(), "Handling %s need-context message for %s", contextType, GST_MESSAGE_SRC_NAME(message)); + + if (!g_strcmp0(contextType, WEBKIT_WEB_SRC_RESOURCE_LOADER_CONTEXT_TYPE_NAME)) { + auto context = adoptGRef(gst_context_new(WEBKIT_WEB_SRC_RESOURCE_LOADER_CONTEXT_TYPE_NAME, FALSE)); + GstStructure* contextStructure = gst_context_writable_structure(context.get()); + + gst_structure_set(contextStructure, "loader", G_TYPE_POINTER, m_loader.get(), nullptr); + gst_element_set_context(GST_ELEMENT(GST_MESSAGE_SRC(message)), context.get()); + return true; + } + +#if ENABLE(ENCRYPTED_MEDIA) + if (!g_strcmp0(contextType, "drm-preferred-decryption-system-id")) { + initializationDataEncountered(parseInitDataFromProtectionMessage(message)); + bool isCDMAttached = waitForCDMAttachment(); + if (isCDMAttached && !isPlayerShuttingDown() && !m_cdmInstance->keySystem().isEmpty()) { + const char* preferredKeySystemUuid = GStreamerEMEUtilities::keySystemToUuid(m_cdmInstance->keySystem()); + GST_INFO_OBJECT(pipeline(), "working with key system %s, continuing with key system %s on %s", m_cdmInstance->keySystem().utf8().data(), preferredKeySystemUuid, GST_MESSAGE_SRC_NAME(message)); + + GRefPtr context = adoptGRef(gst_context_new("drm-preferred-decryption-system-id", FALSE)); + GstStructure* contextStructure = gst_context_writable_structure(context.get()); + gst_structure_set(contextStructure, "decryption-system-id", G_TYPE_STRING, preferredKeySystemUuid, nullptr); + gst_element_set_context(GST_ELEMENT(GST_MESSAGE_SRC(message)), context.get()); + return true; + } + + GST_WARNING_OBJECT(pipeline(), "waiting for a CDM failed, no CDM available"); + return false; + } +#endif // ENABLE(ENCRYPTED_MEDIA) + + GST_DEBUG_OBJECT(pipeline(), "Unhandled %s need-context message for %s", contextType, GST_MESSAGE_SRC_NAME(message)); + return false; +} + +// Returns the size of the video. +FloatSize MediaPlayerPrivateGStreamer::naturalSize() const +{ + if (!hasVideo()) + return FloatSize(); + + if (!m_videoSize.isEmpty()) + return m_videoSize; + +#if USE(GSTREAMER_HOLEPUNCH) + // When using the holepuch we may not be able to get the video frames size, so we can't use + // it. But we need to report some non empty naturalSize for the player's GraphicsLayer + // to be properly created. + return s_holePunchDefaultFrameSize; +#endif + + return m_videoSize; +} + +void MediaPlayerPrivateGStreamer::configureMediaStreamAudioTracks() +{ +#if ENABLE(MEDIA_STREAM) + if (WEBKIT_IS_MEDIA_STREAM_SRC(m_source.get())) + webkitMediaStreamSrcConfigureAudioTracks(WEBKIT_MEDIA_STREAM_SRC(m_source.get()), volume(), isMuted(), !m_isPaused); +#endif +} + +void MediaPlayerPrivateGStreamer::setVolume(float volume) +{ + if (!m_volumeElement) + return; + + GST_DEBUG_OBJECT(pipeline(), "Setting volume: %f", volume); + gst_stream_volume_set_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_LINEAR, static_cast(volume)); + configureMediaStreamAudioTracks(); +} + +float MediaPlayerPrivateGStreamer::volume() const +{ + if (!m_volumeElement) + return 0; + + auto volume = gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_LINEAR); + GST_DEBUG_OBJECT(pipeline(), "Volume: %f", volume); + return volume; +} + +void MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange() +{ + RefPtr player = m_player.get(); + if (!player || !m_volumeElement) + return; + + // get_volume() can return values superior to 1.0 if the user applies software user gain via + // third party application (GNOME volume control for instance). + auto oldVolume = this->volume(); + auto volume = CLAMP(oldVolume, 0.0, 1.0); + + if (volume != oldVolume) + GST_DEBUG_OBJECT(pipeline(), "Volume value (%f) was not in [0,1] range. Clamped to %f", oldVolume, volume); + player->volumeChanged(volume); +} + +void MediaPlayerPrivateGStreamer::volumeChangedCallback(MediaPlayerPrivateGStreamer* player) +{ + if (player->isPlayerShuttingDown()) + return; + + // This is called when m_volumeElement receives the notify::volume signal. + GST_DEBUG_OBJECT(player->pipeline(), "Volume changed to: %f", player->volume()); + + player->m_notifier->notify(MainThreadNotification::VolumeChanged, [player] { + player->notifyPlayerOfVolumeChange(); + }); +} + +MediaPlayer::NetworkState MediaPlayerPrivateGStreamer::networkState() const +{ + return m_networkState; +} + +MediaPlayer::ReadyState MediaPlayerPrivateGStreamer::readyState() const +{ + return m_readyState; +} + +void MediaPlayerPrivateGStreamer::setMuted(bool shouldMute) +{ + GST_DEBUG_OBJECT(pipeline(), "Attempting to set muted state to %s", boolForPrinting(shouldMute)); + + if (!m_volumeElement || shouldMute == isMuted()) + return; + + GST_INFO_OBJECT(pipeline(), "Setting muted state to %s", boolForPrinting(shouldMute)); + g_object_set(m_volumeElement.get(), "mute", static_cast(shouldMute), nullptr); + configureMediaStreamAudioTracks(); +} + +void MediaPlayerPrivateGStreamer::notifyPlayerOfMute() +{ + RefPtr player = m_player.get(); + if (!player || !m_volumeElement) + return; + + gboolean value; + bool isMuted; + g_object_get(m_volumeElement.get(), "mute", &value, nullptr); + isMuted = value; + if (isMuted == m_isMuted) + return; + + m_isMuted = isMuted; + GST_DEBUG_OBJECT(pipeline(), "Notifying player of new mute value: %s", boolForPrinting(isMuted)); + player->muteChanged(m_isMuted); +} + +void MediaPlayerPrivateGStreamer::muteChangedCallback(MediaPlayerPrivateGStreamer* player) +{ + // This is called when m_volumeElement receives the notify::mute signal. + player->m_notifier->notify(MainThreadNotification::MuteChanged, [player] { + player->notifyPlayerOfMute(); + }); +} + +void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message) +{ + GUniqueOutPtr err; + GUniqueOutPtr debug; + MediaPlayer::NetworkState error; + bool issueError = true; + bool attemptNextLocation = false; + const GstStructure* structure = gst_message_get_structure(message); + GstState requestedState, currentState; + + m_canFallBackToLastFinishedSeekPosition = false; + + if (structure) { + const gchar* messageTypeName = gst_structure_get_name(structure); + + // Redirect messages are sent from elements, like qtdemux, to + // notify of the new location(s) of the media. + if (!g_strcmp0(messageTypeName, "redirect")) { + mediaLocationChanged(message); + return; + } + } + + RefPtr player = m_player.get(); + + // We ignore state changes from internal elements. They are forwarded to playbin2 anyway. + bool messageSourceIsPlaybin = GST_MESSAGE_SRC(message) == reinterpret_cast(m_pipeline.get()); + + GST_LOG_OBJECT(pipeline(), "Message %s received from element %s", GST_MESSAGE_TYPE_NAME(message), GST_MESSAGE_SRC_NAME(message)); + switch (GST_MESSAGE_TYPE(message)) { + case GST_MESSAGE_ERROR: + gst_message_parse_error(message, &err.outPtr(), &debug.outPtr()); + GST_ERROR_OBJECT(pipeline(), "%s (url=%s) (code=%d)", err->message, m_url.string().utf8().data(), err->code); + + if (m_shouldResetPipeline || m_didErrorOccur) + break; + + m_errorMessage = String::fromLatin1(err->message); + + error = MediaPlayer::NetworkState::Empty; + if (g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_CODEC_NOT_FOUND) + || g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_DECRYPT) + || g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_DECRYPT_NOKEY) + || g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_WRONG_TYPE) + || g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED) + || g_error_matches(err.get(), GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN) + || g_error_matches(err.get(), GST_CORE_ERROR, GST_CORE_ERROR_PAD) + || g_error_matches(err.get(), GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND)) + error = MediaPlayer::NetworkState::FormatError; + else if (g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_TYPE_NOT_FOUND)) { + GST_ERROR_OBJECT(pipeline(), "Decode error, let the Media element emit a stalled event."); + m_loadingStalled = true; + error = MediaPlayer::NetworkState::DecodeError; + attemptNextLocation = true; + } else if (err->domain == GST_STREAM_ERROR) { + error = MediaPlayer::NetworkState::DecodeError; + attemptNextLocation = true; + } else if (err->domain == GST_RESOURCE_ERROR) + error = MediaPlayer::NetworkState::NetworkError; + + if (attemptNextLocation) + issueError = !loadNextLocation(); + if (issueError) { + m_didErrorOccur = true; + if (m_networkState != error) { + m_networkState = error; + if (player) + player->networkStateChanged(); + } + } + break; + case GST_MESSAGE_WARNING: + gst_message_parse_warning(message, &err.outPtr(), &debug.outPtr()); + GST_WARNING_OBJECT(pipeline(), "%s (url=%s) (code=%d)", err->message, m_url.string().utf8().data(), err->code); + break; + case GST_MESSAGE_EOS: { + // In some specific cases, an EOS GstEvent can happen right before a seek. The event is translated + // by playbin as an EOS GstMessage and posted to the bus, waiting to be forwarded to the main thread. + // The EOS message (now irrelevant after the seek) is received and processed right after the seek, + // causing the termination of the media at the player private and upper levels. This can even happen + // after the seek has completed (m_isSeeking already false). + // The code below detects that condition by ensuring that the playback is coherent with the EOS message, + // that is, if we're still playing somewhere inside the playable ranges, there should be no EOS at + // all. If that's the case, it's considered to be one of those spureous EOS and is ignored. + // Live streams (infinite duration) are special and we still have to detect legitimate EOS there, so + // this message bailout isn't done in those cases. + MediaTime playbackPosition = MediaTime::invalidTime(); + MediaTime duration = durationMediaTime(); + GstClockTime gstreamerPosition = gstreamerPositionFromSinks(); + bool eosFlagIsSetInSink = false; + if (player && player->isVideoPlayer()) { + GRefPtr sinkPad = adoptGRef(gst_element_get_static_pad(m_videoSink.get(), "sink")); + eosFlagIsSetInSink = sinkPad && GST_PAD_IS_EOS(sinkPad.get()); + } + + if (!eosFlagIsSetInSink && m_audioSink) { + GRefPtr sinkPad = adoptGRef(gst_element_get_static_pad(m_audioSink.get(), "sink")); + eosFlagIsSetInSink = sinkPad && GST_PAD_IS_EOS(sinkPad.get()); + } + + if (GST_CLOCK_TIME_IS_VALID(gstreamerPosition)) + playbackPosition = MediaTime(gstreamerPosition, GST_SECOND); + if (!player->isLooping() && !eosFlagIsSetInSink && playbackPosition.isValid() && duration.isValid() + && ((m_playbackRate >= 0 && playbackPosition < duration && duration.isFinite()) + || (m_playbackRate < 0 && playbackPosition > MediaTime::zeroTime()))) { + GST_DEBUG_OBJECT(pipeline(), "EOS received but position %s is still in the finite playable limits [%s, %s], ignoring it", + playbackPosition.toString().utf8().data(), MediaTime::zeroTime().toString().utf8().data(), duration.toString().utf8().data()); + break; + } + didEnd(); + break; + } + case GST_MESSAGE_ASYNC_DONE: + if (!messageSourceIsPlaybin || m_isDelayingLoad) + break; + + // The MediaPlayerPrivateGStreamer superclass now processes what it needs by calling updateStates() in handleMessage() for + // GST_MESSAGE_STATE_CHANGED. However, subclasses still need to override asyncStateChangeDone() to do their own stuff. + didPreroll(); + break; + case GST_MESSAGE_STATE_CHANGED: { + GstState newState; + gst_message_parse_state_changed(message, ¤tState, &newState, nullptr); + +#if USE(GSTREAMER_HOLEPUNCH) && (USE(WPEWEBKIT_PLATFORM_BCM_NEXUS) || USE(WESTEROS_SINK)) + if (currentState <= GST_STATE_READY && newState >= GST_STATE_READY) { + // If we didn't create a video sink, store a reference to the created one. + if (!m_videoSink) { + // Detect the videoSink element. Getting the video-sink property of the pipeline requires + // locking some elements, which may lead to deadlocks during playback. Instead, identify + // the videoSink based on its metadata. + GstElement* element = GST_ELEMENT(GST_MESSAGE_SRC(message)); + if (GST_OBJECT_FLAG_IS_SET(element, GST_ELEMENT_FLAG_SINK)) { + const gchar* klassStr = gst_element_get_metadata(element, "klass"); + if (strstr(klassStr, "Sink") && strstr(klassStr, "Video")) { + m_videoSink = element; + + // Ensure that there's a buffer with the transparent rectangle available when playback is going to start. + pushNextHolePunchBuffer(); + } + } + } + } +#endif + +#if PLATFORM(BROADCOM) || USE(WESTEROS_SINK) || PLATFORM(AMLOGIC) || PLATFORM(REALTEK) + if (currentState <= GST_STATE_READY && newState >= GST_STATE_READY) { + // If we didn't create an audio sink, store a reference to the created one. + if (!m_audioSink) { + // Detect an audio sink element. + GstElement* element = GST_ELEMENT(GST_MESSAGE_SRC(message)); + if (GST_OBJECT_FLAG_IS_SET(element, GST_ELEMENT_FLAG_SINK)) { + const gchar* klassStr = gst_element_get_metadata(element, "klass"); + if (strstr(klassStr, "Sink") && strstr(klassStr, "Audio")) + m_audioSink = element; + } + } + } +#endif + + if (!messageSourceIsPlaybin || m_isDelayingLoad) + break; + + GST_DEBUG_OBJECT(pipeline(), "Changed state from %s to %s", gst_element_state_get_name(currentState), gst_element_state_get_name(newState)); + + if (!m_isLegacyPlaybin && currentState == GST_STATE_PAUSED && newState == GST_STATE_PLAYING) + playbin3SendSelectStreamsIfAppropriate(); + updateStates(); + checkPlayingConsistency(); + + break; + } + case GST_MESSAGE_BUFFERING: + processBufferingStats(message); + break; + case GST_MESSAGE_DURATION_CHANGED: + // Duration in MSE is managed by MediaSource, SourceBuffer and AppendPipeline. + if (messageSourceIsPlaybin && !isMediaSource()) + durationChanged(); + break; + case GST_MESSAGE_REQUEST_STATE: + gst_message_parse_request_state(message, &requestedState); + gst_element_get_state(m_pipeline.get(), ¤tState, nullptr, 250 * GST_NSECOND); + if (requestedState < currentState) { + GST_INFO_OBJECT(pipeline(), "Element %s requested state change to %s", GST_MESSAGE_SRC_NAME(message), + gst_element_state_get_name(requestedState)); + m_requestedState = requestedState; + if (!changePipelineState(requestedState)) + loadingFailed(MediaPlayer::NetworkState::Empty); + } + break; + case GST_MESSAGE_CLOCK_LOST: + // This can only happen in PLAYING state and we should just + // get a new clock by moving back to PAUSED and then to + // PLAYING again. + // This can happen if the stream that ends in a sink that + // provides the current clock disappears, for example if + // the audio sink provides the clock and the audio stream + // is disabled. It also happens relatively often with + // HTTP adaptive streams when switching between different + // variants of a stream. + gst_element_set_state(m_pipeline.get(), GST_STATE_PAUSED); + gst_element_set_state(m_pipeline.get(), GST_STATE_PLAYING); + break; + case GST_MESSAGE_LATENCY: + // Recalculate the latency, we don't need any special handling + // here other than the GStreamer default. + // This can happen if the latency of live elements changes, or + // for one reason or another a new live element is added or + // removed from the pipeline. + gst_bin_recalculate_latency(GST_BIN(m_pipeline.get())); + break; + case GST_MESSAGE_ELEMENT: +#if USE(GSTREAMER_MPEGTS) + if (GstMpegtsSection* section = gst_message_parse_mpegts_section(message)) { + processMpegTsSection(section); + gst_mpegts_section_unref(section); + } else +#endif + if (gst_structure_has_name(structure, "http-headers")) { + GST_DEBUG_OBJECT(pipeline(), "Processing HTTP headers: %" GST_PTR_FORMAT, structure); + if (const char* uri = gst_structure_get_string(structure, "uri")) { + URL url { String::fromLatin1(uri) }; + + if (url != m_url) { + GST_DEBUG_OBJECT(pipeline(), "Ignoring HTTP response headers for non-main URI."); + break; + } + } + + bool isRangeRequest = false; + GUniqueOutPtr requestHeaders; + if (gst_structure_get(structure, "request-headers", GST_TYPE_STRUCTURE, &requestHeaders.outPtr(), nullptr)) + isRangeRequest = gst_structure_has_field(requestHeaders.get(), "Range"); + + GST_DEBUG_OBJECT(pipeline(), "Is range request: %s", boolForPrinting(isRangeRequest)); + + GUniqueOutPtr responseHeaders; + if (gst_structure_get(structure, "response-headers", GST_TYPE_STRUCTURE, &responseHeaders.outPtr(), nullptr)) { + auto contentLengthHeaderName = httpHeaderNameString(HTTPHeaderName::ContentLength); + uint64_t contentLength = 0; + if (!gst_structure_get_uint64(responseHeaders.get(), contentLengthHeaderName.characters(), &contentLength)) { + // souphttpsrc sets a string for Content-Length, so + // handle it here, until we remove the webkit+ protocol + // prefix from webkitwebsrc. + if (const char* contentLengthAsString = gst_structure_get_string(responseHeaders.get(), contentLengthHeaderName.characters())) { + contentLength = g_ascii_strtoull(contentLengthAsString, nullptr, 10); + if (contentLength == G_MAXUINT64) + contentLength = 0; + } + } + if (!isRangeRequest) { + m_isLiveStream = !contentLength; + GST_INFO_OBJECT(pipeline(), "%s stream detected", m_isLiveStream.value_or(false) ? "Live" : "Non-live"); + updateDownloadBufferingFlag(); + } + } + } else if (gst_structure_has_name(structure, "webkit-network-statistics")) { + if (gst_structure_get(structure, "read-position", G_TYPE_UINT64, &m_networkReadPosition, "size", G_TYPE_UINT64, &m_httpResponseTotalSize, nullptr)) + GST_LOG_OBJECT(pipeline(), "Updated network read position %" G_GUINT64_FORMAT ", size: %" G_GUINT64_FORMAT, m_networkReadPosition, m_httpResponseTotalSize); + } else if (gst_structure_has_name(structure, "GstCacheDownloadComplete")) { + GST_INFO_OBJECT(pipeline(), "Stream is fully downloaded, stopping monitoring downloading progress."); + m_fillTimer.stop(); + m_bufferingPercentage = 100; + updateStates(); + } else if (gst_structure_has_name(structure, "webkit-web-src-has-eos")) { + GST_DEBUG_OBJECT(pipeline(), "WebKitWebSrc has EOS"); + m_hasWebKitWebSrcSentEOS = true; + } else + GST_DEBUG_OBJECT(pipeline(), "Unhandled element message: %" GST_PTR_FORMAT, structure); + break; + case GST_MESSAGE_TOC: + processTableOfContents(message); + break; + case GST_MESSAGE_STREAMS_SELECTED: { + if (m_isLegacyPlaybin) + break; + +#ifndef GST_DISABLE_DEBUG + GST_DEBUG_OBJECT(m_pipeline.get(), "Received STREAMS_SELECTED message selecting the following streams:"); + unsigned numStreams = gst_message_streams_selected_get_size(message); + for (unsigned i = 0; i < numStreams; i++) { + auto stream = adoptGRef(gst_message_streams_selected_get_stream(message, i)); + GST_DEBUG_OBJECT(pipeline(), "#%u %s %s", i, gst_stream_type_get_name(gst_stream_get_stream_type(stream.get())), gst_stream_get_stream_id(stream.get())); + } +#endif + GST_DEBUG_OBJECT(m_pipeline.get(), "Setting m_waitingForStreamsSelectedEvent to false."); + m_waitingForStreamsSelectedEvent = false; + + // Unfortunately, STREAMS_SELECTED messages from playbin3 are highly unreliable, often only including the audio + // stream or only the video stream when both are present and going to be played. + // Therefore, instead of reading the event data, we will just assume our previously requested selection was honored. + m_currentAudioStreamId = m_requestedAudioStreamId; + m_currentVideoStreamId = m_requestedVideoStreamId; + m_currentTextStreamId = m_requestedTextStreamId; + + // It's possible the user made a track switch before the initial STREAMS_SELECED. Now it's a good moment to + // request it being attended. Note that it's not possible to send a SELECT_STREAMS before the first + // STREAMS_SELECTED message because at that point the pipeline is not compeletely constructed. + playbin3SendSelectStreamsIfAppropriate(); + break; + } + case GST_MESSAGE_STREAM_START: { + // Real track id configuration in MSE is managed by AppendPipeline. In MediaStream we don't support native stream ids. + if (!m_isLegacyPlaybin) + break; + + notifyPlayerOfTrack(); + notifyPlayerOfTrack(); + notifyPlayerOfTrack(); + break; + } + default: + GST_DEBUG_OBJECT(pipeline(), "Unhandled GStreamer message type: %s", GST_MESSAGE_TYPE_NAME(message)); + break; + } +} + +void MediaPlayerPrivateGStreamer::processBufferingStats(GstMessage* message) +{ + GstBufferingMode mode; + gst_message_parse_buffering_stats(message, &mode, nullptr, nullptr, nullptr); + + int percentage; + gst_message_parse_buffering(message, &percentage); + + updateBufferingStatus(mode, percentage); +} + +void MediaPlayerPrivateGStreamer::updateMaxTimeLoaded(double percentage) +{ + MediaTime mediaDuration = durationMediaTime(); + if (!mediaDuration) + return; + + m_maxTimeLoaded = MediaTime(percentage * static_cast(toGstUnsigned64Time(mediaDuration)) / 100, GST_SECOND); + GST_DEBUG_OBJECT(pipeline(), "[Buffering] Updated maxTimeLoaded: %s", toString(m_maxTimeLoaded).utf8().data()); +} + +void MediaPlayerPrivateGStreamer::updateBufferingStatus(GstBufferingMode mode, double percentage) +{ + bool wasBuffering = m_isBuffering; + +#ifndef GST_DISABLE_GST_DEBUG + GUniquePtr modeString(g_enum_to_string(GST_TYPE_BUFFERING_MODE, mode)); + GST_DEBUG_OBJECT(pipeline(), "[Buffering] mode: %s, status: %f%%", modeString.get(), percentage); +#endif + + m_didDownloadFinish = percentage == 100; + + if (!m_didDownloadFinish) + m_isBuffering = true; + else + m_fillTimer.stop(); + + m_bufferingPercentage = percentage; + switch (mode) { + case GST_BUFFERING_STREAM: { + updateMaxTimeLoaded(percentage); + + m_bufferingPercentage = percentage; + if (m_didDownloadFinish || !wasBuffering) + updateStates(); + + break; + } + case GST_BUFFERING_DOWNLOAD: { + updateMaxTimeLoaded(percentage); + updateStates(); + break; + } + default: +#ifndef GST_DISABLE_GST_DEBUG + GST_DEBUG_OBJECT(pipeline(), "Unhandled buffering mode: %s", modeString.get()); +#endif + break; + } +} + +#if USE(GSTREAMER_MPEGTS) +void MediaPlayerPrivateGStreamer::processMpegTsSection(GstMpegtsSection* section) +{ + ASSERT(section); + + if (section->section_type == GST_MPEGTS_SECTION_PMT) { + const GstMpegtsPMT* pmt = gst_mpegts_section_get_pmt(section); + m_metadataTracks.clear(); + for (unsigned i = 0; i < pmt->streams->len; ++i) { + const GstMpegtsPMTStream* stream = static_cast(g_ptr_array_index(pmt->streams, i)); + if (stream->stream_type == 0x05 || stream->stream_type >= 0x80) { + AtomString pid = AtomString::number(stream->pid); + RefPtr track = InbandMetadataTextTrackPrivateGStreamer::create( + InbandTextTrackPrivate::Kind::Metadata, InbandTextTrackPrivate::CueFormat::Data, pid); + + // 4.7.10.12.2 Sourcing in-band text tracks + // If the new text track's kind is metadata, then set the text track in-band metadata track dispatch + // type as follows, based on the type of the media resource: + // Let stream type be the value of the "stream_type" field describing the text track's type in the + // file's program map section, interpreted as an 8-bit unsigned integer. Let length be the value of + // the "ES_info_length" field for the track in the same part of the program map section, interpreted + // as an integer as defined by the MPEG-2 specification. Let descriptor bytes be the length bytes + // following the "ES_info_length" field. The text track in-band metadata track dispatch type must be + // set to the concatenation of the stream type byte and the zero or more descriptor bytes bytes, + // expressed in hexadecimal using uppercase ASCII hex digits. + StringBuilder inbandMetadataTrackDispatchType; + inbandMetadataTrackDispatchType.append(hex(stream->stream_type, 2)); + for (unsigned j = 0; j < stream->descriptors->len; ++j) { + const GstMpegtsDescriptor* descriptor = static_cast(g_ptr_array_index(stream->descriptors, j)); + for (unsigned k = 0; k < descriptor->length; ++k) + inbandMetadataTrackDispatchType.append(hex(descriptor->data[k], 2)); + } + track->setInBandMetadataTrackDispatchType(inbandMetadataTrackDispatchType.toAtomString()); + + m_metadataTracks.add(pid, track); + if (RefPtr player = m_player.get()) + player->addTextTrack(*track); + } + } + } else { + AtomString pid = AtomString::number(section->pid); + RefPtr track = m_metadataTracks.get(pid); + if (!track) + return; + + GRefPtr data = gst_mpegts_section_get_data(section); + gsize size; + const void* bytes = g_bytes_get_data(data.get(), &size); + + track->addDataCue(currentMediaTime(), currentMediaTime(), bytes, size); + } +} +#endif + +void MediaPlayerPrivateGStreamer::processTableOfContents(GstMessage* message) +{ + RefPtr player = m_player.get(); + + if (player && m_chaptersTrack) + player->removeTextTrack(*m_chaptersTrack); + + m_chaptersTrack = InbandMetadataTextTrackPrivateGStreamer::create(InbandTextTrackPrivate::Kind::Chapters, InbandTextTrackPrivate::CueFormat::Generic); + if (player) + player->addTextTrack(*m_chaptersTrack); + + GRefPtr toc; + gboolean updated; + gst_message_parse_toc(message, &toc.outPtr(), &updated); + ASSERT(toc); + + for (GList* i = gst_toc_get_entries(toc.get()); i; i = i->next) + processTableOfContentsEntry(static_cast(i->data)); +} + +void MediaPlayerPrivateGStreamer::processTableOfContentsEntry(GstTocEntry* entry) +{ + ASSERT(entry); + + auto cue = InbandGenericCue::create(); + + gint64 start = -1, stop = -1; + gst_toc_entry_get_start_stop_times(entry, &start, &stop); + + uint32_t truncatedGstSecond = static_cast(GST_SECOND); + if (start != -1) + cue->setStartTime(MediaTime(static_cast(start), truncatedGstSecond)); + if (stop != -1) + cue->setEndTime(MediaTime(static_cast(stop), truncatedGstSecond)); + + GstTagList* tags = gst_toc_entry_get_tags(entry); + if (tags) { + gchar* title = nullptr; + gst_tag_list_get_string(tags, GST_TAG_TITLE, &title); + if (title) { + cue->setContent(String::fromUTF8(title)); + g_free(title); + } + } + + m_chaptersTrack->addGenericCue(cue); + + for (GList* i = gst_toc_entry_get_sub_entries(entry); i; i = i->next) + processTableOfContentsEntry(static_cast(i->data)); +} + +void MediaPlayerPrivateGStreamer::configureElement(GstElement* element) +{ +#if PLATFORM(BROADCOM) || USE(WESTEROS_SINK) || PLATFORM(AMLOGIC) || PLATFORM(REALTEK) + configureElementPlatformQuirks(element); +#endif + + GUniquePtr elementName(gst_element_get_name(element)); + auto elementClass = makeString(gst_element_get_metadata(element, GST_ELEMENT_METADATA_KLASS)); + auto classifiers = elementClass.split('/'); + + // In GStreamer 1.20 and older urisourcebin mishandles source elements with dynamic pads. This + // is not an issue in 1.22. Streams parsing is not needed for MediaStream cases because we do it + // upfront for incoming WebRTC MediaStreams. It is however needed for MSE, otherwise decodebin3 + // might not auto-plug hardware decoders. + if (webkitGstCheckVersion(1, 22, 0) && g_str_has_prefix(elementName.get(), "urisourcebin") && (isMediaSource() || isMediaStreamPlayer())) + g_object_set(element, "use-buffering", FALSE, "parse-streams", !isMediaStreamPlayer(), nullptr); + + // In case of playbin3 with