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

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

Issue 1738243002: Removed main-thread one dimensional scrolling paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removeStepFromUserScroll
Patch Set: Rebase Created 4 years, 9 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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 [m_scrollbarPainterController.get() setDelegate:nil]; 722 [m_scrollbarPainterController.get() setDelegate:nil];
723 [m_horizontalScrollbarPainterDelegate.get() invalidate]; 723 [m_horizontalScrollbarPainterDelegate.get() invalidate];
724 [m_verticalScrollbarPainterDelegate.get() invalidate]; 724 [m_verticalScrollbarPainterDelegate.get() invalidate];
725 [m_scrollAnimationHelperDelegate.get() invalidate]; 725 [m_scrollAnimationHelperDelegate.get() invalidate];
726 END_BLOCK_OBJC_EXCEPTIONS; 726 END_BLOCK_OBJC_EXCEPTIONS;
727 } 727 }
728 m_initialScrollbarPaintTaskFactory->cancel(); 728 m_initialScrollbarPaintTaskFactory->cancel();
729 m_sendContentAreaScrolledTaskFactory->cancel(); 729 m_sendContentAreaScrolledTaskFactory->cancel();
730 } 730 }
731 731
732 ScrollResultOneDimensional ScrollAnimatorMac::userScroll(ScrollbarOrientation or ientation, ScrollGranularity granularity, float delta) 732 ScrollResult ScrollAnimatorMac::userScroll(ScrollGranularity granularity, const FloatSize& delta)
733 { 733 {
734 m_haveScrolledSincePageLoad = true; 734 m_haveScrolledSincePageLoad = true;
735 735
736 if (!m_scrollableArea->scrollAnimatorEnabled()) 736 if (!m_scrollableArea->scrollAnimatorEnabled())
737 return ScrollAnimatorBase::userScroll(orientation, granularity, delta); 737 return ScrollAnimatorBase::userScroll(granularity, delta);
738 738
739 if (granularity == ScrollByPixel || granularity == ScrollByPrecisePixel) 739 if (granularity == ScrollByPixel || granularity == ScrollByPrecisePixel)
740 return ScrollAnimatorBase::userScroll(orientation, granularity, delta); 740 return ScrollAnimatorBase::userScroll(granularity, delta);
741 741
742 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_cu rrentPosY; 742 FloatSize consumedDelta = computeDeltaToConsume(delta);
743 float usedDelta = computeDeltaToConsume(orientation, delta); 743 FloatPoint newPos = m_currentPos + consumedDelta;
744 float newPos = currentPos + usedDelta; 744 if (m_currentPos == newPos)
745 if (currentPos == newPos) 745 return ScrollResult();
746 return ScrollResultOneDimensional(false);
747 746
748 NSPoint newPoint; 747 // Prevent clobbering an existing animation on an unscrolled axis.
749 if ([m_scrollAnimationHelper.get() _isAnimating]) { 748 if ([m_scrollAnimationHelper.get() _isAnimating]) {
750 NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin]; 749 NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin];
751 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targ etOrigin.y) : NSMakePoint(targetOrigin.x, newPos); 750 if (!delta.width())
752 } else 751 newPos.setX(targetOrigin.x);
753 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_cu rrentPosY) : NSMakePoint(m_currentPosX, newPos); 752 if (!delta.height())
753 newPos.setY(targetOrigin.y);
754 }
754 755
756 NSPoint newPoint = NSMakePoint(newPos.x(), newPos.y());
755 [m_scrollAnimationHelper.get() scrollToPoint:newPoint]; 757 [m_scrollAnimationHelper.get() scrollToPoint:newPoint];
756 758
757 return ScrollResultOneDimensional(true, delta - usedDelta); 759 // TODO(bokan): This has different semantics on ScrollResult than ScrollAnim ator,
760 // which only returns unused delta if there's no animation and we don't star t one.
761 return ScrollResult(
762 consumedDelta.width(),
763 consumedDelta.height(),
764 delta.width() - consumedDelta.width(),
765 delta.height() - consumedDelta.height());
758 } 766 }
759 767
760 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset) 768 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
761 { 769 {
762 [m_scrollAnimationHelper.get() _stopRun]; 770 [m_scrollAnimationHelper.get() _stopRun];
763 immediateScrollTo(offset); 771 immediateScrollTo(offset);
764 } 772 }
765 773
766 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const 774 FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const
767 { 775 {
768 IntPoint minPos = m_scrollableArea->minimumScrollPosition(); 776 IntPoint minPos = m_scrollableArea->minimumScrollPosition();
769 IntPoint maxPos = m_scrollableArea->maximumScrollPosition(); 777 IntPoint maxPos = m_scrollableArea->maximumScrollPosition();
770 778
771 float newX = clampTo<float, float>(position.x(), minPos.x(), maxPos.x()); 779 float newX = clampTo<float, float>(position.x(), minPos.x(), maxPos.x());
772 float newY = clampTo<float, float>(position.y(), minPos.y(), maxPos.y()); 780 float newY = clampTo<float, float>(position.y(), minPos.y(), maxPos.y());
773 781
774 return FloatPoint(newX, newY); 782 return FloatPoint(newX, newY);
775 } 783 }
776 784
777 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition) 785 void ScrollAnimatorMac::immediateScrollTo(const FloatPoint& newPosition)
778 { 786 {
779 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); 787 FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition);
780 788
781 bool positionChanged = adjustedPosition.x() != m_currentPosX || adjustedPosi tion.y() != m_currentPosY; 789 bool positionChanged = adjustedPosition != m_currentPos;
782 if (!positionChanged && !scrollableArea()->scrollOriginChanged()) 790 if (!positionChanged && !scrollableArea()->scrollOriginChanged())
783 return; 791 return;
784 792
785 FloatSize delta = FloatSize(adjustedPosition.x() - m_currentPosX, adjustedPo sition.y() - m_currentPosY); 793 FloatSize delta = adjustedPosition - m_currentPos;
786 794
787 m_currentPosX = adjustedPosition.x(); 795 m_currentPos = adjustedPosition;
788 m_currentPosY = adjustedPosition.y();
789 notifyContentAreaScrolled(delta); 796 notifyContentAreaScrolled(delta);
790 notifyPositionChanged(); 797 notifyPositionChanged();
791 } 798 }
792 799
793 void ScrollAnimatorMac::immediateScrollToPointForScrollAnimation(const FloatPoin t& newPosition) 800 void ScrollAnimatorMac::immediateScrollToPointForScrollAnimation(const FloatPoin t& newPosition)
794 { 801 {
795 ASSERT(m_scrollAnimationHelper); 802 ASSERT(m_scrollAnimationHelper);
796 immediateScrollTo(newPosition); 803 immediateScrollTo(newPosition);
797 } 804 }
798 805
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 return; 1182 return;
1176 1183
1177 m_visibleScrollerThumbRect = rectInViewCoordinates; 1184 m_visibleScrollerThumbRect = rectInViewCoordinates;
1178 } 1185 }
1179 1186
1180 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { 1187 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() {
1181 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); 1188 return ScrollbarThemeMacCommon::isOverlayAPIAvailable();
1182 } 1189 }
1183 1190
1184 } // namespace blink 1191 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.h ('k') | third_party/WebKit/Source/platform/scroll/ScrollAnimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698