Changeset 117069 in webkit


Ignore:
Timestamp:
May 15, 2012 8:07:59 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt][WK2] Fix scrolling in touch mode
https://bugs.webkit.org/show_bug.cgi?id=75006

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-05-15
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

  • page/FrameView.cpp:

(WebCore::FrameView::setFixedVisibleContentRect):

On changes to fixedVisibleContentRect update scroll-animators position, and
recalculate page-step sizes in scrollbars.

  • platform/ScrollView.cpp:

(WebCore::ScrollView::scrollTo):

Forward scrolling-request to the host window.

(WebCore::ScrollView::updateScrollbars):

Allow ScrollViews to have invisible scrollbars when scrolling is delegated.

  • platform/ScrollView.h:

(ScrollView):

Source/WebKit2:

Only handle mouse-wheel events in WebCore to avoid double scrolling, and
scale pixels scrolled by wheel events according to viewport transformation.

  • Shared/qt/WebEventFactoryQt.cpp:

(WebKit::WebEventFactory::createWebWheelEvent):

  • UIProcess/qt/QtViewportInteractionEngine.cpp:
  • UIProcess/qt/QtViewportInteractionEngine.h:

(QtViewportInteractionEngine):

  • UIProcess/qt/QtWebPageEventHandler.cpp:

