Changeset 94673 in webkit


Ignore:
Timestamp:
Sep 7, 2011, 9:40:36 AM (14 years ago)
Author:
jocelyn.turcotte@nokia.com
Message:

[Qt][WK2] Make sure that the visible content rect and the content scale get to the web process in one single message.
https://bugs.webkit.org/show_bug.cgi?id=67189

Reviewed by Kenneth Rohde Christiansen.

The TiledBackingStore needs to know the screen size of the viewport to know how many tiles to
create, and since the visible content rect is given in page coordinates, the contents scale is
necessary to calculate the viewport size.
Both the rect and the scale then need to arrive to the web process at the same time to prevent
picking the new visible rect with the old scale or vice-versa which can produce a huge viewport size
and create/render an insane amount of tiles.

Things this patch does:

  • Merge the visible contents rect and content scale handling together.
  • Make QTouchWebView responsible for telling those viewport values to the web process instead of QTouchWebPage.
  • Prevent updating the viewport in ViewportInteractionEngine while a pinch is in progress and update the viewport at the end.
  • UIProcess/API/qt/qtouchwebpage.cpp:
  • UIProcess/API/qt/qtouchwebpage.h:
  • UIProcess/API/qt/qtouchwebpage_p.h:
  • UIProcess/API/qt/qtouchwebview.cpp:

(QTouchWebViewPrivate::QTouchWebViewPrivate):
(QTouchWebViewPrivate::_q_viewportUpdated):
(QTouchWebView::geometryChanged):

  • UIProcess/API/qt/qtouchwebview.h:
  • UIProcess/API/qt/qtouchwebview_p.h:
  • UIProcess/TiledDrawingAreaProxy.cpp:

(WebKit::TiledDrawingAreaProxy::setVisibleContentRectAndScale):

  • UIProcess/TiledDrawingAreaProxy.h:
  • UIProcess/qt/ViewportInteractionEngine.cpp:

(WebKit::ViewportInteractionEngine::ViewportInteractionEngine):
(WebKit::ViewportInteractionEngine::~ViewportInteractionEngine): Allows OwnPtr with the forward declaration of ViewportUpdateGuard.
(WebKit::ViewportInteractionEngine::setConstraints):
(WebKit::ViewportInteractionEngine::pinchGestureStarted):
(WebKit::ViewportInteractionEngine::pinchGestureEnded):
(WebKit::ViewportInteractionEngine::contentViewportChanged):

  • UIProcess/qt/ViewportInteractionEngine.h:
  • UIProcess/qt/qtouchwebpageproxy.cpp:

(QTouchWebPageProxy::setVisibleContentRectAndScale):

  • UIProcess/qt/qtouchwebpageproxy.h:
  • WebProcess/WebPage/DrawingArea.h:

(WebKit::DrawingArea::setVisibleContentRectAndScale):

  • WebProcess/WebPage/DrawingArea.messages.in:
  • WebProcess/WebPage/TiledDrawingArea.cpp:

(WebKit::TiledDrawingArea::setVisibleContentRectAndScale):

  • WebProcess/WebPage/TiledDrawingArea.h:
