[Qt][WK2] Private non-QtQuick API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Jun 2012 04:18:40 +0000 (04:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Jun 2012 04:18:40 +0000 (04:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84532

.:

Patch by Luiz Agostini <luiz.agostini@nokia.com> on 2012-06-29
Reviewed by Noam Rosenthal.

API tests for QRawWebView.

* Source/tests.pri:

Source/WebKit2:

Patch by Luiz Agostini <luiz.agostini@nokia.com> on 2012-06-29
Reviewed by Noam Rosenthal.

Adding new private non-QtQuick API. This new C++ API makes it possible
to have control over the lower levels of WebKit without going via QML.

This is a first version of the API, enough to show pages on the screen.
Many features are not implemented.

* Target.pri:
* UIProcess/API/qt/raw/qrawwebview.cpp: Added.
* UIProcess/API/qt/raw/qrawwebview_p.h: Added.
* UIProcess/API/qt/raw/qrawwebview_p_p.h: Added.

The tests for the new API are pixel tests. They use QRawWebView to load
html files and generate images, and them compare those images to the ones
in UIProcess/API/qt/tests/html/resources.

* UIProcess/API/qt/tests/html/bluesquare.html: Added.
* UIProcess/API/qt/tests/html/redsquare.html: Added.
* UIProcess/API/qt/tests/html/resources/qwkview_noBackground1.png: Added.
* UIProcess/API/qt/tests/html/resources/qwkview_noBackground3.png: Added.
* UIProcess/API/qt/tests/html/resources/qwkview_paint.png: Added.
* UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro: Added.
* UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp: Added.

Tools:

MiniBrowserRaw is an usage example for the QRawWebView API.
It is only an example and is not fully implemented.

Patch by Luiz Agostini <luiz.agostini@nokia.com> on 2012-06-29
Reviewed by Noam Rosenthal.

* MiniBrowser/qt/raw/DerivedSources.pri: Added.
* MiniBrowser/qt/raw/MiniBrowserRaw.pro: Added.
* MiniBrowser/qt/raw/Target.pri: Added.
* MiniBrowser/qt/raw/View.cpp: Added.
* MiniBrowser/qt/raw/View.h: Added.
* Scripts/webkitpy/style/checker.py:
* Tools.pro:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121620 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
ChangeLog
Source/WebKit2/ChangeLog
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/html/bluesquare.html [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/html/redsquare.html [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground1.png [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground3.png [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_paint.png [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp [new file with mode: 0644]
Source/tests.pri
Tools/ChangeLog
Tools/MiniBrowser/qt/raw/DerivedSources.pri [new file with mode: 0644]
Tools/MiniBrowser/qt/raw/MiniBrowserRaw.pro [new file with mode: 0644]
Tools/MiniBrowser/qt/raw/Target.pri [new file with mode: 0644]
Tools/MiniBrowser/qt/raw/View.cpp [new file with mode: 0644]
Tools/MiniBrowser/qt/raw/View.h [new file with mode: 0644]
Tools/Scripts/webkitpy/style/checker.py
Tools/Tools.pro

index a8f465d..9ef46fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-06-29  Luiz Agostini  <luiz.agostini@nokia.com>
+
+        [Qt][WK2] Private non-QtQuick API
+        https://bugs.webkit.org/show_bug.cgi?id=84532
+
+        Reviewed by Noam Rosenthal.
+
+        API tests for QRawWebView.
+
+        * Source/tests.pri:
+
 2012-06-29  Zan Dobersek  <zandobersek@gmail.com>
 
         Unreviewed build fix after r121518, adding a missing symbol to symbols.filter.
index 0ae1889..2e33673 100644 (file)
@@ -1,3 +1,33 @@
+2012-06-29  Luiz Agostini  <luiz.agostini@nokia.com>
+
+        [Qt][WK2] Private non-QtQuick API
+        https://bugs.webkit.org/show_bug.cgi?id=84532
+
+        Reviewed by Noam Rosenthal.
+
+        Adding new private non-QtQuick API. This new C++ API makes it possible
+        to have control over the lower levels of WebKit without going via QML.
+
+        This is a first version of the API, enough to show pages on the screen.
+        Many features are not implemented.
+
+        * Target.pri:
+        * UIProcess/API/qt/raw/qrawwebview.cpp: Added.
+        * UIProcess/API/qt/raw/qrawwebview_p.h: Added.
+        * UIProcess/API/qt/raw/qrawwebview_p_p.h: Added.
+
+        The tests for the new API are pixel tests. They use QRawWebView to load
+        html files and generate images, and them compare those images to the ones
+        in UIProcess/API/qt/tests/html/resources.
+
+        * UIProcess/API/qt/tests/html/bluesquare.html: Added.
+        * UIProcess/API/qt/tests/html/redsquare.html: Added.
+        * UIProcess/API/qt/tests/html/resources/qwkview_noBackground1.png: Added.
+        * UIProcess/API/qt/tests/html/resources/qwkview_noBackground3.png: Added.
+        * UIProcess/API/qt/tests/html/resources/qwkview_paint.png: Added.
+        * UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro: Added.
+        * UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp: Added.
+
 2012-06-29  Christophe Dumez  <christophe.dumez@intel.com>
 
         [WK2] Move intent delivery code from the frame to the page
index d827adb..2700582 100644 (file)
@@ -201,6 +201,8 @@ HEADERS += \
     UIProcess/API/qt/qquicknetworkrequest_p.h \
     UIProcess/API/qt/qquickurlschemedelegate_p.h \
     UIProcess/API/qt/qwebkittest_p.h \
+    UIProcess/API/qt/raw/qrawwebview_p.h \
+    UIProcess/API/qt/raw/qrawwebview_p_p.h \
     UIProcess/Authentication/AuthenticationChallengeProxy.h \
     UIProcess/Authentication/AuthenticationDecisionListener.h \
     UIProcess/Authentication/WebCredential.h \
@@ -551,6 +553,7 @@ SOURCES += \
     UIProcess/API/qt/qquickurlschemedelegate.cpp \
     UIProcess/API/qt/qwebpreferences.cpp \
     UIProcess/API/qt/qwebkittest.cpp \
+    UIProcess/API/qt/raw/qrawwebview.cpp \
     UIProcess/Authentication/AuthenticationChallengeProxy.cpp \
     UIProcess/Authentication/AuthenticationDecisionListener.cpp \
     UIProcess/Authentication/WebCredential.cpp \
diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
new file mode 100644 (file)
index 0000000..875ed1d
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+    Copyright (C) 2012 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 "qrawwebview_p.h"
+
+#include "Cursor.h"
+#include "DrawingAreaProxyImpl.h"
+#include "LayerTreeCoordinatorProxy.h"
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebMouseEvent.h"
+#include "NativeWebTouchEvent.h"
+#include "NativeWebWheelEvent.h"
+#include "NotImplemented.h"
+#include "WebContext.h"
+#include "WebLayerTreeRenderer.h"
+#include "WebPageGroup.h"
+#include "WebPreferences.h"
+#include "qrawwebview_p_p.h"
+#include <WebKit2/qrawwebview_p.h>
+
+void QRawWebViewPrivate::didReceiveMessageFromNavigatorQtObject(const String& message)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportAttributes& attr)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::handleDownloadRequest(WebKit::DownloadProxy* download)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::handleProxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo)
+{
+    notImplemented();
+}
+
+bool QRawWebViewPrivate::canUndoRedo(WebKit::WebPageProxy::UndoOrRedo undoOrRedo)
+{
+    notImplemented();
+    return false;
+}
+
+void QRawWebViewPrivate::executeUndoRedo(WebKit::WebPageProxy::UndoOrRedo undoOrRedo)
+{
+    notImplemented();
+}
+
+WebCore::FloatRect QRawWebViewPrivate::convertToDeviceSpace(const WebCore::FloatRect& rect)
+{
+    notImplemented();
+    return rect;
+}
+
+WebCore::FloatRect QRawWebViewPrivate::convertToUserSpace(const WebCore::FloatRect& rect)
+{
+    notImplemented();
+    return rect;
+}
+
+WebCore::IntPoint QRawWebViewPrivate::screenToWindow(const WebCore::IntPoint& point)
+{
+    notImplemented();
+    return point;
+}
+
+WebCore::IntRect QRawWebViewPrivate::windowToScreen(const WebCore::IntRect& rect)
+{
+    notImplemented();
+    return rect;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void QRawWebViewPrivate::enterAcceleratedCompositingMode(const WebKit::LayerTreeContext&)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::exitAcceleratedCompositingMode()
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::updateAcceleratedCompositingMode(const WebKit::LayerTreeContext&)
+{
+    notImplemented();
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void QRawWebViewPrivate::updateTextInputState()
+{
+    notImplemented();
+}
+
+#if ENABLE(GESTURE_EVENTS)
+void QRawWebViewPrivate::doneWithGestureEvent(const WebKit::WebGestureEvent& event, bool wasEventHandled)
+{
+    notImplemented();
+}
+
+#endif
+void QRawWebViewPrivate::displayView()
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::flashBackingStoreUpdates(const Vector<WebCore::IntRect>&)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::toolTipChanged(const String&, const String& newTooltip)
+{
+    notImplemented();
+}
+
+void QRawWebViewPrivate::startDrag(const WebCore::DragData& dragData, PassRefPtr<WebKit::ShareableBitmap> dragImage)
+{
+    notImplemented();
+}
+
+PassRefPtr<WebKit::WebPopupMenuProxy> QRawWebViewPrivate::createPopupMenuProxy(WebKit::WebPageProxy* webPageProxy)
+{
+    notImplemented();
+    return PassRefPtr<WebKit::WebPopupMenuProxy>();
+}
+
+PassRefPtr<WebKit::WebContextMenuProxy> QRawWebViewPrivate::createContextMenuProxy(WebKit::WebPageProxy* webPageProxy)
+{
+    notImplemented();
+    return PassRefPtr<WebKit::WebContextMenuProxy>();
+}
+
+#if ENABLE(INPUT_TYPE_COLOR)
+PassRefPtr<WebKit::WebColorChooserProxy> QRawWebViewPrivate::createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor)
+{
+    notImplemented();
+    return PassRefPtr<WebKit::WebColorChooserProxy>();
+}
+#endif
+
+void QRawWebViewPrivate::pageDidRequestScroll(const WebCore::IntPoint& pos)
+{
+    m_client->viewRequestedScroll(pos);
+
+}
+void QRawWebViewPrivate::processDidCrash()
+{
+    m_client->viewProcessCrashed();
+}
+
+void QRawWebViewPrivate::didRelaunchProcess()
+{
+    m_client->viewProcessRelaunched();
+}
+
+void QRawWebViewPrivate::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+    m_client->viewNeedsDisplay(rect);
+}
+
+void QRawWebViewPrivate::didChangeContentsSize(const WebCore::IntSize& newSize)
+{
+    m_client->viewContentSizeChanged(newSize);
+}
+
+void QRawWebViewPrivate::setCursor(const WebCore::Cursor& cursor)
+{
+    m_client->viewRequestedCursorOverride(*cursor.platformCursor());
+}
+
+#if ENABLE(TOUCH_EVENTS)
+void QRawWebViewPrivate::doneWithTouchEvent(const WebKit::NativeWebTouchEvent& event, bool wasEventHandled)
+{
+    m_client->doneWithTouchEvent(event.nativeEvent(), wasEventHandled);
+}
+#endif
+
+void QRawWebViewPrivate::doneWithKeyEvent(const WebKit::NativeWebKeyboardEvent& event, bool wasEventHandled)
+{
+    m_client->doneWithKeyEvent(event.nativeEvent(), wasEventHandled);
+}
+
+PassOwnPtr<WebKit::DrawingAreaProxy> QRawWebViewPrivate::createDrawingAreaProxy()
+{
+    return WebKit::DrawingAreaProxyImpl::create(m_webPageProxy.get());
+}
+
+QRawWebViewPrivate::QRawWebViewPrivate(WebKit::WebContext* context, WebKit::WebPageGroup* pageGroup, QRawWebViewClient* client)
+    : m_client(client)
+    , m_webPageProxy(context->createWebPage(this, pageGroup))
+{
+    m_webPageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
+}
+
+QRawWebViewPrivate::~QRawWebViewPrivate()
+{
+}
+
+QRawWebView::QRawWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QRawWebViewClient* client)
+    : d(new QRawWebViewPrivate(WebKit::toImpl(contextRef), WebKit::toImpl(pageGroupRef), client))
+{
+}
+
+QRawWebView::~QRawWebView()
+{
+    delete d;
+}
+
+void QRawWebView::create()
+{
+    d->m_webPageProxy->initializeWebPage();
+}
+
+void QRawWebView::setTransparentBackground(bool value)
+{
+    d->m_webPageProxy->setDrawsTransparentBackground(value);
+}
+
+bool QRawWebView::transparentBackground() const
+{
+    return d->m_webPageProxy->drawsTransparentBackground();
+}
+
+void QRawWebView::setDrawBackground(bool value)
+{
+    d->m_webPageProxy->setDrawsBackground(value);
+}
+
+bool QRawWebView::drawBackground() const
+{
+    return d->m_webPageProxy->drawsBackground();
+}
+
+bool QRawWebView::isFocused() const
+{
+    return d->m_focused;
+}
+
+void QRawWebView::setFocused(bool focused)
+{
+    d->m_focused = focused;
+    d->m_webPageProxy->viewStateDidChange(WebKit::WebPageProxy::ViewIsFocused);
+}
+
+bool QRawWebView::isVisible() const
+{
+    return d->m_visible;
+}
+
+void QRawWebView::setVisible(bool visible)
+{
+    d->m_visible = visible;
+    d->m_webPageProxy->viewStateDidChange(WebKit::WebPageProxy::ViewIsVisible);
+}
+
+bool QRawWebView::isActive() const
+{
+    return d->m_active;
+}
+
+void QRawWebView::setActive(bool active)
+{
+    d->m_active = active;
+    d->m_webPageProxy->viewStateDidChange(WebKit::WebPageProxy::ViewWindowIsActive);
+}
+
+QSize QRawWebView::size() const
+{
+    return d->m_size;
+}
+
+void QRawWebView::setSize(const QSize& size)
+{
+    d->m_size = size;
+    d->m_webPageProxy->setViewportSize(size);
+
+
+    WebKit::DrawingAreaProxy* drawingArea = d->m_webPageProxy->drawingArea();
+    if (!drawingArea)
+        return;
+
+
+    drawingArea->setSize(d->m_size, WebCore::IntSize());
+    drawingArea->setVisibleContentsRect(WebCore::IntRect(WebCore::IntPoint(), d->m_size), 1 /*scale*/, WebCore::FloatPoint());
+}
+
+WKPageRef QRawWebView::pageRef()
+{
+    return toAPI(d->m_webPageProxy.get());
+}
+
+void QRawWebView::paint(const QMatrix4x4& transform, float opacity, unsigned paintFlags)
+{
+    WebKit::DrawingAreaProxy* drawingArea = d->m_webPageProxy->drawingArea();
+    if (!drawingArea)
+        return;
+
+    WebKit::LayerTreeCoordinatorProxy* coordinatorProxy = drawingArea->layerTreeCoordinatorProxy();
+    if (!coordinatorProxy)
+        return;
+
+    WebKit::WebLayerTreeRenderer* renderer = coordinatorProxy->layerTreeRenderer();
+    if (!renderer)
+        return;
+
+    renderer->setActive(true);
+    renderer->syncRemoteContent();
+
+    WebCore::FloatRect rect(0, 0, d->m_size.width(), d->m_size.height());
+
+    renderer->paintToCurrentGLContext(transform, opacity, rect, paintFlags);
+}
+
+void QRawWebView::sendKeyEvent(QKeyEvent* event)
+{
+    d->m_webPageProxy->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(event));
+}
+
+void QRawWebView::sendMouseEvent(QMouseEvent* event, int clickCount)
+{
+    d->m_webPageProxy->handleMouseEvent(WebKit::NativeWebMouseEvent(event, QTransform(), clickCount));
+}
+
+void QRawWebView::sendWheelEvent(QWheelEvent* event)
+{
+    d->m_webPageProxy->handleWheelEvent(WebKit::NativeWebWheelEvent(event, QTransform()));
+}
+
+void QRawWebView::sendTouchEvent(QTouchEvent* event)
+{
+    d->m_webPageProxy->handleTouchEvent(WebKit::NativeWebTouchEvent(event, QTransform()));
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h
new file mode 100644 (file)
index 0000000..b8cba69
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+    Copyright (C) 2012 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.
+*/
+
+/*
+    This file is not part of the public Qt Api. It may change without notice at any time in future.
+    We make no commitment regarding source compatibility or binary compatibility.
+*/
+
+#ifndef qrawwebview_p_h
+#define qrawwebview_p_h
+
+#include "qwebkitglobal.h"
+
+#include <WebKit2/WKContext.h>
+#include <WebKit2/WKPage.h>
+#include <WebKit2/WKPageGroup.h>
+
+class QRect;
+class QRectF;
+class QPoint;
+class QSize;
+class QKeyEvent;
+class QMouseEvent;
+class QWheelEvent;
+class QTouchEvent;
+class QUrl;
+class QMatrix4x4;
+class QCursor;
+
+class QRawWebViewPrivate;
+
+class QRawWebViewClient {
+public:
+    virtual ~QRawWebViewClient() { }
+
+    virtual void viewNeedsDisplay(const QRect&) = 0;
+    virtual void viewRequestedScroll(const QPoint&) = 0;
+    virtual void viewProcessCrashed() = 0;
+    virtual void viewProcessRelaunched() = 0;
+    virtual void viewContentSizeChanged(const QSize&) = 0;
+    virtual void viewRequestedCursorOverride(const QCursor&) = 0;
+    virtual void doneWithKeyEvent(const QKeyEvent*, bool wasHandled) = 0;
+    virtual void doneWithTouchEvent(const QTouchEvent*, bool wasHandled) = 0;
+};
+
+class QWEBKIT_EXPORT QRawWebView {
+public:
+    QRawWebView(WKContextRef, WKPageGroupRef, QRawWebViewClient*);
+    ~QRawWebView();
+
+    void create();
+
+    void setSize(const QSize&);
+    QSize size() const;
+
+    void setFocused(bool);
+    bool isFocused() const;
+
+    void setVisible(bool);
+    bool isVisible() const;
+
+    void setActive(bool);
+    bool isActive() const;
+
+    void setTransparentBackground(bool);
+    bool transparentBackground() const;
+
+    void setDrawBackground(bool);
+    bool drawBackground() const;
+
+    // Paints on the current GL context.
+    void paint(const QMatrix4x4& transform, float opacity, unsigned paintFlags);
+
+    WKPageRef pageRef();
+
+    void sendKeyEvent(QKeyEvent*);
+    void sendMouseEvent(QMouseEvent*, int clickCount = 0);
+    void sendWheelEvent(QWheelEvent*);
+    void sendTouchEvent(QTouchEvent*);
+
+private:
+    QRawWebViewPrivate* d;
+};
+
+#endif // qrawwebview_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h
new file mode 100644 (file)
index 0000000..0a4bf5a
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+    Copyright (C) 2012 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.
+*/
+
+/*
+    This file is not part of the public Qt Api. It may change without notice at any time in future.
+    We make no commitment regarding source compatibility or binary compatibility.
+*/
+
+#ifndef qrawwebview_p_p_h
+#define qrawwebview_p_p_h
+
+#include "PageClient.h"
+#include "WebContextMenuProxy.h"
+#include "WebPopupMenuProxy.h"
+#include "qrawwebview_p.h"
+
+class QRawWebViewPrivate : public WebKit::PageClient {
+public:
+
+    virtual void pageClosed() { }
+
+    virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut, bool animate) { }
+    virtual void didCommitLoadForMainFrame(bool useCustomRepresentation) { }
+    virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&) { }
+    virtual double customRepresentationZoomFactor() { return 1; }
+    virtual void setCustomRepresentationZoomFactor(double) { }
+    virtual void didChangeScrollbarsForMainFrame() const { }
+    virtual void findStringInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
+    virtual void countStringMatchesInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
+    virtual void clearAllEditCommands() { }
+
+    virtual void didReceiveMessageFromNavigatorQtObject(const String& message);
+    virtual void didChangeViewportProperties(const WebCore::ViewportAttributes& attr);
+    virtual void handleDownloadRequest(WebKit::DownloadProxy* download);
+
+    virtual void handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password);
+    virtual void handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors);
+    virtual void handleProxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password);
+
+    virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
+    virtual bool canUndoRedo(WebKit::WebPageProxy::UndoOrRedo undoOrRedo);
+    virtual void executeUndoRedo(WebKit::WebPageProxy::UndoOrRedo undoOrRedo);
+
+    virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect& rect);
+    virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect& rect);
+    virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint& point);
+    virtual WebCore::IntRect windowToScreen(const WebCore::IntRect& rect);
+
+#if USE(ACCELERATED_COMPOSITING)
+    virtual void enterAcceleratedCompositingMode(const WebKit::LayerTreeContext&);
+    virtual void exitAcceleratedCompositingMode();
+    virtual void updateAcceleratedCompositingMode(const WebKit::LayerTreeContext&);
+#endif // USE(ACCELERATED_COMPOSITING)
+
+    virtual void updateTextInputState();
+#if ENABLE(GESTURE_EVENTS)
+    virtual void doneWithGestureEvent(const WebKit::WebGestureEvent& event, bool wasEventHandled);
+#endif
+    virtual void displayView();
+    virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+
+    virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&);
+    virtual void didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area);
+
+    virtual void setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves);
+    virtual void toolTipChanged(const String&, const String& newTooltip);
+
+    virtual void startDrag(const WebCore::DragData& dragData, PassRefPtr<WebKit::ShareableBitmap> dragImage);
+
+    virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy* webPageProxy);
+    virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy* webPageProxy);
+
+#if ENABLE(INPUT_TYPE_COLOR)
+    virtual PassRefPtr<WebKit::WebColorChooserProxy> createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor);
+#endif
+
+    QRawWebViewPrivate(WebKit::WebContext*, WebKit::WebPageGroup*, QRawWebViewClient*);
+    ~QRawWebViewPrivate();
+
+    // PageClient
+
+    virtual PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
+
+    virtual void pageDidRequestScroll(const WebCore::IntPoint& pos);
+    virtual void processDidCrash();
+    virtual void didRelaunchProcess();
+    virtual void setViewNeedsDisplay(const WebCore::IntRect& rect);
+    virtual void didChangeContentsSize(const WebCore::IntSize& newSize);
+    virtual void setCursor(const WebCore::Cursor&);
+
+    virtual bool isViewFocused() { return m_focused; }
+    virtual bool isViewVisible() { return m_visible; }
+    virtual bool isViewWindowActive() { return m_active; }
+    virtual bool isViewInWindow() { return true; } // FIXME
+    virtual WebCore::IntSize viewSize() { return m_size; }
+
+    virtual void doneWithKeyEvent(const WebKit::NativeWebKeyboardEvent&, bool wasEventHandled);
+#if ENABLE(TOUCH_EVENTS)
+    virtual void doneWithTouchEvent(const WebKit::NativeWebTouchEvent&, bool wasEventHandled);
+#endif
+
+
+    bool m_focused;
+    bool m_visible;
+    bool m_active;
+    QSize m_size;
+
+    QRawWebViewClient* m_client;
+    WTF::RefPtr<WebKit::WebPageProxy> m_webPageProxy;
+
+private:
+    QRawWebView* q;
+};
+
+#endif // qrawwebview_p_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/bluesquare.html b/Source/WebKit2/UIProcess/API/qt/tests/html/bluesquare.html
new file mode 100644 (file)
index 0000000..f4b6396
--- /dev/null
@@ -0,0 +1,5 @@
+<body style="margin:60px">
+    <table style="border:10px solid blue; width:80px; height:80px">
+        <tr><td>&nbsp;</td></tr>
+    </table>
+</body>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/redsquare.html b/Source/WebKit2/UIProcess/API/qt/tests/html/redsquare.html
new file mode 100644 (file)
index 0000000..f70d291
--- /dev/null
@@ -0,0 +1,5 @@
+<body style="margin:20px">
+    <table style="border:10px solid red; width:160px; height:160px">
+        <tr><td>&nbsp;</td></tr>
+    </table>
+</body>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground1.png b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground1.png
new file mode 100644 (file)
index 0000000..c293f44
Binary files /dev/null and b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground1.png differ
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground3.png b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground3.png
new file mode 100644 (file)
index 0000000..4fa53b1
Binary files /dev/null and b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_noBackground3.png differ
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_paint.png b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_paint.png
new file mode 100644 (file)
index 0000000..68743ac
Binary files /dev/null and b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/qwkview_paint.png differ
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro
new file mode 100644 (file)
index 0000000..02dc197
--- /dev/null
@@ -0,0 +1,3 @@
+include(../tests.pri)
+SOURCES += $${TARGET}.cpp
+QT += webkit-private
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp
new file mode 100644 (file)
index 0000000..ae015e3
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+    Copyright (C) 2011 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 "../util.h"
+
+#include <QImage>
+#include <QMatrix4x4>
+#include <QOpenGLContext>
+#include <QSize>
+#include <QWindow>
+#include <QtTest/QtTest>
+
+#include <WebKit2/WKContext.h>
+#include <WebKit2/WKPageGroup.h>
+#include <WebKit2/WKPreferences.h>
+#include <WebKit2/WKPreferencesPrivate.h>
+#include <WebKit2/WKStringQt.h>
+#include <WebKit2/WKURL.h>
+#include <WebKit2/qrawwebview_p.h>
+
+static WKContextRef webContext()
+{
+    static WKContextRef result = WKContextCreate();
+    return result;
+}
+
+static WKPageGroupRef createWebPageGroup(const QString& name)
+{
+    WKPageGroupRef pageGroup =WKPageGroupCreateWithIdentifier(WKStringCreateWithQString(name));
+    WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup);
+    WKPreferencesSetAcceleratedCompositingEnabled(preferences, true);
+    WKPreferencesSetFrameFlatteningEnabled(preferences, true);
+
+    return pageGroup;
+}
+
+static WKPageGroupRef webPageGroup(const QString& name)
+{
+    static WKPageGroupRef result = createWebPageGroup(name);
+    return result;
+}
+
+class WebView : public QObject, public QRawWebViewClient {
+    Q_OBJECT
+public:
+    WebView(const QSize& size)
+    {
+        WKPageLoaderClient loaderClient;
+        memset(&loaderClient, 0, sizeof(WKPageLoaderClient));
+        loaderClient.clientInfo = this;
+        loaderClient.didFinishLoadForFrame = WebView::finishLoadForFrame;
+
+        m_webView = new QRawWebView(webContext(), webPageGroup(QString()), this);
+        WKPageSetPageLoaderClient(m_webView->pageRef(), &loaderClient);
+        m_webView->create();
+        WKPageSetUseFixedLayout(m_webView->pageRef(), true);
+
+        m_webView->setSize(size);
+        m_webView->setFocused(true);
+        m_webView->setVisible(true);
+        m_webView->setActive(true);
+    }
+
+    ~WebView() { delete m_webView; }
+
+    void load(const QString& html)
+    {
+        m_frameLoaded = false;
+        WKPageLoadURL(m_webView->pageRef(), WKURLCreateWithUTF8CString(html.toAscii().data()));
+        QVERIFY(::waitForSignal(this, SIGNAL(loaded()), 5000));
+    }
+
+    void setDrawBackground(bool value) { m_webView->setDrawBackground(value); }
+    void setTransparentBackground(bool value) { m_webView->setTransparentBackground(value); }
+
+    virtual void viewNeedsDisplay(const QRect&)
+    {
+        m_webView->paint(QMatrix4x4(), 1, 0);
+        if (m_frameLoaded)
+            emit loaded();
+    }
+
+    virtual void viewRequestedScroll(const QPoint&) { }
+    virtual void viewProcessCrashed() { }
+    virtual void viewProcessRelaunched() { }
+    virtual void viewContentSizeChanged(const QSize&) { }
+    virtual void viewRequestedCursorOverride(const QCursor&) { }
+    virtual void doneWithKeyEvent(const QKeyEvent*, bool wasHandled) { }
+    virtual void doneWithTouchEvent(const QTouchEvent*, bool wasHandled) { }
+
+    static void finishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+
+signals:
+    void loaded();
+
+private:
+    QRawWebView* m_webView;
+    bool m_frameLoaded;
+};
+
+void WebView::finishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
+{
+    WebView* obj = static_cast<WebView*>(const_cast<void*>(clientInfo));
+    obj->m_frameLoaded = true;
+}
+
+static bool compareImages(const QImage& i1, const QImage& i2, const QPoint& p1, const QPoint& p2, int iter)
+{
+    const QPoint point((p1.x() + p2.x()) >> 1, (p1.y() + p2.y()) >> 1);
+
+    if (i1.pixel(point) != i2.pixel(point))
+        return false;
+
+    if (!iter)
+        return true;
+
+    --iter;
+    return compareImages(i1, i2, point, p1, iter) && compareImages(i1, i2, point, p2, iter)
+        && compareImages(i1, i2, point, QPoint(p1.x(), p2.y()), iter) && compareImages(i1, i2, point, QPoint(p2.x(), p1.y()), iter);
+}
+
+static bool compareImages(const QImage& i1, const QImage& i2, int iter)
+{
+    if (i1.size() != i2.size())
+        return false;
+    return compareImages(i1, i2, QPoint(0, 0), QPoint(i1.size().width(), i1.size().height()), iter);
+}
+
+class tst_qrawwebview : public QObject {
+    Q_OBJECT
+public:
+    tst_qrawwebview()
+        : m_resourceDir(QString::fromAscii(TESTS_SOURCE_DIR "/html/resources"))
+        , m_baseUrl(QUrl::fromLocalFile(TESTS_SOURCE_DIR "/html").toString())
+    { }
+
+private slots:
+    void paint() { run(&tst_qrawwebview::doPaint, m_resourceDir + "/qwkview_paint.png"); }
+    void noBackground1() { run(&tst_qrawwebview::doNoBackground1, m_resourceDir + "/qwkview_noBackground1.png"); }
+    void noBackground2() { run(&tst_qrawwebview::doNoBackground2, m_resourceDir + "/qwkview_noBackground1.png"); }
+    void noBackground3() { run(&tst_qrawwebview::doNoBackground3, m_resourceDir + "/qwkview_noBackground3.png"); }
+
+private:
+    const QString m_resourceDir;
+    const QString m_baseUrl;
+
+    void doPaint(const QSize& size);
+    void doNoBackground1(const QSize& size);
+    void doNoBackground2(const QSize& size);
+    void doNoBackground3(const QSize& size);
+
+    typedef void (tst_qrawwebview::*PaintMethod)(const QSize& size);
+    void run(PaintMethod, const QString& expectation);
+};
+
+void tst_qrawwebview::doPaint(const QSize& size)
+{
+    WebView view(size);
+    view.load(m_baseUrl + "/redsquare.html");
+}
+
+void tst_qrawwebview::doNoBackground1(const QSize& size)
+{
+    WebView view(size);
+    view.setTransparentBackground(true);
+    view.load(m_baseUrl + "/redsquare.html");
+    view.load(m_baseUrl + "/bluesquare.html");
+}
+
+void tst_qrawwebview::doNoBackground2(const QSize& size)
+{
+    WebView view1(size);
+    view1.setTransparentBackground(true);
+    view1.load(m_baseUrl + "/redsquare.html");
+
+    WebView view2(size);
+    view2.setTransparentBackground(true);
+    view2.load(m_baseUrl + "/bluesquare.html");
+}
+
+void tst_qrawwebview::doNoBackground3(const QSize& size)
+{
+    WebView view1(size);
+    view1.setTransparentBackground(false);
+    view1.load(m_baseUrl + "/redsquare.html");
+
+    WebView view2(size);
+    view2.setTransparentBackground(true);
+    view2.load(m_baseUrl + "/bluesquare.html");
+}
+
+void tst_qrawwebview::run(PaintMethod method, const QString& expectation)
+{
+
+    QWindow window;
+    window.setSurfaceType(QSurface::OpenGLSurface);
+    window.setGeometry(0, 0, 200, 200);
+    window.create();
+
+    QOpenGLContext context;
+    context.create();
+    context.makeCurrent(&window);
+
+    glViewport(0, 0, window.size().width(), window.size().height());
+    glClearColor(0, 0, 0, 0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    (this->*method)(window.size());
+
+    QImage image(window.size(), QImage::Format_ARGB32_Premultiplied);
+    glReadPixels(0, 0, window.size().width(), window.size().height(), GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
+
+    QVERIFY(compareImages(QImage(expectation), image.rgbSwapped(), 5));
+}
+
+QTEST_MAIN(tst_qrawwebview)
+
+#include "tst_qrawwebview.moc"
index 5d2eb6b..2781578 100644 (file)
@@ -50,5 +50,6 @@ SUBDIRS += \
         $$WEBKIT2_TESTS_DIR/inspectorserver \
         $$WEBKIT2_TESTS_DIR/publicapi \
         $$WEBKIT2_TESTS_DIR/qquickwebview \
-        $$WEBKIT2_TESTS_DIR/qmltests
+        $$WEBKIT2_TESTS_DIR/qmltests \
+        $$WEBKIT2_TESTS_DIR/qrawwebview
 }
index df60a39..f7a494e 100644 (file)
@@ -1,3 +1,21 @@
+2012-06-29  Luiz Agostini  <luiz.agostini@nokia.com>
+
+        [Qt][WK2] Private non-QtQuick API
+        https://bugs.webkit.org/show_bug.cgi?id=84532
+
+        MiniBrowserRaw is an usage example for the QRawWebView API.
+        It is only an example and is not fully implemented.
+
+        Reviewed by Noam Rosenthal.
+
+        * MiniBrowser/qt/raw/DerivedSources.pri: Added.
+        * MiniBrowser/qt/raw/MiniBrowserRaw.pro: Added.
+        * MiniBrowser/qt/raw/Target.pri: Added.
+        * MiniBrowser/qt/raw/View.cpp: Added.
+        * MiniBrowser/qt/raw/View.h: Added.
+        * Scripts/webkitpy/style/checker.py:
+        * Tools.pro:
+
 2012-06-29  Ojan Vafai  <ojan@chromium.org>
 
         Remove leopard bots from garden-o-matic
diff --git a/Tools/MiniBrowser/qt/raw/DerivedSources.pri b/Tools/MiniBrowser/qt/raw/DerivedSources.pri
new file mode 100644 (file)
index 0000000..dc4d2f4
--- /dev/null
@@ -0,0 +1,6 @@
+TEMPLATE = derived
+
+# Make sure forwarded headers needed by this project are present
+fwheader_generator.commands = perl $${ROOT_WEBKIT_DIR}/Source/WebKit2/Scripts/generate-forwarding-headers.pl $${ROOT_WEBKIT_DIR}/Tools/WebKitTestRunner $${ROOT_BUILD_DIR}/Source/include qt
+fwheader_generator.depends  = $${ROOT_WEBKIT_DIR}/Source/WebKit2/Scripts/generate-forwarding-headers.pl
+GENERATORS += fwheader_generator
diff --git a/Tools/MiniBrowser/qt/raw/MiniBrowserRaw.pro b/Tools/MiniBrowser/qt/raw/MiniBrowserRaw.pro
new file mode 100644 (file)
index 0000000..0503104
--- /dev/null
@@ -0,0 +1,9 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+
+derived_sources.file = DerivedSources.pri
+target.file = Target.pri
+
+SUBDIRS = derived_sources target
+
+addStrictSubdirOrderBetween(derived_sources, target)
diff --git a/Tools/MiniBrowser/qt/raw/Target.pri b/Tools/MiniBrowser/qt/raw/Target.pri
new file mode 100644 (file)
index 0000000..061b33e
--- /dev/null
@@ -0,0 +1,16 @@
+TEMPLATE = app
+TARGET = MiniBrowserRaw
+
+HEADERS += \
+    View.h
+
+SOURCES += \
+    View.cpp
+
+DESTDIR = $${ROOT_BUILD_DIR}/bin
+
+QT = core gui network webkit
+
+load(features)
+
+WEBKIT += wtf javascriptcore webkit2
diff --git a/Tools/MiniBrowser/qt/raw/View.cpp b/Tools/MiniBrowser/qt/raw/View.cpp
new file mode 100644 (file)
index 0000000..a7b0aa8
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+    Copyright (C) 2012 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 "View.h"
+
+#include <QDebug>
+#include <QExposeEvent>
+#include <QGuiApplication>
+#include <QKeyEvent>
+#include <QMatrix4x4>
+#include <QResizeEvent>
+#include <QUrl>
+
+#include <WebKit2/WKContext.h>
+#include <WebKit2/WKPageGroup.h>
+#include <WebKit2/WKPreferences.h>
+#include <WebKit2/WKPreferencesPrivate.h>
+#include <WebKit2/WKStringQt.h>
+#include <WebKit2/WKURL.h>
+
+
+static WKContextRef createWebContext()
+{
+    return WKContextCreate();
+}
+
+static WKPageGroupRef createWebPageGroup(const QString& name)
+{
+    WKPageGroupRef pageGroup =WKPageGroupCreateWithIdentifier(WKStringCreateWithQString(name));
+    WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup);
+    WKPreferencesSetAcceleratedCompositingEnabled(preferences, true);
+    WKPreferencesSetFrameFlatteningEnabled(preferences, true);
+
+    return pageGroup;
+}
+
+View::~View()
+{
+    delete m_context;
+    delete m_webView;
+}
+
+View::View(const QString& url)
+    : m_url(url)
+    , m_active(false)
+{
+    setSurfaceType(OpenGLSurface);
+    setGeometry(50, 50, 980, 600);
+    setWindowFlags(Qt::Window | Qt::WindowTitleHint);
+    create();
+
+    m_context = new QOpenGLContext;
+    m_context->create();
+
+    m_webView = new QRawWebView(createWebContext(), createWebPageGroup(QString()), this);
+    m_webView->create();
+    WKPageSetUseFixedLayout(m_webView->pageRef(), true);
+}
+
+
+void View::exposeEvent(QExposeEvent* event)
+{
+    if (!m_active) {
+        m_active = true;
+        WKPageLoadURL(m_webView->pageRef(), WKURLCreateWithUTF8CString(m_url.toAscii().data()));
+
+        m_webView->setFocused(true);
+        m_webView->setVisible(true);
+        m_webView->setActive(true);
+    }
+}
+
+void View::resizeEvent(QResizeEvent* event)
+{
+    m_webView->setSize(event->size());
+}
+
+void View::timerEvent(QTimerEvent* event)
+{
+    if (event->timerId() == m_paintTimer.timerId()) {
+        m_paintTimer.stop();
+        m_context->makeCurrent(this);
+        m_webView->paint(QMatrix4x4(), 1, 0);
+        m_context->swapBuffers(this);
+    }
+}
+
+void View::viewNeedsDisplay(const QRect&)
+{
+    if (!m_paintTimer.isActive())
+        m_paintTimer.start(0, this);
+}
+
+void View::viewRequestedCursorOverride(const QCursor& cursor)
+{
+    QGuiApplication::setOverrideCursor(cursor);
+}
+
+void View::doneWithKeyEvent(const QKeyEvent* event, bool wasHandled)
+{
+    if (wasHandled || event->isAccepted())
+        return;
+
+    switch (event->key()) {
+    case Qt::Key_Backspace: {
+        WKPageRef page = m_webView->pageRef();
+        if (WKPageCanGoBack(page))
+            WKPageGoBack(page);
+        break;
+    }
+    }
+}
+
+int main(int argc, char** argv)
+{
+    QGuiApplication app(argc, argv);
+
+    View view(app.arguments().size() > 1 ? app.arguments().at(1) : QString::fromAscii("http://www.google.com"));
+    view.show();
+    return app.exec();
+}
diff --git a/Tools/MiniBrowser/qt/raw/View.h b/Tools/MiniBrowser/qt/raw/View.h
new file mode 100644 (file)
index 0000000..6de7a25
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+    Copyright (C) 2012 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 View_h
+#define View_h
+
+#include <QBasicTimer>
+#include <QOpenGLContext>
+#include <QWindow>
+#include <WebKit2/qrawwebview_p.h>
+
+
+class View :  public QWindow, private QRawWebViewClient {
+public:
+    View(const QString& url);
+    ~View();
+
+public: // WKViewClient
+    virtual void viewNeedsDisplay(const QRect&);
+    virtual void viewRequestedScroll(const QPoint&) { }
+    virtual void viewProcessCrashed() { }
+    virtual void viewProcessRelaunched() { }
+    virtual void viewContentSizeChanged(const QSize&) { }
+    virtual void viewRequestedCursorOverride(const QCursor&);
+    virtual void doneWithKeyEvent(const QKeyEvent*, bool wasHandled);
+    virtual void doneWithTouchEvent(const QTouchEvent*, bool wasHandled) { }
+
+protected:
+    virtual void exposeEvent(QExposeEvent*);
+    virtual void resizeEvent(QResizeEvent*);
+
+    virtual void keyPressEvent(QKeyEvent* event) { m_webView->sendKeyEvent(event); }
+    virtual void keyReleaseEvent(QKeyEvent* event) { m_webView->sendKeyEvent(event); }
+
+    virtual void mouseDoubleClickEvent(QMouseEvent* event) { m_webView->sendMouseEvent(event, 2); }
+    virtual void mouseMoveEvent(QMouseEvent* event) { m_webView->sendMouseEvent(event); }
+    virtual void mousePressEvent(QMouseEvent* event) { m_webView->sendMouseEvent(event, 1); }
+    virtual void mouseReleaseEvent(QMouseEvent* event) { m_webView->sendMouseEvent(event); }
+
+private:
+    QRawWebView* m_webView;
+    QOpenGLContext *m_context;
+    QBasicTimer m_paintTimer;
+
+    QString m_url;
+    bool m_active;
+
+    virtual void timerEvent(QTimerEvent*);
+};
+
+#endif // View_h
index dff790e..8cd8745 100644 (file)
@@ -152,7 +152,8 @@ _PATH_RULES_SPECIFIER = [
       "-whitespace/declaration"]),
 
      ([# Qt's MiniBrowser has no config.h
-       "Tools/MiniBrowser/qt"],
+       "Tools/MiniBrowser/qt",
+       "Tools/MiniBrowser/qt/raw"],
       ["-build/include"]),
 
     ([# The Qt APIs use Qt/QML naming style, which includes
index 64e837b..7f97eff 100644 (file)
@@ -18,6 +18,7 @@ load(features)
 !no_webkit2 {
     SUBDIRS += MiniBrowser/qt/MiniBrowser.pro
     SUBDIRS += WebKitTestRunner/WebKitTestRunner.pro
+    SUBDIRS += MiniBrowser/qt/raw/MiniBrowserRaw.pro
 }
 
 # FIXME: with Qt 5 the test plugin cause some trouble during layout tests.