Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: Source/platform/mac/ScrollAnimatorMac.mm

Issue 1173053003: Remove ScrollableArea::notifyScrollPositionChanged and cleanup scroll animators. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase + remove updateScrollbars from FrameView::setScrollPosition Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targ etOrigin.y) : NSMakePoint(targetOrigin.x, newPos); 726 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targ etOrigin.y) : NSMakePoint(targetOrigin.x, newPos);
727 } else 727 } else
728 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_cu rrentPosY) : NSMakePoint(m_currentPosX, newPos); 728 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_cu rrentPosY) : NSMakePoint(m_currentPosX, newPos);
729 729
730 [m_scrollAnimationHelper.get() scrollToPoint:newPoint]; 730 [m_scrollAnimationHelper.get() scrollToPoint:newPoint];
731 731
732 float usedDelta = (newPos - currentPos) / step; 732 float usedDelta = (newPos - currentPos) / step;
733 return ScrollResultOneDimensional(true, delta - usedDelta); 733 return ScrollResultOneDimensional(true, delta - usedDelta);
734 } 734 }
735 735
736 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollType scrollType) 736 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
737 { 737 {
738 [m_scrollAnimationHelper.get() _stopRun]; 738 [m_scrollAnimationHelper.get() _stopRun];
739 immediateScrollTo(offset, scrollType); 739 immediateScrollTo(offset);
740 } 740 }
741 741
742 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const 742 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const
743 { 743 {
744 if (!m_scrollableArea->constrainsScrollingToContentEdge()) 744 if (!m_scrollableArea->constrainsScrollingToContentEdge())
745 return position; 745 return position;
746 746
747 IntPoint minPos = m_scrollableArea->minimumScrollPosition(); 747 IntPoint minPos = m_scrollableArea->minimumScrollPosition();
748 IntPoint maxPos = m_scrollableArea->maximumScrollPosition(); 748 IntPoint maxPos = m_scrollableArea->maximumScrollPosition();
749 749
750 float newX = std::max<float>(std::min<float>(position.x(), maxPos.x()), minP os.x()); 750 float newX = std::max<float>(std::min<float>(position.x(), maxPos.x()), minP os.x());
751 float newY = std::max<float>(std::min<float>(position.y(), maxPos.y()), minP os.y()); 751 float newY = std::max<float>(std::min<float>(position.y(), maxPos.y()), minP os.y());
752 752
753 return FloatPoint(newX, newY); 753 return FloatPoint(newX, newY);
754 } 754 }
755 755
756 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition, ScrollT ype scrollType) 756 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition)
757 { 757 {
758 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); 758 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition);
759 759
760 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi tion.y() != m_currentPosY; 760 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi tion.y() != m_currentPosY;
761 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) 761 if (!positionChanged && !scrollableArea()->scrollOriginChanged())
762 return; 762 return;
763 763
764 FloatSize delta = FloatSize(adjustedPosition.x() - m_currentPosX, adjustedPo sition.y() - m_currentPosY); 764 FloatSize delta = FloatSize(adjustedPosition.x() - m_currentPosX, adjustedPo sition.y() - m_currentPosY);
765 765
766 m_currentPosX = adjustedPosition.x(); 766 m_currentPosX = adjustedPosition.x();
767 m_currentPosY = adjustedPosition.y(); 767 m_currentPosY = adjustedPosition.y();
768 notifyContentAreaScrolled(delta); 768 notifyContentAreaScrolled(delta);
769 notifyPositionChanged(scrollType); 769 notifyPositionChanged();
770 } 770 }
771 771
772 void ScrollAnimatorMac::immediateScrollToPointForScrollAnimation(const FloatPoin t& newPosition) 772 void ScrollAnimatorMac::immediateScrollToPointForScrollAnimation(const FloatPoin t& newPosition)
773 { 773 {
774 ASSERT(m_scrollAnimationHelper); 774 ASSERT(m_scrollAnimationHelper);
775 immediateScrollTo(newPosition, ProgrammaticScroll); 775 immediateScrollTo(newPosition);
776 } 776 }
777 777
778 void ScrollAnimatorMac::contentAreaWillPaint() const 778 void ScrollAnimatorMac::contentAreaWillPaint() const
779 { 779 {
780 if (!scrollableArea()->scrollbarsCanBeActive()) 780 if (!scrollableArea()->scrollbarsCanBeActive())
781 return; 781 return;
782 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) 782 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable())
783 [m_scrollbarPainterController.get() contentAreaWillDraw]; 783 [m_scrollbarPainterController.get() contentAreaWillDraw];
784 } 784 }
785 785
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 return; 1167 return;
1168 1168
1169 m_visibleScrollerThumbRect = rectInViewCoordinates; 1169 m_visibleScrollerThumbRect = rectInViewCoordinates;
1170 } 1170 }
1171 1171
1172 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { 1172 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() {
1173 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); 1173 return ScrollbarThemeMacCommon::isOverlayAPIAvailable();
1174 } 1174 }
1175 1175
1176 } // namespace blink 1176 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/mac/ScrollAnimatorMac.h ('k') | Source/platform/scroll/ProgrammaticScrollAnimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698