summaryrefslogtreecommitdiffstats
path: root/WebKit/qt
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/qt')
-rw-r--r--WebKit/qt/Api/DerivedSources.pro14
-rw-r--r--WebKit/qt/Api/qgraphicswebview.cpp67
-rw-r--r--WebKit/qt/Api/qgraphicswebview.h5
-rw-r--r--WebKit/qt/Api/qwebelement.h9
-rw-r--r--WebKit/qt/Api/qwebframe.cpp42
-rw-r--r--WebKit/qt/Api/qwebframe.h4
-rw-r--r--WebKit/qt/Api/qwebframe_p.h1
-rw-r--r--WebKit/qt/Api/qwebpage.cpp34
-rw-r--r--WebKit/qt/Api/qwebsettings.cpp6
-rw-r--r--WebKit/qt/Api/qwebsettings.h1
-rw-r--r--WebKit/qt/ChangeLog200
-rw-r--r--WebKit/qt/QGVLauncher/main.cpp23
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.cpp6
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.h1
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp18
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h1
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.cpp15
-rw-r--r--WebKit/qt/symbian/eabi/QtWebKitu.def2
-rw-r--r--WebKit/qt/tests/hybridPixmap/test.html12
-rw-r--r--WebKit/qt/tests/qwebframe/tst_qwebframe.cpp56
20 files changed, 500 insertions, 17 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
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index e0d1b28..fb832b3 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,203 @@
+2010-02-18 Noam Rosenthal <noam.rosenthal@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Minor improvement to hybrid QPixmap
+ https://bugs.webkit.org/show_bug.cgi?id=34507
+
+ * tests/hybridPixmap/test.html: use assignToHTMLImageElement on an
+ existing element instead of toHTMLImageElement which creates a new one
+
+2010-02-17 Dmitry Titov <dimich@chromium.org>
+
+ Reviewed by David Levin, Darin Fisher, Simon Hausmann.
+
+ When a live iframe element is moved between pages, it still depends on the old page.
+ https://bugs.webkit.org/show_bug.cgi?id=34382
+
+ * Api/qwebframe_p.h:
+ (QWebFramePrivate::setPage): Added.
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::didTransferChildFrameToNewDocument):
+ The QWebFrame caches a QWebPage which should be replaced when Frame is re-parented.
+ Also, the QWebFrame is a child (in QT terms) of QWebPage - so update that relationship as well.
+ Emit a signal that QWebFrame moved to a different QWebPage.
+
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2010-02-17 Kent Tamura <tkent@chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Introduces new Icon loading interface in order to support
+ asynchronous loading.
+ https://bugs.webkit.org/show_bug.cgi?id=32054
+
+ Add an empty implementation of ChromeClient::iconForFiles().
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::iconForFiles):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2010-02-17 Diego Gonzalez <diego.gonzalez@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Make possible Qt DRT to get total number of pages to be printed
+
+ LayoutTests:
+ printing/numberOfPages.html
+
+ [Qt] DRT: Get total number of pages to be printed
+ https://bugs.webkit.org/show_bug.cgi?id=34955
+
+ * Api/qwebframe.cpp:
+ (qt_drt_numberOfPages):
+ (qt_drt_evaluateScriptInIsolatedWorld):
+
+2010-02-16 Ariya Hidayat <ariya.hidayat@gmail.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Allow scrolling to an anchor programmatically.
+ https://bugs.webkit.org/show_bug.cgi?id=29856
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::scrollToAnchor): New API function.
+ * Api/qwebframe.h:
+ * tests/qwebframe/tst_qwebframe.cpp: New tests for scrollToAnchor().
+
+2010-02-16 Ariya Hidayat <ariya.hidayat@gmail.com>
+
+ Reviewed by Laszlo Gombos.
+
+ Fix building with Qt < 4.6.
+ https://bugs.webkit.org/show_bug.cgi?id=34885
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebViewPrivate::updateResizesToContentsForPage):
+
+2010-02-16 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Unreviewed Symbian build fix.
+
+ Updated the def file with two new exports used by QtLauncher.
+
+ * symbian/eabi/QtWebKitu.def:
+
+2010-02-16 Ismail Donmez <ismail@namtrac.org>
+
+ Reviewed by Pavel Feldman.
+
+ Fix compilation with inspector disabled.
+ https://bugs.webkit.org/show_bug.cgi?id=32724
+
+ * Api/qwebpage.cpp:
+ (qt_drt_webinspector_executeScript):
+ (qt_drt_webinspector_close):
+ (qt_drt_webinspector_show):
+ (qt_drt_setTimelineProfilingEnabled):
+
+2010-02-16 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausman.
+
+ [Qt] Fix include paths for forwarding headers in standalone builds.
+
+ * Api/DerivedSources.pro: Use relative paths for package builds and added some
+ documentation.
+
+2010-02-15 Noam Rosenthal <noam.rosenthal@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] QtWebkit bridge: enable passing a QWebElement to a signal/slot/property
+ Add Q_DECLARE_METATYPE to QWebElement, add relevant tests to
+ tst_qwebframe
+ https://bugs.webkit.org/show_bug.cgi?id=34901
+
+ * Api/qwebelement.h: declare metatype
+ * tests/qwebframe/tst_qwebframe.cpp:
+ (MyQObject::webElementProperty): new test for QWebElement
+ (MyQObject::setWebElementProperty): new test for QWebElement
+ (MyQObject::myOverloadedSlot): new test for QWebElement
+
+2010-02-15 Robert Hogan <robert@roberthogan.net>, Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] DRT: Support evaluateInWebInspector(), setTimelineProfilingEnabled().
+
+ Support LayoutTestController.evaluateInWebInspector(), setTimelineProfilingEnabled() in Qt DRT.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33096
+
+ This allows the following tests to pass:
+
+ inspector/console-format-collections.html
+ inspector/styles-iframe.html
+ inspector/syntax-highlight-css.html
+ inspector/syntax-highlight-javascript.html
+ inspector/timeline-enum-stability.html
+ inspector/timeline-layout.html
+ inspector/timeline-mark-timeline.html
+ inspector/timeline-paint.html
+ inspector/timeline-parse-html.html
+ inspector/timeline-recalculate-styles.html
+ inspector/timeline-script-tag-1.html
+ inspector/timeline-script-tag-2.html
+ inspector/timeline-trivial.html
+ inspector/cookie-resource-match.html
+ inspector/elements-img-tooltip.html
+ inspector/elements-panel-selection-on-refresh.html
+ inspector/inspected-objects-not-overriden.html
+ inspector/timeline-event-dispatch.html
+ inspector/timeline-network-resource.html
+ inspector/elements-panel-rewrite-href.html
+ inspector/console-dir.html
+ inspector/console-dirxml.html
+ inspector/console-format.html
+ inspector/console-tests.html
+ inspector/elements-panel-structure.html
+ inspector/evaluate-in-frontend.html
+ inspector/console-clear.html
+
+ * Api/qwebpage.cpp:
+ (qt_drt_webinspector_executeScript):
+ (qt_drt_webinspector_close):
+ (qt_drt_webinspector_show):
+ (qt_drt_setTimelineProfilingEnabled):
+
+ * WebCoreSupport/InspectorClientQt.cpp:
+ (InspectorClientQt::createPage)
+
+2010-02-12 Antti Koivisto <koivisto@iki.fi>
+
+ Reviewed by Kenneth Rohde Christiansen and Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=34885
+ Add a QGraphicsWebView mode that makes it automatically resize itself to the size of the content.
+
+ This is useful for cases where the client wants to implement page panning and zooming by manipulating
+ the graphics item.
+
+ Add a option to QGVLauncher to test this mode.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
+ (QGraphicsWebViewPrivate::updateResizesToContentsForPage):
+ (QGraphicsWebViewPrivate::_q_contentsSizeChanged):
+ (QGraphicsWebView::setPage):
+ (QGraphicsWebView::setResizesToContents):
+ (QGraphicsWebView::resizesToContents):
+ * Api/qgraphicswebview.h:
+ * QGVLauncher/main.cpp:
+ (WebView::WebView):
+ (MainView::MainView):
+ (MainView::setMainWidget):
+ (MainView::resizeEvent):
+ (main):
+
2010-02-12 Diego Gonzalez <diego.gonzalez@openbossa.org>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit/qt/QGVLauncher/main.cpp b/WebKit/qt/QGVLauncher/main.cpp
index 0536af5..448b4b0 100644
--- a/WebKit/qt/QGVLauncher/main.cpp
+++ b/WebKit/qt/QGVLauncher/main.cpp
@@ -74,6 +74,8 @@ public:
{
if (QApplication::instance()->arguments().contains("--cacheWebView"))
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ if (QApplication::instance()->arguments().contains("--resizesToContents"))
+ setResizesToContents(true);
}
void setYRotation(qreal angle)
{
@@ -129,8 +131,11 @@ public:
, m_numTotalPaints(0)
, m_numPaintsSinceLastMeasure(0)
{
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ // Use the graphics view scrollbars when the webview is set to size to the content.
+ if (!QApplication::instance()->arguments().contains("--resizesToContents")) {
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ }
setFrameShape(QFrame::NoFrame);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -143,17 +148,19 @@ public:
}
}
- void setMainWidget(QGraphicsWidget* widget)
+ void setMainWidget(WebView* widget)
{
- QRectF rect(QRect(QPoint(0, 0), size()));
- widget->setGeometry(rect);
m_mainWidget = widget;
+ if (m_mainWidget->resizesToContents())
+ return;
+ QRectF rect(QRect(QPoint(0, 0), size()));
+ m_mainWidget->setGeometry(rect);
}
void resizeEvent(QResizeEvent* event)
{
QGraphicsView::resizeEvent(event);
- if (!m_mainWidget)
+ if (!m_mainWidget || m_mainWidget->resizesToContents())
return;
QRectF rect(QPoint(0, 0), event->size());
m_mainWidget->setGeometry(rect);
@@ -231,7 +238,7 @@ signals:
void flipRequest();
private:
- QGraphicsWidget* m_mainWidget;
+ WebView* m_mainWidget;
bool m_measureFps;
int m_numTotalPaints;
int m_numPaintsSinceLastMeasure;
@@ -493,7 +500,7 @@ int main(int argc, char** argv)
{
QApplication app(argc, argv);
if (app.arguments().contains("--help")) {
- qDebug() << "Usage: QGVLauncher [--url url] [--compositing] [--updateMode Full|Minimal|Smart|No|BoundingRect] [--cacheWebView]\n";
+ qDebug() << "Usage: QGVLauncher [--url url] [--compositing] [--updateMode Full|Minimal|Smart|No|BoundingRect] [--cacheWebView] [--resizesToContents]\n";
return 0;
}
QString url = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html"));
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 893a1b7..ecbabe4 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -463,6 +463,12 @@ void ChromeClientQt::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileC
}
}
+void ChromeClientQt::iconForFiles(const Vector<String>&, PassRefPtr<FileChooser>)
+{
+ // FIXME: Move the code of Icon::createIconForFiles() here.
+ notImplemented();
+}
+
bool ChromeClientQt::setCursor(PlatformCursorHandle)
{
notImplemented();
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index 6b3017d..3d5cbe9 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -138,6 +138,7 @@ namespace WebCore {
#endif
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
+ virtual void iconForFiles(const Vector<String>&, PassRefPtr<FileChooser>);
virtual void formStateDidChange(const Node*) { }
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 16a6faa..2eb2761 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -1066,6 +1066,24 @@ PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String
return frameData.frame.release();
}
+void FrameLoaderClientQt::didTransferChildFrameToNewDocument()
+{
+ ASSERT(m_frame->ownerElement());
+
+ if (!m_webFrame)
+ return;
+
+ Frame* parentFrame = m_webFrame->d->frame->tree()->parent();
+ ASSERT(parentFrame);
+
+ if (QWebFrame* parent = QWebFramePrivate::kit(parentFrame)) {
+ m_webFrame->d->setPage(parent->page());
+
+ if (m_webFrame->parent() != qobject_cast<QObject*>(parent))
+ m_webFrame->setParent(parent);
+ }
+}
+
ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const String& _mimeType)
{
// qDebug()<<" ++++++++++++++++ url is "<<url.prettyURL()<<", mime = "<<_mimeType;
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
index 32b9caa..adeb31c 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -194,6 +194,7 @@ namespace WebCore {
virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) ;
+ virtual void didTransferChildFrameToNewDocument();
virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
virtual void redirectDataToPlugin(Widget* pluginWidget);
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
index 4927ea8..5f343ff 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -83,16 +83,19 @@ void InspectorClientQt::inspectorDestroyed()
Page* InspectorClientQt::createPage()
{
- QWebView* inspectorView = new QWebView;
- InspectorClientWebPage* inspectorPage = new InspectorClientWebPage(inspectorView);
- inspectorView->setPage(inspectorPage);
- m_inspectorView.set(inspectorView);
+ QWebView* inspectorView = m_inspectorView.get();
+ if (!inspectorView) {
+ inspectorView = new QWebView;
+ InspectorClientWebPage* inspectorPage = new InspectorClientWebPage(inspectorView);
+ inspectorView->setPage(inspectorPage);
+ m_inspectorView.set(inspectorView);
+ }
- inspectorPage->mainFrame()->load(QString::fromLatin1("qrc:/webkit/inspector/inspector.html"));
+ inspectorView->page()->mainFrame()->load(QString::fromLatin1("qrc:/webkit/inspector/inspector.html"));
m_inspectedWebPage->d->inspectorFrontend = inspectorView;
m_inspectedWebPage->d->getOrCreateInspector()->d->setFrontend(inspectorView);
- return m_inspectorView->page()->d->page;
+ return inspectorView->page()->d->page;
}
String InspectorClientQt::localizedStringsURL()
diff --git a/WebKit/qt/symbian/eabi/QtWebKitu.def b/WebKit/qt/symbian/eabi/QtWebKitu.def
index 78523c6..f53bb0d 100644
--- a/WebKit/qt/symbian/eabi/QtWebKitu.def
+++ b/WebKit/qt/symbian/eabi/QtWebKitu.def
@@ -696,4 +696,6 @@ EXPORTS
_Z35qtwebkit_webframe_scrollRecursivelyP9QWebFrameii @ 695 NONAME
_ZN13QWebInspector10closeEventEP11QCloseEvent @ 696 NONAME
_ZN9QWebFrame17scrollRecursivelyEii @ 697 NONAME
+ _ZN16QGraphicsWebView20setResizesToContentsEb @ 698 NONAME
+ _ZNK16QGraphicsWebView17resizesToContentsEv @ 699 NONAME
diff --git a/WebKit/qt/tests/hybridPixmap/test.html b/WebKit/qt/tests/hybridPixmap/test.html
index ddaf75c..0f2c345 100644
--- a/WebKit/qt/tests/hybridPixmap/test.html
+++ b/WebKit/qt/tests/hybridPixmap/test.html
@@ -9,11 +9,17 @@
var obj = myWidget.image;
var pxm = myWidget.pixmap;
- var img = obj.toHTMLImageElement();
+ var img = new Image;
+ obj.assignToHTMLImageElement(img);
var img1 = document.getElementById("img1");
var img2 = document.getElementById("img2");
+ var img3 = document.getElementById("img3");
+ var img4 = document.getElementById("img4");
document.body.appendChild(img);
- document.body.appendChild(pxm.toHTMLImageElement());
+ obj.assignToHTMLImageElement(img3);
+ pxm.assignToHTMLImageElement(img4);
+ myWidget.compare(pxm.width, img4.width);
+ myWidget.compare(obj.width, img3.width);
var signalsFired = 0;
myWidget.compare(obj.toString(),"[Qt Native Pixmap "+obj.width+","+obj.height+"]");
myWidget.compare(String(pxm),"[Qt Native Pixmap "+pxm.width+","+pxm.height+"]");
@@ -53,5 +59,7 @@
<body onload="startTest()">
<img id="img1" />
<img id="img2" />
+ <img id="img3" />
+ <img id="img4" />
</body>
</html>
diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 0fb0bd6..5ac3769 100644
--- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -66,6 +66,7 @@ class MyQObject : public QObject
Q_PROPERTY(int readOnlyProperty READ readOnlyProperty)
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType)
+ Q_PROPERTY(QWebElement webElementProperty READ webElementProperty WRITE setWebElementProperty)
Q_ENUMS(Policy Strategy)
Q_FLAGS(Ability)
@@ -181,6 +182,14 @@ public:
m_shortcut = seq;
}
+ QWebElement webElementProperty() const {
+ return m_webElement;
+ }
+
+ void setWebElementProperty(const QWebElement& element) {
+ m_webElement = element;
+ }
+
CustomType propWithCustomType() const {
return m_customType;
}
@@ -433,6 +442,10 @@ public Q_SLOTS:
m_qtFunctionInvoked = 35;
m_actuals << arg;
}
+ void myOverloadedSlot(const QWebElement &arg) {
+ m_qtFunctionInvoked = 36;
+ m_actuals << QVariant::fromValue<QWebElement>(arg);
+ }
void qscript_call(int arg) {
m_qtFunctionInvoked = 40;
@@ -467,6 +480,7 @@ private:
int m_writeOnlyValue;
int m_readOnlyValue;
QKeySequence m_shortcut;
+ QWebElement m_webElement;
CustomType m_customType;
int m_qtFunctionInvoked;
QVariantList m_actuals;
@@ -570,6 +584,7 @@ private slots:
void hasSetFocus();
void render();
void scrollPosition();
+ void scrollToAnchor();
void evaluateWillCauseRepaint();
void qObjectWrapperWithSameIdentity();
void scrollRecursively();
@@ -685,6 +700,7 @@ void tst_QWebFrame::cleanup()
void tst_QWebFrame::getSetStaticProperty()
{
+ m_page->mainFrame()->setHtml("<html><head><body></body></html>");
QCOMPARE(evalJS("typeof myObject.noSuchProperty"), sUndefined);
// initial value (set in MyQObject constructor)
@@ -824,6 +840,8 @@ void tst_QWebFrame::getSetStaticProperty()
QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("two"));
QCOMPARE(evalJS("typeof myObject.stringListProperty[2]"), sString);
QCOMPARE(evalJS("myObject.stringListProperty[2]"), QLatin1String("true"));
+ evalJS("myObject.webElementProperty=document.body;");
+ QCOMPARE(evalJS("myObject.webElementProperty.tagName"), QLatin1String("BODY"));
// try to delete
QCOMPARE(evalJS("delete myObject.intProperty"), sFalse);
@@ -1886,6 +1904,12 @@ void tst_QWebFrame::overloadedSlots()
f.call(QString(), QStringList() << m_engine->newVariant(QVariant("ciao")));
QCOMPARE(m_myObject->qtFunctionInvoked(), 35);
*/
+
+ // should pick myOverloadedSlot(QRegExp)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(document.body)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
+
// should pick myOverloadedSlot(QObject*)
m_myObject->resetQtFunctionInvoked();
evalJS("myObject.myOverloadedSlot(myObject)");
@@ -2741,6 +2765,38 @@ void tst_QWebFrame::scrollPosition()
QCOMPARE(y, 29);
}
+void tst_QWebFrame::scrollToAnchor()
+{
+ QWebPage page;
+ page.setViewportSize(QSize(480, 800));
+ QWebFrame* frame = page.mainFrame();
+
+ QString html("<html><body><p style=\"margin-bottom: 1500px;\">Hello.</p>"
+ "<p><a id=\"foo\">This</a> is an anchor</p>"
+ "<p style=\"margin-bottom: 1500px;\"><a id=\"bar\">This</a> is another anchor</p>"
+ "</body></html>");
+ frame->setHtml(html);
+ frame->setScrollPosition(QPoint(0, 0));
+ QCOMPARE(frame->scrollPosition().x(), 0);
+ QCOMPARE(frame->scrollPosition().y(), 0);
+
+ QWebElement fooAnchor = frame->findFirstElement("a[id=foo]");
+
+ frame->scrollToAnchor("foo");
+ QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
+
+ frame->scrollToAnchor("bar");
+ frame->scrollToAnchor("foo");
+ QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
+
+ frame->scrollToAnchor("top");
+ QCOMPARE(frame->scrollPosition().y(), 0);
+
+ frame->scrollToAnchor("bar");
+ frame->scrollToAnchor("notexist");
+ QVERIFY(frame->scrollPosition().y() != 0);
+}
+
void tst_QWebFrame::evaluateWillCauseRepaint()
{
QWebView view;