Changeset 194502 in webkit
- Timestamp:
- Jan 2, 2016 1:58:48 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r194500 r194502 1 2016-01-02 Simon Fraser <simon.fraser@apple.com> 2 3 Some cleanup in ScrollAnimator 4 https://bugs.webkit.org/show_bug.cgi?id=152649 5 6 Reviewed by Zalan Bujtas. 7 8 Added fast/scrolling/arrow-key-scroll-in-rtl-document.html to test for arrow 9 key scrolling in an RTL document, which an earlier version of the patch 10 regressed without detection. 11 12 * fast/dom/horizontal-scrollbar-in-rtl-expected.txt: 13 * fast/scrolling/arrow-key-scroll-in-rtl-document-expected.txt: Added. 14 * fast/scrolling/arrow-key-scroll-in-rtl-document.html: Added. 15 1 16 2016-01-02 Zalan Bujtas <zalan@apple.com> 2 17 -
trunk/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
r149088 r194502 4 4 zoom in and out preserve scroll position: Success 5 5 resize preserves scroll position: Success 6 KeyDown HOME move x-scroll position to right for RTL page: -10007 KeyDown END move x-scroll position to right for RTL page: -10006 KeyDown HOME move x-scroll position to right for RTL page: 0 7 KeyDown END move x-scroll position to right for RTL page: 0 8 8 selectAll selects all document: Success -
trunk/Source/WebCore/ChangeLog
r194500 r194502 1 2016-01-02 Simon Fraser <simon.fraser@apple.com> 2 3 Some cleanup in ScrollAnimator 4 https://bugs.webkit.org/show_bug.cgi?id=152649 5 6 Reviewed by Zalan Bujtas. 7 8 Change ScrollAnimatorMac::adjustScrollPositionIfNecessary() and similar code in 9 ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary() to 10 constrain between minimumScrollPosition() and maximumScrollPosition(), rather than 11 rolling their own code. 12 13 This revealed several issues. First, RenderLayer::maximumScrollPosition() is 14 wrong when the layer has borders, because RenderLayer::visibleContentRectInternal() 15 seems to have incorrect logic. However, we can just remove it, and use the ScrollableArea 16 implementation. 17 18 Second, ScrollAnimatorMac::scrollToOffsetWithoutAnimation() was failing to do a 19 position/offset conversion, so do one. We're converting too much, and should probably 20 just change ScrollAnimator to do everything in terms of positions. 21 22 Third, ScrollAnimator::scroll() was clamping a scroll position as an offset 23 (detected by scrollbars/scroll-rtl-or-bt-layer.html), so fix that. 24 25 Remove ScrollController::absoluteScrollPosition() and overrides, since this was 26 confusingly named, and could just be removed. 27 28 Remove ScrollController::m_origOrigin which was assigned to, but never read. 29 30 Test: fast/scrolling/arrow-key-scroll-in-rtl-document.html: new 31 fast/dom/horizontal-scrollbar-in-rtl.html: progressed with these changes. 32 33 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: 34 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: 35 (WebCore::ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary): 36 (WebCore::ScrollingTreeFrameScrollingNodeMac::absoluteScrollPosition): Deleted. 37 * platform/ScrollAnimator.cpp: 38 (WebCore::ScrollAnimator::scroll): 39 (WebCore::ScrollAnimator::notifyPositionChanged): 40 * platform/ScrollableArea.h: 41 (WebCore::ScrollableArea::constrainScrollPosition): 42 * platform/cocoa/ScrollController.h: 43 * platform/cocoa/ScrollController.mm: 44 (WebCore::ScrollController::snapRubberBandTimerFired): Deleted. 45 (WebCore::ScrollController::snapRubberBand): Deleted. 46 * platform/mac/ScrollAnimatorMac.h: 47 * platform/mac/ScrollAnimatorMac.mm: 48 (-[WebScrollAnimationHelperDelegate _immediateScrollToPoint:]): 49 (WebCore::ScrollAnimatorMac::scroll): 50 (WebCore::ScrollAnimatorMac::scrollToOffsetWithoutAnimation): 51 (WebCore::ScrollAnimatorMac::adjustScrollPositionIfNecessary): 52 (WebCore::ScrollAnimatorMac::adjustScrollPositionToBoundsIfNecessary): 53 (WebCore::ScrollAnimatorMac::immediateScrollToPosition): 54 (WebCore::ScrollAnimatorMac::immediateScrollToPositionForScrollAnimation): 55 (WebCore::ScrollAnimatorMac::immediateScrollTo): Deleted. 56 (WebCore::ScrollAnimatorMac::immediateScrollToPointForScrollAnimation): Deleted. 57 (WebCore::ScrollAnimatorMac::absoluteScrollPosition): Deleted. 58 * rendering/RenderLayer.cpp: 59 (WebCore::RenderLayer::visibleContentRectInternal): 60 (WebCore::RenderLayer::overhangAmount): 61 (WebCore::RenderLayer::maximumScrollPosition): Deleted. 62 * rendering/RenderLayer.h: 63 * rendering/RenderListBox.cpp: 64 (WebCore::RenderListBox::minimumScrollPosition): 65 (WebCore::RenderListBox::maximumScrollPosition): RenderListBox scrolls by lines, 66 so it needs a custom implementation of this. 67 * rendering/RenderListBox.h: 68 1 69 2016-01-02 Zalan Bujtas <zalan@apple.com> 2 70 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h
r186469 r194502 59 59 bool canScrollVertically() override; 60 60 bool shouldRubberBandInDirection(ScrollDirection) override; 61 IntPoint absoluteScrollPosition() override;62 61 void immediateScrollBy(const FloatSize&) override; 63 62 void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) override; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
r194487 r194502 326 326 } 327 327 328 IntPoint ScrollingTreeFrameScrollingNodeMac::absoluteScrollPosition()329 {330 return roundedIntPoint(scrollPosition());331 }332 333 328 void ScrollingTreeFrameScrollingNodeMac::immediateScrollBy(const FloatSize& delta) 334 329 { … … 351 346 void ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary() 352 347 { 353 FloatPoint currentScrollPosition = absoluteScrollPosition(); 354 FloatPoint minPosition = minimumScrollPosition(); 355 FloatPoint maxPosition = maximumScrollPosition(); 356 357 float nearestXWithinBounds = std::max(std::min(currentScrollPosition.x(), maxPosition.x()), minPosition.x()); 358 float nearestYWithinBounds = std::max(std::min(currentScrollPosition.y(), maxPosition.y()), minPosition.y()); 359 360 FloatPoint nearestPointWithinBounds(nearestXWithinBounds, nearestYWithinBounds); 361 immediateScrollBy(nearestPointWithinBounds - currentScrollPosition); 348 FloatPoint currentScrollPosition = scrollPosition(); 349 FloatPoint constainedPosition = currentScrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition()); 350 immediateScrollBy(constainedPosition - currentScrollPosition); 362 351 } 363 352 -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r189749 r194502 64 64 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier) 65 65 { 66 float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX : &m_currentPosY; 67 float newPos = std::max(std::min(*currentPos + (step * multiplier), static_cast<float>(m_scrollableArea.scrollSize(orientation))), 0.0f); 68 float delta = *currentPos - newPos; 69 if (*currentPos == newPos) 66 FloatPoint currentPosition(m_currentPosX, m_currentPosY); 67 FloatSize delta; 68 if (orientation == HorizontalScrollbar) 69 delta.setWidth(step * multiplier); 70 else 71 delta.setHeight(step * multiplier); 72 73 FloatPoint newPosition = FloatPoint(currentPosition + delta).constrainedBetween(m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition()); 74 if (currentPosition == newPosition) 70 75 return false; 71 *currentPos = newPos; 72 73 notifyPositionChanged(orientation == HorizontalScrollbar ? FloatSize(delta, 0) : FloatSize(0, delta)); 74 76 77 // FIXME: m_currentPosX/Y should just be a FloatPoint. 78 m_currentPosX = newPosition.x(); 79 m_currentPosY = newPosition.y(); 80 81 notifyPositionChanged(newPosition - currentPosition); 75 82 return true; 76 83 } … … 195 202 { 196 203 UNUSED_PARAM(delta); 197 m_scrollableArea.setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_currentPosY)); 204 // FIXME: need to not map back and forth all the time. 205 m_scrollableArea.setScrollOffsetFromAnimation(m_scrollableArea.scrollOffsetFromPosition(IntPoint(m_currentPosX, m_currentPosY))); 198 206 } 199 207 -
trunk/Source/WebCore/platform/ScrollableArea.h
r194487 r194502 189 189 virtual ScrollPosition maximumScrollPosition() const; 190 190 191 ScrollPosition constrainScrollPosition(const ScrollPosition& position) const 192 { 193 return position.constrainedBetween(minimumScrollPosition(), maximumScrollPosition()); 194 } 195 191 196 ScrollOffset maximumScrollOffset() const; 192 197 -
trunk/Source/WebCore/platform/cocoa/ScrollController.h
r186469 r194502 61 61 virtual bool shouldRubberBandInDirection(ScrollDirection) = 0; 62 62 63 // Return the absolute scroll position, not relative to the scroll origin.64 virtual WebCore::IntPoint absoluteScrollPosition() = 0;65 66 63 virtual void immediateScrollBy(const FloatSize&) = 0; 67 64 virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0; … … 180 177 CFTimeInterval m_startTime { 0 }; 181 178 FloatSize m_startStretch; 182 FloatPoint m_origOrigin;183 179 FloatSize m_origVelocity; 184 180 RunLoop::Timer<ScrollController> m_snapRubberbandTimer; -
trunk/Source/WebCore/platform/cocoa/ScrollController.mm
r188641 r194502 350 350 m_startTime = 0; 351 351 m_startStretch = FloatSize(); 352 m_origOrigin = FloatPoint();353 352 m_origVelocity = FloatSize(); 354 353 return; 355 354 } 356 355 357 m_origOrigin = m_client.absoluteScrollPosition() - m_startStretch;358 356 m_origVelocity = m_momentumVelocity; 359 357 … … 388 386 m_startTime = 0; 389 387 m_startStretch = FloatSize(); 390 m_origOrigin = FloatPoint();391 388 m_origVelocity = FloatSize(); 392 389 } … … 452 449 m_startTime = [NSDate timeIntervalSinceReferenceDate]; 453 450 m_startStretch = FloatSize(); 454 m_origOrigin = FloatPoint();455 451 m_origVelocity = FloatSize(); 456 452 -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h
r191735 r194502 53 53 virtual ~ScrollAnimatorMac(); 54 54 55 void immediateScrollToPo intForScrollAnimation(const FloatPoint& newPosition);55 void immediateScrollToPositionForScrollAnimation(const FloatPoint& newPosition); 56 56 bool haveScrolledSincePageLoad() const { return m_haveScrolledSincePageLoad; } 57 57 … … 135 135 FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const; 136 136 137 void immediateScrollTo (const FloatPoint&);137 void immediateScrollToPosition(const FloatPoint&); 138 138 139 139 bool isRubberBandInProgress() const override; … … 149 149 virtual bool canScrollVertically() override; 150 150 virtual bool shouldRubberBandInDirection(ScrollDirection) override; 151 virtual WebCore::IntPoint absoluteScrollPosition() override;152 151 virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) override; 153 152 virtual void immediateScrollBy(const FloatSize&) override; -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r194448 r194502 33 33 #include "FloatPoint.h" 34 34 #include "GraphicsLayer.h" 35 #include "Logging.h" 35 36 #include "NSScrollerImpDetails.h" 36 37 #include "PlatformWheelEvent.h" … … 39 40 #include "ScrollbarTheme.h" 40 41 #include "ScrollbarThemeMac.h" 42 #include "TextStream.h" 41 43 #include "WebCoreSystemInterface.h" 42 44 … … 131 133 if (!_animator) 132 134 return; 133 _animator->immediateScrollToPo intForScrollAnimation(newPosition);135 _animator->immediateScrollToPositionForScrollAnimation(newPosition); 134 136 } 135 137 … … 701 703 return ScrollAnimator::scroll(orientation, granularity, step, multiplier); 702 704 703 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_currentPosY; 704 float newPos = std::max<float>(std::min<float>(currentPos + (step * multiplier), static_cast<float>(m_scrollableArea.scrollSize(orientation))), 0); 705 if (currentPos == newPos) 705 FloatPoint currentPosition(m_currentPosX, m_currentPosY); 706 FloatSize delta; 707 if (orientation == HorizontalScrollbar) 708 delta.setWidth(step * multiplier); 709 else 710 delta.setHeight(step * multiplier); 711 712 FloatPoint newPosition = FloatPoint(currentPosition + delta).constrainedBetween(m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition()); 713 if (currentPosition == newPosition) 706 714 return false; 707 715 708 NSPoint newPoint;709 716 if ([m_scrollAnimationHelper _isAnimating]) { 710 717 NSPoint targetOrigin = [m_scrollAnimationHelper targetOrigin]; 711 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targetOrigin.y) : NSMakePoint(targetOrigin.x, newPos); 712 } else 713 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_currentPosY) : NSMakePoint(m_currentPosX, newPos); 714 715 [m_scrollAnimationHelper scrollToPoint:newPoint]; 718 if (orientation == HorizontalScrollbar) 719 newPosition.setY(targetOrigin.y); 720 else 721 newPosition.setX(targetOrigin.x); 722 } 723 724 LOG_WITH_STREAM(Scrolling, stream << "ScrollAnimatorMac::scroll " << " from " << FloatPoint(m_currentPosX, m_currentPosY) << " to " << newPosition); 725 [m_scrollAnimationHelper scrollToPoint:newPosition]; 716 726 return true; 717 727 } 718 728 729 // FIXME: Maybe this should take a position. 719 730 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset) 720 731 { 721 732 [m_scrollAnimationHelper _stopRun]; 722 immediateScrollTo (offset);733 immediateScrollToPosition(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()))); 723 734 } 724 735 … … 728 739 return position; 729 740 730 float newX = std::max<float>(std::min<float>(position.x(), m_scrollableArea.totalContentsSize().width() - m_scrollableArea.visibleWidth()), 0); 731 float newY = std::max<float>(std::min<float>(position.y(), m_scrollableArea.totalContentsSize().height() - m_scrollableArea.visibleHeight()), 0); 732 733 return FloatPoint(newX, newY); 741 return m_scrollableArea.constrainScrollPosition(ScrollPosition(position)); 734 742 } 735 743 … … 739 747 m_scrollableArea.setConstrainsScrollingToContentEdge(true); 740 748 741 IntPoint currentScrollPosition = absoluteScrollPosition();742 FloatPoint nearestPointWithinBounds = adjustScrollPositionIfNecessary(absoluteScrollPosition());743 immediateScrollBy( nearestPointWithinBounds- currentScrollPosition);749 ScrollPosition currentScrollPosition = m_scrollableArea.scrollPosition(); 750 ScrollPosition constainedPosition = m_scrollableArea.constrainScrollPosition(currentScrollPosition); 751 immediateScrollBy(constainedPosition - currentScrollPosition); 744 752 745 753 m_scrollableArea.setConstrainsScrollingToContentEdge(currentlyConstrainsToContentEdge); 746 754 } 747 755 748 void ScrollAnimatorMac::immediateScrollTo (const FloatPoint& newPosition)756 void ScrollAnimatorMac::immediateScrollToPosition(const FloatPoint& newPosition) 749 757 { 750 758 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); … … 780 788 } 781 789 782 void ScrollAnimatorMac::immediateScrollToPo intForScrollAnimation(const FloatPoint& newPosition)790 void ScrollAnimatorMac::immediateScrollToPositionForScrollAnimation(const FloatPoint& newPosition) 783 791 { 784 792 ASSERT(m_scrollAnimationHelper); 785 immediateScrollTo (newPosition);793 immediateScrollToPosition(newPosition); 786 794 } 787 795 … … 1283 1291 } 1284 1292 1285 IntPoint ScrollAnimatorMac::absoluteScrollPosition()1286 {1287 // FIXME: can this use m_scrollableArea.scrollPosition()?1288 return m_scrollableArea.scrollOffsetFromPosition(m_scrollableArea.visibleContentRect().location());1289 }1290 1291 1293 void ScrollAnimatorMac::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& delta) 1292 1294 { -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r194496 r194502 2733 2733 } 2734 2734 2735 ScrollPosition RenderLayer::maximumScrollPosition() const2736 {2737 // FIXME: m_scrollSize may not be up-to-date if m_scrollDimensionsDirty is true.2738 // FIXME: should be able to use the ScrollableArea implementation.2739 return scrollPositionFromOffset(roundedIntPoint(m_scrollSize) - visibleContentRectIncludingScrollbars(ContentsVisibleRect).size());2740 }2741 2742 2735 IntRect RenderLayer::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion, VisibleContentRectBehavior) const 2743 2736 { … … 2746 2739 scrollbarSpace = scrollbarIntrusion(); 2747 2740 2741 // FIXME: This seems wrong: m_layerSize includes borders. Can we just use the ScrollableArea implementation? 2748 2742 return IntRect(scrollPosition(), IntSize(std::max(0, m_layerSize.width() - scrollbarSpace.width()), std::max(0, m_layerSize.height() - scrollbarSpace.height()))); 2749 2743 } … … 2757 2751 IntSize stretch; 2758 2752 2759 // FIXME: use maximumScrollOffset() 2753 // FIXME: use maximumScrollOffset(), or just move this to ScrollableArea. 2760 2754 ScrollOffset scrollOffset = scrollOffsetFromPosition(scrollPosition()); 2761 2755 if (scrollOffset.y() < 0) -
trunk/Source/WebCore/rendering/RenderLayer.h
r194478 r194502 867 867 868 868 virtual ScrollPosition scrollPosition() const override { return m_scrollPosition; } 869 virtual ScrollPosition maximumScrollPosition() const override;870 869 871 870 virtual IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const override; -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r194496 r194502 609 609 } 610 610 611 ScrollPosition RenderListBox::minimumScrollPosition() const 612 { 613 return { 0, 0 }; 614 } 615 616 ScrollPosition RenderListBox::maximumScrollPosition() const 617 { 618 return { 0, numItems() - numVisibleItems() }; 619 } 620 611 621 void RenderListBox::setScrollOffset(const ScrollOffset& offset) 612 622 { -
trunk/Source/WebCore/rendering/RenderListBox.h
r194487 r194502 113 113 virtual int scrollPosition(Scrollbar*) const override; 114 114 virtual void setScrollOffset(const ScrollOffset&) override; 115 virtual ScrollPosition minimumScrollPosition() const override; 116 virtual ScrollPosition maximumScrollPosition() const override; 115 117 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; 116 118 virtual bool isActive() const override;
Note: See TracChangeset
for help on using the changeset viewer.