Changeset 170541 in webkit
- Timestamp:
- Jun 27, 2014 11:28:39 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r170539 r170541 1 2014-06-26 Simon Fraser <simon.fraser@apple.com> 2 3 [iOS WK2] Fix touch-scrollable elements with overflow:scroll on just one axis, and RTL scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=134377 5 <rdar://problem/16762224> 6 7 Reviewed by Tim Horton. 8 9 Make -webkit-overflow-scrolling:touch scrolling work correctly when one axis 10 has overflow:scroll and the other overflow:hidden. Also fix scrolling in RTL 11 contexts. 12 13 An RTL scroller with overflow-x:hidden will have a non-zero scroll origin, 14 and needs to truncate the scrolled content on the left side. To pass the 15 correct geometry to the UI process, we need to introduce the concept of 16 "reachable" size as well as total content size; normally these are the same, 17 but will differ when scrolling is only allowed on one axis but there is overflow 18 on both axes. 19 20 To get the reachable size, add RenderLayer::scrollableContentsSize(). 21 22 RenderLayer::visibleSize() was wrong; the function should return the size of the 23 scrollable portion, but used layer size which includes borders. Fix to use pixelSnappedClientWidth()/Height(), 24 which is what we use for scrollbar computations. 25 26 * WebCore.exp.in: 27 * page/scrolling/AsyncScrollingCoordinator.cpp: 28 (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated): 29 (WebCore::AsyncScrollingCoordinator::updateFrameScrollingNode): 30 (WebCore::AsyncScrollingCoordinator::updateOverflowScrollingNode): 31 * page/scrolling/ScrollingCoordinator.h: 32 * page/scrolling/ScrollingStateScrollingNode.cpp: 33 (WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode): 34 (WebCore::ScrollingStateScrollingNode::setReachableContentsSize): 35 * page/scrolling/ScrollingStateScrollingNode.h: 36 (WebCore::ScrollingStateScrollingNode::reachableContentsSize): 37 * page/scrolling/ScrollingTreeScrollingNode.cpp: 38 (WebCore::ScrollingTreeScrollingNode::updateBeforeChildren): 39 * page/scrolling/ScrollingTreeScrollingNode.h: 40 (WebCore::ScrollingTreeScrollingNode::reachableContentsSize): 41 * rendering/RenderLayer.cpp: 42 (WebCore::RenderLayer::visibleSize): 43 (WebCore::RenderLayer::scrollableContentsSize): 44 * rendering/RenderLayer.h: 45 * rendering/RenderLayerCompositor.cpp: 46 (WebCore::updateScrollingLayerWithClient): 47 (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): 48 1 49 2014-06-27 Bear Travis <betravis@adobe.com> 2 50 -
trunk/Source/WebCore/WebCore.exp.in
r170514 r170541 2884 2884 __ZN7WebCore27ScrollingStateScrollingNode20setTotalContentsSizeERKNS_9FloatSizeE 2885 2885 __ZN7WebCore27ScrollingStateScrollingNode21setScrollableAreaSizeERKNS_9FloatSizeE 2886 __ZN7WebCore27ScrollingStateScrollingNode24setReachableContentsSizeERKNS_9FloatSizeE 2886 2887 __ZN7WebCore27ScrollingStateScrollingNode26setRequestedScrollPositionERKNS_10FloatPointEb 2887 2888 __ZN7WebCore27ScrollingStateScrollingNode27setScrollableAreaParametersERKNS_24ScrollableAreaParametersE -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r170118 r170541 95 95 node->setScrollableAreaSize(frameView->visibleContentRect().size()); 96 96 node->setTotalContentsSize(frameView->totalContentsSize()); 97 node->setReachableContentsSize(frameView->totalContentsSize()); 97 98 98 99 ScrollableAreaParameters scrollParameters; … … 376 377 node->setScrollPosition(scrollingGeometry->scrollPosition); 377 378 node->setTotalContentsSize(scrollingGeometry->contentSize); 379 node->setReachableContentsSize(scrollingGeometry->reachableContentSize); 378 380 node->setScrollableAreaSize(scrollingGeometry->scrollableAreaSize); 379 381 } … … 394 396 node->setScrollPosition(scrollingGeometry->scrollPosition); 395 397 node->setTotalContentsSize(scrollingGeometry->contentSize); 398 node->setReachableContentsSize(scrollingGeometry->reachableContentSize); 396 399 node->setScrollableAreaSize(scrollingGeometry->scrollableAreaSize); 397 400 } -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r169733 r170541 162 162 FloatSize scrollableAreaSize; 163 163 FloatSize contentSize; 164 FloatSize reachableContentSize; // Smaller than contentSize when overflow is hidden on one axis. 164 165 FloatPoint scrollPosition; 165 166 IntPoint scrollOrigin; -
trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
r169063 r170541 45 45 , m_scrollableAreaSize(stateNode.scrollableAreaSize()) 46 46 , m_totalContentsSize(stateNode.totalContentsSize()) 47 , m_reachableContentsSize(stateNode.reachableContentsSize()) 47 48 , m_scrollPosition(stateNode.scrollPosition()) 48 49 , m_requestedScrollPosition(stateNode.requestedScrollPosition()) … … 73 74 m_totalContentsSize = totalContentsSize; 74 75 setPropertyChanged(TotalContentsSize); 76 } 77 78 void ScrollingStateScrollingNode::setReachableContentsSize(const FloatSize& reachableContentsSize) 79 { 80 if (m_reachableContentsSize == reachableContentsSize) 81 return; 82 83 m_reachableContentsSize = reachableContentsSize; 84 setPropertyChanged(ReachableContentsSize); 75 85 } 76 86 -
trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
r169063 r170541 43 43 ScrollableAreaSize = NumStateNodeBits, 44 44 TotalContentsSize, 45 ReachableContentsSize, 45 46 ScrollPosition, 46 47 ScrollOrigin, … … 55 56 const FloatSize& totalContentsSize() const { return m_totalContentsSize; } 56 57 void setTotalContentsSize(const FloatSize&); 58 59 const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; } 60 void setReachableContentsSize(const FloatSize&); 57 61 58 62 const FloatPoint& scrollPosition() const { return m_scrollPosition; } … … 78 82 FloatSize m_scrollableAreaSize; 79 83 FloatSize m_totalContentsSize; 84 FloatSize m_reachableContentsSize; 80 85 FloatPoint m_scrollPosition; 81 86 FloatPoint m_requestedScrollPosition; -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
r169313 r170541 59 59 } 60 60 61 if (state.hasChangedProperty(ScrollingStateScrollingNode::ReachableContentsSize)) 62 m_reachableContentsSize = state.reachableContentsSize(); 63 61 64 if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition)) 62 65 m_lastCommittedScrollPosition = state.scrollPosition(); -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
r169411 r170541 70 70 const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; } 71 71 const FloatSize& totalContentsSize() const { return m_totalContentsSize; } 72 const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; } 72 73 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } 73 74 … … 90 91 FloatSize m_totalContentsSize; 91 92 FloatSize m_totalContentsSizeForRubberBand; 93 FloatSize m_reachableContentsSize; 92 94 FloatPoint m_lastCommittedScrollPosition; 93 95 IntPoint m_scrollOrigin; -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r170532 r170541 2735 2735 } 2736 2736 2737 IntSize RenderLayer::visibleSize() const 2738 { 2739 if (!renderer().isBox()) 2740 return IntSize(); 2741 2742 return IntSize(renderBox()->pixelSnappedClientWidth(), renderBox()->pixelSnappedClientHeight()); 2743 } 2744 2737 2745 IntSize RenderLayer::contentsSize() const 2738 2746 { 2739 2747 return IntSize(scrollWidth(), scrollHeight()); 2748 } 2749 2750 IntSize RenderLayer::scrollableContentsSize() const 2751 { 2752 IntSize contentsSize = this->contentsSize(); 2753 2754 if (!hasScrollableHorizontalOverflow()) 2755 contentsSize.setWidth(std::min(contentsSize.width(), visibleSize().width())); 2756 2757 if (!hasScrollableVerticalOverflow()) 2758 contentsSize.setHeight(std::min(contentsSize.height(), visibleSize().height())); 2759 2760 return contentsSize; 2740 2761 } 2741 2762 -
trunk/Source/WebCore/rendering/RenderLayer.h
r170381 r170541 345 345 346 346 RenderLayerModelObject& renderer() const { return m_renderer; } 347 RenderBox* renderBox() const { return renderer().isBox() ? &toRenderBox(renderer()) : 0; }347 RenderBox* renderBox() const { return renderer().isBox() ? &toRenderBox(renderer()) : nullptr; } 348 348 RenderLayer* parent() const { return m_parent; } 349 349 RenderLayer* previousSibling() const { return m_previous; } … … 421 421 int scrollYOffset() const { return m_scrollOffset.height() + scrollOrigin().y(); } 422 422 IntSize scrollOffset() const { return IntSize(scrollXOffset(), scrollYOffset()); } 423 IntSize scrollableContentsSize() const; 423 424 424 425 void scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX, const ScrollAlignment& alignY); … … 1078 1079 virtual IntPoint maximumScrollPosition() const override; 1079 1080 virtual IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const override; 1080 virtual IntSize visibleSize() const override { return m_layerSize; }1081 virtual IntSize visibleSize() const override; 1081 1082 virtual IntSize contentsSize() const override; 1082 1083 virtual IntSize overhangAmount() const override; -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r170514 r170541 509 509 bool allowVerticalScrollbar = !scrollbarHasDisplayNone(layer.verticalScrollbar()); 510 510 client->addOrUpdateScrollingLayer(layer.renderer().element(), backing->scrollingLayer()->platformLayer(), backing->scrollingContentsLayer()->platformLayer(), 511 IntSize(layer.scrollWidth(), layer.scrollHeight()), allowHorizontalScrollbar, allowVerticalScrollbar);511 layer.scrollableContentsSize(), allowHorizontalScrollbar, allowVerticalScrollbar); 512 512 } 513 513 … … 3740 3740 updateScrollCoordinationForThisFrame(parentNodeID); 3741 3741 else { 3742 ScrollingNodeType nodeType = isRootLayer ? FrameScrollingNode :OverflowScrollingNode;3742 ScrollingNodeType nodeType = OverflowScrollingNode; 3743 3743 ScrollingNodeID nodeID = attachScrollingNode(layer, nodeType, parentNodeID); 3744 3744 if (!nodeID) … … 3750 3750 scrollingGeometry.scrollableAreaSize = layer.visibleSize(); 3751 3751 scrollingGeometry.contentSize = layer.contentsSize(); 3752 scrollingGeometry.reachableContentSize = layer.scrollableContentsSize(); 3752 3753 scrollingCoordinator->updateOverflowScrollingNode(nodeID, backing->scrollingLayer(), backing->scrollingContentsLayer(), &scrollingGeometry); 3753 3754 } -
trunk/Source/WebKit2/ChangeLog
r170540 r170541 1 2014-06-26 Simon Fraser <simon.fraser@apple.com> 2 3 [iOS WK2] Fix touch-scrollable elements with overflow:scroll on just one axis, and RTL scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=134377 5 <rdar://problem/16762224> 6 7 Reviewed by Tim Horton. 8 9 Make -webkit-overflow-scrolling:touch scrolling work correctly when one axis 10 has overflow:scroll and the other overflow:hidden. Also fix scrolling in RTL 11 contexts. 12 13 An RTL scroller with overflow-x:hidden will have a non-zero scroll origin, 14 and needs to truncate the scrolled content on the left side. To pass the 15 correct geometry to the UI process, we need to introduce the concept of 16 "reachable" size as well as total content size; normally these are the same, 17 but will differ when scrolling is only allowed on one axis but there is overflow 18 on both axes. 19 20 ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren() uses the total and 21 reachable content sizes to set a negative edge inset on the left (for RTL) or top 22 (for bottom-to-top) so prevent scrolling into these areas. 23 24 * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp: 25 (ArgumentCoder<ScrollingStateScrollingNode>::encode): 26 (ArgumentCoder<ScrollingStateScrollingNode>::decode): 27 (WebKit::RemoteScrollingTreeTextStream::dump): 28 * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm: 29 (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren): 30 1 31 2014-06-27 Joseph Pecoraro <pecoraro@apple.com> 2 32 -
trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp
r170267 r170541 126 126 SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollableAreaSize, scrollableAreaSize) 127 127 SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::TotalContentsSize, totalContentsSize) 128 SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ReachableContentsSize, reachableContentsSize) 128 129 SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollPosition, scrollPosition) 129 130 SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollOrigin, scrollOrigin) … … 190 191 SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollableAreaSize, FloatSize, setScrollableAreaSize); 191 192 SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::TotalContentsSize, FloatSize, setTotalContentsSize); 193 SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ReachableContentsSize, FloatSize, setReachableContentsSize); 192 194 SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollPosition, FloatPoint, setScrollPosition); 193 195 SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollOrigin, IntPoint, setScrollOrigin); … … 566 568 567 569 if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollableAreaSize)) 568 dumpProperty(ts, "scrollable-area-size", node. totalContentsSize());570 dumpProperty(ts, "scrollable-area-size", node.scrollableAreaSize()); 569 571 570 572 if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) 571 573 dumpProperty(ts, "total-contents-size", node.totalContentsSize()); 574 575 if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ReachableContentsSize)) 576 dumpProperty(ts, "reachable-contents-size", node.reachableContentsSize()); 572 577 573 578 if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition)) -
trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm
r170466 r170541 141 141 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollLayer) 142 142 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize) 143 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition)) { 143 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ReachableContentsSize) 144 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition) 145 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin)) { 144 146 BEGIN_BLOCK_OBJC_EXCEPTIONS 145 147 UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate]; … … 153 155 } 154 156 155 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) 156 scrollView.contentSize = scrollingStateNode.totalContentsSize(); 157 158 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition) && ![m_scrollViewDelegate _isInUserInteraction]) 159 scrollView.contentOffset = scrollingStateNode.scrollPosition(); 160 157 bool recomputeInsets = scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize); 158 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ReachableContentsSize)) { 159 scrollView.contentSize = scrollingStateNode.reachableContentsSize(); 160 recomputeInsets = true; 161 } 162 163 if ((scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition) 164 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin)) 165 && ![m_scrollViewDelegate _isInUserInteraction]) { 166 scrollView.contentOffset = scrollingStateNode.scrollPosition() + scrollOrigin(); 167 recomputeInsets = true; 168 } 169 170 if (recomputeInsets) { 171 UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 0, 0); 172 // With RTL or bottom-to-top scrolling (non-zero origin), we need extra space on the left or top. 173 if (scrollOrigin().x()) 174 insets.left = reachableContentsSize().width() - totalContentsSize().width(); 175 176 if (scrollOrigin().y()) 177 insets.top = reachableContentsSize().height() - totalContentsSize().height(); 178 179 scrollView.contentInset = insets; 180 } 181 161 182 END_BLOCK_OBJC_EXCEPTIONS 162 183 }
Note: See TracChangeset
for help on using the changeset viewer.