diff options
author | erikchen@chromium.org <erikchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-05 10:18:21 +0000 |
---|---|---|
committer | erikchen@chromium.org <erikchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-05 10:18:21 +0000 |
commit | 7c7a224a4378a350449e3ce47496338ad5fde7f6 (patch) | |
tree | f77ccfcb7cc47940f1817f32f46c37678b6c4509 | |
parent | db024825de7b10be6382b216c11cda7c8aa16af4 (diff) | |
download | chromium_src-7c7a224a4378a350449e3ce47496338ad5fde7f6.zip chromium_src-7c7a224a4378a350449e3ce47496338ad5fde7f6.tar.gz chromium_src-7c7a224a4378a350449e3ce47496338ad5fde7f6.tar.bz2 |
mac: History swipe arrow disappears slowly with magic mouse.
The history swipe arrow was being dismissed at the wrong time. It should be
dismissed as soon as the browser begins to navigate forwards or backwards. It
was being dismissed when the gesture completed, which takes ~1 second longer,
due to momentum swipe events that keep coming in after a user has let go.
This bug came from an incorrect revival of previously deleted code. This CL
fixes the newly introduced bug, but introduces a behavioral change. There are
3 possible end conditions for the history swipe:
1. PhaseEnded & navigation occurs
2. PhaseEnded & no navigation occurs
3. PhaseCancelled, no navigation occurs
There's no way for the user to differentiate 2&3, so the behavior between them
should be consistent. In the dead code, 1&2 had an animated dismissal of the
arrow, whereas 3 had an instant dismissal of the arrow. In this patch, I've
unified the logic to always use an animated dismissal of the arrow.
BUG=338206
Review URL: https://codereview.chromium.org/184813007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254997 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm index 9729a1d..788c6ca 100644 --- a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm +++ b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm @@ -330,9 +330,10 @@ static BOOL forceMagicMouse = NO; - (void)initiateMagicMouseHistorySwipe:(BOOL)isRightScroll event:(NSEvent*)event { // Released by the tracking handler once the gesture is complete. - HistoryOverlayController* historyOverlay = [[HistoryOverlayController alloc] - initForMode:isRightScroll ? kHistoryOverlayModeForward - : kHistoryOverlayModeBack]; + __block HistoryOverlayController* historyOverlay = + [[HistoryOverlayController alloc] + initForMode:isRightScroll ? kHistoryOverlayModeForward + : kHistoryOverlayModeBack]; // The way this API works: gestureAmount is between -1 and 1 (float). If // the user does the gesture for more than about 30% (i.e. < -0.3 or > @@ -359,43 +360,44 @@ static BOOL forceMagicMouse = NO; // in the wrong direction. forceMagicMouse = YES; [event trackSwipeEventWithOptions:NSEventSwipeTrackingLockDirection - dampenAmountThresholdMin:-1 - max:1 - usingHandler:^(CGFloat gestureAmount, - NSEventPhase phase, - BOOL isComplete, - BOOL *stop) { - if (phase == NSEventPhaseBegan) { - [historyOverlay - showPanelForView:[delegate_ viewThatWantsHistoryOverlay]]; - return; - } - - BOOL ended = phase == NSEventPhaseEnded; - - // Dismiss the panel before navigation for immediate visual feedback. - CGFloat progress = std::abs(gestureAmount) / 0.3; - BOOL finished = progress >= 1.0; - progress = MAX(0.0, progress); - progress = MIN(1.0, progress); - [historyOverlay setProgress:progress finished:finished]; - - // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice] - // automatically. - Browser* browser = - chrome::FindBrowserWithWindow(historyOverlay.view.window); - if (ended && browser) { - if (isRightScroll) - chrome::GoForward(browser, CURRENT_TAB); - else - chrome::GoBack(browser, CURRENT_TAB); - } - - if (isComplete) { - [historyOverlay dismiss]; - [historyOverlay release]; - } - }]; + dampenAmountThresholdMin:-1 + max:1 + usingHandler:^(CGFloat gestureAmount, + NSEventPhase phase, + BOOL isComplete, + BOOL* stop) { + if (phase == NSEventPhaseBegan) { + [historyOverlay + showPanelForView:[delegate_ viewThatWantsHistoryOverlay]]; + return; + } + + BOOL ended = phase == NSEventPhaseEnded; + + // Dismiss the panel before navigation for immediate visual feedback. + CGFloat progress = std::abs(gestureAmount) / 0.3; + BOOL finished = progress >= 1.0; + progress = MAX(0.0, progress); + progress = MIN(1.0, progress); + [historyOverlay setProgress:progress finished:finished]; + + // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice] + // automatically. + Browser* browser = + chrome::FindBrowserWithWindow(historyOverlay.view.window); + if (ended && browser) { + if (isRightScroll) + chrome::GoForward(browser, CURRENT_TAB); + else + chrome::GoBack(browser, CURRENT_TAB); + } + + if (ended || isComplete) { + [historyOverlay dismiss]; + [historyOverlay release]; + historyOverlay = nil; + } + }]; } // Checks if |theEvent| should trigger history swiping, and if so, does |