diff options
author | Steve Block <steveblock@google.com> | 2010-04-27 16:31:00 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-11 14:42:12 +0100 |
commit | dcc8cf2e65d1aa555cce12431a16547e66b469ee (patch) | |
tree | 92a8d65cd5383bca9749f5327fb5e440563926e6 /WebKit/qt/Api | |
parent | ccac38a6b48843126402088a309597e682f40fe6 (diff) | |
download | external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2 |
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebKit/qt/Api')
-rw-r--r-- | WebKit/qt/Api/DerivedSources.pro | 5 | ||||
-rw-r--r-- | WebKit/qt/Api/qgraphicswebview.cpp | 282 | ||||
-rw-r--r-- | WebKit/qt/Api/qgraphicswebview.h | 7 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebelement.cpp | 20 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebelement.h | 11 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.cpp | 335 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.h | 4 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe_p.h | 6 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebinspector.cpp | 6 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebinspector.h | 1 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebkitglobal.h | 6 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.cpp | 238 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.h | 11 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage_p.h | 8 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsecurityorigin.cpp | 15 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.cpp | 101 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.h | 13 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebview.cpp | 39 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebview.h | 2 |
19 files changed, 626 insertions, 484 deletions
diff --git a/WebKit/qt/Api/DerivedSources.pro b/WebKit/qt/Api/DerivedSources.pro index a8f2684..389fb5f 100644 --- a/WebKit/qt/Api/DerivedSources.pro +++ b/WebKit/qt/Api/DerivedSources.pro @@ -32,8 +32,6 @@ regex = ".*\sclass\sQWEBKIT_EXPORT\s(\w+)\s(.*)" for(HEADER, WEBKIT_API_HEADERS) { # 1. Append to QtWebKit header that includes all other header files - - qtheader_module.depends += $$HEADER # 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} &&) @@ -53,6 +51,7 @@ for(HEADER, WEBKIT_API_HEADERS) { 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 @@ -97,7 +96,7 @@ qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}endif // QT_QTWEBKIT_M QMAKE_EXTRA_TARGETS += qtheader_module qtheader_pri.target = $${DESTDIR}/classheaders.pri -qtheader_pri.depends = $${WEBKIT_API_HEADERS} $${_PRO_FILE_} +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 diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index 9720e0c..c865c4d 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -26,7 +26,10 @@ #include "qwebpage.h" #include "qwebpage_p.h" #include "QWebPageClient.h" -#include <FrameView.h> +#include "FrameView.h" +#include "GraphicsContext.h" +#include "IntRect.h" +#include "TiledBackingStore.h" #include <QtCore/qmetaobject.h> #include <QtCore/qsharedpointer.h> #include <QtCore/qtimer.h> @@ -35,14 +38,14 @@ #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> -#if USE(ACCELERATED_COMPOSITING) - // 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 { @@ -52,7 +55,9 @@ class QGraphicsWebViewOverlay : public QGraphicsItem { , q(view) { setPos(0, 0); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); +#endif setCacheMode(QGraphicsItem::DeviceCoordinateCache); } @@ -70,8 +75,6 @@ class QGraphicsWebViewOverlay : public QGraphicsItem { QGraphicsWebView* q; }; -#endif - class QGraphicsWebViewPrivate : public QWebPageClient { public: QGraphicsWebViewPrivate(QGraphicsWebView* parent) @@ -92,6 +95,7 @@ public: } virtual ~QGraphicsWebViewPrivate(); + virtual void scroll(int dx, int dy, const QRect&); virtual void update(const QRect& dirtyRect); virtual void setInputMethodEnabled(bool enable); @@ -108,6 +112,7 @@ public: virtual QPalette palette() const; virtual int screenNumber() const; virtual QWidget* ownerWidget() const; + virtual QRect geometryRelativeToOwnerWidget() const; virtual QObject* pluginParent() const; @@ -117,34 +122,49 @@ public: virtual void setRootGraphicsLayer(QGraphicsItem* layer); virtual void markForSync(bool scheduleSync); void updateCompositingScrollPosition(); + + // QGraphicsWebView can render composited layers + virtual bool allowsAcceleratedCompositing() const { return true; } #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; -#if USE(ACCELERATED_COMPOSITING) - QGraphicsItem* rootGraphicsLayer; - // 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; - - // we need to put the root graphics layer behind the overlay (which contains the scrollbar) - enum { RootGraphicsLayerZValue, OverlayZValue }; #endif }; @@ -160,6 +180,26 @@ QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate() #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) { @@ -175,15 +215,9 @@ void QGraphicsWebViewPrivate::setRootGraphicsLayer(QGraphicsItem* layer) layer->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); layer->setParentItem(q); layer->setZValue(RootGraphicsLayerZValue); - if (!overlay) { - overlay = QSharedPointer<QGraphicsWebViewOverlay>(new QGraphicsWebViewOverlay(q)); - overlay->setZValue(OverlayZValue); - } updateCompositingScrollPosition(); - } else { - // we don't have compositing layers, we can render the scrollbars and content in one go - overlay.clear(); } + createOrDeleteOverlay(); } void QGraphicsWebViewPrivate::markForSync(bool scheduleSync) @@ -200,7 +234,6 @@ void QGraphicsWebViewPrivate::updateCompositingScrollPosition() rootGraphicsLayer->setPos(-scrollPosition); } } - #endif void QGraphicsWebViewPrivate::syncLayers() @@ -222,9 +255,30 @@ void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) emit q->loadFinished(success); } +void QGraphicsWebViewPrivate::_q_updateMicroFocus() +{ +#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) + // Ideally, this should be handled by a common call to an updateMicroFocus function + // in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578. + QList<QGraphicsView*> views = q->scene()->views(); + for (int c = 0; c < views.size(); ++c) { + QInputContext* ic = views.at(c)->inputContext(); + if (ic) + ic->update(); + } +#endif +} + +void QGraphicsWebViewPrivate::_q_pageDestroyed() +{ + page = 0; + q->setPage(0); +} + void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) { q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll)); + #if USE(ACCELERATED_COMPOSITING) updateCompositingScrollPosition(); #endif @@ -233,9 +287,11 @@ void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) { q->update(QRectF(dirtyRect)); -#if USE(ACCELERATED_COMPOSITING) + + createOrDeleteOverlay(); if (overlay) overlay->update(QRectF(dirtyRect)); +#if USE(ACCELERATED_COMPOSITING) syncLayers(); #endif } @@ -286,10 +342,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; @@ -297,8 +355,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 @@ -340,6 +414,42 @@ void QGraphicsWebViewPrivate::_q_contentsSizeChanged(const QSize& size) 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) { +#ifndef QT_NO_DEBUG_STREAM + qDebug() << "QGraphicsWebView is in more than one graphics views, unable to compute the visible rect"; +#endif + 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. @@ -433,6 +543,9 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) #endif setFocusPolicy(Qt::StrongFocus); setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); +#if ENABLE(TILED_BACKING_STORE) + QObject::connect(this, SIGNAL(scaleChanged()), this, SLOT(_q_scaleChanged())); +#endif } /*! @@ -482,6 +595,21 @@ QWebPage* QGraphicsWebView::page() const */ void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*) { +#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 @@ -589,6 +717,29 @@ bool QGraphicsWebView::event(QEvent* event) 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. @@ -603,26 +754,20 @@ 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; -#if USE(ACCELERATED_COMPOSITING) + + d->page->d->client = d; // set the page client + if (d->overlay) d->overlay->prepareGeometryChange(); -#endif - d->page->d->client = d; // set the page client QSize size = geometry().size().toSize(); page->setViewportSize(size); - + if (d->resizesToContents) d->updateResizesToContentsForPage(); @@ -644,6 +789,10 @@ void QGraphicsWebView::setPage(QWebPage* page) this, SIGNAL(statusBarMessage(QString))); connect(d->page, SIGNAL(linkClicked(QUrl)), this, SIGNAL(linkClicked(QUrl))); + connect(d->page, SIGNAL(microFocusChanged()), + this, SLOT(_q_updateMicroFocus())); + connect(d->page, SIGNAL(destroyed()), + this, SLOT(_q_pageDestroyed())); } /*! @@ -724,11 +873,8 @@ qreal QGraphicsWebView::zoomFactor() const */ void QGraphicsWebView::updateGeometry() { - -#if USE(ACCELERATED_COMPOSITING) if (d->overlay) d->overlay->prepareGeometryChange(); -#endif QGraphicsWidget::updateGeometry(); @@ -745,10 +891,8 @@ void QGraphicsWebView::setGeometry(const QRectF& rect) { QGraphicsWidget::setGeometry(rect); -#if USE(ACCELERATED_COMPOSITING) if (d->overlay) d->overlay->prepareGeometryChange(); -#endif if (!d->page) return; @@ -920,7 +1064,12 @@ QWebSettings* QGraphicsWebView::settings() const */ QAction *QGraphicsWebView::pageAction(QWebPage::WebAction action) const { +#ifdef QT_NO_ACTION + Q_UNUSED(action) + return 0; +#else return page()->action(action); +#endif } /*! @@ -964,12 +1113,13 @@ bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags op 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. + 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 + \sa QWebPage::setPreferredContentsSize() */ void QGraphicsWebView::setResizesToContents(bool enabled) { @@ -985,6 +1135,48 @@ 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) diff --git a/WebKit/qt/Api/qgraphicswebview.h b/WebKit/qt/Api/qgraphicswebview.h index 14de9d5..88729d3 100644 --- a/WebKit/qt/Api/qgraphicswebview.h +++ b/WebKit/qt/Api/qgraphicswebview.h @@ -46,6 +46,7 @@ class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget { 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); @@ -82,6 +83,9 @@ public: bool resizesToContents() const; void setResizesToContents(bool enabled); + + bool isTiledBackingStoreFrozen() const; + void setTiledBackingStoreFrozen(bool frozen); virtual void setGeometry(const QRectF& rect); virtual void updateGeometry(); @@ -138,10 +142,13 @@ protected: 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/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp index 9d4d0d0..8af7203 100644 --- a/WebKit/qt/Api/qwebelement.cpp +++ b/WebKit/qt/Api/qwebelement.cpp @@ -26,7 +26,6 @@ #include "CSSRule.h" #include "CSSRuleList.h" #include "CSSStyleRule.h" -#include "CString.h" #include "Document.h" #include "DocumentFragment.h" #include "FrameView.h" @@ -45,6 +44,7 @@ #include "runtime_root.h" #include <parser/SourceCode.h> #include <wtf/Vector.h> +#include <wtf/text/CString.h> #include <QPainter> @@ -864,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/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h index 156d24b..c488d12 100644 --- a/WebKit/qt/Api/qwebelement.h +++ b/WebKit/qt/Api/qwebelement.h @@ -20,11 +20,11 @@ #ifndef QWEBELEMENT_H #define QWEBELEMENT_H -#include <QString> -#include <QStringList> -#include <QRect> -#include <QVariant> -#include <QExplicitlySharedDataPointer> +#include <QtCore/qstring.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qrect.h> +#include <QtCore/qvariant.h> +#include <QtCore/qshareddata.h> #include "qwebkitglobal.h" namespace WebCore { @@ -154,6 +154,7 @@ private: static QWebElement enclosingElement(WebCore::Node*); + friend class DumpRenderTreeSupportQt; friend class QWebFrame; friend class QWebElementCollection; friend class QWebHitTestResult; diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 15b5c00..e6ee00f 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -58,6 +58,7 @@ #include "SelectionController.h" #include "SubstituteData.h" #include "SVGSMILElement.h" +#include "TiledBackingStore.h" #include "htmlediting.h" #include "markup.h" #include "qt_instance.h" @@ -87,182 +88,80 @@ QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT int qt_defaultDpi(); QT_END_NAMESPACE -bool QWEBKIT_EXPORT qt_drt_hasDocumentElement(QWebFrame* qframe) +static bool webframe_scrollOverflow(WebCore::Frame* frame, int dx, int dy, const QPoint& pos) { - return QWebFramePrivate::core(qframe)->document()->documentElement(); -} - -void QWEBKIT_EXPORT qt_drt_setJavaScriptProfilingEnabled(QWebFrame* qframe, bool enabled) -{ -#if ENABLE(JAVASCRIPT_DEBUGGER) - Frame* frame = QWebFramePrivate::core(qframe); - InspectorController* controller = frame->page()->inspectorController(); - if (!controller) - return; - if (enabled) - controller->enableProfiler(); - else - controller->disableProfiler(); -#endif -} - -// Pause a given CSS animation or transition on the target node at a specific time. -// If the animation or transition is already paused, it will update its pause time. -// This method is only intended to be used for testing the CSS animation and transition system. -bool QWEBKIT_EXPORT qt_drt_pauseAnimation(QWebFrame *qframe, const QString &animationName, double time, const QString &elementId) -{ - Frame* frame = QWebFramePrivate::core(qframe); - if (!frame) - return false; - - AnimationController* controller = frame->animation(); - if (!controller) + if (!frame || !frame->document() || !frame->view() || !frame->eventHandler()) return false; - Document* doc = frame->document(); - Q_ASSERT(doc); - - Node* coreNode = doc->getElementById(elementId); - if (!coreNode || !coreNode->renderer()) - return false; - - return controller->pauseAnimationAtTime(coreNode->renderer(), animationName, time); -} - -bool QWEBKIT_EXPORT qt_drt_pauseTransitionOfProperty(QWebFrame *qframe, const QString &propertyName, double time, const QString &elementId) -{ - Frame* frame = QWebFramePrivate::core(qframe); - if (!frame) - return false; - - AnimationController* controller = frame->animation(); - if (!controller) - return false; - - Document* doc = frame->document(); - Q_ASSERT(doc); - - Node* coreNode = doc->getElementById(elementId); - if (!coreNode || !coreNode->renderer()) - return false; - - 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()) + QPoint contentsPos = frame->view()->windowToContents(pos); + Node* node = frame->document()->elementFromPoint(contentsPos.x(), contentsPos.y()); + if (!node) return false; - Node* coreNode = doc->getElementById(animationId); - if (!coreNode || !SVGSMILElement::isSMILElement(coreNode)) + RenderObject* renderer = node->renderer(); + if (!renderer) 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) -{ - Frame* frame = QWebFramePrivate::core(qframe); - if (!frame) + if (renderer->isListBox()) return false; - AnimationController* controller = frame->animation(); - if (!controller) + RenderLayer* renderLayer = renderer->enclosingLayer(); + if (!renderLayer) return false; - return controller->numberOfActiveAnimations(); -} - -void QWEBKIT_EXPORT qt_drt_clearFrameName(QWebFrame* qFrame) -{ - Frame* frame = QWebFramePrivate::core(qFrame); - frame->tree()->clearName(); -} + bool scrolledHorizontal = false; + bool scrolledVertical = false; -int QWEBKIT_EXPORT qt_drt_javaScriptObjectsCount() -{ - return JSDOMWindowBase::commonJSGlobalData()->heap.globalObjectCount(); -} + if (dx > 0) + scrolledHorizontal = renderLayer->scroll(ScrollRight, ScrollByPixel, dx); + else if (dx < 0) + scrolledHorizontal = renderLayer->scroll(ScrollLeft, ScrollByPixel, qAbs(dx)); -void QWEBKIT_EXPORT qt_drt_garbageCollector_collect() -{ - gcController().garbageCollectNow(); -} + if (dy > 0) + scrolledVertical = renderLayer->scroll(ScrollDown, ScrollByPixel, dy); + else if (dy < 0) + scrolledVertical = renderLayer->scroll(ScrollUp, ScrollByPixel, qAbs(dy)); -void QWEBKIT_EXPORT qt_drt_garbageCollector_collectOnAlternateThread(bool waitUntilDone) -{ - gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); + return (scrolledHorizontal || scrolledVertical); } -// Returns the value of counter in the element specified by \a id. -QString QWEBKIT_EXPORT qt_drt_counterValueForElementById(QWebFrame* qFrame, const QString& id) -{ - Frame* frame = QWebFramePrivate::core(qFrame); - if (Document* document = frame->document()) { - Element* element = document->getElementById(id); - return WebCore::counterValueForElement(element); - } - return QString(); -} -int QWEBKIT_EXPORT qt_drt_pageNumberForElementById(QWebFrame* qFrame, const QString& id, float width, float height) +/*! + \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) - return -1; + if (!qFrame) + return; - Element* element = frame->document()->getElementById(AtomicString(id)); - if (!element) - return -1; + if (webframe_scrollOverflow(QWebFramePrivate::core(qFrame), dx, dy, pos)) + return; - return PrintContext::pageNumberForElement(element, FloatSize(width, height)); -} + bool scrollHorizontal = false; + bool scrollVertical = false; -int QWEBKIT_EXPORT qt_drt_numberOfPages(QWebFrame* qFrame, float width, float height) -{ - Frame* frame = QWebFramePrivate::core(qFrame); - if (!frame) - return -1; + do { + if (dx > 0) // scroll right + scrollHorizontal = qFrame->scrollBarValue(Qt::Horizontal) < qFrame->scrollBarMaximum(Qt::Horizontal); + else if (dx < 0) // scroll left + scrollHorizontal = qFrame->scrollBarValue(Qt::Horizontal) > qFrame->scrollBarMinimum(Qt::Horizontal); - return PrintContext::numberOfPages(frame, FloatSize(width, height)); -} + if (dy > 0) // scroll down + scrollVertical = qFrame->scrollBarValue(Qt::Vertical) < qFrame->scrollBarMaximum(Qt::Vertical); + else if (dy < 0) //scroll up + scrollVertical = qFrame->scrollBarValue(Qt::Vertical) > qFrame->scrollBarMinimum(Qt::Vertical); -// Suspend active DOM objects in this frame. -void QWEBKIT_EXPORT qt_suspendActiveDOMObjects(QWebFrame* qFrame) -{ - Frame* frame = QWebFramePrivate::core(qFrame); - if (frame->document()) - frame->document()->suspendActiveDOMObjects(); -} - -// Resume active DOM objects in this frame. -void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* qFrame) -{ - Frame* frame = QWebFramePrivate::core(qFrame); - if (frame->document()) - frame->document()->resumeActiveDOMObjects(); -} + if (scrollHorizontal || scrollVertical) { + qFrame->scroll(dx, dy); + return; + } -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(); + qFrame = qFrame->parentFrame(); + } while (qFrame); } QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame, @@ -327,8 +226,11 @@ WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const return frame->view()->verticalScrollbar(); } -void QWebFramePrivate::renderContentsLayerAbsoluteCoords(GraphicsContext* context, 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; @@ -339,21 +241,25 @@ void QWebFramePrivate::renderContentsLayerAbsoluteCoords(GraphicsContext* contex QPainter* painter = context->platformContext(); WebCore::FrameView* view = frame->view(); - view->layoutIfNeededRecursive(); + + 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(); - painter->setClipRect(clipRect, Qt::IntersectClip); + + QRect rect = clipRect.translated(scrollX, scrollY); + painter->setClipRect(rect, Qt::IntersectClip); - context->save(); - view->paintContents(context, clipRect); - context->restore(); + frame->tiledBackingStore()->paint(context, rect); painter->restore(); } } +#endif void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame::RenderLayer layer, const QRegion& clip) { @@ -421,45 +327,6 @@ void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame: } } -bool QWebFramePrivate::scrollOverflow(int dx, int dy) -{ - if (!frame || !frame->document() || !frame->eventHandler()) - return false; - - Node* node = frame->document()->focusedNode(); - if (!node) - node = frame->document()->elementFromPoint(frame->eventHandler()->currentMousePosition().x(), - frame->eventHandler()->currentMousePosition().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 @@ -731,8 +598,8 @@ static inline QUrl ensureAbsoluteUrl(const QUrl &url) void QWebFrame::setUrl(const QUrl &url) { - d->frame->loader()->begin(ensureAbsoluteUrl(url)); - d->frame->loader()->end(); + d->frame->loader()->writer()->begin(ensureAbsoluteUrl(url)); + d->frame->loader()->writer()->end(); load(ensureAbsoluteUrl(url)); } @@ -807,6 +674,8 @@ QString QWebFrame::frameName() const /*! The web page that contains this frame. + + \sa pageChanged() */ QWebPage *QWebFrame::page() const { @@ -831,7 +700,7 @@ void QWebFrame::load(const QUrl &url) \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() */ @@ -990,13 +859,13 @@ void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPol if (orientation == Qt::Horizontal) { d->horizontalScrollBarPolicy = policy; if (d->frame->view()) { - d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy, policy != Qt::ScrollBarAsNeeded /* lock */); d->frame->view()->updateCanHaveScrollbars(); } } else { d->verticalScrollBarPolicy = policy; if (d->frame->view()) { - d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy, policy != Qt::ScrollBarAsNeeded /* lock */); d->frame->view()->updateCanHaveScrollbars(); } } @@ -1099,55 +968,6 @@ void QWebFrame::scroll(int dx, int dy) } /*! - \since 4.7 - 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 followed by this frame. If this - frame doesn't scroll, attempts to scroll the parent - - \sa QWebFrame::scroll -*/ -bool QWebFrame::scrollRecursively(int dx, int dy) -{ - bool scrolledHorizontal = false; - bool scrolledVertical = false; - bool scrolledOverflow = d->scrollOverflow(dx, dy); - - if (!scrolledOverflow) { - Frame* frame = d->frame; - if (!frame || !frame->view()) - return false; - - do { - 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 true; - } - frame = frame->tree()->parent(); - } while (frame && frame->view()); - } - return (scrolledHorizontal || scrolledVertical || scrolledOverflow); -} - -bool QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy) -{ - return qFrame->scrollRecursively(dx, dy); -} - -/*! \property QWebFrame::scrollPosition \since 4.5 \brief the position the frame is currently scrolled to. @@ -1245,7 +1065,7 @@ void QWebFrame::render(QPainter* painter) */ void QWebFrame::setTextSizeMultiplier(qreal factor) { - d->frame->setZoomFactor(factor, /*isTextOnly*/true); + d->frame->setZoomFactor(factor, ZoomTextOnly); } /*! @@ -1264,7 +1084,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 @@ -1621,6 +1441,15 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame) */ /*! + \fn void QWebFrame::pageChanged() + \since 4.7 + + This signal is emitted when this frame has been moved to a different QWebPage. + + \sa page() +*/ + +/*! \class QWebHitTestResult \since 4.4 \brief The QWebHitTestResult class provides information about the web diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h index 68594fd..ecd31de 100644 --- a/WebKit/qt/Api/qwebframe.h +++ b/WebKit/qt/Api/qwebframe.h @@ -50,6 +50,7 @@ class QWebSecurityOrigin; class QWebElement; class QWebElementCollection; +class DumpRenderTreeSupportQt; namespace WebCore { class WidgetPrivate; class FrameLoaderClientQt; @@ -156,7 +157,6 @@ public: QRect scrollBarGeometry(Qt::Orientation orientation) const; void scroll(int, int); - bool scrollRecursively(int, int); QPoint scrollPosition() const; void setScrollPosition(const QPoint &pos); @@ -222,9 +222,11 @@ Q_SIGNALS: void pageChanged(); private: + friend class QGraphicsWebView; friend class QWebPage; friend class QWebPagePrivate; friend class QWebFramePrivate; + friend class DumpRenderTreeSupportQt; friend class WebCore::WidgetPrivate; friend class WebCore::FrameLoaderClientQt; friend class WebCore::ChromeClientQt; diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index 7d79474..fcc37e7 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -84,9 +84,9 @@ public: static QWebFrame* kit(WebCore::Frame*); void renderRelativeCoords(WebCore::GraphicsContext*, QWebFrame::RenderLayer, const QRegion& clip); - void renderContentsLayerAbsoluteCoords(WebCore::GraphicsContext*, const QRegion& clip); - - bool scrollOverflow(int dx, int dy); +#if ENABLE(TILED_BACKING_STORE) + void renderFromTiledBackingStore(WebCore::GraphicsContext*, const QRegion& clip); +#endif QWebFrame *q; Qt::ScrollBarPolicy horizontalScrollBarPolicy; diff --git a/WebKit/qt/Api/qwebinspector.cpp b/WebKit/qt/Api/qwebinspector.cpp index c3ef530..c0e5277 100644 --- a/WebKit/qt/Api/qwebinspector.cpp +++ b/WebKit/qt/Api/qwebinspector.cpp @@ -161,6 +161,10 @@ void QWebInspector::showEvent(QShowEvent* event) /*! \reimp */ void QWebInspector::hideEvent(QHideEvent* event) { +#if ENABLE(INSPECTOR) + if (d->page) + d->page->d->inspectorController()->close(); +#endif } /*! \reimp */ @@ -168,7 +172,7 @@ void QWebInspector::closeEvent(QCloseEvent* event) { #if ENABLE(INSPECTOR) if (d->page) - d->page->d->inspectorController()->setWindowVisible(false); + d->page->d->inspectorController()->close(); #endif } diff --git a/WebKit/qt/Api/qwebinspector.h b/WebKit/qt/Api/qwebinspector.h index 6cda479..f192e92 100644 --- a/WebKit/qt/Api/qwebinspector.h +++ b/WebKit/qt/Api/qwebinspector.h @@ -52,5 +52,6 @@ private: friend class QWebPage; friend class QWebPagePrivate; friend class WebCore::InspectorClientQt; + friend class WebCore::InspectorFrontendClientQt; }; #endif diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h index 9e8979f..665bf1b 100644 --- a/WebKit/qt/Api/qwebkitglobal.h +++ b/WebKit/qt/Api/qwebkitglobal.h @@ -22,6 +22,12 @@ #include <QtCore/qglobal.h> +#define QTWEBKIT_VERSION_STR "2.0.0" +// QTWEBKIT_VERSION is (major << 16) + (minor << 8) + patch. Similar to Qt. +#define QTWEBKIT_VERSION 0x020000 +// Use: #if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 0, 0)). Similar to Qt. +#define QTWEBKIT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) + #if defined(QT_MAKEDLL) /* create a Qt DLL library */ # if defined(BUILD_WEBKIT) # define QWEBKIT_EXPORT Q_DECL_EXPORT diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 2a8aced..0e11c15 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -80,6 +80,7 @@ #include "Cache.h" #include "runtime/InitializeThreading.h" #include "PageGroup.h" +#include "NotificationPresenterClientQt.h" #include "QWebPageClient.h" #include "WorkerThread.h" @@ -119,81 +120,16 @@ using namespace WebCore; -void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories() +void QWEBKIT_EXPORT qt_wrt_setViewMode(QWebPage* page, const QString& mode) { - PluginDatabase* db = PluginDatabase::installedPlugins(/* populate */ false); - - Vector<String> paths; - String qtPath(qgetenv("QTWEBKIT_PLUGIN_PATH").data()); - qtPath.split(UChar(':'), /* allowEmptyEntries */ false, paths); - - db->setPluginDirectories(paths); - db->refresh(); -} - -int QWEBKIT_EXPORT qt_drt_workerThreadCount() -{ -#if ENABLE(WORKERS) - return WebCore::WorkerThread::workerThreadCount(); -#else - return 0; -#endif + QWebPagePrivate::priv(page)->viewMode = mode; + WebCore::Frame* frame = QWebFramePrivate::core(page->mainFrame()); + WebCore::FrameView* view = frame->view(); + frame->document()->updateStyleSelector(); + view->forceLayout(); } bool QWebPagePrivate::drtRun = false; -void QWEBKIT_EXPORT qt_drt_run(bool b) -{ - QWebPagePrivate::drtRun = b; -} - -void QWEBKIT_EXPORT qt_drt_setFrameSetFlatteningEnabled(QWebPage* page, bool enabled) -{ - QWebPagePrivate::core(page)->settings()->setFrameSetFlatteningEnabled(enabled); -} - -void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName) -{ - page->handle()->page->setGroupName(groupName); -} - -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 class QWebPageWidgetClient : public QWebPageClient { public: @@ -203,6 +139,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); @@ -219,6 +157,7 @@ public: virtual QPalette palette() const; virtual int screenNumber() const; virtual QWidget* ownerWidget() const; + virtual QRect geometryRelativeToOwnerWidget() const; virtual QObject* pluginParent() const; @@ -276,10 +215,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; } @@ -288,6 +225,11 @@ QWidget* QWebPageWidgetClient::ownerWidget() const return view; } +QRect QWebPageWidgetClient::geometryRelativeToOwnerWidget() const +{ + return view->geometry(); +} + QObject* QWebPageWidgetClient::pluginParent() const { return view; @@ -464,11 +406,17 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) #ifndef QT_NO_CONTEXTMENU currentContextMenu = 0; #endif + smartInsertDeleteEnabled = false; + selectTrailingWhitespaceEnabled = false; history.d = new QWebHistoryPrivate(page->backForwardList()); memset(actions, 0, sizeof(actions)); PageGroup::setShouldTrackVisitedLinks(true); + +#if ENABLE(NOTIFICATIONS) + notificationPresenterClient = new NotificationPresenterClientQt(); +#endif } QWebPagePrivate::~QWebPagePrivate() @@ -481,6 +429,10 @@ QWebPagePrivate::~QWebPagePrivate() #endif delete settings; delete page; + +#if ENABLE(NOTIFICATIONS) + delete notificationPresenterClient; +#endif } WebCore::Page* QWebPagePrivate::core(QWebPage* page) @@ -488,6 +440,11 @@ WebCore::Page* QWebPagePrivate::core(QWebPage* page) return page->d->page; } +QWebPagePrivate* QWebPagePrivate::priv(QWebPage* page) +{ + return page->d; +} + bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) { if (insideOpenCall @@ -542,7 +499,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()) { @@ -591,6 +551,7 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen } #endif // QT_NO_CONTEXTMENU +#ifndef QT_NO_ACTION void QWebPagePrivate::_q_webActionTriggered(bool checked) { QAction *a = qobject_cast<QAction *>(q->sender()); @@ -599,6 +560,7 @@ void QWebPagePrivate::_q_webActionTriggered(bool checked) QWebPage::WebAction action = static_cast<QWebPage::WebAction>(a->data().toInt()); q->triggerAction(action, checked); } +#endif // QT_NO_ACTION void QWebPagePrivate::_q_cleanupLeakMessages() { @@ -610,6 +572,9 @@ void QWebPagePrivate::_q_cleanupLeakMessages() void QWebPagePrivate::updateAction(QWebPage::WebAction action) { +#ifdef QT_NO_ACTION + Q_UNUSED(action) +#else QAction *a = actions[action]; if (!a || !mainFrame) return; @@ -669,6 +634,7 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action) if (a->isCheckable()) a->setChecked(checked); +#endif // QT_NO_ACTION } void QWebPagePrivate::updateNavigationActions() @@ -769,6 +735,11 @@ void QWebPagePrivate::mousePressEvent(QGraphicsSceneMouseEvent* ev) if (!frame->view()) return; + RefPtr<WebCore::Node> oldNode; + Frame* focusedFrame = page->focusController()->focusedFrame(); + if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0) + oldNode = focusedDocument->focusedNode(); + if (tripleClickTimer.isActive() && (ev->pos().toPoint() - tripleClick).manhattanLength() < QApplication::startDragDistance()) { @@ -782,6 +753,14 @@ void QWebPagePrivate::mousePressEvent(QGraphicsSceneMouseEvent* ev) if (mev.button() != NoButton) accepted = frame->eventHandler()->handleMousePressEvent(mev); ev->setAccepted(accepted); + + RefPtr<WebCore::Node> newNode; + focusedFrame = page->focusController()->focusedFrame(); + if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0) + newNode = focusedDocument->focusedNode(); + + if (newNode && oldNode != newNode) + clickCausedFocus = true; } void QWebPagePrivate::mousePressEvent(QMouseEvent *ev) @@ -791,9 +770,9 @@ void QWebPagePrivate::mousePressEvent(QMouseEvent *ev) return; RefPtr<WebCore::Node> oldNode; - if (page->focusController()->focusedFrame() - && page->focusController()->focusedFrame()->document()) - oldNode = page->focusController()->focusedFrame()->document()->focusedNode(); + Frame* focusedFrame = page->focusController()->focusedFrame(); + if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0) + oldNode = focusedDocument->focusedNode(); if (tripleClickTimer.isActive() && (ev->pos() - tripleClick).manhattanLength() @@ -810,9 +789,9 @@ void QWebPagePrivate::mousePressEvent(QMouseEvent *ev) ev->setAccepted(accepted); RefPtr<WebCore::Node> newNode; - if (page->focusController()->focusedFrame() - && page->focusController()->focusedFrame()->document()) - newNode = page->focusController()->focusedFrame()->document()->focusedNode(); + focusedFrame = page->focusController()->focusedFrame(); + if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0) + newNode = focusedDocument->focusedNode(); if (newNode && oldNode != newNode) clickCausedFocus = true; @@ -1050,10 +1029,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 } }; @@ -1078,8 +1055,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()) { @@ -1294,7 +1271,7 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) case QInputMethodEvent::TextFormat: { QTextCharFormat textCharFormat = a.value.value<QTextFormat>().toCharFormat(); QColor qcolor = textCharFormat.underlineColor(); - underlines.append(CompositionUnderline(a.start, a.length, Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())), false)); + underlines.append(CompositionUnderline(qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)), Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())), false)); break; } case QInputMethodEvent::Cursor: { @@ -1311,8 +1288,8 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) #if QT_VERSION >= 0x040600 case QInputMethodEvent::Selection: { if (renderTextControl) { - renderTextControl->setSelectionStart(a.start); - renderTextControl->setSelectionEnd(a.start + a.length); + renderTextControl->setSelectionStart(qMin(a.start, (a.start + a.length))); + renderTextControl->setSelectionEnd(qMax(a.start, (a.start + a.length))); } break; } @@ -1777,7 +1754,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 @@ -1861,21 +1838,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); } /*! @@ -1916,7 +1900,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()), Qt::escape(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 } @@ -1932,7 +1917,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()), Qt::escape(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 } @@ -1951,7 +1937,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()), Qt::escape(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 @@ -1976,7 +1963,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 } @@ -1995,7 +1983,7 @@ bool QWebPage::shouldInterruptJavaScript() */ 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) @@ -2260,6 +2248,7 @@ QString QWebPage::selectedText() const return d->page->focusController()->focusedOrMainFrame()->selectedText(); } +#ifndef QT_NO_ACTION /*! Returns a QAction for the specified WebAction \a action. @@ -2279,7 +2268,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) { @@ -2532,6 +2521,7 @@ QAction *QWebPage::action(WebAction action) const d->updateAction(action); return a; } +#endif // QT_NO_ACTION /*! \property QWebPage::modified @@ -2801,6 +2791,7 @@ bool QWebPage::swallowContextMenuEvent(QContextMenuEvent *event) */ void QWebPage::updatePositionDependentActions(const QPoint &pos) { +#ifndef QT_NO_ACTION // First we disable all actions, but keep track of which ones were originally enabled. QBitArray originallyEnabledWebActions(QWebPage::WebActionCount); for (int i = ContextMenuItemTagNoAction; i < ContextMenuItemBaseApplicationTag; ++i) { @@ -2810,6 +2801,7 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) a->setEnabled(false); } } +#endif // QT_NO_ACTION d->createMainFrame(); WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame(); @@ -2836,6 +2828,7 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) d->currentContextMenu = d->createContextMenu(&menu, menu.platformDescription(), &visitedWebActions); #endif // QT_NO_CONTEXTMENU +#ifndef QT_NO_ACTION // Finally, we restore the original enablement for the actions that were not put into the menu. originallyEnabledWebActions &= ~visitedWebActions; // Mask out visited actions (they're part of the menu) for (int i = 0; i < QWebPage::WebActionCount; ++i) { @@ -2844,6 +2837,7 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) a->setEnabled(true); } } +#endif // QT_NO_ACTION // This whole process ensures that any actions put into to the context menu has the right // enablement, while also keeping the correct enablement for actions that were left out of @@ -2976,7 +2970,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; } @@ -3058,7 +3053,8 @@ 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 @@ -3129,6 +3125,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. @@ -3336,8 +3334,8 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const // Language QLocale locale; - if (view()) - locale = view()->locale(); + if (d->client && d->client->ownerWidget()) + locale = d->client->ownerWidget()->locale(); QString name = locale.name(); name[2] = QLatin1Char('-'); ua.append(name); @@ -3360,9 +3358,11 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const 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; } @@ -3515,7 +3515,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/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index 4766cbd..c085fd7 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -54,6 +54,8 @@ namespace WebCore { class EditorClientQt; class FrameLoaderClientQt; class InspectorClientQt; + class InspectorFrontendClientQt; + class NotificationPresenterClientQt; class ResourceHandle; class HitTestResult; class QNetworkReplyHandler; @@ -219,7 +221,9 @@ public: QString selectedText() const; +#ifndef QT_NO_ACTION QAction *action(WebAction action) const; +#endif virtual void triggerAction(WebAction action, bool checked = false); QSize viewportSize() const; @@ -347,7 +351,9 @@ protected: private: Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int)) +#ifndef QT_NO_ACTION Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked)) +#endif Q_PRIVATE_SLOT(d, void _q_cleanupLeakMessages()) QWebPagePrivate *d; @@ -355,14 +361,19 @@ 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::NotificationPresenterClientQt; friend class WebCore::ResourceHandle; friend class WebCore::QNetworkReplyHandler; + friend class DumpRenderTreeSupportQt; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QWebPage::FindFlags) diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index 15ddfb2..f40053b 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.h @@ -44,6 +44,7 @@ namespace WebCore { class EditorClientQt; class Element; class InspectorController; + class NotificationPresenterClientQt; class Node; class Page; class Frame; @@ -64,6 +65,7 @@ public: ~QWebPagePrivate(); static WebCore::Page* core(QWebPage*); + static QWebPagePrivate* priv(QWebPage*); void createMainFrame(); #ifndef QT_NO_CONTEXTMENU @@ -162,6 +164,8 @@ public: QNetworkAccessManager *networkManager; bool forwardUnsupportedContent; + bool smartInsertDeleteEnabled; + bool selectTrailingWhitespaceEnabled; QWebPage::LinkDelegationPolicy linkPolicy; QSize viewportSize; @@ -184,6 +188,10 @@ public: QWebInspector* inspector; bool inspectorIsInternalOnly; // True if created through the Inspect context menu action Qt::DropAction m_lastDropAction; + + WebCore::NotificationPresenterClientQt* notificationPresenterClient; + + QString viewMode; static bool drtRun; }; diff --git a/WebKit/qt/Api/qwebsecurityorigin.cpp b/WebKit/qt/Api/qwebsecurityorigin.cpp index 6c26bd7..b69f24d 100644 --- a/WebKit/qt/Api/qwebsecurityorigin.cpp +++ b/WebKit/qt/Api/qwebsecurityorigin.cpp @@ -30,21 +30,6 @@ using namespace WebCore; -void QWEBKIT_EXPORT qt_drt_whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) -{ - SecurityOrigin::whiteListAccessFromOrigin(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); -} - -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/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index d60f09c..1dff037 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/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; @@ -158,6 +160,13 @@ void QWebSettingsPrivate::apply() 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); @@ -174,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); @@ -182,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)); @@ -193,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)); @@ -219,10 +238,16 @@ void QWebSettingsPrivate::apply() global->attributes.value(QWebSettings::LocalContentCanAccessFileUrls)); settings->setAllowFileAccessFromFileURLs(value); - value = attributes.value(QWebSettings::XSSAuditorEnabled, - global->attributes.value(QWebSettings::XSSAuditorEnabled)); + value = attributes.value(QWebSettings::XSSAuditingEnabled, + global->attributes.value(QWebSettings::XSSAuditingEnabled)); 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(); @@ -326,6 +351,7 @@ QWebSettings* QWebSettings::globalSettings() \value MissingPluginGraphic The replacement graphic shown when a plugin could not be loaded. \value DefaultFrameIconGraphic The default icon for QWebFrame::icon(). \value TextAreaSizeGripCornerGraphic The graphic shown for the size grip of text areas. + \value DeleteButtonGraphic The graphic shown for the WebKit-Editing-Delete-Button in Deletion UI. */ /*! @@ -352,6 +378,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 @@ -367,8 +400,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 LocalContentCanAccessFileUrls Specifies whether locally loaded documents are allowed to access other local urls. + \value XSSAuditingEnabled 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. */ /*! @@ -392,6 +442,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); @@ -400,7 +451,10 @@ QWebSettings::QWebSettings() d->attributes.insert(QWebSettings::LocalStorageEnabled, false); d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false); d->attributes.insert(QWebSettings::LocalContentCanAccessFileUrls, true); - d->attributes.insert(QWebSettings::AcceleratedCompositingEnabled, false); + 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"); } @@ -469,7 +523,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() */ @@ -902,6 +957,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 } @@ -941,6 +998,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 @@ -969,8 +1051,9 @@ void QWebSettings::enablePersistentStorage(const QString& path) QString storagePath; if (path.isEmpty()) { +#ifndef QT_NO_DESKTOPSERVICES storagePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - +#endif if (storagePath.isEmpty()) storagePath = WebCore::pathByAppendingComponent(QDir::homePath(), QCoreApplication::applicationName()); } else diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h index b1f5cf2..bd728d8 100644 --- a/WebKit/qt/Api/qwebsettings.h +++ b/WebKit/qt/Api/qwebsettings.h @@ -67,10 +67,14 @@ public: LocalStorageDatabaseEnabled = LocalStorageEnabled, #endif LocalContentCanAccessRemoteUrls, - LocalContentCanAccessFileUrls, DnsPrefetchEnabled, - XSSAuditorEnabled, - AcceleratedCompositingEnabled + XSSAuditingEnabled, + AcceleratedCompositingEnabled, + WebGLEnabled, + SpatialNavigationEnabled, + LocalContentCanAccessFileUrls, + TiledBackingStoreEnabled, + FrameFlatteningEnabled }; enum WebGraphic { MissingImageGraphic, @@ -133,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/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp index 79c16c7..3ba1678 100644 --- a/WebKit/qt/Api/qwebview.cpp +++ b/WebKit/qt/Api/qwebview.cpp @@ -45,6 +45,7 @@ public: } void _q_pageDestroyed(); + void unsetPageIfExists(); QWebView *view; QWebPage *page; @@ -347,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. @@ -360,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()); @@ -397,9 +417,6 @@ void QWebView::setPage(QWebPage* page) this, SLOT(_q_pageDestroyed())); } setAttribute(Qt::WA_OpaquePaintEvent, d->page); -#if USE(ACCELERATED_COMPOSITING) - d->page->d->page->settings()->setAcceleratedCompositingEnabled(false); -#endif update(); } @@ -565,6 +582,7 @@ QString QWebView::selectedText() const return QString(); } +#ifndef QT_NO_ACTION /*! Returns a pointer to a QAction that encapsulates the specified web action \a action. */ @@ -572,6 +590,7 @@ QAction *QWebView::pageAction(QWebPage::WebAction action) const { return page()->action(action); } +#endif /*! Triggers the specified \a action. If it is a checkable action the specified diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h index f681fbc..1d651d5 100644 --- a/WebKit/qt/Api/qwebview.h +++ b/WebKit/qt/Api/qwebview.h @@ -75,7 +75,9 @@ public: QString selectedText() const; +#ifndef QT_NO_ACTION QAction* pageAction(QWebPage::WebAction action) const; +#endif void triggerPageAction(QWebPage::WebAction action, bool checked = false); bool isModified() const; |