diff options
Diffstat (limited to 'WebCore/platform/qt')
40 files changed, 2095 insertions, 1843 deletions
diff --git a/WebCore/platform/qt/ClipboardQt.cpp b/WebCore/platform/qt/ClipboardQt.cpp index c23e42e..20cf62b 100644 --- a/WebCore/platform/qt/ClipboardQt.cpp +++ b/WebCore/platform/qt/ClipboardQt.cpp @@ -22,51 +22,68 @@ * 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 "Document.h" +#include "DragData.h" #include "Element.h" #include "FileList.h" #include "Frame.h" #include "HTMLNames.h" +#include "HTMLParserIdioms.h" #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 <wtf/text/StringHash.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) + : Clipboard(policy, DragAndDrop) , m_readableData(readableClipboard) , m_writableData(0) { Q_ASSERT(policy == ClipboardReadable || policy == ClipboardTypesReadable); } -ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, bool forDragging) - : Clipboard(policy, forDragging) +ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, ClipboardType clipboardType) + : Clipboard(policy, clipboardType) , m_readableData(0) , m_writableData(0) { @@ -74,7 +91,7 @@ ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, bool forDragging) #ifndef QT_NO_CLIPBOARD if (policy != ClipboardWritable) { - Q_ASSERT(!forDragging); + Q_ASSERT(isForCopyAndPaste()); m_readableData = QApplication::clipboard()->mimeData(); } #endif @@ -82,7 +99,7 @@ ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, bool forDragging) ClipboardQt::~ClipboardQt() { - if (m_writableData && !isForDragging()) + if (m_writableData && isForCopyAndPaste()) m_writableData = 0; else delete m_writableData; @@ -97,13 +114,13 @@ void ClipboardQt::clearData(const String& type) if (m_writableData) { m_writableData->removeFormat(type); if (m_writableData->formats().isEmpty()) { - if (isForDragging()) + if (isForDragAndDrop()) delete m_writableData; m_writableData = 0; } } #ifndef QT_NO_CLIPBOARD - if (!isForDragging()) + if (isForCopyAndPaste()) QApplication::clipboard()->setMimeData(m_writableData); #endif } @@ -114,7 +131,7 @@ void ClipboardQt::clearAllData() return; #ifndef QT_NO_CLIPBOARD - if (!isForDragging()) + if (isForCopyAndPaste()) QApplication::clipboard()->setMimeData(0); else #endif @@ -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,11 +171,18 @@ 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()) + if (isForCopyAndPaste()) QApplication::clipboard()->setMimeData(m_writableData); #endif return true; @@ -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); @@ -241,7 +276,7 @@ void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, co if (imageURL.isEmpty()) return; - KURL fullURL = frame->document()->completeURL(deprecatedParseURL(imageURL)); + KURL fullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL)); if (fullURL.isEmpty()) return; @@ -252,7 +287,7 @@ void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, co m_writableData->setText(title); m_writableData->setUrls(urls); #ifndef QT_NO_CLIPBOARD - if (!isForDragging()) + if (isForCopyAndPaste()) QApplication::clipboard()->setMimeData(m_writableData); #endif } @@ -268,7 +303,7 @@ void ClipboardQt::writeURL(const KURL& url, const String& title, Frame* frame) m_writableData->setUrls(urls); m_writableData->setText(title); #ifndef QT_NO_CLIPBOARD - if (!isForDragging()) + if (isForCopyAndPaste()) QApplication::clipboard()->setMimeData(m_writableData); #endif } @@ -280,12 +315,12 @@ void ClipboardQt::writeRange(Range* range, Frame* frame) if (!m_writableData) m_writableData = new QMimeData; - QString text = frame->selectedText(); + QString text = frame->editor()->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()) + if (isForCopyAndPaste()) QApplication::clipboard()->setMimeData(m_writableData); #endif } @@ -298,7 +333,7 @@ void ClipboardQt::writePlainText(const String& str) text.replace(QChar(0xa0), QLatin1Char(' ')); m_writableData->setText(text); #ifndef QT_NO_CLIPBOARD - if (!isForDragging()) + if (isForCopyAndPaste()) QApplication::clipboard()->setMimeData(m_writableData); #endif } diff --git a/WebCore/platform/qt/ClipboardQt.h b/WebCore/platform/qt/ClipboardQt.h index 9b54d5f..5aca1a6 100644 --- a/WebCore/platform/qt/ClipboardQt.h +++ b/WebCore/platform/qt/ClipboardQt.h @@ -44,9 +44,9 @@ namespace WebCore { { return adoptRef(new ClipboardQt(policy, readableClipboard)); } - static PassRefPtr<ClipboardQt> create(ClipboardAccessPolicy policy, bool forDragging = false) + static PassRefPtr<ClipboardQt> create(ClipboardAccessPolicy policy, ClipboardType clipboardType = CopyAndPaste) { - return adoptRef(new ClipboardQt(policy, forDragging)); + return adoptRef(new ClipboardQt(policy, clipboardType)); } virtual ~ClipboardQt(); @@ -77,7 +77,7 @@ namespace WebCore { ClipboardQt(ClipboardAccessPolicy, const QMimeData* readableClipboard); // Clipboard is writable so it will create its own QMimeData object - ClipboardQt(ClipboardAccessPolicy, bool forDragging); + ClipboardQt(ClipboardAccessPolicy, ClipboardType); void setDragImage(CachedImage*, Node*, const IntPoint& loc); diff --git a/WebCore/platform/qt/ContextMenuItemQt.cpp b/WebCore/platform/qt/ContextMenuItemQt.cpp index cf23587..a65e50c 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 { @@ -103,6 +104,12 @@ void ContextMenuItem::setChecked(bool on) m_platformDescription.checked = on; } +bool ContextMenuItem::checked() const +{ + // FIXME - Implement + return false; +} + void ContextMenuItem::setEnabled(bool on) { m_platformDescription.enabled = on; diff --git a/WebCore/platform/qt/ContextMenuQt.cpp b/WebCore/platform/qt/ContextMenuQt.cpp index 9b1a054..2c1a6cb 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 { @@ -76,6 +74,11 @@ PlatformMenuDescription ContextMenu::releasePlatformDescription() return PlatformMenuDescription(); } +Vector<ContextMenuItem> contextMenuItemVector(PlatformMenuDescription) +{ + // FIXME - Implement + return Vector<ContextMenuItem>(); +} } // vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/CookieJarQt.cpp b/WebCore/platform/qt/CookieJarQt.cpp index 01d1756..4e1de23 100644 --- a/WebCore/platform/qt/CookieJarQt.cpp +++ b/WebCore/platform/qt/CookieJarQt.cpp @@ -31,6 +31,7 @@ #include "Cookie.h" #include "Document.h" #include "KURL.h" +#include "NetworkingContext.h" #include "PlatformString.h" #include "qwebpage.h" @@ -51,9 +52,7 @@ static QNetworkCookieJar *cookieJar(const Document *document) FrameLoader *loader = frame->loader(); if (!loader) return 0; - QWebFrame* webFrame = static_cast<FrameLoaderClientQt*>(loader->client())->webFrame(); - QWebPage* page = webFrame->page(); - QNetworkAccessManager* manager = page->networkAccessManager(); + QNetworkAccessManager* manager = loader->networkingContext()->networkAccessManager(); QNetworkCookieJar* jar = manager->cookieJar(); return jar; } @@ -67,7 +66,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 +73,6 @@ void setCookies(Document* document, const KURL& url, const String& value) else ++it; } -#endif jar->setCookiesFromUrl(cookies, u); } @@ -92,10 +89,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..5883600 100644 --- a/WebCore/platform/qt/CursorQt.cpp +++ b/WebCore/platform/qt/CursorQt.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2006 George Staikos <staikos@kde.org> * Copyright (C) 2006 Charles Samuels <charles@kde.org> * Copyright (C) 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2010 University of Szeged * * All rights reserved. * @@ -43,328 +44,164 @@ namespace WebCore { -Cursor::Cursor(PlatformCursor p) - : m_impl(p) -{ -} - Cursor::Cursor(const Cursor& other) - : m_impl(other.m_impl) + : m_type(other.m_type) + , m_image(other.m_image) + , m_hotSpot(other.m_hotSpot) +#ifndef QT_NO_CURSOR + , m_platformCursor(other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0) +#endif { } Cursor::~Cursor() { -} - -Cursor::Cursor(Image* image, const IntPoint& hotspot) #ifndef QT_NO_CURSOR - : m_impl(*(image->nativeImageForCurrentFrame()), hotspot.x(), hotspot.y()) + delete m_platformCursor; #endif -{ } Cursor& Cursor::operator=(const Cursor& other) { - m_impl = other.m_impl; - return *this; -} - -namespace { - -// FIXME: static deleter -class Cursors : public Noncopyable { -protected: - Cursors() + m_type = other.m_type; + m_image = other.m_image; + m_hotSpot = other.m_hotSpot; #ifndef QT_NO_CURSOR - : CrossCursor(Qt::CrossCursor) - , MoveCursor(Qt::SizeAllCursor) - , PointerCursor(Qt::ArrowCursor) - , PointingHandCursor(Qt::PointingHandCursor) - , IBeamCursor(Qt::IBeamCursor) - , WaitCursor(Qt::WaitCursor) - , WhatsThisCursor(Qt::WhatsThisCursor) - , SizeHorCursor(Qt::SizeHorCursor) - , SizeVerCursor(Qt::SizeVerCursor) - , SizeFDiagCursor(Qt::SizeFDiagCursor) - , SizeBDiagCursor(Qt::SizeBDiagCursor) - , SplitHCursor(Qt::SplitHCursor) - , SplitVCursor(Qt::SplitVCursor) - , NoDropCursor(Qt::ForbiddenCursor) - , BlankCursor(Qt::BlankCursor) - , ZoomInCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomInCursor.png")), 7, 7)) - , ZoomOutCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomOutCursor.png")), 7, 7)) - , VerticalTextCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/verticalTextCursor.png")), 7, 7)) - , CellCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/cellCursor.png")), 7, 7)) - , ContextMenuCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/contextMenuCursor.png")), 3, 2)) - , CopyCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/copyCursor.png")), 3, 2)) - , ProgressCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/progressCursor.png")), 3, 2)) - , AliasCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/aliasCursor.png")), 11, 3)) - + m_platformCursor = other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0; #endif - { - } - - ~Cursors() - { - } - -public: - static Cursors* self(); - static Cursors* s_self; - - Cursor CrossCursor; - Cursor MoveCursor; - Cursor PointerCursor; - Cursor PointingHandCursor; - Cursor IBeamCursor; - Cursor WaitCursor; - Cursor WhatsThisCursor; - Cursor SizeHorCursor; - Cursor SizeVerCursor; - Cursor SizeFDiagCursor; - Cursor SizeBDiagCursor; - Cursor SplitHCursor; - Cursor SplitVCursor; - Cursor NoDropCursor; - Cursor BlankCursor; - Cursor ZoomInCursor; - Cursor ZoomOutCursor; - Cursor VerticalTextCursor; - Cursor CellCursor; - Cursor ContextMenuCursor; - Cursor CopyCursor; - Cursor ProgressCursor; - Cursor AliasCursor; -}; - -Cursors* Cursors::s_self = 0; - -Cursors* Cursors::self() -{ - if (!s_self) - s_self = new Cursors(); - - return s_self; -} - -} - -const Cursor& pointerCursor() -{ - return Cursors::self()->PointerCursor; -} - -const Cursor& moveCursor() -{ - return Cursors::self()->MoveCursor; -} - -const Cursor& crossCursor() -{ - return Cursors::self()->CrossCursor; -} - -const Cursor& handCursor() -{ - return Cursors::self()->PointingHandCursor; -} - -const Cursor& iBeamCursor() -{ - return Cursors::self()->IBeamCursor; -} - -const Cursor& waitCursor() -{ - return Cursors::self()->WaitCursor; -} - -const Cursor& helpCursor() -{ - return Cursors::self()->WhatsThisCursor; -} - -const Cursor& eastResizeCursor() -{ - return Cursors::self()->SizeHorCursor; -} - -const Cursor& northResizeCursor() -{ - return Cursors::self()->SizeVerCursor; -} - -const Cursor& northEastResizeCursor() -{ - return Cursors::self()->SizeBDiagCursor; -} - -const Cursor& northWestResizeCursor() -{ - return Cursors::self()->SizeFDiagCursor; -} - -const Cursor& southResizeCursor() -{ - return Cursors::self()->SizeVerCursor; -} - -const Cursor& southEastResizeCursor() -{ - return Cursors::self()->SizeFDiagCursor; -} - -const Cursor& southWestResizeCursor() -{ - return Cursors::self()->SizeBDiagCursor; -} - -const Cursor& westResizeCursor() -{ - return Cursors::self()->SizeHorCursor; -} - -const Cursor& northSouthResizeCursor() -{ - return Cursors::self()->SizeVerCursor; -} - -const Cursor& eastWestResizeCursor() -{ - return Cursors::self()->SizeHorCursor; -} - -const Cursor& northEastSouthWestResizeCursor() -{ - return Cursors::self()->SizeBDiagCursor; -} - -const Cursor& northWestSouthEastResizeCursor() -{ - return Cursors::self()->SizeFDiagCursor; -} - -const Cursor& columnResizeCursor() -{ - return Cursors::self()->SplitHCursor; -} - -const Cursor& rowResizeCursor() -{ - return Cursors::self()->SplitVCursor; -} - -const Cursor& middlePanningCursor() -{ - return moveCursor(); -} - -const Cursor& eastPanningCursor() -{ - return eastResizeCursor(); -} - -const Cursor& northPanningCursor() -{ - return northResizeCursor(); -} - -const Cursor& northEastPanningCursor() -{ - return northEastResizeCursor(); -} - -const Cursor& northWestPanningCursor() -{ - return northWestResizeCursor(); -} - -const Cursor& southPanningCursor() -{ - return southResizeCursor(); -} - -const Cursor& southEastPanningCursor() -{ - return southEastResizeCursor(); -} - -const Cursor& southWestPanningCursor() -{ - return southWestResizeCursor(); -} - -const Cursor& westPanningCursor() -{ - return westResizeCursor(); -} - -const Cursor& verticalTextCursor() -{ - return Cursors::self()->VerticalTextCursor; -} - -const Cursor& cellCursor() -{ - return Cursors::self()->CellCursor; -} - -const Cursor& contextMenuCursor() -{ - return Cursors::self()->ContextMenuCursor; -} - -const Cursor& noDropCursor() -{ - return Cursors::self()->NoDropCursor; -} - -const Cursor& copyCursor() -{ - return Cursors::self()->CopyCursor; -} - -const Cursor& progressCursor() -{ - return Cursors::self()->ProgressCursor; -} - -const Cursor& aliasCursor() -{ - return Cursors::self()->AliasCursor; -} - -const Cursor& noneCursor() -{ - return Cursors::self()->BlankCursor; -} - -const Cursor& notAllowedCursor() -{ - return Cursors::self()->NoDropCursor; -} - -const Cursor& zoomInCursor() -{ - return Cursors::self()->ZoomInCursor; -} - -const Cursor& zoomOutCursor() -{ - return Cursors::self()->ZoomOutCursor; + return *this; } -const Cursor& grabCursor() +#ifndef QT_NO_CURSOR +static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot) { - notImplemented(); - return Cursors::self()->PointerCursor; + IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot); + return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y()); } +#endif -const Cursor& grabbingCursor() +void Cursor::ensurePlatformCursor() const { - notImplemented(); - return Cursors::self()->PointerCursor; +#ifndef QT_NO_CURSOR + if (m_platformCursor) + return; + + switch (m_type) { + case Pointer: + m_platformCursor = new QCursor(Qt::ArrowCursor); + break; + case Cross: + m_platformCursor = new QCursor(Qt::CrossCursor); + break; + case Hand: + m_platformCursor = new QCursor(Qt::PointingHandCursor); + break; + case IBeam: + m_platformCursor = new QCursor(Qt::IBeamCursor); + break; + case Wait: + m_platformCursor = new QCursor(Qt::WaitCursor); + break; + case Help: + m_platformCursor = new QCursor(Qt::WhatsThisCursor); + break; + case EastResize: + case EastPanning: + m_platformCursor = new QCursor(Qt::SizeHorCursor); + break; + case NorthResize: + case NorthPanning: + m_platformCursor = new QCursor(Qt::SizeVerCursor); + break; + case NorthEastResize: + case NorthEastPanning: + m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + break; + case NorthWestResize: + case NorthWestPanning: + m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + break; + case SouthResize: + case SouthPanning: + m_platformCursor = new QCursor(Qt::SizeVerCursor); + break; + case SouthEastResize: + case SouthEastPanning: + m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + break; + case SouthWestResize: + case SouthWestPanning: + m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + break; + case WestResize: + case WestPanning: + m_platformCursor = new QCursor(Qt::SizeHorCursor); + break; + case NorthSouthResize: + m_platformCursor = new QCursor(Qt::SizeVerCursor); + break; + case EastWestResize: + m_platformCursor = new QCursor(Qt::SizeHorCursor); + break; + case NorthEastSouthWestResize: + m_platformCursor = new QCursor(Qt::SizeBDiagCursor); + break; + case NorthWestSouthEastResize: + m_platformCursor = new QCursor(Qt::SizeFDiagCursor); + break; + case ColumnResize: + m_platformCursor = new QCursor(Qt::SplitHCursor); + break; + case RowResize: + m_platformCursor = new QCursor(Qt::SplitVCursor); + break; + case MiddlePanning: + case Move: + m_platformCursor = new QCursor(Qt::SizeAllCursor); + break; + case None: + m_platformCursor = new QCursor(Qt::BlankCursor); + break; + case NoDrop: + case NotAllowed: + m_platformCursor = new QCursor(Qt::ForbiddenCursor); + break; + case Grab: + case Grabbing: + notImplemented(); + m_platformCursor = new QCursor(Qt::ArrowCursor); + break; + case VerticalText: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/verticalTextCursor.png")), 7, 7); + break; + case Cell: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/cellCursor.png")), 7, 7); + break; + case ContextMenu: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/contextMenuCursor.png")), 3, 2); + break; + case Alias: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/aliasCursor.png")), 11, 3); + break; + case Progress: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/progressCursor.png")), 3, 2); + break; + case Copy: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/copyCursor.png")), 3, 2); + break; + case ZoomIn: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomInCursor.png")), 7, 7); + break; + case ZoomOut: + m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomOutCursor.png")), 7, 7); + break; + case Custom: + m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot); + break; + default: + ASSERT_NOT_REACHED(); + } +#endif } } 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..b384091 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,17 +115,46 @@ Vector<String> listDirectory(const String& path, const String& filter) CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle) { - QTemporaryFile* tempFile = new QTemporaryFile(QLatin1String(prefix)); +#ifndef QT_NO_TEMPORARYFILE + QTemporaryFile* tempFile = new QTemporaryFile(QDir::tempPath() + QLatin1Char('/') + QLatin1String(prefix)); tempFile->setAutoRemove(false); QFile* temp = tempFile; if (temp->open(QIODevice::ReadWrite)) { handle = temp; return String(temp->fileName()).utf8(); } +#endif handle = invalidPlatformFileHandle; return CString(); } +#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) +PlatformFileHandle openFile(const String& path, FileOpenMode mode) +{ + QIODevice::OpenMode platformMode; + + if (mode == OpenForRead) + platformMode = QIODevice::ReadOnly; + else if (mode == OpenForWrite) + platformMode = (QIODevice::WriteOnly | QIODevice::Truncate); + else + return invalidPlatformFileHandle; + + QFile* file = new QFile(path); + if (file->open(platformMode)) + return file; + + return invalidPlatformFileHandle; +} + +int readFromFile(PlatformFileHandle handle, char* data, int length) +{ + if (handle && handle->exists() && handle->isReadable()) + return handle->read(data, length); + return 0; +} +#endif + void closeFile(PlatformFileHandle& handle) { if (handle) { @@ -154,11 +181,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/LanguageQt.cpp b/WebCore/platform/qt/LanguageQt.cpp new file mode 100644 index 0000000..71e554f --- /dev/null +++ b/WebCore/platform/qt/LanguageQt.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 INdT - Instituto Nokia de Tecnologia + * 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 COMPUTER, 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 COMPUTER, 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 "Language.h" + +#include "PlatformString.h" +#include <QLocale> + +namespace WebCore { + +String platformDefaultLanguage() +{ + QLocale locale; + return locale.name().replace("_", "-"); +} + +} diff --git a/WebCore/platform/qt/Localizations.cpp b/WebCore/platform/qt/Localizations.cpp deleted file mode 100644 index c919193..0000000 --- a/WebCore/platform/qt/Localizations.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * All rights reserved. - * - * 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 COMPUTER, 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 COMPUTER, 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 "IntSize.h" -#include "LocalizedStrings.h" -#include "NotImplemented.h" -#include "PlatformString.h" -#include <wtf/MathExtras.h> - -#include <QCoreApplication> -#include <QLocale> - -namespace WebCore { - -String submitButtonDefaultLabel() -{ - return QCoreApplication::translate("QWebPage", "Submit", "default label for Submit buttons in forms on web pages"); -} - -String inputElementAltText() -{ - return QCoreApplication::translate("QWebPage", "Submit", "Submit (input element) alt text for <input> elements with no alt, title, or value"); -} - -String resetButtonDefaultLabel() -{ - return QCoreApplication::translate("QWebPage", "Reset", "default label for Reset buttons in forms on web pages"); -} - -String defaultLanguage() -{ - QLocale locale; - return locale.name().replace("_", "-"); -} - -String searchableIndexIntroduction() -{ - return QCoreApplication::translate("QWebPage", "This is a searchable index. Enter search keywords: ", "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'"); -} - -String fileButtonChooseFileLabel() -{ - return QCoreApplication::translate("QWebPage", "Choose File", "title for file button used in HTML forms"); -} - -String fileButtonNoFileSelectedLabel() -{ - return QCoreApplication::translate("QWebPage", "No file selected", "text to display in file button used in HTML forms when no file is selected"); -} - -String contextMenuItemTagOpenLinkInNewWindow() -{ - return QCoreApplication::translate("QWebPage", "Open in New Window", "Open in New Window context menu item"); -} - -String contextMenuItemTagDownloadLinkToDisk() -{ - return QCoreApplication::translate("QWebPage", "Save Link...", "Download Linked File context menu item"); -} - -String contextMenuItemTagCopyLinkToClipboard() -{ - return QCoreApplication::translate("QWebPage", "Copy Link", "Copy Link context menu item"); -} - -String contextMenuItemTagOpenImageInNewWindow() -{ - return QCoreApplication::translate("QWebPage", "Open Image", "Open Image in New Window context menu item"); -} - -String contextMenuItemTagDownloadImageToDisk() -{ - return QCoreApplication::translate("QWebPage", "Save Image", "Download Image context menu item"); -} - -String contextMenuItemTagCopyImageToClipboard() -{ - return QCoreApplication::translate("QWebPage", "Copy Image", "Copy Link context menu item"); -} - -String contextMenuItemTagOpenFrameInNewWindow() -{ - return QCoreApplication::translate("QWebPage", "Open Frame", "Open Frame in New Window context menu item"); -} - -String contextMenuItemTagCopy() -{ - return QCoreApplication::translate("QWebPage", "Copy", "Copy context menu item"); -} - -String contextMenuItemTagGoBack() -{ - return QCoreApplication::translate("QWebPage", "Go Back", "Back context menu item"); -} - -String contextMenuItemTagGoForward() -{ - return QCoreApplication::translate("QWebPage", "Go Forward", "Forward context menu item"); -} - -String contextMenuItemTagStop() -{ - return QCoreApplication::translate("QWebPage", "Stop", "Stop context menu item"); -} - -String contextMenuItemTagReload() -{ - return QCoreApplication::translate("QWebPage", "Reload", "Reload context menu item"); -} - -String contextMenuItemTagCut() -{ - return QCoreApplication::translate("QWebPage", "Cut", "Cut context menu item"); -} - -String contextMenuItemTagPaste() -{ - return QCoreApplication::translate("QWebPage", "Paste", "Paste context menu item"); -} - -String contextMenuItemTagNoGuessesFound() -{ - return QCoreApplication::translate("QWebPage", "No Guesses Found", "No Guesses Found context menu item"); -} - -String contextMenuItemTagIgnoreSpelling() -{ - return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Spelling context menu item"); -} - -String contextMenuItemTagLearnSpelling() -{ - return QCoreApplication::translate("QWebPage", "Add To Dictionary", "Learn Spelling context menu item"); -} - -String contextMenuItemTagSearchWeb() -{ - return QCoreApplication::translate("QWebPage", "Search The Web", "Search The Web context menu item"); -} - -String contextMenuItemTagLookUpInDictionary() -{ - return QCoreApplication::translate("QWebPage", "Look Up In Dictionary", "Look Up in Dictionary context menu item"); -} - -String contextMenuItemTagOpenLink() -{ - return QCoreApplication::translate("QWebPage", "Open Link", "Open Link context menu item"); -} - -String contextMenuItemTagIgnoreGrammar() -{ - return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Grammar context menu item"); -} - -String contextMenuItemTagSpellingMenu() -{ - return QCoreApplication::translate("QWebPage", "Spelling", "Spelling and Grammar context sub-menu item"); -} - -String contextMenuItemTagShowSpellingPanel(bool show) -{ - return show ? QCoreApplication::translate("QWebPage", "Show Spelling and Grammar", "menu item title") : - QCoreApplication::translate("QWebPage", "Hide Spelling and Grammar", "menu item title"); -} - -String contextMenuItemTagCheckSpelling() -{ - return QCoreApplication::translate("QWebPage", "Check Spelling", "Check spelling context menu item"); -} - -String contextMenuItemTagCheckSpellingWhileTyping() -{ - return QCoreApplication::translate("QWebPage", "Check Spelling While Typing", "Check spelling while typing context menu item"); -} - -String contextMenuItemTagCheckGrammarWithSpelling() -{ - return QCoreApplication::translate("QWebPage", "Check Grammar With Spelling", "Check grammar with spelling context menu item"); -} - -String contextMenuItemTagFontMenu() -{ - return QCoreApplication::translate("QWebPage", "Fonts", "Font context sub-menu item"); -} - -String contextMenuItemTagBold() -{ - return QCoreApplication::translate("QWebPage", "Bold", "Bold context menu item"); -} - -String contextMenuItemTagItalic() -{ - return QCoreApplication::translate("QWebPage", "Italic", "Italic context menu item"); -} - -String contextMenuItemTagUnderline() -{ - return QCoreApplication::translate("QWebPage", "Underline", "Underline context menu item"); -} - -String contextMenuItemTagOutline() -{ - return QCoreApplication::translate("QWebPage", "Outline", "Outline context menu item"); -} - -String contextMenuItemTagWritingDirectionMenu() -{ - return QCoreApplication::translate("QWebPage", "Direction", "Writing direction context sub-menu item"); -} - -String contextMenuItemTagTextDirectionMenu() -{ - return QCoreApplication::translate("QWebPage", "Text Direction", "Text direction context sub-menu item"); -} - -String contextMenuItemTagDefaultDirection() -{ - return QCoreApplication::translate("QWebPage", "Default", "Default writing direction context menu item"); -} - -String contextMenuItemTagLeftToRight() -{ - return QCoreApplication::translate("QWebPage", "Left to Right", "Left to Right context menu item"); -} - -String contextMenuItemTagRightToLeft() -{ - return QCoreApplication::translate("QWebPage", "Right to Left", "Right to Left context menu item"); -} - -String contextMenuItemTagInspectElement() -{ - return QCoreApplication::translate("QWebPage", "Inspect", "Inspect Element context menu item"); -} - -String searchMenuNoRecentSearchesText() -{ - return QCoreApplication::translate("QWebPage", "No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed"); -} - -String searchMenuRecentSearchesText() -{ - return QCoreApplication::translate("QWebPage", "Recent searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title"); -} - -String searchMenuClearRecentSearchesText() -{ - return QCoreApplication::translate("QWebPage", "Clear recent searches", "menu item in Recent Searches menu that empties menu's contents"); -} - -String AXWebAreaText() -{ - return String(); -} - -String AXLinkText() -{ - return String(); -} - -String AXListMarkerText() -{ - return String(); -} - -String AXImageMapText() -{ - return String(); -} - -String AXHeadingText() -{ - return String(); -} - -String AXDefinitionListTermText() -{ - return String(); -} - -String AXDefinitionListDefinitionText() -{ - return String(); -} - -String AXButtonActionVerb() -{ - return String(); -} - -String AXRadioButtonActionVerb() -{ - return String(); -} - -String AXTextFieldActionVerb() -{ - return String(); -} - -String AXCheckedCheckBoxActionVerb() -{ - return String(); -} - -String AXUncheckedCheckBoxActionVerb() -{ - return String(); -} - -String AXLinkActionVerb() -{ - return String(); -} - -String AXMenuListPopupActionVerb() -{ - return String(); -} - -String AXMenuListActionVerb() -{ - return String(); -} - -String multipleFileUploadText(unsigned) -{ - return String(); -} - -String unknownFileSizeText() -{ - return QCoreApplication::translate("QWebPage", "Unknown", "Unknown filesize FTP directory listing item"); -} - -String imageTitle(const String& filename, const IntSize& size) -{ - return QCoreApplication::translate("QWebPage", "%1 (%2x%3 pixels)", "Title string for images").arg(filename).arg(size.width()).arg(size.height()); -} - -String mediaElementLoadingStateText() -{ - return QCoreApplication::translate("QWebPage", "Loading...", "Media controller status message when the media is loading"); -} - -String mediaElementLiveBroadcastStateText() -{ - return QCoreApplication::translate("QWebPage", "Live Broadcast", "Media controller status message when watching a live broadcast"); -} - -#if ENABLE(VIDEO) - -String localizedMediaControlElementString(const String& name) -{ - if (name == "AudioElement") - return QCoreApplication::translate("QWebPage", "Audio Element", "Media controller element"); - if (name == "VideoElement") - return QCoreApplication::translate("QWebPage", "Video Element", "Media controller element"); - if (name == "MuteButton") - return QCoreApplication::translate("QWebPage", "Mute Button", "Media controller element"); - if (name == "UnMuteButton") - return QCoreApplication::translate("QWebPage", "Unmute Button", "Media controller element"); - if (name == "PlayButton") - return QCoreApplication::translate("QWebPage", "Play Button", "Media controller element"); - if (name == "PauseButton") - return QCoreApplication::translate("QWebPage", "Pause Button", "Media controller element"); - if (name == "Slider") - return QCoreApplication::translate("QWebPage", "Slider", "Media controller element"); - if (name == "SliderThumb") - return QCoreApplication::translate("QWebPage", "Slider Thumb", "Media controller element"); - if (name == "RewindButton") - return QCoreApplication::translate("QWebPage", "Rewind Button", "Media controller element"); - if (name == "ReturnToRealtimeButton") - return QCoreApplication::translate("QWebPage", "Return to Real-time Button", "Media controller element"); - if (name == "CurrentTimeDisplay") - return QCoreApplication::translate("QWebPage", "Elapsed Time", "Media controller element"); - if (name == "TimeRemainingDisplay") - return QCoreApplication::translate("QWebPage", "Remaining Time", "Media controller element"); - if (name == "StatusDisplay") - return QCoreApplication::translate("QWebPage", "Status Display", "Media controller element"); - if (name == "FullscreenButton") - return QCoreApplication::translate("QWebPage", "Fullscreen Button", "Media controller element"); - if (name == "SeekForwardButton") - return QCoreApplication::translate("QWebPage", "Seek Forward Button", "Media controller element"); - if (name == "SeekBackButton") - return QCoreApplication::translate("QWebPage", "Seek Back Button", "Media controller element"); - - return String(); -} - -String localizedMediaControlElementHelpText(const String& name) -{ - if (name == "AudioElement") - return QCoreApplication::translate("QWebPage", "Audio element playback controls and status display", "Media controller element"); - if (name == "VideoElement") - return QCoreApplication::translate("QWebPage", "Video element playback controls and status display", "Media controller element"); - if (name == "MuteButton") - return QCoreApplication::translate("QWebPage", "Mute audio tracks", "Media controller element"); - if (name == "UnMuteButton") - return QCoreApplication::translate("QWebPage", "Unmute audio tracks", "Media controller element"); - if (name == "PlayButton") - return QCoreApplication::translate("QWebPage", "Begin playback", "Media controller element"); - if (name == "PauseButton") - return QCoreApplication::translate("QWebPage", "Pause playback", "Media controller element"); - if (name == "Slider") - return QCoreApplication::translate("QWebPage", "Movie time scrubber", "Media controller element"); - if (name == "SliderThumb") - return QCoreApplication::translate("QWebPage", "Movie time scrubber thumb", "Media controller element"); - if (name == "RewindButton") - return QCoreApplication::translate("QWebPage", "Rewind movie", "Media controller element"); - if (name == "ReturnToRealtimeButton") - return QCoreApplication::translate("QWebPage", "Return streaming movie to real-time", "Media controller element"); - if (name == "CurrentTimeDisplay") - return QCoreApplication::translate("QWebPage", "Current movie time", "Media controller element"); - if (name == "TimeRemainingDisplay") - return QCoreApplication::translate("QWebPage", "Remaining movie time", "Media controller element"); - if (name == "StatusDisplay") - return QCoreApplication::translate("QWebPage", "Current movie status", "Media controller element"); - if (name == "FullscreenButton") - return QCoreApplication::translate("QWebPage", "Play movie in full-screen mode", "Media controller element"); - if (name == "SeekForwardButton") - return QCoreApplication::translate("QWebPage", "Seek quickly back", "Media controller element"); - if (name == "SeekBackButton") - return QCoreApplication::translate("QWebPage", "Seek quickly forward", "Media controller element"); - - ASSERT_NOT_REACHED(); - return String(); -} - -String localizedMediaTimeDescription(float time) -{ - if (!isfinite(time)) - return QCoreApplication::translate("QWebPage", "Indefinite time", "Media time description"); - - int seconds = (int)fabsf(time); - int days = seconds / (60 * 60 * 24); - int hours = seconds / (60 * 60); - int minutes = (seconds / 60) % 60; - seconds %= 60; - - 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) { - return QCoreApplication::translate("QWebPage", "%1 hours %2 minutes %3 seconds", "Media time description").arg(hours).arg(minutes).arg(seconds); - } - - 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) - -String validationMessageValueMissingText() -{ - notImplemented(); - return String(); -} - -String validationMessageTypeMismatchText() -{ - notImplemented(); - return String(); -} - -String validationMessagePatternMismatchText() -{ - notImplemented(); - return String(); -} - -String validationMessageTooLongText() -{ - notImplemented(); - return String(); -} - -String validationMessageRangeUnderflowText() -{ - notImplemented(); - return String(); -} - -String validationMessageRangeOverflowText() -{ - notImplemented(); - return String(); -} - -String validationMessageStepMismatchText() -{ - notImplemented(); - return String(); -} - -} -// vim: ts=4 sw=4 et 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..12db891 100644 --- a/WebCore/platform/qt/MIMETypeRegistryQt.cpp +++ b/WebCore/platform/qt/MIMETypeRegistryQt.cpp @@ -79,7 +79,13 @@ String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) ++e; } - return "application/octet-stream"; + return String(); +} + +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/PasteboardQt.cpp b/WebCore/platform/qt/PasteboardQt.cpp index 44c9eec..ac54fdb 100644 --- a/WebCore/platform/qt/PasteboardQt.cpp +++ b/WebCore/platform/qt/PasteboardQt.cpp @@ -58,26 +58,27 @@ 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(); + QString text = frame->editor()->selectedText(); text.replace(QChar(0xa0), QLatin1Char(' ')); 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 += QLatin1String("</body></html>"); - md->setHtml(html); + md->setHtml(createMarkup(selectedRange, 0, AnnotateForInterchange, false, AbsoluteURLs)); #ifndef QT_NO_CLIPBOARD 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 +152,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/PlatformBridge.h b/WebCore/platform/qt/PlatformBridge.h new file mode 100644 index 0000000..e478d8f --- /dev/null +++ b/WebCore/platform/qt/PlatformBridge.h @@ -0,0 +1,99 @@ +/* + * Copyright 2009, 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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 PlatformBridge_h +#define PlatformBridge_h + +#include "KURL.h" +#include "PlatformString.h" + +#include <wtf/Vector.h> + +// V8 bindings use the ARRAYSIZE_UNSAFE macro. This macro was copied +// from http://src.chromium.org/viewvc/chrome/trunk/src/base/basictypes.h +// +// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize, +// but can be used on anonymous types or types defined inside +// functions. It's less safe than arraysize as it accepts some +// (although not all) pointers. Therefore, you should use arraysize +// whenever possible. +// +// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type +// size_t. +// +// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error +// +// "warning: division by zero in ..." +// +// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer. +// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays. +// +// The following comments are on the implementation details, and can +// be ignored by the users. +// +// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in +// the array) and sizeof(*(arr)) (the # of bytes in one array +// element). If the former is divisible by the latter, perhaps arr is +// indeed an array, in which case the division result is the # of +// elements in the array. Otherwise, arr cannot possibly be an array, +// and we generate a compiler error to prevent the code from +// compiling. +// +// Since the size of bool is implementation-defined, we need to cast +// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final +// result has type size_t. +// +// This macro is not perfect as it wrongfully accepts certain +// pointers, namely where the pointer size is divisible by the pointee +// size. Since all our code has to go through a 32-bit compiler, +// where a pointer is 4 bytes, this means all pointers to a type whose +// size is 3 or greater than 4 will be (righteously) rejected. + +#define ARRAYSIZE_UNSAFE(a) \ + ((sizeof(a) / sizeof(*(a))) / \ + static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) + + +typedef struct NPObject NPObject; +typedef struct _NPP NPP_t; +typedef NPP_t* NPP; + +namespace WebCore { + +class Widget; + +// An interface to the embedding layer, which has the ability to answer +// questions about the system and so on... +// This is very similar to ChromiumBridge and the two are likely to converge +// in the future. +class PlatformBridge { +public: + static bool popupsAllowed(NPP npp); + // Plugin + static NPObject* pluginScriptableObject(Widget*); +}; + +} +#endif // PlatformBridge_h diff --git a/WebCore/platform/qt/SearchPopupMenuQt.cpp b/WebCore/platform/qt/PlatformBridgeQt.cpp index 187a5de..62065d7 100644 --- a/WebCore/platform/qt/SearchPopupMenuQt.cpp +++ b/WebCore/platform/qt/PlatformBridgeQt.cpp @@ -1,5 +1,7 @@ /* - * Copyright C 2006 Zack Rusin <zack@kde.org> + * This file is part of the WebKit project. + * + * 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 @@ -15,31 +17,35 @@ * 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 "SearchPopupMenu.h" +#include "PlatformBridge.h" -#include "AtomicString.h" +#include "Frame.h" +#include "PluginView.h" +#include "Widget.h" namespace WebCore { -SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client) - : PopupMenu(client) +bool PlatformBridge::popupsAllowed(NPP npp) { -} + if (npp && npp->ndata) + return static_cast<PluginView*>(npp->ndata)->arePopupsAllowed(); -void SearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&) -{ + return false; } -void SearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&) +NPObject* PlatformBridge::pluginScriptableObject(Widget* widget) { -} + if (!widget) + return 0; -bool SearchPopupMenu::enabled() -{ - return true; + if (!widget->isPluginView()) + return 0; + + PluginView* pluginView = static_cast<PluginView*>(widget); + return pluginView->npObject(); } } diff --git a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp index 12200f4..498bb88 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: @@ -187,6 +188,13 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad = false return VK_RIGHT; // (27) RIGHT ARROW key case Qt::Key_Down: return VK_DOWN; // (28) DOWN ARROW key + case Qt::Key_Enter: + case Qt::Key_Return: + return VK_RETURN; // (0D) Return key + case Qt::Key_Insert: + return VK_INSERT; // (2D) INS key + case Qt::Key_Delete: + return VK_DELETE; // (2E) DEL key default: return 0; } @@ -194,311 +202,380 @@ 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_SNAPSHOT; // (2A) PRINT key + case Qt::Key_Execute: + return VK_EXECUTE; // (2B) EXECUTE 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; } +} +static bool isVirtualKeyCodeRepresentingCharacter(int code) +{ + switch (code) { + case VK_SPACE: + case VK_0: + case VK_1: + case VK_2: + case VK_3: + case VK_4: + case VK_5: + case VK_6: + case VK_7: + case VK_8: + case VK_9: + case VK_A: + case VK_B: + case VK_C: + case VK_D: + case VK_E: + case VK_F: + case VK_G: + case VK_H: + case VK_I: + case VK_J: + case VK_K: + case VK_L: + case VK_M: + case VK_N: + case VK_O: + case VK_P: + case VK_Q: + case VK_R: + case VK_S: + case VK_T: + case VK_U: + case VK_V: + case VK_W: + case VK_X: + case VK_Y: + case VK_Z: + case VK_NUMPAD0: + case VK_NUMPAD1: + case VK_NUMPAD2: + case VK_NUMPAD3: + case VK_NUMPAD4: + case VK_NUMPAD5: + case VK_NUMPAD6: + case VK_NUMPAD7: + case VK_NUMPAD8: + case VK_NUMPAD9: + case VK_MULTIPLY: + case VK_ADD: + case VK_SEPARATOR: + case VK_SUBTRACT: + case VK_DECIMAL: + case VK_DIVIDE: + case VK_OEM_1: + case VK_OEM_PLUS: + case VK_OEM_COMMA: + case VK_OEM_MINUS: + case VK_OEM_PERIOD: + case VK_OEM_2: + case VK_OEM_3: + case VK_OEM_4: + case VK_OEM_5: + case VK_OEM_6: + case VK_OEM_7: + return true; + default: + return false; + } } PlatformKeyboardEvent::PlatformKeyboardEvent(QKeyEvent* event) @@ -509,13 +586,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; } @@ -535,7 +612,7 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool) we try to detect this situation and still set the text, to ensure that the general event handling sends a key press event after this disambiguation. */ - if (m_text.isEmpty() && m_windowsVirtualKeyCode && m_qtEvent->key() < Qt::Key_Escape) + if (m_text.isEmpty() && m_windowsVirtualKeyCode && isVirtualKeyCodeRepresentingCharacter(m_windowsVirtualKeyCode)) m_text.append(UChar(m_windowsVirtualKeyCode)); m_keyIdentifier = String(); @@ -549,6 +626,27 @@ 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; +} + +uint32_t PlatformKeyboardEvent::nativeModifiers() const +{ + ASSERT(m_qtEvent); + return m_qtEvent->nativeModifiers(); +} + +uint32_t PlatformKeyboardEvent::nativeScanCode() const +{ + ASSERT(m_qtEvent); + return m_qtEvent->nativeScanCode(); +} + } // 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/PlatformScreenQt.cpp b/WebCore/platform/qt/PlatformScreenQt.cpp index 8221760..db34e21 100644 --- a/WebCore/platform/qt/PlatformScreenQt.cpp +++ b/WebCore/platform/qt/PlatformScreenQt.cpp @@ -58,16 +58,30 @@ int screenDepth(Widget* w) int screenDepthPerComponent(Widget* w) { + int depth = QApplication::desktop()->screen(0)->depth(); if (w) { QWebPageClient* client = w->root()->hostWindow()->platformPageClient(); if (client) { QWidget* view = client->ownerWidget(); if (view) - return view->depth(); + depth = view->depth(); } } - return QApplication::desktop()->screen(0)->depth(); + // An interface to establish the actual number of bits per color + // doesn't exist in Qt, or probably at all, so use common-sense + // values for each screen depth and assume RGB/RGBA where appropriate. + // Per http://www.w3.org/TR/css3-mediaqueries/#color, 'If different color + // components are represented by different number of bits, the smallest + // number is used.' + switch (depth) { + case 8: + return 2; + case 32: + return 8; + default: + return qRound(depth / 3); + } } bool screenIsMonochrome(Widget* w) diff --git a/WebCore/platform/qt/PopupMenuQt.cpp b/WebCore/platform/qt/PopupMenuQt.cpp deleted file mode 100644 index 315b891..0000000 --- a/WebCore/platform/qt/PopupMenuQt.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is part of the popup menu implementation for <select> elements in WebCore. - * - * Copyright (C) 2008, 2009, 2010 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com - * Coypright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * - * 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 "PopupMenu.h" - -#include "Chrome.h" -#include "ChromeClientQt.h" -#include "FrameView.h" -#include "PopupMenuClient.h" -#include "QWebPageClient.h" -#include "QtAbstractWebPopup.h" - -namespace WebCore { - -PopupMenu::PopupMenu(PopupMenuClient* client) - : m_popupClient(client) - , m_popup(0) -{ -} - -PopupMenu::~PopupMenu() -{ - delete m_popup; -} - -void PopupMenu::show(const IntRect& rect, FrameView* view, int index) -{ - ChromeClientQt* chromeClient = static_cast<ChromeClientQt*>( - view->frame()->page()->chrome()->client()); - ASSERT(chromeClient); - - if (!m_popup) - m_popup = chromeClient->createSelectPopup(); - - m_popup->m_popupClient = m_popupClient; - m_popup->m_currentIndex = index; - m_popup->m_pageClient = chromeClient->platformPageClient(); - - QRect geometry(rect); - geometry.moveTopLeft(view->contentsToWindow(rect.topLeft())); - m_popup->m_geometry = geometry; - - m_popup->show(); - -} - -void PopupMenu::hide() -{ - m_popup->hide(); -} - -void PopupMenu::updateFromElement() -{ - client()->setTextFromItem(m_popupClient->selectedIndex()); -} - -bool PopupMenu::itemWritingDirectionIsNatural() -{ - return false; -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/QWebPageClient.h b/WebCore/platform/qt/QWebPageClient.h index 6d47c29..d8f4171 100644 --- a/WebCore/platform/qt/QWebPageClient.h +++ b/WebCore/platform/qt/QWebPageClient.h @@ -30,61 +30,71 @@ #include <QCursor> #endif +#if USE(ACCELERATED_COMPOSITING) +#include <GraphicsLayer.h> +#endif + +#include <QPalette> #include <QRect> QT_BEGIN_NAMESPACE -class QGraphicsItem; class QStyle; 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; virtual bool inputMethodEnabled() const = 0; #if USE(ACCELERATED_COMPOSITING) - // this gets called when we start/stop compositing. - virtual void setRootGraphicsLayer(QGraphicsItem* layer) {} + virtual void setRootGraphicsLayer(WebCore::PlatformLayer* layer) { } // this gets called when the compositor wants us to sync the layers // 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 + virtual void setInputMethodHints(Qt::InputMethodHints hint) = 0; + +#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 deleted file mode 100644 index f64287d..0000000 --- a/WebCore/platform/qt/QtAbstractWebPopup.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2009 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 "QtAbstractWebPopup.h" - -#include "PopupMenuClient.h" - - -namespace WebCore { - -QtAbstractWebPopup::QtAbstractWebPopup() - : m_popupClient(0) - , m_pageClient(0) - , m_currentIndex(-1) -{ -} - -QtAbstractWebPopup::~QtAbstractWebPopup() -{ -} - -void QtAbstractWebPopup::popupDidHide() -{ - Q_ASSERT(m_popupClient); - m_popupClient->popupDidHide(); -} - -void QtAbstractWebPopup::valueChanged(int index) -{ - Q_ASSERT(m_popupClient); - m_popupClient->valueChanged(index); -} - -QtAbstractWebPopup::ItemType QtAbstractWebPopup::itemType(int idx) const -{ - if (m_popupClient->itemIsSeparator(idx)) - return Separator; - if (m_popupClient->itemIsLabel(idx)) - return Group; - return Option; -} - -} // namespace WebCore diff --git a/WebCore/platform/qt/QtAbstractWebPopup.h b/WebCore/platform/qt/QtAbstractWebPopup.h deleted file mode 100644 index 93b4122..0000000 --- a/WebCore/platform/qt/QtAbstractWebPopup.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 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 QtAbstractWebPopup_h -#define QtAbstractWebPopup_h - -#include "PopupMenuClient.h" - -#include <QFont> -#include <QList> -#include <QRect> -#include <QWidget> - -class QWebPageClient; - -namespace WebCore { - -class QtAbstractWebPopup { -public: - enum ItemType { Option, Group, Separator }; - - ItemType itemType(int) const; - QString itemText(int idx) const { return m_popupClient->itemText(idx); } - 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(); } - - QWebPageClient* pageClient() const { return m_pageClient; } - QRect geometry() const { return m_geometry; } - int currentIndex() const { return m_currentIndex; } - - QtAbstractWebPopup(); - virtual ~QtAbstractWebPopup(); - - virtual void show() = 0; - virtual void hide() = 0; - - void popupDidHide(); - void valueChanged(int index); - - QFont font() { return m_popupClient->menuStyle().font().font(); } - -private: - friend class PopupMenu; - PopupMenuClient* m_popupClient; - QWebPageClient* m_pageClient; - int m_currentIndex; - QRect m_geometry; -}; - -} - -#endif // QtAbstractWebPopup_h diff --git a/WebCore/platform/qt/QtMobileWebStyle.cpp b/WebCore/platform/qt/QtMobileWebStyle.cpp new file mode 100644 index 0000000..240faa5 --- /dev/null +++ b/WebCore/platform/qt/QtMobileWebStyle.cpp @@ -0,0 +1,293 @@ +/* + * 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 "QtMobileWebStyle.h" + +#include "QtStyleOptionWebComboBox.h" + +#include <QPainter> +#include <QPixmapCache> +#include <QStyleOption> + +QtMobileWebStyle::QtMobileWebStyle() +{ +} + +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 QtMobileWebStyle::drawChecker(QPainter* painter, int size, QColor color) const +{ + int border = qMin(qMax(1, int(0.2 * size)), 6); + int checkerSize = qMax(size - 2 * border, 3); + 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 QtMobileWebStyle::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::lightGray : Qt::darkGray); + QPixmapCache::insert(key, result); + } + return result; +} + +void QtMobileWebStyle::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)); + const QPoint centerGradient(rect.bottomRight() * 0.7); + + QRadialGradient radialGradient(centerGradient, centerGradient.x() - 1); + radialGradient.setColorAt(0.0, Qt::white); + radialGradient.setColorAt(0.6, Qt::white); + radialGradient.setColorAt(1.0, color); + + painter->setPen(color); + painter->setBrush(color); + painter->drawEllipse(rect); + painter->setBrush(radialGradient); + 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 QtMobileWebStyle::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::lightGray : Qt::darkGray); + QPixmapCache::insert(key, result); + } + return result; +} + +void QtMobileWebStyle::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); + + QLinearGradient linearGradient(rect.topLeft(), rect.bottomLeft()); + if (disabled) { + linearGradient.setColorAt(0.0, Qt::lightGray); + linearGradient.setColorAt(0.5, Qt::white); + } else { + linearGradient.setColorAt(0.0, Qt::darkGray); + linearGradient.setColorAt(0.5, Qt::white); + } + + drawRectangularControlBackground(painter, QPen(disabled ? Qt::lightGray : Qt::darkGray), rect, linearGradient); + 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 QtMobileWebStyle::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 QtMobileWebStyle::drawSimpleComboButton(QPainter* painter, const QSize& size, QColor color) const +{ + int width = size.width(); + int midle = width >> 1; + QVector<QLine> lines(width + 1); + + for (int x = 0, y = 0; x < midle; x++, y++) { + lines[x] = QLine(x, y, x, y + 2); + lines[x + midle] = QLine(width - x - 1, y, width - x - 1, y + 2); + } + // Just to ensure the lines' intersection. + lines[width] = QLine(midle, midle, midle, midle + 2); + + painter->setPen(color); + painter->setBrush(color); + painter->drawLines(lines); +} + +QSize QtMobileWebStyle::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); +} + +QPixmap QtMobileWebStyle::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::lightGray : Qt::darkGray); + else + drawSimpleComboButton(&painter, imageSize, disabled ? Qt::lightGray : Qt::darkGray); + QPixmapCache::insert(key, result); + } + return result; +} + +void QtMobileWebStyle::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/QtMobileWebStyle.h b/WebCore/platform/qt/QtMobileWebStyle.h new file mode 100644 index 0000000..779bd26 --- /dev/null +++ b/WebCore/platform/qt/QtMobileWebStyle.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 QtMobileWebStyle_h +#define QtMobileWebStyle_h + +#include <QWindowsStyle> + +class QtMobileWebStyle : public QWindowsStyle { +public: + QtMobileWebStyle(); + + 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 // QtMobileWebStyle_h 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..7ef4ab7 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 "QtMobileWebStyle.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> @@ -69,8 +80,21 @@ namespace WebCore { using namespace HTMLNames; +inline static void initStyleOption(QWidget *widget, QStyleOption& option) +{ + if (widget) + option.initFrom(widget); + else { + /* + If a widget is not directly available for rendering, we fallback to default + value for an active widget. + */ + option.state = QStyle::State_Active | QStyle::State_Enabled; + } +} -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 +153,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 +164,45 @@ RenderThemeQt::RenderThemeQt(Page* page) m_buttonFontPixelSize = fontInfo.pixelSize(); #endif +#if USE(QT_MOBILE_THEME) + m_fallbackStyle = new QtMobileWebStyle; +#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 +211,7 @@ QStyle* RenderThemeQt::fallbackStyle() const QStyle* RenderThemeQt::qStyle() const { -#ifdef Q_WS_MAEMO_5 +#if USE(QT_MOBILE_THEME) return fallbackStyle(); #endif @@ -169,6 +225,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(themeQtMobileUserAgentStyleSheet, sizeof(themeQtMobileUserAgentStyleSheet)); +#endif + return result; +} + bool RenderThemeQt::supportsHover(const RenderStyle*) const { return true; @@ -207,11 +275,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,19 +365,35 @@ 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; int checkBoxWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &styleOption); + checkBoxWidth *= renderStyle->effectiveZoom(); size = QSize(checkBoxWidth, checkBoxWidth); break; } @@ -309,6 +401,7 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const QStyleOption styleOption; styleOption.state |= QStyle::State_Small; int radioWidth = style->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &styleOption); + radioWidth *= renderStyle->effectiveZoom(); size = QSize(radioWidth, radioWidth); break; } @@ -341,23 +434,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 +450,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 +460,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,16 +544,14 @@ 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()) return true; QStyleOptionButton option; - if (p.widget) - option.initFrom(p.widget); - + initStyleOption(p.widget, option); option.rect = r; option.state |= QStyle::State_Small; @@ -501,16 +575,14 @@ 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()) return true; QStyleOptionFrameV2 panel; - if (p.widget) - panel.initFrom(p.widget); - + initStyleOption(p.widget, panel); panel.rect = r; panel.lineWidth = findFrameLineWidth(qStyle()); panel.state |= QStyle::State_Sunken; @@ -535,7 +607,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,15 +642,14 @@ 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; - if (p.widget) - opt.initFrom(p.widget); + QtStyleOptionWebComboBox opt(o); + initStyleOption(p.widget, opt); initializeCommonQStyleOptions(opt, o); const QPoint topLeft = r.topLeft(); @@ -593,9 +664,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,16 +684,15 @@ 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; - if (p.widget) - option.initFrom(p.widget); + QtStyleOptionWebComboBox option(o); + initStyleOption(p.widget, option); initializeCommonQStyleOptions(option, o); option.rect = r; @@ -630,7 +704,78 @@ 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; + initStyleOption(p.widget, option); + 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); @@ -638,8 +783,8 @@ bool RenderThemeQt::paintSliderTrack(RenderObject* o, const RenderObject::PaintI return true; QStyleOptionSlider option; - if (p.widget) - option.initFrom(p.widget); + initStyleOption(p.widget, option); + option.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; ControlPart appearance = initializeCommonQStyleOptions(option, o); RenderSlider* renderSlider = toRenderSlider(o); @@ -684,7 +829,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 +841,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 +861,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 +875,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 +889,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 +917,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 +979,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 +1027,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 +1048,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 +1071,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 +1104,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 +1148,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::paintMediaSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeQt::paintMediaVolumeSliderThumb(RenderObject *o, const PaintInfo &paintInfo, const IntRect &r) { - HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o->parent()); + StylePainter p(this, paintInfo); + if (!p.isValid()) + return true; + + // Nothing to draw here, this is all done in the track + return false; +} + +bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) +{ + HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o); if (!mediaElement) return false; @@ -1000,6 +1208,39 @@ bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::P p.painter->setRenderHint(QPainter::Antialiasing, true); + paintMediaBackground(p.painter, r); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + 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 +1260,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..a517064 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; @@ -72,23 +72,21 @@ bool Scrollbar::contextMenu(const PlatformMouseEvent& event) const QPoint globalPos = QPoint(event.globalX(), event.globalY()); QAction* actionSelected = menu.exec(globalPos); - if (!actionSelected) - { /* Do nothing */ } - else if (actionSelected == actScrollHere) { + if (actionSelected == actScrollHere) { const QPoint pos = convertFromContainingWindow(event.pos()); moveThumb(horizontal ? pos.x() : pos.y()); } else if (actionSelected == actScrollTop) - setValue(0); + scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByDocument); else if (actionSelected == actScrollBottom) - setValue(maximum()); + scroll(horizontal ? ScrollRight : ScrollDown, ScrollByDocument); else if (actionSelected == actPageUp) - scroll(horizontal ? ScrollLeft: ScrollUp, ScrollByPage, 1); + scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByPage); else if (actionSelected == actPageDown) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByPage, 1); + scroll(horizontal ? ScrollRight : ScrollDown, ScrollByPage); else if (actionSelected == actScrollUp) - scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByLine, 1); + scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByLine); else if (actionSelected == actScrollDown) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByLine, 1); + scroll(horizontal ? ScrollRight : ScrollDown, ScrollByLine); #endif // QT_NO_CONTEXTMENU return true; } 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..d7b5104 100644 --- a/WebCore/platform/qt/TemporaryLinkStubs.cpp +++ b/WebCore/platform/qt/TemporaryLinkStubsQt.cpp @@ -33,28 +33,22 @@ #include "config.h" #include "AXObjectCache.h" -#include "DNS.h" -#include "CString.h" #include "CachedResource.h" #include "CookieJar.h" +#include "CookieStorage.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 +62,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; @@ -91,6 +88,19 @@ bool PluginDatabase::isPreferredPluginDirectory(const String& directory) notImplemented(); return false; } + +void PluginView::privateBrowsingStateChanged(bool) +{ +} + +PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance() +{ + return 0; +} + +void PluginView::setJavaScriptPaused(bool) +{ +} #endif namespace WebCore { @@ -114,6 +124,11 @@ float userIdleTime() } #endif +void setCookieStoragePrivateBrowsingEnabled(bool) +{ + notImplemented(); +} + } // vim: ts=4 sw=4 et 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..e64d655 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,17 +71,17 @@ void Widget::setFrameRect(const IntRect& rect) frameRectsChanged(); } -void Widget::setFocus() +void Widget::setFocus(bool focused) { } void Widget::setCursor(const Cursor& cursor) { #ifndef QT_NO_CURSOR - QWebPageClient* pageClient = root()->hostWindow()->platformPageClient(); - - if (pageClient) - pageClient->setCursor(cursor.impl()); + ScrollView* view = root(); + if (!view) + return; + view->hostWindow()->setCursor(cursor); #endif } |