diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2019-06-26 19:22:59 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2019-06-26 19:25:02 +0300 |
commit | eb6c5179e8650f66b304a656409a1e5e5efec956 (patch) | |
tree | c0babfa588a97e9d325c39410fb9f2a5ffeab430 | |
parent | cd2fc453baf21084d0fb9f5f6b203f3aac3fa2ba (diff) |
Import WebKit commit d6bf9b7a5a72ec63236f3f2d0eabc20913309793v5.212.0-alpha3
Change-Id: I15a655045d43ea5f2cfe1158016db6426ded0224
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
23 files changed, 297 insertions, 192 deletions
@@ -6,7 +6,18 @@ The Qt port of WebKit currently compiles and runs on Linux, *BSD, Windows and ma # Building -See instructions at https://github.com/annulen/webkit/wiki +You can build and install QtWebKit with these commands: + +mkdir build +cd build +cmake -G Ninja -DPORT=Qt -DCMAKE_BUILD_TYPE=Release .. +ninja +sudo ninja install + +See https://github.com/annulen/webkit/wiki for more detailed instuctions + +After QtWebKit is installed, you can use it as described in +https://github.com/annulen/webkit/wiki/Using-QtWebKit-in-your-project # Contacts diff --git a/Source/WTF/wtf/text/WTFString.cpp b/Source/WTF/wtf/text/WTFString.cpp index 958fd2069..ce376e23a 100644 --- a/Source/WTF/wtf/text/WTFString.cpp +++ b/Source/WTF/wtf/text/WTFString.cpp @@ -460,21 +460,6 @@ Vector<UChar> String::charactersWithNullTermination() const String String::format(const char *format, ...) { -#if PLATFORM(QT) - // Use QString::vsprintf to avoid the locale dependent formatting of vsnprintf. - // https://bugs.webkit.org/show_bug.cgi?id=18994 - va_list args; - va_start(args, format); - - QString buffer; - buffer.vsprintf(format, args); - - va_end(args); - - QByteArray ba = buffer.toUtf8(); - return StringImpl::create(reinterpret_cast<const LChar*>(ba.constData()), ba.length()); - -#else va_list args; va_start(args, format); @@ -503,7 +488,6 @@ String String::format(const char *format, ...) va_end(args); return StringImpl::create(reinterpret_cast<const LChar*>(buffer.data()), len); -#endif } String String::number(int number) diff --git a/Source/WebCore/platform/Cursor.cpp b/Source/WebCore/platform/Cursor.cpp index 60a619acd..014efa5f5 100644 --- a/Source/WebCore/platform/Cursor.cpp +++ b/Source/WebCore/platform/Cursor.cpp @@ -154,7 +154,7 @@ Cursor::Cursor(Image* image, const IntPoint& hotSpot) #if ENABLE(MOUSE_CURSOR_SCALE) , m_imageScaleFactor(1) #endif - , m_platformCursor(0) + , m_platformCursor(nullptr) { } @@ -174,11 +174,17 @@ Cursor::Cursor(Type type) #if ENABLE(MOUSE_CURSOR_SCALE) , m_imageScaleFactor(1) #endif - , m_platformCursor(0) + , m_platformCursor(nullptr) { } -#if !PLATFORM(COCOA) +#if PLATFORM(QT) +PlatformCursor Cursor::platformCursor() const +{ + ensurePlatformCursor(); + return m_platformCursor.get(); +} +#elif !PLATFORM(COCOA) PlatformCursor Cursor::platformCursor() const { diff --git a/Source/WebCore/platform/Cursor.h b/Source/WebCore/platform/Cursor.h index d06ad7d47..86d714903 100644 --- a/Source/WebCore/platform/Cursor.h +++ b/Source/WebCore/platform/Cursor.h @@ -140,7 +140,7 @@ namespace WebCore { #if ENABLE(MOUSE_CURSOR_SCALE) , m_imageScaleFactor(1) #endif - , m_platformCursor(0) + , m_platformCursor(nullptr) #endif // !PLATFORM(IOS) { } @@ -181,7 +181,9 @@ namespace WebCore { float m_imageScaleFactor; #endif -#if !USE(APPKIT) +#if PLATFORM(QT) + mutable std::unique_ptr<QCursor> m_platformCursor; +#elif !USE(APPKIT) mutable PlatformCursor m_platformCursor; #else mutable RetainPtr<NSCursor> m_platformCursor; diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index 9091fdc72..cef4750ed 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -80,7 +80,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateQt::supportsType(const MediaEngineSu if (parameters.isMediaStream || parameters.isMediaSource) return MediaPlayer::IsNotSupported; - if (!parameters.type.startsWith("audio/") && !parameters.type.startsWith("video/")) + if (!parameters.type.startsWithIgnoringASCIICase("audio/") && !parameters.type.startsWithIgnoringASCIICase("video/")) return MediaPlayer::IsNotSupported; // Parse and trim codecs. diff --git a/Source/WebCore/platform/qt/CursorQt.cpp b/Source/WebCore/platform/qt/CursorQt.cpp index ffec6715a..4a62cec82 100644 --- a/Source/WebCore/platform/qt/CursorQt.cpp +++ b/Source/WebCore/platform/qt/CursorQt.cpp @@ -49,17 +49,12 @@ Cursor::Cursor(const Cursor& other) , m_image(other.m_image) , m_hotSpot(other.m_hotSpot) #ifndef QT_NO_CURSOR - , m_platformCursor(other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0) + , m_platformCursor(other.m_platformCursor ? std::make_unique<QCursor>(*other.m_platformCursor) : nullptr) #endif { } -Cursor::~Cursor() -{ -#ifndef QT_NO_CURSOR - delete m_platformCursor; -#endif -} +Cursor::~Cursor() = default; Cursor& Cursor::operator=(const Cursor& other) { @@ -67,18 +62,18 @@ Cursor& Cursor::operator=(const Cursor& other) m_image = other.m_image; m_hotSpot = other.m_hotSpot; #ifndef QT_NO_CURSOR - m_platformCursor = other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0; + m_platformCursor = other.m_platformCursor ? std::make_unique<QCursor>(*other.m_platformCursor) : nullptr; #endif return *this; } #ifndef QT_NO_CURSOR -static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot) +static std::unique_ptr<QCursor> createCustomCursor(Image* image, const IntPoint& hotSpot) { if (!image->nativeImageForCurrentFrame()) - return 0; + return nullptr; IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot); - return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y()); + return std::make_unique<QCursor>(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y()); } #endif @@ -90,117 +85,117 @@ void Cursor::ensurePlatformCursor() const switch (m_type) { case Pointer: - m_platformCursor = new QCursor(Qt::ArrowCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::ArrowCursor); break; case Cross: - m_platformCursor = new QCursor(Qt::CrossCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::CrossCursor); break; case Hand: - m_platformCursor = new QCursor(Qt::PointingHandCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::PointingHandCursor); break; case IBeam: - m_platformCursor = new QCursor(Qt::IBeamCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::IBeamCursor); break; case Wait: - m_platformCursor = new QCursor(Qt::WaitCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::WaitCursor); break; case Help: - m_platformCursor = new QCursor(Qt::WhatsThisCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::WhatsThisCursor); break; case EastResize: case EastPanning: - m_platformCursor = new QCursor(Qt::SizeHorCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeHorCursor); break; case NorthResize: case NorthPanning: - m_platformCursor = new QCursor(Qt::SizeVerCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeVerCursor); break; case NorthEastResize: case NorthEastPanning: - m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeBDiagCursor); break; case NorthWestResize: case NorthWestPanning: - m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeFDiagCursor); break; case SouthResize: case SouthPanning: - m_platformCursor = new QCursor(Qt::SizeVerCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeVerCursor); break; case SouthEastResize: case SouthEastPanning: - m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeFDiagCursor); break; case SouthWestResize: case SouthWestPanning: - m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeBDiagCursor); break; case WestResize: case WestPanning: - m_platformCursor = new QCursor(Qt::SizeHorCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeHorCursor); break; case NorthSouthResize: - m_platformCursor = new QCursor(Qt::SizeVerCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeVerCursor); break; case EastWestResize: - m_platformCursor = new QCursor(Qt::SizeHorCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeHorCursor); break; case NorthEastSouthWestResize: - m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeBDiagCursor); break; case NorthWestSouthEastResize: - m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeFDiagCursor); break; case ColumnResize: - m_platformCursor = new QCursor(Qt::SplitHCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SplitHCursor); break; case RowResize: - m_platformCursor = new QCursor(Qt::SplitVCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SplitVCursor); break; case MiddlePanning: case Move: - m_platformCursor = new QCursor(Qt::SizeAllCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::SizeAllCursor); break; case None: - m_platformCursor = new QCursor(Qt::BlankCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::BlankCursor); break; case NoDrop: case NotAllowed: - m_platformCursor = new QCursor(Qt::ForbiddenCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::ForbiddenCursor); break; case Grab: case Grabbing: notImplemented(); - m_platformCursor = new QCursor(Qt::ArrowCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::ArrowCursor); break; case VerticalText: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/verticalTextCursor.png")), 7, 7); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/verticalTextCursor.png")), 7, 7); break; case Cell: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/cellCursor.png")), 7, 7); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/cellCursor.png")), 7, 7); break; case ContextMenu: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/contextMenuCursor.png")), 3, 2); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/contextMenuCursor.png")), 3, 2); break; case Alias: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/aliasCursor.png")), 11, 3); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/aliasCursor.png")), 11, 3); break; case Progress: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/progressCursor.png")), 3, 2); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/progressCursor.png")), 3, 2); break; case Copy: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/copyCursor.png")), 3, 2); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/copyCursor.png")), 3, 2); break; case ZoomIn: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/zoomInCursor.png")), 7, 7); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/zoomInCursor.png")), 7, 7); break; case ZoomOut: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/zoomOutCursor.png")), 7, 7); + m_platformCursor = std::make_unique<QCursor>(QPixmap(QStringLiteral(":/webkit/resources/zoomOutCursor.png")), 7, 7); break; case Custom: m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot); if (!m_platformCursor) - m_platformCursor = new QCursor(Qt::ArrowCursor); + m_platformCursor = std::make_unique<QCursor>(Qt::ArrowCursor); break; default: ASSERT_NOT_REACHED(); diff --git a/Source/WebKit/qt/README b/Source/WebKit/qt/README index 8a2bc8c5b..6b6a411ce 100644 --- a/Source/WebKit/qt/README +++ b/Source/WebKit/qt/README @@ -6,7 +6,18 @@ The Qt port of WebKit currently compiles and runs on Linux, *BSD, Windows and ma # Building -See instructions at https://github.com/annulen/webkit/wiki +You can build and install QtWebKit with these commands: + +mkdir build +cd build +cmake -G Ninja -DPORT=Qt -DCMAKE_BUILD_TYPE=Release .. +ninja +sudo ninja install + +See https://github.com/annulen/webkit/wiki for more detailed instuctions + +After QtWebKit is installed, you can use it as described in +https://github.com/annulen/webkit/wiki/Using-QtWebKit-in-your-project # Contacts diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index b3209a572..9634e6d51 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -213,6 +213,8 @@ FrameLoaderClientQt::FrameLoaderClientQt() , m_pluginView(0) , m_hasSentResponseToPlugin(false) , m_isOriginatingLoad(false) + , m_isDisplayingErrorPage(false) + , m_shouldSuppressLoadStarted(false) { } @@ -1089,6 +1091,9 @@ bool FrameLoaderClientQt::callErrorPageExtension(const WebCore::ResourceError& e if (!page->errorPageExtension(&option, &output)) return false; + m_isDisplayingErrorPage = true; + m_shouldSuppressLoadStarted = true; + URL baseUrl(output.baseUrl); URL failingUrl(option.url); @@ -1098,6 +1103,9 @@ bool FrameLoaderClientQt::callErrorPageExtension(const WebCore::ResourceError& e // FIXME: visibility? WebCore::SubstituteData substituteData(buffer, failingUrl, response, SubstituteData::SessionHistoryVisibility::Hidden); m_frame->loader().load(WebCore::FrameLoadRequest(m_frame, request, ShouldOpenExternalURLsPolicy::ShouldNotAllow /*FIXME*/, substituteData)); + + m_shouldSuppressLoadStarted = false; + return true; } @@ -1107,8 +1115,7 @@ void FrameLoaderClientQt::dispatchDidFailProvisionalLoad(const WebCore::Resource printf("%s - didFailProvisionalLoadWithError\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); if (!error.isNull() && !error.isCancellation()) { - if (callErrorPageExtension(error)) - return; + callErrorPageExtension(error); } if (m_webFrame) @@ -1121,8 +1128,7 @@ void FrameLoaderClientQt::dispatchDidFailLoad(const WebCore::ResourceError& erro printf("%s - didFailLoadWithError\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); if (!error.isNull() && !error.isCancellation()) { - if (callErrorPageExtension(error)) - return; + callErrorPageExtension(error); } if (m_webFrame) @@ -1534,11 +1540,19 @@ QWebFrameAdapter* FrameLoaderClientQt::webFrame() const void FrameLoaderClientQt::emitLoadStarted() { + if (m_shouldSuppressLoadStarted) + return; + + m_isDisplayingErrorPage = false; + m_webFrame->emitLoadStarted(m_isOriginatingLoad); } void FrameLoaderClientQt::emitLoadFinished(bool ok) { + if (ok && m_isDisplayingErrorPage) + return; + // Signal handlers can lead to a new load, that will use the member again. const bool wasOriginatingLoad = m_isOriginatingLoad; m_isOriginatingLoad = false; diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index a20364f76..8465db721 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -254,6 +254,10 @@ private: URL m_lastRequestedUrl; bool m_isOriginatingLoad; + + // QTFIXME: consider introducing some sort of flags for storing state + bool m_isDisplayingErrorPage; + bool m_shouldSuppressLoadStarted; }; } diff --git a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 17bc703fc..ab15c6315 100644 --- a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -94,6 +94,7 @@ private Q_SLOTS: void setUrlThenLoads_data(); void setUrlThenLoads(); void loadFinishedAfterNotFoundError(); + void signalsDuringErrorHandling(); void loadInSignalHandlers_data(); void loadInSignalHandlers(); @@ -1472,6 +1473,30 @@ void tst_QWebFrame::loadFinishedAfterNotFoundError() QVERIFY(!wasLoadOk); } +void tst_QWebFrame::signalsDuringErrorHandling() +{ + QWebPage page; + QWebFrame* frame = page.mainFrame(); + + QSignalSpy loadStartedSpy(frame, &QWebFrame::loadStarted); + QSignalSpy loadFinishedSpy(frame, &QWebFrame::loadFinished); + FakeNetworkManager* networkManager = new FakeNetworkManager(&page); + page.setNetworkAccessManager(networkManager); + + frame->setUrl(FakeReply::urlFor404ErrorWithoutContents); + QTRY_COMPARE(loadStartedSpy.count(), 1); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + bool wasLoadOk = loadFinishedSpy.at(0).at(0).toBool(); + QVERIFY(!wasLoadOk); + + frame->load(QUrl("http://example.com")); + waitForSignal(frame, SIGNAL(loadFinished(bool))); + QCOMPARE(loadStartedSpy.count(), 2); + QCOMPARE(loadFinishedSpy.count(), 2); + wasLoadOk = loadFinishedSpy.at(1).at(0).toBool(); + QVERIFY(wasLoadOk); +} + class URLSetter : public QObject { Q_OBJECT diff --git a/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp b/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp index 240fc7374..040c722ef 100644 --- a/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp +++ b/Source/WebKit2/Scripts/webkit/LegacyMessageReceiver-expected.cpp @@ -104,7 +104,7 @@ bool TestMultipleAttributes::DelayedReply::send() namespace WebKit { -void WebPage::didReceiveWebPageMessage(IPC::Connection*, IPC::MessageDecoder& decoder) +void WebPage::didReceiveWebPageMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder) { if (decoder.messageName() == Messages::WebPage::LoadURL::name()) { IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL); @@ -184,11 +184,12 @@ void WebPage::didReceiveWebPageMessage(IPC::Connection*, IPC::MessageDecoder& de return; } #endif + UNUSED_PARAM(connection); UNUSED_PARAM(decoder); ASSERT_NOT_REACHED(); } -void WebPage::didReceiveSyncWebPageMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) +void WebPage::didReceiveSyncWebPageMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) { if (decoder.messageName() == Messages::WebPage::CreatePlugin::name()) { IPC::handleMessage<Messages::WebPage::CreatePlugin>(decoder, *replyEncoder, this, &WebPage::createPlugin); @@ -216,6 +217,7 @@ void WebPage::didReceiveSyncWebPageMessage(IPC::Connection* connection, IPC::Mes return; } #endif + UNUSED_PARAM(connection); UNUSED_PARAM(decoder); UNUSED_PARAM(replyEncoder); ASSERT_NOT_REACHED(); diff --git a/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h b/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h index 6397c1043..50e1ca41f 100644 --- a/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h +++ b/Source/WebKit2/Scripts/webkit/LegacyMessages-expected.h @@ -27,13 +27,27 @@ #if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) +#include "ArgumentCoders.h" #include "Arguments.h" #include "Connection.h" +#if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE) +#include "DummyType.h" +#endif +#if PLATFORM(MAC) +#include "MachPort.h" +#endif #include "MessageEncoder.h" #include "Plugin.h" #include "StringReference.h" +#include "WebCoreArgumentCoders.h" +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) +#include "WebEvent.h" +#endif +#include "WebPreferencesStore.h" #include <WebCore/GraphicsLayer.h> +#if PLATFORM(MAC) #include <WebCore/KeyboardEvent.h> +#endif #include <WebCore/PluginData.h> #include <utility> #include <wtf/HashMap.h> @@ -43,17 +57,6 @@ namespace IPC { class Connection; - class DummyType; - class MachPort; -} - -namespace WTF { - class String; -} - -namespace WebKit { - struct WebPreferencesStore; - class WebTouchEvent; } namespace Messages { diff --git a/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp b/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp index 8d5e13dea..877e5129c 100644 --- a/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp +++ b/Source/WebKit2/Scripts/webkit/MessageReceiver-expected.cpp @@ -104,7 +104,7 @@ bool TestMultipleAttributes::DelayedReply::send() namespace WebKit { -void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder) +void WebPage::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder) { if (decoder.messageName() == Messages::WebPage::LoadURL::name()) { IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL); @@ -189,7 +189,7 @@ void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder ASSERT_NOT_REACHED(); } -void WebPage::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) +void WebPage::didReceiveSyncMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) { if (decoder.messageName() == Messages::WebPage::CreatePlugin::name()) { IPC::handleMessage<Messages::WebPage::CreatePlugin>(decoder, *replyEncoder, this, &WebPage::createPlugin); diff --git a/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp b/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp index c6889781f..b498e9d9a 100644 --- a/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp +++ b/Source/WebKit2/Scripts/webkit/MessageReceiverSuperclass-expected.cpp @@ -34,7 +34,7 @@ namespace WebKit { -void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder) +void WebPage::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder) { if (decoder.messageName() == Messages::WebPage::LoadURL::name()) { IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL); diff --git a/Source/WebKit2/Scripts/webkit/Messages-expected.h b/Source/WebKit2/Scripts/webkit/Messages-expected.h index 6397c1043..50e1ca41f 100644 --- a/Source/WebKit2/Scripts/webkit/Messages-expected.h +++ b/Source/WebKit2/Scripts/webkit/Messages-expected.h @@ -27,13 +27,27 @@ #if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) +#include "ArgumentCoders.h" #include "Arguments.h" #include "Connection.h" +#if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE) +#include "DummyType.h" +#endif +#if PLATFORM(MAC) +#include "MachPort.h" +#endif #include "MessageEncoder.h" #include "Plugin.h" #include "StringReference.h" +#include "WebCoreArgumentCoders.h" +#if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) +#include "WebEvent.h" +#endif +#include "WebPreferencesStore.h" #include <WebCore/GraphicsLayer.h> +#if PLATFORM(MAC) #include <WebCore/KeyboardEvent.h> +#endif #include <WebCore/PluginData.h> #include <utility> #include <wtf/HashMap.h> @@ -43,17 +57,6 @@ namespace IPC { class Connection; - class DummyType; - class MachPort; -} - -namespace WTF { - class String; -} - -namespace WebKit { - struct WebPreferencesStore; - class WebTouchEvent; } namespace Messages { diff --git a/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h b/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h index 9b353a040..89167b6b3 100644 --- a/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h +++ b/Source/WebKit2/Scripts/webkit/MessagesSuperclass-expected.h @@ -25,13 +25,12 @@ #ifndef WebPageMessages_h #define WebPageMessages_h +#include "ArgumentCoders.h" #include "Arguments.h" #include "MessageEncoder.h" #include "StringReference.h" +#include <wtf/text/WTFString.h> -namespace WTF { - class String; -} namespace Messages { namespace WebPage { diff --git a/Source/WebKit2/Scripts/webkit/messages.py b/Source/WebKit2/Scripts/webkit/messages.py index b71df91b6..4b786fe62 100644 --- a/Source/WebKit2/Scripts/webkit/messages.py +++ b/Source/WebKit2/Scripts/webkit/messages.py @@ -1,4 +1,4 @@ -# Copyright (C) 2010, 2011 Apple Inc. All rights reserved. +# Copyright (C) 2010-2017 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -23,6 +23,7 @@ import collections import re import sys + from webkit import parser WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection' @@ -168,11 +169,11 @@ def forward_declarations_for_namespace(namespace, kind_and_types): def forward_declarations_and_headers(receiver): types_by_namespace = collections.defaultdict(set) - headers = set([ - '"Arguments.h"', - '"MessageEncoder.h"', - '"StringReference.h"', - ]) + header_conditions = { + '"Arguments.h"' : [], + '"MessageEncoder.h"' : [], + '"StringReference.h"': [] + } non_template_wtf_types = frozenset([ 'String', @@ -180,38 +181,47 @@ def forward_declarations_and_headers(receiver): for message in receiver.messages: if message.reply_parameters != None and message.has_attribute(DELAYED_ATTRIBUTE): - headers.add('<wtf/ThreadSafeRefCounted.h>') + header_conditions['<wtf/ThreadSafeRefCounted.h>'] = [] types_by_namespace['IPC'].update([('class', 'Connection')]) + type_conditions = {} for parameter in receiver.iterparameters(): - kind = parameter.kind - type = parameter.type + if not parameter.type in type_conditions: + type_conditions[parameter.type] = [] - if type.find('<') != -1: - # Don't forward declare class templates. - headers.update(headers_for_type(type)) - continue + if not parameter.condition in type_conditions[parameter.type]: + type_conditions[parameter.type].append(parameter.condition) - split = type.split('::') + for parameter in receiver.iterparameters(): + type = parameter.type + conditions = type_conditions[type] - # Handle WTF types even if the WTF:: prefix is not given - if split[0] in non_template_wtf_types: - split.insert(0, 'WTF') + argument_encoder_headers = argument_coder_headers_for_type(type) + if argument_encoder_headers: + for header in argument_encoder_headers: + if header not in header_conditions: + header_conditions[header] = [] + header_conditions[header].extend(conditions) - if len(split) == 2: - namespace = split[0] - inner_type = split[1] - types_by_namespace[namespace].add((kind, inner_type)) - elif len(split) > 2: - # We probably have a nested struct, which means we can't forward declare it. - # Include its header instead. - headers.update(headers_for_type(type)) + type_headers = headers_for_type(type) + for header in type_headers: + if header not in header_conditions: + header_conditions[header] = [] + header_conditions[header].extend(conditions) forward_declarations = '\n'.join([forward_declarations_for_namespace(namespace, types) for (namespace, types) in sorted(types_by_namespace.items())]) - headers = ['#include %s\n' % header for header in sorted(headers)] + headers = [] + for header in sorted(header_conditions): + if header_conditions[header] and not None in header_conditions[header]: + headers.append('#if %s\n' % ' || '.join(set(header_conditions[header]))) + headers += ['#include %s\n' % header] + headers.append('#endif\n') + else: + headers += ['#include %s\n' % header] return (forward_declarations, headers) + def generate_messages_header(file): receiver = parser.parse(file) header_guard = messages_header_filename(receiver).replace('.', '_') @@ -302,7 +312,7 @@ def class_template_headers(template_string): match = re.match('(?P<template_name>.+?)<(?P<parameter_string>.+)>', template_string) if not match: - return {'header_infos':[], 'types':[template_string]} + return {'header_infos': [], 'types': [template_string]} template_name = match.groupdict()['template_name'] if template_name not in class_template_types: @@ -315,10 +325,10 @@ def class_template_headers(template_string): for parameter in parser.split_parameters_string(match.groupdict()['parameter_string']): parameter_header_infos_and_types = class_template_headers(parameter) - header_infos += parameter_header_infos_and_types['header_infos']; + header_infos += parameter_header_infos_and_types['header_infos'] types += parameter_header_infos_and_types['types'] - return {'header_infos':header_infos, 'types':types} + return {'header_infos': header_infos, 'types': types} def argument_coder_headers_for_type(type): @@ -346,6 +356,7 @@ def argument_coder_headers_for_type(type): return headers + def headers_for_type(type): header_infos_and_types = class_template_headers(type) @@ -402,6 +413,7 @@ def headers_for_type(type): return headers + def generate_message_handler(file): receiver = parser.parse(file) header_conditions = { @@ -452,7 +464,6 @@ def generate_message_handler(file): header_conditions[header] = [] header_conditions[header].append(message.condition) - result = [] result.append(_license_header) diff --git a/Source/WebKit2/Scripts/webkit/messages_unittest.py b/Source/WebKit2/Scripts/webkit/messages_unittest.py index e12dfd41e..164199fc2 100644 --- a/Source/WebKit2/Scripts/webkit/messages_unittest.py +++ b/Source/WebKit2/Scripts/webkit/messages_unittest.py @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Apple Inc. All rights reserved. +# Copyright (C) 2010-2017 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -21,44 +21,33 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os +import re +import sys import unittest from StringIO import StringIO -import messages -import parser - -print os.getcwd() +sys.path.append(os.path.dirname(os.path.dirname(__file__))) +from webkit import messages +from webkit import parser script_directory = os.path.dirname(os.path.realpath(__file__)) -with open(os.path.join(script_directory, 'test-messages.in')) as file: - _messages_file_contents = file.read() - -with open(os.path.join(script_directory, 'test-legacy-messages.in')) as file: - _legacy_messages_file_contents = file.read() - -with open(os.path.join(script_directory, 'test-superclass-messages.in')) as file: - _superclass_messages_file_contents = file.read() - - -with open(os.path.join(script_directory, 'Messages-expected.h')) as file: - _expected_receiver_header = file.read() +with open(os.path.join(script_directory, 'test-messages.in')) as in_file: + _messages_file_contents = in_file.read() -with open(os.path.join(script_directory, 'LegacyMessages-expected.h')) as file: - _expected_legacy_receiver_header = file.read() +with open(os.path.join(script_directory, 'test-legacy-messages.in')) as in_file: + _legacy_messages_file_contents = in_file.read() -with open(os.path.join(script_directory, 'MessagesSuperclass-expected.h')) as file: - _expected_superclass_receiver_header = file.read() - +with open(os.path.join(script_directory, 'test-superclass-messages.in')) as in_file: + _superclass_messages_file_contents = in_file.read() -with open(os.path.join(script_directory, 'MessageReceiver-expected.cpp')) as file: - _expected_receiver_implementation = file.read() +_expected_receiver_header_file_name = 'Messages-expected.h' +_expected_legacy_receiver_header_file_name = 'LegacyMessages-expected.h' +_expected_superclass_receiver_header_file_name = 'MessagesSuperclass-expected.h' -with open(os.path.join(script_directory, 'LegacyMessageReceiver-expected.cpp')) as file: - _expected_legacy_receiver_implementation = file.read() - -with open(os.path.join(script_directory, 'MessageReceiverSuperclass-expected.cpp')) as file: - _expected_superclass_receiver_implementation = file.read() +_expected_receiver_implementation_file_name = 'MessageReceiver-expected.cpp' +_expected_legacy_receiver_implementation_file_name = 'LegacyMessageReceiver-expected.cpp' +_expected_superclass_receiver_implementation_file_name = 'MessageReceiverSuperclass-expected.cpp' _expected_results = { 'name': 'WebPage', @@ -243,7 +232,7 @@ _expected_results = { _expected_superclass_results = { 'name': 'WebPage', - 'superclass' : 'WebPageBase', + 'superclass': 'WebPageBase', 'conditions': None, 'messages': ( { @@ -278,7 +267,7 @@ class ParsingTest(MessagesTest): self.assertTrue(parameter.has_attribute(attribute)) else: self.assertEquals(parameter.attributes, frozenset()) - if message.reply_parameters != None: + if message.reply_parameters is not None: for index, parameter in enumerate(message.reply_parameters): self.assertEquals(parameter.type, expected_message['reply_parameters'][index][0]) self.assertEquals(parameter.name, expected_message['reply_parameters'][index][1]) @@ -307,40 +296,50 @@ class ParsingTest(MessagesTest): self.check_message(message, _expected_superclass_results['messages'][index]) - class GeneratedFileContentsTest(unittest.TestCase): - def assertGeneratedFileContentsEqual(self, first, second): - first_list = first.split('\n') - second_list = second.split('\n') + def assertGeneratedFileContentsEqual(self, actual_file_contents, expected_file_name): + if reset_results: + with open(os.path.join(script_directory, expected_file_name), mode='w') as out_file: + out_file.write(actual_file_contents) + return - for index, first_line in enumerate(first_list): - self.assertEquals(first_line, second_list[index]) + with open(os.path.join(script_directory, expected_file_name), mode='r') as in_file: + expected_file_contents = in_file.read() + actual_line_list = actual_file_contents.splitlines(False) + expected_line_list = expected_file_contents.splitlines(False) - self.assertEquals(len(first_list), len(second_list)) + for index, actual_line in enumerate(actual_line_list): + self.assertEquals(actual_line, expected_line_list[index]) + self.assertEquals(len(actual_line_list), len(expected_line_list)) -class HeaderTest(GeneratedFileContentsTest): - def test_header(self): - file_contents = messages.generate_messages_header(StringIO(_messages_file_contents)) - self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_header) + def assertHeaderEqual(self, input_messages_file_contents, expected_file_name): + actual_file_contents = messages.generate_messages_header(StringIO(input_messages_file_contents)) + self.assertGeneratedFileContentsEqual(actual_file_contents, expected_file_name) - legacy_file_contents = messages.generate_messages_header(StringIO(_legacy_messages_file_contents)) - self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_header) + def assertImplementationEqual(self, input_messages_file_contents, expected_file_name): + actual_file_contents = messages.generate_message_handler(StringIO(input_messages_file_contents)) + self.assertGeneratedFileContentsEqual(actual_file_contents, expected_file_name) - superclass_file_contents = messages.generate_messages_header(StringIO(_superclass_messages_file_contents)) - self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_header) +class HeaderTest(GeneratedFileContentsTest): + def test_receiver_headers(self): + self.assertHeaderEqual(_messages_file_contents, + _expected_receiver_header_file_name) + self.assertHeaderEqual(_legacy_messages_file_contents, + _expected_legacy_receiver_header_file_name) + self.assertHeaderEqual(_superclass_messages_file_contents, + _expected_superclass_receiver_header_file_name) -class ReceiverImplementationTest(GeneratedFileContentsTest): - def test_receiver_implementation(self): - file_contents = messages.generate_message_handler(StringIO(_messages_file_contents)) - self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_implementation) - - legacy_file_contents = messages.generate_message_handler(StringIO(_legacy_messages_file_contents)) - self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_implementation) - superclass_file_contents = messages.generate_message_handler(StringIO(_superclass_messages_file_contents)) - self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_implementation) +class ReceiverImplementationTest(GeneratedFileContentsTest): + def test_receiver_implementations(self): + self.assertImplementationEqual(_messages_file_contents, + _expected_receiver_implementation_file_name) + self.assertImplementationEqual(_legacy_messages_file_contents, + _expected_legacy_receiver_implementation_file_name) + self.assertImplementationEqual(_superclass_messages_file_contents, + _expected_superclass_receiver_implementation_file_name) class UnsupportedPrecompilerDirectiveTest(unittest.TestCase): @@ -353,5 +352,38 @@ class UnsupportedPrecompilerDirectiveTest(unittest.TestCase): messages.generate_message_handler(StringIO("asd\n#elif bla\nfoo")) +def add_reset_results_to_unittest_help(): + script_name = os.path.basename(__file__) + reset_results_help = ''' +Custom Options: + -r, --reset-results Reset expected results for {0} +'''.format(script_name) + + options_regex = re.compile('^Usage:') + lines = unittest.TestProgram.USAGE.splitlines(True) + index = 0 + for index, line in enumerate(lines): + if options_regex.match(line) and index + 1 < len(lines): + lines.insert(index + 1, reset_results_help) + break + + if index == (len(lines) - 1): + lines.append(reset_results_help) + + unittest.TestProgram.USAGE = ''.join(lines) + + +def parse_sys_argv(): + global reset_results + for index, arg in enumerate(sys.argv[1:]): + if arg in ('-r', '--r', '--reset', '--reset-results') or '--reset-results'.startswith(arg): + reset_results = True + del sys.argv[index + 1] + break + + if __name__ == '__main__': + reset_results = False + add_reset_results_to_unittest_help() + parse_sys_argv() unittest.main() diff --git a/Source/WebKit2/Scripts/webkit/model.py b/Source/WebKit2/Scripts/webkit/model.py index ebf75ccd4..d0830440d 100644 --- a/Source/WebKit2/Scripts/webkit/model.py +++ b/Source/WebKit2/Scripts/webkit/model.py @@ -1,4 +1,4 @@ -# Copyright (C) 2010, 2011 Apple Inc. All rights reserved. +# Copyright (C) 2010-2017 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -38,6 +38,7 @@ class MessageReceiver(object): def has_attribute(self, attribute): return attribute in self.attributes + class Message(object): def __init__(self, name, parameters, reply_parameters, attributes, condition): self.name = name diff --git a/Source/WebKit2/Scripts/webkit/parser.py b/Source/WebKit2/Scripts/webkit/parser.py index 69a81dfef..306139468 100644 --- a/Source/WebKit2/Scripts/webkit/parser.py +++ b/Source/WebKit2/Scripts/webkit/parser.py @@ -1,4 +1,4 @@ -# Copyright (C) 2010, 2011 Apple Inc. All rights reserved. +# Copyright (C) 2010-2017 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -121,6 +121,7 @@ def split_parameters_string(parameters_string): parameters.append(current_parameter_string) return parameters + def parse_parameters_string(parameters_string): parameters = [] diff --git a/Source/qtwebkit.qdocconf b/Source/qtwebkit.qdocconf index 8e4edbd75..0d963a7fb 100644 --- a/Source/qtwebkit.qdocconf +++ b/Source/qtwebkit.qdocconf @@ -30,7 +30,7 @@ qhp.QtWebKit.subprojects.qmltypes.selectors = qmlclass qhp.QtWebKit.subprojects.qmltypes.sortPages = true headerdirs = WebKit/qt/Api WebKit/qt/WidgetApi WebKit2/UIProcess/API/qt -sourcedirs = WebKit/qt/Api WebKit/qt/WidgetApi WebKit/qt/docs Source/JavaScriptCore/qt/api WebKit2/UIProcess/API/qt +sourcedirs = WebKit/qt/Api WebKit/qt/WidgetApi WebKit/qt/docs WebKit2/UIProcess/API/qt exampledirs = WebKit/qt/docs imagedirs = WebKit/qt/docs diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp index 6e221840d..6e9d388e9 100644 --- a/Tools/QtTestBrowser/launcherwindow.cpp +++ b/Tools/QtTestBrowser/launcherwindow.cpp @@ -106,6 +106,8 @@ LauncherWindow::LauncherWindow(WindowOptions* data, QGraphicsScene* sharedScene) createChrome(); #if !defined(QT_NO_FILEDIALOG) && !defined(QT_NO_MESSAGEBOX) connect(page(), SIGNAL(downloadRequested(const QNetworkRequest&)), this, SLOT(downloadRequest(const QNetworkRequest&))); + connect(page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), + this, SLOT(showSSLErrorConfirmation(QNetworkReply*, const QList<QSslError>&))); #endif } @@ -1166,7 +1168,7 @@ void LauncherWindow::showSSLErrorConfirmation(QNetworkReply* reply, const QList< errorStrings += "</ul>"; QMessageBox sslWarningBox; - sslWarningBox.setText("SSL handshake problem"); + sslWarningBox.setText("TLS handshake problem"); sslWarningBox.setInformativeText(errorStrings); sslWarningBox.setStandardButtons(QMessageBox::Abort | QMessageBox::Ignore); sslWarningBox.setDefaultButton(QMessageBox::Abort); diff --git a/Tools/QtTestBrowser/mainwindow.cpp b/Tools/QtTestBrowser/mainwindow.cpp index e22193a96..573bc77c9 100644 --- a/Tools/QtTestBrowser/mainwindow.cpp +++ b/Tools/QtTestBrowser/mainwindow.cpp @@ -86,7 +86,6 @@ void MainWindow::buildUI() connect(page()->mainFrame(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(page()->mainFrame(), SIGNAL(iconChanged()), this, SLOT(onIconChanged())); connect(page()->mainFrame(), SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString))); - connect(page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(onSSLErrors(QNetworkReply*, const QList<QSslError>&))); connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); #ifndef QT_NO_SHORTCUT |