From eb6c5179e8650f66b304a656409a1e5e5efec956 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Wed, 26 Jun 2019 19:22:59 +0300 Subject: Import WebKit commit d6bf9b7a5a72ec63236f3f2d0eabc20913309793 Change-Id: I15a655045d43ea5f2cfe1158016db6426ded0224 Reviewed-by: Konstantin Tokarev --- Source/WebCore/platform/Cursor.cpp | 12 +++- Source/WebCore/platform/Cursor.h | 6 +- .../platform/graphics/qt/MediaPlayerPrivateQt.cpp | 2 +- Source/WebCore/platform/qt/CursorQt.cpp | 83 ++++++++++------------ 4 files changed, 53 insertions(+), 50 deletions(-) (limited to 'Source/WebCore') 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 m_platformCursor; +#elif !USE(APPKIT) mutable PlatformCursor m_platformCursor; #else mutable RetainPtr 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(*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(*other.m_platformCursor) : nullptr; #endif return *this; } #ifndef QT_NO_CURSOR -static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot) +static std::unique_ptr 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(*(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(Qt::ArrowCursor); break; case Cross: - m_platformCursor = new QCursor(Qt::CrossCursor); + m_platformCursor = std::make_unique(Qt::CrossCursor); break; case Hand: - m_platformCursor = new QCursor(Qt::PointingHandCursor); + m_platformCursor = std::make_unique(Qt::PointingHandCursor); break; case IBeam: - m_platformCursor = new QCursor(Qt::IBeamCursor); + m_platformCursor = std::make_unique(Qt::IBeamCursor); break; case Wait: - m_platformCursor = new QCursor(Qt::WaitCursor); + m_platformCursor = std::make_unique(Qt::WaitCursor); break; case Help: - m_platformCursor = new QCursor(Qt::WhatsThisCursor); + m_platformCursor = std::make_unique(Qt::WhatsThisCursor); break; case EastResize: case EastPanning: - m_platformCursor = new QCursor(Qt::SizeHorCursor); + m_platformCursor = std::make_unique(Qt::SizeHorCursor); break; case NorthResize: case NorthPanning: - m_platformCursor = new QCursor(Qt::SizeVerCursor); + m_platformCursor = std::make_unique(Qt::SizeVerCursor); break; case NorthEastResize: case NorthEastPanning: - m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + m_platformCursor = std::make_unique(Qt::SizeBDiagCursor); break; case NorthWestResize: case NorthWestPanning: - m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + m_platformCursor = std::make_unique(Qt::SizeFDiagCursor); break; case SouthResize: case SouthPanning: - m_platformCursor = new QCursor(Qt::SizeVerCursor); + m_platformCursor = std::make_unique(Qt::SizeVerCursor); break; case SouthEastResize: case SouthEastPanning: - m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + m_platformCursor = std::make_unique(Qt::SizeFDiagCursor); break; case SouthWestResize: case SouthWestPanning: - m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + m_platformCursor = std::make_unique(Qt::SizeBDiagCursor); break; case WestResize: case WestPanning: - m_platformCursor = new QCursor(Qt::SizeHorCursor); + m_platformCursor = std::make_unique(Qt::SizeHorCursor); break; case NorthSouthResize: - m_platformCursor = new QCursor(Qt::SizeVerCursor); + m_platformCursor = std::make_unique(Qt::SizeVerCursor); break; case EastWestResize: - m_platformCursor = new QCursor(Qt::SizeHorCursor); + m_platformCursor = std::make_unique(Qt::SizeHorCursor); break; case NorthEastSouthWestResize: - m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + m_platformCursor = std::make_unique(Qt::SizeBDiagCursor); break; case NorthWestSouthEastResize: - m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + m_platformCursor = std::make_unique(Qt::SizeFDiagCursor); break; case ColumnResize: - m_platformCursor = new QCursor(Qt::SplitHCursor); + m_platformCursor = std::make_unique(Qt::SplitHCursor); break; case RowResize: - m_platformCursor = new QCursor(Qt::SplitVCursor); + m_platformCursor = std::make_unique(Qt::SplitVCursor); break; case MiddlePanning: case Move: - m_platformCursor = new QCursor(Qt::SizeAllCursor); + m_platformCursor = std::make_unique(Qt::SizeAllCursor); break; case None: - m_platformCursor = new QCursor(Qt::BlankCursor); + m_platformCursor = std::make_unique(Qt::BlankCursor); break; case NoDrop: case NotAllowed: - m_platformCursor = new QCursor(Qt::ForbiddenCursor); + m_platformCursor = std::make_unique(Qt::ForbiddenCursor); break; case Grab: case Grabbing: notImplemented(); - m_platformCursor = new QCursor(Qt::ArrowCursor); + m_platformCursor = std::make_unique(Qt::ArrowCursor); break; case VerticalText: - m_platformCursor = new QCursor(QPixmap(QStringLiteral(":/webkit/resources/verticalTextCursor.png")), 7, 7); + m_platformCursor = std::make_unique(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(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(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(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(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(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(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(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(Qt::ArrowCursor); break; default: ASSERT_NOT_REACHED(); -- cgit v1.2.1