Changeset 165652 in webkit


Ignore:
Timestamp:
Mar 14, 2014 2:50:57 PM (10 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Improve behavior of fixed elments on zooming
https://bugs.webkit.org/show_bug.cgi?id=130253

Reviewed by Beth Dakin.

Correctly reposition right- and bottom-relative position:fixed
elements on zooming in WK2 iOS by telling the scrolling tree
about zoom-related viewport changes.

Source/WebCore:

  • WebCore.exp.in:
  • page/FrameView.cpp:

(WebCore::FrameView::rectForViewportConstrainedObjects):
(WebCore::FrameView::viewportConstrainedObjectsRect): We need to be able to
recompute the fixed position rect from the scrolling tree on iOS, so we need
a static function, similar to scrollOffsetForFixedPosition(), that computes
the constrained viewport.

  • page/FrameView.h:
  • page/Page.cpp:

(WebCore::Page::setPageScaleFactor): When scrolling (and, by implication, zooming)
is delegated, then setPageScaleFactor() should not affect the scroll position.

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated): Go back to just
passing the visibleContentRect() for iOS.

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling): Entrypoint to
the scrolling tree, called when the viewport is changed by zooming.

  • page/scrolling/ScrollingTree.h:
  • page/scrolling/ScrollingTreeScrollingNode.h:
  • page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h:
  • page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:

(WebCore::ScrollingTreeScrollingNodeIOS::setScrollLayerPosition): Use the
new FrameView::rectForViewportConstrainedObjects() to compute the correct viewport
for fixed/sticky child nodes.
(WebCore::ScrollingTreeScrollingNodeIOS::updateForViewport):

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

(WebCore::ScrollingTreeScrollingNodeMac::updateForViewport):

Source/WebKit2:

  • Shared/mac/RemoteLayerTreeTransaction.h:

(WebKit::RemoteLayerTreeTransaction::LayerProperties::notePropertiesChanged):
Drive-by cleanup; typedef the flags field to an unsigned, to avoid ugly casting.

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:

(WebKit::RemoteScrollingCoordinatorProxy::updateScrollingTree): Pass out a flag to say
if the update contained a new fixed or sticky layer.
(WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
(WebKit::RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling):
Call into the new ScrolingTree::viewportChangedViaDelegatedScrolling().

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
  • UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm: If we got a new fixed

or sticky layer, set fixedOrStickyLayerChanged to true.
(WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers): Ditto.

  • UIProcess/ios/WKContentView.mm:

(-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:inStableState:]):
Remember both the old zoomScale and the filteredScale, since the fixed position rect
should be computed using the unfiltered scale.
Some FloatRect -> CGRect changes.
Now call viewportChangedViaDelegatedScrolling() on the scrolling coordinator.
(-[WKContentView fixedPositionRectFromExposedRect:scale:]): Call the
FrameView function to compute the iOS fixed position rect.

  • UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:

(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): If the update
got a new fixed or sticky layer, run the scrolling tree logic to make sure
it gets into the right place.

  • UIProcess/mac/RemoteLayerTreeHost.mm:

