diff options
Diffstat (limited to 'Source/WebKit2/Shared/qt')
-rw-r--r-- | Source/WebKit2/Shared/qt/CleanupHandler.cpp | 58 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/CleanupHandler.h | 76 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/NativeWebKeyboardEventQt.cpp | 38 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/PlatformCertificateInfo.h | 57 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp | 58 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/UpdateChunk.cpp | 118 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/UpdateChunk.h | 66 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp | 53 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp | 209 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/WebEventFactoryQt.h | 54 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/WebURLRequestQt.cpp | 41 | ||||
-rw-r--r-- | Source/WebKit2/Shared/qt/WebURLResponseQt.cpp | 41 |
12 files changed, 869 insertions, 0 deletions
diff --git a/Source/WebKit2/Shared/qt/CleanupHandler.cpp b/Source/WebKit2/Shared/qt/CleanupHandler.cpp new file mode 100644 index 0000000..74c1d4c --- /dev/null +++ b/Source/WebKit2/Shared/qt/CleanupHandler.cpp @@ -0,0 +1,58 @@ +/* + * 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 INC. 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 INC. 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 "CleanupHandler.h" + +#include "MappedMemoryPool.h" +#include "RunLoop.h" +#include <csignal> +#include <cstdlib> +#include <QApplication> + +namespace WebKit { + +CleanupHandler* CleanupHandler::theInstance = 0; + +CleanupHandler::CleanupHandler() + : m_hasStartedDeleting(false) +{ + moveToThread(qApp->thread()); // Ensure that we are acting on the main thread. + connect(qApp, SIGNAL(aboutToQuit()), SLOT(deleteObjects()), Qt::DirectConnection); + signal(SIGTERM, &CleanupHandler::sigTermHandler); +} + +void CleanupHandler::sigTermHandler(int) +{ + ::RunLoop::main()->stop(); +} + +void CleanupHandler::deleteObjects() +{ + m_hasStartedDeleting = true; + for (unsigned i = 0; i < m_objects.size(); ++i) + m_objects[i]->deleteLater(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/CleanupHandler.h b/Source/WebKit2/Shared/qt/CleanupHandler.h new file mode 100644 index 0000000..afd7723 --- /dev/null +++ b/Source/WebKit2/Shared/qt/CleanupHandler.h @@ -0,0 +1,76 @@ +/* + * 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 INC. 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 INC. 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. + */ + +#ifndef CleanupHandler_h +#define CleanupHandler_h + +#include <QCoreApplication> +#include <QList> +#include <QObject> +#include <wtf/HashSet.h> +#include <wtf/StdLibExtras.h> + +namespace WebKit { + +class CleanupHandler : private QObject { + Q_OBJECT +public: + static CleanupHandler* instance() + { + if (!theInstance) + theInstance = new CleanupHandler(); + return theInstance; + } + + void markForCleanup(QObject* object) + { + m_objects.append(object); + } + + void unmark(QObject* object) + { + if (m_hasStartedDeleting) + return; + m_objects.removeOne(object); + } + + bool hasStartedDeleting() const { return m_hasStartedDeleting; } + +private slots: + void deleteObjects(); + +private: + static void sigTermHandler(int); + static CleanupHandler* theInstance; + + CleanupHandler(); + + QList<QObject*> m_objects; + bool m_hasStartedDeleting; +}; + +} // namespace WebKit + +#endif // CleanupHandler_h diff --git a/Source/WebKit2/Shared/qt/NativeWebKeyboardEventQt.cpp b/Source/WebKit2/Shared/qt/NativeWebKeyboardEventQt.cpp new file mode 100644 index 0000000..d0d247c --- /dev/null +++ b/Source/WebKit2/Shared/qt/NativeWebKeyboardEventQt.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "NativeWebKeyboardEvent.h" + +#include "WebEventFactoryQt.h" + +namespace WebKit { + +NativeWebKeyboardEvent::NativeWebKeyboardEvent(QKeyEvent* event) + : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event)) + , m_nativeEvent(*event) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/PlatformCertificateInfo.h b/Source/WebKit2/Shared/qt/PlatformCertificateInfo.h new file mode 100644 index 0000000..32776f7 --- /dev/null +++ b/Source/WebKit2/Shared/qt/PlatformCertificateInfo.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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. + */ + +#ifndef PlatformCertificateInfo_h +#define PlatformCertificateInfo_h + +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" +#include <WebCore/ResourceResponse.h> + +namespace WebKit { + +class PlatformCertificateInfo { +public: + PlatformCertificateInfo() + { + } + + explicit PlatformCertificateInfo(const WebCore::ResourceResponse&) + { + } + + void encode(CoreIPC::ArgumentEncoder*) const + { + } + + static bool decode(CoreIPC::ArgumentDecoder*, PlatformCertificateInfo&) + { + return true; + } +}; + +} // namespace WebKit + +#endif // PlatformCertificateInfo_h diff --git a/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp b/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp new file mode 100644 index 0000000..184b0f8 --- /dev/null +++ b/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "ShareableBitmap.h" + +#include <QImage> +#include <QPainter> +#include <WebCore/GraphicsContext.h> + +using namespace WebCore; + +namespace WebKit { + +static inline QImage createQImage(void* data, int width, int height) +{ + return QImage(reinterpret_cast<uchar*>(data), width, height, width * 4, QImage::Format_RGB32); +} + +PassOwnPtr<GraphicsContext> ShareableBitmap::createGraphicsContext() +{ + QImage* image = new QImage(createQImage(data(), m_size.width(), m_size.height())); + GraphicsContext* context = new GraphicsContext(new QPainter(image)); + context->takeOwnershipOfPlatformContext(); + return context; +} + +void ShareableBitmap::paint(GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect) +{ + QImage image = createQImage(data(), m_size.width(), m_size.height()); + QPainter* painter = context.platformContext(); + painter->translate(-srcRect.x(), -srcRect.y()); + painter->drawImage(dstPoint, image, QRect(srcRect)); + painter->translate(srcRect.x(), srcRect.y()); +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/UpdateChunk.cpp b/Source/WebKit2/Shared/qt/UpdateChunk.cpp new file mode 100644 index 0000000..4d8e62d --- /dev/null +++ b/Source/WebKit2/Shared/qt/UpdateChunk.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2010 University of Szeged + * + * 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. 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 INC. 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 "UpdateChunk.h" + +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" +#include "MappedMemoryPool.h" +#include "WebCoreArgumentCoders.h" +#include <QIODevice> +#include <QImage> +#include <QPixmap> +#include <WebCore/FloatRect.h> +#include <wtf/text/WTFString.h> + +using namespace WebCore; +using namespace std; + +namespace WebKit { + +UpdateChunk::UpdateChunk() + : m_mappedMemory(0) +{ +} + +UpdateChunk::UpdateChunk(const IntRect& rect) + : m_rect(rect) + , m_mappedMemory(MappedMemoryPool::instance()->mapMemory(size())) +{ +} + +UpdateChunk::~UpdateChunk() +{ + if (m_mappedMemory) + m_mappedMemory->markFree(); +} + +void UpdateChunk::encode(CoreIPC::ArgumentEncoder* encoder) const +{ + encoder->encode(m_rect); + encoder->encode(String(m_mappedMemory->mappedFileName())); + + m_mappedMemory = 0; +} + +bool UpdateChunk::decode(CoreIPC::ArgumentDecoder* decoder, UpdateChunk& chunk) +{ + ASSERT_ARG(chunk, chunk.isEmpty()); + + IntRect rect; + if (!decoder->decode(rect)) + return false; + chunk.m_rect = rect; + + if (chunk.isEmpty()) + return true; // Successfully decoded empty chunk. + + String fileName; + if (!decoder->decode(fileName)) + return false; + + chunk.m_mappedMemory = MappedMemoryPool::instance()->mapFile(fileName, chunk.size()); + return true; +} + +size_t UpdateChunk::size() const +{ + int bpp; + if (QPixmap::defaultDepth() == 16) + bpp = 2; + else + bpp = 4; + + return ((m_rect.width() * bpp + 3) & ~0x3) + * m_rect.height(); +} + +QImage UpdateChunk::createImage() const +{ + ASSERT(m_mappedMemory); + QImage::Format format; + int bpp; + if (QPixmap::defaultDepth() == 16) { + format = QImage::Format_RGB16; + bpp = 2; + } else { + format = QImage::Format_RGB32; + bpp = 4; + } + + return QImage(m_mappedMemory->data(), m_rect.width(), m_rect.height(), (m_rect.width() * bpp + 3) & ~0x3, format); +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/UpdateChunk.h b/Source/WebKit2/Shared/qt/UpdateChunk.h new file mode 100644 index 0000000..f506ba7 --- /dev/null +++ b/Source/WebKit2/Shared/qt/UpdateChunk.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * 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. 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 INC. 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. + */ + +#ifndef UpdateChunk_h +#define UpdateChunk_h + +#include <QImage> +#include <WebCore/IntRect.h> + +namespace CoreIPC { +class ArgumentEncoder; +class ArgumentDecoder; +} + +namespace WebKit { + +class MappedMemory; + +class UpdateChunk { +public: + UpdateChunk(); + UpdateChunk(const WebCore::IntRect&); + ~UpdateChunk(); + + const WebCore::IntRect& rect() const { return m_rect; } + bool isEmpty() const { return m_rect.isEmpty(); } + + void encode(CoreIPC::ArgumentEncoder*) const; + static bool decode(CoreIPC::ArgumentDecoder*, UpdateChunk&); + + QImage createImage() const; + +private: + size_t size() const; + + WebCore::IntRect m_rect; + + mutable MappedMemory* m_mappedMemory; +}; + +} // namespace WebKit + +#endif // UpdateChunk_h diff --git a/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp b/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp new file mode 100644 index 0000000..80ab3f9 --- /dev/null +++ b/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "WebCoreArgumentCoders.h" +#include "NotImplemented.h" + +namespace CoreIPC { + +void encodeResourceRequest(ArgumentEncoder* encoder, const WebCore::ResourceRequest& resourceRequest) +{ + notImplemented(); +} + +bool decodeResourceRequest(ArgumentDecoder* decoder, WebCore::ResourceRequest& resourceRequest) +{ + notImplemented(); + return false; +} + +void encodeResourceResponse(ArgumentEncoder* encoder, const WebCore::ResourceResponse& resourceResponse) +{ + notImplemented(); +} + +bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse& resourceResponse) +{ + notImplemented(); + return false; +} + +} // namespace CoreIPC diff --git a/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp b/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp new file mode 100644 index 0000000..39a6455 --- /dev/null +++ b/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * 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. 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 INC. 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 "WebEventFactoryQt.h" +#include <qgraphicssceneevent.h> +#include <QApplication> +#include <QKeyEvent> +#include <WebCore/IntPoint.h> +#include <WebCore/FloatPoint.h> +#include <WebCore/PlatformKeyboardEvent.h> +#include <wtf/ASCIICType.h> +#include <wtf/CurrentTime.h> + +using namespace WebCore; + +namespace WebKit { + +static WebMouseEvent::Button mouseButtonForEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton)) + return WebMouseEvent::LeftButton; + else if (event->button() == Qt::RightButton || (event->buttons() & Qt::RightButton)) + return WebMouseEvent::RightButton; + else if (event->button() == Qt::MidButton || (event->buttons() & Qt::MidButton)) + return WebMouseEvent::MiddleButton; + return WebMouseEvent::NoButton; +} + +static WebEvent::Type webEventTypeForEvent(QEvent* event) +{ + switch (event->type()) { + case QEvent::GraphicsSceneMouseDoubleClick: + case QEvent::GraphicsSceneMousePress: + return WebEvent::MouseDown; + case QEvent::GraphicsSceneMouseRelease: + return WebEvent::MouseUp; + case QEvent::GraphicsSceneMouseMove: + return WebEvent::MouseMove; + case QEvent::Wheel: + return WebEvent::Wheel; + case QEvent::KeyPress: + return WebEvent::KeyDown; + case QEvent::KeyRelease: + return WebEvent::KeyUp; +#if ENABLE(TOUCH_EVENTS) + case QEvent::TouchBegin: + return WebEvent::TouchStart; + case QEvent::TouchUpdate: + return WebEvent::TouchMove; + case QEvent::TouchEnd: + return WebEvent::TouchEnd; +#endif + default: + // assert + return WebEvent::MouseMove; + } +} + +static inline WebEvent::Modifiers modifiersForEvent(Qt::KeyboardModifiers modifiers) +{ + unsigned result = 0; + if (modifiers & Qt::ShiftModifier) + result |= WebEvent::ShiftKey; + if (modifiers & Qt::ControlModifier) + result |= WebEvent::ControlKey; + if (modifiers & Qt::AltModifier) + result |= WebEvent::AltKey; + if (modifiers & Qt::MetaModifier) + result |= WebEvent::MetaKey; + return (WebEvent::Modifiers)result; +} + +WebMouseEvent WebEventFactory::createWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount) +{ + FloatPoint delta(event->pos().x() - event->lastPos().x(), event->pos().y() - event->lastPos().y()); + + WebEvent::Type type = webEventTypeForEvent(event); + WebMouseEvent::Button button = mouseButtonForEvent(event); + float deltaX = delta.x(); + float deltaY = delta.y(); + int clickCount = eventClickCount; + WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers()); + double timestamp = WTF::currentTime(); + + return WebMouseEvent(type, button, event->pos().toPoint(), event->screenPos(), deltaX, deltaY, 0.0f, clickCount, modifiers, timestamp); +} + +WebWheelEvent WebEventFactory::createWebWheelEvent(QGraphicsSceneWheelEvent* e) +{ + float deltaX = 0; + float deltaY = 0; + float wheelTicksX = 0; + float wheelTicksY = 0; + WebWheelEvent::Granularity granularity = WebWheelEvent::ScrollByPixelWheelEvent; + WebEvent::Modifiers modifiers = modifiersForEvent(e->modifiers()); + double timestamp = WTF::currentTime(); + + // 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 = !(e->delta() % 120); + + if (e->orientation() == Qt::Horizontal) { + deltaX = (fullTick) ? e->delta() / 120.0f : e->delta(); + wheelTicksX = deltaX; + } else { + deltaY = (fullTick) ? e->delta() / 120.0f : e->delta(); + wheelTicksY = 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 + deltaX *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1; + deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1; +#endif + + return WebWheelEvent(WebEvent::Wheel, e->pos().toPoint(), e->screenPos(), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp); +} + +WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(QKeyEvent* event) +{ + const int state = event->modifiers(); + WebEvent::Type type = webEventTypeForEvent(event); + const String text = event->text(); + const String unmodifiedText = event->text(); + bool isAutoRepeat = event->isAutoRepeat(); + bool isSystemKey = false; // FIXME: No idea what that is. + bool isKeypad = (state & Qt::KeypadModifier); + const String keyIdentifier = keyIdentifierForQtKeyCode(event->key()); + int windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event->key(), isKeypad); + int nativeVirtualKeyCode = event->nativeVirtualKey(); + int macCharCode = 0; + WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers()); + double timestamp = WTF::currentTime(); + + return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp); +} + +#if ENABLE(TOUCH_EVENTS) + +WebTouchEvent WebEventFactory::createWebTouchEvent(QTouchEvent* event) +{ + WebEvent::Type type = webEventTypeForEvent(event); + WebPlatformTouchPoint::TouchPointState state = static_cast<WebPlatformTouchPoint::TouchPointState>(0); + unsigned int id; + WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers()); + double timestamp = WTF::currentTime(); + + const QList<QTouchEvent::TouchPoint>& points = event->touchPoints(); + + Vector<WebPlatformTouchPoint> m_touchPoints; + for (int i = 0; i < points.count(); ++i) { + id = static_cast<unsigned>(points.at(i).id()); + switch (points.at(i).state()) { + case Qt::TouchPointReleased: + state = WebPlatformTouchPoint::TouchReleased; + break; + case Qt::TouchPointMoved: + state = WebPlatformTouchPoint::TouchMoved; + break; + case Qt::TouchPointPressed: + state = WebPlatformTouchPoint::TouchPressed; + break; + case Qt::TouchPointStationary: + state = WebPlatformTouchPoint::TouchStationary; + break; + default: + ASSERT_NOT_REACHED(); + break; + } + + m_touchPoints.append(WebPlatformTouchPoint(id, state, points.at(i).screenPos().toPoint(), points.at(i).pos().toPoint())); + } + + bool m_ctrlKey = (event->modifiers() & Qt::ControlModifier); + bool m_altKey = (event->modifiers() & Qt::AltModifier); + bool m_shiftKey = (event->modifiers() & Qt::ShiftModifier); + bool m_metaKey = (event->modifiers() & Qt::MetaModifier); + + return WebTouchEvent(type, m_touchPoints, m_ctrlKey, m_altKey, m_shiftKey, m_metaKey, modifiers, timestamp); +} +#endif + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/WebEventFactoryQt.h b/Source/WebKit2/Shared/qt/WebEventFactoryQt.h new file mode 100644 index 0000000..7864b16 --- /dev/null +++ b/Source/WebKit2/Shared/qt/WebEventFactoryQt.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * 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. 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 INC. 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. + */ + +#ifndef WebEventFactory_h +#define WebEventFactory_h + +#include "WebEvent.h" + +#if ENABLE(TOUCH_EVENTS) +class QTouchEvent; +#endif + +class QGraphicsSceneMouseEvent; +class QGraphicsSceneWheelEvent; +class QKeyEvent; + +namespace WebKit { + +class WebEventFactory { +public: + static WebMouseEvent createWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount); + static WebWheelEvent createWebWheelEvent(QGraphicsSceneWheelEvent* event); + static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent* event); +#if ENABLE(TOUCH_EVENTS) + static WebTouchEvent createWebTouchEvent(QTouchEvent* event); +#endif +}; + +} // namespace WebKit + +#endif // WebEventFactory_h diff --git a/Source/WebKit2/Shared/qt/WebURLRequestQt.cpp b/Source/WebKit2/Shared/qt/WebURLRequestQt.cpp new file mode 100644 index 0000000..834353a --- /dev/null +++ b/Source/WebKit2/Shared/qt/WebURLRequestQt.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "WebURLRequest.h" + +namespace WebKit { + +WebURLRequest::WebURLRequest(PlatformRequest) +{ + ASSERT_NOT_REACHED(); +} + +PlatformRequest WebURLRequest::platformRequest() const +{ + ASSERT_NOT_REACHED(); + return 0; +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/WebURLResponseQt.cpp b/Source/WebKit2/Shared/qt/WebURLResponseQt.cpp new file mode 100644 index 0000000..abc0c29 --- /dev/null +++ b/Source/WebKit2/Shared/qt/WebURLResponseQt.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "WebURLResponse.h" + +namespace WebKit { + +WebURLResponse::WebURLResponse(PlatformResponse) +{ + ASSERT_NOT_REACHED(); +} + +PlatformResponse WebURLResponse::platformResponse() const +{ + ASSERT_NOT_REACHED(); + return 0; +} + +} // namespace WebKit |