Changeset 96416 in webkit


Ignore:
Timestamp:
Sep 30, 2011 1:04:57 PM (13 years ago)
Author:
vestbo@webkit.org
Message:

[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.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r96414 r96416  
     12011-09-30  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
     2
     3        [Qt] Make sure WTR sizes the window and item correctly
     4
     5        Revision 96345 changed the logic for how the view and
     6        window was created, but missed a vital part, setting
     7        the size.
     8
     9        We now use a QSGView for the window, that has a simple
     10        item as its root object that is always resized to fit
     11        within the window. The webview is then parented to the
     12        root object and set to anchors.fill: parent. That way
     13        any window geometry changes will propagate to the web
     14        view.
     15
     16        https://bugs.webkit.org/show_bug.cgi?id=69134
     17
     18        Reviewed by Andreas Kling.
     19
     20        * WebKitTestRunner/PlatformWebView.h:
     21        * WebKitTestRunner/qt/PlatformWebViewQt.cpp:
     22
    1232011-09-30  Raphael Kubo da Costa  <kubo@profusion.mobi>
    224
  • trunk/Tools/WebKitTestRunner/PlatformWebView.h

    r96345 r96416  
    3030class QDesktopWebView;
    3131typedef QDesktopWebView* PlatformWKView;
    32 class QSGCanvas;
    33 typedef QSGCanvas* PlatformWindow;
     32class QSGView;
     33typedef QSGView* PlatformWindow;
    3434#elif defined(__APPLE__) && __APPLE__
    3535#if __OBJC__
  • trunk/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp

    r96345 r96416  
    3131
    3232#include <QApplication>
    33 #include <QtDeclarative/qsgcanvas.h>
     33#include <QDeclarativeProperty>
     34#include <QSGView>
    3435
    3536namespace WTR {
    3637
     38class WrapperWindow : public QSGView {
     39    Q_OBJECT
     40public:
     41    WrapperWindow(QSGItem* view)
     42        : QSGView(QUrl("data:text/plain,import QtQuick 2.0\nItem { objectName: 'root' }"))
     43        , m_view(view)
     44    {
     45        connect(this, SIGNAL(statusChanged(QSGView::Status)), SLOT(handleStatusChanged(QSGView::Status)));
     46    }
     47
     48private slots:
     49    void handleStatusChanged(QSGView::Status status)
     50    {
     51        if (status != QSGView::Ready)
     52            return;
     53
     54        setGeometry(0, 0, 800, 600);
     55        setResizeMode(QSGView::SizeRootObjectToView);
     56
     57        m_view->setParentItem(rootObject());
     58        QDeclarativeProperty::write(m_view, "anchors.fill", qVariantFromValue(rootObject()));
     59
     60        QFocusEvent ev(QEvent::WindowActivate);
     61        QApplication::sendEvent(m_view, &ev);
     62        m_view->setFocus(Qt::OtherFocusReason);
     63    }
     64
     65private:
     66    QSGItem* m_view;
     67};
     68
    3769PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
    3870    : m_view(new QDesktopWebView(contextRef, pageGroupRef))
    39     , m_window(new QSGCanvas)
     71    , m_window(new WrapperWindow(m_view))
    4072{
    41     m_view->setParent(m_window->rootItem());
    42     m_window->setGeometry(0, 0, 800, 600);
    43 
    44     QFocusEvent ev(QEvent::WindowActivate);
    45     QApplication::sendEvent(m_view, &ev);
    46     m_view->setFocus(Qt::OtherFocusReason);
    4773}
    4874
     
    94120
    95121} // namespace WTR
     122
     123#include "PlatformWebViewQt.moc"
Note: See TracChangeset for help on using the changeset viewer.