Changeset 169430 in webkit


Ignore:
Timestamp:
May 28, 2014 12:34:52 PM (10 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Improve behavior of position:fixed inside accelerated overflow-scroll
https://bugs.webkit.org/show_bug.cgi?id=133352

Reviewed by Tim Horton.

Source/WebCore:
When adjusting layers inside accelerated overflow-scroll, pass a delta
down to descendant nodes. Fix behavior of sticky nodes inside fixed nodes
inside overflow scroll (sticky should only be affected if the parent node
is a scrolling node).

  • page/scrolling/mac/ScrollingTreeFixedNode.mm:

(WebCore::ScrollingTreeFixedNode::updateLayersAfterAncestorChange): Just remove
some .get()

  • page/scrolling/mac/ScrollingTreeStickyNode.mm:

(WebCore::ScrollingTreeStickyNode::updateLayersAfterAncestorChange): Remove .get()s.
We never care about the cumulative delta here, because sticky nodes only respond to
changes in their direct scrolling ancestors. Only adjust the layer if the parent
is a scrolling node.

Source/WebKit2:
Pass the correct delta down to descendant nodes.

  • UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:

(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateChildNodesAfterScroll):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r169427 r169430  
     12014-05-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Improve behavior of position:fixed inside accelerated overflow-scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=133352
     5
     6        Reviewed by Tim Horton.
     7
     8        When adjusting layers inside accelerated overflow-scroll, pass a delta
     9        down to descendant nodes. Fix behavior of sticky nodes inside fixed nodes
     10        inside overflow scroll (sticky should only be affected if the parent node
     11        is a scrolling node).
     12
     13        * page/scrolling/mac/ScrollingTreeFixedNode.mm:
     14        (WebCore::ScrollingTreeFixedNode::updateLayersAfterAncestorChange): Just remove
     15        some .get()
     16        * page/scrolling/mac/ScrollingTreeStickyNode.mm:
     17        (WebCore::ScrollingTreeStickyNode::updateLayersAfterAncestorChange): Remove .get()s.
     18        We never care about the cumulative delta here, because sticky nodes only respond to
     19        changes in their direct scrolling ancestors. Only adjust the layer if the parent
     20        is a scrolling node.
     21
    1222014-05-27  Chris Fleizach  <cfleizach@apple.com>
    223
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.mm

    r169411 r169430  
    7070    layerPosition -= cumulativeDelta;
    7171
    72     CGRect layerBounds = [m_layer.get() bounds];
    73     CGPoint anchorPoint = [m_layer.get() anchorPoint];
     72    CGRect layerBounds = [m_layer bounds];
     73    CGPoint anchorPoint = [m_layer anchorPoint];
    7474    CGPoint newPosition = layerPosition - m_constraints.alignmentOffset() + anchorPoint * layerBounds.size;
    75     [m_layer.get() setPosition:newPosition];
     75   
     76    [m_layer setPosition:newPosition];
    7677
    7778    if (!m_children)
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.mm

    r169411 r169430  
    6868void ScrollingTreeStickyNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
    6969{
    70     FloatRect constrainingRect = fixedPositionRect;
    71     if (parent()->isOverflowScrollingNode())
     70    bool adjustStickyLayer = false;
     71    FloatRect constrainingRect;
     72
     73    if (parent()->isOverflowScrollingNode()) {
    7274        constrainingRect = FloatRect(toScrollingTreeOverflowScrollingNode(parent())->scrollPosition(), m_constraints.constrainingRectAtLastLayout().size());
     75        adjustStickyLayer = true;
     76    } else if (parent()->isFrameScrollingNode()) {
     77        constrainingRect = fixedPositionRect;
     78        adjustStickyLayer = true;
     79    }
    7380
    74     FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect);
     81    FloatSize deltaForDescendants = cumulativeDelta;
    7582
    76     // FIXME: Subtracting the cumulativeDelta is not totally sufficient to get the new position right for nested
    77     // sticky objects. We probably need a way to modify the containingBlockRect in the ViewportContraints
    78     // to get this right in all cases.
    79     layerPosition -= cumulativeDelta;
     83    if (adjustStickyLayer) {
     84        FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect);
    8085
    81     CGRect layerBounds = [m_layer.get() bounds];
    82     CGPoint anchorPoint = [m_layer.get() anchorPoint];
    83     CGPoint newPosition = layerPosition - m_constraints.alignmentOffset() + anchorPoint * layerBounds.size;
    84     [m_layer.get() setPosition:newPosition];
     86        CGRect layerBounds = [m_layer bounds];
     87        CGPoint anchorPoint = [m_layer anchorPoint];
     88        CGPoint newPosition = layerPosition - m_constraints.alignmentOffset() + anchorPoint * layerBounds.size;
     89        [m_layer setPosition:newPosition];
     90
     91        deltaForDescendants = layerPosition - m_constraints.layerPositionAtLastLayout() + cumulativeDelta;
     92    }
    8593
    8694    if (!m_children)
    8795        return;
    8896
    89     FloatSize newDelta = layerPosition - m_constraints.layerPositionAtLastLayout() + cumulativeDelta;
    90 
    9197    for (auto& child : *m_children)
    92         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, newDelta);
     98        child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, deltaForDescendants);
    9399}
    94100
  • trunk/Source/WebKit2/ChangeLog

    r169426 r169430  
     12014-05-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Improve behavior of position:fixed inside accelerated overflow-scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=133352
     5
     6        Reviewed by Tim Horton.
     7
     8        Pass the correct delta down to descendant nodes.
     9
     10        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
     11        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateChildNodesAfterScroll):
     12
    1132014-05-28  Andy Estes  <aestes@apple.com>
    214
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm

    r169411 r169430  
    186186
    187187    FloatRect fixedPositionRect = scrollingTree().fixedPositionRect();
    188 
    189     size_t size = m_children->size();
    190     for (size_t i = 0; i < size; ++i)
    191         m_children->at(i)->updateLayersAfterAncestorChange(*this, fixedPositionRect, FloatSize());
     188    FloatSize scrollDelta = lastCommittedScrollPosition() - scrollPosition;
     189
     190    for (auto& child : *m_children)
     191        child->updateLayersAfterAncestorChange(*this, fixedPositionRect, scrollDelta);
    192192}
    193193
Note: See TracChangeset for help on using the changeset viewer.