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

Changeset 181504 in webkit


Ignore:
Timestamp:
Mar 14, 2015, 10:11:19 PM (11 years ago)
Author:
Brent Fulgham
Message:

Source/WebCore:
[iOS] scroll snap points are animating to the wrong positions...
https://bugs.webkit.org/show_bug.cgi?id=142705
<rdar://problem/20136946>

Reviewed by Simon Fraser.

Avoid adding an extra '0' snap point to our set. We always start with one zero; this
extra append just forces us to do more steps in our search for nearest snap point.

  • page/scrolling/AxisScrollSnapOffsets.cpp:

(WebCore::updateFromStyle): Remove extra '0' appended to offsets.

Source/WebKit2:
[iOS] scroll snap points are animating to the wrong positions.
https://bugs.webkit.org/show_bug.cgi?id=142705
<rdar://problem/20136946>

Reviewed by Simon Fraser.

Scroll snapping was landing in the wrong place on iOS because of two problems:
(1) It was searching for the closest snap offset point using unscaled 'screen' pixels,
which caused it to always choose one of the earliest snap point options.
(2) It was then selecting a scaled snap point coordinate and passing it back to UIKit
to animate the snap. This caused it to select a target point beyond the 'screen' pixel
we want to hit.

The solution to both problems are to scale the scroll destination UIKit suggests so that
we search among the scaled points with a valid value. Then, we need to scale the returned
value back to screen units before handing it back to UIKit to process.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView scrollViewWillBeginDragging:]): Drive-by fix. Get rid of extra ';' at
the end of the line.

  • UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:

(WebKit::RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181502 r181504  
     12015-03-14  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [iOS] scroll snap points are animating to the wrong positions...
     4        https://bugs.webkit.org/show_bug.cgi?id=142705
     5        <rdar://problem/20136946>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Avoid adding an extra '0' snap point to our set. We always start with one zero; this
     10        extra append just forces us to do more steps in our search for nearest snap point.
     11
     12        * page/scrolling/AxisScrollSnapOffsets.cpp:
     13        (WebCore::updateFromStyle): Remove extra '0' appended to offsets.
     14
    1152015-03-14  Dean Jackson  <dino@apple.com>
    216
  • trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp

    r181194 r181504  
    8484    LayoutUnit maxScrollOffset = scrollSize - viewSize;
    8585    LayoutUnit lastSnapPosition = curSnapPositionShift;
    86     snapOffsets.append(0);
    8786    do {
    8887        for (auto& snapPosition : snapOffsetSubsequence) {
     
    9998        curSnapPositionShift = lastSnapPosition + repeatOffset;
    10099    } while (hasRepeat && curSnapPositionShift < maxScrollOffset);
     100
     101    if (snapOffsets.isEmpty())
     102        snapOffsets.append(0);
     103
    101104    // Always put a snap point on the maximum scroll offset.
    102105    // Not a part of the spec, but necessary to prevent unreachable content when snapping.
  • trunk/Source/WebKit2/ChangeLog

    r181502 r181504  
     12015-03-14  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [iOS] scroll snap points are animating to the wrong positions.
     4        https://bugs.webkit.org/show_bug.cgi?id=142705
     5        <rdar://problem/20136946>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Scroll snapping was landing in the wrong place on iOS because of two problems:
     10        (1) It was searching for the closest snap offset point using unscaled 'screen' pixels,
     11        which caused it to always choose one of the earliest snap point options.
     12        (2) It was then selecting a scaled snap point coordinate and passing it back to UIKit
     13        to animate the snap. This caused it to select a target point beyond the 'screen' pixel
     14        we want to hit.
     15       
     16        The solution to both problems are to scale the scroll destination UIKit suggests so that
     17        we search among the scaled points with a valid value. Then, we need to scale the returned
     18        value back to screen units before handing it back to UIKit to process.
     19
     20        * UIProcess/API/Cocoa/WKWebView.mm:
     21        (-[WKWebView scrollViewWillBeginDragging:]): Drive-by fix. Get rid of extra ';' at
     22        the end of the line.
     23        * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
     24        (WebKit::RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling):
     25
    1262015-03-14  Dean Jackson  <dino@apple.com>
    227
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r181443 r181504  
    13401340    WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy();
    13411341    ASSERT(scrollView == _scrollView.get());
    1342     scrollView.decelerationRate = (coordinator && coordinator->shouldSetScrollViewDecelerationRateFast()) ? UIScrollViewDecelerationRateFast : [_scrollView preferredScrollDecelerationFactor];;
     1342    scrollView.decelerationRate = (coordinator && coordinator->shouldSetScrollViewDecelerationRateFast()) ? UIScrollViewDecelerationRateFast : [_scrollView preferredScrollDecelerationFactor];
    13431343#endif
    13441344}
  • trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm

    r174340 r181504  
    150150    ScrollingTreeFrameScrollingNode* rootFrame = static_cast<ScrollingTreeFrameScrollingNode*>(root);
    151151    const Vector<float>& snapOffsets = axis == ScrollEventAxis::Horizontal ? rootFrame->horizontalSnapOffsets() : rootFrame->verticalSnapOffsets();
    152     return closestSnapOffset<float, float>(snapOffsets, scrollDestination, velocity);
     152
     153    float scaledScrollDestination = scrollDestination / m_webPageProxy.displayedContentScale();
     154    float rawClosestSnapOffset = closestSnapOffset<float, float>(snapOffsets, scaledScrollDestination, velocity);
     155    return rawClosestSnapOffset * m_webPageProxy.displayedContentScale();
    153156}
    154157#endif
Note: See TracChangeset for help on using the changeset viewer.