Changeset 68457 in webkit


Ignore:
Timestamp:
Sep 27, 2010 5:31:09 PM (14 years ago)
Author:
kenneth@webkit.org
Message:

[Qt] Remove setDeviceSize methods
https://bugs.webkit.org/show_bug.cgi?id=46347

Reviewed by Antonio Gomes.

Remove our setDeviceHeight() API and obtain it automatically from the
system. Also for testing purposes, make it possible to override the
values via two newly introduced environment variables.

  • Api/qgraphicswebview.cpp:
  • Api/qgraphicswebview.h:
  • Api/qwebpage.cpp:

(getintenv):
(queryDeviceSizeForScreenContainingWidget):
(QWebPage::viewportConfigurationForSize):

  • WebCoreSupport/PageClientQt.cpp:

(WebCore::PageClientQGraphicsWidget::windowRect):

  • symbian/eabi/QtWebKitu.def:
Location:
trunk/WebKit/qt
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/Api/qgraphicswebview.cpp

    r65124 r68457  
    7676    QWebPage* page;
    7777    bool resizesToContents;
    78     QSize deviceSize;
    7978
    8079    // Just a convenience to avoid using page->client->overlay always
     
    556555
    557556/*!
    558     \property QGraphicsWebView::deviceSize
    559     \brief the size of the device using the web view
    560 
    561     The device size is used by the DOM window object methods
    562     otherHeight(), otherWidth() as well as a page for the viewport
    563     meta tag attributes device-width and device-height.
    564 */
    565 void QGraphicsWebView::setDeviceSize(const QSize& size)
    566 {
    567     d->deviceSize = size;
    568 }
    569 
    570 QSize QGraphicsWebView::deviceSize() const
    571 {
    572     return d->deviceSize;
    573 }
    574 
    575 /*!
    576557    \property QGraphicsWebView::zoomFactor
    577558    \brief the zoom factor for the view
  • trunk/WebKit/qt/Api/qgraphicswebview.h

    r65124 r68457  
    4242    Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
    4343    Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
    44     Q_PROPERTY(QSize deviceSize READ deviceSize WRITE setDeviceSize)
    4544
    4645    Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
     
    6564    qreal zoomFactor() const;
    6665    void setZoomFactor(qreal);
    67 
    68     QSize deviceSize() const;
    69     void setDeviceSize(const QSize&);
    7066
    7167    bool isModified() const;
  • trunk/WebKit/qt/Api/qwebpage.cpp

    r68292 r68457  
    2222#include "config.h"
    2323#include "qwebpage.h"
     24
    2425#include "qwebview.h"
    2526#include "qwebframe.h"
     
    9596#include <QBitArray>
    9697#include <QDebug>
     98#include <QDesktopWidget>
    9799#include <QDragEnterEvent>
    98100#include <QDragLeaveEvent>
     
    23392341}
    23402342
     2343static int getintenv(const char* variable)
     2344{
     2345    bool ok;
     2346    int value = qgetenv(variable).toInt(&ok);
     2347    return (ok) ? value : -1;
     2348}
     2349
     2350static QSize queryDeviceSizeForScreenContainingWidget(const QWidget* widget)
     2351{
     2352    QDesktopWidget* desktop = QApplication::desktop();
     2353    if (!desktop)
     2354        return QSize();
     2355
     2356    QSize size;
     2357
     2358    if (widget) {
     2359        // Returns the available geometry of the screen which contains widget.
     2360        // NOTE: this must be the the full screen size including any fixed status areas etc.
     2361        size = desktop->availableGeometry(widget).size();
     2362    } else
     2363        size = desktop->availableGeometry().size();
     2364
     2365    // This must be in portrait mode, adjust if not.
     2366    if (size.width() > size.height()) {
     2367        int width = size.width();
     2368        size.setWidth(size.height());
     2369        size.setHeight(width);
     2370    }
     2371
     2372    return size;
     2373}
     2374
     2375/*!
     2376    Computes the optimal viewport configuration given the \a availableSize, when
     2377    user interface components are disregarded.
     2378
     2379    The configuration is also dependent on the device screen size which is obtained
     2380    automatically. For testing purposes the size can be overridden by setting two
     2381    environment variables QTWEBKIT_DEVICE_WIDTH and QTWEBKIT_DEVICE_HEIGHT, which
     2382    both needs to be set.
     2383*/
     2384
    23412385QWebPage::ViewportConfiguration QWebPage::viewportConfigurationForSize(QSize availableSize) const
    23422386{
     
    23442388    static int deviceDPI = 160;
    23452389
    2346     FloatRect rect = d->page->chrome()->windowRect();
    2347 
    2348     int deviceWidth = rect.width();
    2349     int deviceHeight = rect.height();
    2350 
    2351     WebCore::ViewportConfiguration conf = WebCore::findConfigurationForViewportData(mainFrame()->d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize);
    2352 
    23532390    ViewportConfiguration result;
     2391
     2392    int deviceWidth = getintenv("QTWEBKIT_DEVICE_WIDTH");
     2393    int deviceHeight = getintenv("QTWEBKIT_DEVICE_HEIGHT");
     2394
     2395    // Both environment variables need to be set - or they will be ignored.
     2396    if (deviceWidth < 0 && deviceHeight < 0) {
     2397        QSize size = queryDeviceSizeForScreenContainingWidget((d->client) ? d->client->ownerWidget() : 0);
     2398        deviceWidth = size.width();
     2399        deviceHeight = size.height();
     2400    }
     2401
     2402    WebCore::ViewportConfiguration conf = WebCore::findConfigurationForViewportData(mainFrame()->d->viewportArguments(),
     2403            desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize);
    23542404
    23552405    result.m_isValid = true;
  • trunk/WebKit/qt/ChangeLog

    r68390 r68457  
     12010-09-27  Kenneth Rohde Christiansen  <kenneth.christiansen@openbossa.org>
     2
     3        Reviewed by Antonio Gomes.
     4
     5        [Qt] Remove setDeviceSize methods
     6        https://bugs.webkit.org/show_bug.cgi?id=46347
     7
     8        Remove our setDeviceHeight() API and obtain it automatically from the
     9        system. Also for testing purposes, make it possible to override the
     10        values via two newly introduced environment variables.
     11
     12        * Api/qgraphicswebview.cpp:
     13        * Api/qgraphicswebview.h:
     14        * Api/qwebpage.cpp:
     15        (getintenv):
     16        (queryDeviceSizeForScreenContainingWidget):
     17        (QWebPage::viewportConfigurationForSize):
     18        * WebCoreSupport/PageClientQt.cpp:
     19        (WebCore::PageClientQGraphicsWidget::windowRect):
     20        * symbian/eabi/QtWebKitu.def:
     21
    1222010-09-27  Girish Ramakrishnan  <girish@forwardbias.in>
    223
  • trunk/WebKit/qt/WebCoreSupport/PageClientQt.cpp

    r64965 r68457  
    319319QRectF PageClientQGraphicsWidget::windowRect() const
    320320{
    321     if (!view->deviceSize().isEmpty())
    322         return QRectF(QRect(QPoint(0, 0), view->deviceSize()));
    323 
    324321    if (!view->scene())
    325322        return QRectF();
  • trunk/WebKit/qt/symbian/eabi/QtWebKitu.def

    r67549 r68457  
    800800        _ZN8QWebPage23viewportChangeRequestedERKNS_13ViewportHintsE @ 799 NONAME ABSENT
    801801        _ZNK15QWebScriptWorld5worldEv @ 800 NONAME
    802         _ZN16QGraphicsWebView13setDeviceSizeERK5QSize @ 801 NONAME
    803802        _ZN23DumpRenderTreeSupportQt12pagePropertyEP9QWebFrameRK7QStringi @ 802 NONAME
    804803        _ZN23DumpRenderTreeSupportQt16isPageBoxVisibleEP9QWebFramei @ 803 NONAME
     
    812811        _ZN8QWebPage25requestPermissionFromUserEP9QWebFrameNS_16PermissionDomainE @ 811 NONAME
    813812        _ZN8QWebPage27cancelRequestsForPermissionEP9QWebFrameNS_16PermissionDomainE @ 812 NONAME
    814         _ZNK16QGraphicsWebView10deviceSizeEv @ 813 NONAME
    815813        _ZN23DumpRenderTreeSupportQt14viewportAsTextEP8QWebPageRK5QSize @ 814 NONAME
    816814        _ZN23DumpRenderTreeSupportQt32simulateDesktopNotificationClickERK7QString @ 815 NONAME
Note: See TracChangeset for help on using the changeset viewer.