summaryrefslogtreecommitdiff
path: root/src/3rdparty/webkit/WebKit/qt/Api
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebKit/qt/Api')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro107
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp447
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h13
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp19
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h9
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp412
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebframe.h11
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h9
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp18
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.h2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h11
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp334
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h22
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h21
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp107
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h15
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp203
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebview.h6
19 files changed, 1322 insertions, 449 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro b/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro
new file mode 100644
index 0000000000..389fb5fbb1
--- /dev/null
+++ b/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro
@@ -0,0 +1,107 @@
+TEMPLATE = lib
+TARGET = dummy
+
+include(headers.pri)
+
+CONFIG -= debug_and_release
+
+DESTDIR = ../../../include/QtWebKit
+
+QUOTE = ""
+DOUBLE_ESCAPED_QUOTE = ""
+ESCAPE = ""
+win32-msvc*|symbian {
+ ESCAPE = "^"
+} else:win32-g++:isEmpty(QMAKE_SH) {
+ # MinGW's make will run makefile commands using sh, even if make
+ # was run from the Windows shell, if it finds sh in the path.
+ ESCAPE = "^"
+} else {
+ QUOTE = "\'"
+ DOUBLE_ESCAPED_QUOTE = "\\\'"
+}
+
+qtheader_module.target = $${DESTDIR}/QtWebKit
+qtheader_module.depends = $${_PRO_FILE_}
+qtheader_module.commands = echo $${QUOTE}$${LITERAL_HASH}ifndef QT_QTWEBKIT_MODULE_H$${QUOTE} > $${qtheader_module.target} &&
+qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}define QT_QTWEBKIT_MODULE_H$${QUOTE} >> $${qtheader_module.target} &&
+qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}include $${ESCAPE}<QtNetwork/QtNetwork$${ESCAPE}>$${QUOTE} >> $${qtheader_module.target} &&
+WEBKIT_CLASS_HEADERS = $${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}PWD/QtWebKit
+
+regex = ".*\sclass\sQWEBKIT_EXPORT\s(\w+)\s(.*)"
+
+for(HEADER, WEBKIT_API_HEADERS) {
+ # 1. Append to QtWebKit header that includes all other header files
+ # Quotes need to be escaped once more when placed in eval()
+ eval(qtheader_module.commands += echo $${DOUBLE_ESCAPED_QUOTE}\$${LITERAL_HASH}include \\\"$$basename(HEADER)\\\"$${DOUBLE_ESCAPED_QUOTE} >> $${qtheader_module.target} &&)
+
+ HEADER_NAME = $$basename(HEADER)
+ HEADER_TARGET = $$replace(HEADER_NAME, [^a-zA-Z0-9_], -)
+ HEADER_TARGET = "qtheader-$${HEADER_TARGET}"
+
+ # 2. Create forwarding header files for qwebframe.h, etc.
+ # Normally they contain absolute paths, for package builds we make the path relative so that
+ # the package sources are relocatable.
+
+ PATH_TO_HEADER = $$HEADER
+ CONFIG(standalone_package): PATH_TO_HEADER = ../../WebKit/qt/Api/$$basename(HEADER)
+
+ eval($${HEADER_TARGET}.target = $${DESTDIR}/$${HEADER_NAME})
+ eval($${HEADER_TARGET}.depends = $$HEADER)
+ eval($${HEADER_TARGET}.commands = echo $${DOUBLE_ESCAPED_QUOTE}\$${LITERAL_HASH}include \\\"$$PATH_TO_HEADER\\\"$${DOUBLE_ESCAPED_QUOTE} > $$eval($${HEADER_TARGET}.target))
+
+ QMAKE_EXTRA_TARGETS += $$HEADER_TARGET
+ qtheader_module.depends += $$eval($${HEADER_TARGET}.target)
+
+ # 3. Extract class names of exported classes from the headers and generate
+ # the class name header files
+
+ src_words = $$cat($$HEADER)
+ # Really make sure we're dealing with words
+ src_words = $$split(src_words, " ")
+
+ src = $$join(src_words, $${LITERAL_WHITESPACE})
+ for(ever) {
+ # Looking up by line is faster, so we try that first
+ res = $$find(src_words, "QWEBKIT_EXPORT")
+ isEmpty(res):break()
+
+ # Then do a slow lookup to ensure we're dealing with an exported class
+ res = $$find(src, $$regex)
+ isEmpty(res):break()
+
+ exp = $$replace(src, $$regex, "EXPORTED_CLASS = \1")
+ eval($$exp)
+
+ CLASS_TARGET = "qtheader_$${EXPORTED_CLASS}"
+
+ eval($${CLASS_TARGET}.target = $${DESTDIR}/$${EXPORTED_CLASS})
+ eval($${CLASS_TARGET}.depends = $$eval($${HEADER_TARGET}.target))
+ eval($${CLASS_TARGET}.commands = echo $${DOUBLE_ESCAPED_QUOTE}\$${LITERAL_HASH}include \\\"$$basename(HEADER)\\\"$${DOUBLE_ESCAPED_QUOTE} > $$eval($${CLASS_TARGET}.target))
+
+ QMAKE_EXTRA_TARGETS += $$CLASS_TARGET
+ WEBKIT_CLASS_HEADERS += $${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}PWD/$${EXPORTED_CLASS}
+
+ generated_files.depends += $$eval($${CLASS_TARGET}.target)
+ qtheader_pri.depends += $$eval($${CLASS_TARGET}.target)
+
+ # Qt's QRegExp does not support inline non-greedy matching,
+ # so we'll have to work around it by updating the haystack
+ src = $$replace(src, $$regex, "\2")
+ src_words = $$join(src, $${LITERAL_WHITESPACE})
+ }
+}
+
+qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}endif // QT_QTWEBKIT_MODULE_H$${QUOTE} >> $${qtheader_module.target}
+QMAKE_EXTRA_TARGETS += qtheader_module
+
+qtheader_pri.target = $${DESTDIR}/classheaders.pri
+qtheader_pri.depends += $${_PRO_FILE_}
+qtheader_pri.commands = echo $${QUOTE}WEBKIT_CLASS_HEADERS = $${WEBKIT_CLASS_HEADERS}$${QUOTE} > $${qtheader_pri.target}
+QMAKE_EXTRA_TARGETS += qtheader_pri
+
+generated_files.depends += $${qtheader_module.target} $${qtheader_pri.target}
+QMAKE_EXTRA_TARGETS += generated_files
+
+
+
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
index 490ada1691..2878960521 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
@@ -22,27 +22,80 @@
#include "qgraphicswebview.h"
#include "qwebframe.h"
+#include "qwebframe_p.h"
#include "qwebpage.h"
#include "qwebpage_p.h"
#include "QWebPageClient.h"
-#include <QtGui/QGraphicsScene>
-#include <QtGui/QGraphicsView>
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include "TiledBackingStore.h"
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qtimer.h>
#include <QtGui/qapplication.h>
+#include <QtGui/qgraphicsscene.h>
#include <QtGui/qgraphicssceneevent.h>
+#include <QtGui/qgraphicsview.h>
+#include <QtGui/qpixmapcache.h>
+#include <QtGui/qscrollbar.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qinputcontext.h>
#if defined(Q_WS_X11)
#include <QX11Info>
#endif
+#include <Settings.h>
+
+// the overlay is here for one reason only: to have the scroll-bars and other
+// extra UI elements appear on top of any QGraphicsItems created by CSS compositing layers
+class QGraphicsWebViewOverlay : public QGraphicsItem {
+ public:
+ QGraphicsWebViewOverlay(QGraphicsWebView* view)
+ :QGraphicsItem(view)
+ , q(view)
+ {
+ setPos(0, 0);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
+#endif
+ setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ }
+
+ QRectF boundingRect() const
+ {
+ return q->boundingRect();
+ }
+
+ void paint(QPainter* painter, const QStyleOptionGraphicsItem* options, QWidget*)
+ {
+ q->page()->mainFrame()->render(painter, static_cast<QWebFrame::RenderLayer>(QWebFrame::AllLayers&(~QWebFrame::ContentsLayer)), options->exposedRect.toRect());
+ }
+
+ friend class QGraphicsWebView;
+ QGraphicsWebView* q;
+};
class QGraphicsWebViewPrivate : public QWebPageClient {
public:
QGraphicsWebViewPrivate(QGraphicsWebView* parent)
: q(parent)
, page(0)
- {}
+ , resizesToContents(false)
+#if USE(ACCELERATED_COMPOSITING)
+ , rootGraphicsLayer(0)
+ , shouldSync(false)
+#endif
+ {
+#if USE(ACCELERATED_COMPOSITING)
+ // the overlay and stays alive for the lifetime of
+ // this QGraphicsWebView as the scrollbars are needed when there's no compositing
+ q->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption);
+ syncMetaMethod = q->metaObject()->method(q->metaObject()->indexOfMethod("syncLayers()"));
+#endif
+ }
virtual ~QGraphicsWebViewPrivate();
+
virtual void scroll(int dx, int dy, const QRect&);
virtual void update(const QRect& dirtyRect);
virtual void setInputMethodEnabled(bool enable);
@@ -59,20 +112,135 @@ public:
virtual QPalette palette() const;
virtual int screenNumber() const;
virtual QWidget* ownerWidget() const;
+ virtual QRect geometryRelativeToOwnerWidget() const;
virtual QObject* pluginParent() const;
+ virtual QStyle* style() const;
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void setRootGraphicsLayer(QGraphicsItem* layer);
+ virtual void markForSync(bool scheduleSync);
+ void updateCompositingScrollPosition();
+#endif
+
+ void updateResizesToContentsForPage();
+ QRectF graphicsItemVisibleRect() const;
+#if ENABLE(TILED_BACKING_STORE)
+ void updateTiledBackingStoreScale();
+#endif
+
+ void createOrDeleteOverlay();
+
+ void syncLayers();
+
+ void unsetPageIfExists();
+
void _q_doLoadFinished(bool success);
+ void _q_contentsSizeChanged(const QSize&);
+ void _q_scaleChanged();
void _q_updateMicroFocus();
void _q_pageDestroyed();
QGraphicsWebView* q;
QWebPage* page;
+
+ bool resizesToContents;
+
+ // the overlay gets instantiated when the root layer is attached, and get deleted when it's detached
+ QSharedPointer<QGraphicsWebViewOverlay> overlay;
+
+ // we need to put the root graphics layer behind the overlay (which contains the scrollbar)
+ enum { RootGraphicsLayerZValue, OverlayZValue };
+
+#if USE(ACCELERATED_COMPOSITING)
+ QGraphicsItem* rootGraphicsLayer;
+ // we need to sync the layers if we get a special call from the WebCore
+ // compositor telling us to do so. We'll get that call from ChromeClientQt
+ bool shouldSync;
+
+ // we have to flush quite often, so we use a meta-method instead of QTimer::singleShot for putting the event in the queue
+ QMetaMethod syncMetaMethod;
+#endif
};
QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate()
{
+#if USE(ACCELERATED_COMPOSITING)
+ if (rootGraphicsLayer) {
+ // we don't need to delete the root graphics layer
+ // The lifecycle is managed in GraphicsLayerQt.cpp
+ rootGraphicsLayer->setParentItem(0);
+ q->scene()->removeItem(rootGraphicsLayer);
+ }
+#endif
+}
+
+void QGraphicsWebViewPrivate::createOrDeleteOverlay()
+{
+ bool useOverlay = false;
+ if (!resizesToContents) {
+#if USE(ACCELERATED_COMPOSITING)
+ useOverlay = useOverlay || rootGraphicsLayer;
+#endif
+#if ENABLE(TILED_BACKING_STORE)
+ useOverlay = useOverlay || QWebFramePrivate::core(q->page()->mainFrame())->tiledBackingStore();
+#endif
+ }
+ if (useOverlay == !!overlay)
+ return;
+ if (useOverlay) {
+ overlay = QSharedPointer<QGraphicsWebViewOverlay>(new QGraphicsWebViewOverlay(q));
+ overlay->setZValue(OverlayZValue);
+ } else
+ overlay.clear();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void QGraphicsWebViewPrivate::setRootGraphicsLayer(QGraphicsItem* layer)
+{
+ if (rootGraphicsLayer) {
+ rootGraphicsLayer->setParentItem(0);
+ q->scene()->removeItem(rootGraphicsLayer);
+ QWebFramePrivate::core(q->page()->mainFrame())->view()->syncCompositingStateRecursive();
+ }
+
+ rootGraphicsLayer = layer;
+
+ if (layer) {
+ layer->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
+ layer->setParentItem(q);
+ layer->setZValue(RootGraphicsLayerZValue);
+ updateCompositingScrollPosition();
+ }
+ createOrDeleteOverlay();
+}
+
+void QGraphicsWebViewPrivate::markForSync(bool scheduleSync)
+{
+ shouldSync = true;
+ if (scheduleSync)
+ syncMetaMethod.invoke(q, Qt::QueuedConnection);
+}
+
+void QGraphicsWebViewPrivate::updateCompositingScrollPosition()
+{
+ if (rootGraphicsLayer && q->page() && q->page()->mainFrame()) {
+ const QPoint scrollPosition = q->page()->mainFrame()->scrollPosition();
+ rootGraphicsLayer->setPos(-scrollPosition);
+ }
+}
+#endif
+
+void QGraphicsWebViewPrivate::syncLayers()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ if (shouldSync) {
+ QWebFramePrivate::core(q->page()->mainFrame())->view()->syncCompositingStateRecursive();
+ shouldSync = false;
+ }
+#endif
}
void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success)
@@ -107,11 +275,22 @@ void QGraphicsWebViewPrivate::_q_pageDestroyed()
void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
{
q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll));
+
+#if USE(ACCELERATED_COMPOSITING)
+ updateCompositingScrollPosition();
+#endif
}
void QGraphicsWebViewPrivate::update(const QRect & dirtyRect)
{
q->update(QRectF(dirtyRect));
+
+ createOrDeleteOverlay();
+ if (overlay)
+ overlay->update(QRectF(dirtyRect));
+#if USE(ACCELERATED_COMPOSITING)
+ syncLayers();
+#endif
}
@@ -160,10 +339,12 @@ QPalette QGraphicsWebViewPrivate::palette() const
int QGraphicsWebViewPrivate::screenNumber() const
{
#if defined(Q_WS_X11)
- const QList<QGraphicsView*> views = q->scene()->views();
+ if (QGraphicsScene* scene = q->scene()) {
+ const QList<QGraphicsView*> views = scene->views();
- if (!views.isEmpty())
- return views.at(0)->x11Info().screen();
+ if (!views.isEmpty())
+ return views.at(0)->x11Info().screen();
+ }
#endif
return 0;
@@ -171,8 +352,24 @@ int QGraphicsWebViewPrivate::screenNumber() const
QWidget* QGraphicsWebViewPrivate::ownerWidget() const
{
- const QList<QGraphicsView*> views = q->scene()->views();
- return views.value(0);
+ if (QGraphicsScene* scene = q->scene()) {
+ const QList<QGraphicsView*> views = scene->views();
+ return views.value(0);
+ }
+ return 0;
+}
+
+QRect QGraphicsWebViewPrivate::geometryRelativeToOwnerWidget() const
+{
+ if (!q->scene())
+ return QRect();
+
+ QList<QGraphicsView*> views = q->scene()->views();
+ if (views.isEmpty())
+ return QRect();
+
+ QGraphicsView* view = views.at(0);
+ return view->mapFromScene(q->boundingRect()).boundingRect();
}
QObject* QGraphicsWebViewPrivate::pluginParent() const
@@ -180,6 +377,74 @@ QObject* QGraphicsWebViewPrivate::pluginParent() const
return q;
}
+QStyle* QGraphicsWebViewPrivate::style() const
+{
+ return q->style();
+}
+
+void QGraphicsWebViewPrivate::updateResizesToContentsForPage()
+{
+ ASSERT(page);
+
+ if (resizesToContents) {
+ // resizes to contents mode requires preferred contents size to be set
+ if (!page->preferredContentsSize().isValid())
+ page->setPreferredContentsSize(QSize(960, 800));
+
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
+ q, SLOT(_q_contentsSizeChanged(const QSize&)), Qt::UniqueConnection);
+#else
+ QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
+ q, SLOT(_q_contentsSizeChanged(const QSize&)));
+#endif
+ } else {
+ QObject::disconnect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
+ q, SLOT(_q_contentsSizeChanged(const QSize&)));
+ }
+}
+
+void QGraphicsWebViewPrivate::_q_contentsSizeChanged(const QSize& size)
+{
+ if (!resizesToContents)
+ return;
+ q->setGeometry(QRectF(q->geometry().topLeft(), size));
+}
+
+void QGraphicsWebViewPrivate::_q_scaleChanged()
+{
+#if ENABLE(TILED_BACKING_STORE)
+ updateTiledBackingStoreScale();
+#endif
+}
+
+QRectF QGraphicsWebViewPrivate::graphicsItemVisibleRect() const
+{
+ if (!q->scene())
+ return QRectF();
+ QList<QGraphicsView*> views = q->scene()->views();
+ if (views.size() > 1) {
+ qDebug() << "QGraphicsWebView is in more than one graphics views, unable to compute the visible rect";
+ return QRectF();
+ }
+ if (views.size() < 1)
+ return QRectF();
+
+ int xPosition = views[0]->horizontalScrollBar()->value();
+ int yPosition = views[0]->verticalScrollBar()->value();
+ return q->mapRectFromScene(QRectF(QPoint(xPosition, yPosition), views[0]->viewport()->size()));
+}
+
+#if ENABLE(TILED_BACKING_STORE)
+void QGraphicsWebViewPrivate::updateTiledBackingStoreScale()
+{
+ WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page->mainFrame())->tiledBackingStore();
+ if (!backingStore)
+ return;
+ backingStore->setContentsScale(q->scale());
+}
+#endif
+
/*!
\class QGraphicsWebView
\brief The QGraphicsWebView class allows Web content to be added to a GraphicsView.
@@ -266,8 +531,16 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent)
#if QT_VERSION >= 0x040600
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
#endif
+ setAcceptDrops(true);
setAcceptHoverEvents(true);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ setAcceptTouchEvents(true);
+#endif
setFocusPolicy(Qt::StrongFocus);
+ setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
+#if ENABLE(TILED_BACKING_STORE)
+ QObject::connect(this, SIGNAL(scaleChanged()), this, SLOT(_q_scaleChanged()));
+#endif
}
/*!
@@ -317,7 +590,26 @@ QWebPage* QGraphicsWebView::page() const
*/
void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*)
{
- page()->mainFrame()->render(painter, option->exposedRect.toRect());
+#if ENABLE(TILED_BACKING_STORE)
+ if (WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page()->mainFrame())->tiledBackingStore()) {
+ // FIXME: We should set the backing store viewport earlier than in paint
+ if (d->resizesToContents)
+ backingStore->viewportChanged(WebCore::IntRect(d->graphicsItemVisibleRect()));
+ else {
+ QRectF visibleRect(d->page->mainFrame()->scrollPosition(), d->page->mainFrame()->geometry().size());
+ backingStore->viewportChanged(WebCore::IntRect(visibleRect));
+ }
+ // QWebFrame::render is a public API, bypass it for tiled rendering so behavior does not need to change.
+ WebCore::GraphicsContext context(painter);
+ page()->mainFrame()->d->renderFromTiledBackingStore(&context, option->exposedRect.toAlignedRect());
+ return;
+ }
+#endif
+#if USE(ACCELERATED_COMPOSITING)
+ page()->mainFrame()->render(painter, d->overlay ? QWebFrame::ContentsLayer : QWebFrame::AllLayers, option->exposedRect.toAlignedRect());
+#else
+ page()->mainFrame()->render(painter, QWebFrame::AllLayers, option->exposedRect.toRect());
+#endif
}
/*! \reimp
@@ -325,6 +617,17 @@ void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem*
bool QGraphicsWebView::sceneEvent(QEvent* event)
{
// Re-implemented in order to allows fixing event-related bugs in patch releases.
+
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ if (d->page && (event->type() == QEvent::TouchBegin
+ || event->type() == QEvent::TouchEnd
+ || event->type() == QEvent::TouchUpdate)) {
+ d->page->event(event);
+ if (event->isAccepted())
+ return true;
+ }
+#endif
+
return QGraphicsWidget::sceneEvent(event);
}
@@ -391,7 +694,6 @@ bool QGraphicsWebView::event(QEvent* event)
#endif // QT_NO_CONTEXTMENU
{
#ifndef QT_NO_CURSOR
-#if QT_VERSION >= 0x040400
if (event->type() == QEvent::CursorChange) {
// An unsetCursor will set the cursor to Qt::ArrowCursor.
// Thus this cursor change might be a QWidget::unsetCursor()
@@ -405,12 +707,34 @@ bool QGraphicsWebView::event(QEvent* event)
d->resetCursor();
}
#endif
-#endif
}
}
return QGraphicsWidget::event(event);
}
+void QGraphicsWebViewPrivate::unsetPageIfExists()
+{
+ if (!page)
+ return;
+
+ // if the page client is the special client constructed for
+ // delegating the responsibilities to a QWidget, we need
+ // to destroy it.
+
+ if (page->d->client && page->d->client->isQWidgetClient())
+ delete page->d->client;
+
+ page->d->client = 0;
+
+ // if the page was created by us, we own it and need to
+ // destroy it as well.
+
+ if (page->parent() == q)
+ delete page;
+ else
+ page->disconnect(q);
+}
+
/*!
Makes \a page the new web page of the web graphicsitem.
@@ -425,22 +749,23 @@ void QGraphicsWebView::setPage(QWebPage* page)
if (d->page == page)
return;
- if (d->page) {
- d->page->d->client = 0; // unset the page client
- if (d->page->parent() == this)
- delete d->page;
- else
- d->page->disconnect(this);
- }
-
+ d->unsetPageIfExists();
d->page = page;
+
if (!d->page)
return;
+
d->page->d->client = d; // set the page client
+ if (d->overlay)
+ d->overlay->prepareGeometryChange();
+
QSize size = geometry().size().toSize();
page->setViewportSize(size);
+ if (d->resizesToContents)
+ d->updateResizesToContentsForPage();
+
QWebFrame* mainFrame = d->page->mainFrame();
connect(mainFrame, SIGNAL(titleChanged(QString)),
@@ -523,7 +848,6 @@ QIcon QGraphicsWebView::icon() const
/*!
\property QGraphicsWebView::zoomFactor
- \since 4.5
\brief the zoom factor for the view
*/
@@ -544,6 +868,9 @@ qreal QGraphicsWebView::zoomFactor() const
*/
void QGraphicsWebView::updateGeometry()
{
+ if (d->overlay)
+ d->overlay->prepareGeometryChange();
+
QGraphicsWidget::updateGeometry();
if (!d->page)
@@ -559,6 +886,9 @@ void QGraphicsWebView::setGeometry(const QRectF& rect)
{
QGraphicsWidget::setGeometry(rect);
+ if (d->overlay)
+ d->overlay->prepareGeometryChange();
+
if (!d->page)
return;
@@ -766,6 +1096,77 @@ bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags op
return false;
}
+/*!
+ \property QGraphicsWebView::resizesToContents
+ \brief whether the size of the QGraphicsWebView and its viewport changes to match the contents size
+ \since 4.7
+
+ If this property is set, the QGraphicsWebView will automatically change its
+ size to match the size of the main frame contents. As a result the top level frame
+ will never have scrollbars. It will also make CSS fixed positioning to behave like absolute positioning
+ with elements positioned relative to the document instead of the viewport.
+
+ This property should be used in conjunction with the QWebPage::preferredContentsSize property.
+ If not explicitly set, the preferredContentsSize is automatically set to a reasonable value.
+
+ \sa QWebPage::setPreferredContentsSize()
+*/
+void QGraphicsWebView::setResizesToContents(bool enabled)
+{
+ if (d->resizesToContents == enabled)
+ return;
+ d->resizesToContents = enabled;
+ if (d->page)
+ d->updateResizesToContentsForPage();
+}
+
+bool QGraphicsWebView::resizesToContents() const
+{
+ return d->resizesToContents;
+}
+
+/*!
+ \property QGraphicsWebView::tiledBackingStoreFrozen
+ \brief whether the tiled backing store updates its contents
+ \since 4.7
+
+ If the tiled backing store is enabled using QWebSettings::TiledBackingStoreEnabled attribute, this property
+ can be used to disable backing store updates temporarily. This can be useful for example for running
+ a smooth animation that changes the scale of the QGraphicsWebView.
+
+ When the backing store is unfrozen, its contents will be automatically updated to match the current
+ state of the document. If the QGraphicsWebView scale was changed, the backing store is also
+ re-rendered using the new scale.
+
+ If the tiled backing store is not enabled, this property does nothing.
+
+ \sa QWebSettings::TiledBackingStoreEnabled
+ \sa QGraphicsObject::scale
+*/
+bool QGraphicsWebView::isTiledBackingStoreFrozen() const
+{
+#if ENABLE(TILED_BACKING_STORE)
+ WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page()->mainFrame())->tiledBackingStore();
+ if (!backingStore)
+ return false;
+ return backingStore->contentsFrozen();
+#else
+ return false;
+#endif
+}
+
+void QGraphicsWebView::setTiledBackingStoreFrozen(bool frozen)
+{
+#if ENABLE(TILED_BACKING_STORE)
+ WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page()->mainFrame())->tiledBackingStore();
+ if (!backingStore)
+ return;
+ backingStore->setContentsFrozen(frozen);
+#else
+ UNUSED_PARAM(frozen);
+#endif
+}
+
/*! \reimp
*/
void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev)
@@ -903,10 +1304,8 @@ bool QGraphicsWebView::focusNextPrevChild(bool next)
void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev)
{
#ifndef QT_NO_DRAGANDDROP
- //if (d->page)
- // d->page->event(ev);
- //Just remove this line below when the code above is working
- Q_UNUSED(ev);
+ if (d->page)
+ d->page->event(ev);
#else
Q_UNUSED(ev);
#endif
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
index 1b02f35698..88729d31e4 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
@@ -45,6 +45,8 @@ class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget {
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(bool modified READ isModified)
+ Q_PROPERTY(bool resizesToContents READ resizesToContents WRITE setResizesToContents)
+ Q_PROPERTY(bool tiledBackingStoreFrozen READ isTiledBackingStoreFrozen WRITE setTiledBackingStoreFrozen)
public:
explicit QGraphicsWebView(QGraphicsItem* parent = 0);
@@ -79,6 +81,12 @@ public:
bool findText(const QString& subString, QWebPage::FindFlags options = 0);
+ bool resizesToContents() const;
+ void setResizesToContents(bool enabled);
+
+ bool isTiledBackingStoreFrozen() const;
+ void setTiledBackingStoreFrozen(bool frozen);
+
virtual void setGeometry(const QRectF& rect);
virtual void updateGeometry();
virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = 0);
@@ -136,6 +144,11 @@ private:
Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success))
Q_PRIVATE_SLOT(d, void _q_updateMicroFocus())
Q_PRIVATE_SLOT(d, void _q_pageDestroyed())
+ // we don't want to change the moc based on USE() macro, so this function is here
+ // but will be empty if ACCLERATED_COMPOSITING is disabled
+ Q_PRIVATE_SLOT(d, void syncLayers())
+ Q_PRIVATE_SLOT(d, void _q_contentsSizeChanged(const QSize&))
+ Q_PRIVATE_SLOT(d, void _q_scaleChanged())
QGraphicsWebViewPrivate* const d;
friend class QGraphicsWebViewPrivate;
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp
index 441bec7526..955206d1ac 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp
@@ -38,7 +38,6 @@
#include "NodeList.h"
#include "PropertyNameArray.h"
#include "RenderImage.h"
-#include "ScriptFunctionCall.h"
#include "StaticNodeList.h"
#include "qt_runtime.h"
#include "qwebframe.h"
@@ -865,25 +864,7 @@ QStringList QWebElement::classes() const
return QStringList();
QStringList classes = attribute(QLatin1String("class")).simplified().split(QLatin1Char(' '), QString::SkipEmptyParts);
-#if QT_VERSION >= 0x040500
classes.removeDuplicates();
-#else
- int n = classes.size();
- int j = 0;
- QSet<QString> seen;
- seen.reserve(n);
- for (int i = 0; i < n; ++i) {
- const QString& s = classes.at(i);
- if (seen.contains(s))
- continue;
- seen.insert(s);
- if (j != i)
- classes[j] = s;
- ++j;
- }
- if (n != j)
- classes.erase(classes.begin() + j, classes.end());
-#endif
return classes;
}
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
index 13c341cd42..a87d388d85 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
@@ -32,6 +32,12 @@ namespace WebCore {
class Node;
}
+namespace JSC {
+namespace Bindings {
+ class QtWebElementRuntime;
+}
+}
+
QT_BEGIN_NAMESPACE
class QPainter;
QT_END_NAMESPACE
@@ -153,6 +159,7 @@ private:
friend class QWebHitTestResult;
friend class QWebHitTestResultPrivate;
friend class QWebPage;
+ friend class JSC::Bindings::QtWebElementRuntime;
QWebElementPrivate* d;
WebCore::Element* m_element;
@@ -255,4 +262,6 @@ private:
QExplicitlySharedDataPointer<QWebElementCollectionPrivate> d;
};
+Q_DECLARE_METATYPE(QWebElement)
+
#endif // QWEBELEMENT_H
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
index 710e11b6c2..06c82baef4 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
@@ -21,6 +21,7 @@
#include "config.h"
#include "qwebframe.h"
+#include "Bridge.h"
#include "CallFrame.h"
#include "Document.h"
#include "DocumentLoader.h"
@@ -56,6 +57,8 @@
#include "Scrollbar.h"
#include "SelectionController.h"
#include "SubstituteData.h"
+#include "SVGSMILElement.h"
+#include "TiledBackingStore.h"
#include "htmlediting.h"
#include "markup.h"
#include "qt_instance.h"
@@ -66,7 +69,6 @@
#include "qwebpage_p.h"
#include "qwebsecurityorigin.h"
#include "qwebsecurityorigin_p.h"
-#include "runtime.h"
#include "runtime_object.h"
#include "runtime_root.h"
#include "wtf/HashMap.h"
@@ -77,14 +79,7 @@
#include <qpainter.h>
#include <qprinter.h>
#include <qregion.h>
-
-#if QT_VERSION < 0x040400
-#include "qwebnetworkinterface.h"
-#endif
-
-#if QT_VERSION >= 0x040400
#include <qnetworkrequest.h>
-#endif
using namespace WebCore;
@@ -93,6 +88,20 @@ QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT int qt_defaultDpi();
QT_END_NAMESPACE
+void QWEBKIT_EXPORT qt_drt_setMediaType(QWebFrame* qframe, const QString& type)
+{
+ WebCore::Frame* frame = QWebFramePrivate::core(qframe);
+ WebCore::FrameView* view = frame->view();
+ view->setMediaType(type);
+ frame->document()->updateStyleSelector();
+ view->forceLayout();
+}
+
+bool QWEBKIT_EXPORT qt_drt_hasDocumentElement(QWebFrame* qframe)
+{
+ return QWebFramePrivate::core(qframe)->document()->documentElement();
+}
+
void QWEBKIT_EXPORT qt_drt_setJavaScriptProfilingEnabled(QWebFrame* qframe, bool enabled)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
@@ -150,6 +159,31 @@ bool QWEBKIT_EXPORT qt_drt_pauseTransitionOfProperty(QWebFrame *qframe, const QS
return controller->pauseTransitionAtTime(coreNode->renderer(), propertyName, time);
}
+// Pause a given SVG animation on the target node at a specific time.
+// This method is only intended to be used for testing the SVG animation system.
+bool QWEBKIT_EXPORT qt_drt_pauseSVGAnimation(QWebFrame *qframe, const QString &animationId, double time, const QString &elementId)
+{
+#if !ENABLE(SVG)
+ return false;
+#else
+ Frame* frame = QWebFramePrivate::core(qframe);
+ if (!frame)
+ return false;
+
+ Document* doc = frame->document();
+ Q_ASSERT(doc);
+
+ if (!doc->svgExtensions())
+ return false;
+
+ Node* coreNode = doc->getElementById(animationId);
+ if (!coreNode || !SVGSMILElement::isSMILElement(coreNode))
+ return false;
+
+ return doc->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreNode), time);
+#endif
+}
+
// Returns the total number of currently running animations (includes both CSS transitions and CSS animations).
int QWEBKIT_EXPORT qt_drt_numberOfActiveAnimations(QWebFrame *qframe)
{
@@ -196,6 +230,28 @@ QString QWEBKIT_EXPORT qt_drt_counterValueForElementById(QWebFrame* qFrame, cons
return QString();
}
+int QWEBKIT_EXPORT qt_drt_pageNumberForElementById(QWebFrame* qFrame, const QString& id, float width, float height)
+{
+ Frame* frame = QWebFramePrivate::core(qFrame);
+ if (!frame)
+ return -1;
+
+ Element* element = frame->document()->getElementById(AtomicString(id));
+ if (!element)
+ return -1;
+
+ return PrintContext::pageNumberForElement(element, FloatSize(width, height));
+}
+
+int QWEBKIT_EXPORT qt_drt_numberOfPages(QWebFrame* qFrame, float width, float height)
+{
+ Frame* frame = QWebFramePrivate::core(qFrame);
+ if (!frame)
+ return -1;
+
+ return PrintContext::numberOfPages(frame, FloatSize(width, height));
+}
+
// Suspend active DOM objects in this frame.
void QWEBKIT_EXPORT qt_suspendActiveDOMObjects(QWebFrame* qFrame)
{
@@ -212,6 +268,93 @@ void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* qFrame)
frame->document()->resumeActiveDOMObjects();
}
+void QWEBKIT_EXPORT qt_drt_evaluateScriptInIsolatedWorld(QWebFrame* qFrame, int worldId, const QString& script)
+{
+ Frame* frame = QWebFramePrivate::core(qFrame);
+ if (frame)
+ JSC::JSValue result = frame->script()->executeScriptInWorld(mainThreadNormalWorld(), script, true).jsValue();
+}
+
+static bool webframe_scrollOverflow(WebCore::Frame* frame, int dx, int dy, const QPoint& pos)
+{
+ if (!frame || !frame->document() || !frame->eventHandler())
+ return false;
+
+ Node* node = frame->document()->elementFromPoint(pos.x(), pos.y());
+ if (!node)
+ return false;
+
+ RenderObject* renderer = node->renderer();
+ if (!renderer)
+ return false;
+
+ if (renderer->isListBox())
+ return false;
+
+ RenderLayer* renderLayer = renderer->enclosingLayer();
+ if (!renderLayer)
+ return false;
+
+ bool scrolledHorizontal = false;
+ bool scrolledVertical = false;
+
+ if (dx > 0)
+ scrolledHorizontal = renderLayer->scroll(ScrollRight, ScrollByPixel, dx);
+ else if (dx < 0)
+ scrolledHorizontal = renderLayer->scroll(ScrollLeft, ScrollByPixel, qAbs(dx));
+
+ if (dy > 0)
+ scrolledVertical = renderLayer->scroll(ScrollDown, ScrollByPixel, dy);
+ else if (dy < 0)
+ scrolledVertical = renderLayer->scroll(ScrollUp, ScrollByPixel, qAbs(dy));
+
+ return (scrolledHorizontal || scrolledVertical);
+}
+
+
+/*!
+ \internal
+ Scrolls nested frames starting at this frame, \a dx pixels to the right
+ and \a dy pixels downward. Both \a dx and \a dy may be negative. First attempts
+ to scroll elements with CSS overflow at position pos, followed by this frame. If this
+ frame doesn't scroll, attempts to scroll the parent
+*/
+void QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy, const QPoint& pos)
+{
+ Frame* frame = QWebFramePrivate::core(qFrame);
+
+ if (!frame || !frame->view())
+ return;
+
+ if (!webframe_scrollOverflow(frame, dx, dy, pos)) {
+ do {
+ bool scrolledHorizontal = false;
+ bool scrolledVertical = false;
+
+ IntSize scrollOffset = frame->view()->scrollOffset();
+ IntPoint maxScrollOffset = frame->view()->maximumScrollPosition();
+
+ if (dx > 0) // scroll right
+ scrolledHorizontal = scrollOffset.width() < maxScrollOffset.x();
+ else if (dx < 0) // scroll left
+ scrolledHorizontal = scrollOffset.width() > 0;
+
+ if (dy > 0) // scroll down
+ scrolledVertical = scrollOffset.height() < maxScrollOffset.y();
+ else if (dy < 0) //scroll up
+ scrolledVertical = scrollOffset.height() > 0;
+
+ if (scrolledHorizontal || scrolledVertical) {
+ frame->view()->scrollBy(IntSize(dx, dy));
+ return;
+ }
+
+ frame = frame->tree()->parent();
+ } while (frame && frame->view());
+ }
+}
+
+
QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame,
WebCore::HTMLFrameOwnerElement* ownerFrameElement,
const WebCore::String& frameName)
@@ -245,6 +388,21 @@ void QWebFramePrivate::init(QWebFrame *qframe, QWebFrameData *frameData)
frame->init();
}
+void QWebFramePrivate::setPage(QWebPage* newPage)
+{
+ if (page == newPage)
+ return;
+
+ // The QWebFrame is created as a child of QWebPage or a parent QWebFrame.
+ // That adds it to QObject's internal children list and ensures it will be
+ // deleted when parent QWebPage is deleted. Reparent if needed.
+ if (q->parent() == qobject_cast<QObject*>(page))
+ q->setParent(newPage);
+
+ page = newPage;
+ emit q->pageChanged();
+}
+
WebCore::Scrollbar* QWebFramePrivate::horizontalScrollBar() const
{
if (!frame->view())
@@ -259,8 +417,11 @@ WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const
return frame->view()->verticalScrollbar();
}
-void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer layer, const QRegion &clip)
+#if ENABLE(TILED_BACKING_STORE)
+void QWebFramePrivate::renderFromTiledBackingStore(GraphicsContext* context, const QRegion& clip)
{
+ ASSERT(frame->tiledBackingStore());
+
if (!frame->view() || !frame->contentRenderer())
return;
@@ -268,15 +429,46 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l
if (vector.isEmpty())
return;
- GraphicsContext context(painter);
- if (context.paintingDisabled() && !context.updatingControlTints())
+ QPainter* painter = context->platformContext();
+
+ WebCore::FrameView* view = frame->view();
+
+ int scrollX = view->scrollX();
+ int scrollY = view->scrollY();
+ context->translate(-scrollX, -scrollY);
+
+ for (int i = 0; i < vector.size(); ++i) {
+ const QRect& clipRect = vector.at(i);
+
+ painter->save();
+
+ QRect rect = clipRect.translated(scrollX, scrollY);
+ painter->setClipRect(rect, Qt::IntersectClip);
+
+ frame->tiledBackingStore()->paint(context, rect);
+
+ painter->restore();
+ }
+}
+#endif
+
+void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame::RenderLayer layer, const QRegion& clip)
+{
+ if (!frame->view() || !frame->contentRenderer())
+ return;
+
+ QVector<QRect> vector = clip.rects();
+ if (vector.isEmpty())
return;
+ QPainter* painter = context->platformContext();
+
WebCore::FrameView* view = frame->view();
view->layoutIfNeededRecursive();
for (int i = 0; i < vector.size(); ++i) {
const QRect& clipRect = vector.at(i);
+
QRect intersectedRect = clipRect.intersected(view->frameRect());
painter->save();
@@ -286,84 +478,46 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l
int y = view->y();
if (layer & QWebFrame::ContentsLayer) {
- context.save();
+ context->save();
int scrollX = view->scrollX();
int scrollY = view->scrollY();
QRect rect = intersectedRect;
- context.translate(x, y);
+ context->translate(x, y);
rect.translate(-x, -y);
- context.translate(-scrollX, -scrollY);
+ context->translate(-scrollX, -scrollY);
rect.translate(scrollX, scrollY);
- context.clip(view->visibleContentRect());
+ context->clip(view->visibleContentRect());
- view->paintContents(&context, rect);
+ view->paintContents(context, rect);
- context.restore();
+ context->restore();
}
if (layer & QWebFrame::ScrollBarLayer
&& !view->scrollbarsSuppressed()
&& (view->horizontalScrollbar() || view->verticalScrollbar())) {
- context.save();
+ context->save();
QRect rect = intersectedRect;
- context.translate(x, y);
+ context->translate(x, y);
rect.translate(-x, -y);
- view->paintScrollbars(&context, rect);
+ view->paintScrollbars(context, rect);
- context.restore();
+ context->restore();
}
+#if ENABLE(PAN_SCROLLING)
if (layer & QWebFrame::PanIconLayer)
- view->paintPanScrollIcon(&context);
+ view->paintPanScrollIcon(context);
+#endif
painter->restore();
}
}
-static bool webframe_scrollOverflow(WebCore::Frame* frame, int dx, int dy, const QPoint& pos)
-{
- if (!frame || !frame->document() || !frame->eventHandler())
- return false;
-
- Node* node = frame->document()->elementFromPoint(pos.x(), pos.y());
- if (!node)
- return false;
-
- RenderObject* renderer = node->renderer();
- if (!renderer)
- return false;
-
- if (renderer->isListBox())
- return false;
-
- RenderLayer* renderLayer = renderer->enclosingLayer();
- if (!renderLayer)
- return false;
-
- bool scrolledHorizontal = false;
- bool scrolledVertical = false;
-
- if (dx > 0)
- scrolledHorizontal = renderLayer->scroll(ScrollRight, ScrollByPixel, dx);
- else if (dx < 0)
- scrolledHorizontal = renderLayer->scroll(ScrollLeft, ScrollByPixel, qAbs(dx));
-
- if (dy > 0)
- scrolledVertical = renderLayer->scroll(ScrollDown, ScrollByPixel, dy);
- else if (dy < 0)
- scrolledVertical = renderLayer->scroll(ScrollUp, ScrollByPixel, qAbs(dy));
-
- return (scrolledHorizontal || scrolledVertical);
-}
-
-
-
-
-
/*!
\class QWebFrame
\since 4.4
@@ -554,7 +708,7 @@ QString QWebFrame::renderTreeDump() const
if (d->frame->view() && d->frame->view()->layoutPending())
d->frame->view()->layout();
- return externalRepresentation(d->frame->contentRenderer());
+ return externalRepresentation(d->frame);
}
/*!
@@ -726,58 +880,16 @@ QWebPage *QWebFrame::page() const
*/
void QWebFrame::load(const QUrl &url)
{
-#if QT_VERSION < 0x040400
- load(QWebNetworkRequest(ensureAbsoluteUrl(url)));
-#else
load(QNetworkRequest(ensureAbsoluteUrl(url)));
-#endif
-}
-
-#if QT_VERSION < 0x040400
-/*!
- Loads a network request, \a req, into this frame.
-
- \note The view remains the same until enough data has arrived to display the new url.
-*/
-void QWebFrame::load(const QWebNetworkRequest &req)
-{
- if (d->parentFrame())
- d->page->d->insideOpenCall = true;
-
- QUrl url = ensureAbsoluteUrl(req.url());
- QHttpRequestHeader httpHeader = req.httpHeader();
- QByteArray postData = req.postData();
-
- WebCore::ResourceRequest request(url);
-
- QString method = httpHeader.method();
- if (!method.isEmpty())
- request.setHTTPMethod(method);
-
- QList<QPair<QString, QString> > values = httpHeader.values();
- for (int i = 0; i < values.size(); ++i) {
- const QPair<QString, QString> &val = values.at(i);
- request.addHTTPHeaderField(val.first, val.second);
- }
-
- if (!postData.isEmpty())
- request.setHTTPBody(WebCore::FormData::create(postData.constData(), postData.size()));
-
- d->frame->loader()->load(request, false);
-
- if (d->parentFrame())
- d->page->d->insideOpenCall = false;
}
-#else
-
/*!
Loads a network request, \a req, into this frame, using the method specified in \a
operation.
\a body is optional and is only used for POST operations.
- \note The view remains the same until enough data has arrived to display the new \a url.
+ \note The view remains the same until enough data has arrived to display the new content.
\sa setUrl()
*/
@@ -829,7 +941,6 @@ void QWebFrame::load(const QNetworkRequest &req,
if (d->parentFrame())
d->page->d->insideOpenCall = false;
}
-#endif
/*!
Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative
@@ -837,10 +948,6 @@ void QWebFrame::load(const QNetworkRequest &req,
The \a html is loaded immediately; external objects are loaded asynchronously.
- If a script in the \a html runs longer than the default script timeout (currently 10 seconds),
- for example due to being blocked by a modal JavaScript alert dialog, this method will return
- as soon as possible after the timeout and any subsequent \a html will be loaded asynchronously.
-
When using this method WebKit assumes that external resources such as JavaScript programs or style
sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external
script can be specified through the charset attribute of the HTML script tag. It is also possible
@@ -942,11 +1049,13 @@ void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPol
d->horizontalScrollBarPolicy = policy;
if (d->frame->view()) {
d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy);
+ d->frame->view()->updateCanHaveScrollbars();
}
} else {
d->verticalScrollBarPolicy = policy;
if (d->frame->view()) {
d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy);
+ d->frame->view()->updateCanHaveScrollbars();
}
}
}
@@ -1048,48 +1157,6 @@ void QWebFrame::scroll(int dx, int dy)
}
/*!
- \internal
- Scrolls nested frames starting at this frame, \a dx pixels to the right
- and \a dy pixels downward. Both \a dx and \a dy may be negative. First attempts
- to scroll elements with CSS overflow at position pos, followed by this frame. If this
- frame doesn't scroll, attempts to scroll the parent
-*/
-void QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy, const QPoint& pos)
-{
- Frame* frame = QWebFramePrivate::core(qFrame);
-
- if (!frame || !frame->view())
- return;
-
- if (!webframe_scrollOverflow(frame, dx, dy, pos)) {
- do {
- bool scrolledHorizontal = false;
- bool scrolledVertical = false;
-
- IntSize scrollOffset = frame->view()->scrollOffset();
- IntPoint maxScrollOffset = frame->view()->maximumScrollPosition();
-
- if (dx > 0) // scroll right
- scrolledHorizontal = scrollOffset.width() < maxScrollOffset.x();
- else if (dx < 0) // scroll left
- scrolledHorizontal = scrollOffset.width() > 0;
-
- if (dy > 0) // scroll down
- scrolledVertical = scrollOffset.height() < maxScrollOffset.y();
- else if (dy < 0) //scroll up
- scrolledVertical = scrollOffset.height() > 0;
-
- if (scrolledHorizontal || scrolledVertical) {
- frame->view()->scrollBy(IntSize(dx, dy));
- return;
- }
-
- frame = frame->tree()->parent();
- } while (frame && frame->view());
- }
-}
-
-/*!
\property QWebFrame::scrollPosition
\since 4.5
\brief the position the frame is currently scrolled to.
@@ -1113,6 +1180,17 @@ void QWebFrame::setScrollPosition(const QPoint &pos)
}
/*!
+ \since 4.7
+ Scrolls the frame to the given \a anchor name.
+*/
+void QWebFrame::scrollToAnchor(const QString& anchor)
+{
+ FrameView *view = d->frame->view();
+ if (view)
+ view->scrollToAnchor(anchor);
+}
+
+/*!
\since 4.6
Render the \a layer of the frame using \a painter clipping to \a clip.
@@ -1121,29 +1199,41 @@ void QWebFrame::setScrollPosition(const QPoint &pos)
void QWebFrame::render(QPainter* painter, RenderLayer layer, const QRegion& clip)
{
+ GraphicsContext context(painter);
+ if (context.paintingDisabled() && !context.updatingControlTints())
+ return;
+
if (!clip.isEmpty())
- d->renderPrivate(painter, layer, clip);
+ d->renderRelativeCoords(&context, layer, clip);
else if (d->frame->view())
- d->renderPrivate(painter, layer, QRegion(d->frame->view()->frameRect()));
+ d->renderRelativeCoords(&context, layer, QRegion(d->frame->view()->frameRect()));
}
/*!
Render the frame into \a painter clipping to \a clip.
*/
-void QWebFrame::render(QPainter *painter, const QRegion &clip)
+void QWebFrame::render(QPainter* painter, const QRegion& clip)
{
- d->renderPrivate(painter, AllLayers, clip);
+ GraphicsContext context(painter);
+ if (context.paintingDisabled() && !context.updatingControlTints())
+ return;
+
+ d->renderRelativeCoords(&context, AllLayers, clip);
}
/*!
Render the frame into \a painter.
*/
-void QWebFrame::render(QPainter *painter)
+void QWebFrame::render(QPainter* painter)
{
if (!d->frame->view())
return;
- d->renderPrivate(painter, AllLayers, QRegion(d->frame->view()->frameRect()));
+ GraphicsContext context(painter);
+ if (context.paintingDisabled() && !context.updatingControlTints())
+ return;
+
+ d->renderRelativeCoords(&context, AllLayers, QRegion(d->frame->view()->frameRect()));
}
/*!
@@ -1164,7 +1254,7 @@ void QWebFrame::render(QPainter *painter)
*/
void QWebFrame::setTextSizeMultiplier(qreal factor)
{
- d->frame->setZoomFactor(factor, /*isTextOnly*/true);
+ d->frame->setZoomFactor(factor, ZoomTextOnly);
}
/*!
@@ -1183,7 +1273,7 @@ qreal QWebFrame::textSizeMultiplier() const
void QWebFrame::setZoomFactor(qreal factor)
{
- d->frame->setZoomFactor(factor, d->frame->isZoomFactorTextOnly());
+ d->frame->setZoomFactor(factor, d->frame->zoomMode());
}
qreal QWebFrame::zoomFactor() const
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.h
index 08285f84ad..ce9805b85b 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.h
@@ -26,9 +26,7 @@
#include <QtCore/qvariant.h>
#include <QtGui/qicon.h>
#include <QtScript/qscriptengine.h>
-#if QT_VERSION >= 0x040400
#include <QtNetwork/qnetworkaccessmanager.h>
-#endif
#include "qwebkitglobal.h"
QT_BEGIN_NAMESPACE
@@ -123,13 +121,9 @@ public:
QWebPage *page() const;
void load(const QUrl &url);
-#if QT_VERSION < 0x040400
- void load(const QWebNetworkRequest &request);
-#else
void load(const QNetworkRequest &request,
QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
const QByteArray &body = QByteArray());
-#endif
void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
@@ -165,6 +159,8 @@ public:
QPoint scrollPosition() const;
void setScrollPosition(const QPoint &pos);
+ void scrollToAnchor(const QString& anchor);
+
enum RenderLayer {
ContentsLayer = 0x10,
ScrollBarLayer = 0x20,
@@ -222,7 +218,10 @@ Q_SIGNALS:
void loadStarted();
void loadFinished(bool ok);
+ void pageChanged();
+
private:
+ friend class QGraphicsWebView;
friend class QWebPage;
friend class QWebPagePrivate;
friend class QWebFramePrivate;
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h
index 095d1340a7..fcc37e7103 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h
@@ -25,6 +25,7 @@
#include "qwebpage_p.h"
#include "EventHandler.h"
+#include "GraphicsContext.h"
#include "KURL.h"
#include "PlatformString.h"
#include "qwebelement.h"
@@ -72,6 +73,7 @@ public:
, marginHeight(-1)
{}
void init(QWebFrame* qframe, QWebFrameData* frameData);
+ void setPage(QWebPage*);
inline QWebFrame *parentFrame() { return qobject_cast<QWebFrame*>(q->parent()); }
@@ -81,9 +83,10 @@ public:
static WebCore::Frame* core(QWebFrame*);
static QWebFrame* kit(WebCore::Frame*);
- void renderPrivate(QPainter*, QWebFrame::RenderLayer, const QRegion& clip);
-
- bool scrollOverflow(int dx, int dy);
+ void renderRelativeCoords(WebCore::GraphicsContext*, QWebFrame::RenderLayer, const QRegion& clip);
+#if ENABLE(TILED_BACKING_STORE)
+ void renderFromTiledBackingStore(WebCore::GraphicsContext*, const QRegion& clip);
+#endif
QWebFrame *q;
Qt::ScrollBarPolicy horizontalScrollBarPolicy;
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
index 1145744c3f..c0e5277710 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
@@ -139,9 +139,6 @@ QSize QWebInspector::sizeHint() const
/*! \reimp */
bool QWebInspector::event(QEvent* ev)
{
- if (ev->type() == QEvent::Close && d->page)
- d->page->d->inspectorController()->setWindowVisible(false);
-
return QWidget::event(ev);
}
@@ -154,14 +151,29 @@ void QWebInspector::resizeEvent(QResizeEvent* event)
/*! \reimp */
void QWebInspector::showEvent(QShowEvent* event)
{
+#if ENABLE(INSPECTOR)
// Allows QWebInspector::show() to init the inspector.
if (d->page)
d->page->d->inspectorController()->show();
+#endif
}
/*! \reimp */
void QWebInspector::hideEvent(QHideEvent* event)
{
+#if ENABLE(INSPECTOR)
+ if (d->page)
+ d->page->d->inspectorController()->close();
+#endif
+}
+
+/*! \reimp */
+void QWebInspector::closeEvent(QCloseEvent* event)
+{
+#if ENABLE(INSPECTOR)
+ if (d->page)
+ d->page->d->inspectorController()->close();
+#endif
}
/*! \internal */
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.h
index a5c1ed5b4a..f192e921b6 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.h
@@ -43,6 +43,7 @@ protected:
void resizeEvent(QResizeEvent* event);
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
+ void closeEvent(QCloseEvent* event);
private:
QWebInspectorPrivate* d;
@@ -51,5 +52,6 @@ private:
friend class QWebPage;
friend class QWebPagePrivate;
friend class WebCore::InspectorClientQt;
+ friend class WebCore::InspectorFrontendClientQt;
};
#endif
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h
index 0885bdc754..9e8979ff93 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h
@@ -40,15 +40,4 @@
# endif
#endif
-#if QT_VERSION < 0x040400
- #ifndef QT_BEGIN_NAMESPACE
- #define QT_BEGIN_NAMESPACE
- #endif
-
- #ifndef QT_END_NAMESPACE
- #define QT_END_NAMESPACE
- #endif
-#endif
-
-
#endif // QWEBKITGLOBAL_H
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
index 97a4e4ed2b..4c92c9fc51 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
@@ -32,6 +32,8 @@
#include "qwebsettings.h"
#include "qwebkitversion.h"
+#include "Chrome.h"
+#include "ContextMenuController.h"
#include "Frame.h"
#include "FrameTree.h"
#include "FrameLoader.h"
@@ -79,6 +81,7 @@
#include "runtime/InitializeThreading.h"
#include "PageGroup.h"
#include "QWebPageClient.h"
+#include "WorkerThread.h"
#include <QApplication>
#include <QBasicTimer>
@@ -102,18 +105,29 @@
#include <QStyle>
#include <QSysInfo>
#include <QTextCharFormat>
-#if QT_VERSION >= 0x040400
+#include <QTextDocument>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
-#else
-#include "qwebnetworkinterface.h"
-#endif
#if defined(Q_WS_X11)
#include <QX11Info>
#endif
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+#include <QTouchEvent>
+#include "PlatformTouchEvent.h"
+#endif
+
using namespace WebCore;
+void QWEBKIT_EXPORT qt_wrt_setViewMode(QWebPage* page, const QString& mode)
+{
+ QWebPagePrivate::priv(page)->viewMode = mode;
+ WebCore::Frame* frame = QWebFramePrivate::core(page->mainFrame());
+ WebCore::FrameView* view = frame->view();
+ frame->document()->updateStyleSelector();
+ view->forceLayout();
+}
+
void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories()
{
PluginDatabase* db = PluginDatabase::installedPlugins(/* populate */ false);
@@ -126,12 +140,26 @@ void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories()
db->refresh();
}
+int QWEBKIT_EXPORT qt_drt_workerThreadCount()
+{
+#if ENABLE(WORKERS)
+ return WebCore::WorkerThread::workerThreadCount();
+#else
+ return 0;
+#endif
+}
+
bool QWebPagePrivate::drtRun = false;
void QWEBKIT_EXPORT qt_drt_run(bool b)
{
QWebPagePrivate::drtRun = b;
}
+void QWEBKIT_EXPORT qt_drt_setFrameFlatteningEnabled(QWebPage* page, bool enabled)
+{
+ QWebPagePrivate::core(page)->settings()->setFrameFlatteningEnabled(enabled);
+}
+
void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName)
{
page->handle()->page->setGroupName(groupName);
@@ -142,6 +170,45 @@ QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page)
return page->handle()->page->groupName();
}
+#if ENABLE(INSPECTOR)
+void QWEBKIT_EXPORT qt_drt_webinspector_executeScript(QWebPage* page, long callId, const QString& script)
+{
+ if (!page->handle()->page->inspectorController())
+ return;
+ page->handle()->page->inspectorController()->evaluateForTestInFrontend(callId, script);
+}
+
+void QWEBKIT_EXPORT qt_drt_webinspector_close(QWebPage* page)
+{
+ if (!page->handle()->page->inspectorController())
+ return;
+ page->handle()->page->inspectorController()->close();
+}
+
+void QWEBKIT_EXPORT qt_drt_webinspector_show(QWebPage* page)
+{
+ if (!page->handle()->page->inspectorController())
+ return;
+ page->handle()->page->inspectorController()->show();
+}
+
+void QWEBKIT_EXPORT qt_drt_setTimelineProfilingEnabled(QWebPage* page, bool enabled)
+{
+ InspectorController* controller = page->handle()->page->inspectorController();
+ if (!controller)
+ return;
+ if (enabled)
+ controller->startTimelineProfiler();
+ else
+ controller->stopTimelineProfiler();
+}
+#endif
+
+void QWEBKIT_EXPORT qt_drt_enableCaretBrowsing(QWebPage* page, bool value)
+{
+ page->handle()->page->settings()->setCaretBrowsingEnabled(value);
+}
+
class QWebPageWidgetClient : public QWebPageClient {
public:
QWebPageWidgetClient(QWidget* view)
@@ -150,6 +217,8 @@ public:
Q_ASSERT(view);
}
+ virtual bool isQWidgetClient() const { return true; }
+
virtual void scroll(int dx, int dy, const QRect&);
virtual void update(const QRect& dirtyRect);
virtual void setInputMethodEnabled(bool enable);
@@ -166,9 +235,12 @@ public:
virtual QPalette palette() const;
virtual int screenNumber() const;
virtual QWidget* ownerWidget() const;
+ virtual QRect geometryRelativeToOwnerWidget() const;
virtual QObject* pluginParent() const;
+ virtual QStyle* style() const;
+
QWidget* view;
};
@@ -221,10 +293,8 @@ QPalette QWebPageWidgetClient::palette() const
int QWebPageWidgetClient::screenNumber() const
{
#if defined(Q_WS_X11)
- if (view)
- return view->x11Info().screen();
+ return view->x11Info().screen();
#endif
-
return 0;
}
@@ -233,11 +303,21 @@ QWidget* QWebPageWidgetClient::ownerWidget() const
return view;
}
+QRect QWebPageWidgetClient::geometryRelativeToOwnerWidget() const
+{
+ return view->geometry();
+}
+
QObject* QWebPageWidgetClient::pluginParent() const
{
return view;
}
+QStyle* QWebPageWidgetClient::style() const
+{
+ return view->style();
+}
+
// Lookup table mapping QWebPage::WebActions to the associated Editor commands
static const char* editorCommandWebActions[] =
{
@@ -341,8 +421,10 @@ static inline DragOperation dropActionToDragOp(Qt::DropActions actions)
unsigned result = 0;
if (actions & Qt::CopyAction)
result |= DragOperationCopy;
+ // DragOperationgeneric represents InternetExplorer's equivalent of Move operation,
+ // hence it should be considered as "move"
if (actions & Qt::MoveAction)
- result |= DragOperationMove;
+ result |= (DragOperationMove | DragOperationGeneric);
if (actions & Qt::LinkAction)
result |= DragOperationLink;
return (DragOperation)result;
@@ -355,6 +437,10 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
result = Qt::CopyAction;
else if (actions & DragOperationMove)
result = Qt::MoveAction;
+ // DragOperationgeneric represents InternetExplorer's equivalent of Move operation,
+ // hence it should be considered as "move"
+ else if (actions & DragOperationGeneric)
+ result = Qt::MoveAction;
else if (actions & DragOperationLink)
result = Qt::LinkAction;
return result;
@@ -366,11 +452,11 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
#if QT_VERSION < 0x040600
, view(0)
#endif
+ , clickCausedFocus(false)
+ , viewportSize(QSize(0, 0))
, inspectorFrontend(0)
, inspector(0)
, inspectorIsInternalOnly(false)
- , viewportSize(QSize(0, 0))
- , clickCausedFocus(false)
{
WebCore::InitializeLoggingChannelsIfNecessary();
JSC::initializeThreading();
@@ -380,7 +466,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
contextMenuClient = new ContextMenuClientQt();
editorClient = new EditorClientQt(q);
page = new Page(chromeClient, contextMenuClient, editorClient,
- new DragClientQt(q), new InspectorClientQt(q), 0);
+ new DragClientQt(q), new InspectorClientQt(q), 0, 0);
settings = new QWebSettings(page->settings());
@@ -388,11 +474,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
undoStack = 0;
#endif
mainFrame = 0;
-#if QT_VERSION < 0x040400
- networkInterface = 0;
-#else
networkManager = 0;
-#endif
pluginFactory = 0;
insideOpenCall = false;
forwardUnsupportedContent = false;
@@ -421,15 +503,16 @@ QWebPagePrivate::~QWebPagePrivate()
delete page;
}
-#if QT_VERSION < 0x040400
-bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
+WebCore::Page* QWebPagePrivate::core(QWebPage* page)
{
- if (insideOpenCall
- && frame == mainFrame)
- return true;
- return q->acceptNavigationRequest(frame, request, type);
+ return page->d->page;
}
-#else
+
+QWebPagePrivate* QWebPagePrivate::priv(QWebPage* page)
+{
+ return page->d;
+}
+
bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
{
if (insideOpenCall
@@ -437,7 +520,6 @@ bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRe
return true;
return q->acceptNavigationRequest(frame, request, type);
}
-#endif
void QWebPagePrivate::createMainFrame()
{
@@ -473,7 +555,9 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
case WebCore::ContextMenuItemTagBold: return QWebPage::ToggleBold;
case WebCore::ContextMenuItemTagItalic: return QWebPage::ToggleItalic;
case WebCore::ContextMenuItemTagUnderline: return QWebPage::ToggleUnderline;
+#if ENABLE(INSPECTOR)
case WebCore::ContextMenuItemTagInspectElement: return QWebPage::InspectElement;
+#endif
default: break;
}
return QWebPage::NoWebAction;
@@ -483,7 +567,10 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu,
const QList<WebCore::ContextMenuItem> *items, QBitArray *visitedWebActions)
{
- QMenu* menu = new QMenu(q->view());
+ if (!client)
+ return 0;
+
+ QMenu* menu = new QMenu(client->ownerWidget());
for (int i = 0; i < items->count(); ++i) {
const ContextMenuItem &item = items->at(i);
switch (item.type()) {
@@ -991,10 +1078,8 @@ QWebPage::WebAction QWebPagePrivate::editorActionForKeyEvent(QKeyEvent* event)
{ QKeySequence::SelectEndOfDocument, QWebPage::SelectEndOfDocument },
{ QKeySequence::DeleteStartOfWord, QWebPage::DeleteStartOfWord },
{ QKeySequence::DeleteEndOfWord, QWebPage::DeleteEndOfWord },
-#if QT_VERSION >= 0x040500
{ QKeySequence::InsertParagraphSeparator, QWebPage::InsertParagraphSeparator },
{ QKeySequence::InsertLineSeparator, QWebPage::InsertLineSeparator },
-#endif
{ QKeySequence::SelectAll, QWebPage::SelectAll },
{ QKeySequence::UnknownKey, QWebPage::NoWebAction }
};
@@ -1019,8 +1104,8 @@ void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
if (!handled) {
handled = true;
QFont defaultFont;
- if (q->view())
- defaultFont = q->view()->font();
+ if (client)
+ defaultFont = client->ownerWidget()->font();
QFontMetrics fm(defaultFont);
if (!handleScrolling(ev, frame)) {
switch (ev->key()) {
@@ -1079,8 +1164,9 @@ void QWebPagePrivate::focusOutEvent(QFocusEvent*)
// and the focus frame. But don't tell the focus controller so that upon
// focusInEvent() we can re-activate the frame.
FocusController *focusController = page->focusController();
- focusController->setActive(false);
+ // Call setFocused first so that window.onblur doesn't get called twice
focusController->setFocused(false);
+ focusController->setActive(false);
}
void QWebPagePrivate::dragEnterEvent(QGraphicsSceneDragDropEvent* ev)
@@ -1102,8 +1188,9 @@ void QWebPagePrivate::dragEnterEvent(QDragEnterEvent* ev)
dropActionToDragOp(ev->possibleActions()));
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData));
ev->setDropAction(action);
- if (action != Qt::IgnoreAction)
- ev->accept();
+ // We must accept this event in order to receive the drag move events that are sent
+ // while the drag and drop action is in progress.
+ ev->accept();
#endif
}
@@ -1143,9 +1230,11 @@ void QWebPagePrivate::dragMoveEvent(QDragMoveEvent* ev)
DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(),
dropActionToDragOp(ev->possibleActions()));
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragUpdated(&dragData));
+ m_lastDropAction = action;
ev->setDropAction(action);
- if (action != Qt::IgnoreAction)
- ev->accept();
+ // We must accept this event in order to receive the drag move events that are sent
+ // while the drag and drop action is in progress.
+ ev->accept();
#endif
}
@@ -1154,8 +1243,7 @@ void QWebPagePrivate::dropEvent(QGraphicsSceneDragDropEvent* ev)
#ifndef QT_NO_DRAGANDDROP
DragData dragData(ev->mimeData(), ev->pos().toPoint(),
QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
- Qt::DropAction action = dragOpToDropAction(page->dragController()->performDrag(&dragData));
- if (action != Qt::IgnoreAction)
+ if (page->dragController()->performDrag(&dragData))
ev->accept();
#endif
}
@@ -1163,10 +1251,11 @@ void QWebPagePrivate::dropEvent(QGraphicsSceneDragDropEvent* ev)
void QWebPagePrivate::dropEvent(QDropEvent* ev)
{
#ifndef QT_NO_DRAGANDDROP
+ // Overwrite the defaults set by QDragManager::defaultAction()
+ ev->setDropAction(m_lastDropAction);
DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(),
- dropActionToDragOp(ev->possibleActions()));
- Qt::DropAction action = dragOpToDropAction(page->dragController()->performDrag(&dragData));
- if (action != Qt::IgnoreAction)
+ dropActionToDragOp(Qt::DropAction(ev->dropAction())));
+ if (page->dragController()->performDrag(&dragData))
ev->accept();
#endif
}
@@ -1235,7 +1324,7 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
break;
}
case QInputMethodEvent::Cursor: {
- frame->setCaretVisible(a.length); //if length is 0 cursor is invisible
+ frame->selection()->setCaretVisible(a.length); //if length is 0 cursor is invisible
if (a.length > 0) {
RenderObject* caretRenderer = frame->selection()->caretRenderer();
if (caretRenderer) {
@@ -1313,16 +1402,16 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame)
granularity = ScrollByPage;
direction = ScrollDown;
} else if (ev == QKeySequence::MoveToPreviousPage
- || (ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier)) {
+ || ((ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier))) {
granularity = ScrollByPage;
direction = ScrollUp;
} else
#endif // QT_NO_SHORTCUT
- if (ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier
+ if ((ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier)
|| ev->key() == Qt::Key_Home) {
granularity = ScrollByDocument;
direction = ScrollUp;
- } else if (ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier
+ } else if ((ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier)
|| ev->key() == Qt::Key_End) {
granularity = ScrollByDocument;
direction = ScrollDown;
@@ -1352,6 +1441,18 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame)
return frame->eventHandler()->scrollRecursively(direction, granularity);
}
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+void QWebPagePrivate::touchEvent(QTouchEvent* event)
+{
+ WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+ if (!frame->view())
+ return;
+
+ bool accepted = frame->eventHandler()->handleTouchEvent(PlatformTouchEvent(event));
+ event->setAccepted(accepted);
+}
+#endif
+
/*!
This method is used by the input method to query a set of properties of the page
to be able to support complex input method operations as support for surrounding
@@ -1380,6 +1481,11 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
switch (property) {
case Qt::ImMicroFocus: {
+ WebCore::FrameView* view = frame->view();
+ if (view && view->needsLayout()) {
+ // We can't access absoluteCaretBounds() while the view needs to layout.
+ return QVariant();
+ }
return QVariant(frame->selection()->absoluteCaretBounds());
}
case Qt::ImFont: {
@@ -1478,6 +1584,7 @@ void QWebPagePrivate::setInspector(QWebInspector* insp)
*/
QWebInspector* QWebPagePrivate::getOrCreateInspector()
{
+#if ENABLE(INSPECTOR)
if (!inspector) {
QWebInspector* insp = new QWebInspector;
insp->setPage(q);
@@ -1485,13 +1592,18 @@ QWebInspector* QWebPagePrivate::getOrCreateInspector()
Q_ASSERT(inspector); // Associated through QWebInspector::setPage(q)
}
+#endif
return inspector;
}
/*! \internal */
InspectorController* QWebPagePrivate::inspectorController()
{
+#if ENABLE(INSPECTOR)
return page->inspectorController();
+#else
+ return 0;
+#endif
}
@@ -1691,7 +1803,7 @@ QWebPage::QWebPage(QObject *parent)
: QObject(parent)
, d(new QWebPagePrivate(this))
{
- setView(qobject_cast<QWidget *>(parent));
+ setView(qobject_cast<QWidget*>(parent));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(_q_onLoadProgressChanged(int)));
#ifndef NDEBUG
@@ -1775,21 +1887,28 @@ QWebHistory *QWebPage::history() const
\sa view()
*/
-void QWebPage::setView(QWidget *view)
-{
- if (this->view() != view) {
- d->view = view;
- if (!view) {
- delete d->client;
- d->client = 0;
- } else {
- if (!d->client)
- d->client = new QWebPageWidgetClient(view);
- else
- static_cast<QWebPageWidgetClient*>(d->client)->view = view;
- }
- setViewportSize(view ? view->size() : QSize(0, 0));
+void QWebPage::setView(QWidget* view)
+{
+ if (this->view() == view)
+ return;
+
+ d->view = view;
+ setViewportSize(view ? view->size() : QSize(0, 0));
+
+ // If we have no client, we install a special client delegating
+ // the responsibility to the QWidget. This is the code path
+ // handling a.o. the "legacy" QWebView.
+ //
+ // If such a special delegate already exist, we substitute the view.
+
+ if (d->client) {
+ if (d->client->isQWidgetClient())
+ static_cast<QWebPageWidgetClient*>(d->client)->view = view;
+ return;
}
+
+ if (view)
+ d->client = new QWebPageWidgetClient(view);
}
/*!
@@ -1830,7 +1949,8 @@ void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg)
{
Q_UNUSED(frame)
#ifndef QT_NO_MESSAGEBOX
- QMessageBox::information(view(), tr("JavaScript Alert - %1").arg(mainFrame()->url().host()), msg, QMessageBox::Ok);
+ QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
+ QMessageBox::information(parent, tr("JavaScript Alert - %1").arg(mainFrame()->url().host()), Qt::escape(msg), QMessageBox::Ok);
#endif
}
@@ -1846,7 +1966,8 @@ bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
#ifdef QT_NO_MESSAGEBOX
return true;
#else
- return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Confirm - %1").arg(mainFrame()->url().host()), msg, QMessageBox::Yes, QMessageBox::No);
+ QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
+ return QMessageBox::Yes == QMessageBox::information(parent, tr("JavaScript Confirm - %1").arg(mainFrame()->url().host()), Qt::escape(msg), QMessageBox::Yes, QMessageBox::No);
#endif
}
@@ -1865,7 +1986,8 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr
Q_UNUSED(frame)
bool ok = false;
#ifndef QT_NO_INPUTDIALOG
- QString x = QInputDialog::getText(view(), tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()), msg, QLineEdit::Normal, defaultValue, &ok);
+ QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
+ QString x = QInputDialog::getText(parent, tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()), Qt::escape(msg), QLineEdit::Normal, defaultValue, &ok);
if (ok && result)
*result = x;
#endif
@@ -1890,7 +2012,8 @@ bool QWebPage::shouldInterruptJavaScript()
#ifdef QT_NO_MESSAGEBOX
return false;
#else
- return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No);
+ QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
+ return QMessageBox::Yes == QMessageBox::information(parent, tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No);
#endif
}
@@ -1903,11 +2026,13 @@ bool QWebPage::shouldInterruptJavaScript()
If the view associated with the web page is a QWebView object, then the default implementation forwards
the request to QWebView's createWindow() function; otherwise it returns a null pointer.
+ If \a type is WebModalDialog, the application must call setWindowModality(Qt::ApplicationModal) on the new window.
+
\sa acceptNavigationRequest()
*/
QWebPage *QWebPage::createWindow(WebWindowType type)
{
- QWebView *webView = qobject_cast<QWebView *>(view());
+ QWebView *webView = qobject_cast<QWebView*>(view());
if (webView) {
QWebView *newView = webView->createWindow(type);
if (newView)
@@ -2033,11 +2158,13 @@ void QWebPage::triggerAction(WebAction action, bool)
editor->setBaseWritingDirection(RightToLeftWritingDirection);
break;
case InspectElement: {
+#if ENABLE(INSPECTOR)
if (!d->hitTestResult.isNull()) {
d->getOrCreateInspector(); // Make sure the inspector is created
d->inspector->show(); // The inspector is expected to be shown on inspection
d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get());
}
+#endif
break;
}
default:
@@ -2134,11 +2261,7 @@ void QWebPage::setPreferredContentsSize(const QSize &size) const
\sa createWindow()
*/
-#if QT_VERSION >= 0x040400
bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
-#else
-bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
-#endif
{
Q_UNUSED(frame)
if (type == NavigationTypeLinkClicked) {
@@ -2193,7 +2316,7 @@ QAction *QWebPage::action(WebAction action) const
QString text;
QIcon icon;
- QStyle *style = view() ? view()->style() : qApp->style();
+ QStyle *style = d->client ? d->client->style() : qApp->style();
bool checkable = false;
switch (action) {
@@ -2226,27 +2349,19 @@ QAction *QWebPage::action(WebAction action) const
case Back:
text = contextMenuItemTagGoBack();
-#if QT_VERSION >= 0x040400
icon = style->standardIcon(QStyle::SP_ArrowBack);
-#endif
break;
case Forward:
text = contextMenuItemTagGoForward();
-#if QT_VERSION >= 0x040400
icon = style->standardIcon(QStyle::SP_ArrowForward);
-#endif
break;
case Stop:
text = contextMenuItemTagStop();
-#if QT_VERSION >= 0x040400
icon = style->standardIcon(QStyle::SP_BrowserStop);
-#endif
break;
case Reload:
text = contextMenuItemTagReload();
-#if QT_VERSION >= 0x040400
icon = style->standardIcon(QStyle::SP_BrowserReload);
-#endif
break;
case Cut:
@@ -2579,6 +2694,13 @@ bool QWebPage::event(QEvent *ev)
case QEvent::Leave:
d->leaveEvent(ev);
break;
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ d->touchEvent(static_cast<QTouchEvent*>(ev));
+ break;
+#endif
default:
return QObject::event(ev);
}
@@ -2736,8 +2858,11 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos)
d->hitTestResult = QWebHitTestResult(new QWebHitTestResultPrivate(result));
WebCore::ContextMenu menu(result);
menu.populate();
+
+#if ENABLE(INSPECTOR)
if (d->page->inspectorController()->enabled())
menu.addInspectElementItem();
+#endif
QBitArray visitedWebActions(QWebPage::WebActionCount);
@@ -2888,7 +3013,8 @@ bool QWebPage::extension(Extension extension, const ExtensionOption *option, Ext
if (extension == ChooseMultipleFilesExtension) {
// FIXME: do not ignore suggestedFiles
QStringList suggestedFiles = static_cast<const ChooseMultipleFilesExtensionOption*>(option)->suggestedFileNames;
- QStringList names = QFileDialog::getOpenFileNames(view(), QString::null);
+ QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
+ QStringList names = QFileDialog::getOpenFileNames(parent, QString::null);
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names;
return true;
}
@@ -2970,41 +3096,13 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFil
{
Q_UNUSED(parentFrame)
#ifndef QT_NO_FILEDIALOG
- return QFileDialog::getOpenFileName(view(), QString::null, suggestedFile);
+ QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
+ return QFileDialog::getOpenFileName(parent, QString::null, suggestedFile);
#else
return QString::null;
#endif
}
-#if QT_VERSION < 0x040400 && !defined qdoc
-
-void QWebPage::setNetworkInterface(QWebNetworkInterface *interface)
-{
- d->networkInterface = interface;
-}
-
-QWebNetworkInterface *QWebPage::networkInterface() const
-{
- if (d->networkInterface)
- return d->networkInterface;
- else
- return QWebNetworkInterface::defaultInterface();
-}
-
-#ifndef QT_NO_NETWORKPROXY
-void QWebPage::setNetworkProxy(const QNetworkProxy& proxy)
-{
- d->networkProxy = proxy;
-}
-
-QNetworkProxy QWebPage::networkProxy() const
-{
- return d->networkProxy;
-}
-#endif
-
-#else
-
/*!
Sets the QNetworkAccessManager \a manager responsible for serving network requests for this
QWebPage.
@@ -3038,8 +3136,6 @@ QNetworkAccessManager *QWebPage::networkAccessManager() const
return d->networkManager;
}
-#endif
-
/*!
Sets the QWebPluginFactory \a factory responsible for creating plugins embedded into this
QWebPage.
@@ -3072,6 +3168,8 @@ QWebPluginFactory *QWebPage::pluginFactory() const
"Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%"
+ On mobile platforms such as Symbian S60 and Maemo, "Mobile Safari" is used instead of "Safari".
+
In this string the following values are replaced at run-time:
\list
\o %Platform% and %Subplatform% are expanded to the windowing system and the operation system.
@@ -3279,8 +3377,8 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
// Language
QLocale locale;
- if (view())
- locale = view()->locale();
+ if (d->client)
+ locale = d->client->ownerWidget()->locale();
QString name = locale.name();
name[2] = QLatin1Char('-');
ua.append(name);
@@ -3294,20 +3392,20 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty()) {
ua.append(appName);
-#if QT_VERSION >= 0x040400
QString appVer = QCoreApplication::applicationVersion();
if (!appVer.isEmpty())
ua.append(QLatin1Char('/') + appVer);
-#endif
} else {
// Qt version
ua.append(QLatin1String("Qt/"));
ua.append(QLatin1String(qVersion()));
}
- ua.append(QString(QLatin1String(" Safari/%1"))
- .arg(qWebKitVersion()));
-
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
+ ua.append(QString(QLatin1String(" Mobile Safari/%1")).arg(qWebKitVersion()));
+#else
+ ua.append(QString(QLatin1String(" Safari/%1")).arg(qWebKitVersion()));
+#endif
return ua;
}
@@ -3460,7 +3558,11 @@ quint64 QWebPage::bytesReceived() const
/*!
\fn void QWebPage::unsupportedContent(QNetworkReply *reply)
- This signal is emitted when WebKit cannot handle a link the user navigated to.
+ This signal is emitted when WebKit cannot handle a link the user navigated to or a
+ web server's response includes a "Content-Disposition" header with the 'attachment'
+ directive. If "Content-Disposition" is present in \a reply, the web server is indicating
+ that the client should prompt the user to save the content regardless of content-type.
+ See RFC 2616 sections 19.5.1 for details about Content-Disposition.
At signal emission time the meta-data of the QNetworkReply \a reply is available.
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h
index 8c455b1490..24d0ed9cf4 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h
@@ -54,6 +54,7 @@ namespace WebCore {
class EditorClientQt;
class FrameLoaderClientQt;
class InspectorClientQt;
+ class InspectorFrontendClientQt;
class ResourceHandle;
class HitTestResult;
class QNetworkReplyHandler;
@@ -208,20 +209,8 @@ public:
QUndoStack *undoStack() const;
#endif
-#if QT_VERSION < 0x040400 && !defined(qdoc)
- void setNetworkInterface(QWebNetworkInterface *interface);
- QWebNetworkInterface *networkInterface() const;
-
- // #### why is this in the page itself?
-#ifndef QT_NO_NETWORKPROXY
- void setNetworkProxy(const QNetworkProxy& proxy);
- QNetworkProxy networkProxy() const;
-#endif
-
-#else
void setNetworkAccessManager(QNetworkAccessManager *manager);
QNetworkAccessManager *networkAccessManager() const;
-#endif
void setPluginFactory(QWebPluginFactory *factory);
QWebPluginFactory *pluginFactory() const;
@@ -334,10 +323,8 @@ Q_SIGNALS:
void statusBarVisibilityChangeRequested(bool visible);
void menuBarVisibilityChangeRequested(bool visible);
-#if QT_VERSION >= 0x040400
void unsupportedContent(QNetworkReply *reply);
void downloadRequested(const QNetworkRequest &request);
-#endif
void microFocusChanged();
void contentsChanged();
@@ -350,11 +337,7 @@ protected:
virtual QWebPage *createWindow(WebWindowType type);
virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
-#if QT_VERSION >= 0x040400
virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
-#else
- virtual bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
-#endif
virtual QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile);
virtual void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg);
virtual bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg);
@@ -373,12 +356,15 @@ private:
friend class QWebFrame;
friend class QWebPagePrivate;
friend class QWebView;
+ friend class QWebViewPrivate;
friend class QGraphicsWebView;
+ friend class QGraphicsWebViewPrivate;
friend class QWebInspector;
friend class WebCore::ChromeClientQt;
friend class WebCore::EditorClientQt;
friend class WebCore::FrameLoaderClientQt;
friend class WebCore::InspectorClientQt;
+ friend class WebCore::InspectorFrontendClientQt;
friend class WebCore::ResourceHandle;
friend class WebCore::QNetworkReplyHandler;
};
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h
index f0f842d099..0712d0cc39 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h
@@ -62,6 +62,10 @@ class QWebPagePrivate {
public:
QWebPagePrivate(QWebPage*);
~QWebPagePrivate();
+
+ static WebCore::Page* core(QWebPage*);
+ static QWebPagePrivate* priv(QWebPage*);
+
void createMainFrame();
#ifndef QT_NO_CONTEXTMENU
QMenu* createContextMenu(const WebCore::ContextMenu* webcoreMenu, const QList<WebCore::ContextMenuItem>* items, QBitArray* visitedWebActions);
@@ -114,6 +118,10 @@ public:
void handleSoftwareInputPanel(Qt::MouseButton);
bool handleScrolling(QKeyEvent*, WebCore::Frame*);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ void touchEvent(QTouchEvent*);
+#endif
+
void setInspector(QWebInspector*);
QWebInspector* getOrCreateInspector();
WebCore::InspectorController* inspectorController();
@@ -151,18 +159,8 @@ public:
bool clickCausedFocus;
-#if QT_VERSION < 0x040400
- bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type);
-
- QWebNetworkInterface *networkInterface;
-#ifndef QT_NO_NETWORKPROXY
- QNetworkProxy networkProxy;
-#endif
-
-#else
bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
QNetworkAccessManager *networkManager;
-#endif
bool forwardUnsupportedContent;
QWebPage::LinkDelegationPolicy linkPolicy;
@@ -186,6 +184,9 @@ public:
QWidget* inspectorFrontend;
QWebInspector* inspector;
bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
+ Qt::DropAction m_lastDropAction;
+
+ QString viewMode;
static bool drtRun;
};
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp
index 2a225c5765..6c26bd7ab4 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp
@@ -40,6 +40,11 @@ void QWEBKIT_EXPORT qt_drt_resetOriginAccessWhiteLists()
SecurityOrigin::resetOriginAccessWhiteLists();
}
+void QWEBKIT_EXPORT qt_drt_setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme)
+{
+ SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme);
+}
+
/*!
\class QWebSecurityOrigin
\since 4.5
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp
index 79ef16f761..c759445dc2 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp
@@ -26,6 +26,7 @@
#include "Cache.h"
#include "CrossOriginPreflightResultCache.h"
+#include "Database.h"
#include "FontCache.h"
#include "Page.h"
#include "PageCache.h"
@@ -73,6 +74,7 @@ public:
QString localStoragePath;
QString offlineWebApplicationCachePath;
qint64 offlineStorageDefaultQuota;
+ QUrl inspectorLocation;
void apply();
WebCore::Settings* settings;
@@ -90,6 +92,7 @@ static WebGraphicHash* graphics()
hash->insert(QWebSettings::MissingPluginGraphic, QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));
hash->insert(QWebSettings::DefaultFrameIconGraphic, QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));
hash->insert(QWebSettings::TextAreaSizeGripCornerGraphic, QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
+ hash->insert(QWebSettings::DeleteButtonGraphic, QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
}
return hash;
@@ -151,7 +154,19 @@ void QWebSettingsPrivate::apply()
value = attributes.value(QWebSettings::JavascriptEnabled,
global->attributes.value(QWebSettings::JavascriptEnabled));
settings->setJavaScriptEnabled(value);
+#if USE(ACCELERATED_COMPOSITING)
+ value = attributes.value(QWebSettings::AcceleratedCompositingEnabled,
+ global->attributes.value(QWebSettings::AcceleratedCompositingEnabled));
+ settings->setAcceleratedCompositingEnabled(value);
+#endif
+#if ENABLE(3D_CANVAS)
+ value = attributes.value(QWebSettings::WebGLEnabled,
+ global->attributes.value(QWebSettings::WebGLEnabled));
+
+ settings->setWebGLEnabled(value);
+#endif
+
value = attributes.value(QWebSettings::JavascriptCanOpenWindows,
global->attributes.value(QWebSettings::JavascriptCanOpenWindows));
settings->setJavaScriptCanOpenWindowsAutomatically(value);
@@ -168,6 +183,10 @@ void QWebSettingsPrivate::apply()
global->attributes.value(QWebSettings::PrivateBrowsingEnabled));
settings->setPrivateBrowsingEnabled(value);
+ value = attributes.value(QWebSettings::SpatialNavigationEnabled,
+ global->attributes.value(QWebSettings::SpatialNavigationEnabled));
+ settings->setSpatialNavigationEnabled(value);
+
value = attributes.value(QWebSettings::JavascriptCanAccessClipboard,
global->attributes.value(QWebSettings::JavascriptCanAccessClipboard));
settings->setDOMPasteAllowed(value);
@@ -176,6 +195,10 @@ void QWebSettingsPrivate::apply()
global->attributes.value(QWebSettings::DeveloperExtrasEnabled));
settings->setDeveloperExtrasEnabled(value);
+ value = attributes.value(QWebSettings::FrameFlatteningEnabled,
+ global->attributes.value(QWebSettings::FrameFlatteningEnabled));
+ settings->setFrameFlatteningEnabled(value);
+
QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation;
settings->setUserStyleSheetLocation(WebCore::KURL(location));
@@ -187,15 +210,17 @@ void QWebSettingsPrivate::apply()
value = attributes.value(QWebSettings::ZoomTextOnly,
global->attributes.value(QWebSettings::ZoomTextOnly));
- settings->setZoomsTextOnly(value);
+ settings->setZoomMode(value ? WebCore::ZoomTextOnly : WebCore::ZoomPage);
value = attributes.value(QWebSettings::PrintElementBackgrounds,
global->attributes.value(QWebSettings::PrintElementBackgrounds));
settings->setShouldPrintBackgrounds(value);
+#if ENABLE(DATABASE)
value = attributes.value(QWebSettings::OfflineStorageDatabaseEnabled,
global->attributes.value(QWebSettings::OfflineStorageDatabaseEnabled));
- settings->setDatabasesEnabled(value);
+ WebCore::Database::setIsAvailable(value);
+#endif
value = attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled,
global->attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled));
@@ -203,12 +228,26 @@ void QWebSettingsPrivate::apply()
value = attributes.value(QWebSettings::LocalStorageEnabled,
global->attributes.value(QWebSettings::LocalStorageEnabled));
-
settings->setLocalStorageEnabled(value);
value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls,
global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls));
settings->setAllowUniversalAccessFromFileURLs(value);
+
+ value = attributes.value(QWebSettings::LocalContentCanAccessFileUrls,
+ global->attributes.value(QWebSettings::LocalContentCanAccessFileUrls));
+ settings->setAllowFileAccessFromFileURLs(value);
+
+ value = attributes.value(QWebSettings::XSSAuditorEnabled,
+ global->attributes.value(QWebSettings::XSSAuditorEnabled));
+ settings->setXSSAuditorEnabled(value);
+
+#if ENABLE(TILED_BACKING_STORE)
+ value = attributes.value(QWebSettings::TiledBackingStoreEnabled,
+ global->attributes.value(QWebSettings::TiledBackingStoreEnabled));
+ settings->setTiledBackingStoreEnabled(value);
+#endif
+
settings->setUsesPageCache(WebCore::pageCache()->capacity());
} else {
QList<QWebSettingsPrivate*> settings = *::allSettings();
@@ -338,6 +377,13 @@ QWebSettings* QWebSettings::globalSettings()
Currently this enables the "Inspect" element in the context menu as
well as the use of QWebInspector which controls the WebKit WebInspector
for web site debugging.
+ \value SpatialNavigationEnabled Enables or disables the Spatial Navigation
+ feature, which consists in the ability to navigate between focusable
+ elements in a Web page, such as hyperlinks and form controls, by using
+ Left, Right, Up and Down arrow keys. For example, if an user presses the
+ Right key, heuristics determine whether there is an element he might be
+ trying to reach towards the right, and if there are multiple elements,
+ which element he probably wants.
\value LinksIncludedInFocusChain Specifies whether hyperlinks should be
included in the keyboard focus chain.
\value ZoomTextOnly Specifies whether the zoom factor on a frame applies to
@@ -353,6 +399,25 @@ QWebSettings* QWebSettings::globalSettings()
\value LocalStorageDatabaseEnabled \e{This enum value is deprecated.} Use
QWebSettings::LocalStorageEnabled instead.
\value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls.
+ \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are allowed to access other local urls.
+ \value XSSAuditorEnabled Specifies whether load requests should be monitored for cross-site scripting attempts.
+ \value AcceleratedCompositingEnabled This feature, when used in conjunction with
+ QGraphicsWebView, accelerates animations of web content. CSS animations of the transform and
+ opacity properties will be rendered by composing the cached content of the animated elements.
+ This feature is enabled by default
+ \value TiledBackingStoreEnabled This setting enables the tiled backing store feature
+ for a QGraphicsWebView. With the tiled backing store enabled, the web page contents in and around
+ the current visible area is speculatively cached to bitmap tiles. The tiles are automatically kept
+ in sync with the web page as it changes. Enabling tiling can significantly speed up painting heavy
+ operations like scrolling. Enabling the feature increases memory consumption. It does not work well
+ with contents using CSS fixed positioning (see also \l{QGraphicsWebView::}{resizesToContents} property).
+ \l{QGraphicsWebView::}{tiledBackingStoreFrozen} property allows application to temporarily freeze the contents of the backing store.
+ \value FrameFlatteningEnabled With this setting each subframe is expanded to its contents.
+ On touch devices, it is desired to not have any scrollable sub parts of the page
+ as it results in a confusing user experience, with scrolling sometimes scrolling sub parts
+ and at other times scrolling the page itself. For this reason iframes and framesets are
+ barely usable on touch devices. This will flatten all the frames to become one scrollable page.
+ Disabled by default.
*/
/*!
@@ -376,6 +441,7 @@ QWebSettings::QWebSettings()
d->attributes.insert(QWebSettings::AutoLoadImages, true);
d->attributes.insert(QWebSettings::DnsPrefetchEnabled, false);
d->attributes.insert(QWebSettings::JavascriptEnabled, true);
+ d->attributes.insert(QWebSettings::SpatialNavigationEnabled, false);
d->attributes.insert(QWebSettings::LinksIncludedInFocusChain, true);
d->attributes.insert(QWebSettings::ZoomTextOnly, false);
d->attributes.insert(QWebSettings::PrintElementBackgrounds, true);
@@ -383,6 +449,11 @@ QWebSettings::QWebSettings()
d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false);
d->attributes.insert(QWebSettings::LocalStorageEnabled, false);
d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false);
+ d->attributes.insert(QWebSettings::LocalContentCanAccessFileUrls, true);
+ d->attributes.insert(QWebSettings::AcceleratedCompositingEnabled, true);
+ d->attributes.insert(QWebSettings::WebGLEnabled, false);
+ d->attributes.insert(QWebSettings::TiledBackingStoreEnabled, false);
+ d->attributes.insert(QWebSettings::FrameFlatteningEnabled, false);
d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
d->defaultTextEncoding = QLatin1String("iso-8859-1");
}
@@ -451,7 +522,8 @@ void QWebSettings::resetFontSize(FontSize type)
The \a location must be either a path on the local filesystem, or a data URL
with UTF-8 and Base64 encoded data, such as:
- "data:text/css;charset=utf-8;base64,cCB7IGJhY2tncm91bmQtY29sb3I6IHJlZCB9Ow==;"
+ "data:text/css;charset=utf-8;base64,cCB7IGJhY2tncm91bmQtY29sb3I6IHJlZCB9Ow=="
+ NOTE: In case the base 64 data is not valid the style will not be applied.
\sa userStyleSheetUrl()
*/
@@ -884,6 +956,8 @@ QString QWebSettings::offlineWebApplicationCachePath()
void QWebSettings::setOfflineWebApplicationCacheQuota(qint64 maximumSize)
{
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ WebCore::cacheStorage().empty();
+ WebCore::cacheStorage().vacuumDatabaseFile();
WebCore::cacheStorage().setMaximumSize(maximumSize);
#endif
}
@@ -923,6 +997,31 @@ void QWebSettings::setLocalStoragePath(const QString& path)
}
/*!
+ \since 4.7
+
+ Specifies the \a location of a frontend to load with each web page when using Web Inspector.
+
+ \sa inspectorUrl()
+*/
+void QWebSettings::setInspectorUrl(const QUrl& location)
+{
+ d->inspectorLocation = location;
+ d->apply();
+}
+
+/*!
+ \since 4.7
+
+ Returns the location of the Web Inspector frontend.
+
+ \sa setInspectorUrl()
+*/
+QUrl QWebSettings::inspectorUrl() const
+{
+ return d->inspectorLocation;
+}
+
+/*!
\since 4.6
\relates QWebSettings
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h
index 50cf424397..caba0d5dd6 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h
@@ -67,13 +67,21 @@ public:
LocalStorageDatabaseEnabled = LocalStorageEnabled,
#endif
LocalContentCanAccessRemoteUrls,
- DnsPrefetchEnabled
+ DnsPrefetchEnabled,
+ XSSAuditorEnabled,
+ AcceleratedCompositingEnabled,
+ WebGLEnabled,
+ SpatialNavigationEnabled,
+ LocalContentCanAccessFileUrls,
+ TiledBackingStoreEnabled,
+ FrameFlatteningEnabled
};
enum WebGraphic {
MissingImageGraphic,
MissingPluginGraphic,
DefaultFrameIconGraphic,
- TextAreaSizeGripCornerGraphic
+ TextAreaSizeGripCornerGraphic,
+ DeleteButtonGraphic
};
enum FontSize {
MinimumFontSize,
@@ -129,6 +137,9 @@ public:
void setLocalStoragePath(const QString& path);
QString localStoragePath() const;
+ void setInspectorUrl(const QUrl &location);
+ QUrl inspectorUrl() const;
+
static void clearMemoryCaches();
static void enablePersistentStorage(const QString& path = QString());
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
index 79538ff8e1..4387f4ae52 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
@@ -22,10 +22,11 @@
#include "config.h"
#include "qwebview.h"
+#include "Page.h"
#include "QWebPageClient.h"
+#include "Settings.h"
#include "qwebframe.h"
#include "qwebpage_p.h"
-
#include "qbitmap.h"
#include "qevent.h"
#include "qpainter.h"
@@ -44,6 +45,7 @@ public:
}
void _q_pageDestroyed();
+ void unsetPageIfExists();
QWebView *view;
QWebPage *page;
@@ -59,96 +61,141 @@ void QWebViewPrivate::_q_pageDestroyed()
#ifdef Q_WS_MAEMO_5
#include "qabstractkineticscroller.h"
+#include "qapplication.h"
+
+// QCoreApplication::sendSpontaneousEvent() is private, hence this friend wrapper
+bool qt_sendSpontaneousEvent(QObject* receiver, QEvent* ev)
+{
+ return QCoreApplication::sendSpontaneousEvent(receiver, ev);
+}
-class QWebViewKineticScroller : public QAbstractKineticScroller {
+class QWebViewKineticScroller : public QObject, public QAbstractKineticScroller {
public:
- QWebViewKineticScroller() : QAbstractKineticScroller() {}
- // remember the frame where the button was pressed
+ QWebViewKineticScroller()
+ : QObject()
+ , QAbstractKineticScroller()
+ , m_view(0)
+ , m_ignoreEvents(false)
+ {
+ }
+
+ void setWidget(QWebView* widget)
+ {
+ if (m_view) {
+ m_view->removeEventFilter(this);
+ QWebFrame* frame = m_view->page()->mainFrame();
+ frame->setScrollBarPolicy(Qt::Vertical, m_oldVerticalScrollBarPolicy);
+ frame->setScrollBarPolicy(Qt::Horizontal, m_oldHorizontalScrollBarPolicy);
+ }
+
+ m_view = widget;
+ setParent(m_view);
+ if (m_view) {
+ QWebFrame* frame = m_view->page()->mainFrame();
+ m_oldHorizontalScrollBarPolicy = frame->scrollBarPolicy(Qt::Horizontal);
+ m_oldVerticalScrollBarPolicy = frame->scrollBarPolicy(Qt::Vertical);
+ frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
+ frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+ m_view->installEventFilter(this);
+ }
+ }
+
+protected:
bool eventFilter(QObject* o, QEvent* ev)
{
+ if (!o || m_view != o || m_ignoreEvents || !m_view->isEnabled())
+ return QObject::eventFilter(o, ev);
+
+ bool res = false;
+
switch (ev->type()) {
case QEvent::MouseButtonPress: {
+ // remember the frame where the button was pressed
QWebFrame* hitFrame = scrollingFrameAt(static_cast<QMouseEvent*>(ev)->pos());
if (hitFrame)
m_frame = hitFrame;
- break;
+ // fall through
}
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ res = handleMouseEvent(static_cast<QMouseEvent*>(ev));
+ break;
default:
break;
}
- return QAbstractKineticScroller::eventFilter(o, ev);
+ return res ? true : QObject::eventFilter(o, ev);
}
-protected:
- QWebFrame* currentFrame() const
+ void cancelLeftMouseButtonPress(const QPoint& /* globalPressPos */)
{
- if (!m_frame.isNull())
- return m_frame.data();
-
- QWebView* view = static_cast<QWebView*>(widget());
- QWebFrame* frame = view->page()->mainFrame();
- return frame;
+ QMouseEvent cmem(QEvent::MouseMove, QPoint(-INT_MAX, -INT_MAX), Qt::LeftButton, QApplication::mouseButtons() | Qt::LeftButton, QApplication::keyboardModifiers());
+ sendEvent(m_view, &cmem);
+ QMouseEvent cmer(QEvent::MouseButtonRelease, QPoint(-INT_MAX, -INT_MAX), Qt::LeftButton, QApplication::mouseButtons() & ~Qt::LeftButton, QApplication::keyboardModifiers());
+ sendEvent(m_view, &cmer);
}
- // Returns the innermost frame at the given position that can scroll.
- QWebFrame* scrollingFrameAt(const QPoint& pos) const
+ QWebFrame* currentFrame() const
{
- QWebView* view = static_cast<QWebView*>(widget());
- QWebFrame* mainFrame = view->page()->mainFrame();
- QWebFrame* hitFrame = mainFrame->hitTestContent(pos).frame();
- QSize range = hitFrame->contentsSize() - hitFrame->geometry().size();
+ if (m_frame)
+ return m_frame;
- while (hitFrame && range.width() <= 1 && range.height() <= 1)
- hitFrame = hitFrame->parentFrame();
+ if (m_view)
+ return m_view->page()->mainFrame();
- return hitFrame;
+ return 0;
}
- void attachToWidget()
+ // Returns the innermost frame at the given position that can scroll.
+ QWebFrame* scrollingFrameAt(const QPoint& pos) const
{
- QWebView* view = static_cast<QWebView*>(widget());
- QWebFrame* mainFrame = view->page()->mainFrame();
- m_oldHorizontalScrollBarPolicy = mainFrame->scrollBarPolicy(Qt::Horizontal);
- m_oldVerticalScrollBarPolicy = mainFrame->scrollBarPolicy(Qt::Vertical);
- mainFrame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
- mainFrame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
- view->installEventFilter(this);
- }
+ QWebFrame* hitFrame = 0;
+ if (m_view) {
+ QWebFrame* frame = m_view->page()->mainFrame();
+ hitFrame = frame->hitTestContent(pos).frame();
+ QSize range = hitFrame->contentsSize() - hitFrame->geometry().size();
- void removeFromWidget()
- {
- QWebView* view = static_cast<QWebView*>(widget());
- view->removeEventFilter(this);
- QWebFrame* mainFrame = view->page()->mainFrame();
- mainFrame->setScrollBarPolicy(Qt::Vertical, m_oldVerticalScrollBarPolicy);
- mainFrame->setScrollBarPolicy(Qt::Horizontal, m_oldHorizontalScrollBarPolicy);
+ while (hitFrame && range.width() <= 1 && range.height() <= 1)
+ hitFrame = hitFrame->parentFrame();
+
+ return hitFrame;
+ }
}
- QRect positionRange() const
+ QPoint maximumScrollPosition() const
{
- QRect r;
QWebFrame* frame = currentFrame();
- r.setSize(frame->contentsSize() - frame->geometry().size());
- return r;
+ QSize s = frame ? frame->contentsSize() - frame->geometry().size() : QSize(0, 0);
+ return QPoint(qMax(0, s.width()), qMax(0, s.height()));
}
- QPoint position() const
+ QPoint scrollPosition() const
{
QWebFrame* frame = currentFrame();
- return frame->scrollPosition();
+ return frame ? frame->scrollPosition() : QPoint();
}
QSize viewportSize() const
{
- return static_cast<QWebView*>(widget())->page()->viewportSize();
+ return m_view ? m_view->page()->viewportSize() : QSize();
}
- void setPosition(const QPoint& point, const QPoint& /* overShootDelta */)
+ void setScrollPosition(const QPoint& point, const QPoint& /* overShootDelta */)
{
QWebFrame* frame = currentFrame();
- frame->setScrollPosition(point);
+ if (frame)
+ frame->setScrollPosition(point);
}
+ void sendEvent(QWidget* w, QEvent* ev)
+ {
+ m_ignoreEvents = true;
+ qt_sendSpontaneousEvent(w, ev);
+ m_ignoreEvents = false;
+ }
+
+ QWebView* m_view;
+ bool m_ignoreEvents;
QPointer<QWebFrame> m_frame;
Qt::ScrollBarPolicy m_oldVerticalScrollBarPolicy;
Qt::ScrollBarPolicy m_oldHorizontalScrollBarPolicy;
@@ -253,9 +300,13 @@ QWebView::QWebView(QWidget *parent)
setAttribute(Qt::WA_InputMethodEnabled);
#endif
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ setAttribute(Qt::WA_AcceptTouchEvents);
+#endif
#if defined(Q_WS_MAEMO_5)
QAbstractKineticScroller* scroller = new QWebViewKineticScroller();
- scroller->setWidget(this);
+ static_cast<QWebViewKineticScroller*>(scroller)->setWidget(this);
+ setProperty("kineticScroller", QVariant::fromValue(scroller));
#endif
setAcceptDrops(true);
@@ -297,6 +348,29 @@ QWebPage *QWebView::page() const
return d->page;
}
+void QWebViewPrivate::unsetPageIfExists()
+{
+ if (!page)
+ return;
+
+ // if the page client is the special client constructed for
+ // delegating the responsibilities to a QWidget, we need
+ // to destroy it.
+
+ if (page->d->client && page->d->client->isQWidgetClient())
+ delete page->d->client;
+
+ page->d->client = 0;
+
+ // if the page was created by us, we own it and need to
+ // destroy it as well.
+
+ if (page->parent() == view)
+ delete page;
+ else
+ page->disconnect(view);
+}
+
/*!
Makes \a page the new web page of the web view.
@@ -310,14 +384,10 @@ void QWebView::setPage(QWebPage* page)
{
if (d->page == page)
return;
- if (d->page) {
- d->page->d->client = 0; // unset the page client
- if (d->page->parent() == this)
- delete d->page;
- else
- d->page->disconnect(this);
- }
+
+ d->unsetPageIfExists();
d->page = page;
+
if (d->page) {
d->page->setView(this);
d->page->setPalette(palette());
@@ -345,6 +415,9 @@ void QWebView::setPage(QWebPage* page)
this, SLOT(updateMicroFocus()));
connect(d->page, SIGNAL(destroyed()),
this, SLOT(_q_pageDestroyed()));
+#if USE(ACCELERATED_COMPOSITING)
+ d->page->d->page->settings()->setAcceleratedCompositingEnabled(false);
+#endif
}
setAttribute(Qt::WA_OpaquePaintEvent, d->page);
update();
@@ -374,19 +447,11 @@ void QWebView::load(const QUrl &url)
\sa url(), urlChanged()
*/
-#if QT_VERSION < 0x040400 && !defined(qdoc)
-void QWebView::load(const QWebNetworkRequest &request)
-#else
void QWebView::load(const QNetworkRequest &request,
QNetworkAccessManager::Operation operation,
const QByteArray &body)
-#endif
{
- page()->mainFrame()->load(request
-#if QT_VERSION >= 0x040400
- , operation, body
-#endif
- );
+ page()->mainFrame()->load(request, operation, body);
}
/*!
@@ -740,7 +805,6 @@ bool QWebView::event(QEvent *e)
if (e->type() == QEvent::ShortcutOverride) {
d->page->event(e);
#ifndef QT_NO_CURSOR
-#if QT_VERSION >= 0x040400
} else if (e->type() == QEvent::CursorChange) {
// An unsetCursor will set the cursor to Qt::ArrowCursor.
// Thus this cursor change might be a QWidget::unsetCursor()
@@ -753,6 +817,13 @@ bool QWebView::event(QEvent *e)
if (cursor().shape() == Qt::ArrowCursor)
d->page->d->client->resetCursor();
#endif
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ } else if (e->type() == QEvent::TouchBegin
+ || e->type() == QEvent::TouchEnd
+ || e->type() == QEvent::TouchUpdate) {
+ d->page->event(e);
+ if (e->isAccepted())
+ return true;
#endif
} else if (e->type() == QEvent::Leave)
d->page->event(e);
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
index 0f79c704ff..f681fbcd97 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
@@ -27,9 +27,7 @@
#include <QtGui/qicon.h>
#include <QtGui/qpainter.h>
#include <QtCore/qurl.h>
-#if QT_VERSION >= 0x040400
#include <QtNetwork/qnetworkaccessmanager.h>
-#endif
QT_BEGIN_NAMESPACE
class QNetworkRequest;
@@ -61,13 +59,9 @@ public:
void setPage(QWebPage* page);
void load(const QUrl& url);
-#if QT_VERSION < 0x040400 && !defined(qdoc)
- void load(const QWebNetworkRequest& request);
-#else
void load(const QNetworkRequest& request,
QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
const QByteArray &body = QByteArray());
-#endif
void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl());