Assertion in ScrollController::processWheelEventForScrollSnapOnAxis when scrolling...
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Mar 2015 01:00:15 +0000 (01:00 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Mar 2015 01:00:15 +0000 (01:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142517

Reviewed by Simon Fraser.

* platform/cocoa/ScrollController.mm:
(WebCore::toWheelEventStatus): Recognize stateless mechanical wheel events.
(WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): If a mechanical wheel event is processed while
considering scroll snap logic, end any snap animations and clean up.
(WebCore::ScrollController::updateScrollSnapPoints): Don't begin tracking scroll snap state if there is not
scroll snap point defined in the markup.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181300 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/cocoa/ScrollController.mm

index e9165b3..a1c92c2 100644 (file)
@@ -1,3 +1,17 @@
+2015-03-09  Brent Fulgham  <bfulgham@apple.com>
+
+        Assertion in ScrollController::processWheelEventForScrollSnapOnAxis when scrolling with mechanical wheel mouse
+        https://bugs.webkit.org/show_bug.cgi?id=142517
+
+        Reviewed by Simon Fraser.
+
+        * platform/cocoa/ScrollController.mm:
+        (WebCore::toWheelEventStatus): Recognize stateless mechanical wheel events.
+        (WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): If a mechanical wheel event is processed while
+        considering scroll snap logic, end any snap animations and clean up.
+        (WebCore::ScrollController::updateScrollSnapPoints): Don't begin tracking scroll snap state if there is not
+        scroll snap point defined in the markup.
+
 2015-03-09  Myles C. Maxfield  <mmaxfield@apple.com>
 
         REGRESSION(r176978): Inline-blocks with overflowing contents have ascents that are too large
index cafef75..6b052cf 100644 (file)
@@ -90,6 +90,7 @@ enum class WheelEventStatus {
     InertialScrollBegin,
     InertialScrolling,
     InertialScrollEnd,
+    StatelessScrollEvent,
     Unknown
 };
 
@@ -476,7 +477,10 @@ static inline WheelEventStatus toWheelEventStatus(PlatformWheelEventPhase phase,
                 
         case PlatformWheelEventPhaseEnded:
             return WheelEventStatus::InertialScrollEnd;
-                
+
+        case PlatformWheelEventPhaseNone:
+            return WheelEventStatus::StatelessScrollEvent;
+
         default:
             return WheelEventStatus::Unknown;
         }
@@ -540,7 +544,13 @@ void ScrollController::processWheelEventForScrollSnapOnAxis(ScrollEventAxis axis
         snapState.clearInitialWheelDeltaWindow();
         snapState.m_shouldOverrideWheelEvent = false;
         break;
-        
+
+    case WheelEventStatus::StatelessScrollEvent:
+        endScrollSnapAnimation(axis, ScrollSnapState::UserInteraction);
+        snapState.clearInitialWheelDeltaWindow();
+        snapState.m_shouldOverrideWheelEvent = false;
+        break;
+
     case WheelEventStatus::Unknown:
         ASSERT_NOT_REACHED();
         break;
@@ -588,10 +598,10 @@ void ScrollController::updateScrollSnapPoints(ScrollEventAxis axis, const Vector
 {
     // FIXME: Currently, scroll snap animators are recreated even though the snap offsets alone can be updated.
     if (axis == ScrollEventAxis::Horizontal)
-        m_horizontalScrollSnapState = std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Horizontal, snapPoints);
+        m_horizontalScrollSnapState = !snapPoints.isEmpty() ? std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Horizontal, snapPoints) : nullptr;
 
     if (axis == ScrollEventAxis::Vertical)
-        m_verticalScrollSnapState = std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Vertical, snapPoints);
+        m_verticalScrollSnapState = !snapPoints.isEmpty() ? std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Vertical, snapPoints) : nullptr;
 }
 
 void ScrollController::startScrollSnapTimer(ScrollEventAxis axis)