⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181510 in webkit


Ignore:
Timestamp:
Mar 15, 2015, 12:13:36 PM (11 years ago)
Author:
Brent Fulgham
Message:

scroll snap points do not properly account for zoomed pages
https://bugs.webkit.org/show_bug.cgi?id=142706
<rdar://problem/20165771>

Reviewed by Anders Carlsson.

When a WebView is zoomed (such that it has a non-unity pageScaleFactor), we need to account for this
scaling value when selecting our correct scroll snap point target, as well as when specifying the
pixel location for our animation to target.

  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:

(WebCore::ScrollingTreeFrameScrollingNodeMac::pageScaleFactor): Added new delegate method.

  • platform/cocoa/ScrollController.h:

(WebCore::ScrollControllerClient::pageScaleFactor): Added new default delegate.

  • platform/cocoa/ScrollController.mm:

(WebCore::ScrollController::beginScrollSnapAnimation): Calculate the correct scroll target
based on the page scale factor.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181508 r181510  
     12015-03-15  Brent Fulgham  <bfulgham@apple.com>
     2
     3        scroll snap points do not properly account for zoomed pages
     4        https://bugs.webkit.org/show_bug.cgi?id=142706
     5        <rdar://problem/20165771>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        When a WebView is zoomed (such that it has a non-unity pageScaleFactor), we need to account for this
     10        scaling value when selecting our correct scroll snap point target, as well as when specifying the
     11        pixel location for our animation to target.
     12
     13        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
     14        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     15        (WebCore::ScrollingTreeFrameScrollingNodeMac::pageScaleFactor): Added new delegate method.
     16        * platform/cocoa/ScrollController.h:
     17        (WebCore::ScrollControllerClient::pageScaleFactor): Added new default delegate.
     18        * platform/cocoa/ScrollController.mm:
     19        (WebCore::ScrollController::beginScrollSnapAnimation): Calculate the correct scroll target
     20        based on the page scale factor.
     21
    1222015-03-15  Csaba Osztrogonác  <ossy@webkit.org>
    223
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h

    r181087 r181510  
    8383    LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const override;
    8484    void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
     85    float pageScaleFactor() const override;
    8586#endif
    8687
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r181087 r181510  
    559559    immediateScrollBy(change - currentPosition);
    560560}
     561
     562float ScrollingTreeFrameScrollingNodeMac::pageScaleFactor() const
     563{
     564    return frameScaleFactor();
     565}
    561566#endif
    562567
  • trunk/Source/WebCore/platform/cocoa/ScrollController.h

    r181087 r181510  
    8787    {
    8888        // Override to perform client-specific scroll snap point end logic
    89        
     89    }
     90
     91    virtual float pageScaleFactor() const
     92    {
     93        return 1.0f;
    9094    }
    9195#endif
  • trunk/Source/WebCore/platform/cocoa/ScrollController.mm

    r181300 r181510  
    685685        return;
    686686
    687     projectedScrollDestination = std::min(std::max(projectedScrollDestination, snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
     687    float scaleFactor = m_client->pageScaleFactor();
     688   
     689    projectedScrollDestination = std::min(std::max(LayoutUnit(projectedScrollDestination / scaleFactor), snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
    688690    snapState.m_initialOffset = offset;
    689     snapState.m_targetOffset = closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta);
     691    snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta);
    690692    if (snapState.m_initialOffset == snapState.m_targetOffset)
    691693        return;
Note: See TracChangeset for help on using the changeset viewer.