diff options
Diffstat (limited to 'WebCore/platform/qt')
34 files changed, 1600 insertions, 738 deletions
diff --git a/WebCore/platform/qt/ClipboardQt.cpp b/WebCore/platform/qt/ClipboardQt.cpp index c23e42e..6ca4830 100644 --- a/WebCore/platform/qt/ClipboardQt.cpp +++ b/WebCore/platform/qt/ClipboardQt.cpp @@ -22,15 +22,16 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "ClipboardQt.h" -#include "CachedImage.h" #include "CSSHelper.h" +#include "CachedImage.h" #include "Document.h" +#include "DragData.h" #include "Element.h" #include "FileList.h" #include "Frame.h" @@ -38,25 +39,41 @@ #include "Image.h" #include "IntPoint.h" #include "KURL.h" -#include "markup.h" #include "NotImplemented.h" #include "PlatformString.h" #include "Range.h" #include "RenderImage.h" #include "StringHash.h" +#include "markup.h" +#include <QApplication> +#include <QClipboard> #include <QList> #include <QMimeData> #include <QStringList> +#include <QTextCodec> #include <QUrl> -#include <QApplication> -#include <QClipboard> #include <qdebug.h> #define methodDebug() qDebug("ClipboardQt: %s", __FUNCTION__) namespace WebCore { +static bool isTextMimeType(const String& type) +{ + return type == "text/plain" || type.startsWith("text/plain;"); +} + +static bool isHtmlMimeType(const String& type) +{ + return type == "text/html" || type.startsWith("text/html;"); +} + +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame*) +{ + return ClipboardQt::create(policy, dragData->platformData()); +} + ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, const QMimeData* readableClipboard) : Clipboard(policy, true) , m_readableData(readableClipboard) @@ -130,10 +147,21 @@ String ClipboardQt::getData(const String& type, bool& success) const return String(); } + if (isHtmlMimeType(type) && m_readableData->hasHtml()) { + success = true; + return m_readableData->html(); + } + + if (isTextMimeType(type) && m_readableData->hasText()) { + success = true; + return m_readableData->text(); + } + ASSERT(m_readableData); - QByteArray data = m_readableData->data(QString(type)); + QByteArray rawData = m_readableData->data(type); + QString data = QTextCodec::codecForName("UTF-16")->toUnicode(rawData); success = !data.isEmpty(); - return String(data.data(), data.size()); + return data; } bool ClipboardQt::setData(const String& type, const String& data) @@ -143,9 +171,16 @@ bool ClipboardQt::setData(const String& type, const String& data) if (!m_writableData) m_writableData = new QMimeData; - QByteArray array(reinterpret_cast<const char*>(data.characters()), - data.length()*2); - m_writableData->setData(QString(type), array); + + if (isTextMimeType(type)) + m_writableData->setText(QString(data)); + else if (isHtmlMimeType(type)) + m_writableData->setHtml(QString(data)); + else { + QByteArray array(reinterpret_cast<const char*>(data.characters()), data.length() * 2); + m_writableData->setData(QString(type), array); + } + #ifndef QT_NO_CLIPBOARD if (!isForDragging()) QApplication::clipboard()->setMimeData(m_writableData); @@ -226,14 +261,14 @@ void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, co { ASSERT(frame); - //WebCore::writeURL(m_writableDataObject.get(), url, title, true, false); + // WebCore::writeURL(m_writableDataObject.get(), url, title, true, false); if (!m_writableData) m_writableData = new QMimeData; CachedImage* cachedImage = getCachedImage(element); if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded()) return; - QPixmap *pixmap = cachedImage->image()->nativeImageForCurrentFrame(); + QPixmap* pixmap = cachedImage->image()->nativeImageForCurrentFrame(); if (pixmap) m_writableData->setImageData(*pixmap); @@ -283,7 +318,7 @@ void ClipboardQt::writeRange(Range* range, Frame* frame) QString text = frame->selectedText(); text.replace(QChar(0xa0), QLatin1Char(' ')); m_writableData->setText(text); - m_writableData->setHtml(createMarkup(range, 0, AnnotateForInterchange)); + m_writableData->setHtml(createMarkup(range, 0, AnnotateForInterchange, false, AbsoluteURLs)); #ifndef QT_NO_CLIPBOARD if (!isForDragging()) QApplication::clipboard()->setMimeData(m_writableData); diff --git a/WebCore/platform/qt/ContextMenuItemQt.cpp b/WebCore/platform/qt/ContextMenuItemQt.cpp index cf23587..b91a2a7 100644 --- a/WebCore/platform/qt/ContextMenuItemQt.cpp +++ b/WebCore/platform/qt/ContextMenuItemQt.cpp @@ -21,11 +21,12 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "ContextMenuItem.h" + #include "ContextMenu.h" namespace WebCore { diff --git a/WebCore/platform/qt/ContextMenuQt.cpp b/WebCore/platform/qt/ContextMenuQt.cpp index 9b1a054..30c4c2d 100644 --- a/WebCore/platform/qt/ContextMenuQt.cpp +++ b/WebCore/platform/qt/ContextMenuQt.cpp @@ -21,19 +21,17 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "ContextMenu.h" -#include <wtf/Assertions.h> - -#include <QAction> - #include <Document.h> #include <Frame.h> #include <FrameView.h> +#include <QAction> +#include <wtf/Assertions.h> namespace WebCore { diff --git a/WebCore/platform/qt/CookieJarQt.cpp b/WebCore/platform/qt/CookieJarQt.cpp index 01d1756..15053eb 100644 --- a/WebCore/platform/qt/CookieJarQt.cpp +++ b/WebCore/platform/qt/CookieJarQt.cpp @@ -67,7 +67,6 @@ void setCookies(Document* document, const KURL& url, const String& value) return; QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toAscii()); -#if QT_VERSION >= 0x040500 QList<QNetworkCookie>::Iterator it = cookies.begin(); while (it != cookies.end()) { if (it->isHttpOnly()) @@ -75,7 +74,6 @@ void setCookies(Document* document, const KURL& url, const String& value) else ++it; } -#endif jar->setCookiesFromUrl(cookies, u); } @@ -92,10 +90,8 @@ String cookies(const Document* document, const KURL& url) QStringList resultCookies; foreach (QNetworkCookie networkCookie, cookies) { -#if QT_VERSION >= 0x040500 if (networkCookie.isHttpOnly()) continue; -#endif resultCookies.append(QString::fromAscii( networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData())); } diff --git a/WebCore/platform/qt/CursorQt.cpp b/WebCore/platform/qt/CursorQt.cpp index 87f4fce..6017daa 100644 --- a/WebCore/platform/qt/CursorQt.cpp +++ b/WebCore/platform/qt/CursorQt.cpp @@ -44,12 +44,12 @@ namespace WebCore { Cursor::Cursor(PlatformCursor p) - : m_impl(p) + : m_platformCursor(p) { } Cursor::Cursor(const Cursor& other) - : m_impl(other.m_impl) + : m_platformCursor(other.m_platformCursor) { } @@ -57,16 +57,17 @@ Cursor::~Cursor() { } -Cursor::Cursor(Image* image, const IntPoint& hotspot) +Cursor::Cursor(Image* image, const IntPoint& hotSpot) +{ #ifndef QT_NO_CURSOR - : m_impl(*(image->nativeImageForCurrentFrame()), hotspot.x(), hotspot.y()) + IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot); + m_platformCursor = QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y()); #endif -{ } Cursor& Cursor::operator=(const Cursor& other) { - m_impl = other.m_impl; + m_platformCursor = other.m_platformCursor; return *this; } diff --git a/WebCore/platform/qt/DragDataQt.cpp b/WebCore/platform/qt/DragDataQt.cpp index 09a797f..4033123 100644 --- a/WebCore/platform/qt/DragDataQt.cpp +++ b/WebCore/platform/qt/DragDataQt.cpp @@ -20,21 +20,20 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "DragData.h" -#include "ClipboardQt.h" #include "Document.h" #include "DocumentFragment.h" #include "markup.h" +#include <QColor> #include <QList> #include <QMimeData> #include <QUrl> -#include <QColor> namespace WebCore { @@ -90,7 +89,7 @@ String DragData::asPlainText() const return text; // FIXME: Should handle rich text here - return asURL(0); + return asURL(DoNotConvertFilenames, 0); } Color DragData::asColor() const @@ -100,11 +99,6 @@ Color DragData::asColor() const return qvariant_cast<QColor>(m_platformDragData->colorData()); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return ClipboardQt::create(policy, m_platformDragData); -} - bool DragData::containsCompatibleContent() const { if (!m_platformDragData) @@ -112,15 +106,17 @@ bool DragData::containsCompatibleContent() const return containsColor() || containsURL() || m_platformDragData->hasHtml() || m_platformDragData->hasText(); } -bool DragData::containsURL() const +bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const { + // FIXME: Use filenamePolicy. if (!m_platformDragData) return false; return m_platformDragData->hasUrls(); } -String DragData::asURL(String*) const +String DragData::asURL(FilenameConversionPolicy filenamePolicy, String*) const { + // FIXME: Use filenamePolicy. if (!m_platformDragData) return String(); QList<QUrl> urls = m_platformDragData->urls(); diff --git a/WebCore/platform/qt/FileChooserQt.cpp b/WebCore/platform/qt/FileChooserQt.cpp index 307876c..8b1df0a 100644 --- a/WebCore/platform/qt/FileChooserQt.cpp +++ b/WebCore/platform/qt/FileChooserQt.cpp @@ -21,8 +21,8 @@ #include "config.h" #include "FileChooser.h" -#include "LocalizedStrings.h" #include "Font.h" +#include "LocalizedStrings.h" #include <QCoreApplication> #include <QFontMetrics> diff --git a/WebCore/platform/qt/FileSystemQt.cpp b/WebCore/platform/qt/FileSystemQt.cpp index 4093fad..03dfc8f 100644 --- a/WebCore/platform/qt/FileSystemQt.cpp +++ b/WebCore/platform/qt/FileSystemQt.cpp @@ -9,13 +9,13 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -32,15 +32,13 @@ #include "config.h" #include "FileSystem.h" -#include "CString.h" #include "PlatformString.h" - #include <QDateTime> +#include <QDir> #include <QFile> -#include <QTemporaryFile> #include <QFileInfo> -#include <QDateTime> -#include <QDir> +#include <QTemporaryFile> +#include <wtf/text/CString.h> namespace WebCore { @@ -117,6 +115,7 @@ Vector<String> listDirectory(const String& path, const String& filter) CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle) { +#ifndef QT_NO_TEMPORARYFILE QTemporaryFile* tempFile = new QTemporaryFile(QLatin1String(prefix)); tempFile->setAutoRemove(false); QFile* temp = tempFile; @@ -124,6 +123,7 @@ CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle) handle = temp; return String(temp->fileName()).utf8(); } +#endif handle = invalidPlatformFileHandle; return CString(); } @@ -154,11 +154,12 @@ bool unloadModule(PlatformModule module) return ::FreeLibrary(module); #else +#ifndef QT_NO_LIBRARY if (module->unload()) { delete module; return true; } - +#endif return false; #endif } diff --git a/WebCore/platform/qt/GeolocationServiceQt.cpp b/WebCore/platform/qt/GeolocationServiceQt.cpp new file mode 100644 index 0000000..3562eb9 --- /dev/null +++ b/WebCore/platform/qt/GeolocationServiceQt.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GeolocationServiceQt.h" + +#include "Geolocation.h" +#include "Geoposition.h" +#include "PositionError.h" +#include "PositionOptions.h" + +using namespace QtMobility; + +namespace WebCore { + +GeolocationService::FactoryFunction* GeolocationService::s_factoryFunction = &GeolocationServiceQt::create; + +GeolocationService* GeolocationServiceQt::create(GeolocationServiceClient* client) +{ + return new GeolocationServiceQt(client); +} + +GeolocationServiceQt::GeolocationServiceQt(GeolocationServiceClient* client) + : GeolocationService(client) + , m_lastPosition(0) + , m_lastError(0) +{ + m_location = QGeoPositionInfoSource::createDefaultSource(this); + + if (m_location) + connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); +} + +GeolocationServiceQt::~GeolocationServiceQt() +{ + delete m_location; +} + +void GeolocationServiceQt::positionUpdated(const QGeoPositionInfo &geoPosition) +{ + if (!geoPosition.isValid()) + errorOccurred(); + + QGeoCoordinate coord = geoPosition.coordinate(); + double latitude = coord.latitude(); + double longitude = coord.longitude(); + bool providesAltitude = (geoPosition.coordinate().type() == QGeoCoordinate::Coordinate3D); + double altitude = coord.altitude(); + + double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy); + + bool providesAltitudeAccuracy = geoPosition.hasAttribute(QGeoPositionInfo::VerticalAccuracy); + double altitudeAccuracy = geoPosition.attribute(QGeoPositionInfo::VerticalAccuracy); + + bool providesHeading = geoPosition.hasAttribute(QGeoPositionInfo::Direction); + double heading = geoPosition.attribute(QGeoPositionInfo::Direction); + + bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed); + double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed); + + RefPtr<Coordinates> coordinates = Coordinates::create(latitude, longitude, providesAltitude, altitude, + accuracy, providesAltitudeAccuracy, altitudeAccuracy, + providesHeading, heading, providesSpeed, speed); + m_lastPosition = Geoposition::create(coordinates.release(), geoPosition.timestamp().toTime_t()); + positionChanged(); +} + +bool GeolocationServiceQt::startUpdating(PositionOptions*) +{ + m_lastPosition = 0; + + if (!m_location) + return false; + + // TODO: handle enableHighAccuracy() + + m_location->startUpdates(); + return true; +} + +void GeolocationServiceQt::stopUpdating() +{ + if (m_location) + m_location->stopUpdates(); +} + +} // namespace WebCore diff --git a/WebCore/platform/qt/GeolocationServiceQt.h b/WebCore/platform/qt/GeolocationServiceQt.h new file mode 100644 index 0000000..2525e47 --- /dev/null +++ b/WebCore/platform/qt/GeolocationServiceQt.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GeolocationServiceQt_h +#define GeolocationServiceQt_h + +#include "GeolocationService.h" +#include <QGeoPositionInfoSource> +#include <wtf/RefPtr.h> + +// FIXME: Remove usage of "using namespace" in a header file. +// There is bug in qtMobility signal names are not full qualified when used with namespace +// QtMobility namespace in slots throws up error and its required to be fixed in qtmobility. +using namespace QtMobility; + +namespace WebCore { + +// This class provides a implementation of a GeolocationService for qtWebkit. +// It uses QtMobility (v1.0.0) location service to get positions +class GeolocationServiceQt : public QObject, GeolocationService { + Q_OBJECT + +public: + static GeolocationService* create(GeolocationServiceClient*); + + GeolocationServiceQt(GeolocationServiceClient*); + virtual ~GeolocationServiceQt(); + + virtual bool startUpdating(PositionOptions*); + virtual void stopUpdating(); + + virtual Geoposition* lastPosition() const { return m_lastPosition.get(); } + virtual PositionError* lastError() const { return m_lastError.get(); } + +public Q_SLOTS: + // QGeoPositionInfoSource + void positionUpdated(const QGeoPositionInfo&); + +private: + RefPtr<Geoposition> m_lastPosition; + RefPtr<PositionError> m_lastError; + + QtMobility::QGeoPositionInfoSource* m_location; +}; + +} // namespace WebCore + +#endif // GeolocationServiceQt_h diff --git a/WebCore/platform/qt/KURLQt.cpp b/WebCore/platform/qt/KURLQt.cpp index 3bb3db2..f6d2a86 100644 --- a/WebCore/platform/qt/KURLQt.cpp +++ b/WebCore/platform/qt/KURLQt.cpp @@ -19,22 +19,14 @@ */ #include "config.h" #include "KURL.h" -#include "CString.h" -#include "TextEncoding.h" #include "NotImplemented.h" +#include "TextEncoding.h" #include "qurl.h" +#include <wtf/text/CString.h> namespace WebCore { -#if QT_VERSION < 0x040500 -static const char hexnumbers[] = "0123456789ABCDEF"; -static inline char toHex(char c) -{ - return hexnumbers[c & 0xf]; -} -#endif - KURL::KURL(const QUrl& url) { *this = KURL(KURL(), url.toEncoded().constData(), UTF8Encoding()); @@ -42,53 +34,8 @@ KURL::KURL(const QUrl& url) KURL::operator QUrl() const { -#if QT_VERSION < 0x040500 - unsigned length = m_string.length(); - - QByteArray ba; - ba.reserve(length); - - int path = -1; - int host = m_string.find("://"); - if (host != -1) { - host += 3; - - path = m_string.find('/', host); - } - - for (unsigned i = 0; i < length; ++i) { - const char chr = static_cast<char>(m_string[i]); - - switch (chr) { - encode: - case '{': - case '}': - case '|': - case '\\': - case '^': - case '`': - ba.append('%'); - ba.append(toHex((chr & 0xf0) >> 4)); - ba.append(toHex(chr & 0xf)); - break; - case '[': - case ']': - // special case: if this is the host part, don't encode - // otherwise, encode - if (host == -1 || (path != -1 && i >= path)) - goto encode; - // fall through - default: - ba.append(chr); - break; - } - } -#else - // Qt 4.5 or later - // No need for special encoding QString str = QString::fromRawData(reinterpret_cast<const QChar*>(m_string.characters()), m_string.length()); QByteArray ba = str.toUtf8(); -#endif QUrl url = QUrl::fromEncoded(ba); return url; diff --git a/WebCore/platform/qt/Localizations.cpp b/WebCore/platform/qt/Localizations.cpp index c919193..454872a 100644 --- a/WebCore/platform/qt/Localizations.cpp +++ b/WebCore/platform/qt/Localizations.cpp @@ -27,15 +27,15 @@ */ #include "config.h" +#include "LocalizedStrings.h" #include "IntSize.h" -#include "LocalizedStrings.h" #include "NotImplemented.h" #include "PlatformString.h" -#include <wtf/MathExtras.h> - #include <QCoreApplication> #include <QLocale> +#include <wtf/MathExtras.h> + namespace WebCore { @@ -351,6 +351,17 @@ String AXMenuListActionVerb() return String(); } +String missingPluginText() +{ + return QCoreApplication::translate("QWebPage", "Missing Plug-in", "Label text to be used when a plug-in is missing"); +} + +String crashedPluginText() +{ + notImplemented(); + return String(); +} + String multipleFileUploadText(unsigned) { return String(); @@ -466,21 +477,18 @@ String localizedMediaTimeDescription(float time) int minutes = (seconds / 60) % 60; seconds %= 60; - if (days) { + if (days) return QCoreApplication::translate("QWebPage", "%1 days %2 hours %3 minutes %4 seconds", "Media time description").arg(days).arg(hours).arg(minutes).arg(seconds); - } - if (hours) { + if (hours) return QCoreApplication::translate("QWebPage", "%1 hours %2 minutes %3 seconds", "Media time description").arg(hours).arg(minutes).arg(seconds); - } - if (minutes) { + if (minutes) return QCoreApplication::translate("QWebPage", "%1 minutes %2 seconds", "Media time description").arg(minutes).arg(seconds); - } return QCoreApplication::translate("QWebPage", "%1 seconds", "Media time description").arg(seconds); } -#endif // ENABLE(VIDEO) +#endif // ENABLE(VIDEO) String validationMessageValueMissingText() { diff --git a/WebCore/platform/qt/LoggingQt.cpp b/WebCore/platform/qt/LoggingQt.cpp index 2854953..817887d 100644 --- a/WebCore/platform/qt/LoggingQt.cpp +++ b/WebCore/platform/qt/LoggingQt.cpp @@ -19,8 +19,8 @@ #include "config.h" #include "Logging.h" -#include "PlatformString.h" +#include "PlatformString.h" #include <QDebug> #include <QStringList> diff --git a/WebCore/platform/qt/MIMETypeRegistryQt.cpp b/WebCore/platform/qt/MIMETypeRegistryQt.cpp index 22cee6f..4161f81 100644 --- a/WebCore/platform/qt/MIMETypeRegistryQt.cpp +++ b/WebCore/platform/qt/MIMETypeRegistryQt.cpp @@ -82,4 +82,10 @@ String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) return "application/octet-stream"; } +bool MIMETypeRegistry::isApplicationPluginMIMEType(const String& mimeType) +{ + return mimeType.startsWith("application/x-qt-plugin", false) + || mimeType.startsWith("application/x-qt-styled-widget", false); +} + } diff --git a/WebCore/platform/qt/Maemo5Webstyle.cpp b/WebCore/platform/qt/Maemo5Webstyle.cpp new file mode 100644 index 0000000..42b0b71 --- /dev/null +++ b/WebCore/platform/qt/Maemo5Webstyle.cpp @@ -0,0 +1,268 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#include "config.h" +#include "Maemo5Webstyle.h" + +#include "QtStyleOptionWebComboBox.h" + +#include <QPainter> +#include <QPixmapCache> +#include <QStyleOption> + +Maemo5WebStyle::Maemo5WebStyle() +{ +} + +static inline void drawRectangularControlBackground(QPainter* painter, const QPen& pen, const QRect& rect, const QBrush& brush) +{ + QPen oldPen = painter->pen(); + QBrush oldBrush = painter->brush(); + painter->setPen(pen); + painter->setBrush(brush); + + int line = 1; + painter->drawRect(rect.adjusted(line, line, -line, -line)); + + painter->setPen(oldPen); + painter->setBrush(oldBrush); +} + +void Maemo5WebStyle::drawChecker(QPainter* painter, int size, QColor color) const +{ + int border = qMin(qMax(1, int(0.2 * size)), 6); + int checkerSize = size - 2 * border; + int width = checkerSize / 3; + int middle = qMax(3 * checkerSize / 7, 3); + int x = ((size - checkerSize) >> 1); + int y = ((size - checkerSize) >> 1) + (checkerSize - width - middle); + QVector<QLineF> lines(checkerSize + 1); + painter->setPen(color); + for (int i = 0; i < middle; ++i) { + lines[i] = QLineF(x, y, x, y + width); + ++x; + ++y; + } + for (int i = middle; i <= checkerSize; ++i) { + lines[i] = QLineF(x, y, x, y + width); + ++x; + --y; + } + painter->drawLines(lines.constData(), lines.size()); +} + +QPixmap Maemo5WebStyle::findChecker(const QRect& rect, bool disabled) const +{ + int size = qMin(rect.width(), rect.height()); + QPixmap result; + static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-checker-"; + QString key = prefix + QString::number(size) + "-" + (disabled ? "disabled" : "enabled"); + if (!QPixmapCache::find(key, result)) { + result = QPixmap(size, size); + result.fill(Qt::transparent); + QPainter painter(&result); + drawChecker(&painter, size, disabled ? Qt::gray : Qt::black); + QPixmapCache::insert(key, result); + } + return result; +} + +void Maemo5WebStyle::drawRadio(QPainter* painter, const QSize& size, bool checked, QColor color) const +{ + painter->setRenderHint(QPainter::Antialiasing, true); + + // deflate one pixel + QRect rect = QRect(QPoint(1, 1), QSize(size.width() - 2, size.height() - 2)); + + QPen pen(Qt::black); + pen.setWidth(1); + painter->setPen(color); + painter->setBrush(Qt::white); + painter->drawEllipse(rect); + int border = 0.1 * (rect.width() + rect.height()); + border = qMin(qMax(2, border), 10); + rect.adjust(border, border, -border, -border); + if (checked) { + painter->setPen(Qt::NoPen); + painter->setBrush(color); + painter->drawEllipse(rect); + } +} + +QPixmap Maemo5WebStyle::findRadio(const QSize& size, bool checked, bool disabled) const +{ + QPixmap result; + static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-radio-"; + QString key = prefix + QString::number(size.width()) + "-" + QString::number(size.height()) + + + "-" + (disabled ? "disabled" : "enabled") + (checked ? "-checked" : ""); + if (!QPixmapCache::find(key, result)) { + result = QPixmap(size); + result.fill(Qt::transparent); + QPainter painter(&result); + drawRadio(&painter, size, checked, disabled ? Qt::gray : Qt::black); + QPixmapCache::insert(key, result); + } + return result; +} + +void Maemo5WebStyle::drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const +{ + switch (element) { + case CE_CheckBox: { + QRect rect = option->rect; + const bool disabled = !(option->state & State_Enabled); + drawRectangularControlBackground(painter, QPen(disabled ? Qt::gray : Qt::black), rect, option->palette.base()); + rect.adjust(1, 1, -1, -1); + + if (option->state & State_Off) + break; + + QPixmap checker = findChecker(rect, disabled); + if (checker.isNull()) + break; + + int x = (rect.width() - checker.width()) >> 1; + int y = (rect.height() - checker.height()) >> 1; + painter->drawPixmap(rect.x() + x, rect.y() + y, checker); + break; + } + case CE_RadioButton: { + const bool disabled = !(option->state & State_Enabled); + QPixmap radio = findRadio(option->rect.size(), option->state & State_On, disabled); + if (radio.isNull()) + break; + painter->drawPixmap(option->rect.x(), option->rect.y(), radio); + break; + } + default: + QWindowsStyle::drawControl(element, option, painter, widget); + } +} + +void Maemo5WebStyle::drawMultipleComboButton(QPainter* painter, const QSize& size, QColor color) const +{ + int rectWidth = size.width() - 1; + int width = qMax(2, rectWidth >> 3); + int distance = (rectWidth - 3 * width) >> 1; + int top = (size.height() - width) >> 1; + + painter->setPen(color); + painter->setBrush(color); + + painter->drawRect(0, top, width, width); + painter->drawRect(width + distance, top, width, width); + painter->drawRect(2 * (width + distance), top, width, width); +} + +void Maemo5WebStyle::drawSimpleComboButton(QPainter* painter, const QSize& size, QColor color) const +{ + QPolygon polygon; + int width = size.width(); + polygon.setPoints(3, 0, 0, width - 1, 0, width >> 1, size.height()); + painter->setPen(color); + painter->setBrush(color); + painter->drawPolygon(polygon); +} + +QSize Maemo5WebStyle::getButtonImageSize(const QSize& buttonSize) const +{ + const int border = qMax(3, buttonSize.width() >> 3) << 1; + + int width = buttonSize.width() - border; + int height = buttonSize.height() - border; + + if (width < 0 || height < 0) + return QSize(); + + if (height >= (width >> 1)) + width = width >> 1 << 1; + else + width = height << 1; + + return QSize(width + 1, width >> 1); +} + +QPixmap Maemo5WebStyle::findComboButton(const QSize& size, bool multiple, bool disabled) const +{ + QPixmap result; + QSize imageSize = getButtonImageSize(size); + + if (imageSize.isNull()) + return QPixmap(); + static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-combo-"; + QString key = prefix + (multiple ? "multiple-" : "simple-") + + QString::number(imageSize.width()) + "-" + QString::number(imageSize.height()) + + + "-" + (disabled ? "disabled" : "enabled"); + if (!QPixmapCache::find(key, result)) { + result = QPixmap(imageSize); + result.fill(Qt::transparent); + QPainter painter(&result); + if (multiple) + drawMultipleComboButton(&painter, imageSize, disabled ? Qt::gray : Qt::black); + else + drawSimpleComboButton(&painter, imageSize, disabled ? Qt::gray : Qt::black); + QPixmapCache::insert(key, result); + } + return result; +} + +void Maemo5WebStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const +{ + switch (control) { + case CC_ComboBox: { + + bool multiple = false; + const bool disabled = !(option->state & State_Enabled); + + const QStyleOptionComboBox* cmb = 0; + const WebCore::QtStyleOptionWebComboBox* webCombo = static_cast<const WebCore::QtStyleOptionWebComboBox*>(option); + + if (webCombo) { + multiple = webCombo->multiple(); + cmb = webCombo; + } else + cmb = qstyleoption_cast<const QStyleOptionComboBox*>(option); + + if (!cmb) { + QWindowsStyle::drawComplexControl(control, option, painter, widget); + break; + } + + if (!(cmb->subControls & SC_ComboBoxArrow)) + break; + + QRect rect = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget); + QPixmap pic = findComboButton(rect.size(), multiple, disabled); + + if (pic.isNull()) + break; + + int x = (rect.width() - pic.width()) >> 1; + int y = (rect.height() - pic.height()) >> 1; + painter->drawPixmap(rect.x() + x, rect.y() + y, pic); + + painter->setPen(disabled ? Qt::gray : Qt::darkGray); + painter->drawLine(rect.left() - 2, rect.top() + 2, rect.left() - 2, rect.bottom() - 2); + + break; + } + default: + QWindowsStyle::drawComplexControl(control, option, painter, widget); + } +} diff --git a/WebCore/platform/qt/Maemo5Webstyle.h b/WebCore/platform/qt/Maemo5Webstyle.h new file mode 100644 index 0000000..ce717b6 --- /dev/null +++ b/WebCore/platform/qt/Maemo5Webstyle.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * 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 Maemo5Webstyle_h +#define Maemo5Webstyle_h + +#include <QWindowsStyle> + +class Maemo5WebStyle : public QWindowsStyle { +public: + Maemo5WebStyle(); + + void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = 0) const; + void drawComplexControl(ComplexControl cc, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget = 0) const; + +private: + void drawChecker(QPainter* painter, int size, QColor color) const; + QPixmap findChecker(const QRect& rect, bool disabled) const; + + void drawRadio(QPainter* painter, const QSize& size, bool checked, QColor color) const; + QPixmap findRadio(const QSize& size, bool checked, bool disabled) const; + + QSize getButtonImageSize(const QSize& buttonSize) const; + void drawSimpleComboButton(QPainter* painter, const QSize& size, QColor color) const; + void drawMultipleComboButton(QPainter* painter, const QSize& size, QColor color) const; + QPixmap findComboButton(const QSize& size, bool multiple, bool disabled) const; + +}; + +#endif // Maemo5WebStyle_h diff --git a/WebCore/platform/qt/PasteboardQt.cpp b/WebCore/platform/qt/PasteboardQt.cpp index 44c9eec..e1e6d84 100644 --- a/WebCore/platform/qt/PasteboardQt.cpp +++ b/WebCore/platform/qt/PasteboardQt.cpp @@ -58,7 +58,7 @@ Pasteboard* Pasteboard::generalPasteboard() return pasteboard; } -void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame) +void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) { QMimeData* md = new QMimeData; QString text = frame->selectedText(); @@ -66,7 +66,7 @@ void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame) md->setText(text); QString html = QLatin1String("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><body>"); - html += createMarkup(selectedRange, 0, AnnotateForInterchange); + html += createMarkup(selectedRange, 0, AnnotateForInterchange, false, AbsoluteURLs); html += QLatin1String("</body></html>"); md->setHtml(html); @@ -74,10 +74,14 @@ void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame) QApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard); #endif + if (canSmartCopyOrDelete) + md->setData("application/vnd.qtwebkit.smartpaste", QByteArray()); } bool Pasteboard::canSmartReplace() { + if (QApplication::clipboard()->mimeData()->hasFormat((QLatin1String("application/vnd.qtwebkit.smartpaste")))) + return true; return false; } @@ -151,14 +155,15 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&) #ifndef QT_NO_CLIPBOARD CachedImage* cachedImage = toRenderImage(node->renderer())->cachedImage(); - ASSERT(cachedImage); + if (!cachedImage || cachedImage->errorOccurred()) + return; Image* image = cachedImage->image(); ASSERT(image); QPixmap* pixmap = image->nativeImageForCurrentFrame(); - ASSERT(pixmap); - + if (!pixmap) + return; QApplication::clipboard()->setPixmap(*pixmap, QClipboard::Clipboard); #endif } diff --git a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp index 12200f4..6dde9c4 100644 --- a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp +++ b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp @@ -28,149 +28,150 @@ #include "config.h" #include "PlatformKeyboardEvent.h" -#include "KeyboardCodes.h" #include "NotImplemented.h" - -#include <ctype.h> +#include "WindowsKeyboardCodes.h" #include <QKeyEvent> +#include <ctype.h> namespace WebCore { -static String keyIdentifierForQtKeyCode(int keyCode) +String keyIdentifierForQtKeyCode(int keyCode) { switch (keyCode) { - case Qt::Key_Menu: - case Qt::Key_Alt: - return "Alt"; - case Qt::Key_Clear: - return "Clear"; - case Qt::Key_Down: - return "Down"; - case Qt::Key_End: - return "End"; - case Qt::Key_Return: - case Qt::Key_Enter: - return "Enter"; - case Qt::Key_Execute: - return "Execute"; - case Qt::Key_F1: - return "F1"; - case Qt::Key_F2: - return "F2"; - case Qt::Key_F3: - return "F3"; - case Qt::Key_F4: - return "F4"; - case Qt::Key_F5: - return "F5"; - case Qt::Key_F6: - return "F6"; - case Qt::Key_F7: - return "F7"; - case Qt::Key_F8: - return "F8"; - case Qt::Key_F9: - return "F9"; - case Qt::Key_F10: - return "F10"; - case Qt::Key_F11: - return "F11"; - case Qt::Key_F12: - return "F12"; - case Qt::Key_F13: - return "F13"; - case Qt::Key_F14: - return "F14"; - case Qt::Key_F15: - return "F15"; - case Qt::Key_F16: - return "F16"; - case Qt::Key_F17: - return "F17"; - case Qt::Key_F18: - return "F18"; - case Qt::Key_F19: - return "F19"; - case Qt::Key_F20: - return "F20"; - case Qt::Key_F21: - return "F21"; - case Qt::Key_F22: - return "F22"; - case Qt::Key_F23: - return "F23"; - case Qt::Key_F24: - return "F24"; - case Qt::Key_Help: - return "Help"; - case Qt::Key_Home: - return "Home"; - case Qt::Key_Insert: - return "Insert"; - case Qt::Key_Left: - return "Left"; - case Qt::Key_PageDown: - return "PageDown"; - case Qt::Key_PageUp: - return "PageUp"; - case Qt::Key_Pause: - return "Pause"; - case Qt::Key_Print: - return "PrintScreen"; - case Qt::Key_Right: - return "Right"; - case Qt::Key_Select: - return "Select"; - case Qt::Key_Up: - return "Up"; - // Standard says that DEL becomes U+007F. - case Qt::Key_Delete: - return "U+007F"; - case Qt::Key_Tab: - return "U+0009"; - case Qt::Key_Backtab: - return "U+0009"; - default: - return String::format("U+%04X", toupper(keyCode)); + case Qt::Key_Menu: + case Qt::Key_Alt: + return "Alt"; + case Qt::Key_Clear: + return "Clear"; + case Qt::Key_Down: + return "Down"; + case Qt::Key_End: + return "End"; + case Qt::Key_Return: + case Qt::Key_Enter: + return "Enter"; + case Qt::Key_Execute: + return "Execute"; + case Qt::Key_F1: + return "F1"; + case Qt::Key_F2: + return "F2"; + case Qt::Key_F3: + return "F3"; + case Qt::Key_F4: + return "F4"; + case Qt::Key_F5: + return "F5"; + case Qt::Key_F6: + return "F6"; + case Qt::Key_F7: + return "F7"; + case Qt::Key_F8: + return "F8"; + case Qt::Key_F9: + return "F9"; + case Qt::Key_F10: + return "F10"; + case Qt::Key_F11: + return "F11"; + case Qt::Key_F12: + return "F12"; + case Qt::Key_F13: + return "F13"; + case Qt::Key_F14: + return "F14"; + case Qt::Key_F15: + return "F15"; + case Qt::Key_F16: + return "F16"; + case Qt::Key_F17: + return "F17"; + case Qt::Key_F18: + return "F18"; + case Qt::Key_F19: + return "F19"; + case Qt::Key_F20: + return "F20"; + case Qt::Key_F21: + return "F21"; + case Qt::Key_F22: + return "F22"; + case Qt::Key_F23: + return "F23"; + case Qt::Key_F24: + return "F24"; + case Qt::Key_Help: + return "Help"; + case Qt::Key_Home: + return "Home"; + case Qt::Key_Insert: + return "Insert"; + case Qt::Key_Left: + return "Left"; + case Qt::Key_PageDown: + return "PageDown"; + case Qt::Key_PageUp: + return "PageUp"; + case Qt::Key_Pause: + return "Pause"; + case Qt::Key_Print: + return "PrintScreen"; + case Qt::Key_Right: + return "Right"; + case Qt::Key_Select: + return "Select"; + case Qt::Key_Up: + return "Up"; + // Standard says that DEL becomes U+007F. + case Qt::Key_Delete: + return "U+007F"; + case Qt::Key_Backspace: + return "U+0008"; + case Qt::Key_Tab: + return "U+0009"; + case Qt::Key_Backtab: + return "U+0009"; + default: + return String::format("U+%04X", toupper(keyCode)); } } -static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad = false) +int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) { // Determine wheter the event comes from the keypad if (isKeypad) { switch (keycode) { case Qt::Key_0: - return VK_NUMPAD0; // (60) Numeric keypad 0 key + return VK_NUMPAD0; // (60) Numeric keypad 0 key case Qt::Key_1: - return VK_NUMPAD1; // (61) Numeric keypad 1 key + return VK_NUMPAD1; // (61) Numeric keypad 1 key case Qt::Key_2: return VK_NUMPAD2; // (62) Numeric keypad 2 key case Qt::Key_3: - return VK_NUMPAD3; // (63) Numeric keypad 3 key + return VK_NUMPAD3; // (63) Numeric keypad 3 key case Qt::Key_4: - return VK_NUMPAD4; // (64) Numeric keypad 4 key + return VK_NUMPAD4; // (64) Numeric keypad 4 key case Qt::Key_5: - return VK_NUMPAD5; // (65) Numeric keypad 5 key + return VK_NUMPAD5; // (65) Numeric keypad 5 key case Qt::Key_6: - return VK_NUMPAD6; // (66) Numeric keypad 6 key + return VK_NUMPAD6; // (66) Numeric keypad 6 key case Qt::Key_7: - return VK_NUMPAD7; // (67) Numeric keypad 7 key + return VK_NUMPAD7; // (67) Numeric keypad 7 key case Qt::Key_8: - return VK_NUMPAD8; // (68) Numeric keypad 8 key + return VK_NUMPAD8; // (68) Numeric keypad 8 key case Qt::Key_9: - return VK_NUMPAD9; // (69) Numeric keypad 9 key + return VK_NUMPAD9; // (69) Numeric keypad 9 key case Qt::Key_Asterisk: return VK_MULTIPLY; // (6A) Multiply key case Qt::Key_Plus: - return VK_ADD; // (6B) Add key + return VK_ADD; // (6B) Add key case Qt::Key_Minus: return VK_SUBTRACT; // (6D) Subtract key case Qt::Key_Period: - return VK_DECIMAL; // (6E) Decimal key + return VK_DECIMAL; // (6E) Decimal key case Qt::Key_Slash: - return VK_DIVIDE; // (6F) Divide key + return VK_DIVIDE; // (6F) Divide key case Qt::Key_PageUp: return VK_PRIOR; // (21) PAGE UP key case Qt::Key_PageDown: @@ -194,311 +195,310 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad = false } else switch (keycode) { - case Qt::Key_Backspace: - return VK_BACK; // (08) BACKSPACE key - case Qt::Key_Backtab: - case Qt::Key_Tab: - return VK_TAB; // (09) TAB key - case Qt::Key_Clear: - return VK_CLEAR; // (0C) CLEAR key - case Qt::Key_Enter: - case Qt::Key_Return: - return VK_RETURN; //(0D) Return key - case Qt::Key_Shift: - return VK_SHIFT; // (10) SHIFT key - case Qt::Key_Control: - return VK_CONTROL; // (11) CTRL key - case Qt::Key_Menu: - case Qt::Key_Alt: - return VK_MENU; // (12) ALT key + case Qt::Key_Backspace: + return VK_BACK; // (08) BACKSPACE key + case Qt::Key_Backtab: + case Qt::Key_Tab: + return VK_TAB; // (09) TAB key + case Qt::Key_Clear: + return VK_CLEAR; // (0C) CLEAR key + case Qt::Key_Enter: + case Qt::Key_Return: + return VK_RETURN; // (0D) Return key + case Qt::Key_Shift: + return VK_SHIFT; // (10) SHIFT key + case Qt::Key_Control: + return VK_CONTROL; // (11) CTRL key + case Qt::Key_Menu: + case Qt::Key_Alt: + return VK_MENU; // (12) ALT key - case Qt::Key_F1: - return VK_F1; - case Qt::Key_F2: - return VK_F2; - case Qt::Key_F3: - return VK_F3; - case Qt::Key_F4: - return VK_F4; - case Qt::Key_F5: - return VK_F5; - case Qt::Key_F6: - return VK_F6; - case Qt::Key_F7: - return VK_F7; - case Qt::Key_F8: - return VK_F8; - case Qt::Key_F9: - return VK_F9; - case Qt::Key_F10: - return VK_F10; - case Qt::Key_F11: - return VK_F11; - case Qt::Key_F12: - return VK_F12; - case Qt::Key_F13: - return VK_F13; - case Qt::Key_F14: - return VK_F14; - case Qt::Key_F15: - return VK_F15; - case Qt::Key_F16: - return VK_F16; - case Qt::Key_F17: - return VK_F17; - case Qt::Key_F18: - return VK_F18; - case Qt::Key_F19: - return VK_F19; - case Qt::Key_F20: - return VK_F20; - case Qt::Key_F21: - return VK_F21; - case Qt::Key_F22: - return VK_F22; - case Qt::Key_F23: - return VK_F23; - case Qt::Key_F24: - return VK_F24; + case Qt::Key_F1: + return VK_F1; + case Qt::Key_F2: + return VK_F2; + case Qt::Key_F3: + return VK_F3; + case Qt::Key_F4: + return VK_F4; + case Qt::Key_F5: + return VK_F5; + case Qt::Key_F6: + return VK_F6; + case Qt::Key_F7: + return VK_F7; + case Qt::Key_F8: + return VK_F8; + case Qt::Key_F9: + return VK_F9; + case Qt::Key_F10: + return VK_F10; + case Qt::Key_F11: + return VK_F11; + case Qt::Key_F12: + return VK_F12; + case Qt::Key_F13: + return VK_F13; + case Qt::Key_F14: + return VK_F14; + case Qt::Key_F15: + return VK_F15; + case Qt::Key_F16: + return VK_F16; + case Qt::Key_F17: + return VK_F17; + case Qt::Key_F18: + return VK_F18; + case Qt::Key_F19: + return VK_F19; + case Qt::Key_F20: + return VK_F20; + case Qt::Key_F21: + return VK_F21; + case Qt::Key_F22: + return VK_F22; + case Qt::Key_F23: + return VK_F23; + case Qt::Key_F24: + return VK_F24; - case Qt::Key_Pause: - return VK_PAUSE; // (13) PAUSE key - case Qt::Key_CapsLock: - return VK_CAPITAL; // (14) CAPS LOCK key - case Qt::Key_Kana_Lock: - case Qt::Key_Kana_Shift: - return VK_KANA; // (15) Input Method Editor (IME) Kana mode - case Qt::Key_Hangul: - return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode - // VK_JUNJA (17) IME Junja mode - // VK_FINAL (18) IME final mode - case Qt::Key_Hangul_Hanja: - return VK_HANJA; // (19) IME Hanja mode - case Qt::Key_Kanji: - return VK_KANJI; // (19) IME Kanji mode - case Qt::Key_Escape: - return VK_ESCAPE; // (1B) ESC key - // VK_CONVERT (1C) IME convert - // VK_NONCONVERT (1D) IME nonconvert - // VK_ACCEPT (1E) IME accept - // VK_MODECHANGE (1F) IME mode change request - case Qt::Key_Space: - return VK_SPACE; // (20) SPACEBAR - case Qt::Key_PageUp: - return VK_PRIOR; // (21) PAGE UP key - case Qt::Key_PageDown: - return VK_NEXT; // (22) PAGE DOWN key - case Qt::Key_End: - return VK_END; // (23) END key - case Qt::Key_Home: - return VK_HOME; // (24) HOME key - case Qt::Key_Left: - return VK_LEFT; // (25) LEFT ARROW key - case Qt::Key_Up: - return VK_UP; // (26) UP ARROW key - case Qt::Key_Right: - return VK_RIGHT; // (27) RIGHT ARROW key - case Qt::Key_Down: - return VK_DOWN; // (28) DOWN ARROW key - case Qt::Key_Select: - return VK_SELECT; // (29) SELECT key - case Qt::Key_Print: - return VK_PRINT; // (2A) PRINT key - case Qt::Key_Execute: - return VK_EXECUTE;// (2B) EXECUTE key - //dunno on this - //case Qt::Key_PrintScreen: - // return VK_SNAPSHOT; // (2C) PRINT SCREEN key - case Qt::Key_Insert: - return VK_INSERT; // (2D) INS key - case Qt::Key_Delete: - return VK_DELETE; // (2E) DEL key - case Qt::Key_Help: - return VK_HELP; // (2F) HELP key - case Qt::Key_0: - case Qt::Key_ParenLeft: - return VK_0; // (30) 0) key - case Qt::Key_1: - return VK_1; // (31) 1 ! key - case Qt::Key_2: - case Qt::Key_At: - return VK_2; // (32) 2 & key - case Qt::Key_3: - case Qt::Key_NumberSign: - return VK_3; //case '3': case '#'; - case Qt::Key_4: - case Qt::Key_Dollar: // (34) 4 key '$'; - return VK_4; - case Qt::Key_5: - case Qt::Key_Percent: - return VK_5; // (35) 5 key '%' - case Qt::Key_6: - case Qt::Key_AsciiCircum: - return VK_6; // (36) 6 key '^' - case Qt::Key_7: - case Qt::Key_Ampersand: - return VK_7; // (37) 7 key case '&' - case Qt::Key_8: - case Qt::Key_Asterisk: - return VK_8; // (38) 8 key '*' - case Qt::Key_9: - case Qt::Key_ParenRight: - return VK_9; // (39) 9 key '(' - case Qt::Key_A: - return VK_A; // (41) A key case 'a': case 'A': return 0x41; - case Qt::Key_B: - return VK_B; // (42) B key case 'b': case 'B': return 0x42; - case Qt::Key_C: - return VK_C; // (43) C key case 'c': case 'C': return 0x43; - case Qt::Key_D: - return VK_D; // (44) D key case 'd': case 'D': return 0x44; - case Qt::Key_E: - return VK_E; // (45) E key case 'e': case 'E': return 0x45; - case Qt::Key_F: - return VK_F; // (46) F key case 'f': case 'F': return 0x46; - case Qt::Key_G: - return VK_G; // (47) G key case 'g': case 'G': return 0x47; - case Qt::Key_H: - return VK_H; // (48) H key case 'h': case 'H': return 0x48; - case Qt::Key_I: - return VK_I; // (49) I key case 'i': case 'I': return 0x49; - case Qt::Key_J: - return VK_J; // (4A) J key case 'j': case 'J': return 0x4A; - case Qt::Key_K: - return VK_K; // (4B) K key case 'k': case 'K': return 0x4B; - case Qt::Key_L: - return VK_L; // (4C) L key case 'l': case 'L': return 0x4C; - case Qt::Key_M: - return VK_M; // (4D) M key case 'm': case 'M': return 0x4D; - case Qt::Key_N: - return VK_N; // (4E) N key case 'n': case 'N': return 0x4E; - case Qt::Key_O: - return VK_O; // (4F) O key case 'o': case 'O': return 0x4F; - case Qt::Key_P: - return VK_P; // (50) P key case 'p': case 'P': return 0x50; - case Qt::Key_Q: - return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51; - case Qt::Key_R: - return VK_R; // (52) R key case 'r': case 'R': return 0x52; - case Qt::Key_S: - return VK_S; // (53) S key case 's': case 'S': return 0x53; - case Qt::Key_T: - return VK_T; // (54) T key case 't': case 'T': return 0x54; - case Qt::Key_U: - return VK_U; // (55) U key case 'u': case 'U': return 0x55; - case Qt::Key_V: - return VK_V; // (56) V key case 'v': case 'V': return 0x56; - case Qt::Key_W: - return VK_W; // (57) W key case 'w': case 'W': return 0x57; - case Qt::Key_X: - return VK_X; // (58) X key case 'x': case 'X': return 0x58; - case Qt::Key_Y: - return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59; - case Qt::Key_Z: - return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A; - case Qt::Key_Meta: - return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard) - //case Qt::Key_Meta_R: FIXME: What to do here? + case Qt::Key_Pause: + return VK_PAUSE; // (13) PAUSE key + case Qt::Key_CapsLock: + return VK_CAPITAL; // (14) CAPS LOCK key + case Qt::Key_Kana_Lock: + case Qt::Key_Kana_Shift: + return VK_KANA; // (15) Input Method Editor (IME) Kana mode + case Qt::Key_Hangul: + return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode + // VK_JUNJA (17) IME Junja mode + // VK_FINAL (18) IME final mode + case Qt::Key_Hangul_Hanja: + return VK_HANJA; // (19) IME Hanja mode + case Qt::Key_Kanji: + return VK_KANJI; // (19) IME Kanji mode + case Qt::Key_Escape: + return VK_ESCAPE; // (1B) ESC key + // VK_CONVERT (1C) IME convert + // VK_NONCONVERT (1D) IME nonconvert + // VK_ACCEPT (1E) IME accept + // VK_MODECHANGE (1F) IME mode change request + case Qt::Key_Space: + return VK_SPACE; // (20) SPACEBAR + case Qt::Key_PageUp: + return VK_PRIOR; // (21) PAGE UP key + case Qt::Key_PageDown: + return VK_NEXT; // (22) PAGE DOWN key + case Qt::Key_End: + return VK_END; // (23) END key + case Qt::Key_Home: + return VK_HOME; // (24) HOME key + case Qt::Key_Left: + return VK_LEFT; // (25) LEFT ARROW key + case Qt::Key_Up: + return VK_UP; // (26) UP ARROW key + case Qt::Key_Right: + return VK_RIGHT; // (27) RIGHT ARROW key + case Qt::Key_Down: + return VK_DOWN; // (28) DOWN ARROW key + case Qt::Key_Select: + return VK_SELECT; // (29) SELECT key + case Qt::Key_Print: + return VK_PRINT; // (2A) PRINT key + case Qt::Key_Execute: + return VK_EXECUTE; // (2B) EXECUTE key + // dunno on this + // case Qt::Key_PrintScreen: + // return VK_SNAPSHOT; // (2C) PRINT SCREEN key + case Qt::Key_Insert: + return VK_INSERT; // (2D) INS key + case Qt::Key_Delete: + return VK_DELETE; // (2E) DEL key + case Qt::Key_Help: + return VK_HELP; // (2F) HELP key + case Qt::Key_0: + case Qt::Key_ParenLeft: + return VK_0; // (30) 0) key + case Qt::Key_1: + return VK_1; // (31) 1 ! key + case Qt::Key_2: + case Qt::Key_At: + return VK_2; // (32) 2 & key + case Qt::Key_3: + case Qt::Key_NumberSign: + return VK_3; // case '3': case '#'; + case Qt::Key_4: + case Qt::Key_Dollar: // (34) 4 key '$'; + return VK_4; + case Qt::Key_5: + case Qt::Key_Percent: + return VK_5; // (35) 5 key '%' + case Qt::Key_6: + case Qt::Key_AsciiCircum: + return VK_6; // (36) 6 key '^' + case Qt::Key_7: + case Qt::Key_Ampersand: + return VK_7; // (37) 7 key case '&' + case Qt::Key_8: + case Qt::Key_Asterisk: + return VK_8; // (38) 8 key '*' + case Qt::Key_9: + case Qt::Key_ParenRight: + return VK_9; // (39) 9 key '(' + case Qt::Key_A: + return VK_A; // (41) A key case 'a': case 'A': return 0x41; + case Qt::Key_B: + return VK_B; // (42) B key case 'b': case 'B': return 0x42; + case Qt::Key_C: + return VK_C; // (43) C key case 'c': case 'C': return 0x43; + case Qt::Key_D: + return VK_D; // (44) D key case 'd': case 'D': return 0x44; + case Qt::Key_E: + return VK_E; // (45) E key case 'e': case 'E': return 0x45; + case Qt::Key_F: + return VK_F; // (46) F key case 'f': case 'F': return 0x46; + case Qt::Key_G: + return VK_G; // (47) G key case 'g': case 'G': return 0x47; + case Qt::Key_H: + return VK_H; // (48) H key case 'h': case 'H': return 0x48; + case Qt::Key_I: + return VK_I; // (49) I key case 'i': case 'I': return 0x49; + case Qt::Key_J: + return VK_J; // (4A) J key case 'j': case 'J': return 0x4A; + case Qt::Key_K: + return VK_K; // (4B) K key case 'k': case 'K': return 0x4B; + case Qt::Key_L: + return VK_L; // (4C) L key case 'l': case 'L': return 0x4C; + case Qt::Key_M: + return VK_M; // (4D) M key case 'm': case 'M': return 0x4D; + case Qt::Key_N: + return VK_N; // (4E) N key case 'n': case 'N': return 0x4E; + case Qt::Key_O: + return VK_O; // (4F) O key case 'o': case 'O': return 0x4F; + case Qt::Key_P: + return VK_P; // (50) P key case 'p': case 'P': return 0x50; + case Qt::Key_Q: + return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51; + case Qt::Key_R: + return VK_R; // (52) R key case 'r': case 'R': return 0x52; + case Qt::Key_S: + return VK_S; // (53) S key case 's': case 'S': return 0x53; + case Qt::Key_T: + return VK_T; // (54) T key case 't': case 'T': return 0x54; + case Qt::Key_U: + return VK_U; // (55) U key case 'u': case 'U': return 0x55; + case Qt::Key_V: + return VK_V; // (56) V key case 'v': case 'V': return 0x56; + case Qt::Key_W: + return VK_W; // (57) W key case 'w': case 'W': return 0x57; + case Qt::Key_X: + return VK_X; // (58) X key case 'x': case 'X': return 0x58; + case Qt::Key_Y: + return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59; + case Qt::Key_Z: + return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A; + case Qt::Key_Meta: + return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard) + // case Qt::Key_Meta_R: FIXME: What to do here? // return VK_RWIN; // (5C) Right Windows key (Natural keyboard) - // VK_APPS (5D) Applications key (Natural keyboard) - // VK_SLEEP (5F) Computer Sleep key - // VK_SEPARATOR (6C) Separator key - // VK_SUBTRACT (6D) Subtract key - // VK_DECIMAL (6E) Decimal key - // VK_DIVIDE (6F) Divide key - // handled by key code above + // VK_APPS (5D) Applications key (Natural keyboard) + // VK_SLEEP (5F) Computer Sleep key + // VK_SEPARATOR (6C) Separator key + // VK_SUBTRACT (6D) Subtract key + // VK_DECIMAL (6E) Decimal key + // VK_DIVIDE (6F) Divide key + // handled by key code above - case Qt::Key_NumLock: - return VK_NUMLOCK; // (90) NUM LOCK key + case Qt::Key_NumLock: + return VK_NUMLOCK; // (90) NUM LOCK key - case Qt::Key_ScrollLock: - return VK_SCROLL; // (91) SCROLL LOCK key + case Qt::Key_ScrollLock: + return VK_SCROLL; // (91) SCROLL LOCK key - // VK_LSHIFT (A0) Left SHIFT key - // VK_RSHIFT (A1) Right SHIFT key - // VK_LCONTROL (A2) Left CONTROL key - // VK_RCONTROL (A3) Right CONTROL key - // VK_LMENU (A4) Left MENU key - // VK_RMENU (A5) Right MENU key - // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key - // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key - // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key - // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key - // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key - // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key - // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key - // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key - // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key - // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key - // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key - // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key - // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key - // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key - // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key - // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key - // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key - // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key + // VK_LSHIFT (A0) Left SHIFT key + // VK_RSHIFT (A1) Right SHIFT key + // VK_LCONTROL (A2) Left CONTROL key + // VK_RCONTROL (A3) Right CONTROL key + // VK_LMENU (A4) Left MENU key + // VK_RMENU (A5) Right MENU key + // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key + // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key + // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key + // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key + // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key + // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key + // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key + // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key + // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key + // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key + // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key + // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key + // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key + // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key + // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key + // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key + // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key + // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key - // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key - case Qt::Key_Semicolon: - case Qt::Key_Colon: - return VK_OEM_1; //case ';': case ':': return 0xBA; - // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key - case Qt::Key_Plus: - case Qt::Key_Equal: - return VK_OEM_PLUS; //case '=': case '+': return 0xBB; - // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key - case Qt::Key_Comma: - case Qt::Key_Less: - return VK_OEM_COMMA; //case ',': case '<': return 0xBC; - // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key - case Qt::Key_Minus: - case Qt::Key_Underscore: - return VK_OEM_MINUS; //case '-': case '_': return 0xBD; - // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key - case Qt::Key_Period: - case Qt::Key_Greater: - return VK_OEM_PERIOD; //case '.': case '>': return 0xBE; - // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key - case Qt::Key_Slash: - case Qt::Key_Question: - return VK_OEM_2; //case '/': case '?': return 0xBF; - // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key - case Qt::Key_AsciiTilde: - case Qt::Key_QuoteLeft: - return VK_OEM_3; //case '`': case '~': return 0xC0; - // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key - case Qt::Key_BracketLeft: - case Qt::Key_BraceLeft: - return VK_OEM_4; //case '[': case '{': return 0xDB; - // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key - case Qt::Key_Backslash: - case Qt::Key_Bar: - return VK_OEM_5; //case '\\': case '|': return 0xDC; - // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key - case Qt::Key_BracketRight: - case Qt::Key_BraceRight: - return VK_OEM_6; // case ']': case '}': return 0xDD; - // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key - case Qt::Key_QuoteDbl: - return VK_OEM_7; // case '\'': case '"': return 0xDE; - // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard. - // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard - // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key - // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP - // VK_ATTN (F6) Attn key - // VK_CRSEL (F7) CrSel key - // VK_EXSEL (F8) ExSel key - // VK_EREOF (F9) Erase EOF key - // VK_PLAY (FA) Play key - // VK_ZOOM (FB) Zoom key - // VK_NONAME (FC) Reserved for future use - // VK_PA1 (FD) PA1 key - // VK_OEM_CLEAR (FE) Clear key - default: - return 0; + // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key + case Qt::Key_Semicolon: + case Qt::Key_Colon: + return VK_OEM_1; // case ';': case ':': return 0xBA; + // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key + case Qt::Key_Plus: + case Qt::Key_Equal: + return VK_OEM_PLUS; // case '=': case '+': return 0xBB; + // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key + case Qt::Key_Comma: + case Qt::Key_Less: + return VK_OEM_COMMA; // case ',': case '<': return 0xBC; + // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key + case Qt::Key_Minus: + case Qt::Key_Underscore: + return VK_OEM_MINUS; // case '-': case '_': return 0xBD; + // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key + case Qt::Key_Period: + case Qt::Key_Greater: + return VK_OEM_PERIOD; // case '.': case '>': return 0xBE; + // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key + case Qt::Key_Slash: + case Qt::Key_Question: + return VK_OEM_2; // case '/': case '?': return 0xBF; + // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key + case Qt::Key_AsciiTilde: + case Qt::Key_QuoteLeft: + return VK_OEM_3; // case '`': case '~': return 0xC0; + // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key + case Qt::Key_BracketLeft: + case Qt::Key_BraceLeft: + return VK_OEM_4; // case '[': case '{': return 0xDB; + // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key + case Qt::Key_Backslash: + case Qt::Key_Bar: + return VK_OEM_5; // case '\\': case '|': return 0xDC; + // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key + case Qt::Key_BracketRight: + case Qt::Key_BraceRight: + return VK_OEM_6; // case ']': case '}': return 0xDD; + // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key + case Qt::Key_QuoteDbl: + return VK_OEM_7; // case '\'': case '"': return 0xDE; + // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard. + // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard + // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key + // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP + // VK_ATTN (F6) Attn key + // VK_CRSEL (F7) CrSel key + // VK_EXSEL (F8) ExSel key + // VK_EREOF (F9) Erase EOF key + // VK_PLAY (FA) Play key + // VK_ZOOM (FB) Zoom key + // VK_NONAME (FC) Reserved for future use + // VK_PA1 (FD) PA1 key + // VK_OEM_CLEAR (FE) Clear key + default: + return 0; } - } PlatformKeyboardEvent::PlatformKeyboardEvent(QKeyEvent* event) @@ -509,13 +509,13 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(QKeyEvent* event) m_unmodifiedText = event->text(); // FIXME: not correct m_keyIdentifier = keyIdentifierForQtKeyCode(event->key()); m_autoRepeat = event->isAutoRepeat(); - m_ctrlKey = (state & Qt::ControlModifier) != 0; - m_altKey = (state & Qt::AltModifier) != 0; - m_metaKey = (state & Qt::MetaModifier) != 0; - m_isKeypad = (state & Qt::KeypadModifier) != 0; + m_ctrlKey = (state & Qt::ControlModifier); + m_altKey = (state & Qt::AltModifier); + m_metaKey = (state & Qt::MetaModifier); + m_isKeypad = (state & Qt::KeypadModifier); m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event->key(), m_isKeypad); m_nativeVirtualKeyCode = event->nativeVirtualKey(); - m_shiftKey = (state & Qt::ShiftModifier) != 0 || event->key() == Qt::Key_Backtab; // Simulate Shift+Tab with Key_Backtab + m_shiftKey = (state & Qt::ShiftModifier) || event->key() == Qt::Key_Backtab; // Simulate Shift+Tab with Key_Backtab m_qtEvent = event; } @@ -549,6 +549,15 @@ bool PlatformKeyboardEvent::currentCapsLockState() return false; } +void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey) +{ + notImplemented(); + shiftKey = false; + ctrlKey = false; + altKey = false; + metaKey = false; +} + } // vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/PlatformMouseEventQt.cpp b/WebCore/platform/qt/PlatformMouseEventQt.cpp index e486e68..a8956bf 100644 --- a/WebCore/platform/qt/PlatformMouseEventQt.cpp +++ b/WebCore/platform/qt/PlatformMouseEventQt.cpp @@ -28,10 +28,9 @@ #include "config.h" #include "PlatformMouseEvent.h" -#include <wtf/CurrentTime.h> - -#include <QMouseEvent> #include <QGraphicsSceneMouseEvent> +#include <QMouseEvent> +#include <wtf/CurrentTime.h> namespace WebCore { @@ -65,10 +64,10 @@ PlatformMouseEvent::PlatformMouseEvent(QGraphicsSceneMouseEvent* event, int clic m_button = NoButton; m_clickCount = clickCount; - m_shiftKey = (event->modifiers() & Qt::ShiftModifier) != 0; - m_ctrlKey = (event->modifiers() & Qt::ControlModifier) != 0; - m_altKey = (event->modifiers() & Qt::AltModifier) != 0; - m_metaKey = (event->modifiers() & Qt::MetaModifier) != 0; + m_shiftKey = (event->modifiers() & Qt::ShiftModifier); + m_ctrlKey = (event->modifiers() & Qt::ControlModifier); + m_altKey = (event->modifiers() & Qt::AltModifier); + m_metaKey = (event->modifiers() & Qt::MetaModifier); } PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount) @@ -94,7 +93,7 @@ PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount) #ifndef QT_NO_CONTEXTMENU case QEvent::ContextMenu: { m_eventType = MouseEventPressed; - QContextMenuEvent *ce = static_cast<QContextMenuEvent *>(event); + QContextMenuEvent* ce = static_cast<QContextMenuEvent*>(event); m_position = IntPoint(ce->pos()); m_globalPosition = IntPoint(ce->globalPos()); m_button = RightButton; @@ -120,10 +119,10 @@ PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount) } m_clickCount = clickCount; - m_shiftKey = (event->modifiers() & Qt::ShiftModifier) != 0; - m_ctrlKey = (event->modifiers() & Qt::ControlModifier) != 0; - m_altKey = (event->modifiers() & Qt::AltModifier) != 0; - m_metaKey = (event->modifiers() & Qt::MetaModifier) != 0; + m_shiftKey = (event->modifiers() & Qt::ShiftModifier); + m_ctrlKey = (event->modifiers() & Qt::ControlModifier); + m_altKey = (event->modifiers() & Qt::AltModifier); + m_metaKey = (event->modifiers() & Qt::MetaModifier); } } diff --git a/WebCore/platform/qt/QWebPageClient.h b/WebCore/platform/qt/QWebPageClient.h index 6d47c29..1f508bb 100644 --- a/WebCore/platform/qt/QWebPageClient.h +++ b/WebCore/platform/qt/QWebPageClient.h @@ -40,7 +40,9 @@ QT_END_NAMESPACE class QWebPageClient { public: virtual ~QWebPageClient() { } - + + virtual bool isQWidgetClient() const { return false; } + virtual void scroll(int dx, int dy, const QRect&) = 0; virtual void update(const QRect&) = 0; virtual void setInputMethodEnabled(bool enable) = 0; @@ -53,38 +55,45 @@ public: // if scheduleSync is true, we schedule a sync ourselves. otherwise, // we wait for the next update and sync the layers then. virtual void markForSync(bool scheduleSync = false) {} + virtual bool allowsAcceleratedCompositing() const { return false; } #endif #if QT_VERSION >= 0x040600 virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable) = 0; #endif + +#ifndef QT_NO_CURSOR inline void resetCursor() { -#ifndef QT_NO_CURSOR if (!cursor().bitmap() && cursor().shape() == m_lastCursor.shape()) return; updateCursor(m_lastCursor); -#endif } inline void setCursor(const QCursor& cursor) { -#ifndef QT_NO_CURSOR m_lastCursor = cursor; if (!cursor.bitmap() && cursor.shape() == this->cursor().shape()) return; updateCursor(cursor); -#endif } +#endif virtual QPalette palette() const = 0; virtual int screenNumber() const = 0; virtual QWidget* ownerWidget() const = 0; + virtual QRect geometryRelativeToOwnerWidget() const = 0; virtual QObject* pluginParent() const = 0; virtual QStyle* style() const = 0; + virtual QRectF graphicsItemVisibleRect() const { return QRectF(); } + + virtual bool viewResizesToContentsEnabled() const = 0; + + virtual QRectF windowRect() const = 0; + protected: #ifndef QT_NO_CURSOR virtual QCursor cursor() const = 0; diff --git a/WebCore/platform/qt/QtAbstractWebPopup.cpp b/WebCore/platform/qt/QtAbstractWebPopup.cpp index f64287d..31ab28d 100644 --- a/WebCore/platform/qt/QtAbstractWebPopup.cpp +++ b/WebCore/platform/qt/QtAbstractWebPopup.cpp @@ -48,6 +48,28 @@ void QtAbstractWebPopup::valueChanged(int index) m_popupClient->valueChanged(index); } +void QtAbstractWebPopup::selectItem(int index, bool allowMultiplySelections, bool shift) +{ +#if ENABLE(NO_LISTBOX_RENDERING) + ListPopupMenuClient* client = static_cast<ListPopupMenuClient*>(m_popupClient); + if (client) { + client->listBoxSelectItem(index, allowMultiplySelections, shift); + return; + } +#endif + valueChanged(index); +} + +bool QtAbstractWebPopup::multiple() +{ +#if ENABLE(NO_LISTBOX_RENDERING) + ListPopupMenuClient* client = static_cast<ListPopupMenuClient*>(m_popupClient); + return client && client->multiple(); +#else + return false; +#endif +} + QtAbstractWebPopup::ItemType QtAbstractWebPopup::itemType(int idx) const { if (m_popupClient->itemIsSeparator(idx)) diff --git a/WebCore/platform/qt/QtAbstractWebPopup.h b/WebCore/platform/qt/QtAbstractWebPopup.h index 93b4122..dad4997 100644 --- a/WebCore/platform/qt/QtAbstractWebPopup.h +++ b/WebCore/platform/qt/QtAbstractWebPopup.h @@ -40,6 +40,8 @@ public: QString itemToolTip(int idx) const { return m_popupClient->itemToolTip(idx); } bool itemIsEnabled(int idx) const { return m_popupClient->itemIsEnabled(idx); } int itemCount() const { return m_popupClient->listSize(); } + bool itemIsSelected(int idx) const { return m_popupClient->itemIsSelected(idx); } + QWebPageClient* pageClient() const { return m_pageClient; } QRect geometry() const { return m_geometry; } @@ -54,6 +56,10 @@ public: void popupDidHide(); void valueChanged(int index); + void selectItem(int index, bool allowMultiplySelections, bool shift); + bool multiple(); + + QFont font() { return m_popupClient->menuStyle().font().font(); } private: diff --git a/WebCore/platform/qt/QtStyleOptionWebComboBox.h b/WebCore/platform/qt/QtStyleOptionWebComboBox.h new file mode 100644 index 0000000..29c8220 --- /dev/null +++ b/WebCore/platform/qt/QtStyleOptionWebComboBox.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * 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 QtStyleOptionWebComboBox_h +#define QtStyleOptionWebComboBox_h + +#include "HTMLSelectElement.h" +#include "RenderObject.h" + +#include <QStyleOption> + +namespace WebCore { + +class RenderObject; + +class QtStyleOptionWebComboBox : public QStyleOptionComboBox { +public: + QtStyleOptionWebComboBox(RenderObject* o) + : QStyleOptionComboBox() + #if ENABLE(NO_LISTBOX_RENDERING) + , m_multiple(checkMultiple(o)) + #else + , m_multiple(false) + #endif + { + } + + bool multiple() const { return m_multiple; } + +private: + bool m_multiple; + + bool checkMultiple(RenderObject* o) + { + HTMLSelectElement* select = o ? static_cast<HTMLSelectElement*>(o->node()) : 0; + return select ? select->multiple() : false; + } +}; + +} + +#endif // QtStyleOptionWebComboBox_h diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp index 271c11a..22d99a1 100644 --- a/WebCore/platform/qt/RenderThemeQt.cpp +++ b/WebCore/platform/qt/RenderThemeQt.cpp @@ -39,17 +39,25 @@ #include "Font.h" #include "FontSelector.h" #include "GraphicsContext.h" +#include "HTMLInputElement.h" #include "HTMLMediaElement.h" #include "HTMLNames.h" +#if USE(QT_MOBILE_THEME) +#include "Maemo5Webstyle.h" +#endif #include "NotImplemented.h" #include "Page.h" #include "QWebPageClient.h" +#include "QtStyleOptionWebComboBox.h" #include "RenderBox.h" +#if ENABLE(PROGRESS_TAG) +#include "RenderProgress.h" +#endif #include "RenderSlider.h" #include "RenderTheme.h" #include "ScrollbarThemeQt.h" +#include "TimeRanges.h" #include "UserAgentStyleSheets.h" -#include "qwebpage.h" #include <QApplication> #include <QColor> @@ -61,6 +69,9 @@ #include <QStyleFactory> #include <QStyleOptionButton> #include <QStyleOptionFrameV2> +#if ENABLE(PROGRESS_TAG) +#include <QStyleOptionProgressBarV2> +#endif #include <QStyleOptionSlider> #include <QWidget> @@ -70,7 +81,7 @@ namespace WebCore { using namespace HTMLNames; -StylePainter::StylePainter(RenderThemeQt* theme, const RenderObject::PaintInfo& paintInfo) +StylePainter::StylePainter(RenderThemeQt* theme, const PaintInfo& paintInfo) { init(paintInfo.context ? paintInfo.context : 0, theme->qStyle()); } @@ -129,6 +140,7 @@ PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) RenderThemeQt::RenderThemeQt(Page* page) : RenderTheme() , m_page(page) + , m_lineEdit(0) { QPushButton button; button.setAttribute(Qt::WA_MacSmallSize); @@ -139,14 +151,45 @@ RenderThemeQt::RenderThemeQt(Page* page) m_buttonFontPixelSize = fontInfo.pixelSize(); #endif +#if USE(QT_MOBILE_THEME) + m_fallbackStyle = new Maemo5WebStyle; +#else m_fallbackStyle = QStyleFactory::create(QLatin1String("windows")); +#endif } RenderThemeQt::~RenderThemeQt() { delete m_fallbackStyle; +#ifndef QT_NO_LINEEDIT + delete m_lineEdit; +#endif } +#if USE(QT_MOBILE_THEME) +bool RenderThemeQt::isControlStyled(const RenderStyle* style, const BorderData& border, const FillLayer& fill, const Color& backgroundColor) const +{ + switch (style->appearance()) { + case PushButtonPart: + case ButtonPart: + case MenulistPart: + case TextFieldPart: + case TextAreaPart: + return true; + case CheckboxPart: + case RadioPart: + return false; + default: + return RenderTheme::isControlStyled(style, border, fill, backgroundColor); + } +} + +int RenderThemeQt::popupInternalPaddingBottom(RenderStyle* style) const +{ + return 1; +} +#endif + // for some widget painting, we need to fallback to Windows style QStyle* RenderThemeQt::fallbackStyle() const { @@ -155,7 +198,7 @@ QStyle* RenderThemeQt::fallbackStyle() const QStyle* RenderThemeQt::qStyle() const { -#ifdef Q_WS_MAEMO_5 +#if USE(QT_MOBILE_THEME) return fallbackStyle(); #endif @@ -169,6 +212,18 @@ QStyle* RenderThemeQt::qStyle() const return QApplication::style(); } +String RenderThemeQt::extraDefaultStyleSheet() +{ + String result = RenderTheme::extraDefaultStyleSheet(); +#if ENABLE(NO_LISTBOX_RENDERING) + result += String(themeQtNoListboxesUserAgentStyleSheet, sizeof(themeQtNoListboxesUserAgentStyleSheet)); +#endif +#if USE(QT_MOBILE_THEME) + result += String(themeQtMaemo5UserAgentStyleSheet, sizeof(themeQtMaemo5UserAgentStyleSheet)); +#endif + return result; +} + bool RenderThemeQt::supportsHover(const RenderStyle*) const { return true; @@ -207,11 +262,19 @@ bool RenderThemeQt::supportsControlTints() const return true; } -static int findFrameLineWidth(QStyle* style) +int RenderThemeQt::findFrameLineWidth(QStyle* style) const { - QLineEdit lineEdit; +#ifndef QT_NO_LINEEDIT + if (!m_lineEdit) + m_lineEdit = new QLineEdit(); +#endif + QStyleOptionFrameV2 opt; - return style->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, &lineEdit); + QWidget* widget = 0; +#ifndef QT_NO_LINEEDIT + widget = m_lineEdit; +#endif + return style->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, widget); } static QRect inflateButtonRect(const QRect& originalRect, QStyle* style) @@ -289,15 +352,30 @@ int RenderThemeQt::minimumMenuListSize(RenderStyle*) const void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const { - // If the width and height are both specified, then we have nothing to do. - if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto()) - return; - QSize size(0, 0); const QFontMetrics fm(renderStyle->font().font()); QStyle* style = qStyle(); switch (renderStyle->appearance()) { + case TextAreaPart: + case TextFieldPart: { + int padding = findFrameLineWidth(style); + + renderStyle->setPaddingLeft(Length(padding, Fixed)); + renderStyle->setPaddingRight(Length(padding, Fixed)); + renderStyle->setPaddingTop(Length(padding, Fixed)); + renderStyle->setPaddingBottom(Length(padding, Fixed)); + break; + } + default: + break; + } + + // If the width and height are both specified, then we have nothing to do. + if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto()) + return; + + switch (renderStyle->appearance()) { case CheckboxPart: { QStyleOption styleOption; styleOption.state |= QStyle::State_Small; @@ -341,23 +419,6 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const size.setHeight(menuListSize.height()); break; } - case TextFieldPart: { - const int verticalMargin = 1; - const int horizontalMargin = 2; - int h = qMax(fm.lineSpacing(), 14) + 2*verticalMargin; - int w = fm.width(QLatin1Char('x')) * 17 + 2*horizontalMargin; - QStyleOptionFrameV2 opt; - opt.lineWidth = findFrameLineWidth(style); - QSize sz = style->sizeFromContents(QStyle::CT_LineEdit, - &opt, - QSize(w, h).expandedTo(QApplication::globalStrut()), - 0); - size.setHeight(sz.height()); - - renderStyle->setPaddingLeft(Length(opt.lineWidth, Fixed)); - renderStyle->setPaddingRight(Length(opt.lineWidth, Fixed)); - break; - } default: break; } @@ -374,7 +435,7 @@ void RenderThemeQt::setCheckboxSize(RenderStyle* style) const computeSizeBasedOnStyle(style); } -bool RenderThemeQt::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeQt::paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r) { return paintButton(o, i, r); } @@ -384,7 +445,7 @@ void RenderThemeQt::setRadioSize(RenderStyle* style) const computeSizeBasedOnStyle(style); } -bool RenderThemeQt::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeQt::paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r) { return paintButton(o, i, r); } @@ -468,7 +529,7 @@ void RenderThemeQt::setButtonPadding(RenderStyle* style) const style->setPaddingBottom(Length(paddingBottom, Fixed)); } -bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeQt::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r) { StylePainter p(this, i); if (!p.isValid()) @@ -501,7 +562,7 @@ void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, computeSizeBasedOnStyle(style); } -bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeQt::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r) { StylePainter p(this, i); if (!p.isValid()) @@ -535,7 +596,7 @@ void RenderThemeQt::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* adjustTextFieldStyle(selector, style, element); } -bool RenderThemeQt::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeQt::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); } @@ -570,13 +631,13 @@ void RenderThemeQt::setPopupPadding(RenderStyle* style) const } -bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeQt::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) { StylePainter p(this, i); if (!p.isValid()) return true; - QStyleOptionComboBox opt; + QtStyleOptionWebComboBox opt(o); if (p.widget) opt.initFrom(p.widget); initializeCommonQStyleOptions(opt, o); @@ -593,9 +654,13 @@ bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo void RenderThemeQt::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { +#if USE(QT_MOBILE_THEME) + // Mobile theme uses border radius. +#else // WORKAROUND because html.css specifies -webkit-border-radius for <select> so we override it here // see also http://bugs.webkit.org/show_bug.cgi?id=18399 style->resetBorderRadius(); +#endif // Height is locked to auto. style->setHeight(Length(Auto)); @@ -609,14 +674,14 @@ void RenderThemeQt::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle* st setPopupPadding(style); } -bool RenderThemeQt::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, +bool RenderThemeQt::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r) { StylePainter p(this, i); if (!p.isValid()) return true; - QStyleOptionComboBox option; + QtStyleOptionWebComboBox option(o); if (p.widget) option.initFrom(p.widget); initializeCommonQStyleOptions(option, o); @@ -630,7 +695,79 @@ bool RenderThemeQt::paintMenuListButton(RenderObject* o, const RenderObject::Pai return false; } -bool RenderThemeQt::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& pi, +#if ENABLE(PROGRESS_TAG) +double RenderThemeQt::animationRepeatIntervalForProgressBar(RenderProgress* renderProgress) const +{ + if (renderProgress->position() >= 0) + return 0; + + // FIXME: Use hard-coded value until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed. + // Use the value from windows style which is 10 fps. + return 0.1; +} + +double RenderThemeQt::animationDurationForProgressBar(RenderProgress* renderProgress) const +{ + if (renderProgress->position() >= 0) + return 0; + + QStyleOptionProgressBarV2 option; + option.rect.setSize(renderProgress->size()); + // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed, + // we simulate one square animating across the progress bar. + return (option.rect.width() / qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option)) * animationRepeatIntervalForProgressBar(renderProgress); +} + +void RenderThemeQt::adjustProgressBarStyle(CSSStyleSelector*, RenderStyle* style, Element*) const +{ + style->setBoxShadow(0); +} + +bool RenderThemeQt::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r) +{ + if (!o->isProgress()) + return true; + + StylePainter p(this, pi); + if (!p.isValid()) + return true; + + QStyleOptionProgressBarV2 option; + if (p.widget) + option.initFrom(p.widget); + initializeCommonQStyleOptions(option, o); + + RenderProgress* renderProgress = toRenderProgress(o); + option.rect = r; + option.maximum = std::numeric_limits<int>::max(); + option.minimum = 0; + option.progress = (renderProgress->position() * std::numeric_limits<int>::max()); + + const QPoint topLeft = r.topLeft(); + p.painter->translate(topLeft); + option.rect.moveTo(QPoint(0, 0)); + option.rect.setSize(r.size()); + + if (option.progress < 0) { + // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed, + // we simulate one square animating across the progress bar. + p.drawControl(QStyle::CE_ProgressBarGroove, option); + int chunkWidth = qStyle()->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); + if (renderProgress->style()->direction() == RTL) + p.painter->fillRect(option.rect.right() - chunkWidth - renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); + else + p.painter->fillRect(renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); + } else + p.drawControl(QStyle::CE_ProgressBar, option); + + p.painter->translate(-topLeft); + + return false; +} +#endif + +bool RenderThemeQt::paintSliderTrack(RenderObject* o, const PaintInfo& pi, const IntRect& r) { StylePainter p(this, pi); @@ -684,7 +821,7 @@ void RenderThemeQt::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style style->setBoxShadow(0); } -bool RenderThemeQt::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& pi, +bool RenderThemeQt::paintSliderThumb(RenderObject* o, const PaintInfo& pi, const IntRect& r) { // We've already painted it in paintSliderTrack(), no need to do anything here. @@ -696,7 +833,7 @@ void RenderThemeQt::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle* style style->setBoxShadow(0); } -bool RenderThemeQt::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& pi, +bool RenderThemeQt::paintSearchField(RenderObject* o, const PaintInfo& pi, const IntRect& r) { return true; @@ -716,7 +853,7 @@ void RenderThemeQt::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selecto RenderTheme::adjustSearchFieldCancelButtonStyle(selector, style, e); } -bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& pi, +bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& pi, const IntRect& r) { notImplemented(); @@ -730,7 +867,7 @@ void RenderThemeQt::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderTheme::adjustSearchFieldDecorationStyle(selector, style, e); } -bool RenderThemeQt::paintSearchFieldDecoration(RenderObject* o, const RenderObject::PaintInfo& pi, +bool RenderThemeQt::paintSearchFieldDecoration(RenderObject* o, const PaintInfo& pi, const IntRect& r) { notImplemented(); @@ -744,7 +881,7 @@ void RenderThemeQt::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* se RenderTheme::adjustSearchFieldResultsDecorationStyle(selector, style, e); } -bool RenderThemeQt::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& pi, +bool RenderThemeQt::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& pi, const IntRect& r) { notImplemented(); @@ -772,7 +909,7 @@ bool RenderThemeQt::supportsFocus(ControlPart appearance) const void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const { -#ifdef Q_WS_MAEMO_5 +#if USE(QT_MOBILE_THEME) static QPalette lightGrayPalette(Qt::lightGray); palette = lightGrayPalette; return; @@ -834,7 +971,7 @@ ControlPart RenderThemeQt::initializeCommonQStyleOptions(QStyleOption& option, R case SearchFieldCancelButtonPart: { if (isPressed(o)) option.state |= QStyle::State_Sunken; - else if (result == PushButtonPart) + else if (result == PushButtonPart || result == ButtonPart) option.state |= QStyle::State_Raised; break; } @@ -882,10 +1019,15 @@ HTMLMediaElement* RenderThemeQt::getMediaElementFromRenderObject(RenderObject* o return static_cast<HTMLMediaElement*>(mediaNode); } +double RenderThemeQt::mediaControlsBaselineOpacity() const +{ + return 0.4; +} + void RenderThemeQt::paintMediaBackground(QPainter* painter, const IntRect& r) const { painter->setPen(Qt::NoPen); - static QColor transparentBlack(0, 0, 0, 100); + static QColor transparentBlack(0, 0, 0, mediaControlsBaselineOpacity() * 255); painter->setBrush(transparentBlack); painter->drawRoundedRect(r.x(), r.y(), r.width(), r.height(), 5.0, 5.0); } @@ -898,12 +1040,12 @@ QColor RenderThemeQt::getMediaControlForegroundColor(RenderObject* o) const return fgColor; } -bool RenderThemeQt::paintMediaFullscreenButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeQt::paintMediaFullscreenButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { return RenderTheme::paintMediaFullscreenButton(o, paintInfo, r); } -bool RenderThemeQt::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeQt::paintMediaMuteButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o); if (!mediaElement) @@ -921,18 +1063,13 @@ bool RenderThemeQt::paintMediaMuteButton(RenderObject* o, const RenderObject::Pa const QPointF speakerPolygon[6] = { QPointF(20, 30), QPointF(50, 30), QPointF(80, 0), QPointF(80, 100), QPointF(50, 70), QPointF(20, 70)}; - p.painter->setBrush(getMediaControlForegroundColor(o)); + p.painter->setBrush(mediaElement->muted() ? Qt::darkRed : getMediaControlForegroundColor(o)); p.painter->drawPolygon(speakerPolygon, 6); - if (mediaElement->muted()) { - p.painter->setPen(Qt::red); - p.painter->drawLine(0, 100, 100, 0); - } - return false; } -bool RenderThemeQt::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeQt::paintMediaPlayButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o); if (!mediaElement) @@ -959,24 +1096,42 @@ bool RenderThemeQt::paintMediaPlayButton(RenderObject* o, const RenderObject::Pa return false; } -bool RenderThemeQt::paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) +bool RenderThemeQt::paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&) { // We don't want to paint this at the moment. return false; } -bool RenderThemeQt::paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) +bool RenderThemeQt::paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&) { // We don't want to paint this at the moment. return false; } -bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeQt::paintMediaCurrentTime(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { - HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o); - if (!mediaElement) - return false; + StylePainter p(this, paintInfo); + if (!p.isValid()) + return true; + + p.painter->setRenderHint(QPainter::Antialiasing, true); + paintMediaBackground(p.painter, r); + + return false; +} + +String RenderThemeQt::formatMediaControlsCurrentTime(float currentTime, float duration) const +{ + return formatMediaControlsTime(currentTime) + " / " + formatMediaControlsTime(duration); +} +String RenderThemeQt::formatMediaControlsRemainingTime(float currentTime, float duration) const +{ + return String(); +} + +bool RenderThemeQt::paintMediaVolumeSliderTrack(RenderObject *o, const PaintInfo &paintInfo, const IntRect &r) +{ StylePainter p(this, paintInfo); if (!p.isValid()) return true; @@ -985,12 +1140,57 @@ bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const RenderObject::P paintMediaBackground(p.painter, r); + if (!o->isSlider()) + return false; + + IntRect b = toRenderBox(o)->contentBoxRect(); + + // Position the outer rectangle + int top = r.y() + b.y(); + int left = r.x() + b.x(); + int width = b.width(); + int height = b.height(); + + // Get the scale color from the page client + QPalette pal = QApplication::palette(); + setPaletteFromPageClientIfExists(pal); + const QColor highlightText = pal.brush(QPalette::Active, QPalette::HighlightedText).color(); + const QColor scaleColor(highlightText.red(), highlightText.green(), highlightText.blue(), mediaControlsBaselineOpacity() * 255); + + // Draw the outer rectangle + p.painter->setBrush(scaleColor); + p.painter->drawRect(left, top, width, height); + + if (!o->node() || !o->node()->hasTagName(inputTag)) + return false; + + HTMLInputElement* slider = static_cast<HTMLInputElement*>(o->node()); + + // Position the inner rectangle + height = height * slider->valueAsNumber(); + top += b.height() - height; + + // Draw the inner rectangle + p.painter->setPen(Qt::NoPen); + p.painter->setBrush(getMediaControlForegroundColor(o)); + p.painter->drawRect(left, top, width, height); + + return false; +} + +bool RenderThemeQt::paintMediaVolumeSliderThumb(RenderObject *o, const PaintInfo &paintInfo, const IntRect &r) +{ + StylePainter p(this, paintInfo); + if (!p.isValid()) + return true; + + // Nothing to draw here, this is all done in the track return false; } -bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { - HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o->parent()); + HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o); if (!mediaElement) return false; @@ -1000,6 +1200,39 @@ bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::P p.painter->setRenderHint(QPainter::Antialiasing, true); + paintMediaBackground(p.painter, r); + +#if QT_VERSION >= 0x040700 + if (MediaPlayer* player = mediaElement->player()) { + // Get the buffered parts of the media + PassRefPtr<TimeRanges> buffered = player->buffered(); + if (buffered->length() > 0 && player->duration() < std::numeric_limits<float>::infinity()) { + // Set the transform and brush + WorldMatrixTransformer transformer(p.painter, o, r); + p.painter->setBrush(getMediaControlForegroundColor()); + + // Paint each buffered section + ExceptionCode ex; + for (int i = 0; i < buffered->length(); i++) { + float startX = (buffered->start(i, ex) / player->duration()) * 100; + float width = ((buffered->end(i, ex) / player->duration()) * 100) - startX; + p.painter->drawRect(startX, 37, width, 26); + } + } + } +#endif + + return false; +} + +bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) +{ + StylePainter p(this, paintInfo); + if (!p.isValid()) + return true; + + p.painter->setRenderHint(QPainter::Antialiasing, true); + p.painter->setPen(Qt::NoPen); p.painter->setBrush(getMediaControlForegroundColor(o)); p.painter->drawRect(r.x(), r.y(), r.width(), r.height()); @@ -1019,6 +1252,13 @@ void RenderThemeQt::adjustSliderThumbSize(RenderObject* o) const int parentHeight = parentStyle->height().value(); o->style()->setWidth(Length(parentHeight / 3, Fixed)); o->style()->setHeight(Length(parentHeight, Fixed)); + } else if (part == MediaVolumeSliderThumbPart) { + RenderStyle* parentStyle = o->parent()->style(); + Q_ASSERT(parentStyle); + + int parentWidth = parentStyle->width().value(); + o->style()->setHeight(Length(parentWidth / 3, Fixed)); + o->style()->setWidth(Length(parentWidth, Fixed)); } else if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) { QStyleOptionSlider option; if (part == SliderThumbVerticalPart) diff --git a/WebCore/platform/qt/RenderThemeQt.h b/WebCore/platform/qt/RenderThemeQt.h index 5385881..7ab6769 100644 --- a/WebCore/platform/qt/RenderThemeQt.h +++ b/WebCore/platform/qt/RenderThemeQt.h @@ -27,12 +27,16 @@ #include <QStyle> QT_BEGIN_NAMESPACE +class QLineEdit; class QPainter; class QWidget; QT_END_NAMESPACE namespace WebCore { +#if ENABLE(PROGRESS_TAG) +class RenderProgress; +#endif class RenderStyle; class HTMLMediaElement; class ScrollbarThemeQt; @@ -45,6 +49,8 @@ private: public: static PassRefPtr<RenderTheme> create(Page*); + String extraDefaultStyleSheet(); + virtual bool supportsHover(const RenderStyle*) const; virtual bool supportsFocusRing(const RenderStyle* style) const; @@ -72,6 +78,11 @@ public: virtual double caretBlinkInterval() const; +#if USE(QT_MOBILE_THEME) + virtual bool isControlStyled(const RenderStyle*, const BorderData&, const FillLayer&, const Color& backgroundColor) const; + virtual int popupInternalPaddingBottom(RenderStyle*) const; +#endif + #if ENABLE(VIDEO) virtual String extraMediaControlsStyleSheet(); #endif @@ -79,58 +90,75 @@ public: QStyle* qStyle() const; protected: - virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r); virtual void setCheckboxSize(RenderStyle*) const; - virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r); virtual void setRadioSize(RenderStyle*) const; virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); virtual void setButtonSize(RenderStyle*) const; - virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual bool paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r); virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); +#if ENABLE(PROGRESS_TAG) + virtual void adjustProgressBarStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); +#endif + + virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&); -#if ENABLE(VIDEO) - virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); +#if ENABLE(PROGRESS_TAG) + // Returns the repeat interval of the animation for the progress bar. + virtual double animationRepeatIntervalForProgressBar(RenderProgress* renderProgress) const; + // Returns the duration of the animation for the progress bar. + virtual double animationDurationForProgressBar(RenderProgress* renderProgress) const; +#endif +#if ENABLE(VIDEO) + virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); + virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const; + virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const; private: HTMLMediaElement* getMediaElementFromRenderObject(RenderObject* o) const; void paintMediaBackground(QPainter* painter, const IntRect& r) const; + double mediaControlsBaselineOpacity() const; QColor getMediaControlForegroundColor(RenderObject* o = 0) const; #endif void computeSizeBasedOnStyle(RenderStyle* renderStyle) const; @@ -145,6 +173,8 @@ private: void setPaletteFromPageClientIfExists(QPalette&) const; + int findFrameLineWidth(QStyle* style) const; + QStyle* fallbackStyle() const; Page* m_page; @@ -155,11 +185,12 @@ private: QString m_buttonFontFamily; QStyle* m_fallbackStyle; + mutable QLineEdit* m_lineEdit; }; class StylePainter { public: - explicit StylePainter(RenderThemeQt*, const RenderObject::PaintInfo&); + explicit StylePainter(RenderThemeQt*, const PaintInfo&); explicit StylePainter(ScrollbarThemeQt*, GraphicsContext*); ~StylePainter(); diff --git a/WebCore/platform/qt/ScreenQt.cpp b/WebCore/platform/qt/ScreenQt.cpp index def1995..d648c53 100644 --- a/WebCore/platform/qt/ScreenQt.cpp +++ b/WebCore/platform/qt/ScreenQt.cpp @@ -23,18 +23,18 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "Screen.h" -#include "Page.h" +#include "FloatRect.h" #include "Frame.h" #include "FrameView.h" -#include "Widget.h" #include "IntRect.h" -#include "FloatRect.h" +#include "Page.h" +#include "Widget.h" #include <QApplication> #include <QDesktopWidget> diff --git a/WebCore/platform/qt/ScrollbarQt.cpp b/WebCore/platform/qt/ScrollbarQt.cpp index 8eac15f..70aa5db 100644 --- a/WebCore/platform/qt/ScrollbarQt.cpp +++ b/WebCore/platform/qt/ScrollbarQt.cpp @@ -29,8 +29,8 @@ #include "Scrollbar.h" #include "EventHandler.h" -#include "FrameView.h" #include "Frame.h" +#include "FrameView.h" #include "GraphicsContext.h" #include "IntRect.h" #include "PlatformMouseEvent.h" @@ -38,9 +38,9 @@ #include <QApplication> #include <QDebug> +#include <QMenu> #include <QPainter> #include <QStyle> -#include <QMenu> using namespace std; diff --git a/WebCore/platform/qt/ScrollbarThemeQt.cpp b/WebCore/platform/qt/ScrollbarThemeQt.cpp index c0c80ba..67226b0 100644 --- a/WebCore/platform/qt/ScrollbarThemeQt.cpp +++ b/WebCore/platform/qt/ScrollbarThemeQt.cpp @@ -22,7 +22,7 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" @@ -31,15 +31,15 @@ #include "GraphicsContext.h" #include "PlatformMouseEvent.h" #include "RenderThemeQt.h" -#include "Scrollbar.h" #include "ScrollView.h" +#include "Scrollbar.h" #include <QApplication> #include <QDebug> +#include <QMenu> #include <QPainter> #include <QStyle> #include <QStyleOptionSlider> -#include <QMenu> namespace WebCore { @@ -56,20 +56,20 @@ ScrollbarThemeQt::~ScrollbarThemeQt() static QStyle::SubControl scPart(const ScrollbarPart& part) { switch (part) { - case NoPart: - return QStyle::SC_None; - case BackButtonStartPart: - case BackButtonEndPart: - return QStyle::SC_ScrollBarSubLine; - case BackTrackPart: - return QStyle::SC_ScrollBarSubPage; - case ThumbPart: - return QStyle::SC_ScrollBarSlider; - case ForwardTrackPart: - return QStyle::SC_ScrollBarAddPage; - case ForwardButtonStartPart: - case ForwardButtonEndPart: - return QStyle::SC_ScrollBarAddLine; + case NoPart: + return QStyle::SC_None; + case BackButtonStartPart: + case BackButtonEndPart: + return QStyle::SC_ScrollBarSubLine; + case BackTrackPart: + return QStyle::SC_ScrollBarSubPage; + case ThumbPart: + return QStyle::SC_ScrollBarSlider; + case ForwardTrackPart: + return QStyle::SC_ScrollBarAddPage; + case ForwardButtonStartPart: + case ForwardButtonEndPart: + return QStyle::SC_ScrollBarAddLine; } return QStyle::SC_None; @@ -78,18 +78,18 @@ static QStyle::SubControl scPart(const ScrollbarPart& part) static ScrollbarPart scrollbarPart(const QStyle::SubControl& sc) { switch (sc) { - case QStyle::SC_None: - return NoPart; - case QStyle::SC_ScrollBarSubLine: - return BackButtonStartPart; - case QStyle::SC_ScrollBarSubPage: - return BackTrackPart; - case QStyle::SC_ScrollBarSlider: - return ThumbPart; - case QStyle::SC_ScrollBarAddPage: - return ForwardTrackPart; - case QStyle::SC_ScrollBarAddLine: - return ForwardButtonStartPart; + case QStyle::SC_None: + return NoPart; + case QStyle::SC_ScrollBarSubLine: + return BackButtonStartPart; + case QStyle::SC_ScrollBarSubPage: + return BackTrackPart; + case QStyle::SC_ScrollBarSlider: + return ThumbPart; + case QStyle::SC_ScrollBarAddPage: + return ForwardTrackPart; + case QStyle::SC_ScrollBarAddLine: + return ForwardButtonStartPart; } return NoPart; } @@ -114,7 +114,7 @@ static QStyleOptionSlider* styleOptionSlider(Scrollbar* scrollbar, QWidget* widg opt.state |= QStyle::State_Horizontal; opt.sliderValue = scrollbar->value(); opt.sliderPosition = opt.sliderValue; - opt.pageStep = scrollbar->visibleSize(); + opt.pageStep = scrollbar->pageStep(); opt.singleStep = scrollbar->lineStep(); opt.minimum = 0; opt.maximum = qMax(0, scrollbar->maximum()); @@ -122,9 +122,9 @@ static QStyleOptionSlider* styleOptionSlider(Scrollbar* scrollbar, QWidget* widg ScrollbarPart hoveredPart = scrollbar->hoveredPart(); if (pressedPart != NoPart) { opt.activeSubControls = scPart(scrollbar->pressedPart()); - if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart || - pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart || - pressedPart == ThumbPart) + if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart + || pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart + || pressedPart == ThumbPart) opt.state |= QStyle::State_Sunken; } else opt.activeSubControls = scPart(hoveredPart); @@ -233,9 +233,6 @@ void ScrollbarThemeQt::paintScrollCorner(ScrollView* scrollView, GraphicsContext return; } -#if QT_VERSION < 0x040500 - context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window), DeviceColorSpace); -#else StylePainter p(this, context); if (!p.isValid()) return; @@ -243,7 +240,6 @@ void ScrollbarThemeQt::paintScrollCorner(ScrollView* scrollView, GraphicsContext QStyleOption option; option.rect = rect; p.drawPrimitive(QStyle::PE_PanelScrollAreaCorner, option); -#endif } QStyle* ScrollbarThemeQt::style() const diff --git a/WebCore/platform/qt/SharedBufferQt.cpp b/WebCore/platform/qt/SharedBufferQt.cpp index 029d9d6..6b7f9c9 100644 --- a/WebCore/platform/qt/SharedBufferQt.cpp +++ b/WebCore/platform/qt/SharedBufferQt.cpp @@ -39,16 +39,9 @@ PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& fi if (!file.exists() || !file.open(QFile::ReadOnly)) return 0; - - RefPtr<SharedBuffer> result = SharedBuffer::create(); - result->m_buffer.resize(file.size()); - if (result->m_buffer.size() != file.size()) - return 0; - - result->m_size = result->m_buffer.size(); - - file.read(result->m_buffer.data(), result->m_buffer.size()); - return result.release(); + Vector<char> buffer(file.size()); + file.read(buffer.data(), buffer.size()); + return SharedBuffer::adoptVector(buffer); } -} +} // namespace WebCore diff --git a/WebCore/platform/qt/SharedTimerQt.cpp b/WebCore/platform/qt/SharedTimerQt.cpp index e9bcaee..8a6bd81 100644 --- a/WebCore/platform/qt/SharedTimerQt.cpp +++ b/WebCore/platform/qt/SharedTimerQt.cpp @@ -24,22 +24,23 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include <wtf/CurrentTime.h> - #include <QBasicTimer> #include <QCoreApplication> #include <QDebug> #include <QPointer> +#include <wtf/CurrentTime.h> namespace WebCore { class SharedTimerQt : public QObject { + Q_OBJECT + friend void setSharedTimerFiredFunction(void (*f)()); public: static SharedTimerQt* inst(); @@ -50,15 +51,18 @@ public: protected: void timerEvent(QTimerEvent* ev); +private slots: + void destroy(); + private: - SharedTimerQt(QObject* parent); + SharedTimerQt(); ~SharedTimerQt(); QBasicTimer m_timer; void (*m_timerFunction)(); }; -SharedTimerQt::SharedTimerQt(QObject* parent) - : QObject(parent) +SharedTimerQt::SharedTimerQt() + : QObject() , m_timerFunction(0) {} @@ -68,11 +72,18 @@ SharedTimerQt::~SharedTimerQt() (m_timerFunction)(); } +void SharedTimerQt::destroy() +{ + delete this; +} + SharedTimerQt* SharedTimerQt::inst() { static QPointer<SharedTimerQt> timer; - if (!timer) - timer = new SharedTimerQt(QCoreApplication::instance()); + if (!timer) { + timer = new SharedTimerQt(); + timer->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(destroy())); + } return timer; } @@ -129,6 +140,8 @@ void stopSharedTimer() SharedTimerQt::inst()->stop(); } +#include "SharedTimerQt.moc" + } // vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/SoundQt.cpp b/WebCore/platform/qt/SoundQt.cpp index 0996328..bf9e142 100644 --- a/WebCore/platform/qt/SoundQt.cpp +++ b/WebCore/platform/qt/SoundQt.cpp @@ -26,11 +26,10 @@ */ #include "config.h" +#include "Sound.h" #include <QApplication> -#include "Sound.h" - namespace WebCore { void systemBeep() diff --git a/WebCore/platform/qt/TemporaryLinkStubs.cpp b/WebCore/platform/qt/TemporaryLinkStubsQt.cpp index 814f961..51e25b8 100644 --- a/WebCore/platform/qt/TemporaryLinkStubs.cpp +++ b/WebCore/platform/qt/TemporaryLinkStubsQt.cpp @@ -33,28 +33,21 @@ #include "config.h" #include "AXObjectCache.h" -#include "DNS.h" -#include "CString.h" #include "CachedResource.h" #include "CookieJar.h" #include "Cursor.h" +#include "DNS.h" +#include "FTPDirectoryDocument.h" +#include "FileSystem.h" #include "Font.h" #include "Frame.h" #include "FrameLoader.h" -#include "FTPDirectoryDocument.h" -#include "IntPoint.h" -#include "Widget.h" -#include "GraphicsContext.h" -#include "Cursor.h" -#include "loader.h" -#include "FileSystem.h" #include "FrameView.h" #include "GraphicsContext.h" #include "IconLoader.h" #include "IntPoint.h" #include "KURL.h" #include "Language.h" -#include "loader.h" #include "LocalizedStrings.h" #include "Node.h" #include "NotImplemented.h" @@ -68,9 +61,12 @@ #include "SystemTime.h" #include "TextBoundaries.h" #include "Widget.h" +#include "loader.h" + +#include <float.h> #include <stdio.h> #include <stdlib.h> -#include <float.h> +#include <wtf/text/CString.h> using namespace WebCore; diff --git a/WebCore/platform/qt/WheelEventQt.cpp b/WebCore/platform/qt/WheelEventQt.cpp index 162a4f2..57a7ebc 100644 --- a/WebCore/platform/qt/WheelEventQt.cpp +++ b/WebCore/platform/qt/WheelEventQt.cpp @@ -18,25 +18,31 @@ */ #include "config.h" -#include "PlatformWheelEvent.h" +#include "WheelEvent.h" #include "PlatformMouseEvent.h" +#include "PlatformWheelEvent.h" #include "Scrollbar.h" -#include <qapplication.h> -#include <QWheelEvent> #include <QGraphicsSceneWheelEvent> +#include <QWheelEvent> +#include <qapplication.h> namespace WebCore { void PlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation) { + // A delta that is not mod 120 indicates a device that is sending + // fine-resolution scroll events, so use the delta as number of wheel ticks + // and number of pixels to scroll.See also webkit.org/b/29601 + bool fullTick = !(delta % 120); + if (orientation == Qt::Horizontal) { - m_deltaX = (delta / 120.0f); + m_deltaX = (fullTick) ? delta / 120.0f : delta; m_deltaY = 0; } else { m_deltaX = 0; - m_deltaY = (delta / 120.0f); + m_deltaY = (fullTick) ? delta / 120.0f : delta; } m_wheelTicksX = m_deltaX; @@ -46,17 +52,13 @@ void PlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation) // (in QTextEditPrivate::init [h,v]bar->setSingleStep) static const float cDefaultQtScrollStep = 20.f; #ifndef QT_NO_WHEELEVENT - m_deltaX *= QApplication::wheelScrollLines() * cDefaultQtScrollStep; - m_deltaY *= QApplication::wheelScrollLines() * cDefaultQtScrollStep; + m_deltaX *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1; + m_deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1; #endif } PlatformWheelEvent::PlatformWheelEvent(QGraphicsSceneWheelEvent* e) -#ifdef QT_NO_WHEELEVENT -{ - Q_UNUSED(e); -} -#else +#ifndef QT_NO_WHEELEVENT : m_position(e->pos().toPoint()) , m_globalPosition(e->screenPos()) , m_granularity(ScrollByPixelWheelEvent) @@ -65,17 +67,17 @@ PlatformWheelEvent::PlatformWheelEvent(QGraphicsSceneWheelEvent* e) , m_ctrlKey(e->modifiers() & Qt::ControlModifier) , m_altKey(e->modifiers() & Qt::AltModifier) , m_metaKey(e->modifiers() & Qt::MetaModifier) +#endif { +#ifndef QT_NO_WHEELEVENT applyDelta(e->delta(), e->orientation()); +#else + Q_UNUSED(e); +#endif } -#endif // QT_NO_WHEELEVENT PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e) -#ifdef QT_NO_WHEELEVENT -{ - Q_UNUSED(e); -} -#else +#ifndef QT_NO_WHEELEVENT : m_position(e->pos()) , m_globalPosition(e->globalPos()) , m_granularity(ScrollByPixelWheelEvent) @@ -84,9 +86,13 @@ PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e) , m_ctrlKey(e->modifiers() & Qt::ControlModifier) , m_altKey(e->modifiers() & Qt::AltModifier) , m_metaKey(e->modifiers() & Qt::MetaModifier) +#endif { +#ifndef QT_NO_WHEELEVENT applyDelta(e->delta(), e->orientation()); +#else + Q_UNUSED(e); +#endif } -#endif // QT_NO_WHEELEVENT } // namespace WebCore diff --git a/WebCore/platform/qt/WidgetQt.cpp b/WebCore/platform/qt/WidgetQt.cpp index 252bdb4..0903b6e 100644 --- a/WebCore/platform/qt/WidgetQt.cpp +++ b/WebCore/platform/qt/WidgetQt.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> - * Copyright (C) 2006 George Stiakos <staikos@kde.org> + * Copyright (C) 2006 George Staikos <staikos@kde.org> * Copyright (C) 2006 Zack Rusin <zack@kde.org> * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) 2008 Holger Hans Peter Freyther @@ -37,19 +37,15 @@ #include "GraphicsContext.h" #include "HostWindow.h" #include "IntRect.h" -#include "ScrollView.h" #include "NotImplemented.h" #include "QWebPageClient.h" - -#include "qwebframe.h" -#include "qwebframe_p.h" -#include "qwebpage.h" +#include "ScrollView.h" #include <QCoreApplication> -#include <QPainter> -#include <QPaintEngine> - #include <QDebug> +#include <QPaintEngine> +#include <QPainter> +#include <QWidget> namespace WebCore { @@ -75,7 +71,7 @@ void Widget::setFrameRect(const IntRect& rect) frameRectsChanged(); } -void Widget::setFocus() +void Widget::setFocus(bool focused) { } |