From: vestbo@webkit.org Date: Fri, 30 Sep 2011 20:04:57 +0000 (+0000) Subject: [Qt] Make sure WTR sizes the window and item correctly X-Git-Tag: 070512121124~23278 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=379af4581f9d61adf8a517575b269c3a85d1d804;p=profile%2Fivi%2Fwebkit-efl.git [Qt] Make sure WTR sizes the window and item correctly Revision 96345 changed the logic for how the view and window was created, but missed a vital part, setting the size. We now use a QSGView for the window, that has a simple item as its root object that is always resized to fit within the window. The webview is then parented to the root object and set to anchors.fill: parent. That way any window geometry changes will propagate to the web view. https://bugs.webkit.org/show_bug.cgi?id=69134 Reviewed by Andreas Kling. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96416 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Tools/ChangeLog b/Tools/ChangeLog index b6c87a1..f6365cb 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,25 @@ +2011-09-30 Tor Arne Vestbø + + [Qt] Make sure WTR sizes the window and item correctly + + Revision 96345 changed the logic for how the view and + window was created, but missed a vital part, setting + the size. + + We now use a QSGView for the window, that has a simple + item as its root object that is always resized to fit + within the window. The webview is then parented to the + root object and set to anchors.fill: parent. That way + any window geometry changes will propagate to the web + view. + + https://bugs.webkit.org/show_bug.cgi?id=69134 + + Reviewed by Andreas Kling. + + * WebKitTestRunner/PlatformWebView.h: + * WebKitTestRunner/qt/PlatformWebViewQt.cpp: + 2011-09-30 Raphael Kubo da Costa [EFL] Only save the current viewport in PixelDumpSupportEfl. diff --git a/Tools/WebKitTestRunner/PlatformWebView.h b/Tools/WebKitTestRunner/PlatformWebView.h index 5284e87..1cff688 100644 --- a/Tools/WebKitTestRunner/PlatformWebView.h +++ b/Tools/WebKitTestRunner/PlatformWebView.h @@ -29,8 +29,8 @@ #if defined(BUILDING_QT__) class QDesktopWebView; typedef QDesktopWebView* PlatformWKView; -class QSGCanvas; -typedef QSGCanvas* PlatformWindow; +class QSGView; +typedef QSGView* PlatformWindow; #elif defined(__APPLE__) && __APPLE__ #if __OBJC__ @class WKView; diff --git a/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp b/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp index f1e0b69..93f06c7 100644 --- a/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp +++ b/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp @@ -30,20 +30,46 @@ #include "qdesktopwebview.h" #include -#include +#include +#include namespace WTR { +class WrapperWindow : public QSGView { + Q_OBJECT +public: + WrapperWindow(QSGItem* view) + : QSGView(QUrl("data:text/plain,import QtQuick 2.0\nItem { objectName: 'root' }")) + , m_view(view) + { + connect(this, SIGNAL(statusChanged(QSGView::Status)), SLOT(handleStatusChanged(QSGView::Status))); + } + +private slots: + void handleStatusChanged(QSGView::Status status) + { + if (status != QSGView::Ready) + return; + + setGeometry(0, 0, 800, 600); + setResizeMode(QSGView::SizeRootObjectToView); + + m_view->setParentItem(rootObject()); + QDeclarativeProperty::write(m_view, "anchors.fill", qVariantFromValue(rootObject())); + + QFocusEvent ev(QEvent::WindowActivate); + QApplication::sendEvent(m_view, &ev); + m_view->setFocus(Qt::OtherFocusReason); + } + +private: + QSGItem* m_view; +}; + PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef) : m_view(new QDesktopWebView(contextRef, pageGroupRef)) - , m_window(new QSGCanvas) + , m_window(new WrapperWindow(m_view)) { - m_view->setParent(m_window->rootItem()); - m_window->setGeometry(0, 0, 800, 600); - - QFocusEvent ev(QEvent::WindowActivate); - QApplication::sendEvent(m_view, &ev); - m_view->setFocus(Qt::OtherFocusReason); } PlatformWebView::~PlatformWebView() @@ -93,3 +119,5 @@ void PlatformWebView::postEvent(QEvent* event) } } // namespace WTR + +#include "PlatformWebViewQt.moc"