Location:
trunk/Source/WebKit2
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r94672 r94673  
     12011-08-30  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
     2
     3        [Qt][WK2] Make sure that the visible content rect and the content scale get to the web process in one single message.
     4        https://bugs.webkit.org/show_bug.cgi?id=67189
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        The TiledBackingStore needs to know the screen size of the viewport to know how many tiles to
     9        create, and since the visible content rect is given in page coordinates, the contents scale is
     10        necessary to calculate the viewport size.
     11        Both the rect and the scale then need to arrive to the web process at the same time to prevent
     12        picking the new visible rect with the old scale or vice-versa which can produce a huge viewport size
     13        and create/render an insane amount of tiles.
     14
     15        Things this patch does:
     16        - Merge the visible contents rect and content scale handling together.
     17        - Make QTouchWebView responsible for telling those viewport values to the web process instead of QTouchWebPage.
     18        - Prevent updating the viewport in ViewportInteractionEngine while a pinch is in progress and update the viewport at the end.
     19
     20        * UIProcess/API/qt/qtouchwebpage.cpp:
     21        * UIProcess/API/qt/qtouchwebpage.h:
     22        * UIProcess/API/qt/qtouchwebpage_p.h:
     23        * UIProcess/API/qt/qtouchwebview.cpp:
     24        (QTouchWebViewPrivate::QTouchWebViewPrivate):
     25        (QTouchWebViewPrivate::_q_viewportUpdated):
     26        (QTouchWebView::geometryChanged):
     27        * UIProcess/API/qt/qtouchwebview.h:
     28        * UIProcess/API/qt/qtouchwebview_p.h:
     29        * UIProcess/TiledDrawingAreaProxy.cpp:
     30        (WebKit::TiledDrawingAreaProxy::setVisibleContentRectAndScale):
     31        * UIProcess/TiledDrawingAreaProxy.h:
     32        * UIProcess/qt/ViewportInteractionEngine.cpp:
     33        (WebKit::ViewportInteractionEngine::ViewportInteractionEngine):
     34        (WebKit::ViewportInteractionEngine::~ViewportInteractionEngine): Allows OwnPtr with the forward declaration of ViewportUpdateGuard.
     35        (WebKit::ViewportInteractionEngine::setConstraints):
     36        (WebKit::ViewportInteractionEngine::pinchGestureStarted):
     37        (WebKit::ViewportInteractionEngine::pinchGestureEnded):
     38        (WebKit::ViewportInteractionEngine::contentViewportChanged):
     39        * UIProcess/qt/ViewportInteractionEngine.h:
     40        * UIProcess/qt/qtouchwebpageproxy.cpp:
     41        (QTouchWebPageProxy::setVisibleContentRectAndScale):
     42        * UIProcess/qt/qtouchwebpageproxy.h:
     43        * WebProcess/WebPage/DrawingArea.h:
     44        (WebKit::DrawingArea::setVisibleContentRectAndScale):
     45        * WebProcess/WebPage/DrawingArea.messages.in:
     46        * WebProcess/WebPage/TiledDrawingArea.cpp:
     47        (WebKit::TiledDrawingArea::setVisibleContentRectAndScale):
     48        * WebProcess/WebPage/TiledDrawingArea.h:
     49
    1502011-08-29  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    251
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp

    r94672 r94673  
    160160}
    161161
    162 void QTouchWebPagePrivate::_q_commitScaleChange()
    163 {
    164     commitScaleChange();
    165 }
    166 
    167 void QTouchWebPagePrivate::commitScaleChange()
    168 {
    169     page->setContentsScale(q->scale());
    170 }
    171 
    172162void QTouchWebPagePrivate::setPage(QTouchWebPageProxy* page)
    173163{
     
    177167}
    178168
    179 void QTouchWebPagePrivate::setViewportRect(const QRectF& viewportRect)
    180 {
    181     const QRectF visibleContentRect = q->boundingRect().intersected(viewportRect);
    182     page->setVisibleContentRect(visibleContentRect);
    183 }
    184 
    185169#include "moc_qtouchwebpage.cpp"
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h

    r93407 r94673  
    7979
    8080private:
    81     Q_PRIVATE_SLOT(d, void _q_commitScaleChange());
    82 
    8381    QTouchWebPagePrivate* d;
    8482    friend class QTouchWebViewPrivate;
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h

    r94672 r94673  
    3939    void setPage(QTouchWebPageProxy*);
    4040
    41     void setViewportRect(const QRectF&);
    42     void _q_commitScaleChange();
    43     void commitScaleChange();
    44 
    4541    QTouchWebPage* const q;
    4642    QTouchWebPageProxy* page;
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp

    r94313 r94673  
    4040    pageViewPrivate->setPage(&page);
    4141
    42     QObject::connect(&interactionEngine, SIGNAL(viewportUpdateRequested()), q, SLOT(_q_viewportRectUpdated()));
    43     QObject::connect(&interactionEngine, SIGNAL(commitScaleChange()), pageView.data(), SLOT(_q_commitScaleChange()));
     42    QObject::connect(&interactionEngine, SIGNAL(viewportUpdateRequested()), q, SLOT(_q_viewportUpdated()));
    4443}
    4544
     
    4948}
    5049
    51 void QTouchWebViewPrivate::_q_viewportRectUpdated()
     50void QTouchWebViewPrivate::_q_viewportUpdated()
    5251{
    53     QTouchWebPagePrivate* const pageViewPrivate = pageView.data()->d;
    54     const QRectF viewportRectInPageViewCoordinate = q->mapRectToItem(pageView.data(), q->boundingRect());
    55     pageViewPrivate->setViewportRect(viewportRectInPageViewCoordinate);
     52    const QRectF visibleRectInPageViewCoordinate = q->mapRectToItem(pageView.data(), q->boundingRect()).intersected(pageView->boundingRect());
     53    float scale = pageView->scale();
     54    page.setVisibleContentRectAndScale(visibleRectInPageViewCoordinate, scale);
    5655}
    5756
     
    111110    if (newGeometry.size() != oldGeometry.size()) {
    112111        d->updateViewportConstraints();
    113         d->_q_viewportRectUpdated();
     112        d->_q_viewportUpdated();
    114113    }
    115114}
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview.h

    r93407 r94673  
    4848
    4949private:
    50     Q_PRIVATE_SLOT(d, void _q_viewportRectUpdated());
     50    Q_PRIVATE_SLOT(d, void _q_viewportUpdated());
    5151
    5252    friend class WebKit::TouchViewInterface;
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h

    r93407 r94673  
    3636
    3737    void loadDidCommit();
    38     void _q_viewportRectUpdated();
     38    void _q_viewportUpdated();
    3939    void updateViewportConstraints();
    4040
  • trunk/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp

    r93780 r94673  
    5757}
    5858
    59 void TiledDrawingAreaProxy::setVisibleContentRect(const WebCore::IntRect& visibleContentsRect)
     59void TiledDrawingAreaProxy::setVisibleContentRectAndScale(const WebCore::IntRect& visibleContentRect, float scale)
    6060{
    61     // FIXME: Throttle those message enough not to flood the IPC queue and get a good tile creation responsiveness.
    62     page()->process()->send(Messages::DrawingArea::SetVisibleContentRect(visibleContentsRect), page()->pageID());
    63 }
    64 
    65 void TiledDrawingAreaProxy::setContentsScale(float scale)
    66 {
    67     // FIXME: Since the visibleContentRect size depends on the scale, they should get to the web process in
    68     // one single message to avoid unecessary tile rendering because of a possibly very
    69     // oversized calculated visible rect.
    70     page()->process()->send(Messages::DrawingArea::SetContentsScale(scale), page()->pageID());
     61    page()->process()->send(Messages::DrawingArea::SetVisibleContentRectAndScale(visibleContentRect, scale), page()->pageID());
    7162}
    7263
  • trunk/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h

    r93780 r94673  
    7272    virtual ~TiledDrawingAreaProxy();
    7373
    74     void setVisibleContentRect(const WebCore::IntRect&);
    75     void setContentsScale(float);
     74    void setVisibleContentRectAndScale(const WebCore::IntRect&, float);
    7675    void renderNextFrame();
    7776
  • trunk/Source/WebKit2/UIProcess/qt/ViewportInteractionEngine.cpp

    r93592 r94673  
    1919 */
    2020
     21#include "config.h"
    2122#include "ViewportInteractionEngine.h"
    2223
     24#include "PassOwnPtr.h"
    2325#include <QPointF>
    2426#include <QtDeclarative/qsgitem.h>
     
    4345//
    4446// The guard make sure the signal viewportUpdateRequested() is sent if necessary.
     47// When multiple guards are alive, their lifetime must be perfectly imbricated (e.g. if used ouside stack frames).
     48// We rely on the first one to trigger the update at the end since it only uses one bool internally.
    4549//
    4650// The public methods should create the guard if they might update content.
     
    8488{
    8589    reset();
    86     connect(m_content, SIGNAL(xChanged()), this, SLOT(contentGeometryChanged()), Qt::DirectConnection);
    87     connect(m_content, SIGNAL(yChanged()), this, SLOT(contentGeometryChanged()), Qt::DirectConnection);
    88     connect(m_content, SIGNAL(widthChanged()), this, SLOT(contentGeometryChanged()), Qt::DirectConnection);
    89     connect(m_content, SIGNAL(heightChanged()), this, SLOT(contentGeometryChanged()), Qt::DirectConnection);
    90     connect(m_content, SIGNAL(scaleChanged()), this, SLOT(contentScaleChanged()), Qt::DirectConnection);
     90    connect(m_content, SIGNAL(xChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
     91    connect(m_content, SIGNAL(yChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
     92    connect(m_content, SIGNAL(widthChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
     93    connect(m_content, SIGNAL(heightChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
     94    connect(m_content, SIGNAL(scaleChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
     95}
     96
     97ViewportInteractionEngine::~ViewportInteractionEngine()
     98{
    9199}
    92100
     
    112120    //  viewport, it does not pan horizontally anymore).
    113121
    114     const qreal previousScale = m_content->scale();
    115     {
    116         ViewportUpdateGuard guard(this);
    117         m_constraints = constraints;
    118         updateContentIfNeeded();
    119     }
    120     if (m_content->scale() != previousScale)
    121         emit commitScaleChange();
     122    ViewportUpdateGuard guard(this);
     123    m_constraints = constraints;
     124    updateContentIfNeeded();
    122125}
    123126
     
    156159    if (!m_constraints.isUserScalable)
    157160        return;
     161
     162    m_pinchViewportUpdateDeferrer = adoptPtr(new ViewportUpdateGuard(this));
    158163
    159164    m_userInteractionFlags |= UserHasScaledContent;
     
    188193        animateContentIntoBoundariesIfNeeded();
    189194    }
    190     if (m_pinchStartScale != m_content->scale())
    191         emit commitScaleChange();
    192 }
    193 
    194 void ViewportInteractionEngine::contentGeometryChanged()
     195    m_pinchViewportUpdateDeferrer.clear();
     196}
     197
     198void ViewportInteractionEngine::contentViewportChanged()
    195199{
    196200    if (m_isUpdatingContent)
     
    202206    // We must notify the change so the client can rely on us for all change of Geometry.
    203207    emit viewportUpdateRequested();
    204 }
    205 
    206 void ViewportInteractionEngine::contentScaleChanged()
    207 {
    208     if (m_isUpdatingContent)
    209         return;
    210 
    211     ViewportUpdateGuard guard(this);
    212     updateContentIfNeeded();
    213 
    214     // We must notify the change so the client can rely on us for all change of Geometry.
    215     emit viewportUpdateRequested();
    216     emit commitScaleChange();
    217208}
    218209
  • trunk/Source/WebKit2/UIProcess/qt/ViewportInteractionEngine.h

    r93592 r94673  
    2222#define ViewportInteractionEngine_h
    2323
     24#include "OwnPtr.h"
    2425#include "qwebkitglobal.h"
    2526#include <QtCore/QObject>
     
    3233namespace WebKit {
    3334
     35class ViewportUpdateGuard;
     36
    3437class ViewportInteractionEngine : public QObject {
    3538    Q_OBJECT
     
    3740public:
    3841    ViewportInteractionEngine(const QSGItem*, QSGItem*);
     42    ~ViewportInteractionEngine();
    3943
    4044    struct Constraints {
     
    6771    void viewportUpdateRequested();
    6872
    69     void commitScaleChange();
    70 
    7173private Q_SLOTS:
    7274    // Respond to changes of content that are not driven by us, like the page resizing itself.
    73     void contentGeometryChanged();
    74     void contentScaleChanged();
     75    void contentViewportChanged();
    7576
    7677private:
     
    9293    Constraints m_constraints;
    9394    bool m_isUpdatingContent;
     95    OwnPtr<ViewportUpdateGuard> m_pinchViewportUpdateDeferrer;
    9496    enum UserInteractionFlag {
    9597        UserHasNotInteractedWithContent = 0,
  • trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp

    r93784 r94673  
    7878}
    7979
    80 void QTouchWebPageProxy::setVisibleContentRect(const QRectF& visibleContentRect)
     80void QTouchWebPageProxy::setVisibleContentRectAndScale(const QRectF& visibleContentRect, float scale)
    8181{
    82     TiledDrawingAreaProxy* tiledDrawingArea = static_cast<TiledDrawingAreaProxy*>(m_webPageProxy->drawingArea());
    8382    QRect alignedVisibleContentRect = visibleContentRect.toAlignedRect();
    84     tiledDrawingArea->setVisibleContentRect(alignedVisibleContentRect);
     83    drawingArea()->setVisibleContentRectAndScale(alignedVisibleContentRect, scale);
    8584
    8685    // FIXME: Once we support suspend and resume, this should be delayed until the page is active if the page is suspended.
     
    109108}
    110109
    111 void QTouchWebPageProxy::setContentsScale(qreal scale)
    112 {
    113     drawingArea()->setContentsScale(scale);
    114 }
    115 
    116110void QTouchWebPageProxy::renderNextFrame()
    117111{
  • trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.h

    r93784 r94673  
    4444    virtual bool handleEvent(QEvent*);
    4545
    46     void setVisibleContentRect(const QRectF&);
     46    void setVisibleContentRectAndScale(const QRectF&, float);
    4747    void setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize);
    4848    void findZoomableAreaForPoint(const QPoint&);
    49     void setContentsScale(qreal);
    5049    void renderNextFrame();
    5150
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h

    r93780 r94673  
    100100#if ENABLE(TILED_BACKING_STORE)
    101101    virtual void setSize(const WebCore::IntSize& viewSize) { }
    102     virtual void setVisibleContentRect(const WebCore::IntRect&) { }
     102    virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float) { }
    103103    virtual void setContentsScale(float scale) { }
    104104    virtual void renderNextFrame() { }
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in

    r93780 r94673  
    2929#if ENABLE(TILED_BACKING_STORE)
    3030    SetSize(WebCore::IntSize viewSize)
    31     SetVisibleContentRect(WebCore::IntRect visibleContentRect)
    32     SetContentsScale(float scale)
     31    SetVisibleContentRectAndScale(WebCore::IntRect visibleContentRect, float scale)
    3332    RenderNextFrame()
    3433    TakeSnapshot(WebCore::IntSize size, WebCore::IntRect contentsRect)
  • trunk/Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp

    r93780 r94673  
    7171}
    7272
    73 void TiledDrawingArea::setVisibleContentRect(const WebCore::IntRect& visibleContentsRect)
     73void TiledDrawingArea::setVisibleContentRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale)
    7474{
    7575    m_visibleContentRect = visibleContentsRect;
    76     m_mainBackingStore->adjustVisibleRect();
    77 }
    7876
    79 void TiledDrawingArea::setContentsScale(float scale)
    80 {
    81     m_previousBackingStore = m_mainBackingStore.release();
    82     m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
    83     m_mainBackingStore->setContentsScale(scale);
     77    if (scale != m_mainBackingStore->contentsScale()) {
     78        m_previousBackingStore = m_mainBackingStore.release();
     79        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
     80        m_mainBackingStore->setContentsScale(scale);
     81    } else
     82        m_mainBackingStore->adjustVisibleRect();
    8483}
    8584
  • trunk/Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.h

    r93780 r94673  
    5555    // CoreIPC message handlers.
    5656    virtual void setSize(const WebCore::IntSize& viewSize);
    57     virtual void setVisibleContentRect(const WebCore::IntRect&);
    58     virtual void setContentsScale(float);
     57    virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float);
    5958    virtual void renderNextFrame();
    6059    virtual void suspendPainting();
Note: See TracChangeset for help on using the changeset viewer.