diff options
Diffstat (limited to 'WebKit/qt/Api')
-rw-r--r-- | WebKit/qt/Api/DerivedSources.pro | 14 | ||||
-rw-r--r-- | WebKit/qt/Api/qgraphicswebview.cpp | 67 | ||||
-rw-r--r-- | WebKit/qt/Api/qgraphicswebview.h | 5 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebelement.h | 9 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.cpp | 42 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.h | 4 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe_p.h | 1 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.cpp | 34 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.cpp | 6 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.h | 1 |
10 files changed, 182 insertions, 1 deletions
diff --git a/WebKit/qt/Api/DerivedSources.pro b/WebKit/qt/Api/DerivedSources.pro index 8702fde..a8f2684 100644 --- a/WebKit/qt/Api/DerivedSources.pro +++ b/WebKit/qt/Api/DerivedSources.pro @@ -31,6 +31,8 @@ WEBKIT_CLASS_HEADERS = $${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${ 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} &&) @@ -39,12 +41,22 @@ for(HEADER, WEBKIT_API_HEADERS) { 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 \\\"$$HEADER\\\"$${DOUBLE_ESCAPED_QUOTE} > $$eval($${HEADER_TARGET}.target)) + 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 + # 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, " ") diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index b323598..9720e0c 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -77,6 +77,7 @@ public: QGraphicsWebViewPrivate(QGraphicsWebView* parent) : q(parent) , page(0) + , resizesToContents(false) #if USE(ACCELERATED_COMPOSITING) , rootGraphicsLayer(0) , shouldSync(false) @@ -117,12 +118,18 @@ public: virtual void markForSync(bool scheduleSync); void updateCompositingScrollPosition(); #endif + + void updateResizesToContentsForPage(); void syncLayers(); void _q_doLoadFinished(bool success); + void _q_contentsSizeChanged(const QSize&); QGraphicsWebView* q; QWebPage* page; + + bool resizesToContents; + #if USE(ACCELERATED_COMPOSITING) QGraphicsItem* rootGraphicsLayer; @@ -304,6 +311,35 @@ 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)); +} + /*! \class QGraphicsWebView \brief The QGraphicsWebView class allows Web content to be added to a GraphicsView. @@ -586,6 +622,9 @@ void QGraphicsWebView::setPage(QWebPage* page) QSize size = geometry().size().toSize(); page->setViewportSize(size); + + if (d->resizesToContents) + d->updateResizesToContentsForPage(); QWebFrame* mainFrame = d->page->mainFrame(); @@ -918,6 +957,34 @@ 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. + + 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; +} + /*! \reimp */ void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) diff --git a/WebKit/qt/Api/qgraphicswebview.h b/WebKit/qt/Api/qgraphicswebview.h index 3cf51b2..14de9d5 100644 --- a/WebKit/qt/Api/qgraphicswebview.h +++ b/WebKit/qt/Api/qgraphicswebview.h @@ -45,6 +45,7 @@ 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) public: explicit QGraphicsWebView(QGraphicsItem* parent = 0); @@ -79,6 +80,9 @@ public: bool findText(const QString& subString, QWebPage::FindFlags options = 0); + bool resizesToContents() const; + void setResizesToContents(bool enabled); + virtual void setGeometry(const QRectF& rect); virtual void updateGeometry(); virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = 0); @@ -137,6 +141,7 @@ private: // 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&)) QGraphicsWebViewPrivate* const d; friend class QGraphicsWebViewPrivate; diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h index 3833070..156d24b 100644 --- a/WebKit/qt/Api/qwebelement.h +++ b/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/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 4c1f318..15b5c00 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -233,6 +233,15 @@ int QWEBKIT_EXPORT qt_drt_pageNumberForElementById(QWebFrame* qFrame, const QStr 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) { @@ -249,6 +258,13 @@ 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(); +} + QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame, WebCore::HTMLFrameOwnerElement* ownerFrameElement, const WebCore::String& frameName) @@ -282,6 +298,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()) @@ -1140,6 +1171,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. diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h index 25f6c9b..68594fd 100644 --- a/WebKit/qt/Api/qwebframe.h +++ b/WebKit/qt/Api/qwebframe.h @@ -160,6 +160,8 @@ public: QPoint scrollPosition() const; void setScrollPosition(const QPoint &pos); + void scrollToAnchor(const QString& anchor); + enum RenderLayer { ContentsLayer = 0x10, ScrollBarLayer = 0x20, @@ -217,6 +219,8 @@ Q_SIGNALS: void loadStarted(); void loadFinished(bool ok); + void pageChanged(); + private: friend class QWebPage; friend class QWebPagePrivate; diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index ee978be..7d79474 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -73,6 +73,7 @@ public: , marginHeight(-1) {} void init(QWebFrame* qframe, QWebFrameData* frameData); + void setPage(QWebPage*); inline QWebFrame *parentFrame() { return qobject_cast<QWebFrame*>(q->parent()); } diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index f661918..2a8aced 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -161,6 +161,40 @@ 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: QWebPageWidgetClient(QWidget* view) diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index a94a3aa..d60f09c 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -215,6 +215,10 @@ void QWebSettingsPrivate::apply() 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); @@ -363,6 +367,7 @@ 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. */ @@ -394,6 +399,7 @@ 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, false); d->offlineStorageDefaultQuota = 5 * 1024 * 1024; d->defaultTextEncoding = QLatin1String("iso-8859-1"); diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h index 77f2167..b1f5cf2 100644 --- a/WebKit/qt/Api/qwebsettings.h +++ b/WebKit/qt/Api/qwebsettings.h @@ -67,6 +67,7 @@ public: LocalStorageDatabaseEnabled = LocalStorageEnabled, #endif LocalContentCanAccessRemoteUrls, + LocalContentCanAccessFileUrls, DnsPrefetchEnabled, XSSAuditorEnabled, AcceleratedCompositingEnabled |