(WebKit::RemoteLayerTreeHost::updateLayerTree): If we logged here,
we'd log twice if the tiled scrolling indicator was enabled, so
hoisted the logging out into the caller.

Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r165651 r165652  
     12014-03-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Improve behavior of fixed elments on zooming
     4        https://bugs.webkit.org/show_bug.cgi?id=130253
     5
     6        Reviewed by Beth Dakin.
     7
     8        Correctly reposition right- and bottom-relative position:fixed
     9        elements on zooming in WK2 iOS by telling the scrolling tree
     10        about zoom-related viewport changes.
     11
     12        * WebCore.exp.in:
     13        * page/FrameView.cpp:
     14        (WebCore::FrameView::rectForViewportConstrainedObjects):
     15        (WebCore::FrameView::viewportConstrainedObjectsRect): We need to be able to
     16        recompute the fixed position rect from the scrolling tree on iOS, so we need
     17        a static function, similar to scrollOffsetForFixedPosition(), that computes
     18        the constrained viewport.
     19        * page/FrameView.h:
     20        * page/Page.cpp:
     21        (WebCore::Page::setPageScaleFactor): When scrolling (and, by implication, zooming)
     22        is delegated, then setPageScaleFactor() should not affect the scroll position.
     23        * page/scrolling/AsyncScrollingCoordinator.cpp:
     24        (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated): Go back to just
     25        passing the visibleContentRect() for iOS.
     26        * page/scrolling/ScrollingTree.cpp:
     27        (WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling): Entrypoint to
     28        the scrolling tree, called when the viewport is changed by zooming.
     29        * page/scrolling/ScrollingTree.h:
     30        * page/scrolling/ScrollingTreeScrollingNode.h:
     31        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h:
     32        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:
     33        (WebCore::ScrollingTreeScrollingNodeIOS::setScrollLayerPosition): Use the
     34        new FrameView::rectForViewportConstrainedObjects() to compute the correct viewport
     35        for fixed/sticky child nodes.
     36        (WebCore::ScrollingTreeScrollingNodeIOS::updateForViewport):
     37        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.h:
     38        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
     39        (WebCore::ScrollingTreeScrollingNodeMac::updateForViewport):
     40
    1412014-03-14  Dirk Schulze  <krit@webkit.org>
    242
  • trunk/Source/WebCore/WebCore.exp.in

    r165640 r165652  
    807807__ZN7WebCore19TextResourceDecoderC1ERKN3WTF6StringERKNS_12TextEncodingEb
    808808__ZN7WebCore19TextResourceDecoderD1Ev
     809__ZN7WebCore19enclosingLayoutRectERKNS_9FloatRectE
    809810__ZN7WebCore19getFileCreationTimeERKN3WTF6StringERl
    810811__ZN7WebCore19toInt32EnforceRangeEPN3JSC9ExecStateENS0_7JSValueE
     
    26142615__ZN7WebCore9FrameView30graphicsLayerForPlatformWidgetEP7WAKView
    26152616__ZN7WebCore9FrameView32setCustomFixedPositionLayoutRectERKNS_7IntRectE
     2617__ZN7WebCore9FrameView33rectForViewportConstrainedObjectsERKNS_10LayoutRectERKNS_10LayoutSizeEfbNS_30ScrollBehaviorForFixedElementsE
    26162618__ZN7WebCore9FrameView35setUseCustomFixedPositionLayoutRectEb
    26172619__ZN7WebCore9FrameView36scheduleLayerFlushAllowingThrottlingEv
     
    27222724__ZN7WebCore13ScrollingTree32isPointInNonFastScrollableRegionENS_8IntPointE
    27232725__ZN7WebCore13ScrollingTree35shouldHandleWheelEventSynchronouslyERKNS_18PlatformWheelEventE
     2726__ZN7WebCore13ScrollingTree36viewportChangedViaDelegatedScrollingEyRKNS_9FloatRectEd
    27242727__ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb
    2725 __ZN7WebCore13ScrollingTree42scrollPositionChangedViaDelegatedScrollingEyRKNS_10FloatPointE
    27262728__ZN7WebCore13ScrollingTreeC2Ev
    27272729__ZN7WebCore13ScrollingTreeD1Ev
  • trunk/Source/WebCore/page/FrameView.cpp

    r165548 r165652  
    15851585}
    15861586   
     1587#if PLATFORM(IOS)
     1588LayoutRect FrameView::rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements scrollBehavior)
     1589{
     1590    if (fixedElementsLayoutRelativeToFrame)
     1591        return visibleContentRect;
     1592   
     1593    // We impose an lower limit on the size (so an upper limit on the scale) of
     1594    // the rect used to position fixed objects so that they don't crowd into the
     1595    // center of the screen at larger scales.
     1596    const float constraintThresholdScale = 1.2;
     1597
     1598    float maxPostionedObjectsRectScale = std::min(frameScaleFactor, constraintThresholdScale);
     1599
     1600    LayoutRect viewportConstrainedObjectsRect = visibleContentRect;
     1601
     1602    if (frameScaleFactor > constraintThresholdScale) {
     1603        FloatRect contentRect(FloatPoint(), totalContentsSize);
     1604        FloatRect viewportRect = visibleContentRect;
     1605       
     1606        // Scale the rect up from a point that is relative to its position in the viewport.
     1607        FloatSize sizeDelta = contentRect.size() - viewportRect.size();
     1608
     1609        FloatPoint scaleOrigin;
     1610        scaleOrigin.setX(contentRect.x() + sizeDelta.width() > 0 ? contentRect.width() * (viewportRect.x() - contentRect.x()) / sizeDelta.width() : 0);
     1611        scaleOrigin.setY(contentRect.y() + sizeDelta.height() > 0 ? contentRect.height() * (viewportRect.y() - contentRect.y()) / sizeDelta.height() : 0);
     1612       
     1613        AffineTransform rescaleTransform = AffineTransform::translation(scaleOrigin.x(), scaleOrigin.y());
     1614        rescaleTransform.scale(frameScaleFactor / maxPostionedObjectsRectScale, frameScaleFactor / maxPostionedObjectsRectScale);
     1615        rescaleTransform = CGAffineTransformTranslate(rescaleTransform, -scaleOrigin.x(), -scaleOrigin.y());
     1616
     1617        viewportConstrainedObjectsRect = enclosingLayoutRect(rescaleTransform.mapRect(visibleContentRect));
     1618    }
     1619   
     1620    if (scrollBehavior == StickToDocumentBounds) {
     1621        LayoutRect documentBounds(LayoutPoint(), totalContentsSize);
     1622        viewportConstrainedObjectsRect.intersect(documentBounds);
     1623    }
     1624
     1625    return viewportConstrainedObjectsRect;
     1626}
     1627   
     1628LayoutRect FrameView::viewportConstrainedObjectsRect() const
     1629{
     1630    return rectForViewportConstrainedObjects(visibleContentRect(), totalContentsSize(), frame().frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), scrollBehaviorForFixedElements());
     1631}
     1632#endif
     1633   
    15871634IntPoint FrameView::minimumScrollPosition() const
    15881635{
  • trunk/Source/WebCore/page/FrameView.h

    r165534 r165652  
    266266    // Static function can be called from another thread.
    267267    static LayoutSize scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
    268 
     268   
     269#if PLATFORM(IOS)
     270    LayoutRect viewportConstrainedObjectsRect() const;
     271    // Static function can be called from another thread.
     272    static LayoutRect rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements);
     273#endif
     274   
    269275    bool fixedElementsLayoutRelativeToFrame() const;
    270276
  • trunk/Source/WebCore/page/Page.cpp

    r165629 r165652  
    724724        if (!m_settings->delegatesPageScaling() && document->renderView() && document->renderView()->needsLayout() && view->didFirstLayout())
    725725            view->layout();
    726         view->setScrollPosition(origin);
     726       
     727        if (!view->delegatesScrolling())
     728            view->setScrollPosition(origin);
    727729    }
    728730}
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r165493 r165652  
    9090
    9191    node->setScrollOrigin(frameView->scrollOrigin());
    92 #if PLATFORM(IOS)
    93     node->setViewportSize(frameView->viewportConstrainedVisibleContentRect().size());
    94 #else
    9592    node->setViewportSize(frameView->visibleContentRect().size());
    96 #endif
    9793    node->setTotalContentsSize(frameView->totalContentsSize());
    9894
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r165091 r165652  
    9999}
    100100
    101 void ScrollingTree::scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const FloatPoint& scrollPosition)
     101void ScrollingTree::viewportChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatRect& viewportRect, double scale)
    102102{
    103103    ScrollingTreeNode* node = nodeForID(nodeID);
     
    108108        return;
    109109
    110     toScrollingTreeScrollingNode(node)->setScrollPositionWithoutContentEdgeConstraints(scrollPosition);
     110    toScrollingTreeScrollingNode(node)->updateForViewport(viewportRect, scale);
    111111}
    112112
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r165086 r165652  
    6464    bool shouldHandleWheelEventSynchronously(const PlatformWheelEvent&);
    6565   
    66     virtual void scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID, const FloatPoint&);
     66    virtual void viewportChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatRect& viewportRect, double scale);
    6767
    6868    void setMainFrameIsRubberBanding(bool);
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r165493 r165652  
    5353    virtual void setScrollPosition(const FloatPoint&) = 0;
    5454    virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) = 0;
    55 
     55    virtual void updateForViewport(const FloatRect& viewportRect, double scale) = 0;
     56   
    5657    SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
    5758    bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; }
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h

    r165091 r165652  
    5252    virtual void setScrollPosition(const FloatPoint&) override;
    5353    virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) override;
     54    virtual void updateForViewport(const FloatRect& viewportRect, double scale);
    5455
    5556    void setScrollLayerPosition(const FloatPoint&);
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm

    r165493 r165652  
    161161    if (!m_children)
    162162        return;
    163 
    164     viewportRect.setLocation(FloatPoint() + scrollOffsetForFixedChildren);
    165 
     163   
     164    viewportRect.setLocation(scrollOffset);
     165   
     166    FloatRect viewportConstrainedObjectsRect = FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(viewportRect), totalContentsSize(), frameScaleFactor(), false, behaviorForFixed);
     167   
    166168    size_t size = m_children->size();
    167169    for (size_t i = 0; i < size; ++i)
    168         m_children->at(i)->parentScrollPositionDidChange(viewportRect, FloatSize());
     170        m_children->at(i)->parentScrollPositionDidChange(viewportConstrainedObjectsRect, FloatSize());
     171}
     172
     173void ScrollingTreeScrollingNodeIOS::updateForViewport(const FloatRect& viewportRect, double scale)
     174{
     175    if (!m_children)
     176        return;
     177
     178    FloatRect viewportConstrainedObjectsRect = FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(viewportRect), totalContentsSize(), scale, false, scrollBehaviorForFixedElements());
     179
     180    size_t size = m_children->size();
     181    for (size_t i = 0; i < size; ++i)
     182        m_children->at(i)->parentScrollPositionDidChange(viewportConstrainedObjectsRect, FloatSize());
    169183}
    170184
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.h

    r165091 r165652  
    6969    virtual void setScrollPosition(const FloatPoint&) override;
    7070    virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) override;
     71    virtual void updateForViewport(const FloatRect& viewportRect, double scale) override;
    7172
    7273    void setScrollLayerPosition(const FloatPoint&);
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm

    r165493 r165652  
    401401}
    402402
     403void ScrollingTreeScrollingNodeMac::updateForViewport(const FloatRect& viewportRect, double scale)
     404{
     405    // FIXME: correctly handle updates for zooming.
     406    UNUSED_PARAM(scale);
     407    FloatPoint scrollPosition = viewportRect.location();
     408    updateMainFramePinState(scrollPosition);
     409
     410    if (shouldUpdateScrollLayerPositionSynchronously()) {
     411        m_probableMainThreadScrollPosition = scrollPosition;
     412        scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, SetScrollingLayerPosition);
     413        return;
     414    }
     415
     416    setScrollLayerPosition(scrollPosition);
     417    scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition);
     418}
     419
    403420FloatPoint ScrollingTreeScrollingNodeMac::minimumScrollPosition() const
    404421{
  • trunk/Source/WebKit2/ChangeLog

    r165647 r165652  
     12014-03-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Improve behavior of fixed elments on zooming
     4        https://bugs.webkit.org/show_bug.cgi?id=130253
     5
     6        Reviewed by Beth Dakin.
     7
     8        Correctly reposition right- and bottom-relative position:fixed
     9        elements on zooming in WK2 iOS by telling the scrolling tree
     10        about zoom-related viewport changes.
     11
     12        * Shared/mac/RemoteLayerTreeTransaction.h:
     13        (WebKit::RemoteLayerTreeTransaction::LayerProperties::notePropertiesChanged):
     14        Drive-by cleanup; typedef the flags field to an unsigned, to avoid ugly casting.
     15        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
     16        (WebKit::RemoteScrollingCoordinatorProxy::updateScrollingTree): Pass out a flag to say
     17        if the update contained a new fixed or sticky layer.
     18        (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
     19        (WebKit::RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling):
     20        Call into the new ScrolingTree::viewportChangedViaDelegatedScrolling().
     21        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
     22        * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm: If we got a new fixed
     23        or sticky layer, set fixedOrStickyLayerChanged to true.
     24        (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers): Ditto.
     25        * UIProcess/ios/WKContentView.mm:
     26        (-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:inStableState:]):
     27        Remember both the old zoomScale and the filteredScale, since the fixed position rect
     28        should be computed using the unfiltered scale.
     29        Some FloatRect -> CGRect changes.
     30        Now call viewportChangedViaDelegatedScrolling() on the scrolling coordinator.
     31        (-[WKContentView fixedPositionRectFromExposedRect:scale:]): Call the
     32        FrameView function to compute the iOS fixed position rect.
     33        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
     34        (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): If the update
     35        got a new fixed or sticky layer, run the scrolling tree logic to make sure
     36        it gets into the right place.
     37        * UIProcess/mac/RemoteLayerTreeHost.mm:
     38        (WebKit::RemoteLayerTreeHost::updateLayerTree): If we logged here,
     39        we'd log twice if the tiled scrolling indicator was enabled, so
     40        hoisted the logging out into the caller.
     41
    1422014-03-14  Landry Breuil  <landry@openbsd.org>
    243
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r165409 r165652  
    4848class RemoteLayerTreeTransaction {
    4949public:
    50     enum LayerChange {
     50    enum LayerChanges {
    5151        NoChange = 0,
    5252        NameChanged = 1 << 1,
     
    7878        CustomAppearanceChanged = 1 << 27
    7979    };
     80    typedef unsigned LayerChange;
    8081
    8182    struct LayerCreationProperties {
     
    9899        static bool decode(IPC::ArgumentDecoder&, LayerProperties&);
    99100
    100         void notePropertiesChanged(LayerChange layerChanges)
     101        void notePropertiesChanged(LayerChange changeFlags)
    101102        {
    102             changedProperties = static_cast<LayerChange>(changedProperties | layerChanges);
    103             everChangedProperties = static_cast<LayerChange>(everChangedProperties | layerChanges);
     103            changedProperties |= changeFlags;
     104            everChangedProperties |= changeFlags;
    104105        }
    105106
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp

    r165086 r165652  
    7676}
    7777
    78 void RemoteScrollingCoordinatorProxy::updateScrollingTree(const RemoteScrollingCoordinatorTransaction& transaction)
     78void RemoteScrollingCoordinatorProxy::updateScrollingTree(const RemoteScrollingCoordinatorTransaction& transaction, bool& fixedOrStickyLayerChanged)
    7979{
    8080    OwnPtr<ScrollingStateTree> stateTree = const_cast<RemoteScrollingCoordinatorTransaction&>(transaction).scrollingStateTree().release();
     
    8585        return;
    8686    }
    87    
    88     connectStateNodeLayers(*stateTree, *layerTreeHost);
     87
     88    connectStateNodeLayers(*stateTree, *layerTreeHost, fixedOrStickyLayerChanged);
    8989    m_scrollingTree->commitNewTreeState(stateTree.release());
    9090}
    9191
    9292#if !PLATFORM(IOS)
    93 void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost)
     93void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost, bool& fixedOrStickyLayerChanged)
    9494{
    9595    for (auto& currNode : stateTree.nodeMap().values()) {
     
    116116        }
    117117        case FixedNode:
    118             if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
     118            if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) {
    119119                currNode->setLayer(layerTreeHost.getLayer(currNode->layer()));
     120                fixedOrStickyLayerChanged = true;
     121            }
    120122            break;
    121123        case StickyNode:
    122             if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
     124            if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) {
    123125                currNode->setLayer(layerTreeHost.getLayer(currNode->layer()));
     126                fixedOrStickyLayerChanged = true;
     127            }
    124128            break;
    125129        }
     
    139143}
    140144
    141 void RemoteScrollingCoordinatorProxy::scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const FloatPoint& offset)
     145void RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatRect& viewportRect, double scale)
    142146{
    143     m_scrollingTree->scrollPositionChangedViaDelegatedScrolling(nodeID, offset);
     147    m_scrollingTree->viewportChangedViaDelegatedScrolling(nodeID, viewportRect, scale);
    144148}
    145149
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h

    r165086 r165652  
    5858
    5959    // Called externally when native views move around.
    60     void scrollPositionChangedViaDelegatedScrolling(WebCore::ScrollingNodeID, const WebCore::FloatPoint&);
     60    void viewportChangedViaDelegatedScrolling(WebCore::ScrollingNodeID, const WebCore::FloatRect& viewportRect, double scale);
    6161
    6262    // FIXME: expose the tree and pass this to that?
     
    6767    const RemoteLayerTreeHost* layerTreeHost() const;
    6868
    69     void updateScrollingTree(const RemoteScrollingCoordinatorTransaction&);
     69    void updateScrollingTree(const RemoteScrollingCoordinatorTransaction&, bool& fixedOrStickyLayerChanged);
    7070
    7171private:
    72     void connectStateNodeLayers(WebCore::ScrollingStateTree&, const RemoteLayerTreeHost&);
     72    void connectStateNodeLayers(WebCore::ScrollingStateTree&, const RemoteLayerTreeHost&, bool& fixedOrStickyLayerChanged);
    7373
    7474    WebPageProxy& m_webPageProxy;
  • trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm

    r164890 r165652  
    4444}
    4545
    46 void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost)
     46void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost, bool& fixedOrStickyLayerChanged)
    4747{
    4848    for (auto& currNode : stateTree.nodeMap().values()) {
     
    6969        }
    7070        case FixedNode:
    71             if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
     71            if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) {
    7272                currNode->setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(currNode->layer())));
     73                fixedOrStickyLayerChanged = true;
     74            }
    7375            break;
    7476        case StickyNode:
    75             if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
     77            if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) {
    7678                currNode->setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(currNode->layer())));
     79                fixedOrStickyLayerChanged = true;
     80            }
    7781            break;
    7882        }
  • trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm

    r165303 r165652  
    4747#import "WebSystemInterface.h"
    4848#import "WebKitSystemInterfaceIOS.h"
     49#import <WebCore/FrameView.h>
    4950#import <UIKit/UIWindow_Private.h>
    5051#import <wtf/RetainPtr.h>
     
    164165}
    165166
    166 - (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale inStableState:(BOOL)isStableState
     167- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)zoomScale inStableState:(BOOL)isStableState
    167168{
    168169    double scaleNoiseThreshold = 0.0005;
    169     if (!isStableState && fabs(scale - _page->displayedContentScale()) < scaleNoiseThreshold) {
     170    CGFloat filteredScale = zoomScale;
     171    if (!isStableState && fabs(filteredScale - _page->displayedContentScale()) < scaleNoiseThreshold) {
    170172        // Tiny changes of scale during interactive zoom cause content to jump by one pixel, creating
    171173        // visual noise. We filter those useless updates.
    172         scale = _page->displayedContentScale();
     174        filteredScale = _page->displayedContentScale();
    173175    }
    174176
    175     FloatRect fixedPosRect = [self fixedPositionRectFromExposedRect:unobscuredRect scale:scale];
    176     _page->updateVisibleContentRects(VisibleContentRectUpdateInfo(_page->nextVisibleContentRectUpdateID(), visibleRect, unobscuredRect, fixedPosRect, scale, isStableState));
    177 
     177    CGRect customFixedPositionRect = [self fixedPositionRectFromExposedRect:unobscuredRect scale:zoomScale];
     178    _page->updateVisibleContentRects(VisibleContentRectUpdateInfo(_page->nextVisibleContentRectUpdateID(), visibleRect, unobscuredRect, customFixedPositionRect, filteredScale, isStableState));
     179   
    178180    RemoteScrollingCoordinatorProxy* scrollingCoordinator = _page->scrollingCoordinatorProxy();
    179     scrollingCoordinator->scrollPositionChangedViaDelegatedScrolling(scrollingCoordinator->rootScrollingNodeID(), unobscuredRect.origin);
     181    scrollingCoordinator->viewportChangedViaDelegatedScrolling(scrollingCoordinator->rootScrollingNodeID(), unobscuredRect, zoomScale);
    180182
    181183    if (auto drawingArea = _page->drawingArea())
     
    188190}
    189191
    190 - (FloatRect)fixedPositionRectFromExposedRect:(FloatRect)exposedRect scale:(float)scale
    191 {
    192     // FIXME: This should modify the rect based on the scale.
    193     UNUSED_PARAM(scale);
    194     return exposedRect;
     192- (CGRect)fixedPositionRectFromExposedRect:(CGRect)unobscuredRect scale:(CGFloat)scale
     193{
     194    return (FloatRect)FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(unobscuredRect), roundedLayoutSize(FloatSize([self bounds].size)), scale, false, StickToViewportBounds);
    195195}
    196196
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm

    r164890 r165652  
    2727#import "RemoteLayerTreeDrawingAreaProxy.h"
    2828
     29#import "Logging.h"
    2930#import "RemoteLayerTreeDrawingAreaProxyMessages.h"
    3031#import "DrawingAreaMessages.h"
     
    101102void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTransaction& layerTreeTransaction, const RemoteScrollingCoordinatorTransaction& scrollingTreeTransaction)
    102103{
     104    LOG(RemoteLayerTree, "%s", layerTreeTransaction.description().data());
     105
    103106    if (m_remoteLayerTreeHost.updateLayerTree(layerTreeTransaction))
    104107        m_webPageProxy->setAcceleratedCompositingRootLayer(m_remoteLayerTreeHost.rootLayer());
    105108
    106109#if ENABLE(ASYNC_SCROLLING)
    107     m_webPageProxy->scrollingCoordinatorProxy()->updateScrollingTree(scrollingTreeTransaction);
     110    bool fixedOrStickyLayerChanged = false;
     111    m_webPageProxy->scrollingCoordinatorProxy()->updateScrollingTree(scrollingTreeTransaction, fixedOrStickyLayerChanged);
    108112#endif
    109113#if PLATFORM(IOS)
    110114    m_webPageProxy->didCommitLayerTree(layerTreeTransaction);
     115
     116#if ENABLE(ASYNC_SCROLLING)
     117    if (fixedOrStickyLayerChanged) {
     118        // If we got a new layer for a fixed or sticky node, its position from the WebProcess is probably stale. We need to re-run the "viewport" changed logic to udpate it with our UI-side state.
     119        m_webPageProxy->scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling(m_webPageProxy->scrollingCoordinatorProxy()->rootScrollingNodeID(), m_webPageProxy->unobscuredContentRect(), m_webPageProxy->displayedContentScale());
     120    }
     121#endif
    111122#endif
    112123
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm

    r165546 r165652  
    2727#import "RemoteLayerTreeHost.h"
    2828
    29 #import "Logging.h"
    3029#import "RemoteLayerTreePropertyApplier.h"
    3130#import "RemoteLayerTreeTransaction.h"
     
    5554bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& transaction, float indicatorScaleFactor)
    5655{
    57     LOG(RemoteLayerTree, "%s", transaction.description().data());
    58 
    5956    for (const auto& createdLayer : transaction.createdLayers())
    6057        createLayer(createdLayer);
Note: See TracChangeset for help on using the changeset viewer.