(QtWebPageEventHandler::handleWheelEvent):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117065 r117069  
     12012-05-15  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
     2
     3        [Qt][WK2] Fix scrolling in touch mode
     4        https://bugs.webkit.org/show_bug.cgi?id=75006
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        * page/FrameView.cpp:
     9        (WebCore::FrameView::setFixedVisibleContentRect):
     10            On changes to fixedVisibleContentRect update scroll-animators position, and
     11            recalculate page-step sizes in scrollbars.
     12        * platform/ScrollView.cpp:
     13        (WebCore::ScrollView::scrollTo):
     14            Forward scrolling-request to the host window.
     15        (WebCore::ScrollView::updateScrollbars):
     16            Allow ScrollViews to have invisible scrollbars when scrolling is delegated.
     17        * platform/ScrollView.h:
     18        (ScrollView):
     19
    1202012-05-15  Vsevolod Vlasov  <vsevik@chromium.org>
    221
  • trunk/Source/WebCore/page/FrameView.cpp

    r117032 r117069  
    17231723void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect)
    17241724{
     1725    bool visibleContentSizeDidChange = false;
    17251726    if (visibleContentRect.size() != this->fixedVisibleContentRect().size()) {
    17261727        // When the viewport size changes or the content is scaled, we need to
     
    17281729        if (RenderView* root = rootRenderer(this))
    17291730            root->setFixedPositionedObjectsNeedLayout();
     1731        visibleContentSizeDidChange = true;
    17301732    }
    17311733
     
    17351737        if (m_frame->page()->settings()->acceleratedCompositingForFixedPositionEnabled())
    17361738            updateFixedElementsAfterScrolling();
     1739        scrollAnimator()->setCurrentPosition(scrollPosition());
    17371740        scrollPositionChanged();
     1741    }
     1742    if (visibleContentSizeDidChange) {
     1743        // Update the scroll-bars to calculate new page-step size.
     1744        updateScrollbars(scrollOffset());
    17381745    }
    17391746    frame()->loader()->client()->didChangeScrollOffset();
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r115401 r117069  
    372372
    373373    repaintFixedElementsAfterScrolling();
     374#if USE(TILED_BACKING_STORE)
     375    if (delegatesScrolling()) {
     376        hostWindow()->delegatedScrollRequested(IntPoint(newOffset));
     377        return;
     378    }
     379#endif
    374380    scrollContents(scrollDelta);
    375381    updateFixedElementsAfterScrolling();
     
    454460void ScrollView::updateScrollbars(const IntSize& desiredOffset)
    455461{
    456     if (m_inUpdateScrollbars || prohibitsScrolling() || delegatesScrolling() || platformWidget())
     462    if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget())
    457463        return;
    458464
  • trunk/Source/WebCore/platform/ScrollView.h

    r116688 r117069  
    314314    virtual bool isFlippedDocument() const { return false; }
    315315
     316    // Called to update the scrollbars to accurately reflect the state of the view.
     317    void updateScrollbars(const IntSize& desiredOffset);
     318
    316319private:
    317320    RefPtr<Scrollbar> m_horizontalScrollbar;
     
    356359    void destroy();
    357360
    358     // Called to update the scrollbars to accurately reflect the state of the view.
    359     void updateScrollbars(const IntSize& desiredOffset);
    360361    IntRect rectToCopyOnScroll() const;
    361362
  • trunk/Source/WebKit2/ChangeLog

    r117061 r117069  
     12012-05-15  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
     2
     3        [Qt][WK2] Fix scrolling in touch mode
     4        https://bugs.webkit.org/show_bug.cgi?id=75006
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Only handle mouse-wheel events in WebCore to avoid double scrolling, and
     9        scale pixels scrolled by wheel events according to viewport transformation.
     10
     11        * Shared/qt/WebEventFactoryQt.cpp:
     12        (WebKit::WebEventFactory::createWebWheelEvent):
     13        * UIProcess/qt/QtViewportInteractionEngine.cpp:
     14        * UIProcess/qt/QtViewportInteractionEngine.h:
     15        (QtViewportInteractionEngine):
     16        * UIProcess/qt/QtWebPageEventHandler.cpp:
     17        (QtWebPageEventHandler::handleWheelEvent):
     18
    1192012-05-15  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    220
  • trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp

    r114917 r117069  
    2828#include "WebEventFactoryQt.h"
    2929#include <QKeyEvent>
     30#include <QLineF>
    3031#include <QTransform>
     32#include <WebCore/FloatPoint.h>
     33#include <WebCore/FloatSize.h>
    3134#include <WebCore/IntPoint.h>
    32 #include <WebCore/FloatPoint.h>
    3335#include <WebCore/PlatformKeyboardEvent.h>
    3436#include <wtf/ASCIICType.h>
     
    150152    deltaY = wheelTicksY * wheelScrollLines * cDefaultQtScrollStep;
    151153
    152     return WebWheelEvent(WebEvent::Wheel, fromItemTransform.map(e->posF()).toPoint(), e->globalPosF().toPoint(), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp);
     154    // Transform the position and the pixel scrolling distance.
     155    QLineF transformedScroll = fromItemTransform.map(QLineF(e->posF(), e->posF() + QPointF(deltaX, deltaY)));
     156    IntPoint transformedPoint = transformedScroll.p1().toPoint();
     157    IntPoint globalPoint = e->globalPosF().toPoint();
     158    FloatSize transformedDelta(transformedScroll.dx(), transformedScroll.dy());
     159    FloatSize wheelTicks(wheelTicksX, wheelTicksY);
     160    return WebWheelEvent(WebEvent::Wheel, transformedPoint, globalPoint, transformedDelta, wheelTicks, granularity, modifiers, timestamp);
    153161}
    154162
  • trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp

    r117061 r117069  
    262262}
    263263
    264 void QtViewportInteractionEngine::wheelEvent(QWheelEvent* ev)
    265 {
    266     if (scrollAnimationActive() || scaleAnimationActive() || pinchGestureActive())
    267         return; // Ignore.
    268 
    269 
    270     // A normal scroll-tick should have a delta of 120 (1/8) degrees. Convert this to
    271     // local standard scroll step of 3 lines of 20 pixels.
    272     static const int cDefaultQtScrollStep = 20;
    273     static const int wheelScrollLines = 3;
    274     const int wheelTick = wheelScrollLines * cDefaultQtScrollStep;
    275 
    276     int pixelDelta = ev->delta() * (wheelTick / 120.f);
    277 
    278     QPointF newPosition = m_viewport->contentPos();
    279 
    280     if (ev->orientation() == Qt::Horizontal)
    281         newPosition.rx() -= pixelDelta;
    282     else
    283         newPosition.ry() -= pixelDelta;
    284 
    285     QRectF endPosRange = computePosRangeForItemAtScale(m_content->contentsScale());
    286 
    287     QPointF currentPosition = m_viewport->contentPos();
    288     newPosition = boundPosition(endPosRange.topLeft(), newPosition, endPosRange.bottomRight());
    289     m_viewport->setContentPos(newPosition);
    290 
    291     emit contentViewportChanged(currentPosition - newPosition);
    292 }
    293 
    294264void QtViewportInteractionEngine::pagePositionRequest(const QPoint& pagePosition)
    295265{
  • trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h

    r117061 r117069  
    6666    bool animateItemRectVisible(const QRectF&);
    6767
    68     void wheelEvent(QWheelEvent*);
    6968    void pagePositionRequest(const QPoint& pos);
    7069    void touchBegin();
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp

    r115973 r117069  
    155155    QTransform fromItemTransform = m_webPage->transformFromItem();
    156156    m_webPageProxy->handleWheelEvent(NativeWebWheelEvent(ev, fromItemTransform));
    157     // FIXME: Handle whether the page used the wheel event or not.
    158     if (m_interactionEngine)
    159         m_interactionEngine->wheelEvent(ev);
    160157}
    161158
Note: See TracChangeset for help on using the changeset viewer.