diff options
Diffstat (limited to 'WebCore/platform/qt')
42 files changed, 0 insertions, 6476 deletions
diff --git a/WebCore/platform/qt/ClipboardQt.cpp b/WebCore/platform/qt/ClipboardQt.cpp deleted file mode 100644 index c14d362..0000000 --- a/WebCore/platform/qt/ClipboardQt.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2010 Sencha, Inc. 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 "ClipboardQt.h" - -#include "CachedImage.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 "NotImplemented.h" -#include "PlatformString.h" -#include "Range.h" -#include "RenderImage.h" -#include "markup.h" -#include <wtf/text/StringHash.h> - -#include <QApplication> -#include <QClipboard> -#include <QList> -#include <QMimeData> -#include <QStringList> -#include <QTextCodec> -#include <QUrl> -#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, DragAndDrop) - , m_readableData(readableClipboard) - , m_writableData(0) -{ - Q_ASSERT(policy == ClipboardReadable || policy == ClipboardTypesReadable); -} - -ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, ClipboardType clipboardType) - : Clipboard(policy, clipboardType) - , m_readableData(0) - , m_writableData(0) -{ - Q_ASSERT(policy == ClipboardReadable || policy == ClipboardWritable || policy == ClipboardNumb); - -#ifndef QT_NO_CLIPBOARD - if (policy != ClipboardWritable) { - Q_ASSERT(isForCopyAndPaste()); - m_readableData = QApplication::clipboard()->mimeData(); - } -#endif -} - -ClipboardQt::~ClipboardQt() -{ - if (m_writableData && isForCopyAndPaste()) - m_writableData = 0; - else - delete m_writableData; - m_readableData = 0; -} - -void ClipboardQt::clearData(const String& type) -{ - if (policy() != ClipboardWritable) - return; - - if (m_writableData) { - m_writableData->removeFormat(type); - if (m_writableData->formats().isEmpty()) { - if (isForDragAndDrop()) - delete m_writableData; - m_writableData = 0; - } - } -#ifndef QT_NO_CLIPBOARD - if (isForCopyAndPaste()) - QApplication::clipboard()->setMimeData(m_writableData); -#endif -} - -void ClipboardQt::clearAllData() -{ - if (policy() != ClipboardWritable) - return; - -#ifndef QT_NO_CLIPBOARD - if (isForCopyAndPaste()) - QApplication::clipboard()->setMimeData(0); - else -#endif - delete m_writableData; - m_writableData = 0; -} - -String ClipboardQt::getData(const String& type, bool& success) const -{ - - if (policy() != ClipboardReadable) { - success = false; - 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 rawData = m_readableData->data(type); - QString data = QTextCodec::codecForName("UTF-16")->toUnicode(rawData); - success = !data.isEmpty(); - return data; -} - -bool ClipboardQt::setData(const String& type, const String& data) -{ - if (policy() != ClipboardWritable) - return false; - - if (!m_writableData) - m_writableData = new QMimeData; - - 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 (isForCopyAndPaste()) - QApplication::clipboard()->setMimeData(m_writableData); -#endif - return true; -} - -// extensions beyond IE's API -HashSet<String> ClipboardQt::types() const -{ - if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable) - return HashSet<String>(); - - ASSERT(m_readableData); - HashSet<String> result; - QStringList formats = m_readableData->formats(); - for (int i = 0; i < formats.count(); ++i) - result.add(formats.at(i)); - return result; -} - -PassRefPtr<FileList> ClipboardQt::files() const -{ - if (policy() != ClipboardReadable || !m_readableData->hasUrls()) - return FileList::create(); - - RefPtr<FileList> fileList = FileList::create(); - QList<QUrl> urls = m_readableData->urls(); - - for (int i = 0; i < urls.size(); i++) { - QUrl url = urls[i]; - if (url.scheme() != QLatin1String("file")) - continue; - fileList->append(File::create(url.toLocalFile())); - } - - return fileList.release(); -} - -void ClipboardQt::setDragImage(CachedImage* image, const IntPoint& point) -{ - setDragImage(image, 0, point); -} - -void ClipboardQt::setDragImageElement(Node* node, const IntPoint& point) -{ - setDragImage(0, node, point); -} - -void ClipboardQt::setDragImage(CachedImage* image, Node *node, const IntPoint &loc) -{ - if (policy() != ClipboardImageWritable && policy() != ClipboardWritable) - return; - - if (m_dragImage) - m_dragImage->removeClient(this); - m_dragImage = image; - if (m_dragImage) - m_dragImage->addClient(this); - - m_dragLoc = loc; - m_dragImageElement = node; -} - -DragImageRef ClipboardQt::createDragImage(IntPoint& dragLoc) const -{ - if (!m_dragImage) - return 0; - dragLoc = m_dragLoc; - return m_dragImage->image()->nativeImageForCurrentFrame(); -} - - -static CachedImage* getCachedImage(Element* element) -{ - // Attempt to pull CachedImage from element - ASSERT(element); - RenderObject* renderer = element->renderer(); - if (!renderer || !renderer->isImage()) - return 0; - - RenderImage* image = toRenderImage(renderer); - if (image->cachedImage() && !image->cachedImage()->errorOccurred()) - return image->cachedImage(); - - return 0; -} - -void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame) -{ - ASSERT(frame); - - // 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(); - if (pixmap) - m_writableData->setImageData(*pixmap); - - AtomicString imageURL = element->getAttribute(HTMLNames::srcAttr); - if (imageURL.isEmpty()) - return; - - KURL fullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL)); - if (fullURL.isEmpty()) - return; - - QList<QUrl> urls; - urls.append(url); - urls.append(fullURL); - - m_writableData->setText(title); - m_writableData->setUrls(urls); -#ifndef QT_NO_CLIPBOARD - if (isForCopyAndPaste()) - QApplication::clipboard()->setMimeData(m_writableData); -#endif -} - -void ClipboardQt::writeURL(const KURL& url, const String& title, Frame* frame) -{ - ASSERT(frame); - - QList<QUrl> urls; - urls.append(frame->document()->completeURL(url.string())); - if (!m_writableData) - m_writableData = new QMimeData; - m_writableData->setUrls(urls); - m_writableData->setText(title); -#ifndef QT_NO_CLIPBOARD - if (isForCopyAndPaste()) - QApplication::clipboard()->setMimeData(m_writableData); -#endif -} - -void ClipboardQt::writeRange(Range* range, Frame* frame) -{ - ASSERT(range); - ASSERT(frame); - - if (!m_writableData) - m_writableData = new QMimeData; - QString text = frame->editor()->selectedText(); - text.replace(QChar(0xa0), QLatin1Char(' ')); - m_writableData->setText(text); - m_writableData->setHtml(createMarkup(range, 0, AnnotateForInterchange, false, AbsoluteURLs)); -#ifndef QT_NO_CLIPBOARD - if (isForCopyAndPaste()) - QApplication::clipboard()->setMimeData(m_writableData); -#endif -} - -void ClipboardQt::writePlainText(const String& str) -{ - if (!m_writableData) - m_writableData = new QMimeData; - QString text = str; - text.replace(QChar(0xa0), QLatin1Char(' ')); - m_writableData->setText(text); -#ifndef QT_NO_CLIPBOARD - if (isForCopyAndPaste()) - QApplication::clipboard()->setMimeData(m_writableData); -#endif -} - -bool ClipboardQt::hasData() -{ - const QMimeData *data = m_readableData ? m_readableData : m_writableData; - if (!data) - return false; - return data->formats().count() > 0; -} - -} diff --git a/WebCore/platform/qt/ClipboardQt.h b/WebCore/platform/qt/ClipboardQt.h deleted file mode 100644 index 5aca1a6..0000000 --- a/WebCore/platform/qt/ClipboardQt.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. 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. - */ - -#ifndef ClipboardQt_h -#define ClipboardQt_h - -#include "Clipboard.h" -#include "CachedResourceClient.h" - -QT_BEGIN_NAMESPACE -class QMimeData; -QT_END_NAMESPACE - -namespace WebCore { - - class CachedImage; - - // State available during IE's events for drag and drop and copy/paste - class ClipboardQt : public Clipboard, public CachedResourceClient { - public: - static PassRefPtr<ClipboardQt> create(ClipboardAccessPolicy policy, const QMimeData* readableClipboard) - { - return adoptRef(new ClipboardQt(policy, readableClipboard)); - } - static PassRefPtr<ClipboardQt> create(ClipboardAccessPolicy policy, ClipboardType clipboardType = CopyAndPaste) - { - return adoptRef(new ClipboardQt(policy, clipboardType)); - } - virtual ~ClipboardQt(); - - void clearData(const String& type); - void clearAllData(); - String getData(const String& type, bool& success) const; - bool setData(const String& type, const String& data); - - // extensions beyond IE's API - virtual HashSet<String> types() const; - virtual PassRefPtr<FileList> files() const; - - void setDragImage(CachedImage*, const IntPoint&); - void setDragImageElement(Node*, const IntPoint&); - - virtual DragImageRef createDragImage(IntPoint& dragLoc) const; - virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*); - virtual void writeURL(const KURL&, const String&, Frame*); - virtual void writeRange(Range*, Frame*); - virtual void writePlainText(const String&); - - virtual bool hasData(); - - QMimeData* clipboardData() const { return m_writableData; } - void invalidateWritableData() { m_writableData = 0; } - - private: - ClipboardQt(ClipboardAccessPolicy, const QMimeData* readableClipboard); - - // Clipboard is writable so it will create its own QMimeData object - ClipboardQt(ClipboardAccessPolicy, ClipboardType); - - void setDragImage(CachedImage*, Node*, const IntPoint& loc); - - const QMimeData* m_readableData; - QMimeData* m_writableData; - }; -} - -#endif // ClipboardQt_h diff --git a/WebCore/platform/qt/ContextMenuItemQt.cpp b/WebCore/platform/qt/ContextMenuItemQt.cpp deleted file mode 100644 index 2a36b87..0000000 --- a/WebCore/platform/qt/ContextMenuItemQt.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> - * - * 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 "ContextMenuItem.h" - -#include "ContextMenu.h" - -namespace WebCore { - -ContextMenuItem::ContextMenuItem(ContextMenu* subMenu) -{ - m_platformDescription.type = SubmenuType; - m_platformDescription.action = ContextMenuItemTagNoAction; - if (subMenu) - setSubMenu(subMenu); -} - -ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, - const String& title, ContextMenu* subMenu) -{ - m_platformDescription.type = type; - m_platformDescription.action = action; - m_platformDescription.title = title; - if (subMenu) - setSubMenu(subMenu); -} - -ContextMenuItem::ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, bool, bool) -{ - // FIXME: Implement -} - -ContextMenuItem::ContextMenuItem(ContextMenuAction, const String&, bool, bool, Vector<ContextMenuItem>&) -{ - // FIXME: Implement -} - -ContextMenuItem::~ContextMenuItem() -{ -} - -PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() -{ - return m_platformDescription; -} - -ContextMenuItemType ContextMenuItem::type() const -{ - return m_platformDescription.type; -} - -void ContextMenuItem::setType(ContextMenuItemType type) -{ - m_platformDescription.type = type; -} - -ContextMenuAction ContextMenuItem::action() const -{ - return m_platformDescription.action; -} - -void ContextMenuItem::setAction(ContextMenuAction action) -{ - m_platformDescription.action = action; -} - -String ContextMenuItem::title() const -{ - return m_platformDescription.title; -} - -void ContextMenuItem::setTitle(const String& title) -{ - m_platformDescription.title = title; -} - - -PlatformMenuDescription ContextMenuItem::platformSubMenu() const -{ - return &m_platformDescription.subMenuItems; -} - -void ContextMenuItem::setSubMenu(ContextMenu* menu) -{ - m_platformDescription.subMenuItems = *menu->platformDescription(); -} - -void ContextMenuItem::setSubMenu(Vector<ContextMenuItem>&) -{ - // FIXME: Implement -} - -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; -} - -bool ContextMenuItem::enabled() const -{ - return m_platformDescription.enabled; -} - -} -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/ContextMenuQt.cpp b/WebCore/platform/qt/ContextMenuQt.cpp deleted file mode 100644 index c877642..0000000 --- a/WebCore/platform/qt/ContextMenuQt.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> - * - * 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 "ContextMenu.h" - -#include <Document.h> -#include <Frame.h> -#include <FrameView.h> -#include <QAction> -#include <wtf/Assertions.h> - -namespace WebCore { - -ContextMenu::ContextMenu() -{ -} - -ContextMenu::~ContextMenu() -{ -} - -void ContextMenu::appendItem(ContextMenuItem& item) -{ - m_items.append(item); -} - -unsigned ContextMenu::itemCount() const -{ - return m_items.count(); -} - -void ContextMenu::insertItem(unsigned position, ContextMenuItem& item) -{ - m_items.insert(position, item); -} - -void ContextMenu::setPlatformDescription(PlatformMenuDescription) -{ - // doesn't make sense -} - -PlatformMenuDescription ContextMenu::platformDescription() const -{ - return &m_items; -} - -PlatformMenuDescription ContextMenu::releasePlatformDescription() -{ - return PlatformMenuDescription(); -} - -Vector<ContextMenuItem> contextMenuItemVector(PlatformMenuDescription) -{ - // FIXME - Implement - return Vector<ContextMenuItem>(); -} - -PlatformMenuDescription platformMenuDescription(Vector<ContextMenuItem>& menuItemVector) -{ - // FIXME - Implement - return 0; -} - -} -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/CookieJarQt.cpp b/WebCore/platform/qt/CookieJarQt.cpp deleted file mode 100644 index e5d36ba..0000000 --- a/WebCore/platform/qt/CookieJarQt.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2006 George Staikos <staikos@kde.org> - * - * 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 "CookieJar.h" - -#include "Cookie.h" -#include "Document.h" -#include "KURL.h" -#include "QtNAMThreadSafeProxy.h" -#include "NetworkingContext.h" -#include "PlatformString.h" - -#include "qwebpage.h" -#include "qwebframe.h" -#include "FrameLoaderClientQt.h" -#include <QNetworkAccessManager> -#include <QNetworkCookie> -#include <QStringList> - -namespace WebCore { - - -static QNetworkAccessManager *networkAccessManager(const Document *document) -{ - if (!document) - return 0; - Frame *frame = document->frame(); - if (!frame) - return 0; - FrameLoader *loader = frame->loader(); - if (!loader) - return 0; - return loader->networkingContext()->networkAccessManager(); -} - -void setCookies(Document* document, const KURL& url, const String& value) -{ - QNetworkAccessManager* manager = networkAccessManager(document); - if (!manager) - return; - - // Create the manipulator on the heap to let it live until the - // async request is picked by the other thread's event loop. - QtNAMThreadSafeProxy* managerProxy = new QtNAMThreadSafeProxy(manager); - managerProxy->setCookies(url, value); - managerProxy->deleteLater(); -} - -String cookies(const Document* document, const KURL& url) -{ - QNetworkAccessManager* manager = networkAccessManager(document); - if (!manager) - return String(); - - QtNAMThreadSafeProxy managerProxy(manager); - QList<QNetworkCookie> cookies = managerProxy.cookiesForUrl(url); - if (cookies.isEmpty()) - return String(); - - QStringList resultCookies; - foreach (QNetworkCookie networkCookie, cookies) { - if (networkCookie.isHttpOnly()) - continue; - resultCookies.append(QString::fromAscii( - networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData())); - } - - return resultCookies.join(QLatin1String("; ")); -} - -String cookieRequestHeaderFieldValue(const Document* document, const KURL &url) -{ - QNetworkAccessManager* manager = networkAccessManager(document); - if (!manager) - return String(); - - QtNAMThreadSafeProxy managerProxy(manager); - QList<QNetworkCookie> cookies = managerProxy.cookiesForUrl(url); - if (cookies.isEmpty()) - return String(); - - QStringList resultCookies; - foreach (QNetworkCookie networkCookie, cookies) { - resultCookies.append(QString::fromAscii( - networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData())); - } - - return resultCookies.join(QLatin1String("; ")); -} - -bool cookiesEnabled(const Document* document) -{ - return networkAccessManager(document); -} - -bool getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies) -{ - // FIXME: Not yet implemented - rawCookies.clear(); - return false; // return true when implemented -} - -void deleteCookie(const Document*, const KURL&, const String&) -{ - // FIXME: Not yet implemented -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/CursorQt.cpp b/WebCore/platform/qt/CursorQt.cpp deleted file mode 100644 index 5883600..0000000 --- a/WebCore/platform/qt/CursorQt.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> - * 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. - * - * 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 "Cursor.h" - -#include "Image.h" -#include "IntPoint.h" - -#include "NotImplemented.h" - -#include <stdio.h> -#include <stdlib.h> - -#undef CopyCursor - -namespace WebCore { - -Cursor::Cursor(const Cursor& other) - : 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() -{ -#ifndef QT_NO_CURSOR - delete m_platformCursor; -#endif -} - -Cursor& Cursor::operator=(const Cursor& other) -{ - 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 - return *this; -} - -#ifndef QT_NO_CURSOR -static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot) -{ - IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot); - return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y()); -} -#endif - -void Cursor::ensurePlatformCursor() const -{ -#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 -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/DragDataQt.cpp b/WebCore/platform/qt/DragDataQt.cpp deleted file mode 100644 index 4033123..0000000 --- a/WebCore/platform/qt/DragDataQt.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2007, 2008, 2009 Apple Inc. 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 "DragData.h" - -#include "Document.h" -#include "DocumentFragment.h" -#include "markup.h" - -#include <QColor> -#include <QList> -#include <QMimeData> -#include <QUrl> - -namespace WebCore { - -bool DragData::canSmartReplace() const -{ - return false; -} - -bool DragData::containsColor() const -{ - if (!m_platformDragData) - return false; - return m_platformDragData->hasColor(); -} - -bool DragData::containsFiles() const -{ - if (!m_platformDragData) - return false; - QList<QUrl> urls = m_platformDragData->urls(); - foreach (const QUrl &url, urls) { - if (!url.toLocalFile().isEmpty()) - return true; - } - return false; -} - -void DragData::asFilenames(Vector<String>& result) const -{ - if (!m_platformDragData) - return; - QList<QUrl> urls = m_platformDragData->urls(); - foreach (const QUrl &url, urls) { - QString file = url.toLocalFile(); - if (!file.isEmpty()) - result.append(file); - } -} - -bool DragData::containsPlainText() const -{ - if (!m_platformDragData) - return false; - return m_platformDragData->hasText() || m_platformDragData->hasUrls(); -} - -String DragData::asPlainText() const -{ - if (!m_platformDragData) - return String(); - String text = m_platformDragData->text(); - if (!text.isEmpty()) - return text; - - // FIXME: Should handle rich text here - return asURL(DoNotConvertFilenames, 0); -} - -Color DragData::asColor() const -{ - if (!m_platformDragData) - return Color(); - return qvariant_cast<QColor>(m_platformDragData->colorData()); -} - -bool DragData::containsCompatibleContent() const -{ - if (!m_platformDragData) - return false; - return containsColor() || containsURL() || m_platformDragData->hasHtml() || m_platformDragData->hasText(); -} - -bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const -{ - // FIXME: Use filenamePolicy. - if (!m_platformDragData) - return false; - return m_platformDragData->hasUrls(); -} - -String DragData::asURL(FilenameConversionPolicy filenamePolicy, String*) const -{ - // FIXME: Use filenamePolicy. - if (!m_platformDragData) - return String(); - QList<QUrl> urls = m_platformDragData->urls(); - - if (urls.isEmpty()) - return String(); - - return encodeWithURLEscapeSequences(urls.first().toString()); -} - -PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const -{ - if (m_platformDragData && m_platformDragData->hasHtml()) - return createFragmentFromMarkup(doc, m_platformDragData->html(), "", FragmentScriptingNotAllowed); - - return 0; -} - -} - diff --git a/WebCore/platform/qt/DragImageQt.cpp b/WebCore/platform/qt/DragImageQt.cpp deleted file mode 100644 index 90b1bbc..0000000 --- a/WebCore/platform/qt/DragImageQt.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. 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 "DragImage.h" - -#include "CachedImage.h" -#include "Image.h" - -namespace WebCore { - -IntSize dragImageSize(DragImageRef image) -{ - if (!image) - return IntSize(); - - return image->size(); -} - -void deleteDragImage(DragImageRef image) -{ - delete image; -} - -DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) -{ - if (!image) - return 0; - - int scaledWidth = image->width() * scale.width(); - int scaledHeight = image->height() * scale.height(); - - *image = image->scaled(scaledWidth, scaledHeight); - return image; -} - -DragImageRef dissolveDragImageToFraction(DragImageRef image, float) -{ - return image; -} - -DragImageRef createDragImageFromImage(Image* image) -{ - if (!image) - return 0; - - return new QPixmap(*image->nativeImageForCurrentFrame()); -} - -DragImageRef createDragImageIconForCachedImage(CachedImage*) -{ - return 0; -} - -} diff --git a/WebCore/platform/qt/EventLoopQt.cpp b/WebCore/platform/qt/EventLoopQt.cpp deleted file mode 100644 index 39bb54c..0000000 --- a/WebCore/platform/qt/EventLoopQt.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2008 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 "EventLoop.h" - -#include <QCoreApplication> - -namespace WebCore { - -void EventLoop::cycle() -{ - QCoreApplication::processEvents(); -} - -} // namespace WebCore diff --git a/WebCore/platform/qt/FileChooserQt.cpp b/WebCore/platform/qt/FileChooserQt.cpp deleted file mode 100644 index 8b1df0a..0000000 --- a/WebCore/platform/qt/FileChooserQt.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (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 "FileChooser.h" - -#include "Font.h" -#include "LocalizedStrings.h" -#include <QCoreApplication> -#include <QFontMetrics> - -namespace WebCore { - -String FileChooser::basenameForWidth(const Font& f, int width) const -{ - if (width <= 0) - return String(); - - String string; - if (m_filenames.isEmpty()) - string = fileButtonNoFileSelectedLabel(); - else if (m_filenames.size() == 1) { - String fname = m_filenames[0]; - QFontMetrics fm(f.font()); - string = fm.elidedText(fname, Qt::ElideLeft, width); - } else { - int n = m_filenames.size(); - string = QCoreApplication::translate("QWebPage", "%n file(s)", - "number of chosen file", - QCoreApplication::CodecForTr, n); - } - - return string; -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/FileSystemQt.cpp b/WebCore/platform/qt/FileSystemQt.cpp deleted file mode 100644 index d88a967..0000000 --- a/WebCore/platform/qt/FileSystemQt.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) 2007 Staikos Computing Services Inc. - * Copyright (C) 2007 Holger Hans Peter Freyther - * Copyright (C) 2008 Apple, Inc. All rights reserved. - * Copyright (C) 2008 Collabora, Ltd. All rights reserved. - * Copyright (C) 2010 Sencha, Inc. 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. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 "FileSystem.h" - -#include "PlatformString.h" -#include <QDateTime> -#include <QDir> -#include <QFile> -#include <QFileInfo> -#include <QTemporaryFile> -#include <wtf/text/CString.h> - -namespace WebCore { - -bool fileExists(const String& path) -{ - return QFile::exists(path); -} - - -bool deleteFile(const String& path) -{ - return QFile::remove(path); -} - -bool deleteEmptyDirectory(const String& path) -{ - return QDir::root().rmdir(path); -} - -bool getFileSize(const String& path, long long& result) -{ - QFileInfo info(path); - result = info.size(); - return info.exists(); -} - -bool getFileModificationTime(const String& path, time_t& result) -{ - QFileInfo info(path); - result = info.lastModified().toTime_t(); - return info.exists(); -} - -bool makeAllDirectories(const String& path) -{ - return QDir::root().mkpath(path); -} - -String pathByAppendingComponent(const String& path, const String& component) -{ - return QDir::toNativeSeparators(QDir(path).filePath(component)); -} - -String homeDirectoryPath() -{ - return QDir::homePath(); -} - -String pathGetFileName(const String& path) -{ - return QFileInfo(path).fileName(); -} - -String directoryName(const String& path) -{ - return QFileInfo(path).absolutePath(); -} - -Vector<String> listDirectory(const String& path, const String& filter) -{ - Vector<String> entries; - - QStringList nameFilters; - if (!filter.isEmpty()) - nameFilters.append(filter); - QFileInfoList fileInfoList = QDir(path).entryInfoList(nameFilters, QDir::AllEntries | QDir::NoDotAndDotDot); - foreach (const QFileInfo fileInfo, fileInfoList) { - String entry = String(fileInfo.canonicalFilePath()); - entries.append(entry); - } - - return entries; -} - -CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle) -{ -#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(); -} - -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; -} - -void closeFile(PlatformFileHandle& handle) -{ - if (handle) { - handle->close(); - delete handle; - } -} - -long long seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin) -{ - if (handle) { - long long current = 0; - - switch (origin) { - case SeekFromBeginning: - break; - case SeekFromCurrent: - current = handle->pos(); - break; - case SeekFromEnd: - current = handle->size(); - break; - } - - // Add the offset to the current position and seek to the new position - // Return our new position if the seek is successful - current += offset; - if (handle->seek(current)) - return current; - else - return -1; - } - - return -1; -} - -int writeToFile(PlatformFileHandle handle, const char* data, int length) -{ - if (handle && handle->exists() && handle->isWritable()) - return handle->write(data, length); - - return 0; -} - -bool unloadModule(PlatformModule module) -{ -#if defined(Q_WS_MAC) - CFRelease(module); - return true; - -#elif defined(Q_OS_WIN) - return ::FreeLibrary(module); - -#else -#ifndef QT_NO_LIBRARY - if (module->unload()) { - delete module; - return true; - } -#endif - return false; -#endif -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/GeolocationServiceQt.cpp b/WebCore/platform/qt/GeolocationServiceQt.cpp deleted file mode 100644 index f4379b2..0000000 --- a/WebCore/platform/qt/GeolocationServiceQt.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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); - -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) - m_lastPosition = Geoposition::create(coordinates.release(), geoPosition.timestamp().toMSecsSinceEpoch()); -#else - QDateTime timestamp = geoPosition.timestamp(); - m_lastPosition = Geoposition::create(coordinates.release(), (timestamp.toTime_t() * 1000.00) + timestamp.time().msec()); -#endif - 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 deleted file mode 100644 index 2525e47..0000000 --- a/WebCore/platform/qt/GeolocationServiceQt.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 deleted file mode 100644 index f6d2a86..0000000 --- a/WebCore/platform/qt/KURLQt.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 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 "KURL.h" - -#include "NotImplemented.h" -#include "TextEncoding.h" -#include "qurl.h" -#include <wtf/text/CString.h> - -namespace WebCore { - -KURL::KURL(const QUrl& url) -{ - *this = KURL(KURL(), url.toEncoded().constData(), UTF8Encoding()); -} - -KURL::operator QUrl() const -{ - QString str = QString::fromRawData(reinterpret_cast<const QChar*>(m_string.characters()), m_string.length()); - QByteArray ba = str.toUtf8(); - - QUrl url = QUrl::fromEncoded(ba); - return url; -} - -String KURL::fileSystemPath() const -{ - if (!isValid() || !protocolIs("file")) - return String(); - - return String(path()); -} - -} - diff --git a/WebCore/platform/qt/LanguageQt.cpp b/WebCore/platform/qt/LanguageQt.cpp deleted file mode 100644 index 71e554f..0000000 --- a/WebCore/platform/qt/LanguageQt.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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/LoggingQt.cpp b/WebCore/platform/qt/LoggingQt.cpp deleted file mode 100644 index 817887d..0000000 --- a/WebCore/platform/qt/LoggingQt.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2008 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 "Logging.h" - -#include "PlatformString.h" -#include <QDebug> -#include <QStringList> - -namespace WebCore { - -void InitializeLoggingChannelsIfNecessary() -{ - static bool haveInitializedLoggingChannels = false; - if (haveInitializedLoggingChannels) - return; - - haveInitializedLoggingChannels = true; - - QByteArray loggingEnv = qgetenv("QT_WEBKIT_LOG"); - if (loggingEnv.isEmpty()) - return; - -#if defined(NDEBUG) - qWarning("This is a release build. Setting QT_WEBKIT_LOG will have no effect."); -#else - QStringList channels = QString::fromLocal8Bit(loggingEnv).split(QLatin1String(",")); - for (int i = 0; i < channels.count(); i++) { - if (WTFLogChannel* channel = getChannelFromName(channels.at(i))) - channel->state = WTFLogChannelOn; - } - - // By default we log calls to notImplemented(). This can be turned - // off by setting the environment variable DISABLE_NI_WARNING to 1 - LogNotYetImplemented.state = WTFLogChannelOn; -#endif -} - -} // namespace WebCore diff --git a/WebCore/platform/qt/MIMETypeRegistryQt.cpp b/WebCore/platform/qt/MIMETypeRegistryQt.cpp deleted file mode 100644 index 12db891..0000000 --- a/WebCore/platform/qt/MIMETypeRegistryQt.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) - * - * 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 "MIMETypeRegistry.h" - -namespace WebCore { - -struct ExtensionMap { - const char* extension; - const char* mimeType; -}; - -static const ExtensionMap extensionMap[] = { - { "bmp", "image/bmp" }, - { "css", "text/css" }, - { "gif", "image/gif" }, - { "html", "text/html" }, - { "htm", "text/html" }, - { "ico", "image/x-icon" }, - { "jpeg", "image/jpeg" }, - { "jpg", "image/jpeg" }, - { "js", "application/x-javascript" }, - { "mng", "video/x-mng" }, - { "pbm", "image/x-portable-bitmap" }, - { "pgm", "image/x-portable-graymap" }, - { "pdf", "application/pdf" }, - { "png", "image/png" }, - { "ppm", "image/x-portable-pixmap" }, - { "rss", "application/rss+xml" }, - { "svg", "image/svg+xml" }, - { "text", "text/plain" }, - { "tif", "image/tiff" }, - { "tiff", "image/tiff" }, - { "txt", "text/plain" }, - { "xbm", "image/x-xbitmap" }, - { "xml", "text/xml" }, - { "xpm", "image/x-xpm" }, - { "xsl", "text/xsl" }, - { "xhtml", "application/xhtml+xml" }, - { "wml", "text/vnd.wap.wml" }, - { "wmlc", "application/vnd.wap.wmlc" }, - { 0, 0 } -}; - -String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) -{ - String s = ext.lower(); - - const ExtensionMap *e = extensionMap; - while (e->extension) { - if (s == e->extension) - return e->mimeType; - ++e; - } - - 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 deleted file mode 100644 index b98e84e..0000000 --- a/WebCore/platform/qt/PasteboardQt.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2008 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 "Pasteboard.h" - -#include "DocumentFragment.h" -#include "Editor.h" -#include "Frame.h" -#include "Image.h" -#include "markup.h" -#include "RenderImage.h" - -#include <qdebug.h> -#include <qclipboard.h> -#include <qmimedata.h> -#include <qapplication.h> -#include <qurl.h> - -#define methodDebug() qDebug() << "PasteboardQt: " << __FUNCTION__; - -namespace WebCore { - -Pasteboard::Pasteboard() - : m_selectionMode(false) -{ -} - -Pasteboard* Pasteboard::generalPasteboard() -{ - static Pasteboard* pasteboard = 0; - if (!pasteboard) - pasteboard = new Pasteboard(); - return pasteboard; -} - -void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) -{ - QMimeData* md = new QMimeData; - QString text = frame->editor()->selectedText(); - text.replace(QChar(0xa0), QLatin1Char(' ')); - md->setText(text); - - 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() -{ -#ifndef QT_NO_CLIPBOARD - if (QApplication::clipboard()->mimeData()->hasFormat((QLatin1String("application/vnd.qtwebkit.smartpaste")))) - return true; -#endif - return false; -} - -String Pasteboard::plainText(Frame*) -{ -#ifndef QT_NO_CLIPBOARD - return QApplication::clipboard()->text(m_selectionMode ? - QClipboard::Selection : QClipboard::Clipboard); -#else - return String(); -#endif -} - -PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, - bool allowPlainText, bool& chosePlainText) -{ -#ifndef QT_NO_CLIPBOARD - const QMimeData* mimeData = QApplication::clipboard()->mimeData( - m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard); - - chosePlainText = false; - - if (mimeData->hasHtml()) { - QString html = mimeData->html(); - if (!html.isEmpty()) { - RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "", FragmentScriptingNotAllowed); - if (fragment) - return fragment.release(); - } - } - - if (allowPlainText && mimeData->hasText()) { - chosePlainText = true; - RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), mimeData->text()); - if (fragment) - return fragment.release(); - } -#endif - return 0; -} - -void Pasteboard::writePlainText(const String& text) -{ -#ifndef QT_NO_CLIPBOARD - QMimeData* md = new QMimeData; - QString qtext = text; - qtext.replace(QChar(0xa0), QLatin1Char(' ')); - md->setText(qtext); - QApplication::clipboard()->setMimeData(md, m_selectionMode ? - QClipboard::Selection : QClipboard::Clipboard); -#endif -} - -void Pasteboard::writeURL(const KURL& _url, const String&, Frame*) -{ - ASSERT(!_url.isEmpty()); - -#ifndef QT_NO_CLIPBOARD - QMimeData* md = new QMimeData; - QString url = _url.string(); - md->setText(url); - md->setUrls(QList<QUrl>() << QUrl(url)); - QApplication::clipboard()->setMimeData(md, m_selectionMode ? - QClipboard::Selection : QClipboard::Clipboard); -#endif -} - -void Pasteboard::writeImage(Node* node, const KURL&, const String&) -{ - ASSERT(node && node->renderer() && node->renderer()->isImage()); - -#ifndef QT_NO_CLIPBOARD - CachedImage* cachedImage = toRenderImage(node->renderer())->cachedImage(); - if (!cachedImage || cachedImage->errorOccurred()) - return; - - Image* image = cachedImage->image(); - ASSERT(image); - - QPixmap* pixmap = image->nativeImageForCurrentFrame(); - if (!pixmap) - return; - QApplication::clipboard()->setPixmap(*pixmap, QClipboard::Clipboard); -#endif -} - -/* This function is called from Editor::tryDHTMLCopy before actually set the clipboard - * It introduce a race condition with klipper, which will try to grab the clipboard - * It's not required to clear it anyway, since QClipboard take care about replacing the clipboard - */ -void Pasteboard::clear() -{ -} - -bool Pasteboard::isSelectionMode() const -{ - return m_selectionMode; -} - -void Pasteboard::setSelectionMode(bool selectionMode) -{ - m_selectionMode = selectionMode; -} - -} diff --git a/WebCore/platform/qt/PlatformBridge.h b/WebCore/platform/qt/PlatformBridge.h deleted file mode 100644 index e478d8f..0000000 --- a/WebCore/platform/qt/PlatformBridge.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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/PlatformBridgeQt.cpp b/WebCore/platform/qt/PlatformBridgeQt.cpp deleted file mode 100644 index 62065d7..0000000 --- a/WebCore/platform/qt/PlatformBridgeQt.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 - * 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 "PlatformBridge.h" - -#include "Frame.h" -#include "PluginView.h" -#include "Widget.h" - -namespace WebCore { - -bool PlatformBridge::popupsAllowed(NPP npp) -{ - if (npp && npp->ndata) - return static_cast<PluginView*>(npp->ndata)->arePopupsAllowed(); - - return false; -} - -NPObject* PlatformBridge::pluginScriptableObject(Widget* widget) -{ - if (!widget) - return 0; - - 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 deleted file mode 100644 index 498bb88..0000000 --- a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp +++ /dev/null @@ -1,652 +0,0 @@ -/* - * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * - * 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 "PlatformKeyboardEvent.h" - -#include "NotImplemented.h" -#include "WindowsKeyboardCodes.h" - -#include <QKeyEvent> -#include <ctype.h> - -namespace WebCore { - -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_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)); - } -} - -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 - case Qt::Key_1: - 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 - case Qt::Key_4: - return VK_NUMPAD4; // (64) Numeric keypad 4 key - case Qt::Key_5: - return VK_NUMPAD5; // (65) Numeric keypad 5 key - case Qt::Key_6: - return VK_NUMPAD6; // (66) Numeric keypad 6 key - case Qt::Key_7: - return VK_NUMPAD7; // (67) Numeric keypad 7 key - case Qt::Key_8: - return VK_NUMPAD8; // (68) Numeric keypad 8 key - case Qt::Key_9: - 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 - case Qt::Key_Minus: - return VK_SUBTRACT; // (6D) Subtract key - case Qt::Key_Period: - return VK_DECIMAL; // (6E) Decimal key - case Qt::Key_Slash: - return VK_DIVIDE; // (6F) Divide key - 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_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; - } - - } 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_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_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 - - case Qt::Key_NumLock: - return VK_NUMLOCK; // (90) NUM 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_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) -{ - const int state = event->modifiers(); - m_type = (event->type() == QEvent::KeyRelease) ? KeyUp : KeyDown; - m_text = event->text(); - m_unmodifiedText = event->text(); // FIXME: not correct - m_keyIdentifier = keyIdentifierForQtKeyCode(event->key()); - m_autoRepeat = event->isAutoRepeat(); - 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) || event->key() == Qt::Key_Backtab; // Simulate Shift+Tab with Key_Backtab - m_qtEvent = event; -} - -void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool) -{ - // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions. - ASSERT(m_type == KeyDown); - m_type = type; - - if (type == RawKeyDown) { - m_text = String(); - m_unmodifiedText = String(); - } else { - /* - When we receive shortcut events like Ctrl+V then the text in the QKeyEvent is - empty. If we're asked to disambiguate the event into a Char keyboard event, - 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 && isVirtualKeyCodeRepresentingCharacter(m_windowsVirtualKeyCode)) - m_text.append(UChar(m_windowsVirtualKeyCode)); - - m_keyIdentifier = String(); - m_windowsVirtualKeyCode = 0; - } -} - -bool PlatformKeyboardEvent::currentCapsLockState() -{ - notImplemented(); - 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 deleted file mode 100644 index a8956bf..0000000 --- a/WebCore/platform/qt/PlatformMouseEventQt.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * - * 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 "PlatformMouseEvent.h" - -#include <QGraphicsSceneMouseEvent> -#include <QMouseEvent> -#include <wtf/CurrentTime.h> - -namespace WebCore { - -PlatformMouseEvent::PlatformMouseEvent(QGraphicsSceneMouseEvent* event, int clickCount) -{ - m_timestamp = WTF::currentTime(); - - switch (event->type()) { - case QEvent::GraphicsSceneMouseDoubleClick: - case QEvent::GraphicsSceneMousePress: - m_eventType = MouseEventPressed; - break; - case QEvent::GraphicsSceneMouseRelease: - m_eventType = MouseEventReleased; - break; - case QEvent::GraphicsSceneMouseMove: - default: - m_eventType = MouseEventMoved; - } - - m_position = IntPoint(event->pos().toPoint()); - m_globalPosition = IntPoint(event->screenPos()); - - if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton)) - m_button = LeftButton; - else if (event->button() == Qt::RightButton || (event->buttons() & Qt::RightButton)) - m_button = RightButton; - else if (event->button() == Qt::MidButton || (event->buttons() & Qt::MidButton)) - m_button = MiddleButton; - else - m_button = NoButton; - - m_clickCount = clickCount; - 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) -{ - m_timestamp = WTF::currentTime(); - - QMouseEvent* me = 0; - - switch (event->type()) { - case QEvent::MouseMove: - m_eventType = MouseEventMoved; - me = static_cast<QMouseEvent *>(event); - break; - case QEvent::MouseButtonDblClick: - case QEvent::MouseButtonPress: - m_eventType = MouseEventPressed; - me = static_cast<QMouseEvent *>(event); - break; - case QEvent::MouseButtonRelease: - m_eventType = MouseEventReleased; - me = static_cast<QMouseEvent *>(event); - break; -#ifndef QT_NO_CONTEXTMENU - case QEvent::ContextMenu: { - m_eventType = MouseEventPressed; - QContextMenuEvent* ce = static_cast<QContextMenuEvent*>(event); - m_position = IntPoint(ce->pos()); - m_globalPosition = IntPoint(ce->globalPos()); - m_button = RightButton; - break; - } -#endif // QT_NO_CONTEXTMENU - default: - m_eventType = MouseEventMoved; - } - - if (me) { - m_position = IntPoint(me->pos()); - m_globalPosition = IntPoint(me->globalPos()); - - if (me->button() == Qt::LeftButton || (me->buttons() & Qt::LeftButton)) - m_button = LeftButton; - else if (me->button() == Qt::RightButton || (me->buttons() & Qt::RightButton)) - m_button = RightButton; - else if (me->button() == Qt::MidButton || (me->buttons() & Qt::MidButton)) - m_button = MiddleButton; - else - m_button = NoButton; - } - - m_clickCount = clickCount; - m_shiftKey = (event->modifiers() & Qt::ShiftModifier); - m_ctrlKey = (event->modifiers() & Qt::ControlModifier); - m_altKey = (event->modifiers() & Qt::AltModifier); - m_metaKey = (event->modifiers() & Qt::MetaModifier); -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/PlatformScreenQt.cpp b/WebCore/platform/qt/PlatformScreenQt.cpp deleted file mode 100644 index 4db8bd1..0000000 --- a/WebCore/platform/qt/PlatformScreenQt.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2008 Holger Hans Peter Freyther - * - * 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. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 "PlatformScreen.h" - -#include "FloatRect.h" -#include "Frame.h" -#include "FrameView.h" -#include "HostWindow.h" -#include "Widget.h" -#include "QWebPageClient.h" -#include <QApplication> -#include <QDesktopWidget> - -namespace WebCore { - -static int screenNumber(Widget* w) -{ - if (!w) - return 0; - - QWebPageClient* client = w->root()->hostWindow()->platformPageClient(); - return client ? client->screenNumber() : 0; -} - -int screenDepth(Widget* w) -{ - return QApplication::desktop()->screen(screenNumber(w))->depth(); -} - -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) - depth = view->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) -{ - return QApplication::desktop()->screen(screenNumber(w))->colorCount() == 2; -} - -FloatRect screenRect(Widget* w) -{ - QRect r = QApplication::desktop()->screenGeometry(screenNumber(w)); - return FloatRect(r.x(), r.y(), r.width(), r.height()); -} - -FloatRect screenAvailableRect(Widget* w) -{ - QRect r = QApplication::desktop()->availableGeometry(screenNumber(w)); - return FloatRect(r.x(), r.y(), r.width(), r.height()); -} - -} // namespace WebCore diff --git a/WebCore/platform/qt/PlatformTouchEventQt.cpp b/WebCore/platform/qt/PlatformTouchEventQt.cpp deleted file mode 100644 index 338e9d4..0000000 --- a/WebCore/platform/qt/PlatformTouchEventQt.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the WebKit project. - * - * 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 "PlatformTouchEvent.h" - -#if ENABLE(TOUCH_EVENTS) - -namespace WebCore { - -PlatformTouchEvent::PlatformTouchEvent(QTouchEvent* event) -{ - switch (event->type()) { - case QEvent::TouchBegin: m_type = TouchStart; break; - case QEvent::TouchUpdate: m_type = TouchMove; break; - case QEvent::TouchEnd: m_type = TouchEnd; break; - } - const QList<QTouchEvent::TouchPoint>& points = event->touchPoints(); - for (int i = 0; i < points.count(); ++i) - m_touchPoints.append(PlatformTouchPoint(points.at(i))); - - m_ctrlKey = (event->modifiers() & Qt::ControlModifier); - m_altKey = (event->modifiers() & Qt::AltModifier); - m_shiftKey = (event->modifiers() & Qt::ShiftModifier); - m_metaKey = (event->modifiers() & Qt::MetaModifier); -} - -} - -#endif diff --git a/WebCore/platform/qt/PlatformTouchPointQt.cpp b/WebCore/platform/qt/PlatformTouchPointQt.cpp deleted file mode 100644 index c293212..0000000 --- a/WebCore/platform/qt/PlatformTouchPointQt.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the WebKit project. - * - * 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 "PlatformTouchPoint.h" - -#if ENABLE(TOUCH_EVENTS) - -namespace WebCore { - -PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point) -{ - // The QTouchEvent::TouchPoint API states that ids will be >= 0. - m_id = static_cast<unsigned>(point.id()); - switch (point.state()) { - case Qt::TouchPointReleased: m_state = TouchReleased; break; - case Qt::TouchPointMoved: m_state = TouchMoved; break; - case Qt::TouchPointPressed: m_state = TouchPressed; break; - case Qt::TouchPointStationary: m_state = TouchStationary; break; - } - m_screenPos = point.screenPos().toPoint(); - m_pos = point.pos().toPoint(); -} - -} - -#endif diff --git a/WebCore/platform/qt/QWebPageClient.h b/WebCore/platform/qt/QWebPageClient.h deleted file mode 100644 index d8f4171..0000000 --- a/WebCore/platform/qt/QWebPageClient.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -#ifndef QWebPageClient_h -#define QWebPageClient_h - -#ifndef QT_NO_CURSOR -#include <QCursor> -#endif - -#if USE(ACCELERATED_COMPOSITING) -#include <GraphicsLayer.h> -#endif - -#include <QPalette> -#include <QRect> - -QT_BEGIN_NAMESPACE -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) - 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 - - virtual void setInputMethodHints(Qt::InputMethodHints hint) = 0; - -#ifndef QT_NO_CURSOR - inline void resetCursor() - { - if (!cursor().bitmap() && cursor().shape() == m_lastCursor.shape()) - return; - updateCursor(m_lastCursor); - } - - inline void setCursor(const QCursor& cursor) - { - m_lastCursor = cursor; - if (!cursor.bitmap() && cursor.shape() == this->cursor().shape()) - return; - updateCursor(cursor); - } -#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; - virtual void updateCursor(const QCursor& cursor) = 0; -#endif - -private: -#ifndef QT_NO_CURSOR - QCursor m_lastCursor; -#endif -}; - -#endif diff --git a/WebCore/platform/qt/QtMobileWebStyle.cpp b/WebCore/platform/qt/QtMobileWebStyle.cpp deleted file mode 100644 index 240faa5..0000000 --- a/WebCore/platform/qt/QtMobileWebStyle.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/* - * 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 deleted file mode 100644 index 779bd26..0000000 --- a/WebCore/platform/qt/QtMobileWebStyle.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 deleted file mode 100644 index 29c8220..0000000 --- a/WebCore/platform/qt/QtStyleOptionWebComboBox.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 deleted file mode 100644 index 789abb6..0000000 --- a/WebCore/platform/qt/RenderThemeQt.cpp +++ /dev/null @@ -1,1314 +0,0 @@ -/* - * This file is part of the WebKit project. - * - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - * - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * 2006 Dirk Mueller <mueller@kde.org> - * 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2008 Holger Hans Peter Freyther - * - * All rights reserved. - * - * 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 "RenderThemeQt.h" - -#include "CSSStyleSelector.h" -#include "CSSStyleSheet.h" -#include "Chrome.h" -#include "ChromeClientQt.h" -#include "Color.h" -#include "Document.h" -#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 <QApplication> -#include <QColor> -#include <QDebug> -#include <QFile> -#include <QLineEdit> -#include <QPainter> -#include <QPushButton> -#include <QStyleFactory> -#include <QStyleOptionButton> -#include <QStyleOptionFrameV2> -#if ENABLE(PROGRESS_TAG) -#include <QStyleOptionProgressBarV2> -#endif -#include <QStyleOptionSlider> -#include <QWidget> - - -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 PaintInfo& paintInfo) -{ - init(paintInfo.context ? paintInfo.context : 0, theme->qStyle()); -} - -StylePainter::StylePainter(ScrollbarThemeQt* theme, GraphicsContext* context) -{ - init(context, theme->style()); -} - -void StylePainter::init(GraphicsContext* context, QStyle* themeStyle) -{ - painter = static_cast<QPainter*>(context->platformContext()); - widget = 0; - QPaintDevice* dev = 0; - if (painter) - dev = painter->device(); - if (dev && dev->devType() == QInternal::Widget) - widget = static_cast<QWidget*>(dev); - style = themeStyle; - - if (painter) { - // the styles often assume being called with a pristine painter where no brush is set, - // so reset it manually - oldBrush = painter->brush(); - painter->setBrush(Qt::NoBrush); - - // painting the widget with anti-aliasing will make it blurry - // disable it here and restore it later - oldAntialiasing = painter->testRenderHint(QPainter::Antialiasing); - painter->setRenderHint(QPainter::Antialiasing, false); - } -} - -StylePainter::~StylePainter() -{ - if (painter) { - painter->setBrush(oldBrush); - painter->setRenderHints(QPainter::Antialiasing, oldAntialiasing); - } -} - -PassRefPtr<RenderTheme> RenderThemeQt::create(Page* page) -{ - return adoptRef(new RenderThemeQt(page)); -} - -PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) -{ - if (page) - return RenderThemeQt::create(page); - - static RenderTheme* fallback = RenderThemeQt::create(0).releaseRef(); - return fallback; -} - -RenderThemeQt::RenderThemeQt(Page* page) - : RenderTheme() - , m_page(page) - , m_lineEdit(0) -{ - QPushButton button; - button.setAttribute(Qt::WA_MacSmallSize); - QFont defaultButtonFont = QApplication::font(&button); - QFontInfo fontInfo(defaultButtonFont); - m_buttonFontFamily = defaultButtonFont.family(); -#ifdef Q_WS_MAC - 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 -{ - return (m_fallbackStyle) ? m_fallbackStyle : QApplication::style(); -} - -QStyle* RenderThemeQt::qStyle() const -{ -#if USE(QT_MOBILE_THEME) - return fallbackStyle(); -#endif - - if (m_page) { - QWebPageClient* pageClient = m_page->chrome()->client()->platformPageClient(); - - if (pageClient) - return pageClient->style(); - } - - 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; -} - -bool RenderThemeQt::supportsFocusRing(const RenderStyle* style) const -{ - switch (style->appearance()) { - case CheckboxPart: - case RadioPart: - case PushButtonPart: - case SquareButtonPart: - case ButtonPart: - case ButtonBevelPart: - case ListboxPart: - case ListItemPart: - case MenulistPart: - case MenulistButtonPart: - case SliderHorizontalPart: - case SliderVerticalPart: - case SliderThumbHorizontalPart: - case SliderThumbVerticalPart: - case SearchFieldPart: - case SearchFieldResultsButtonPart: - case SearchFieldCancelButtonPart: - case TextFieldPart: - case TextAreaPart: - return true; - default: - return false; - } -} - -int RenderThemeQt::baselinePosition(const RenderObject* o) const -{ - if (!o->isBox()) - return 0; - - if (o->style()->appearance() == CheckboxPart || o->style()->appearance() == RadioPart) - return toRenderBox(o)->marginTop() + toRenderBox(o)->height() - 2; // Same as in old khtml - return RenderTheme::baselinePosition(o); -} - -bool RenderThemeQt::controlSupportsTints(const RenderObject* o) const -{ - if (!isEnabled(o)) - return false; - - // Checkboxes only have tint when checked. - if (o->style()->appearance() == CheckboxPart) - return isChecked(o); - - // For now assume other controls have tint if enabled. - return true; -} - -bool RenderThemeQt::supportsControlTints() const -{ - return true; -} - -int RenderThemeQt::findFrameLineWidth(QStyle* style) const -{ -#ifndef QT_NO_LINEEDIT - if (!m_lineEdit) - m_lineEdit = new QLineEdit(); -#endif - - QStyleOptionFrameV2 opt; - 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) -{ - QStyleOptionButton option; - option.state |= QStyle::State_Small; - option.rect = originalRect; - - QRect layoutRect = style->subElementRect(QStyle::SE_PushButtonLayoutItem, &option, 0); - if (!layoutRect.isNull()) { - int paddingLeft = layoutRect.left() - originalRect.left(); - int paddingRight = originalRect.right() - layoutRect.right(); - int paddingTop = layoutRect.top() - originalRect.top(); - int paddingBottom = originalRect.bottom() - layoutRect.bottom(); - - return originalRect.adjusted(-paddingLeft, -paddingTop, paddingRight, paddingBottom); - } - return originalRect; -} - -void RenderThemeQt::adjustRepaintRect(const RenderObject* o, IntRect& rect) -{ - switch (o->style()->appearance()) { - case CheckboxPart: - break; - case RadioPart: - break; - case PushButtonPart: - case ButtonPart: { - QRect inflatedRect = inflateButtonRect(rect, qStyle()); - rect = IntRect(inflatedRect.x(), inflatedRect.y(), inflatedRect.width(), inflatedRect.height()); - break; - } - case MenulistPart: - break; - default: - break; - } -} - -Color RenderThemeQt::platformActiveSelectionBackgroundColor() const -{ - QPalette pal = QApplication::palette(); - return pal.brush(QPalette::Active, QPalette::Highlight).color(); -} - -Color RenderThemeQt::platformInactiveSelectionBackgroundColor() const -{ - QPalette pal = QApplication::palette(); - return pal.brush(QPalette::Inactive, QPalette::Highlight).color(); -} - -Color RenderThemeQt::platformActiveSelectionForegroundColor() const -{ - QPalette pal = QApplication::palette(); - return pal.brush(QPalette::Active, QPalette::HighlightedText).color(); -} - -Color RenderThemeQt::platformInactiveSelectionForegroundColor() const -{ - QPalette pal = QApplication::palette(); - return pal.brush(QPalette::Inactive, QPalette::HighlightedText).color(); -} - -void RenderThemeQt::systemFont(int, FontDescription&) const -{ - // no-op -} - -int RenderThemeQt::minimumMenuListSize(RenderStyle*) const -{ - const QFontMetrics &fm = QApplication::fontMetrics(); - return 7 * fm.width(QLatin1Char('x')); -} - -void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const -{ - 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; - } - case RadioPart: { - QStyleOption styleOption; - styleOption.state |= QStyle::State_Small; - int radioWidth = style->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &styleOption); - radioWidth *= renderStyle->effectiveZoom(); - size = QSize(radioWidth, radioWidth); - break; - } - case PushButtonPart: - case ButtonPart: { - QStyleOptionButton styleOption; - styleOption.state |= QStyle::State_Small; - QSize contentSize = fm.size(Qt::TextShowMnemonic, QString::fromLatin1("X")); - QSize pushButtonSize = style->sizeFromContents(QStyle::CT_PushButton, - &styleOption, contentSize, 0); - styleOption.rect = QRect(0, 0, pushButtonSize.width(), pushButtonSize.height()); - QRect layoutRect = style->subElementRect(QStyle::SE_PushButtonLayoutItem, - &styleOption, 0); - - // If the style supports layout rects we use that, and compensate accordingly - // in paintButton() below. - if (!layoutRect.isNull()) - size.setHeight(layoutRect.height()); - else - size.setHeight(pushButtonSize.height()); - - break; - } - case MenulistPart: { - QStyleOptionComboBox styleOption; - styleOption.state |= QStyle::State_Small; - int contentHeight = qMax(fm.lineSpacing(), 14) + 2; - QSize menuListSize = style->sizeFromContents(QStyle::CT_ComboBox, - &styleOption, QSize(0, contentHeight), 0); - size.setHeight(menuListSize.height()); - break; - } - default: - break; - } - - // FIXME: Check is flawed, since it doesn't take min-width/max-width into account. - if (renderStyle->width().isIntrinsicOrAuto() && size.width() > 0) - renderStyle->setWidth(Length(size.width(), Fixed)); - if (renderStyle->height().isAuto() && size.height() > 0) - renderStyle->setHeight(Length(size.height(), Fixed)); -} - -void RenderThemeQt::setCheckboxSize(RenderStyle* style) const -{ - computeSizeBasedOnStyle(style); -} - -bool RenderThemeQt::paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r) -{ - return paintButton(o, i, r); -} - -void RenderThemeQt::setRadioSize(RenderStyle* style) const -{ - computeSizeBasedOnStyle(style); -} - -bool RenderThemeQt::paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r) -{ - return paintButton(o, i, r); -} - -void RenderThemeQt::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element*) const -{ - // Ditch the border. - style->resetBorder(); - -#ifdef Q_WS_MAC - if (style->appearance() == PushButtonPart) { - // The Mac ports ignore the specified height for <input type="button"> elements - // unless a border and/or background CSS property is also specified. - style->setHeight(Length(Auto)); - } -#endif - - // White-space is locked to pre - style->setWhiteSpace(PRE); - - FontDescription fontDescription = style->fontDescription(); - fontDescription.setIsAbsoluteSize(true); - -#ifdef Q_WS_MAC // Use fixed font size and family on Mac (like Safari does) - fontDescription.setSpecifiedSize(m_buttonFontPixelSize); - fontDescription.setComputedSize(m_buttonFontPixelSize); -#else - fontDescription.setSpecifiedSize(style->fontSize()); - fontDescription.setComputedSize(style->fontSize()); -#endif - - FontFamily fontFamily; - fontFamily.setFamily(m_buttonFontFamily); - fontDescription.setFamily(fontFamily); - style->setFontDescription(fontDescription); - style->font().update(selector->fontSelector()); - style->setLineHeight(RenderStyle::initialLineHeight()); - - setButtonSize(style); - setButtonPadding(style); -} - -void RenderThemeQt::setButtonSize(RenderStyle* style) const -{ - computeSizeBasedOnStyle(style); -} - -void RenderThemeQt::setButtonPadding(RenderStyle* style) const -{ - QStyleOptionButton styleOption; - styleOption.state |= QStyle::State_Small; - - // Fake a button rect here, since we're just computing deltas - QRect originalRect = QRect(0, 0, 100, 30); - styleOption.rect = originalRect; - - // Default padding is based on the button margin pixel metric - int buttonMargin = qStyle()->pixelMetric(QStyle::PM_ButtonMargin, &styleOption, 0); - int paddingLeft = buttonMargin; - int paddingRight = buttonMargin; - int paddingTop = 1; - int paddingBottom = 0; - - // Then check if the style uses layout margins - QRect layoutRect = qStyle()->subElementRect(QStyle::SE_PushButtonLayoutItem, - &styleOption, 0); - if (!layoutRect.isNull()) { - QRect contentsRect = qStyle()->subElementRect(QStyle::SE_PushButtonContents, - &styleOption, 0); - paddingLeft = contentsRect.left() - layoutRect.left(); - paddingRight = layoutRect.right() - contentsRect.right(); - paddingTop = contentsRect.top() - layoutRect.top(); - - // Can't use this right now because we don't have the baseline to compensate - // paddingBottom = layoutRect.bottom() - contentsRect.bottom(); - } - - style->setPaddingLeft(Length(paddingLeft, Fixed)); - style->setPaddingRight(Length(paddingRight, Fixed)); - style->setPaddingTop(Length(paddingTop, Fixed)); - style->setPaddingBottom(Length(paddingBottom, Fixed)); -} - -bool RenderThemeQt::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r) -{ - StylePainter p(this, i); - if (!p.isValid()) - return true; - - QStyleOptionButton option; - initStyleOption(p.widget, option); - option.rect = r; - option.state |= QStyle::State_Small; - - ControlPart appearance = initializeCommonQStyleOptions(option, o); - if (appearance == PushButtonPart || appearance == ButtonPart) { - option.rect = inflateButtonRect(option.rect, qStyle()); - p.drawControl(QStyle::CE_PushButton, option); - } else if (appearance == RadioPart) - p.drawControl(QStyle::CE_RadioButton, option); - else if (appearance == CheckboxPart) - p.drawControl(QStyle::CE_CheckBox, option); - - return false; -} - -void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const -{ - style->setBackgroundColor(Color::transparent); - style->resetBorder(); - style->resetPadding(); - computeSizeBasedOnStyle(style); -} - -bool RenderThemeQt::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r) -{ - StylePainter p(this, i); - if (!p.isValid()) - return true; - - QStyleOptionFrameV2 panel; - initStyleOption(p.widget, panel); - panel.rect = r; - panel.lineWidth = findFrameLineWidth(qStyle()); - panel.state |= QStyle::State_Sunken; - panel.features = QStyleOptionFrameV2::None; - - // Get the correct theme data for a text field - ControlPart appearance = initializeCommonQStyleOptions(panel, o); - if (appearance != TextFieldPart - && appearance != SearchFieldPart - && appearance != TextAreaPart - && appearance != ListboxPart) - return true; - - // Now paint the text field. - p.drawPrimitive(QStyle::PE_PanelLineEdit, panel); - - return false; -} - -void RenderThemeQt::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, Element* element) const -{ - adjustTextFieldStyle(selector, style, element); -} - -bool RenderThemeQt::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r) -{ - return paintTextField(o, i, r); -} - -void RenderThemeQt::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const -{ - style->resetBorder(); - - // Height is locked to auto. - style->setHeight(Length(Auto)); - - // White-space is locked to pre - style->setWhiteSpace(PRE); - - computeSizeBasedOnStyle(style); - - // Add in the padding that we'd like to use. - setPopupPadding(style); -} - -void RenderThemeQt::setPopupPadding(RenderStyle* style) const -{ - const int padding = 8; - style->setPaddingLeft(Length(padding, Fixed)); - - QStyleOptionComboBox opt; - int w = qStyle()->pixelMetric(QStyle::PM_ButtonIconSize, &opt, 0); - style->setPaddingRight(Length(padding + w, Fixed)); - - style->setPaddingTop(Length(2, Fixed)); - style->setPaddingBottom(Length(0, Fixed)); -} - - -bool RenderThemeQt::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) -{ - StylePainter p(this, i); - if (!p.isValid()) - return true; - - QtStyleOptionWebComboBox opt(o); - initStyleOption(p.widget, opt); - initializeCommonQStyleOptions(opt, o); - - const QPoint topLeft = r.topLeft(); - p.painter->translate(topLeft); - opt.rect.moveTo(QPoint(0, 0)); - opt.rect.setSize(r.size()); - - p.drawComplexControl(QStyle::CC_ComboBox, opt); - p.painter->translate(-topLeft); - return false; -} - -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)); - - // White-space is locked to pre - style->setWhiteSpace(PRE); - - computeSizeBasedOnStyle(style); - - // Add in the padding that we'd like to use. - setPopupPadding(style); -} - -bool RenderThemeQt::paintMenuListButton(RenderObject* o, const PaintInfo& i, - const IntRect& r) -{ - StylePainter p(this, i); - if (!p.isValid()) - return true; - - QtStyleOptionWebComboBox option(o); - initStyleOption(p.widget, option); - initializeCommonQStyleOptions(option, o); - option.rect = r; - - // for drawing the combo box arrow, rely only on the fallback style - p.style = fallbackStyle(); - option.subControls = QStyle::SC_ComboBoxArrow; - p.drawComplexControl(QStyle::CC_ComboBox, option); - - return false; -} - -#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); - if (!p.isValid()) - return true; - - QStyleOptionSlider option; - initStyleOption(p.widget, option); - option.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; - ControlPart appearance = initializeCommonQStyleOptions(option, o); - - RenderSlider* renderSlider = toRenderSlider(o); - IntRect thumbRect = renderSlider->thumbRect(); - - option.rect = r; - - int value; - if (appearance == SliderVerticalPart) { - option.maximum = r.height() - thumbRect.height(); - value = thumbRect.y(); - } else { - option.maximum = r.width() - thumbRect.width(); - value = thumbRect.x(); - } - - value = QStyle::sliderValueFromPosition(0, option.maximum, value, option.maximum); - - option.sliderValue = value; - option.sliderPosition = value; - if (appearance == SliderVerticalPart) - option.orientation = Qt::Vertical; - - if (renderSlider->inDragMode()) { - option.activeSubControls = QStyle::SC_SliderHandle; - option.state |= QStyle::State_Sunken; - } - - const QPoint topLeft = r.topLeft(); - p.painter->translate(topLeft); - option.rect.moveTo(QPoint(0, 0)); - option.rect.setSize(r.size()); - - p.drawComplexControl(QStyle::CC_Slider, option); - p.painter->translate(-topLeft); - - return false; -} - -void RenderThemeQt::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element*) const -{ - style->setBoxShadow(0); -} - -bool RenderThemeQt::paintSliderThumb(RenderObject* o, const PaintInfo& pi, - const IntRect& r) -{ - // We've already painted it in paintSliderTrack(), no need to do anything here. - return false; -} - -void RenderThemeQt::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle* style, Element*) const -{ - style->setBoxShadow(0); -} - -bool RenderThemeQt::paintSearchField(RenderObject* o, const PaintInfo& pi, - const IntRect& r) -{ - return true; -} - -void RenderThemeQt::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, - Element* e) const -{ - notImplemented(); - RenderTheme::adjustSearchFieldStyle(selector, style, e); -} - -void RenderThemeQt::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style, - Element* e) const -{ - notImplemented(); - RenderTheme::adjustSearchFieldCancelButtonStyle(selector, style, e); -} - -bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& pi, - const IntRect& r) -{ - notImplemented(); - return RenderTheme::paintSearchFieldCancelButton(o, pi, r); -} - -void RenderThemeQt::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, - Element* e) const -{ - notImplemented(); - RenderTheme::adjustSearchFieldDecorationStyle(selector, style, e); -} - -bool RenderThemeQt::paintSearchFieldDecoration(RenderObject* o, const PaintInfo& pi, - const IntRect& r) -{ - notImplemented(); - return RenderTheme::paintSearchFieldDecoration(o, pi, r); -} - -void RenderThemeQt::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, - Element* e) const -{ - notImplemented(); - RenderTheme::adjustSearchFieldResultsDecorationStyle(selector, style, e); -} - -bool RenderThemeQt::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& pi, - const IntRect& r) -{ - notImplemented(); - return RenderTheme::paintSearchFieldResultsDecoration(o, pi, r); -} - -bool RenderThemeQt::supportsFocus(ControlPart appearance) const -{ - switch (appearance) { - case PushButtonPart: - case ButtonPart: - case TextFieldPart: - case TextAreaPart: - case ListboxPart: - case MenulistPart: - case RadioPart: - case CheckboxPart: - case SliderHorizontalPart: - case SliderVerticalPart: - return true; - default: // No for all others... - return false; - } -} - -void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const -{ -#if USE(QT_MOBILE_THEME) - static QPalette lightGrayPalette(Qt::lightGray); - palette = lightGrayPalette; - return; -#endif - // If the webview has a custom palette, use it - if (!m_page) - return; - Chrome* chrome = m_page->chrome(); - if (!chrome) - return; - ChromeClient* chromeClient = chrome->client(); - if (!chromeClient) - return; - QWebPageClient* pageClient = chromeClient->platformPageClient(); - if (!pageClient) - return; - palette = pageClient->palette(); -} - -ControlPart RenderThemeQt::initializeCommonQStyleOptions(QStyleOption& option, RenderObject* o) const -{ - // Default bits: no focus, no mouse over - option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); - - if (!isEnabled(o)) - option.state &= ~QStyle::State_Enabled; - - if (isReadOnlyControl(o)) - // Readonly is supported on textfields. - option.state |= QStyle::State_ReadOnly; - - option.direction = Qt::LeftToRight; - - if (isHovered(o)) - option.state |= QStyle::State_MouseOver; - - setPaletteFromPageClientIfExists(option.palette); - RenderStyle* style = o->style(); - if (!style) - return NoControlPart; - - ControlPart result = style->appearance(); - if (supportsFocus(result) && isFocused(o)) { - option.state |= QStyle::State_HasFocus; - option.state |= QStyle::State_KeyboardFocusChange; - } - - if (style->direction() == WebCore::RTL) - option.direction = Qt::RightToLeft; - - switch (result) { - case PushButtonPart: - case SquareButtonPart: - case ButtonPart: - case ButtonBevelPart: - case ListItemPart: - case MenulistButtonPart: - case SearchFieldResultsButtonPart: - case SearchFieldCancelButtonPart: { - if (isPressed(o)) - option.state |= QStyle::State_Sunken; - else if (result == PushButtonPart || result == ButtonPart) - option.state |= QStyle::State_Raised; - break; - } - case RadioPart: - case CheckboxPart: - option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off); - } - - return result; -} - -#if ENABLE(VIDEO) - -String RenderThemeQt::extraMediaControlsStyleSheet() -{ - return String(mediaControlsQtUserAgentStyleSheet, sizeof(mediaControlsQtUserAgentStyleSheet)); -} - -// Helper class to transform the painter's world matrix to the object's content area, scaled to 0,0,100,100 -class WorldMatrixTransformer { -public: - WorldMatrixTransformer(QPainter* painter, RenderObject* renderObject, const IntRect& r) : m_painter(painter) - { - RenderStyle* style = renderObject->style(); - m_originalTransform = m_painter->transform(); - m_painter->translate(r.x() + style->paddingLeft().value(), r.y() + style->paddingTop().value()); - m_painter->scale((r.width() - style->paddingLeft().value() - style->paddingRight().value()) / 100.0, - (r.height() - style->paddingTop().value() - style->paddingBottom().value()) / 100.0); - } - - ~WorldMatrixTransformer() { m_painter->setTransform(m_originalTransform); } - -private: - QPainter* m_painter; - QTransform m_originalTransform; -}; - -HTMLMediaElement* RenderThemeQt::getMediaElementFromRenderObject(RenderObject* o) const -{ - Node* node = o->node(); - Node* mediaNode = node ? node->shadowAncestorNode() : 0; - if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag))) - return 0; - - 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, mediaControlsBaselineOpacity() * 255); - painter->setBrush(transparentBlack); - painter->drawRoundedRect(r.x(), r.y(), r.width(), r.height(), 5.0, 5.0); -} - -QColor RenderThemeQt::getMediaControlForegroundColor(RenderObject* o) const -{ - QColor fgColor = platformActiveSelectionBackgroundColor(); - if (o && o->node()->active()) - fgColor = fgColor.lighter(); - return fgColor; -} - -bool RenderThemeQt::paintMediaFullscreenButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) -{ - return RenderTheme::paintMediaFullscreenButton(o, paintInfo, r); -} - -bool RenderThemeQt::paintMediaMuteButton(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); - - WorldMatrixTransformer transformer(p.painter, o, r); - 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(mediaElement->muted() ? Qt::darkRed : getMediaControlForegroundColor(o)); - p.painter->drawPolygon(speakerPolygon, 6); - - return false; -} - -bool RenderThemeQt::paintMediaPlayButton(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); - - WorldMatrixTransformer transformer(p.painter, o, r); - p.painter->setBrush(getMediaControlForegroundColor(o)); - if (mediaElement->canPlay()) { - const QPointF playPolygon[3] = { QPointF(0, 0), QPointF(100, 50), QPointF(0, 100)}; - p.painter->drawPolygon(playPolygon, 3); - } else { - p.painter->drawRect(0, 0, 30, 100); - p.painter->drawRect(70, 0, 30, 100); - } - - return false; -} - -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 PaintInfo&, const IntRect&) -{ - // We don't want to paint this at the moment. - return false; -} - -bool RenderThemeQt::paintMediaCurrentTime(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) -{ - 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; - - p.painter->setRenderHint(QPainter::Antialiasing, true); - - paintMediaBackground(p.painter, r); - - if (!o->isSlider()) - return false; - - IntRect b = toRenderBox(o)->contentBoxRect(); - - // Position the outer rectangle - int top = r.y() + b.y(); - int left = r.x() + b.x(); - int width = b.width(); - int height = b.height(); - - // Get the scale color from the page client - QPalette pal = QApplication::palette(); - setPaletteFromPageClientIfExists(pal); - const QColor highlightText = pal.brush(QPalette::Active, QPalette::HighlightedText).color(); - const QColor scaleColor(highlightText.red(), highlightText.green(), highlightText.blue(), mediaControlsBaselineOpacity() * 255); - - // Draw the outer rectangle - p.painter->setBrush(scaleColor); - p.painter->drawRect(left, top, width, height); - - if (!o->node() || !o->node()->hasTagName(inputTag)) - return false; - - HTMLInputElement* slider = static_cast<HTMLInputElement*>(o->node()); - - // Position the inner rectangle - height = height * slider->valueAsNumber(); - top += b.height() - height; - - // Draw the inner rectangle - p.painter->setPen(Qt::NoPen); - p.painter->setBrush(getMediaControlForegroundColor(o)); - p.painter->drawRect(left, top, width, height); - - return false; -} - -bool RenderThemeQt::paintMediaVolumeSliderThumb(RenderObject *o, const PaintInfo &paintInfo, const IntRect &r) -{ - StylePainter p(this, paintInfo); - if (!p.isValid()) - return true; - - // Nothing to draw here, this is all done in the track - return false; -} - -bool RenderThemeQt::paintMediaSliderTrack(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); - -#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()); - - return false; -} -#endif - -void RenderThemeQt::adjustSliderThumbSize(RenderObject* o) const -{ - ControlPart part = o->style()->appearance(); - - if (part == MediaSliderThumbPart) { - RenderStyle* parentStyle = o->parent()->style(); - Q_ASSERT(parentStyle); - - 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) - option.orientation = Qt::Vertical; - - QStyle* style = qStyle(); - - int width = style->pixelMetric(QStyle::PM_SliderLength, &option); - int height = style->pixelMetric(QStyle::PM_SliderThickness, &option); - o->style()->setWidth(Length(width, Fixed)); - o->style()->setHeight(Length(height, Fixed)); - } -} - -double RenderThemeQt::caretBlinkInterval() const -{ - return QApplication::cursorFlashTime() / 1000.0 / 2.0; -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/RenderThemeQt.h b/WebCore/platform/qt/RenderThemeQt.h deleted file mode 100644 index 7ab6769..0000000 --- a/WebCore/platform/qt/RenderThemeQt.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * This file is part of the theme implementation for form controls in WebCore. - * - * 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 RenderThemeQt_h -#define RenderThemeQt_h - -#include "RenderTheme.h" - -#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; - -class RenderThemeQt : public RenderTheme { -private: - RenderThemeQt(Page* page); - virtual ~RenderThemeQt(); - -public: - static PassRefPtr<RenderTheme> create(Page*); - - String extraDefaultStyleSheet(); - - virtual bool supportsHover(const RenderStyle*) const; - virtual bool supportsFocusRing(const RenderStyle* style) const; - - virtual int baselinePosition(const RenderObject* o) const; - - // A method asking if the control changes its tint when the window has focus or not. - virtual bool controlSupportsTints(const RenderObject*) const; - - // A general method asking if any control tinting is supported at all. - virtual bool supportsControlTints() const; - - virtual void adjustRepaintRect(const RenderObject* o, IntRect& r); - - // The platform selection color. - virtual Color platformActiveSelectionBackgroundColor() const; - virtual Color platformInactiveSelectionBackgroundColor() const; - virtual Color platformActiveSelectionForegroundColor() const; - virtual Color platformInactiveSelectionForegroundColor() const; - - virtual void systemFont(int propId, FontDescription&) const; - - virtual int minimumMenuListSize(RenderStyle*) const; - - virtual void adjustSliderThumbSize(RenderObject*) const; - - 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 - - QStyle* qStyle() const; - -protected: - virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r); - virtual void setCheckboxSize(RenderStyle*) const; - - 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 PaintInfo&, const IntRect&); - virtual void setButtonSize(RenderStyle*) const; - - virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); - virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - - virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); - virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - - virtual bool paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r); - virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - - virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); - virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - -#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 PaintInfo&, const IntRect&); - virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - - 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 PaintInfo&, const IntRect&); - - virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&); - - virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldResultsDecoration(RenderObject*, const 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; - -private: - bool supportsFocus(ControlPart) const; - - ControlPart initializeCommonQStyleOptions(QStyleOption&, RenderObject*) const; - - void setButtonPadding(RenderStyle*) const; - void setPopupPadding(RenderStyle*) const; - - void setPaletteFromPageClientIfExists(QPalette&) const; - - int findFrameLineWidth(QStyle* style) const; - - QStyle* fallbackStyle() const; - - Page* m_page; - -#ifdef Q_WS_MAC - int m_buttonFontPixelSize; -#endif - QString m_buttonFontFamily; - - QStyle* m_fallbackStyle; - mutable QLineEdit* m_lineEdit; -}; - -class StylePainter { -public: - explicit StylePainter(RenderThemeQt*, const PaintInfo&); - explicit StylePainter(ScrollbarThemeQt*, GraphicsContext*); - ~StylePainter(); - - bool isValid() const { return painter && style; } - - QPainter* painter; - QWidget* widget; - QStyle* style; - - void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption& opt) - { style->drawPrimitive(pe, &opt, painter, widget); } - void drawControl(QStyle::ControlElement ce, const QStyleOption& opt) - { style->drawControl(ce, &opt, painter, widget); } - void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex& opt) - { style->drawComplexControl(cc, &opt, painter, widget); } - -private: - void init(GraphicsContext* context, QStyle*); - - QBrush oldBrush; - bool oldAntialiasing; - - Q_DISABLE_COPY(StylePainter) -}; - -} - -#endif // RenderThemeQt_h diff --git a/WebCore/platform/qt/ScreenQt.cpp b/WebCore/platform/qt/ScreenQt.cpp deleted file mode 100644 index d648c53..0000000 --- a/WebCore/platform/qt/ScreenQt.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> - * (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * - * 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 "Screen.h" - -#include "FloatRect.h" -#include "Frame.h" -#include "FrameView.h" -#include "IntRect.h" -#include "Page.h" -#include "Widget.h" - -#include <QApplication> -#include <QDesktopWidget> - -namespace WebCore { - -static QWidget* qwidgetForPage(const Page* page) -{ - Frame* frame = (page ? page->mainFrame() : 0); - FrameView* frameView = (frame ? frame->view() : 0); - - if (!frameView) - return 0; - - return frameView->qwidget(); -} - -FloatRect screenRect(const Page* page) -{ - QWidget* qw = qwidgetForPage(page); - if (!qw) - return FloatRect(); - - // Taken from KGlobalSettings::desktopGeometry - QDesktopWidget* dw = QApplication::desktop(); - if (!dw) - return FloatRect(); - - return IntRect(dw->screenGeometry(qw)); -} - -int screenDepth(const Page* page) -{ - QWidget* qw = qwidgetForPage(page); - if (!qw) - return 32; - - return qw->depth(); -} - -FloatRect usableScreenRect(const Page* page) -{ - QWidget* qw = qwidgetForPage(page); - if (!qw) - return FloatRect(); - - // Taken from KGlobalSettings::desktopGeometry - QDesktopWidget* dw = QApplication::desktop(); - if (!dw) - return FloatRect(); - - return IntRect(dw->availableGeometry(qw)); -} - -float scaleFactor(const Page*) -{ - return 1.0f; -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/ScrollViewQt.cpp b/WebCore/platform/qt/ScrollViewQt.cpp deleted file mode 100644 index 8fdfd29..0000000 --- a/WebCore/platform/qt/ScrollViewQt.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * Copyright (C) 2006 George Staikos <staikos@kde.org> - * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * - * 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 "ScrollView.h" - -namespace WebCore { - -void ScrollView::platformAddChild(Widget*) -{ -} - -void ScrollView::platformRemoveChild(Widget* child) -{ - child->hide(); -} - -} -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/ScrollbarQt.cpp b/WebCore/platform/qt/ScrollbarQt.cpp deleted file mode 100644 index a517064..0000000 --- a/WebCore/platform/qt/ScrollbarQt.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> - * Copyright (C) 2008 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 "Scrollbar.h" - -#include "EventHandler.h" -#include "Frame.h" -#include "FrameView.h" -#include "GraphicsContext.h" -#include "IntRect.h" -#include "PlatformMouseEvent.h" -#include "ScrollbarTheme.h" - -#include <QApplication> -#include <QDebug> -#include <QMenu> -#include <QPainter> -#include <QStyle> - -using namespace std; - -namespace WebCore { - -bool Scrollbar::contextMenu(const PlatformMouseEvent& event) -{ -#ifndef QT_NO_CONTEXTMENU - if (!QApplication::style()->styleHint(QStyle::SH_ScrollBar_ContextMenu)) - return true; - - bool horizontal = (m_orientation == HorizontalScrollbar); - - QMenu menu; - QAction* actScrollHere = menu.addAction(QCoreApplication::translate("QWebPage", "Scroll here")); - menu.addSeparator(); - - QAction* actScrollTop = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Left edge") : QCoreApplication::translate("QWebPage", "Top")); - QAction* actScrollBottom = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Right edge") : QCoreApplication::translate("QWebPage", "Bottom")); - menu.addSeparator(); - - QAction* actPageUp = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Page left") : QCoreApplication::translate("QWebPage", "Page up")); - QAction* actPageDown = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Page right") : QCoreApplication::translate("QWebPage", "Page down")); - menu.addSeparator(); - - QAction* actScrollUp = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Scroll left") : QCoreApplication::translate("QWebPage", "Scroll up")); - QAction* actScrollDown = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Scroll right") : QCoreApplication::translate("QWebPage", "Scroll down")); - - const QPoint globalPos = QPoint(event.globalX(), event.globalY()); - QAction* actionSelected = menu.exec(globalPos); - - if (actionSelected == actScrollHere) { - const QPoint pos = convertFromContainingWindow(event.pos()); - moveThumb(horizontal ? pos.x() : pos.y()); - } else if (actionSelected == actScrollTop) - scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByDocument); - else if (actionSelected == actScrollBottom) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByDocument); - else if (actionSelected == actPageUp) - scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByPage); - else if (actionSelected == actPageDown) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByPage); - else if (actionSelected == actScrollUp) - scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByLine); - else if (actionSelected == actScrollDown) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByLine); -#endif // QT_NO_CONTEXTMENU - return true; -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/ScrollbarThemeQt.cpp b/WebCore/platform/qt/ScrollbarThemeQt.cpp deleted file mode 100644 index 67226b0..0000000 --- a/WebCore/platform/qt/ScrollbarThemeQt.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> - * Copyright (C) 2008 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 "ScrollbarThemeQt.h" - -#include "GraphicsContext.h" -#include "PlatformMouseEvent.h" -#include "RenderThemeQt.h" -#include "ScrollView.h" -#include "Scrollbar.h" - -#include <QApplication> -#include <QDebug> -#include <QMenu> -#include <QPainter> -#include <QStyle> -#include <QStyleOptionSlider> - -namespace WebCore { - -ScrollbarTheme* ScrollbarTheme::nativeTheme() -{ - static ScrollbarThemeQt theme; - return &theme; -} - -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; - } - - return QStyle::SC_None; -} - -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; - } - return NoPart; -} - -static QStyleOptionSlider* styleOptionSlider(Scrollbar* scrollbar, QWidget* widget = 0) -{ - static QStyleOptionSlider opt; - if (widget) - opt.initFrom(widget); - else - opt.state |= QStyle::State_Active; - - opt.state &= ~QStyle::State_HasFocus; - - opt.rect = scrollbar->frameRect(); - if (scrollbar->enabled()) - opt.state |= QStyle::State_Enabled; - if (scrollbar->controlSize() != RegularScrollbar) - opt.state |= QStyle::State_Mini; - opt.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal; - if (scrollbar->orientation() == HorizontalScrollbar) - opt.state |= QStyle::State_Horizontal; - opt.sliderValue = scrollbar->value(); - opt.sliderPosition = opt.sliderValue; - opt.pageStep = scrollbar->pageStep(); - opt.singleStep = scrollbar->lineStep(); - opt.minimum = 0; - opt.maximum = qMax(0, scrollbar->maximum()); - ScrollbarPart pressedPart = scrollbar->pressedPart(); - ScrollbarPart hoveredPart = scrollbar->hoveredPart(); - if (pressedPart != NoPart) { - opt.activeSubControls = scPart(scrollbar->pressedPart()); - if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart - || pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart - || pressedPart == ThumbPart) - opt.state |= QStyle::State_Sunken; - } else - opt.activeSubControls = scPart(hoveredPart); - if (hoveredPart != NoPart) - opt.state |= QStyle::State_MouseOver; - return &opt; -} - -bool ScrollbarThemeQt::paint(Scrollbar* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect) -{ - if (graphicsContext->updatingControlTints()) { - scrollbar->invalidateRect(damageRect); - return false; - } - - StylePainter p(this, graphicsContext); - if (!p.isValid()) - return true; - - p.painter->save(); - QStyleOptionSlider* opt = styleOptionSlider(scrollbar, p.widget); - - p.painter->setClipRect(opt->rect.intersected(damageRect), Qt::IntersectClip); - -#ifdef Q_WS_MAC - p.drawComplexControl(QStyle::CC_ScrollBar, *opt); -#else - const QPoint topLeft = opt->rect.topLeft(); - p.painter->translate(topLeft); - opt->rect.moveTo(QPoint(0, 0)); - - // The QStyle expects the background to be already filled - p.painter->fillRect(opt->rect, opt->palette.background()); - - p.drawComplexControl(QStyle::CC_ScrollBar, *opt); - opt->rect.moveTo(topLeft); -#endif - p.painter->restore(); - - return true; -} - -ScrollbarPart ScrollbarThemeQt::hitTest(Scrollbar* scrollbar, const PlatformMouseEvent& evt) -{ - QStyleOptionSlider* opt = styleOptionSlider(scrollbar); - const QPoint pos = scrollbar->convertFromContainingWindow(evt.pos()); - opt->rect.moveTo(QPoint(0, 0)); - QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0); - return scrollbarPart(sc); -} - -bool ScrollbarThemeQt::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt) -{ - // Middle click centers slider thumb (if supported) - return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton; -} - -void ScrollbarThemeQt::invalidatePart(Scrollbar* scrollbar, ScrollbarPart) -{ - // FIXME: Do more precise invalidation. - scrollbar->invalidate(); -} - -int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize) -{ - QStyleOptionSlider o; - o.orientation = Qt::Vertical; - o.state &= ~QStyle::State_Horizontal; - if (controlSize != RegularScrollbar) - o.state |= QStyle::State_Mini; - return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0); -} - -int ScrollbarThemeQt::thumbPosition(Scrollbar* scrollbar) -{ - if (scrollbar->enabled()) - return (int)((float)scrollbar->currentPos() * (trackLength(scrollbar) - thumbLength(scrollbar)) / scrollbar->maximum()); - return 0; -} - -int ScrollbarThemeQt::thumbLength(Scrollbar* scrollbar) -{ - QStyleOptionSlider* opt = styleOptionSlider(scrollbar); - IntRect thumb = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0); - return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height(); -} - -int ScrollbarThemeQt::trackPosition(Scrollbar* scrollbar) -{ - QStyleOptionSlider* opt = styleOptionSlider(scrollbar); - IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0); - return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y(); -} - -int ScrollbarThemeQt::trackLength(Scrollbar* scrollbar) -{ - QStyleOptionSlider* opt = styleOptionSlider(scrollbar); - IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0); - return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height(); -} - -void ScrollbarThemeQt::paintScrollCorner(ScrollView* scrollView, GraphicsContext* context, const IntRect& rect) -{ - if (context->updatingControlTints()) { - scrollView->invalidateRect(rect); - return; - } - - StylePainter p(this, context); - if (!p.isValid()) - return; - - QStyleOption option; - option.rect = rect; - p.drawPrimitive(QStyle::PE_PanelScrollAreaCorner, option); -} - -QStyle* ScrollbarThemeQt::style() const -{ - return QApplication::style(); -} - -} - diff --git a/WebCore/platform/qt/ScrollbarThemeQt.h b/WebCore/platform/qt/ScrollbarThemeQt.h deleted file mode 100644 index cf4882d..0000000 --- a/WebCore/platform/qt/ScrollbarThemeQt.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. 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 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 ScrollbarThemeQt_h -#define ScrollbarThemeQt_h - -#include "ScrollbarTheme.h" - -#include <QtCore/qglobal.h> - -QT_BEGIN_NAMESPACE -class QStyle; -QT_END_NAMESPACE - -namespace WebCore { - -class ScrollbarThemeQt : public ScrollbarTheme { -public: - virtual ~ScrollbarThemeQt(); - - virtual bool paint(Scrollbar*, GraphicsContext*, const IntRect& damageRect); - virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect); - - virtual ScrollbarPart hitTest(Scrollbar*, const PlatformMouseEvent&); - - virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&); - - virtual void invalidatePart(Scrollbar*, ScrollbarPart); - - virtual int thumbPosition(Scrollbar*); - virtual int thumbLength(Scrollbar*); - virtual int trackPosition(Scrollbar*); - virtual int trackLength(Scrollbar*); - - virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar); - - QStyle* style() const; -}; - -} -#endif diff --git a/WebCore/platform/qt/SharedBufferQt.cpp b/WebCore/platform/qt/SharedBufferQt.cpp deleted file mode 100644 index 6b7f9c9..0000000 --- a/WebCore/platform/qt/SharedBufferQt.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 Holger Hans Peter Freyther - * - * 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 "SharedBuffer.h" - -#include <QFile> - -namespace WebCore { - -PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& fileName) -{ - if (fileName.isEmpty()) - return 0; - - QFile file(fileName); - if (!file.exists() || !file.open(QFile::ReadOnly)) - return 0; - - 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 deleted file mode 100644 index 8a6bd81..0000000 --- a/WebCore/platform/qt/SharedTimerQt.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2006 George Staikos <staikos@kde.org> - * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> - * Copyright (C) 2008 Holger Hans Peter Freyther - * - * 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 <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(); - - void start(double); - void stop(); - -protected: - void timerEvent(QTimerEvent* ev); - -private slots: - void destroy(); - -private: - SharedTimerQt(); - ~SharedTimerQt(); - QBasicTimer m_timer; - void (*m_timerFunction)(); -}; - -SharedTimerQt::SharedTimerQt() - : QObject() - , m_timerFunction(0) -{} - -SharedTimerQt::~SharedTimerQt() -{ - if (m_timer.isActive()) - (m_timerFunction)(); -} - -void SharedTimerQt::destroy() -{ - delete this; -} - -SharedTimerQt* SharedTimerQt::inst() -{ - static QPointer<SharedTimerQt> timer; - if (!timer) { - timer = new SharedTimerQt(); - timer->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(destroy())); - } - - return timer; -} - -void SharedTimerQt::start(double fireTime) -{ - double interval = fireTime - currentTime(); - unsigned int intervalInMS; - if (interval < 0) - intervalInMS = 0; - else { - interval *= 1000; - intervalInMS = (unsigned int)interval; - } - - m_timer.start(intervalInMS, this); -} - -void SharedTimerQt::stop() -{ - m_timer.stop(); -} - -void SharedTimerQt::timerEvent(QTimerEvent* ev) -{ - if (!m_timerFunction || ev->timerId() != m_timer.timerId()) - return; - - m_timer.stop(); - (m_timerFunction)(); -} - -void setSharedTimerFiredFunction(void (*f)()) -{ - if (!QCoreApplication::instance()) - return; - - SharedTimerQt::inst()->m_timerFunction = f; -} - -void setSharedTimerFireTime(double fireTime) -{ - if (!QCoreApplication::instance()) - return; - - SharedTimerQt::inst()->start(fireTime); -} - -void stopSharedTimer() -{ - if (!QCoreApplication::instance()) - return; - - 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 deleted file mode 100644 index bf9e142..0000000 --- a/WebCore/platform/qt/SoundQt.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * - * 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 "Sound.h" - -#include <QApplication> - -namespace WebCore { - -void systemBeep() -{ - QApplication::beep(); -} - -} - -// vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/TemporaryLinkStubsQt.cpp b/WebCore/platform/qt/TemporaryLinkStubsQt.cpp deleted file mode 100644 index a46b82c..0000000 --- a/WebCore/platform/qt/TemporaryLinkStubsQt.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com - * Copyright (C) 2006 George Staikos <staikos@kde.org> - * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> - * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2008 Collabora, Ltd. - * - * 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 "AXObjectCache.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 "FrameView.h" -#include "GraphicsContext.h" -#include "IconLoader.h" -#include "IntPoint.h" -#include "KURL.h" -#include "Language.h" -#include "LocalizedStrings.h" -#include "Node.h" -#include "NotImplemented.h" -#include "Path.h" -#include "PlatformMouseEvent.h" -#include "PluginDatabase.h" -#include "PluginPackage.h" -#include "PluginView.h" -#include "RenderTheme.h" -#include "SharedBuffer.h" -#include "SystemTime.h" -#include "TextBoundaries.h" -#include "Widget.h" - -#include <float.h> -#include <stdio.h> -#include <stdlib.h> -#include <wtf/text/CString.h> - -using namespace WebCore; - -#if defined(Q_OS_WINCE) -Vector<String> PluginDatabase::defaultPluginDirectories() -{ - notImplemented(); - return Vector<String>(); -} - -void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const -{ - notImplemented(); -} - -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 { - -void getSupportedKeySizes(Vector<String>&) -{ - notImplemented(); -} - -String signedPublicKeyAndChallengeString(unsigned, const String&, const KURL&) -{ - return String(); -} - -#if !defined(Q_OS_WIN) -// defined in win/SystemTimeWin.cpp, which is compiled for the Qt/Windows port -float userIdleTime() -{ - notImplemented(); - return FLT_MAX; // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed -} -#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 deleted file mode 100644 index 57a7ebc..0000000 --- a/WebCore/platform/qt/WheelEventQt.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2008 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 "WheelEvent.h" - -#include "PlatformMouseEvent.h" -#include "PlatformWheelEvent.h" -#include "Scrollbar.h" - -#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 = (fullTick) ? delta / 120.0f : delta; - m_deltaY = 0; - } else { - m_deltaX = 0; - m_deltaY = (fullTick) ? delta / 120.0f : delta; - } - - m_wheelTicksX = m_deltaX; - m_wheelTicksY = m_deltaY; - - // Use the same single scroll step as QTextEdit - // (in QTextEditPrivate::init [h,v]bar->setSingleStep) - static const float cDefaultQtScrollStep = 20.f; -#ifndef QT_NO_WHEELEVENT - m_deltaX *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1; - m_deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1; -#endif -} - -PlatformWheelEvent::PlatformWheelEvent(QGraphicsSceneWheelEvent* e) -#ifndef QT_NO_WHEELEVENT - : m_position(e->pos().toPoint()) - , m_globalPosition(e->screenPos()) - , m_granularity(ScrollByPixelWheelEvent) - , m_isAccepted(false) - , m_shiftKey(e->modifiers() & Qt::ShiftModifier) - , 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 -} - -PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e) -#ifndef QT_NO_WHEELEVENT - : m_position(e->pos()) - , m_globalPosition(e->globalPos()) - , m_granularity(ScrollByPixelWheelEvent) - , m_isAccepted(false) - , m_shiftKey(e->modifiers() & Qt::ShiftModifier) - , 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 -} - -} // namespace WebCore diff --git a/WebCore/platform/qt/WidgetQt.cpp b/WebCore/platform/qt/WidgetQt.cpp deleted file mode 100644 index e64d655..0000000 --- a/WebCore/platform/qt/WidgetQt.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2006 Dirk Mueller <mueller@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 - * - * 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 "Widget.h" - -#include "Cursor.h" -#include "Font.h" -#include "GraphicsContext.h" -#include "HostWindow.h" -#include "IntRect.h" -#include "NotImplemented.h" -#include "QWebPageClient.h" -#include "ScrollView.h" - -#include <QCoreApplication> -#include <QDebug> -#include <QPaintEngine> -#include <QPainter> -#include <QWidget> - -namespace WebCore { - -Widget::Widget(QWidget* widget) -{ - init(widget); -} - -Widget::~Widget() -{ - Q_ASSERT(!parent()); -} - -IntRect Widget::frameRect() const -{ - return m_frame; -} - -void Widget::setFrameRect(const IntRect& rect) -{ - m_frame = rect; - - frameRectsChanged(); -} - -void Widget::setFocus(bool focused) -{ -} - -void Widget::setCursor(const Cursor& cursor) -{ -#ifndef QT_NO_CURSOR - ScrollView* view = root(); - if (!view) - return; - view->hostWindow()->setCursor(cursor); -#endif -} - -void Widget::show() -{ - setSelfVisible(true); - - if (isParentVisible() && platformWidget()) - platformWidget()->show(); -} - -void Widget::hide() -{ - setSelfVisible(false); - - if (isParentVisible() && platformWidget()) - platformWidget()->hide(); -} - -void Widget::paint(GraphicsContext*, const IntRect&) -{ -} - -void Widget::setIsSelected(bool) -{ - notImplemented(); -} - -} - -// vim: ts=4 sw=4 et |